|
54 | 54 | import javax.swing.border.MatteBorder;
|
55 | 55 | import javax.swing.event.*;
|
56 | 56 | import javax.swing.text.BadLocationException;
|
| 57 | +import javax.swing.text.Element; |
57 | 58 | import javax.swing.text.PlainDocument;
|
58 | 59 | import javax.swing.undo.CannotRedoException;
|
59 | 60 | import javax.swing.undo.CannotUndoException;
|
@@ -338,36 +339,23 @@ public void windowDeactivated(WindowEvent e) {
|
338 | 339 |
|
339 | 340 | pane.setTransferHandler(new FileDropHandler());
|
340 | 341 |
|
341 |
| -// System.out.println("t1"); |
342 |
| - |
343 | 342 | // Finish preparing Editor (formerly found in Base)
|
344 | 343 | pack();
|
345 | 344 |
|
346 |
| -// System.out.println("t2"); |
347 |
| - |
348 | 345 | // Set the window bounds and the divider location before setting it visible
|
349 | 346 | setPlacement(storedLocation, defaultLocation);
|
350 | 347 |
|
351 |
| - |
352 | 348 | // Set the minimum size for the editor window
|
353 | 349 | setMinimumSize(scale(new Dimension(
|
354 | 350 | PreferencesData.getInteger("editor.window.width.min"),
|
355 | 351 | PreferencesData.getInteger("editor.window.height.min"))));
|
356 |
| -// System.out.println("t3"); |
357 | 352 |
|
358 | 353 | // Bring back the general options for the editor
|
359 | 354 | applyPreferences();
|
360 | 355 |
|
361 |
| -// System.out.println("t4"); |
362 |
| - |
363 | 356 | // Open the document that was passed in
|
364 | 357 | boolean loaded = handleOpenInternal(file);
|
365 | 358 | if (!loaded) sketch = null;
|
366 |
| - |
367 |
| -// System.out.println("t5"); |
368 |
| - |
369 |
| - // All set, now show the window |
370 |
| - //setVisible(true); |
371 | 359 | }
|
372 | 360 |
|
373 | 361 |
|
@@ -1025,28 +1013,20 @@ private SketchTextArea createTextArea() throws IOException {
|
1025 | 1013 | textArea.setAntiAliasingEnabled(PreferencesData.getBoolean("editor.antialias"));
|
1026 | 1014 | textArea.setTabsEmulated(PreferencesData.getBoolean("editor.tabs.expand"));
|
1027 | 1015 | textArea.setTabSize(PreferencesData.getInteger("editor.tabs.size"));
|
1028 |
| - textArea.addHyperlinkListener(new HyperlinkListener() { |
1029 |
| - @Override |
1030 |
| - public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) { |
1031 |
| - try { |
1032 |
| - platform.openURL(sketch.getFolder(), hyperlinkEvent.getURL().toExternalForm()); |
1033 |
| - } catch (Exception e) { |
1034 |
| - Base.showWarning(e.getMessage(), e.getMessage(), e); |
1035 |
| - } |
| 1016 | + textArea.addHyperlinkListener(evt -> { |
| 1017 | + try { |
| 1018 | + platform.openURL(sketch.getFolder(), evt.getURL().toExternalForm()); |
| 1019 | + } catch (Exception e) { |
| 1020 | + Base.showWarning(e.getMessage(), e.getMessage(), e); |
1036 | 1021 | }
|
1037 | 1022 | });
|
1038 |
| - textArea.addCaretListener(new CaretListener() { |
1039 |
| - |
1040 |
| - @Override |
1041 |
| - public void caretUpdate(CaretEvent e) { |
1042 |
| - int lineStart = textArea.getDocument().getDefaultRootElement().getElementIndex(e.getMark()); |
1043 |
| - int lineEnd = textArea.getDocument().getDefaultRootElement().getElementIndex(e.getDot()); |
1044 |
| - |
1045 |
| - lineStatus.set(lineStart, lineEnd); |
1046 |
| - } |
| 1023 | + textArea.addCaretListener(e -> { |
| 1024 | + Element root = textArea.getDocument().getDefaultRootElement(); |
| 1025 | + int lineStart = root.getElementIndex(e.getMark()); |
| 1026 | + int lineEnd = root.getElementIndex(e.getDot()); |
1047 | 1027 |
|
| 1028 | + lineStatus.set(lineStart, lineEnd); |
1048 | 1029 | });
|
1049 |
| - |
1050 | 1030 | ToolTipManager.sharedInstance().registerComponent(textArea);
|
1051 | 1031 |
|
1052 | 1032 | configurePopupMenu(textArea);
|
|
0 commit comments