use of edu.mit.csail.sdg.alloy4.OurSyntaxWidget in project org.alloytools.alloy by AlloyTools.
the class SimpleGUI method doFindNext.
/**
* This method performs Edit->FindNext.
*/
private Runner doFindNext() {
if (wrap)
return wrapMe();
if (lastFind.length() == 0)
return null;
OurSyntaxWidget t = text.get();
String all = t.getText();
int i = Util.indexOf(all, lastFind, t.getCaret() + (lastFindForward ? 0 : -1), lastFindForward, lastFindCaseSensitive);
if (i < 0) {
i = Util.indexOf(all, lastFind, lastFindForward ? 0 : (all.length() - 1), lastFindForward, lastFindCaseSensitive);
if (i < 0) {
log.logRed("The specified search string cannot be found.");
return null;
}
log.logRed("Search wrapped.");
} else {
log.clearError();
}
if (lastFindForward)
t.moveCaret(i, i + lastFind.length());
else
t.moveCaret(i + lastFind.length(), i);
t.requestFocusInWindow();
return null;
}
use of edu.mit.csail.sdg.alloy4.OurSyntaxWidget in project org.alloytools.alloy by AlloyTools.
the class SimpleGUI method doGoto.
/**
* This method performs Edit->Goto.
*/
private Runner doGoto() {
if (wrap)
return wrapMe();
JTextField y = OurUtil.textfield("", 10);
JTextField x = OurUtil.textfield("", 10);
if (!OurDialog.getInput("Go To", "Line Number:", y, "Column Number (optional):", x))
return null;
try {
OurSyntaxWidget t = text.get();
int xx = 1, yy = Integer.parseInt(y.getText()), lineCount = t.getLineCount();
if (yy < 1)
return null;
if (yy > lineCount) {
log.logRed("This file only has " + lineCount + " line(s).");
return null;
}
if (x.getText().length() != 0)
xx = Integer.parseInt(x.getText());
if (xx < 1) {
log.logRed("If the column number is specified, it must be 1 or greater.");
return null;
}
int caret = t.getLineStartOffset(yy - 1);
int len = (yy == lineCount ? t.getText().length() + 1 : t.getLineStartOffset(yy)) - caret;
if (xx > len)
xx = len;
if (xx < 1)
xx = 1;
t.moveCaret(caret + xx - 1, caret + xx - 1);
t.requestFocusInWindow();
} catch (NumberFormatException ex) {
log.logRed("The number must be 1 or greater.");
} catch (Throwable ex) {
// This error is not important
}
return null;
}
use of edu.mit.csail.sdg.alloy4.OurSyntaxWidget in project org.alloytools.alloy by AlloyTools.
the class SimpleGUI method notifyChange.
/**
* Updates the status bar at the bottom of the screen.
*/
private Runner notifyChange() {
if (wrap)
return wrapMe();
commands = null;
if (text == null)
// If this was called prior to the "text" being fully
return null;
// initialized
OurSyntaxWidget t = text.get();
if (Util.onMac())
frame.getRootPane().putClientProperty("windowModified", Boolean.valueOf(t.modified()));
if (t.isFile())
frame.setTitle(t.getFilename());
else
frame.setTitle("Alloy Analyzer " + Version.version());
toolbar.setBorder(new OurBorder(false, false, text.count() <= 1, false));
int c = t.getCaret();
int y = t.getLineOfOffset(c) + 1;
int x = c - t.getLineStartOffset(y - 1) + 1;
status.setText("<html> Line " + y + ", Column " + x + (t.modified() ? " <b style=\"color:#B43333;\">[modified]</b></html>" : "</html>"));
return null;
}
Aggregations