mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 16:15:10 +00:00
TextEditor: Add a menu action for turning line-wrapping on/off
This commit is contained in:
parent
5aac652b4b
commit
97a695403b
2 changed files with 10 additions and 1 deletions
|
@ -65,7 +65,7 @@ TextEditorWidget::TextEditorWidget()
|
||||||
selection_start = m_editor->normalized_selection().end();
|
selection_start = m_editor->normalized_selection().end();
|
||||||
|
|
||||||
auto found_range = m_editor->find_prev(needle, selection_start);
|
auto found_range = m_editor->find_prev(needle, selection_start);
|
||||||
|
|
||||||
dbg() << "find_prev(\"" << needle << "\") returned " << found_range;
|
dbg() << "find_prev(\"" << needle << "\") returned " << found_range;
|
||||||
if (found_range.is_valid()) {
|
if (found_range.is_valid()) {
|
||||||
m_editor->set_selection(found_range);
|
m_editor->set_selection(found_range);
|
||||||
|
@ -137,8 +137,16 @@ TextEditorWidget::TextEditorWidget()
|
||||||
m_save_as_action->activate();
|
m_save_as_action->activate();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
m_line_wrapping_setting_action = GAction::create("Line wrapping", [&](GAction& action) {
|
||||||
|
action.set_checked(!action.is_checked());
|
||||||
|
m_editor->set_line_wrapping_enabled(action.is_checked());
|
||||||
|
});
|
||||||
|
m_line_wrapping_setting_action->set_checkable(true);
|
||||||
|
m_line_wrapping_setting_action->set_checked(m_editor->is_line_wrapping_enabled());
|
||||||
|
|
||||||
auto menubar = make<GMenuBar>();
|
auto menubar = make<GMenuBar>();
|
||||||
auto app_menu = make<GMenu>("Text Editor");
|
auto app_menu = make<GMenu>("Text Editor");
|
||||||
|
app_menu->add_action(*m_line_wrapping_setting_action);
|
||||||
app_menu->add_action(GAction::create("Quit", { Mod_Alt, Key_F4 }, [](const GAction&) {
|
app_menu->add_action(GAction::create("Quit", { Mod_Alt, Key_F4 }, [](const GAction&) {
|
||||||
GApplication::the().quit(0);
|
GApplication::the().quit(0);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -29,6 +29,7 @@ private:
|
||||||
RefPtr<GAction> m_save_action;
|
RefPtr<GAction> m_save_action;
|
||||||
RefPtr<GAction> m_save_as_action;
|
RefPtr<GAction> m_save_as_action;
|
||||||
RefPtr<GAction> m_find_action;
|
RefPtr<GAction> m_find_action;
|
||||||
|
RefPtr<GAction> m_line_wrapping_setting_action;
|
||||||
|
|
||||||
GTextBox* m_find_textbox { nullptr };
|
GTextBox* m_find_textbox { nullptr };
|
||||||
GButton* m_find_prev_button { nullptr };
|
GButton* m_find_prev_button { nullptr };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue