diff options
author | ckelsel <ckelsel@hotmail.com> | 2017-07-16 08:22:49 +0800 |
---|---|---|
committer | ckelsel <ckelsel@hotmail.com> | 2017-07-16 08:22:49 +0800 |
commit | cb95f71f71f665b21848cf25780d83278cd1dcf0 (patch) | |
tree | 4ebdf96b731ae839f8beb326e36dcb0b429bc453 /src | |
parent | 8cc49f9f1ad4edface62284c32f05ef1140d8220 (diff) | |
parent | 4dee942e732d41ad62b732c0a39719d9405bc928 (diff) | |
download | rneovim-cb95f71f71f665b21848cf25780d83278cd1dcf0.tar.gz rneovim-cb95f71f71f665b21848cf25780d83278cd1dcf0.tar.bz2 rneovim-cb95f71f71f665b21848cf25780d83278cd1dcf0.zip |
merge upstream/master
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/buffer.c | 125 | ||||
-rw-r--r-- | src/nvim/eval.c | 4 | ||||
-rw-r--r-- | src/nvim/ex_cmds.c | 7 | ||||
-rw-r--r-- | src/nvim/fileio.c | 18 | ||||
-rw-r--r-- | src/nvim/fileio.h | 15 | ||||
-rw-r--r-- | src/nvim/regexp_nfa.c | 26 | ||||
-rw-r--r-- | src/nvim/spell.c | 2 | ||||
-rw-r--r-- | src/nvim/testdir/Makefile | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test_regexp_utf8.vim | 15 | ||||
-rw-r--r-- | src/nvim/testdir/test_startup.vim | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test_startup_utf8.vim | 64 | ||||
-rw-r--r-- | src/nvim/tui/tui.c | 86 | ||||
-rw-r--r-- | src/nvim/version.h | 8 | ||||
-rw-r--r-- | src/nvim/vim.h | 4 | ||||
-rw-r--r-- | src/nvim/window.c | 18 |
15 files changed, 263 insertions, 133 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index b5ca6543c5..90a564bb6a 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -91,6 +91,57 @@ static char *e_auabort = N_("E855: Autocommands caused command to abort"); // Number of times free_buffer() was called. static int buf_free_count = 0; +// Read data from buffer for retrying. +static int +read_buffer( + int read_stdin, // read file from stdin, otherwise fifo + exarg_T *eap, // for forced 'ff' and 'fenc' or NULL + int flags) // extra flags for readfile() +{ + int retval = OK; + linenr_T line_count; + + // + // Read from the buffer which the text is already filled in and append at + // the end. This makes it possible to retry when 'fileformat' or + // 'fileencoding' was guessed wrong. + // + line_count = curbuf->b_ml.ml_line_count; + retval = readfile( + read_stdin ? NULL : curbuf->b_ffname, + read_stdin ? NULL : curbuf->b_fname, + (linenr_T)line_count, (linenr_T)0, (linenr_T)MAXLNUM, eap, + flags | READ_BUFFER); + if (retval == OK) { + // Delete the binary lines. + while (--line_count >= 0) { + ml_delete((linenr_T)1, false); + } + } else { + // Delete the converted lines. + while (curbuf->b_ml.ml_line_count > line_count) { + ml_delete(line_count, false); + } + } + // Put the cursor on the first line. + curwin->w_cursor.lnum = 1; + curwin->w_cursor.col = 0; + + if (read_stdin) { + // Set or reset 'modified' before executing autocommands, so that + // it can be changed there. + if (!readonlymode && !bufempty()) { + changed(); + } else if (retval != FAIL) { + unchanged(curbuf, false); + } + + apply_autocmds_retval(EVENT_STDINREADPOST, NULL, NULL, false, + curbuf, &retval); + } + return retval; +} + /* * Open current buffer, that is: open the memfile and read the file into * memory. @@ -106,6 +157,7 @@ open_buffer ( int retval = OK; bufref_T old_curbuf; long old_tw = curbuf->b_p_tw; + int read_fifo = false; /* * The 'readonly' flag is only set when BF_NEVERLOADED is being reset. @@ -156,13 +208,45 @@ open_buffer ( if (curbuf->b_ffname != NULL) { int old_msg_silent = msg_silent; +#ifdef UNIX + int save_bin = curbuf->b_p_bin; + int perm; + + perm = os_getperm((const char *)curbuf->b_ffname); + if (perm >= 0 && (0 +# ifdef S_ISFIFO + || S_ISFIFO(perm) +# endif +# ifdef S_ISSOCK + || S_ISSOCK(perm) +# endif +# ifdef OPEN_CHR_FILES + || (S_ISCHR(perm) + && is_dev_fd_file(curbuf->b_ffname)) +# endif + ) + ) { + read_fifo = true; + } + if (read_fifo) { + curbuf->b_p_bin = true; + } +#endif if (shortmess(SHM_FILEINFO)) { msg_silent = 1; } retval = readfile(curbuf->b_ffname, curbuf->b_fname, (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, eap, - flags | READ_NEW); + flags | READ_NEW | (read_fifo ? READ_FIFO : 0)); +#ifdef UNIX + if (read_fifo) { + curbuf->b_p_bin = save_bin; + if (retval == OK) { + retval = read_buffer(false, eap, flags); + } + } +#endif msg_silent = old_msg_silent; // Help buffer is filtered. @@ -171,7 +255,6 @@ open_buffer ( } } else if (read_stdin) { int save_bin = curbuf->b_p_bin; - linenr_T line_count; /* * First read the text in binary mode into the buffer. @@ -185,41 +268,13 @@ open_buffer ( flags | (READ_NEW + READ_STDIN)); curbuf->b_p_bin = save_bin; if (retval == OK) { - line_count = curbuf->b_ml.ml_line_count; - retval = readfile(NULL, NULL, (linenr_T)line_count, - (linenr_T)0, (linenr_T)MAXLNUM, eap, - flags | READ_BUFFER); - if (retval == OK) { - /* Delete the binary lines. */ - while (--line_count >= 0) - ml_delete((linenr_T)1, FALSE); - } else { - /* Delete the converted lines. */ - while (curbuf->b_ml.ml_line_count > line_count) - ml_delete(line_count, FALSE); - } - /* Put the cursor on the first line. */ - curwin->w_cursor.lnum = 1; - curwin->w_cursor.col = 0; - - // Set or reset 'modified' before executing autocommands, so that - // it can be changed there. - if (!readonlymode && !bufempty()) { - changed(); - } else if (retval == OK) { - unchanged(curbuf, false); - } - - if (retval == OK) { - apply_autocmds_retval(EVENT_STDINREADPOST, NULL, NULL, false, - curbuf, &retval); - } + retval = read_buffer(true, eap, flags); } } /* if first time loading this buffer, init b_chartab[] */ if (curbuf->b_flags & BF_NEVERLOADED) { - (void)buf_init_chartab(curbuf, FALSE); + (void)buf_init_chartab(curbuf, false); parse_cino(curbuf); } @@ -234,7 +289,7 @@ open_buffer ( || modified_was_set // ":set modified" used in autocmd || (aborting() && vim_strchr(p_cpo, CPO_INTMOD) != NULL)) { changed(); - } else if (retval == OK && !read_stdin) { + } else if (retval != FAIL && !read_stdin && !read_fifo) { unchanged(curbuf, false); } save_file_ff(curbuf); // keep this fileformat @@ -416,8 +471,8 @@ void close_buffer(win_T *win, buf_T *buf, int action, int abort_if_last) return; } - /* When the buffer becomes hidden, but is not unloaded, trigger - * BufHidden */ + // When the buffer becomes hidden, but is not unloaded, trigger + // BufHidden if (!unload_buf) { buf->b_locked++; if (apply_autocmds(EVENT_BUFHIDDEN, buf->b_fname, buf->b_fname, false, diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 7e9c006f33..e5bb7f1b38 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -12451,7 +12451,7 @@ static void f_matchadd(typval_T *argvars, typval_T *rettv, FunPtr fptr) return; } if (id >= 1 && id <= 3) { - EMSGN("E798: ID is reserved for \":match\": %" PRId64, id); + EMSGN(_("E798: ID is reserved for \":match\": %" PRId64), id); return; } @@ -12508,7 +12508,7 @@ static void f_matchaddpos(typval_T *argvars, typval_T *rettv, FunPtr fptr) // id == 3 is ok because matchaddpos() is supposed to substitute :3match if (id == 1 || id == 2) { - EMSGN("E798: ID is reserved for \"match\": %" PRId64, id); + EMSGN(_("E798: ID is reserved for \"match\": %" PRId64), id); return; } diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index b550e9a9c6..0987cb3915 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -5023,8 +5023,9 @@ static void helptags_one(char_u *dir, char_u *ext, char_u *tagfname, if (gen_expand_wildcards(1, buff_list, &filecount, &files, EW_FILE|EW_SILENT) == FAIL || filecount == 0) { - if (!got_int) - EMSG2("E151: No match: %s", NameBuff); + if (!got_int) { + EMSG2(_("E151: No match: %s"), NameBuff); + } return; } @@ -5223,7 +5224,7 @@ static void do_helptags(char_u *dirname, bool add_help_tags) if (gen_expand_wildcards(1, buff_list, &filecount, &files, EW_FILE|EW_SILENT) == FAIL || filecount == 0) { - EMSG2("E151: No match: %s", NameBuff); + EMSG2(_("E151: No match: %s"), NameBuff); xfree(dirname); return; } diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index be4188c4df..a0536d456d 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -247,6 +247,7 @@ void filemess(buf_T *buf, char_u *name, char_u *s, int attr) * stdin) * READ_DUMMY read into a dummy buffer (to check if file contents changed) * READ_KEEP_UNDO don't clear undo info or read it from a file + * READ_FIFO read from fifo/socket instead of a file * * return FAIL for failure, NOTDONE for directory (failure), or OK */ @@ -267,6 +268,7 @@ readfile ( int filtering = (flags & READ_FILTER); int read_stdin = (flags & READ_STDIN); int read_buffer = (flags & READ_BUFFER); + int read_fifo = (flags & READ_FIFO); int set_options = newfile || read_buffer || (eap != NULL && eap->read_edit); linenr_T read_buf_lnum = 1; /* next line to read from curbuf */ @@ -426,7 +428,7 @@ readfile ( } } - if (!read_buffer && !read_stdin) { + if (!read_buffer && !read_stdin && !read_fifo) { perm = os_getperm((const char *)fname); #ifdef UNIX // On Unix it is possible to read a directory, so we have to @@ -468,8 +470,8 @@ readfile ( if (check_readonly && !readonlymode) curbuf->b_p_ro = FALSE; - if (newfile && !read_stdin && !read_buffer) { - /* Remember time of file. */ + if (newfile && !read_stdin && !read_buffer && !read_fifo) { + // Remember time of file. FileInfo file_info; if (os_fileinfo((char *)fname, &file_info)) { buf_store_file_info(curbuf, &file_info); @@ -895,6 +897,7 @@ retry: * and we can't do it internally or with iconv(). */ if (fio_flags == 0 && !read_stdin && !read_buffer && *p_ccv != NUL + && !read_fifo # ifdef USE_ICONV && iconv_fd == (iconv_t)-1 # endif @@ -935,7 +938,7 @@ retry: /* Set "can_retry" when it's possible to rewind the file and try with * another "fenc" value. It's FALSE when no other "fenc" to try, reading * stdin or fixed at a specific encoding. */ - can_retry = (*fenc != NUL && !read_stdin && !keep_dest_enc); + can_retry = (*fenc != NUL && !read_stdin && !keep_dest_enc && !read_fifo); if (!skip_read) { linerest = 0; @@ -947,6 +950,7 @@ retry: && curbuf->b_ffname != NULL && curbuf->b_p_udf && !filtering + && !read_fifo && !read_stdin && !read_buffer); if (read_undo_file) @@ -1919,7 +1923,7 @@ failed: u_read_undo(NULL, hash, fname); } - if (!read_stdin && !read_buffer) { + if (!read_stdin && !read_fifo && (!read_buffer || sfname != NULL)) { int m = msg_scroll; int n = msg_scrolled; @@ -1937,7 +1941,7 @@ failed: if (filtering) { apply_autocmds_exarg(EVENT_FILTERREADPOST, NULL, sfname, false, curbuf, eap); - } else if (newfile) { + } else if (newfile || (read_buffer && sfname != NULL)) { apply_autocmds_exarg(EVENT_BUFREADPOST, NULL, sfname, false, curbuf, eap); if (!au_did_filetype && *curbuf->b_p_ft != NUL) { @@ -1970,7 +1974,7 @@ failed: /// Do not accept "/dev/fd/[012]", opening these may hang Vim. /// /// @param fname file name to check -static bool is_dev_fd_file(char_u *fname) +bool is_dev_fd_file(char_u *fname) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { return STRNCMP(fname, "/dev/fd/", 8) == 0 diff --git a/src/nvim/fileio.h b/src/nvim/fileio.h index 426dc0fcb3..8db4b89806 100644 --- a/src/nvim/fileio.h +++ b/src/nvim/fileio.h @@ -4,13 +4,14 @@ #include "nvim/buffer_defs.h" #include "nvim/os/os.h" -/* Values for readfile() flags */ -#define READ_NEW 0x01 /* read a file into a new buffer */ -#define READ_FILTER 0x02 /* read filter output */ -#define READ_STDIN 0x04 /* read from stdin */ -#define READ_BUFFER 0x08 /* read from curbuf (converting stdin) */ -#define READ_DUMMY 0x10 /* reading into a dummy buffer */ -#define READ_KEEP_UNDO 0x20 /* keep undo info*/ +// Values for readfile() flags +#define READ_NEW 0x01 // read a file into a new buffer +#define READ_FILTER 0x02 // read filter output +#define READ_STDIN 0x04 // read from stdin +#define READ_BUFFER 0x08 // read from curbuf (converting stdin) +#define READ_DUMMY 0x10 // reading into a dummy buffer +#define READ_KEEP_UNDO 0x20 // keep undo info +#define READ_FIFO 0x40 // read from fifo or socket #define READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y)) diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 24c156d2ba..491693a371 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -3913,7 +3913,7 @@ addstate ( int k; int found = FALSE; nfa_thread_T *thread; - lpos_T save_lpos; + struct multipos save_multipos; int save_in_use; char_u *save_ptr; int i; @@ -4127,15 +4127,13 @@ skip_add: /* avoid compiler warnings */ save_ptr = NULL; - save_lpos.lnum = 0; - save_lpos.col = 0; + memset(&save_multipos, 0, sizeof(save_multipos)); /* Set the position (with "off" added) in the subexpression. Save * and restore it when it was in use. Otherwise fill any gap. */ if (REG_MULTI) { if (subidx < sub->in_use) { - save_lpos.lnum = sub->list.multi[subidx].start_lnum; - save_lpos.col = sub->list.multi[subidx].start_col; + save_multipos = sub->list.multi[subidx]; save_in_use = -1; } else { save_in_use = sub->in_use; @@ -4178,9 +4176,8 @@ skip_add: sub = &subs->norm; if (save_in_use == -1) { - if (REG_MULTI){ - sub->list.multi[subidx].start_lnum = save_lpos.lnum; - sub->list.multi[subidx].start_col = save_lpos.col; + if (REG_MULTI) { + sub->list.multi[subidx] = save_multipos; } else sub->list.line[subidx].start = save_ptr; @@ -4234,8 +4231,7 @@ skip_add: if (sub->in_use <= subidx) sub->in_use = subidx + 1; if (REG_MULTI) { - save_lpos.lnum = sub->list.multi[subidx].end_lnum; - save_lpos.col = sub->list.multi[subidx].end_col; + save_multipos = sub->list.multi[subidx]; if (off == -1) { sub->list.multi[subidx].end_lnum = reglnum + 1; sub->list.multi[subidx].end_col = 0; @@ -4249,9 +4245,8 @@ skip_add: } else { save_ptr = sub->list.line[subidx].end; sub->list.line[subidx].end = reginput + off; - /* avoid compiler warnings */ - save_lpos.lnum = 0; - save_lpos.col = 0; + // avoid compiler warnings + memset(&save_multipos, 0, sizeof(save_multipos)); } subs = addstate(l, state->out, subs, pim, off_arg); @@ -4261,9 +4256,8 @@ skip_add: else sub = &subs->norm; - if (REG_MULTI){ - sub->list.multi[subidx].end_lnum = save_lpos.lnum; - sub->list.multi[subidx].end_col = save_lpos.col; + if (REG_MULTI) { + sub->list.multi[subidx] = save_multipos; } else sub->list.line[subidx].end = save_ptr; diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 715228cb4b..42c9bcc0ee 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -2068,7 +2068,7 @@ char_u *did_set_spelllang(win_T *wp) // destroying the buffer we are using... if (!bufref_valid(&bufref)) { ret_msg = - (char_u *)"E797: SpellFileMissing autocommand deleted buffer"; + (char_u *)N_("E797: SpellFileMissing autocommand deleted buffer"); goto theend; } } diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 7e55fffa06..510e8820f4 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -62,6 +62,8 @@ NEW_TESTS ?= \ test_signs.res \ test_smartindent.res \ test_stat.res \ + test_startup.res \ + test_startup_utf8.res \ test_substitute.res \ test_syntax.res \ test_tabpage.res \ diff --git a/src/nvim/testdir/test_regexp_utf8.vim b/src/nvim/testdir/test_regexp_utf8.vim index 7f3b31575d..a2f4286d4f 100644 --- a/src/nvim/testdir/test_regexp_utf8.vim +++ b/src/nvim/testdir/test_regexp_utf8.vim @@ -98,6 +98,21 @@ func Test_recursive_substitute() bwipe! endfunc +func Test_nested_backrefs() + " Check example in change.txt. + new + for re in range(0, 2) + exe 'set re=' . re + call setline(1, 'aa ab x') + 1s/\(\(a[a-d] \)*\)\(x\)/-\1- -\2- -\3-/ + call assert_equal('-aa ab - -ab - -x-', getline(1)) + + call assert_equal('-aa ab - -ab - -x-', substitute('aa ab x', '\(\(a[a-d] \)*\)\(x\)', '-\1- -\2- -\3-', '')) + endfor + bwipe! + set re=0 +endfunc + func Test_eow_with_optional() let expected = ['abc def', 'abc', 'def', '', '', '', '', '', '', ''] for re in range(0, 2) diff --git a/src/nvim/testdir/test_startup.vim b/src/nvim/testdir/test_startup.vim index 5996b2cd4a..64f7f31294 100644 --- a/src/nvim/testdir/test_startup.vim +++ b/src/nvim/testdir/test_startup.vim @@ -75,7 +75,7 @@ func Test_help_arg() " check if couple of lines are there let found = [] for line in lines - if line =~ '-R.*Readonly mode' + if line =~ '-R.*Read-only mode' call add(found, 'Readonly mode') endif " Watch out for a second --version line in the Gnome version. diff --git a/src/nvim/testdir/test_startup_utf8.vim b/src/nvim/testdir/test_startup_utf8.vim new file mode 100644 index 0000000000..d179a4cc79 --- /dev/null +++ b/src/nvim/testdir/test_startup_utf8.vim @@ -0,0 +1,64 @@ +" Tests for startup using utf-8. +if !has('multi_byte') + finish +endif + +source shared.vim + +func Test_read_stdin_utf8() + let linesin = ['テスト', '€ÀÈÌÒÙ'] + call writefile(linesin, 'Xtestin') + let before = [ + \ 'set enc=utf-8', + \ 'set fencs=cp932,utf-8', + \ ] + let after = [ + \ 'write ++enc=utf-8 Xtestout', + \ 'quit!', + \ ] + if has('win32') + let pipecmd = 'type Xtestin | ' + else + let pipecmd = 'cat Xtestin | ' + endif + if RunVimPiped(before, after, '-', pipecmd) + let lines = readfile('Xtestout') + call assert_equal(linesin, lines) + else + call assert_equal('', 'RunVimPiped failed.') + endif + call delete('Xtestout') + call delete('Xtestin') +endfunc + +func Test_read_fifo_utf8() + if !has('unix') + return + endif + " Using bash/zsh's process substitution. + if executable('bash') + set shell=bash + elseif executable('zsh') + set shell=zsh + else + return + endif + let linesin = ['テスト', '€ÀÈÌÒÙ'] + call writefile(linesin, 'Xtestin') + let before = [ + \ 'set enc=utf-8', + \ 'set fencs=cp932,utf-8', + \ ] + let after = [ + \ 'write ++enc=utf-8 Xtestout', + \ 'quit!', + \ ] + if RunVim(before, after, '<(cat Xtestin)') + let lines = readfile('Xtestout') + call assert_equal(linesin, lines) + else + call assert_equal('', 'RunVim failed.') + endif + call delete('Xtestout') + call delete('Xtestin') +endfunc diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index c6f4eff08f..ab78a72909 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1236,18 +1236,6 @@ static int unibi_find_ext_str(unibi_term *ut, const char *name) return -1; } -static int unibi_find_ext_bool(unibi_term *ut, const char *name) -{ - size_t max = unibi_count_ext_bool(ut); - for (size_t i = 0; i < max; i++) { - const char * n = unibi_get_ext_bool_name(ut, i); - if (n && 0 == strcmp(n, name)) { - return (int)i; - } - } - return -1; -} - /// Several entries in terminfo are known to be deficient or outright wrong, /// unfortunately; and several terminal emulators falsely announce incorrect /// terminal types. So patch the terminfo records after loading from an @@ -1389,14 +1377,21 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, // No bugs in the vanilla terminfo for our purposes. } -#define XTERM_SETAF_256 \ +// At this time (2017-07-12) it seems like all terminals that support 256 +// color codes can use semicolons in the terminal code and be fine. +// However, this is not correct according to the spec. So to reward those +// terminals that also support colons, we output the code that way on these +// specific ones. + +// using colons like ISO 8613-6:1994/ITU T.416:1993 says. +#define XTERM_SETAF_256_COLON \ "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38:5:%p1%d%;m" -#define XTERM_SETAB_256 \ +#define XTERM_SETAB_256_COLON \ "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48:5:%p1%d%;m" - // "standard" means using colons like ISO 8613-6:1994/ITU T.416:1993 says. -#define XTERM_SETAF_256_NONSTANDARD \ + +#define XTERM_SETAF_256 \ "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m" -#define XTERM_SETAB_256_NONSTANDARD \ +#define XTERM_SETAB_256 \ "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m" #define XTERM_SETAF_16 \ "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e39%;m" @@ -1410,8 +1405,8 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, // more on this. if (true_xterm || iterm || iterm_pretending_xterm) { unibi_set_num(ut, unibi_max_colors, 256); - unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF_256); - unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB_256); + unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF_256_COLON); + unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB_256_COLON); } else if (konsole || xterm || gnome || rxvt || st || putty || linuxvt // Linux 4.8+ supports 256-colour SGR. || mate_pretending_xterm || gnome_pretending_xterm @@ -1420,8 +1415,8 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, || (term && strstr(term, "256")) ) { unibi_set_num(ut, unibi_max_colors, 256); - unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF_256_NONSTANDARD); - unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB_256_NONSTANDARD); + unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF_256); + unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB_256); } } // Terminals where there is actually 16-colour SGR support despite what @@ -1536,26 +1531,20 @@ static void augment_terminfo(TUIData *data, const char *term, const char *colorterm, long vte_version, bool konsole, bool iterm_env) { unibi_term *ut = data->ut; - const char * xterm_version = os_getenv("XTERM_VERSION"); bool xterm = terminfo_is_term_family(term, "xterm"); bool dtterm = terminfo_is_term_family(term, "dtterm"); - bool linuxvt = terminfo_is_term_family(term, "linux"); bool rxvt = terminfo_is_term_family(term, "rxvt"); bool teraterm = terminfo_is_term_family(term, "teraterm"); bool putty = terminfo_is_term_family(term, "putty"); bool screen = terminfo_is_term_family(term, "screen"); - bool tmux = terminfo_is_term_family(term, "tmux"); - bool st = terminfo_is_term_family(term, "st"); - bool gnome = terminfo_is_term_family(term, "gnome") - || terminfo_is_term_family(term, "vte"); bool iterm = terminfo_is_term_family(term, "iterm") || terminfo_is_term_family(term, "iTerm.app"); // None of the following work over SSH; see :help TERM . bool iterm_pretending_xterm = xterm && iterm_env; - bool true_xterm = xterm && !!xterm_version; bool tmux_wrap = screen && !!os_getenv("TMUX"); - bool old_truecolor_env = colorterm - && (0 == strcmp(colorterm, "truecolor") || 0 == strcmp(colorterm, "24bit")); + + const char * xterm_version = os_getenv("XTERM_VERSION"); + bool true_xterm = xterm && !!xterm_version; // Only define this capability for terminal types that we know understand it. if (dtterm // originated this extension @@ -1576,40 +1565,37 @@ static void augment_terminfo(TUIData *data, const char *term, // them to terminal types, that do actually have such control sequences but // lack the correct definitions in terminfo, is an augmentation, not a // fixup. See https://gist.github.com/XVilka/8346728 for more about this. - int Tc = unibi_find_ext_bool(ut, "Tc"); - // "standard" means using colons like ISO 8613-6:1994/ITU T.416:1993 says. - bool has_standard_rgb = false + + // At this time (2017-07-12) it seems like all terminals that support rgb + // color codes can use semicolons in the terminal code and be fine. + // However, this is not correct according to the spec. So to reward those + // terminals that also support colons, we output the code that way on these + // specific ones. + + // can use colons like ISO 8613-6:1994/ITU T.416:1993 says. + bool has_colon_rgb = false // per GNOME bug #685759 and bug #704449 - || ((gnome || xterm) && (vte_version >= 3600)) + || (vte_version >= 3600) || iterm || iterm_pretending_xterm // per analysis of VT100Terminal.m // per http://invisible-island.net/xterm/xterm.log.html#xterm_282 || true_xterm; - bool has_non_standard_rgb = -1 != Tc - // terminfo is definitive if it says something. - ? unibi_get_ext_bool(ut, (size_t)Tc) - : linuxvt // Linux 4.8+ supports true-colour SGR. - || konsole // per commentary in VT102Emulation.cpp - // per http://lists.schmorp.de/pipermail/rxvt-unicode/2016q2/002261.html - || rxvt - || tmux // per experimentation - || st // per experimentation - || old_truecolor_env; + data->unibi_ext.set_rgb_foreground = unibi_find_ext_str(ut, "setrgbf"); if (-1 == data->unibi_ext.set_rgb_foreground) { - if (has_standard_rgb) { + if (has_colon_rgb) { data->unibi_ext.set_rgb_foreground = (int)unibi_add_ext_str(ut, "setrgbf", "\x1b[38:2:%p1%d:%p2%d:%p3%dm"); - } else if (has_non_standard_rgb) { + } else { data->unibi_ext.set_rgb_foreground = (int)unibi_add_ext_str(ut, "setrgbf", "\x1b[38;2;%p1%d;%p2%d;%p3%dm"); } } data->unibi_ext.set_rgb_background = unibi_find_ext_str(ut, "setrgbb"); if (-1 == data->unibi_ext.set_rgb_background) { - if (has_standard_rgb) { + if (has_colon_rgb) { data->unibi_ext.set_rgb_background = (int)unibi_add_ext_str(ut, "setrgbb", "\x1b[48:2:%p1%d:%p2%d:%p3%dm"); - } else if (has_non_standard_rgb) { + } else { data->unibi_ext.set_rgb_background = (int)unibi_add_ext_str(ut, "setrgbb", "\x1b[48;2;%p1%d;%p2%d;%p3%dm"); } @@ -1621,7 +1607,9 @@ static void augment_terminfo(TUIData *data, const char *term, // would use a tmux control sequence and an extra if(screen) test. data->unibi_ext.set_cursor_color = (int)unibi_add_ext_str( ut, NULL, TMUX_WRAP(tmux_wrap, "\033]Pl%p1%06x\033\\")); - } else if (xterm) { + } else if (xterm || (vte_version != 0) || rxvt) { + // This seems to be supported for a long time in VTE + // urxvt also supports this data->unibi_ext.set_cursor_color = (int)unibi_add_ext_str( ut, NULL, "\033]12;#%p1%06x\007"); } diff --git a/src/nvim/version.h b/src/nvim/version.h index a0babfb156..c10f6fa534 100644 --- a/src/nvim/version.h +++ b/src/nvim/version.h @@ -10,14 +10,14 @@ extern char* longVersion; // // Vim version number, name, etc. Patchlevel is defined in version.c. // -#define VIM_VERSION_MAJOR 7 -#define VIM_VERSION_MINOR 4 +#define VIM_VERSION_MAJOR 8 +#define VIM_VERSION_MINOR 0 #define VIM_VERSION_100 (VIM_VERSION_MAJOR * 100 + VIM_VERSION_MINOR) // used for the runtime directory name -#define VIM_VERSION_NODOT "vim74" +#define VIM_VERSION_NODOT "vim80" // swap file compatibility (max. length is 6 chars) -#define VIM_VERSION_SHORT "7.4" +#define VIM_VERSION_SHORT "8.0" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "version.h.generated.h" diff --git a/src/nvim/vim.h b/src/nvim/vim.h index f29ccdd296..5d2c27a2f4 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -319,4 +319,8 @@ enum { FOLD_TEXT_LEN = 51 }; //!< buffer size for get_foldtext() // Lowest number used for window ID. Cannot have this many windows per tab. #define LOWEST_WIN_ID 1000 +#if defined(__FreeBSD__) && defined(S_ISCHR) +# define OPEN_CHR_FILES +#endif + #endif /* NVIM_VIM_H */ diff --git a/src/nvim/window.c b/src/nvim/window.c index 43af2e5e4f..29f5412ba0 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -5532,8 +5532,8 @@ int match_add(win_T *wp, const char *const grp, const char *const pat, return -1; } if (id < -1 || id == 0) { - EMSGN("E799: Invalid ID: %" PRId64 - " (must be greater than or equal to 1)", + EMSGN(_("E799: Invalid ID: %" PRId64 + " (must be greater than or equal to 1)"), id); return -1; } @@ -5541,7 +5541,7 @@ int match_add(win_T *wp, const char *const grp, const char *const pat, cur = wp->w_match_head; while (cur != NULL) { if (cur->id == id) { - EMSGN("E801: ID already taken: %" PRId64, id); + EMSGN(_("E801: ID already taken: %" PRId64), id); return -1; } cur = cur->next; @@ -5705,10 +5705,11 @@ int match_delete(win_T *wp, int id, int perr) int rtype = SOME_VALID; if (id < 1) { - if (perr == TRUE) - EMSGN("E802: Invalid ID: %" PRId64 - " (must be greater than or equal to 1)", + if (perr) { + EMSGN(_("E802: Invalid ID: %" PRId64 + " (must be greater than or equal to 1)"), id); + } return -1; } while (cur != NULL && cur->id != id) { @@ -5716,8 +5717,9 @@ int match_delete(win_T *wp, int id, int perr) cur = cur->next; } if (cur == NULL) { - if (perr == TRUE) - EMSGN("E803: ID not found: %" PRId64, id); + if (perr) { + EMSGN(_("E803: ID not found: %" PRId64), id); + } return -1; } if (cur == prev) |