From 5cf3dec9a98717d171e15729d9320d9ebe5ba7eb Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Thu, 26 Feb 2015 23:28:56 -0300 Subject: syntax: Fix possible invalid read in hl_combine_attr --- src/nvim/syntax.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/nvim/syntax.c') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 0da79cb8ae..c339468233 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -6723,6 +6723,10 @@ int hl_combine_attr(int char_attr, int prim_attr) return prim_attr; } + if (prim_attr == 0) { + return char_attr; + } + // Find the entry for char_attr char_aep = syn_cterm_attr2entry(char_attr); -- cgit From cdedd89d228a016a4e433968702e9e3ce5165e7d Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Sun, 8 Mar 2015 08:58:31 -0300 Subject: terminal: New module that implements a terminal emulator This commit integrates libvterm with Neovim and implements a terminal emulator with nvim buffers as the display mechanism. Terminal buffers can be created using any of the following methods: - Opening a file with name following the "term://[${cwd}//[${pid}:]]${cmd}" URI pattern where: - cwd is the working directory of the process - pid is the process id. This is just for use in session files where a pid would have been assigned to the saved buffer title. - cmd is the command to run - Invoking the `:terminal` ex command - Invoking the `termopen` function which returns a job id for automating the terminal window. Some extra changes were also implemented to adapt with terminal buffers. Here's an overview: - The `main` function now sets a BufReadCmd autocmd to intercept the term:// URI and spawn the terminal buffer instead of reading the file. - terminal buffers behave as if the following local buffer options were set: - `nomodifiable` - `swapfile` - `undolevels=-1` - `bufhidden=hide` - All commands that delete buffers(`:bun`, `:bd` and `:bw`) behave the same for terminal buffers, but only work when bang is passed(eg: `:bwipeout!`) - A new "terminal" mode was added. A consequence is that a new set of mapping commands were implemented with the "t" prefix(tmap, tunmap, tnoremap...) - The `edit` function(which enters insert mode) will actually enter terminal mode if the current buffer is a terminal - The `put` operator was adapted to send data to the terminal instead of modifying the buffer directly. - A window being resized will also trigger a terminal resize if the window displays the terminal. --- src/nvim/syntax.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/nvim/syntax.c') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index c339468233..20bfbc8db4 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -40,10 +40,12 @@ #include "nvim/option.h" #include "nvim/os_unix.h" #include "nvim/path.h" +#include "nvim/macros.h" #include "nvim/regexp.h" #include "nvim/screen.h" #include "nvim/strings.h" #include "nvim/syntax_defs.h" +#include "nvim/terminal.h" #include "nvim/ui.h" #include "nvim/os/os.h" #include "nvim/os/time.h" @@ -6636,7 +6638,7 @@ static garray_T attr_table = GA_EMPTY_INIT_VALUE; * if the combination is new. * Return 0 for error. */ -static int get_attr_entry(attrentry_T *aep) +int get_attr_entry(attrentry_T *aep) { garray_T *table = &attr_table; attrentry_T *taep; @@ -7424,7 +7426,6 @@ char_u *get_highlight_name(expand_T *xp, int idx) return HL_TABLE()[idx].sg_name; } -#define RGB(r, g, b) ((r << 16) | (g << 8) | b) color_name_table_T color_name_table[] = { // Color names taken from // http://www.rapidtables.com/web/color/RGB_Color.htm -- cgit