@@ -424,7 +424,7 @@ public TextEditor(final Context context) {
424424 findPrevious = addToMenu (edit , "Find Previous" , KeyEvent .VK_F3 , shift );
425425 findPrevious .setMnemonic (KeyEvent .VK_P );
426426
427- addSeparator (edit , "Goto:" );
427+ addMenubarSeparator (edit , "Goto:" );
428428 gotoLine = addToMenu (edit , "Goto Line..." , KeyEvent .VK_G , ctrl );
429429 gotoLine .setMnemonic (KeyEvent .VK_G );
430430
@@ -559,7 +559,7 @@ public TextEditor(final Context context) {
559559
560560 toolsMenu = new JMenu ("Tools" );
561561 toolsMenu .setMnemonic (KeyEvent .VK_O );
562- addSeparator (toolsMenu , "Imports:" );
562+ addMenubarSeparator (toolsMenu , "Imports:" );
563563 addImport = addToMenu (toolsMenu , "Add Import..." , 0 , 0 );
564564 addImport .setMnemonic (KeyEvent .VK_I );
565565 respectAutoImports = prefService .getBoolean (getClass (), AUTO_IMPORT_PREFS , false );
@@ -580,7 +580,7 @@ public TextEditor(final Context context) {
580580 sortImports = addToMenu (toolsMenu , "Sort Imports" , 0 , 0 );
581581 sortImports .setMnemonic (KeyEvent .VK_S );
582582
583- addSeparator (toolsMenu , "Source & APIs:" );
583+ addMenubarSeparator (toolsMenu , "Source & APIs:" );
584584 extractSourceJar = addToMenu (toolsMenu , "Extract Source Jar..." , 0 , 0 );
585585 extractSourceJar .setMnemonic (KeyEvent .VK_E );
586586 openSourceForClass = addToMenu (toolsMenu , "Open Java File for Class..." , 0 , 0 );
@@ -609,7 +609,7 @@ public TextEditor(final Context context) {
609609 // -- Window Menu (previously labeled as Tabs menu --
610610 tabsMenu = new JMenu ("Window" );
611611 tabsMenu .setMnemonic (KeyEvent .VK_W );
612- addSeparator (tabsMenu , "Panes:" );
612+ addMenubarSeparator (tabsMenu , "Panes:" );
613613 // Assume initial status from prefs or panel visibility
614614 final JCheckBoxMenuItem jcmi1 = new JCheckBoxMenuItem ("File Explorer" ,
615615 prefService .getInt (getClass (), MAIN_DIV_LOCATION , body .getDividerLocation ()) > 0
@@ -638,7 +638,7 @@ public TextEditor(final Context context) {
638638 }
639639 });
640640 tabsMenu .add (mi );
641- addSeparator (tabsMenu , "Tabs:" );
641+ addMenubarSeparator (tabsMenu , "Tabs:" );
642642 nextTab = addToMenu (tabsMenu , "Next Tab" , KeyEvent .VK_PAGE_DOWN , ctrl );
643643 nextTab .setMnemonic (KeyEvent .VK_N );
644644 previousTab =
@@ -655,7 +655,7 @@ public TextEditor(final Context context) {
655655 options .setMnemonic (KeyEvent .VK_O );
656656
657657 // Font adjustments
658- addSeparator (options , "Font:" );
658+ addMenubarSeparator (options , "Font:" );
659659 decreaseFontSize =
660660 addToMenu (options , "Decrease Font Size" , KeyEvent .VK_MINUS , ctrl );
661661 decreaseFontSize .setMnemonic (KeyEvent .VK_D );
@@ -689,7 +689,7 @@ public TextEditor(final Context context) {
689689 fontSizeMenu .add (chooseFontSize );
690690 options .add (fontSizeMenu );
691691
692- addSeparator (options , "Indentation:" );
692+ addMenubarSeparator (options , "Indentation:" );
693693 tabsEmulated = new JCheckBoxMenuItem ("Indent Using Spaces" );
694694 tabsEmulated .setMnemonic (KeyEvent .VK_S );
695695 tabsEmulated .addItemListener (e -> setTabsEmulated (tabsEmulated .getState ()));
@@ -716,15 +716,15 @@ public TextEditor(final Context context) {
716716 replaceSpacesWithTabs = addToMenu (options , "Replace Spaces With Tabs" , 0 , 0 );
717717 replaceTabsWithSpaces = addToMenu (options , "Replace Tabs With Spaces" , 0 , 0 );
718718
719- addSeparator (options , "View:" );
719+ addMenubarSeparator (options , "View:" );
720720 options .add (markOccurences );
721721 options .add (paintTabs );
722722 options .add (marginLine );
723723 options .add (whiteSpace );
724724 options .add (wrapLines );
725725 options .add (applyThemeMenu ());
726726
727- addSeparator (options , "Code Completions:" );
727+ addMenubarSeparator (options , "Code Completions:" );
728728 options .add (autocompletion );
729729 options .add (keylessAutocompletion );
730730 options .add (fallbackAutocompletion );
@@ -876,7 +876,7 @@ public void windowGainedFocus(final WindowEvent e) {
876876 // Tweaks for Console
877877 errorScreen .setFont (getEditorPane ().getFont ());
878878 errorScreen .setEditable (false );
879- errorScreen .setLineWrap (true );
879+ errorScreen .setLineWrap (false );
880880 applyConsolePopupMenu (errorScreen );
881881
882882 setDefaultCloseOperation (DO_NOTHING_ON_CLOSE );
@@ -928,7 +928,7 @@ public void componentResized(final ComponentEvent e) {
928928 }
929929
930930 private void addScritpEditorMacroCommands (final JMenu menu ) {
931- addSeparator (menu , "Script Editor Macros:" );
931+ addMenubarSeparator (menu , "Script Editor Macros:" );
932932 final JMenuItem startMacro = new JMenuItem ("Start/Resume Macro Recording" );
933933 startMacro .addActionListener (e -> {
934934 final String state = (RTextArea .getCurrentMacro () == null ) ? "on" : "resumed" ;
@@ -2443,6 +2443,7 @@ else if (tabSize == Integer.parseInt(item.getText())) {
24432443 defaultSize = true ;
24442444 }
24452445 }
2446+ getTab ().prompt .setTabSize (getEditorPane ().getTabSize ());
24462447 final int fontSize = (int ) pane .getFontSize ();
24472448 defaultSize = false ;
24482449 for (int i = 0 ; i < fontSizeMenu .getItemCount (); i ++) {
@@ -3707,7 +3708,7 @@ private void appendPreferences(final JMenu menu) {
37073708
37083709 private JMenu helpMenu () {
37093710 final JMenu menu = new JMenu ("Help" );
3710- addSeparator (menu , "Offline Help:" );
3711+ addMenubarSeparator (menu , "Offline Help:" );
37113712 JMenuItem item = new JMenuItem ("List Shortcuts..." );
37123713 item .addActionListener (e -> displayKeyMap ());
37133714 menu .add (item );
@@ -3730,14 +3731,14 @@ private JMenu helpMenu() {
37303731 + "</ul>" );
37313732 });
37323733 menu .add (item );
3733- addSeparator (menu , "Contextual Help:" );
3734+ addMenubarSeparator (menu , "Contextual Help:" );
37343735 menu .add (openHelpWithoutFrames );
37353736 openHelpWithoutFrames .setMnemonic (KeyEvent .VK_O );
37363737 menu .add (openHelp );
37373738 openClassOrPackageHelp = addToMenu (menu , "Lookup Class or Package..." , 0 , 0 );
37383739 openClassOrPackageHelp .setMnemonic (KeyEvent .VK_S );
37393740 menu .add (openMacroFunctions );
3740- addSeparator (menu , "Online Resources:" );
3741+ addMenubarSeparator (menu , "Online Resources:" );
37413742 menu .add (helpMenuItem ("Image.sc Forum " , "https://forum.image.sc/" ));
37423743 menu .add (helpMenuItem ("ImageJ Search Portal" , "https://search.imagej.net/" ));
37433744 //menu.addSeparator();
@@ -3772,7 +3773,7 @@ private void openURL(final String url) {
37723773 protected void applyConsolePopupMenu (final JTextArea textArea ) {
37733774 final JPopupMenu popup = new JPopupMenu ();
37743775 textArea .setComponentPopupMenu (popup );
3775- JMenuItem jmi = new JMenuItem ("Search " + ((textArea == errorScreen ) ? "Erros" : "Outputs" ));
3776+ JMenuItem jmi = new JMenuItem ("Search " + ((textArea == errorScreen ) ? "Erros... " : "Outputs... " ));
37763777 popup .add (jmi );
37773778 jmi .addActionListener (e -> {
37783779 findDialog .setLocationRelativeTo (this );
@@ -3781,7 +3782,7 @@ protected void applyConsolePopupMenu(final JTextArea textArea) {
37813782 if (text != null ) findDialog .setSearchPattern (text );
37823783 findDialog .show (false );
37833784 });
3784- jmi = new JMenuItem ("Search Script for Selected Text" );
3785+ jmi = new JMenuItem ("Search Script for Selected Text... " );
37853786 popup .add (jmi );
37863787 jmi .addActionListener (e -> {
37873788 final String text = textArea .getSelectedText ();
@@ -3810,7 +3811,8 @@ protected void applyConsolePopupMenu(final JTextArea textArea) {
38103811 popup .add (jmi );
38113812 jmi .addActionListener (e -> {
38123813 try {
3813- final Color color = (textArea == errorScreen ) ? Color .YELLOW : Color .CYAN ;
3814+ final Color taint = (textArea == errorScreen ) ? Color .RED : textArea .getSelectionColor ();
3815+ final Color color = ErrorParser .averageColors (textArea .getBackground (), taint );
38143816 final DefaultHighlightPainter painter = new DefaultHighlighter .DefaultHighlightPainter (color );
38153817 textArea .getHighlighter ().addHighlight (textArea .getSelectionStart (), textArea .getSelectionEnd (), painter );
38163818 textArea .setCaretPosition (textArea .getSelectionEnd ());
@@ -3821,13 +3823,14 @@ protected void applyConsolePopupMenu(final JTextArea textArea) {
38213823 });
38223824 jmi = new JMenuItem ("Clear Highlights" );
38233825 popup .add (jmi );
3824- jmi .addActionListener (e -> {
3825- textArea .getHighlighter ().removeAllHighlights ();
3826- });
3827- popup .add (jmi );
3826+ jmi .addActionListener (e -> textArea .getHighlighter ().removeAllHighlights ());
3827+ popup .addSeparator ();
3828+ final JCheckBoxMenuItem jmc = new JCheckBoxMenuItem ("Wrap Lines" );
3829+ popup .add (jmc );
3830+ jmc .addActionListener ( e -> textArea .setLineWrap (jmc .isSelected ()));
38283831 }
38293832
3830- private static void addSeparator (final JMenu menu , final String header ) {
3833+ private static void addMenubarSeparator (final JMenu menu , final String header ) {
38313834 if (menu .getMenuComponentCount () > 1 ) {
38323835 menu .addSeparator ();
38333836 }
@@ -3851,6 +3854,18 @@ private static void addSeparator(final JMenu menu, final String header) {
38513854 }
38523855 }
38533856
3857+ static void addPopupMenuSeparator (final JPopupMenu menu , final String header ) {
3858+ if (menu .getComponentCount () > 1 ) {
3859+ menu .addSeparator ();
3860+ }
3861+ final JLabel label = new JLabel (header );
3862+ // label.setHorizontalAlignment(SwingConstants.LEFT);
3863+ label .setEnabled (false );
3864+ label .setForeground (getDisabledComponentColor ());
3865+ menu .add (label );
3866+
3867+ }
3868+
38543869 private static Collection <File > assembleFlatFileCollection (final Collection <File > collection , final File [] files ) {
38553870 if (files == null ) return collection ; // can happen while pressing 'Esc'!?
38563871 for (final File file : files ) {
0 commit comments