mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:48:12 +00:00
LibGUI+GMLPlayground: Replace text using ReplaceAllTextCommand
This commit is contained in:
parent
343d699627
commit
661e7d691e
5 changed files with 65 additions and 1 deletions
|
@ -1446,6 +1446,19 @@ void TextEditor::insert_at_cursor_or_replace_selection(StringView text)
|
|||
}
|
||||
}
|
||||
|
||||
void TextEditor::replace_all_text_while_keeping_undo_stack(StringView text)
|
||||
{
|
||||
auto start = GUI::TextPosition(0, 0);
|
||||
auto last_line_index = line_count() - 1;
|
||||
auto end = GUI::TextPosition(last_line_index, line(last_line_index).length());
|
||||
auto range = GUI::TextRange(start, end);
|
||||
auto normalized_range = range.normalized();
|
||||
execute<ReplaceAllTextCommand>(text, range);
|
||||
did_change();
|
||||
set_cursor(normalized_range.start());
|
||||
update();
|
||||
}
|
||||
|
||||
void TextEditor::cut()
|
||||
{
|
||||
if (!is_editable())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue