mirror of
https://github.com/RGBCube/serenity
synced 2025-07-19 13:27:35 +00:00
GTextEditor: Add select_all() API.
Take the implementation of Ctrl+A and expose it as an API for clients.
This commit is contained in:
parent
9ee63ef8b3
commit
c31cf907ce
2 changed files with 12 additions and 6 deletions
|
@ -344,6 +344,16 @@ void GTextEditor::toggle_selection_if_needed_for_event(const GKeyEvent& event)
|
|||
}
|
||||
}
|
||||
|
||||
void GTextEditor::select_all()
|
||||
{
|
||||
GTextPosition start_of_document { 0, 0 };
|
||||
GTextPosition end_of_document { line_count() - 1, m_lines[line_count() - 1]->length() };
|
||||
m_selection.set(start_of_document, end_of_document);
|
||||
did_update_selection();
|
||||
set_cursor(end_of_document);
|
||||
update();
|
||||
}
|
||||
|
||||
void GTextEditor::keydown_event(GKeyEvent& event)
|
||||
{
|
||||
if (is_single_line() && event.key() == KeyCode::Key_Tab)
|
||||
|
@ -485,12 +495,7 @@ void GTextEditor::keydown_event(GKeyEvent& event)
|
|||
return;
|
||||
}
|
||||
if (event.modifiers() == Mod_Ctrl && event.key() == KeyCode::Key_A) {
|
||||
GTextPosition start_of_document { 0, 0 };
|
||||
GTextPosition end_of_document { line_count() - 1, m_lines[line_count() - 1]->length() };
|
||||
m_selection.set(start_of_document, end_of_document);
|
||||
did_update_selection();
|
||||
set_cursor(end_of_document);
|
||||
update();
|
||||
select_all();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -127,6 +127,7 @@ public:
|
|||
void paste();
|
||||
void do_delete();
|
||||
void delete_current_line();
|
||||
void select_all();
|
||||
|
||||
Function<void()> on_change;
|
||||
Function<void()> on_return_pressed;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue