@@ -231,7 +231,7 @@ public class TextEditor extends JFrame implements ActionListener,
231
231
private FindAndReplaceDialog findDialog ;
232
232
private JCheckBoxMenuItem autoSave , wrapLines , tabsEmulated , autoImport ,
233
233
autocompletion , fallbackAutocompletion , keylessAutocompletion ,
234
- markOccurences , paintTabs , whiteSpace ;
234
+ markOccurences , paintTabs , whiteSpace , marginLine ;
235
235
private ButtonGroup themeRadioGroup ;
236
236
private JTextArea errorScreen = new JTextArea ();
237
237
@@ -538,10 +538,15 @@ public TextEditor(final Context context) {
538
538
tabsMenu = new JMenu ("Window" );
539
539
tabsMenu .setMnemonic (KeyEvent .VK_W );
540
540
addSeparator (tabsMenu , "Panes:" );
541
- final JCheckBoxMenuItem jcmi1 = new JCheckBoxMenuItem ("File Explorer" , isLeftPaneExpanded (body ));
541
+ // Assume initial status from prefs or panel visibility
542
+ final JCheckBoxMenuItem jcmi1 = new JCheckBoxMenuItem ("File Explorer" ,
543
+ prefService .getInt (getClass (), MAIN_DIV_LOCATION , body .getDividerLocation ()) > 0
544
+ || isLeftPaneExpanded (body ));
542
545
jcmi1 .addItemListener (e -> collapseSplitPane (0 , !jcmi1 .isSelected ()));
543
546
tabsMenu .add (jcmi1 );
544
- final JCheckBoxMenuItem jcmi2 = new JCheckBoxMenuItem ("Console" , true ); // Console not yet initialized
547
+ // Console not initialized. Assume it is displayed if no prefs read
548
+ final JCheckBoxMenuItem jcmi2 = new JCheckBoxMenuItem ("Console" ,
549
+ prefService .getInt (getClass (), TAB_DIV_LOCATION , 1 ) > 0 );
545
550
jcmi2 .addItemListener (e -> collapseSplitPane (1 , !jcmi2 .isSelected ()));
546
551
tabsMenu .add (jcmi2 );
547
552
final JMenuItem mi = new JMenuItem ("Reset Layout..." );
@@ -640,9 +645,10 @@ public TextEditor(final Context context) {
640
645
replaceTabsWithSpaces = addToMenu (options , "Replace Tabs With Spaces" , 0 , 0 );
641
646
642
647
addSeparator (options , "View:" );
643
- options .add (whiteSpace );
644
- options .add (paintTabs );
645
648
options .add (markOccurences );
649
+ options .add (paintTabs );
650
+ options .add (marginLine );
651
+ options .add (whiteSpace );
646
652
options .add (wrapLines );
647
653
options .add (applyThemeMenu ());
648
654
@@ -935,15 +941,18 @@ private void initializeDynamicMenuComponents() {
935
941
// Options menu. These will be updated once EditorPane is created
936
942
wrapLines = new JCheckBoxMenuItem ("Wrap Lines" , false );
937
943
wrapLines .setMnemonic (KeyEvent .VK_W );
944
+ marginLine = new JCheckBoxMenuItem ("Show Margin Line" , false );
945
+ marginLine .setToolTipText ("Displays right margin at column 80" );
946
+ marginLine .addItemListener (e -> setMarginLineEnabled (marginLine .getState ()));
938
947
wrapLines .addItemListener (e -> setWrapLines (wrapLines .getState ()));
939
948
markOccurences = new JCheckBoxMenuItem ("Mark Occurences" , false );
940
- markOccurences .setToolTipText ("Highlights all occurrences of a double-clicked string or selected \n "
941
- + "element. Hits are highlighted on the Editor's rightmost side " );
949
+ markOccurences .setToolTipText ("Allows for all occurrences of a double-clicked string to be "
950
+ + " highlighted. \n Lines with hits are marked on the Editor's notification strip " );
942
951
markOccurences .addItemListener (e -> setMarkOccurrences (markOccurences .getState ()));
943
952
whiteSpace = new JCheckBoxMenuItem ("Show Whitespace" , false );
944
953
whiteSpace .addItemListener (e -> setWhiteSpaceVisible (whiteSpace .isSelected ()));
945
954
paintTabs = new JCheckBoxMenuItem ("Show Indent Guides" );
946
- paintTabs .setToolTipText ("Show 'tab lines' for leading whitespace" );
955
+ paintTabs .setToolTipText ("Displays 'tab lines' for leading whitespace" );
947
956
paintTabs .addItemListener (e -> setPaintTabLines (paintTabs .getState ()));
948
957
autocompletion = new JCheckBoxMenuItem ("Enable Autocompletion" , true );
949
958
autocompletion .setToolTipText ("Whether code completion should be used.\n NB: Not all languages support this feature" );
@@ -1512,6 +1521,11 @@ private void setWrapLines(final boolean wrap) {
1512
1521
getEditorPane (i ).setLineWrap (wrap );
1513
1522
}
1514
1523
1524
+ private void setMarginLineEnabled (final boolean enabled ) {
1525
+ for (int i = 0 ; i < tabbed .getTabCount (); i ++)
1526
+ getEditorPane (i ).setMarginLineEnabled (enabled );
1527
+ }
1528
+
1515
1529
private JMenu applyThemeMenu () {
1516
1530
final LinkedHashMap <String , String > map = new LinkedHashMap <>();
1517
1531
map .put ("Default" , "default" );
@@ -1645,7 +1659,7 @@ public void stateChanged(final ChangeEvent e) {
1645
1659
editorPane .requestFocus ();
1646
1660
checkForOutsideChanges ();
1647
1661
1648
- whiteSpace .setSelected (editorPane .isWhitespaceVisible ());
1662
+ // whiteSpace.setSelected(editorPane.isWhitespaceVisible());
1649
1663
1650
1664
editorPane .setLanguageByFileName (editorPane .getFileName ());
1651
1665
updateLanguageMenu (editorPane .getCurrentLanguage ());
841E
td>@@ -2154,10 +2168,12 @@ else if (tabSize == Integer.parseInt(item.getText())) {
2154
2168
}
2155
2169
markOccurences .setState (pane .getMarkOccurrences ());
2156
2170
wrapLines .setState (pane .getLineWrap ());
2171
+ marginLine .setState (pane .isMarginLineEnabled ());
2157
2172
tabsEmulated .setState (pane .getTabsEmulated ());
2158
2173
paintTabs .setState (pane .getPaintTabLines ());
2159
2174
whiteSpace .setState (pane .isWhitespaceVisible ());
2160
2175
autocompletion .setState (pane .isAutoCompletionEnabled ());
2176
+ fallbackAutocompletion .setState (pane .isAutoCompletionFallbackEnabled ());
2161
2177
keylessAutocompletion .setState (pane .isAutoCompletionKeyless ());
2162
2178
}
2163
2179
0 commit comments