mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +00:00
LibLine: Implement internal functions to jump cursor over non-space word
Two new internal functions `cursor_left_nonspace_word()` (`Ctrl+Alt+B`) and `cursor_right_nonspace_word()` (`Ctrl+Alt+F`) that jump the cursor left or right until a non-space character. Same implementation as the alphanumeric word jump functions `cursor_left_word()` (`Alt+B`) and `cursor_right_word()` (`Alt+F`).
This commit is contained in:
committed by
Ali Mohammad Pur
parent
a6ce86a4b3
commit
97bcdba2a5
@@ -93,6 +93,23 @@ void Editor::cursor_left_word()
|
||||
m_inline_search_cursor = m_cursor;
|
||||
}
|
||||
|
||||
void Editor::cursor_left_nonspace_word()
|
||||
{
|
||||
auto has_seen_nonspace = false;
|
||||
while (m_cursor) {
|
||||
// after seeing at least one non-space, stop just before a space
|
||||
if (is_ascii_space(m_buffer[m_cursor - 1])) {
|
||||
if (has_seen_nonspace)
|
||||
break;
|
||||
} else {
|
||||
has_seen_nonspace = true;
|
||||
}
|
||||
|
||||
--m_cursor;
|
||||
}
|
||||
m_inline_search_cursor = m_cursor;
|
||||
}
|
||||
|
||||
void Editor::cursor_left_character()
|
||||
{
|
||||
if (m_cursor > 0) {
|
||||
@@ -121,6 +138,24 @@ void Editor::cursor_right_word()
|
||||
m_search_offset = 0;
|
||||
}
|
||||
|
||||
void Editor::cursor_right_nonspace_word()
|
||||
{
|
||||
auto has_seen_nonspace = false;
|
||||
while (m_cursor < m_buffer.size()) {
|
||||
// after seeing at least one non-space, stop at the first space
|
||||
if (is_ascii_space(m_buffer[m_cursor])) {
|
||||
if (has_seen_nonspace)
|
||||
break;
|
||||
} else {
|
||||
has_seen_nonspace = true;
|
||||
}
|
||||
|
||||
++m_cursor;
|
||||
}
|
||||
m_inline_search_cursor = m_cursor;
|
||||
m_search_offset = 0;
|
||||
}
|
||||
|
||||
void Editor::cursor_right_character()
|
||||
{
|
||||
if (m_cursor < m_buffer.size()) {
|
||||
|
||||
Reference in New Issue
Block a user