diff options
author | chemzqm <chemzqm@gmail.com> | 2016-11-26 07:39:33 +0800 |
---|---|---|
committer | chemzqm <chemzqm@gmail.com> | 2016-11-30 22:20:06 +0800 |
commit | 3cf4b14e966ec04371d38af6451bc69eaadb425b (patch) | |
tree | 5848aad84944276debad27d09af204b0ce7c6784 | |
parent | ecd7beb6e4876961075cc211d2b92f987d670dfa (diff) | |
download | rneovim-3cf4b14e966ec04371d38af6451bc69eaadb425b.tar.gz rneovim-3cf4b14e966ec04371d38af6451bc69eaadb425b.tar.bz2 rneovim-3cf4b14e966ec04371d38af6451bc69eaadb425b.zip |
add cmdline mode to modechange of RPC and tests
use set_cursor_shape_bar for cmdline mode
fix test of screen_basic_spec.lua & screen.lua
comment fix
-rw-r--r-- | runtime/doc/msgpack_rpc.txt | 5 | ||||
-rw-r--r-- | src/nvim/api/ui.c | 2 | ||||
-rw-r--r-- | src/nvim/tui/tui.c | 4 | ||||
-rw-r--r-- | src/nvim/ui.c | 11 | ||||
-rw-r--r-- | test/functional/ui/screen.lua | 3 | ||||
-rw-r--r-- | test/functional/ui/screen_basic_spec.lua | 47 |
6 files changed, 65 insertions, 7 deletions
diff --git a/runtime/doc/msgpack_rpc.txt b/runtime/doc/msgpack_rpc.txt index 757f5574d4..c074eb43ff 100644 --- a/runtime/doc/msgpack_rpc.txt +++ b/runtime/doc/msgpack_rpc.txt @@ -390,8 +390,9 @@ of update. The menu mappings changed. ["mode_change", mode] - The mode changed. Currently sent when "insert", "replace" and "normal" - modes are entered. A client could for instance change the cursor shape. + The mode changed. Currently sent when "insert", "replace", "cmdline" and + "normal" modes are entered. A client could for instance change the cursor + shape. ["popupmenu_show", items, selected, row, col] When `popupmenu_external` is set to true, nvim will not draw the diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c index 56b41f1eea..9178538110 100644 --- a/src/nvim/api/ui.c +++ b/src/nvim/api/ui.c @@ -271,6 +271,8 @@ static void remote_ui_mode_change(UI *ui, int mode) ADD(args, STRING_OBJ(cstr_to_string("insert"))); } else if (mode == REPLACE) { ADD(args, STRING_OBJ(cstr_to_string("replace"))); + } else if (mode == CMDLINE) { + ADD(args, STRING_OBJ(cstr_to_string("cmdline"))); } else { assert(mode == NORMAL); ADD(args, STRING_OBJ(cstr_to_string("normal"))); diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 5e30517c5a..2171e580ba 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -461,6 +461,10 @@ static void tui_mode_change(UI *ui, int mode) if (data->showing_mode != INSERT) { unibi_out(ui, data->unibi_ext.set_cursor_shape_bar); } + } else if (mode == CMDLINE) { + if (data->showing_mode != CMDLINE) { + unibi_out(ui, data->unibi_ext.set_cursor_shape_bar); + } } else if (mode == REPLACE) { if (data->showing_mode != REPLACE) { unibi_out(ui, data->unibi_ext.set_cursor_shape_ul); diff --git a/src/nvim/ui.c b/src/nvim/ui.c index eb500414a7..cc0d2ad1b4 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -532,13 +532,16 @@ static void ui_mode_change(void) if (!full_screen) { return; } - /* Get a simple UI mode out of State. */ - if ((State & REPLACE) == REPLACE) + // Get a simple UI mode out of State. + if ((State & REPLACE) == REPLACE) { mode = REPLACE; - else if (State & INSERT) + } else if (State & INSERT) { mode = INSERT; - else + } else if (State & CMDLINE) { + mode = CMDLINE; + } else { mode = NORMAL; + } UI_CALL(mode_change, mode); conceal_check_cursur_line(); } diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 6c1a1788ce..ebe8af35eb 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -374,7 +374,8 @@ function Screen:_handle_mouse_off() end function Screen:_handle_mode_change(mode) - assert(mode == 'insert' or mode == 'replace' or mode == 'normal') + assert(mode == 'insert' or mode == 'replace' + or mode == 'normal' or mode == 'cmdline') self.mode = mode end diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 593b6dd763..d03f98c26f 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -642,5 +642,52 @@ describe('Screen', function() eq("normal", screen.mode) end) end) + + it('works in cmdline mode', function() + feed(':') + screen:expect([[ + | + {0:~ }| + {0:~ }| + {0:~ }| + :^ | + ]],nil,nil,function () + eq("cmdline", screen.mode) + end) + + feed('<esc>/') + screen:expect([[ + | + {0:~ }| + {0:~ }| + {0:~ }| + /^ | + ]],nil,nil,function () + eq("cmdline", screen.mode) + end) + + + feed('<esc>?') + screen:expect([[ + | + {0:~ }| + {0:~ }| + {0:~ }| + ?^ | + ]],nil,nil,function () + eq("cmdline", screen.mode) + end) + + feed('<esc>') + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + | + ]],nil,nil,function () + eq("normal", screen.mode) + end) + end) end) end) |