mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:07:35 +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:
parent
a6ce86a4b3
commit
97bcdba2a5
3 changed files with 39 additions and 0 deletions
|
@ -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()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue