mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:18:11 +00:00
TextEditor: Implement word wrapping
Add a new wrapping mode to the TextEditor that will wrap lines at the spaces between words. Replace the previous menubar checkbox 'Wrapping Mode' in HackStudio and the TextEditor with an exclusive submenu which allows switching between 'No wrapping', 'Wrap anywhere' and 'Wrap at words'. 'Wrap anywhere' (the new 'Wrap lines') is still the default mode. Setting the wrapping mode in the constructors of the TextEditorWidget and HackStudio has been removed, it is now set when constructing the menubar actions.
This commit is contained in:
parent
db1c6cf9cf
commit
cc2f35badd
8 changed files with 105 additions and 41 deletions
|
@ -875,13 +875,30 @@ void HackStudioWidget::create_edit_menubar(GUI::MenuBar& menubar)
|
|||
|
||||
edit_menu.add_separator();
|
||||
|
||||
auto line_wrapping_action = GUI::Action::create_checkable("Line wrapping", [this](auto& action) {
|
||||
for (auto& wrapper : m_all_editor_wrappers) {
|
||||
wrapper.editor().set_line_wrapping_enabled(action.is_checked());
|
||||
}
|
||||
m_wrapping_mode_actions.set_exclusive(true);
|
||||
auto& wrapping_mode_menu = edit_menu.add_submenu("Wrapping mode");
|
||||
m_no_wrapping_action = GUI::Action::create_checkable("No wrapping", [&](auto&) {
|
||||
for (auto& wrapper : m_all_editor_wrappers)
|
||||
wrapper.editor().set_wrapping_mode(GUI::TextEditor::WrappingMode::NoWrap);
|
||||
});
|
||||
line_wrapping_action->set_checked(current_editor().is_line_wrapping_enabled());
|
||||
edit_menu.add_action(line_wrapping_action);
|
||||
m_wrap_anywhere_action = GUI::Action::create_checkable("Wrap anywhere", [&](auto&) {
|
||||
for (auto& wrapper : m_all_editor_wrappers)
|
||||
wrapper.editor().set_wrapping_mode(GUI::TextEditor::WrappingMode::WrapAnywhere);
|
||||
});
|
||||
m_wrap_at_words_action = GUI::Action::create_checkable("Wrap at words", [&](auto&) {
|
||||
for (auto& wrapper : m_all_editor_wrappers)
|
||||
wrapper.editor().set_wrapping_mode(GUI::TextEditor::WrappingMode::WrapAtWords);
|
||||
});
|
||||
|
||||
m_wrapping_mode_actions.add_action(*m_no_wrapping_action);
|
||||
m_wrapping_mode_actions.add_action(*m_wrap_anywhere_action);
|
||||
m_wrapping_mode_actions.add_action(*m_wrap_at_words_action);
|
||||
|
||||
wrapping_mode_menu.add_action(*m_no_wrapping_action);
|
||||
wrapping_mode_menu.add_action(*m_wrap_anywhere_action);
|
||||
wrapping_mode_menu.add_action(*m_wrap_at_words_action);
|
||||
|
||||
m_wrap_anywhere_action->set_checked(true);
|
||||
|
||||
edit_menu.add_separator();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue