MCPcopy Create free account
hub / github.com/SpartanJ/eepp / createViewMenu

Method createViewMenu

src/tools/ecode/settingsmenu.cpp:1719–2186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1717}
1718
1719UIMenu* SettingsMenu::createViewMenu() {
1720 mViewMenu = UIPopUpMenu::New();
1721
1722 mLineWrapMenu = UIPopUpMenu::New();
1723
1724 mViewMenu
1725 ->addSubMenu( i18n( "line_wrap", "Line Wrap" ), findIcon( "text-wrap" ), mLineWrapMenu )
1726 ->on( Event::OnMenuShow, [this]( auto ) {
1727 if ( mLineWrapMenu->getCount() == 0 ) {
1728 UIPopUpMenu* wrapModeMenu = UIPopUpMenu::New();
1729 wrapModeMenu->addRadioButton( i18n( "no_wrap", "No Wrap" ) )
1730 ->setId( LineWrap::fromLineWrapMode( LineWrapMode::NoWrap ) );
1731 wrapModeMenu->addRadioButton( i18n( "wrap_word", "Word wrap" ) )
1732 ->setId( LineWrap::fromLineWrapMode( LineWrapMode::Word ) );
1733 wrapModeMenu->addRadioButton( i18n( "wrap_letter", "Letter wrap" ) )
1734 ->setId( LineWrap::fromLineWrapMode( LineWrapMode::Letter ) );
1735
1736 wrapModeMenu->on( Event::OnItemClicked, [this]( const Event* event ) {
1737 if ( !event->getNode()->isType( UI_TYPE_MENUITEM ) )
1738 return;
1739 UIMenuItem* item = event->getNode()->asType<UIMenuItem>();
1740 LineWrapMode mode = LineWrap::toLineWrapMode( item->getId() );
1741 mApp->getConfig().editor.wrapMode = mode;
1742 mApp->getSplitter()->forEachEditor(
1743 [mode]( UICodeEditor* editor ) { editor->setLineWrapMode( mode ); } );
1744 } );
1745
1746 mLineWrapMenu->addSubMenu( i18n( "wrap_mode", "Wrap Mode" ), nullptr, wrapModeMenu )
1747 ->setId( "wrap_mode" );
1748
1749 UIPopUpMenu* wrapTypeMenu = UIPopUpMenu::New();
1750 wrapTypeMenu->addRadioButton( i18n( "viewport", "Viewport" ) )
1751 ->setId( LineWrap::fromLineWrapType( LineWrapType::Viewport ) );
1752 wrapTypeMenu
1753 ->addRadioButton( i18n( "line_breaking_column", "Line Breaking Column" ) )
1754 ->setId( LineWrap::fromLineWrapType( LineWrapType::LineBreakingColumn ) );
1755
1756 wrapTypeMenu->on( Event::OnItemClicked, [this]( const Event* event ) {
1757 if ( !event->getNode()->isType( UI_TYPE_MENUITEM ) )
1758 return;
1759 UIMenuItem* item = event->getNode()->asType<UIMenuItem>();
1760 LineWrapType type = LineWrap::toLineWrapType( item->getId() );
1761 mApp->getConfig().editor.wrapType = type;
1762 mApp->getSplitter()->forEachEditor(
1763 [type]( UICodeEditor* editor ) { editor->setLineWrapType( type ); } );
1764 } );
1765
1766 mLineWrapMenu
1767 ->addSubMenu( i18n( "wrap_type_ellipsis", "Wrap Against..." ), nullptr,
1768 wrapTypeMenu )
1769 ->setId( "wrap_type" );
1770
1771 mLineWrapMenu->addCheckBox( i18n( "keep_indentation", "Keep Indentation" ) )
1772 ->setId( "keep_indentation" );
1773
1774 mLineWrapMenu->on( Event::OnItemClicked, [this]( const Event* event ) {
1775 if ( !event->getNode()->isType( UI_TYPE_MENUITEM ) )
1776 return;

Callers

nothing calls this directly

Calls 15

addSubMenuMethod · 0.80
addRadioButtonMethod · 0.80
getNodeMethod · 0.80
getConfigMethod · 0.80
forEachEditorMethod · 0.80
setLineWrapTypeMethod · 0.80
addCheckBoxMethod · 0.80
getSubMenuMethod · 0.80
addSeparatorMethod · 0.80
getItemIdMethod · 0.80
forEachDocMethod · 0.80
setFoldsAlwaysVisibleMethod · 0.80

Tested by

no test coverage detected