8000 Bugfixes (as per https://forum.image.sc/t/shiny-new-script-editor/64160) · scijava/script-editor@9ef7c38 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9ef7c38

Browse files
committed
1 parent dee20fb commit 9ef7c38

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

src/main/java/org/scijava/ui/swing/script/EditorPane.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public class EditorPane extends RSyntaxTextArea implements DocumentListener {
157157
private PlatformService platformService;
158158
@Parameter
159159
private LogService log;
160-
160+
161161
/**
162162
* Constructor.
163163
*/
@@ -526,7 +526,9 @@ public void open(final File file) throws IOException {
526526
string.append(buffer, 0, count);
527527
}
528528
reader.close();
529-
setText(string.toString());
529+
SwingUtilities.invokeLater(() -> {
530+
setText(string.toString()); // otherwise GUI freezes!??
531+
});
530532
curFile = file;
531533
if (line > getLineCount()) line = getLineCount() - 1;
532534
try {

src/main/java/org/scijava/ui/swing/script/TextEditor.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2356,7 +2356,11 @@ void setLanguage(final ScriptLanguage language, final boolean addHeader) {
23562356

23572357
void updateLanguageMenu(final ScriptLanguage language) {
23582358
JMenuItem item = languageMenuItems.get(language);
2359-
if (item == null) item = noneLanguageItem;
2359+
if (item == null) {
2360+
// is none
2361+
item = noneLanguageItem;
2362+
setIncremental(false);
2363+
}
23602364
if (!item.isSelected()) {
23612365
item.setSelected(true);
23622366
}
@@ -3494,14 +3498,14 @@ private Reader evalScript(final String filename, Reader reader,
34943498

34953499
public void setIncremental(final boolean incremental) {
34963500

3497-
if (null == getCurrentLanguage()) {
3501+
if (incremental && null == getCurrentLanguage()) {
34983502
error("Select a language first!");
34993503
return;
35003504
}
35013505

35023506
this.incremental = incremental;
35033507

3504-
final JTextArea prompt = this.getTab().getPrompt();
3508+
final JTextArea prompt = getTab().getPrompt();
35053509
if (incremental) {
35063510
getTab().setREPLVisible(true);
35073511
prompt.addKeyListener(new KeyAdapter() {
@@ -3540,6 +3544,7 @@ public void keyPressed(final KeyEvent ke) {
35403544
screen.scrollRectToVisible(screen.modelToView(screen.getDocument().getLength()));
35413545
} catch (final Throwable t) {
35423546
log.error(t);
3547+
prompt.requestFocusInWindow();
35433548
}
35443549
ke.consume(); // avoid writing the line break
35453550
return;
@@ -3603,7 +3608,7 @@ public void keyPressed(final KeyEvent ke) {
36033608
for (final KeyListener kl : prompt.getKeyListeners()) {
36043609
prompt.removeKeyListener(kl);
36053610
}
3606-
getTab().getScreenAndPromptSplit().setDividerLocation(1.0);
3611+
getTab().setREPLVisible(false);
36073612
}
36083613
}
36093614

src/main/java/org/scijava/ui/swing/script/TextEditorTab.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ public void actionPerformed(final ActionEvent e) {
235235
bottom.add(scroll, bc);
236236

237237
prompt.setEnabled(false);
238-
238+
prompt.setFont(getEditorPane().getFont());
239+
239240
final JPanel prompt_panel = new JPanel();
240241
prompt_panel.setMinimumSize(new Dimension(0, 0));
241242
prompt_panel.setVisible(false);
@@ -303,12 +304,6 @@ public void actionPerformed(final ActionEvent e) {
303304
});
304305

305306
screenAndPromptSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, bottom, prompt_panel);
306-
prompt_panel.addComponentListener(new ComponentAdapter() {
307-
@Override
308-
public void componentResized(final ComponentEvent e) {
309-
if (prompt_panel.getHeight() ==0) incremental.setSelected(false);
310-
}
311-
});
312307

313308
// Enable ErrorSrip à la Eclipse. This will keep track of lines with 'Mark All'
314309
// occurrences as well as lines associated with ParserNotice.Level.WARNING and
@@ -353,6 +348,7 @@ void setREPLVisible(final boolean visible) {
353348
screenAndPromptSplitDividerLocation = getScreenAndPromptSplit().getDividerLocation();
354349
getScreenAndPromptSplit().setDividerLocation(1f);
355350
}
351+
incremental.setSelected(visible);
356352
});
357353
}
358354

@@ -383,6 +379,8 @@ public void restore() {
383379
ru 672D nit.setEnabled(true);
384380
killit.setEnabled(false);
385381
setExecutor(null);
382+
if(incremental.isSelected())
383+
prompt.requestFocusInWindow();
386384
});
387385
}
388386

0 commit comments

Comments
 (0)
0