@@ -296,7 +296,9 @@ public void windowDeactivated(WindowEvent e) {
296
296
297
297
// RTextScrollPane
298
298
scrollPane = new RTextScrollPane (textarea , true );
299
- scrollPane .setBorder (new MatteBorder (0 , 6 , 0 , 0 , Theme .getColor ("editor.bgcolor" )));
299
+
300
+ scrollPane .setBorder (setMargin ());
301
+
300
302
scrollPane .setViewportBorder (BorderFactory .createEmptyBorder ());
301
303
scrollPane .setLineNumbersEnabled (PreferencesData .getBoolean ("editor.linenumbers" ));
302
304
scrollPane .setIconRowHeaderEnabled (false );
@@ -478,8 +480,12 @@ public void applyPreferences() {
478
480
saveAsMenuItem .setEnabled (!external );
479
481
480
482
textarea .setCodeFoldingEnabled (PreferencesData .getBoolean ("editor.code_folding" ));
483
+
484
+ scrollPane .setBorder (setMargin ());
485
+
481
486
scrollPane .setFoldIndicatorEnabled (PreferencesData .getBoolean ("editor.code_folding" ));
482
487
scrollPane .setLineNumbersEnabled (PreferencesData .getBoolean ("editor.linenumbers" ));
488
+
483
489
484
490
if (external ) {
485
491
// disable line highlight and turn off the caret when disabling
@@ -509,6 +515,37 @@ public void applyPreferences() {
509
515
510
516
}
511
517
518
+ private MatteBorder setMargin ()
519
+ {
520
+ int defaultMargin = 29 ;
521
+ int marginwithNumbers = 6 ;
522
+ int marginWithFoldingCode = 17 ;
523
+ int marginWithBoth = 1 ;
524
+
525
+ MatteBorder formatedMargin ;
526
+ if (PreferencesData .getBoolean ("editor.linenumbers" ) && PreferencesData .getBoolean ("editor.code_folding" ))
527
+ {
528
+
529
+ formatedMargin = new MatteBorder (0 , marginWithBoth , 0 , 0 , Theme .getColor ("editor.bgcolor" ));
530
+ }
531
+ else if (PreferencesData .getBoolean ("editor.linenumbers" ))
532
+ {
533
+
534
+ formatedMargin = new MatteBorder (0 , marginwithNumbers , 0 , 0 , Theme .getColor ("editor.bgcolor" ));
535
+ }
536
+ else if (PreferencesData .getBoolean ("editor.code_folding" ))
537
+ {
538
+
539
+ formatedMargin = new MatteBorder (0 , marginWithFoldingCode , 0 , 0 , Theme .getColor ("editor.bgcolor" ));
540
+ }
541
+ else
542
+ {
543
+ formatedMargin = new MatteBorder (0 , defaultMargin , 0 , 0 , Theme .getColor ("editor.bgcolor" ));
544
+ }
545
+
546
+ return formatedMargin ;
547
+ }
548
+
512
549
513
550
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
514
551
@@ -743,13 +780,13 @@ public void actionPerformed(ActionEvent e) {
743
780
});
744
781
sketchMenu .add (item );
745
782
746
- // item = new JMenuItem("Stop");
747
- // item.addActionListener(new ActionListener() {
748
- // public void actionPerformed(ActionEvent e) {
749
- // handleStop();
750
- // }
751
- // });
752
- // sketchMenu.add(item);
783
+ // item = new JMenuItem("Stop");
784
+ // item.addActionListener(new ActionListener() {
785
+ // public void actionPerformed(ActionEvent e) {
786
+ // handleStop();
787
+ // }
788
+ // });
789
+ // sketchMenu.add(item);
753
790
754
791
sketchMenu .addSeparator ();
755
792
@@ -1402,23 +1439,23 @@ public void actionPerformed(ActionEvent e) {
1402
1439
JMenuItem copyForumItem = newJMenuItemShift (tr ("Copy for Forum" ), 'C' );
1403
1440
copyForumItem .addActionListener (new ActionListener () {
1404
1441
public void actionPerformed (ActionEvent e ) {
1405
- // SwingUtilities.invokeLater(new Runnable() {
1406
- // public void run() {
1442
+ // SwingUtilities.invokeLater(new Runnable() {
1443
+ // public void run() {
1407
1444
new DiscourseFormat (Editor .this , false ).show ();
1408
- // }
1409
- // });
1445
+ // }
1446
+ // });
1410
1447
}
1411
1448
});
1412
1449
menu .add (copyForumItem );
1413
1450
1414
1451
JMenuItem copyHTMLItem = newJMenuItemAlt (tr ("Copy as HTML" ), 'C' );
1415
1452
copyHTMLItem .addActionListener (new ActionListener () {
1416
1453
public void actionPerformed (ActionEvent e ) {
1417
- // SwingUtilities.invokeLater(new Runnable() {
1418
- // public void run() {
1454
+ // SwingUtilities.invokeLater(new Runnable() {
1455
+ // public void run() {
1419
1456
new DiscourseFormat (Editor .this , true ).show ();
1420
- // }
1421
- // });
1457
+ // }
1458
+ // });
1422
1459
}
1423
1460
});
1424
1461
menu .add (copyHTMLItem );
@@ -1701,18 +1738,18 @@ public void setText(String what) {
1701
1738
* Called to update the text but not switch to a different set of code
1702
1739
* (which would affect the undo manager).
1703
1740
*/
1704
- // public void setText2(String what, int start, int stop) {
1705
- // beginCompoundEdit();
1706
- // textarea.setText(what);
1707
- // endCompoundEdit();
1708
- //
1709
- // // make sure that a tool isn't asking for a bad location
1710
- // start = Math.max(0, Math.min(start, textarea.getDocumentLength()));
1711
- // stop = Math.max(0, Math.min(start, textarea.getDocumentLength()));
1712
- // textarea.select(start, stop);
1713
- //
1714
- // textarea.requestFocus(); // get the caret blinking
1715
- // }
1741
+ // public void setText2(String what, int start, int stop) {
1742
+ // beginCompoundEdit();
1743
+ // textarea.setText(what);
1744
+ // endCompoundEdit();
1745
+ //
1746
+ // // make sure that a tool isn't asking for a bad location
1747
+ // start = Math.max(0, Math.min(start, textarea.getDocumentLength()));
1748
+ // stop = Math.max(0, Math.min(start, textarea.getDocumentLength()));
1749
+ // textarea.select(start, stop);
1750
+ //
1751
+ // textarea.requestFocus(); // get the caret blinking
1752
+ // }
1716
1753
1717
1754
1718
1755
public String getSelectedText () {
@@ -1783,7 +1820,7 @@ protected void setCode(final SketchCodeDocument codeDoc) {
1783
1820
bl .printStackTrace ();
1784
1821
}
1785
1822
// set up this guy's own undo manager
1786
- // code.undo = new UndoManager();
1823
+ // code.undo = new UndoManager();
1787
1824
1788
1825
codeDoc .setDocument (document );
1789
1826
}
@@ -2010,12 +2047,12 @@ public void run() {
2010
2047
* Implements Sketch → Stop, or pressing Stop on the toolbar.
2011
2048
*/
2012
2049
private void handleStop () { // called by menu or buttons
2013
- // toolbar.activate(EditorToolbar.STOP);
2050
+ // toolbar.activate(EditorToolbar.STOP);
2014
2051
2015
2052
internalCloseRunner ();
2016
2053
2017
2054
toolbar .deactivateRun ();
2018
- // toolbar.deactivate(EditorToolbar.STOP);
2055
+ // toolbar.deactivate(EditorToolbar.STOP);
2019
2056
2020
2057
// focus the PDE again after quitting presentation mode [toxi 030903]
2021
2058
toFront ();
@@ -2874,10 +2911,10 @@ public void statusError(String what) {
2874
2911
*/
2875
2912
public void statusError (Exception e ) {
2876
2913
e .printStackTrace ();
2877
- // if (e == null) {
2878
- // System.err.println("Editor.statusError() was passed a null exception.");
2879
- // return;
2880
- // }
2914
+ // if (e == null) {
2915
+ // System.err.println("Editor.statusError() was passed a null exception.");
2916
+ // return;
2917
+ // }
2881
2918
2882
2919
if (e instanceof RunnerException ) {
2883
2920
RunnerException re = (RunnerException ) e ;
@@ -2923,7 +2960,7 @@ public void statusError(Exception e) {
2923
2960
}
2924
2961
statusError (mess );
2925
2962
}
2926
- // e.printStackTrace();
2963
+ // e.printStackTrace();
2927
2964
}
2928
2965
2929
2966
0 commit comments