mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:57:34 +00:00
LibGUI: Rename function to make intention clearer
This commit is contained in:
parent
50ca1b3d87
commit
791e881892
3 changed files with 4 additions and 4 deletions
|
@ -227,7 +227,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
TRY(edit_menu->try_add_action(GUI::Action::create("&Format GML", { Mod_Ctrl | Mod_Shift, Key_I }, [&](auto&) {
|
TRY(edit_menu->try_add_action(GUI::Action::create("&Format GML", { Mod_Ctrl | Mod_Shift, Key_I }, [&](auto&) {
|
||||||
auto formatted_gml_or_error = GUI::GML::format_gml(editor->text());
|
auto formatted_gml_or_error = GUI::GML::format_gml(editor->text());
|
||||||
if (!formatted_gml_or_error.is_error()) {
|
if (!formatted_gml_or_error.is_error()) {
|
||||||
editor->replace_all_text_while_keeping_undo_stack(formatted_gml_or_error.release_value());
|
editor->replace_all_text_without_resetting_undo_stack(formatted_gml_or_error.release_value());
|
||||||
} else {
|
} else {
|
||||||
GUI::MessageBox::show(
|
GUI::MessageBox::show(
|
||||||
window,
|
window,
|
||||||
|
|
|
@ -1446,14 +1446,14 @@ void TextEditor::insert_at_cursor_or_replace_selection(StringView text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditor::replace_all_text_while_keeping_undo_stack(StringView text)
|
void TextEditor::replace_all_text_without_resetting_undo_stack(StringView text)
|
||||||
{
|
{
|
||||||
auto start = GUI::TextPosition(0, 0);
|
auto start = GUI::TextPosition(0, 0);
|
||||||
auto last_line_index = line_count() - 1;
|
auto last_line_index = line_count() - 1;
|
||||||
auto end = GUI::TextPosition(last_line_index, line(last_line_index).length());
|
auto end = GUI::TextPosition(last_line_index, line(last_line_index).length());
|
||||||
auto range = GUI::TextRange(start, end);
|
auto range = GUI::TextRange(start, end);
|
||||||
auto normalized_range = range.normalized();
|
auto normalized_range = range.normalized();
|
||||||
execute<ReplaceAllTextCommand>(text, range);
|
execute<ReplaceAllTextCommand>(text, range, "GML Playground Format Text");
|
||||||
did_change();
|
did_change();
|
||||||
set_cursor(normalized_range.start());
|
set_cursor(normalized_range.start());
|
||||||
update();
|
update();
|
||||||
|
|
|
@ -123,7 +123,7 @@ public:
|
||||||
TextRange normalized_selection() const { return m_selection.normalized(); }
|
TextRange normalized_selection() const { return m_selection.normalized(); }
|
||||||
|
|
||||||
void insert_at_cursor_or_replace_selection(StringView);
|
void insert_at_cursor_or_replace_selection(StringView);
|
||||||
void replace_all_text_while_keeping_undo_stack(StringView text);
|
void replace_all_text_without_resetting_undo_stack(StringView text);
|
||||||
bool write_to_file(String const& path);
|
bool write_to_file(String const& path);
|
||||||
bool write_to_file(Core::File&);
|
bool write_to_file(Core::File&);
|
||||||
bool has_selection() const { return m_selection.is_valid(); }
|
bool has_selection() const { return m_selection.is_valid(); }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue