mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	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
This commit is contained in:
		| @@ -390,8 +390,9 @@ of update. | |||||||
| 	The menu mappings changed. | 	The menu mappings changed. | ||||||
|  |  | ||||||
| ["mode_change", mode] | ["mode_change", mode] | ||||||
| 	The mode changed. Currently sent when "insert", "replace" and "normal" | 	The mode changed. Currently sent when "insert", "replace", "cmdline" and | ||||||
| 	modes are entered. A client could for instance change the cursor shape. | 	"normal" modes are entered. A client could for instance change the cursor | ||||||
|  | 	shape. | ||||||
|  |  | ||||||
| ["popupmenu_show", items, selected, row, col] | ["popupmenu_show", items, selected, row, col] | ||||||
| 	When `popupmenu_external` is set to true, nvim will not draw the | 	When `popupmenu_external` is set to true, nvim will not draw the | ||||||
|   | |||||||
| @@ -271,6 +271,8 @@ static void remote_ui_mode_change(UI *ui, int mode) | |||||||
|     ADD(args, STRING_OBJ(cstr_to_string("insert"))); |     ADD(args, STRING_OBJ(cstr_to_string("insert"))); | ||||||
|   } else if (mode == REPLACE) { |   } else if (mode == REPLACE) { | ||||||
|     ADD(args, STRING_OBJ(cstr_to_string("replace"))); |     ADD(args, STRING_OBJ(cstr_to_string("replace"))); | ||||||
|  |   } else if (mode == CMDLINE) { | ||||||
|  |     ADD(args, STRING_OBJ(cstr_to_string("cmdline"))); | ||||||
|   } else { |   } else { | ||||||
|     assert(mode == NORMAL); |     assert(mode == NORMAL); | ||||||
|     ADD(args, STRING_OBJ(cstr_to_string("normal"))); |     ADD(args, STRING_OBJ(cstr_to_string("normal"))); | ||||||
|   | |||||||
| @@ -461,6 +461,10 @@ static void tui_mode_change(UI *ui, int mode) | |||||||
|     if (data->showing_mode != INSERT) { |     if (data->showing_mode != INSERT) { | ||||||
|       unibi_out(ui, data->unibi_ext.set_cursor_shape_bar); |       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) { |   } else if (mode == REPLACE) { | ||||||
|     if (data->showing_mode != REPLACE) { |     if (data->showing_mode != REPLACE) { | ||||||
|       unibi_out(ui, data->unibi_ext.set_cursor_shape_ul); |       unibi_out(ui, data->unibi_ext.set_cursor_shape_ul); | ||||||
|   | |||||||
| @@ -532,13 +532,16 @@ static void ui_mode_change(void) | |||||||
|   if (!full_screen) { |   if (!full_screen) { | ||||||
|     return; |     return; | ||||||
|   } |   } | ||||||
|   /* Get a simple UI mode out of State. */ |   // Get a simple UI mode out of State. | ||||||
|   if ((State & REPLACE) == REPLACE) |   if ((State & REPLACE) == REPLACE) { | ||||||
|     mode = REPLACE; |     mode = REPLACE; | ||||||
|   else if (State & INSERT) |   } else if (State & INSERT) { | ||||||
|     mode = INSERT; |     mode = INSERT; | ||||||
|   else |   } else if (State & CMDLINE) { | ||||||
|  |     mode = CMDLINE; | ||||||
|  |   } else { | ||||||
|     mode = NORMAL; |     mode = NORMAL; | ||||||
|  |   } | ||||||
|   UI_CALL(mode_change, mode); |   UI_CALL(mode_change, mode); | ||||||
|   conceal_check_cursur_line(); |   conceal_check_cursur_line(); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -374,7 +374,8 @@ function Screen:_handle_mouse_off() | |||||||
| end | end | ||||||
|  |  | ||||||
| function Screen:_handle_mode_change(mode) | 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 |   self.mode = mode | ||||||
| end | end | ||||||
|  |  | ||||||
|   | |||||||
| @@ -642,5 +642,52 @@ describe('Screen', function() | |||||||
|         eq("normal", screen.mode) |         eq("normal", screen.mode) | ||||||
|       end) |       end) | ||||||
|     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) | ||||||
| end) | end) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 chemzqm
					chemzqm