mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 14:42:44 +00:00 
			
		
		
		
	LibLine: Add internal function to erase consecutive spaces under cursor
This commit is contained in:
		
							parent
							
								
									7f2582fca9
								
							
						
					
					
						commit
						cb02d52ac9
					
				
					 3 changed files with 19 additions and 0 deletions
				
			
		|  | @ -172,6 +172,7 @@ void Editor::set_default_keybinds() | |||
|     // ^[^H: alt-backspace: backward delete word
 | ||||
|     register_key_input_callback(Key { '\b', Key::Alt }, EDITOR_INTERNAL_FUNCTION(erase_alnum_word_backwards)); | ||||
|     register_key_input_callback(Key { 'd', Key::Alt }, EDITOR_INTERNAL_FUNCTION(erase_alnum_word_forwards)); | ||||
|     register_key_input_callback(Key { '\\', Key::Alt }, EDITOR_INTERNAL_FUNCTION(erase_spaces)); | ||||
|     register_key_input_callback(Key { 'c', Key::Alt }, EDITOR_INTERNAL_FUNCTION(capitalize_word)); | ||||
|     register_key_input_callback(Key { 'l', Key::Alt }, EDITOR_INTERNAL_FUNCTION(lowercase_word)); | ||||
|     register_key_input_callback(Key { 'u', Key::Alt }, EDITOR_INTERNAL_FUNCTION(uppercase_word)); | ||||
|  |  | |||
|  | @ -127,6 +127,7 @@ struct Configuration { | |||
|     M(insert_last_erased)                      \ | ||||
|     M(erase_alnum_word_backwards)              \ | ||||
|     M(erase_alnum_word_forwards)               \ | ||||
|     M(erase_spaces)                            \ | ||||
|     M(capitalize_word)                         \ | ||||
|     M(lowercase_word)                          \ | ||||
|     M(uppercase_word)                          \ | ||||
|  |  | |||
|  | @ -579,6 +579,23 @@ void Editor::erase_alnum_word_forwards() | |||
|     } | ||||
| } | ||||
| 
 | ||||
| void Editor::erase_spaces() | ||||
| { | ||||
|     while (m_cursor < m_buffer.size()) { | ||||
|         if (is_ascii_space(m_buffer[m_cursor])) | ||||
|             erase_character_forwards(); | ||||
|         else | ||||
|             break; | ||||
|     } | ||||
| 
 | ||||
|     while (m_cursor > 0) { | ||||
|         if (is_ascii_space(m_buffer[m_cursor - 1])) | ||||
|             erase_character_backwards(); | ||||
|         else | ||||
|             break; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void Editor::case_change_word(Editor::CaseChangeOp change_op) | ||||
| { | ||||
|     // A word here is contiguous alnums. `foo=bar baz` is three words.
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 ronak69
						ronak69