diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 66 | ||||
-rw-r--r-- | src/nvim/globals.h | 2 | ||||
-rw-r--r-- | src/nvim/memline.c | 7 | ||||
-rw-r--r-- | src/nvim/message.c | 2 | ||||
-rw-r--r-- | src/nvim/mouse.c | 76 | ||||
-rw-r--r-- | src/nvim/os/fileio.c | 1 | ||||
-rw-r--r-- | src/nvim/os/fs.c | 1 | ||||
-rw-r--r-- | src/nvim/os/pty_process_unix.c | 1 | ||||
-rw-r--r-- | src/nvim/syntax.c | 18 | ||||
-rw-r--r-- | src/nvim/testdir/Makefile | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test30.in | 230 | ||||
-rw-r--r-- | src/nvim/testdir/test30.ok | 130 | ||||
-rw-r--r-- | src/nvim/version.c | 2 |
13 files changed, 134 insertions, 403 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 7fb7969783..824b298592 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -6727,7 +6727,6 @@ static struct fst { { "byteidx", 2, 2, f_byteidx }, { "byteidxcomp", 2, 2, f_byteidxcomp }, { "call", 2, 3, f_call }, - { "capture", 1, 1, f_capture }, { "ceil", 1, 1, f_ceil }, { "changenr", 0, 0, f_changenr }, { "char2nr", 1, 2, f_char2nr }, @@ -6756,6 +6755,7 @@ static struct fst { { "eval", 1, 1, f_eval }, { "eventhandler", 0, 0, f_eventhandler }, { "executable", 1, 1, f_executable }, + { "execute", 1, 1, f_execute }, { "exepath", 1, 1, f_exepath }, { "exists", 1, 1, f_exists }, { "exp", 1, 1, f_exp }, @@ -8153,38 +8153,6 @@ static void f_call(typval_T *argvars, typval_T *rettv) (void)func_call(func, &argvars[1], selfdict, rettv); } -// "capture(command)" function -static void f_capture(typval_T *argvars, typval_T *rettv) -{ - int save_msg_silent = msg_silent; - garray_T *save_capture_ga = capture_ga; - - if (check_secure()) { - return; - } - - garray_T capture_local; - capture_ga = &capture_local; - ga_init(capture_ga, (int)sizeof(char), 80); - - msg_silent++; - if (argvars[0].v_type != VAR_LIST) { - do_cmdline_cmd((char *)get_tv_string(&argvars[0])); - } else if (argvars[0].vval.v_list != NULL) { - for (listitem_T *li = argvars[0].vval.v_list->lv_first; - li != NULL; li = li->li_next) { - do_cmdline_cmd((char *)get_tv_string(&li->li_tv)); - } - } - msg_silent = save_msg_silent; - - ga_append(capture_ga, NUL); - rettv->v_type = VAR_STRING; - rettv->vval.v_string = capture_ga->ga_data; - - capture_ga = save_capture_ga; -} - /* * "ceil({float})" function */ @@ -8869,6 +8837,38 @@ static void f_executable(typval_T *argvars, typval_T *rettv) || (gettail_dir(name) != name && os_can_exe(name, NULL, false)); } +// "execute(command)" function +static void f_execute(typval_T *argvars, typval_T *rettv) +{ + int save_msg_silent = msg_silent; + garray_T *save_capture_ga = capture_ga; + + if (check_secure()) { + return; + } + + garray_T capture_local; + capture_ga = &capture_local; + ga_init(capture_ga, (int)sizeof(char), 80); + + msg_silent++; + if (argvars[0].v_type != VAR_LIST) { + do_cmdline_cmd((char *)get_tv_string(&argvars[0])); + } else if (argvars[0].vval.v_list != NULL) { + for (listitem_T *li = argvars[0].vval.v_list->lv_first; + li != NULL; li = li->li_next) { + do_cmdline_cmd((char *)get_tv_string(&li->li_tv)); + } + } + msg_silent = save_msg_silent; + + ga_append(capture_ga, NUL); + rettv->v_type = VAR_STRING; + rettv->vval.v_string = capture_ga->ga_data; + + capture_ga = save_capture_ga; +} + /// "exepath()" function static void f_exepath(typval_T *argvars, typval_T *rettv) { diff --git a/src/nvim/globals.h b/src/nvim/globals.h index f2610ac868..950ceb4c74 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -986,7 +986,7 @@ EXTERN int redir_off INIT(= false); // no redirection for a moment EXTERN FILE *redir_fd INIT(= NULL); // message redirection file EXTERN int redir_reg INIT(= 0); // message redirection register EXTERN int redir_vname INIT(= 0); // message redirection variable -EXTERN garray_T *capture_ga INIT(= NULL); // capture() buffer +EXTERN garray_T *capture_ga INIT(= NULL); // captured output for execute() EXTERN char_u langmap_mapchar[256]; /* mapping for language keys */ diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 673205f08f..08e82071d7 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -3165,9 +3165,10 @@ attention_message ( } /* Some of these messages are long to allow translation to * other languages. */ - MSG_PUTS(_( - "\n(1) Another program may be editing the same file. If this is the case,\n be careful not to end up with two different instances of the same\n file when making changes.")); - MSG_PUTS(_(" Quit, or continue with caution.\n")); + MSG_PUTS(_("\n(1) Another program may be editing the same file. If this is" + " the case,\n be careful not to end up with two different" + " instances of the same\n file when making changes." + " Quit, or continue with caution.\n")); MSG_PUTS(_("(2) An edit session for this file crashed.\n")); MSG_PUTS(_(" If this is the case, use \":recover\" or \"vim -r ")); msg_outtrans(buf->b_fname); diff --git a/src/nvim/message.c b/src/nvim/message.c index 77e8f0e4f2..3c310ed309 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -2396,7 +2396,7 @@ static void redir_write(char_u *str, int maxlen) return; } - // Append output to capture(). + // Append output for execute(). if (capture_ga) { size_t len = 0; while (str[len] && (maxlen < 0 ? 1 : (len < (size_t)maxlen))) { diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c index 2f499e477c..5efac2623c 100644 --- a/src/nvim/mouse.c +++ b/src/nvim/mouse.c @@ -6,6 +6,7 @@ #include "nvim/window.h" #include "nvim/strings.h" #include "nvim/screen.h" +#include "nvim/syntax.h" #include "nvim/ui.h" #include "nvim/os_unix.h" #include "nvim/fold.h" @@ -303,6 +304,10 @@ retnomove: mouse_past_bottom = true; } + if (!(flags & MOUSE_RELEASED) && which_button == MOUSE_LEFT) { + col = mouse_adjust_click(curwin, row, col); + } + // Start Visual mode before coladvance(), for when 'sel' != "old" if ((flags & MOUSE_MAY_VIS) && !VIsual_active) { check_visual_highlight(); @@ -597,3 +602,74 @@ bool mouse_scroll_horiz(int dir) return leftcol_changed(); } + +// Adjust the clicked column position if there are concealed characters +// before the current column. But only when it's absolutely necessary. +static int mouse_adjust_click(win_T *wp, int row, int col) +{ + if (!(wp->w_p_cole > 0 && curbuf->b_p_smc > 0 + && wp->w_leftcol < curbuf->b_p_smc && conceal_cursor_line(wp))) { + return col; + } + + int end = (colnr_T)STRLEN(ml_get(wp->w_cursor.lnum)); + int vend = getviscol2(end, 0); + + if (col >= vend) { + return col; + } + + int i = wp->w_leftcol; + + if (row > 0) { + i += row * (wp->w_width - win_col_off(wp) - win_col_off2(wp) + - wp->w_leftcol) + wp->w_skipcol; + } + + int start_col = i; + int matchid; + int last_matchid; + int bcol = end - (vend - col); + + while (i < bcol) { + matchid = syn_get_concealed_id(wp, wp->w_cursor.lnum, i); + + if (matchid != 0) { + if (wp->w_p_cole == 3) { + bcol++; + } else { + if (row > 0 && i == start_col) { + // Check if the current concealed character is actually part of + // the previous wrapped row's conceal group. + last_matchid = syn_get_concealed_id(wp, wp->w_cursor.lnum, + i - 1); + if (last_matchid == matchid) { + bcol++; + } + } else if (wp->w_p_cole == 1 + || (wp->w_p_cole == 2 + && (lcs_conceal != NUL + || syn_get_sub_char() != NUL))) { + // At least one placeholder character will be displayed. + bcol--; + } + + last_matchid = matchid; + + // Adjust for concealed text that spans more than one character. + do { + i++; + bcol++; + matchid = syn_get_concealed_id(wp, wp->w_cursor.lnum, i); + } while (last_matchid == matchid); + + continue; + } + } + + i++; + } + + return getviscol2(bcol, 0); +} + diff --git a/src/nvim/os/fileio.c b/src/nvim/os/fileio.c index 6cee102305..cf5bfd60ae 100644 --- a/src/nvim/os/fileio.c +++ b/src/nvim/os/fileio.c @@ -4,7 +4,6 @@ /// Neovim stuctures for buffer, with autocommands, etc: just fopen/fread/fwrite /// replacement. -#include <unistd.h> #include <assert.h> #include <stddef.h> #include <stdbool.h> diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index d12d34d595..8c1c80bfad 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -3,7 +3,6 @@ #include <stddef.h> #include <assert.h> #include <limits.h> -#include <unistd.h> #include <fcntl.h> #include <errno.h> diff --git a/src/nvim/os/pty_process_unix.c b/src/nvim/os/pty_process_unix.c index 436de030ba..b57a69b82b 100644 --- a/src/nvim/os/pty_process_unix.c +++ b/src/nvim/os/pty_process_unix.c @@ -3,7 +3,6 @@ #include <stdlib.h> #include <string.h> -#include <unistd.h> #include <termios.h> #include <sys/types.h> #include <sys/wait.h> diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 27855184df..3215f7ea14 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -5661,6 +5661,24 @@ int get_syntax_info(int *seqnrp) return current_flags; } + +/// Get the sequence number of the concealed file position. +/// +/// @return seqnr if the file position is concealed, 0 otherwise. +int syn_get_concealed_id(win_T *wp, linenr_T lnum, colnr_T col) +{ + int seqnr; + int syntax_flags; + + (void)syn_get_id(wp, lnum, col, false, NULL, false); + syntax_flags = get_syntax_info(&seqnr); + + if (syntax_flags & HL_CONCEAL) { + return seqnr; + } + return 0; +} + /* * Return conceal substitution character */ diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index fb0079111c..9a0bba83fe 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -14,7 +14,6 @@ SCRIPTS := \ test14.out \ test17.out \ test24.out \ - test30.out \ test32.out \ test37.out \ test40.out \ diff --git a/src/nvim/testdir/test30.in b/src/nvim/testdir/test30.in deleted file mode 100644 index 56d5d5c6c2..0000000000 --- a/src/nvim/testdir/test30.in +++ /dev/null @@ -1,230 +0,0 @@ -Test for a lot of variations of the 'fileformats' option - -Note: This test will fail if "cat" is not available. - -STARTTEST -:" first write three test files, one in each format -:set fileformat=unix -:set fileformats= -:/^unix/;/eof/-1w! XXUnix -:/^dos/;/eof/-1w! XXDos -:set bin noeol -:$w! XXMac -Gonoeol -:$w! XXEol -:set nobin eol -:enew! -:bwipe XXUnix XXDos XXMac -:" create mixed format files -:if has("win32") -: !copy /b XXUnix+XXDos XXUxDs -: !copy /b XXUnix+XXMac XXUxMac -: !copy /b XXDos+XXMac XXDosMac -: !copy /b XXMac+XXEol XXMacEol -: !copy /b XXUnix+XXDos+XXMac XXUxDsMc -:else -: !cat XXUnix XXDos >XXUxDs -: !cat XXUnix XXMac >XXUxMac -: !cat XXDos XXMac >XXDosMac -: !cat XXMac XXEol >XXMacEol -: !cat XXUnix XXDos XXMac >XXUxDsMc -:endif -:" -:" try reading and writing with 'fileformats' empty -:set fileformat=unix -:e! XXUnix -:w! test.out -:e! XXDos -:w! XXtt01 -:e! XXMac -:w! XXtt02 -:bwipe XXUnix XXDos XXMac -:set fileformat=dos -:e! XXUnix -:w! XXtt11 -:e! XXDos -:w! XXtt12 -:e! XXMac -:w! XXtt13 -:bwipe XXUnix XXDos XXMac -:set fileformat=mac -:e! XXUnix -:w! XXtt21 -:e! XXDos -:w! XXtt22 -:e! XXMac -:w! XXtt23 -:bwipe XXUnix XXDos XXMac -:" -:" try reading and writing with 'fileformats' set to one format -:set fileformats=unix -:e! XXUxDsMc -:w! XXtt31 -:bwipe XXUxDsMc -:set fileformats=dos -:e! XXUxDsMc -:w! XXtt32 -:bwipe XXUxDsMc -:set fileformats=mac -:e! XXUxDsMc -:w! XXtt33 -:bwipe XXUxDsMc -:" -:" try reading and writing with 'fileformats' set to two formats -:set fileformats=unix,dos -:e! XXUxDsMc -:w! XXtt41 -:bwipe XXUxDsMc -:e! XXUxMac -:w! XXtt42 -:bwipe XXUxMac -:e! XXDosMac -:w! XXtt43 -:bwipe XXDosMac -:set fileformats=unix,mac -:e! XXUxDs -:w! XXtt51 -:bwipe XXUxDs -:e! XXUxDsMc -:w! XXtt52 -:bwipe XXUxDsMc -:e! XXDosMac -:w! XXtt53 -:bwipe XXDosMac -:e! XXEol -ggO=&ffs -:=&ff -:w! XXtt54 -:bwipe XXEol -:set fileformats=dos,mac -:e! XXUxDs -:w! XXtt61 -:bwipe XXUxDs -:e! XXUxMac -ggO=&ffs -:=&ff -:w! XXtt62 -:bwipe XXUxMac -:e! XXUxDsMc -:w! XXtt63 -:bwipe XXUxDsMc -:e! XXMacEol -ggO=&ffs -:=&ff -:w! XXtt64 -:bwipe XXMacEol -:" -:" try reading and writing with 'fileformats' set to three formats -:set fileformats=unix,dos,mac -:e! XXUxDsMc -:w! XXtt71 -:bwipe XXUxDsMc -:e! XXEol -ggO=&ffs -:=&ff -:w! XXtt72 -:bwipe XXEol -:set fileformats=mac,dos,unix -:e! XXUxDsMc -:w! XXtt81 -:bwipe XXUxDsMc -:e! XXEol -ggO=&ffs -:=&ff -:w! XXtt82 -:bwipe XXEol -:" try with 'binary' set -:set fileformats=mac,unix,dos -:set binary -:e! XXUxDsMc -:w! XXtt91 -:bwipe XXUxDsMc -:set fileformats=mac -:e! XXUxDsMc -:w! XXtt92 -:bwipe XXUxDsMc -:set fileformats=dos -:e! XXUxDsMc -:w! XXtt93 -:" -:" Append "END" to each file so that we can see what the last written char was. -:set fileformat=unix nobin -ggdGaEND:w >>XXtt01 -:w >>XXtt02 -:w >>XXtt11 -:w >>XXtt12 -:w >>XXtt13 -:w >>XXtt21 -:w >>XXtt22 -:w >>XXtt23 -:w >>XXtt31 -:w >>XXtt32 -:w >>XXtt33 -:w >>XXtt41 -:w >>XXtt42 -:w >>XXtt43 -:w >>XXtt51 -:w >>XXtt52 -:w >>XXtt53 -:w >>XXtt54 -:w >>XXtt61 -:w >>XXtt62 -:w >>XXtt63 -:w >>XXtt64 -:w >>XXtt71 -:w >>XXtt72 -:w >>XXtt81 -:w >>XXtt82 -:w >>XXtt91 -:w >>XXtt92 -:w >>XXtt93 -:" -:" Concatenate the results. -:" Make fileformat of test.out the native fileformat. -:" Add a newline at the end. -:set binary -:e! test.out -:$r XXtt01 -:$r XXtt02 -Go1:$r XXtt11 -:$r XXtt12 -:$r XXtt13 -Go2:$r XXtt21 -:$r XXtt22 -:$r XXtt23 -Go3:$r XXtt31 -:$r XXtt32 -:$r XXtt33 -Go4:$r XXtt41 -:$r XXtt42 -:$r XXtt43 -Go5:$r XXtt51 -:$r XXtt52 -:$r XXtt53 -:$r XXtt54 -Go6:$r XXtt61 -:$r XXtt62 -:$r XXtt63 -:$r XXtt64 -Go7:$r XXtt71 -:$r XXtt72 -Go8:$r XXtt81 -:$r XXtt82 -Go9:$r XXtt91 -:$r XXtt92 -:$r XXtt93 -Go10:$r XXUnix -:set nobinary ff& -:w -:qa! -ENDTEST - -unix -unix -eof - -dos
-dos
-eof - -mac
mac
diff --git a/src/nvim/testdir/test30.ok b/src/nvim/testdir/test30.ok deleted file mode 100644 index b35f4f5904..0000000000 --- a/src/nvim/testdir/test30.ok +++ /dev/null @@ -1,130 +0,0 @@ -unix -unix -dos
-dos
-END -mac
mac
-END -1 -unix
-unix
-END -dos
-dos
-END -mac
mac
-END -2 -unix -unix -
END -dos
-dos
-
END -mac
mac
END -3 -unix -unix -dos
-dos
-mac
mac
-END -unix
-unix
-dos
-dos
-mac
mac
-END -unix -unix -dos
-dos
-mac
mac
END -4 -unix -unix -dos
-dos
-mac
mac
-END -unix -unix -mac
mac
-END -dos
-dos
-mac
mac
-END -5 -unix -unix -dos
-dos
-END -unix -unix -dos
-dos
-mac
mac
-END -dos
-dos
-mac
mac
END -unix,mac:unix -noeol -END -6 -unix
-unix
-dos
-dos
-END -dos,mac:dos
-unix
-unix
-mac
mac
-END -unix
-unix
-dos
-dos
-mac
mac
-END -dos,mac:mac
mac
mac
noeol
END -7 -unix -unix -dos
-dos
-mac
mac
-END -unix,dos,mac:unix -noeol -END -8 -unix -unix -dos
-dos
-mac
mac
-END -mac,dos,unix:mac
noeol
END -9 -unix -unix -dos
-dos
-mac
mac
END -unix -unix -dos
-dos
-mac
mac
END -unix -unix -dos
-dos
-mac
mac
END -10 -unix -unix diff --git a/src/nvim/version.c b/src/nvim/version.c index 4cb3717133..d0af76ac8b 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -1040,7 +1040,7 @@ static int included_patches[] = { // 1240 NA // 1239 NA // 1238 NA - // 1237, + 1237, 1236, // 1235 NA // 1234 NA |