Skip to content

Commit 6d00bee

Browse files
CarlosMiguelDesarrollofacchinm
CarlosMiguelDesarrollo
authored andcommitted
modify the marin on the left of the scrollPane because of the issue #4562
1 parent d1516f6 commit 6d00bee

File tree

1 file changed

+73
-36
lines changed

1 file changed

+73
-36
lines changed

app/src/processing/app/Editor.java

Lines changed: 73 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,9 @@ public void windowDeactivated(WindowEvent e) {
296296

297297
// RTextScrollPane
298298
scrollPane = new RTextScrollPane(textarea, true);
299-
scrollPane.setBorder(new MatteBorder(0, 6, 0, 0, Theme.getColor("editor.bgcolor")));
299+
300+
scrollPane.setBorder(setMargin());
301+
300302
scrollPane.setViewportBorder(BorderFactory.createEmptyBorder());
301303
scrollPane.setLineNumbersEnabled(PreferencesData.getBoolean("editor.linenumbers"));
302304
scrollPane.setIconRowHeaderEnabled(false);
@@ -478,8 +480,12 @@ public void applyPreferences() {
478480
saveAsMenuItem.setEnabled(!external);
479481

480482
textarea.setCodeFoldingEnabled(PreferencesData.getBoolean("editor.code_folding"));
483+
484+
scrollPane.setBorder(setMargin());
485+
481486
scrollPane.setFoldIndicatorEnabled(PreferencesData.getBoolean("editor.code_folding"));
482487
scrollPane.setLineNumbersEnabled(PreferencesData.getBoolean("editor.linenumbers"));
488+
483489

484490
if (external) {
485491
// disable line highlight and turn off the caret when disabling
@@ -509,6 +515,37 @@ public void applyPreferences() {
509515

510516
}
511517

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+
512549

513550
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
514551

@@ -743,13 +780,13 @@ public void actionPerformed(ActionEvent e) {
743780
});
744781
sketchMenu.add(item);
745782

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);
753790

754791
sketchMenu.addSeparator();
755792

@@ -1402,23 +1439,23 @@ public void actionPerformed(ActionEvent e) {
14021439
JMenuItem copyForumItem = newJMenuItemShift(tr("Copy for Forum"), 'C');
14031440
copyForumItem.addActionListener(new ActionListener() {
14041441
public void actionPerformed(ActionEvent e) {
1405-
// SwingUtilities.invokeLater(new Runnable() {
1406-
// public void run() {
1442+
// SwingUtilities.invokeLater(new Runnable() {
1443+
// public void run() {
14071444
new DiscourseFormat(Editor.this, false).show();
1408-
// }
1409-
// });
1445+
// }
1446+
// });
14101447
}
14111448
});
14121449
menu.add(copyForumItem);
14131450

14141451
JMenuItem copyHTMLItem = newJMenuItemAlt(tr("Copy as HTML"), 'C');
14151452
copyHTMLItem.addActionListener(new ActionListener() {
14161453
public void actionPerformed(ActionEvent e) {
1417-
// SwingUtilities.invokeLater(new Runnable() {
1418-
// public void run() {
1454+
// SwingUtilities.invokeLater(new Runnable() {
1455+
// public void run() {
14191456
new DiscourseFormat(Editor.this, true).show();
1420-
// }
1421-
// });
1457+
// }
1458+
// });
14221459
}
14231460
});
14241461
menu.add(copyHTMLItem);
@@ -1701,18 +1738,18 @@ public void setText(String what) {
17011738
* Called to update the text but not switch to a different set of code
17021739
* (which would affect the undo manager).
17031740
*/
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+
// }
17161753

17171754

17181755
public String getSelectedText() {
@@ -1783,7 +1820,7 @@ protected void setCode(final SketchCodeDocument codeDoc) {
17831820
bl.printStackTrace();
17841821
}
17851822
// set up this guy's own undo manager
1786-
// code.undo = new UndoManager();
1823+
// code.undo = new UndoManager();
17871824

17881825
codeDoc.setDocument(document);
17891826
}
@@ -2010,12 +2047,12 @@ public void run() {
20102047
* Implements Sketch → Stop, or pressing Stop on the toolbar.
20112048
*/
20122049
private void handleStop() { // called by menu or buttons
2013-
// toolbar.activate(EditorToolbar.STOP);
2050+
// toolbar.activate(EditorToolbar.STOP);
20142051

20152052
internalCloseRunner();
20162053

20172054
toolbar.deactivateRun();
2018-
// toolbar.deactivate(EditorToolbar.STOP);
2055+
// toolbar.deactivate(EditorToolbar.STOP);
20192056

20202057
// focus the PDE again after quitting presentation mode [toxi 030903]
20212058
toFront();
@@ -2874,10 +2911,10 @@ public void statusError(String what) {
28742911
*/
28752912
public void statusError(Exception e) {
28762913
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+
// }
28812918

28822919
if (e instanceof RunnerException) {
28832920
RunnerException re = (RunnerException) e;
@@ -2923,7 +2960,7 @@ public void statusError(Exception e) {
29232960
}
29242961
statusError(mess);
29252962
}
2926-
// e.printStackTrace();
2963+
// e.printStackTrace();
29272964
}
29282965

29292966

0 commit comments

Comments
 (0)