ConfigSciNotesManager.createUserCopy();
ScilabTabFactory.getInstance().addTabFactory(SciNotesTabFactory.getInstance());
Scilab.registerInitialHook(new Runnable() {
- @Override
- public void run() {
- updateSciNotes();
- }
- });
+ @Override
+ public void run() {
+ updateSciNotes();
+ }
+ });
Document doc = ScilabXMLUtilities.readDocument(System.getenv("SCI") + "/modules/console/etc/Actions-Configuration.xml");
actionToName = XConfiguration.get(doc, "name", String.class, "action", String.class, XPATH_SCINOTES_ACTION);
contentPane = new SciNotesContents(this);
tabPane = contentPane.getScilabTabbedPane();
tabPane.addChangeListener(new ChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- if (getTextPane() != null) {
- // updateUI();
- getTextPane().updateInfosWhenFocused();
- getTextPane().requestFocus();
- getTextPane().highlightWords(IncrementalSearchAction.getWord(SciNotes.this), IncrementalSearchAction.getExact(SciNotes.this));
-
- // Update encoding menu
- EncodingAction.updateEncodingMenu((ScilabDocument) getTextPane().getDocument());
-
- // Update End Of Line menu
- EndOfLineAction.updateEolMenu((ScilabDocument) getTextPane().getDocument());
- setTitle(getTextPane().getTitle());
- }
+ @Override
+ public void stateChanged(ChangeEvent e) {
+ if (getTextPane() != null) {
+ // updateUI();
+ getTextPane().updateInfosWhenFocused();
+ getTextPane().requestFocus();
+ getTextPane().highlightWords(IncrementalSearchAction.getWord(SciNotes.this), IncrementalSearchAction.getExact(SciNotes.this));
+
+ // Update encoding menu
+ EncodingAction.updateEncodingMenu((ScilabDocument) getTextPane().getDocument());
+
+ // Update End Of Line menu
+ EndOfLineAction.updateEolMenu((ScilabDocument) getTextPane().getDocument());
+ setTitle(getTextPane().getTitle());
}
- });
+ }
+ });
this.setContentPane(contentPane);
}
try {
SwingUtilities.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- launchSciNotes();
- // Open an empty file if no tabs were opened at launch.
- if (editor.getTabPane().getTabCount() == 0) {
- editor.openFile(null, 0, null);
- }
+ @Override
+ public void run() {
+ launchSciNotes();
+ // Open an empty file if no tabs were opened at launch.
+ if (editor.getTabPane().getTabCount() == 0) {
+ editor.openFile(null, 0, null);
}
- });
+ }
+ });
} catch (InterruptedException e) {
Logger.getLogger(SciNotes.class.getName()).severe(e.toString());
throw new RuntimeException(e);
try {
SwingUtilities.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- launchSciNotes();
- editor.openFile(filePath, 0, null);
- }
- });
+ @Override
+ public void run() {
+ launchSciNotes();
+ editor.openFile(filePath, 0, null);
+ }
+ });
} catch (InterruptedException e) {
Logger.getLogger(SciNotes.class.getName()).severe(e.toString());
throw new RuntimeException(e);
try {
SwingUtilities.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- launchSciNotes();
- editor.openFile(filePath, lineNumber, functionName);
- }
- });
+ @Override
+ public void run() {
+ launchSciNotes();
+ editor.openFile(filePath, lineNumber, functionName);
+ }
+ });
} catch (InterruptedException e) {
Logger.getLogger(SciNotes.class.getName()).severe(e.toString());
throw new RuntimeException(e);
try {
SwingUtilities.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- launchSciNotes();
- if (options != null && options.length != 0) {
- editor.openFile(filePath, 0, options[0]);
- } else {
- editor.openFile(filePath, 0, "");
- }
+ @Override
+ public void run() {
+ launchSciNotes();
+ if (options != null && options.length != 0) {
+ editor.openFile(filePath, 0, options[0]);
+ } else {
+ editor.openFile(filePath, 0, "");
}
- });
+ }
+ });
} catch (InterruptedException e) {
Logger.getLogger(SciNotes.class.getName()).severe(e.toString());
throw new RuntimeException(e);
try {
SwingUtilities.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- restorePreviousSession();
- }
- });
+ @Override
+ public void run() {
+ restorePreviousSession();
+ }
+ });
} catch (InterruptedException e) {
Logger.getLogger(SciNotes.class.getName()).severe(e.toString());
throw new RuntimeException(e);
}
SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- RestoreOpenedFilesAction.displayDialog((JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, SciNotes.this), getUUID().toString());
- List<File> list = RestoreOpenedFilesAction.getSelectedFiles();
-
- if (list != null && list.size() != 0) {
- for (File f : list) {
- openFile(f.getPath(), 0, null);
- }
- } else {
- if (getTabPane().getTabCount() == 0 || getTextPane(0).getName() == null) {
- openFile(null, 0, null);
- }
+ @Override
+ public void run() {
+ RestoreOpenedFilesAction.displayDialog((JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, SciNotes.this), getUUID().toString());
+ List<File> list = RestoreOpenedFilesAction.getSelectedFiles();
+
+ if (list != null && list.size() != 0) {
+ for (File f : list) {
+ openFile(f.getPath(), 0, null);
}
-
- setWindowIcon("accessories-text-editor");
-
- if (navigator != null) {
- navigator.updateTree();
+ } else {
+ if (getTabPane().getTabCount() == 0 || getTextPane(0).getName() == null) {
+ openFile(null, 0, null);
}
+ }
+
+ setWindowIcon("accessories-text-editor");
- WindowsConfigurationManager.restorationFinished(SciNotes.this);
+ if (navigator != null) {
+ navigator.updateTree();
}
- });
+
+ WindowsConfigurationManager.restorationFinished(SciNotes.this);
+ }
+ });
}
/**
if (!force) {
AnswerOption answer;
if (scilabClose) {
- answer = ScilabModalDialog.show(this, getTabPane().getScilabTitleAt(indexTab) + SciNotesMessages.MODIFIED, SciNotesMessages.SCILAB_EDITOR,
+ answer = ScilabModalDialog.show(this, String.format(SciNotesMessages.MODIFIED, textPaneAt.getShortName()), SciNotesMessages.SCILAB_EDITOR,
IconType.QUESTION_ICON, ButtonType.YES_NO);
} else {
- answer = ScilabModalDialog.show(this, getTabPane().getScilabTitleAt(indexTab) + SciNotesMessages.MODIFIED, SciNotesMessages.SCILAB_EDITOR,
+ answer = ScilabModalDialog.show(this, String.format(SciNotesMessages.MODIFIED, textPaneAt.getShortName()), SciNotesMessages.SCILAB_EDITOR,
IconType.QUESTION_ICON, ButtonType.YES_NO_CANCEL);
}
switch (answer) {
- case YES_OPTION: // Yes, continue
- break;
- case NO_OPTION:// No, exit and returns true
- return true;
- case CANCEL_OPTION: // Cancel, exit and return false
- return false;
- default:
- break;
+ case YES_OPTION: // Yes, continue
+ break;
+ case NO_OPTION:// No, exit and returns true
+ return true;
+ case CANCEL_OPTION: // Cancel, exit and return false
+ return false;
+ default:
+ break;
}
}
String fileName = f.getName();
if (fileName.lastIndexOf(DOT) != -1) {
if (fileName.substring(fileName.lastIndexOf(DOT), fileName.length()).length() >= 2
- && fileName.substring(fileName.lastIndexOf(DOT), fileName.length()).length() <= 4) {
+ && fileName.substring(fileName.lastIndexOf(DOT), fileName.length()).length() <= 4) {
hasNoExtension = false;
}
}
messageBox.displayAndWait(); // Waits for a user action
switch (messageBox.getSelectedButton()) {
- case 1: // Reload
- if ((i == 0) && (getTabPane().getTabCount() == 1)) {
- for (int j = 0; j < tabPane.getChangeListeners().length; j++) {
- tabPane.removeChangeListener(tabPane.getChangeListeners()[j]);
+ case 1: // Reload
+ if ((i == 0) && (getTabPane().getTabCount() == 1)) {
+ for (int j = 0; j < tabPane.getChangeListeners().length; j++) {
+ tabPane.removeChangeListener(tabPane.getChangeListeners()[j]);
+ }
}
- }
- tabPane.remove(i);
- f = new File(textPaneAt.getName());
- index = i;
- break;
- case 2: // Overwrite 2
- overwrite(i);
- alreadyOpened = true;
- break;
- default: // Ignore
- alreadyOpened = true;
+ tabPane.remove(i);
+ f = new File(textPaneAt.getName());
+ index = i;
+ break;
+ case 2: // Overwrite 2
+ overwrite(i);
+ alreadyOpened = true;
+ break;
+ default: // Ignore
+ alreadyOpened = true;
}
} else {
alreadyOpened = true;
ScilabEditorPane theTextPane = addEmptyTab();
ScilabDocument styleDocument = null;
int choice = JOptionPane.showConfirmDialog(SciNotes.this, String.format(SciNotesMessages.FILE_DOESNT_EXIST, f.getName()), SCINOTES,
- JOptionPane.YES_NO_OPTION);
+ JOptionPane.YES_NO_OPTION);
if (choice == 0) { // OK
styleDocument = (ScilabDocument) theTextPane.getDocument();
styleDocument.disableUndoManager();
try {
SwingUtilities.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- SciNotes[] arr = scinotesList.toArray(new SciNotes[0]);
- for (int i = 0; i < arr.length; i++) {
- arr[i].setProtectOpenFileList(true);
- ExitAction.doExit(arr[i]);
- }
- scinotesList.clear();
+ @Override
+ public void run() {
+ SciNotes[] arr = scinotesList.toArray(new SciNotes[0]);
+ for (int i = 0; i < arr.length; i++) {
+ arr[i].setProtectOpenFileList(true);
+ ExitAction.doExit(arr[i]);
}
- });
+ scinotesList.clear();
+ }
+ });
} catch (InterruptedException e) {
Logger.getLogger(SciNotes.class.getName()).severe(e.toString());
} catch (InvocationTargetException e) {
public static boolean executeAction(String fileName, final String[] actionsName) throws IOException {
final boolean[] hasAction = new boolean[] { false };
ActionOnDocument action = new ActionOnDocument() {
- public void actionOn(ScilabDocument doc) throws IOException {
- for (String act : actionsName) {
- if (act.equalsIgnoreCase("indent")) {
- hasAction[0] = true;
- org.scilab.modules.scinotes.actions.IndentAction.getActionOnDocument().actionOn(doc);
- } else if (act.equalsIgnoreCase("trailing")) {
- hasAction[0] = true;
- org.scilab.modules.scinotes.actions.RemoveTrailingWhiteAction.getActionOnDocument().actionOn(doc);
- } else if (act.equalsIgnoreCase("quote")) {
- hasAction[0] = true;
- org.scilab.modules.scinotes.actions.DoubleQuoteStringAction.getActionOnDocument().actionOn(doc);
- }
+ public void actionOn(ScilabDocument doc) throws IOException {
+ for (String act : actionsName) {
+ if (act.equalsIgnoreCase("indent")) {
+ hasAction[0] = true;
+ org.scilab.modules.scinotes.actions.IndentAction.getActionOnDocument().actionOn(doc);
+ } else if (act.equalsIgnoreCase("trailing")) {
+ hasAction[0] = true;
+ org.scilab.modules.scinotes.actions.RemoveTrailingWhiteAction.getActionOnDocument().actionOn(doc);
+ } else if (act.equalsIgnoreCase("quote")) {
+ hasAction[0] = true;
+ org.scilab.modules.scinotes.actions.DoubleQuoteStringAction.getActionOnDocument().actionOn(doc);
}
}
- };
+ }
+ };
executeAction(fileName, action);
import org.scilab.modules.commons.OS;
import org.scilab.modules.commons.gui.ScilabCaret;
import org.scilab.modules.console.utils.ScilabLaTeXViewer;
+import org.scilab.modules.gui.messagebox.MessageBox;
+import org.scilab.modules.gui.messagebox.ScilabMessageBox;
+import org.scilab.modules.gui.messagebox.ScilabModalDialog;
+import org.scilab.modules.gui.messagebox.ScilabModalDialog.AnswerOption;
+import org.scilab.modules.gui.messagebox.ScilabModalDialog.ButtonType;
+import org.scilab.modules.gui.messagebox.ScilabModalDialog.IconType;
import org.scilab.modules.gui.utils.WebBrowser;
import org.scilab.modules.scinotes.actions.CopyAsHTMLAction;
import org.scilab.modules.scinotes.actions.OpenSourceFileOnKeywordAction;
*
*/
public class ScilabEditorPane extends JEditorPane implements Highlighter.HighlightPainter,
- CaretListener, MouseListener,
- MouseMotionListener, Cloneable,
- KeyListener {
+ CaretListener, MouseListener,
+ MouseMotionListener, Cloneable,
+ KeyListener {
private static final long serialVersionUID = 4322071415211939097L;
private Point mousePoint;
private long lastModified;
+ private long lastExternalModification;
/* matchLR matches Left to Right ... */
private MatchingBlockManager matchLR;
enableMatchingOpeners(SciNotesOptions.getSciNotesDisplay().highlightBrackets);
setFocusable(true);
addFocusListener(new FocusListener() {
- public void focusGained(FocusEvent e) {
- updateInfosWhenFocused();
- if (ScilabEditorPane.this.editor != null) {
- NavigatorWindow nav = ScilabEditorPane.this.editor.getNavigator();
- if (nav != null) {
- nav.update((ScilabDocument) getDocument());
- }
+ public void focusGained(FocusEvent e) {
+ updateInfosWhenFocused();
+ if (ScilabEditorPane.this.editor != null) {
+ NavigatorWindow nav = ScilabEditorPane.this.editor.getNavigator();
+ if (nav != null) {
+ nav.update((ScilabDocument) getDocument());
}
}
+ }
- public void focusLost(FocusEvent e) {
- ((ScilabDocument) getDocument()).setFocused(false);
- }
- });
+ public void focusLost(FocusEvent e) {
+ ((ScilabDocument) getDocument()).setFocused(false);
+ }
+ });
addKeywordListener(new KeywordAdapter.MouseOverAdapter() {
- public void caughtKeyword(KeywordEvent e) {
- if (ScilabLexerConstants.isClickable(e.getType())) {
- if (ctrlHit) {
- setCursor(HANDCURSOR);
- hand = true;
- try {
- String url = ((ScilabDocument) getDocument()).getText(e.getStart(), e.getLength());
- if (ScilabLexerConstants.isClickable(e.getType())) {
- String text;
- switch (e.getType()) {
+ public void caughtKeyword(KeywordEvent e) {
+ if (ScilabLexerConstants.isClickable(e.getType())) {
+ if (ctrlHit) {
+ setCursor(HANDCURSOR);
+ hand = true;
+ try {
+ String url = ((ScilabDocument) getDocument()).getText(e.getStart(), e.getLength());
+ if (ScilabLexerConstants.isClickable(e.getType())) {
+ String text;
+ switch (e.getType()) {
case ScilabLexerConstants.URL :
text = SciNotesMessages.OPENURL;
break;
break;
default :
text = null;
- }
+ }
- if (text != null && ScilabEditorPane.this.editor != null) {
- ScilabEditorPane.this.editor.getInfoBar().setText(text + url);
- infoBarChanged = true;
- }
+ if (text != null && ScilabEditorPane.this.editor != null) {
+ ScilabEditorPane.this.editor.getInfoBar().setText(text + url);
+ infoBarChanged = true;
}
- } catch (BadLocationException ex) { }
- } else if (ScilabEditorPane.this.editor != null) {
- ScilabEditorPane.this.editor.getInfoBar().setText(SciNotesMessages.CLICKABLE_URL);
- infoBarChanged = true;
- if (hand) {
- setCursor(TEXTCURSOR);
- hand = false;
}
- }
- } else {
+ } catch (BadLocationException ex) { }
+ } else if (ScilabEditorPane.this.editor != null) {
+ ScilabEditorPane.this.editor.getInfoBar().setText(SciNotesMessages.CLICKABLE_URL);
+ infoBarChanged = true;
if (hand) {
setCursor(TEXTCURSOR);
hand = false;
}
- if (infoBarChanged && ScilabEditorPane.this.editor != null) {
- ScilabEditorPane.this.editor.getInfoBar().setText(infoBar);
- infoBarChanged = false;
- }
- if (ScilabLexerConstants.isLaTeX(e.getType())) {
- try {
- int start = e.getStart();
- int end = start + e.getLength();
- String exp = ((ScilabDocument) getDocument()).getText(start, e.getLength());
- int height = edComponent.getScrollPane().getHeight() + edComponent.getScrollPane().getVerticalScrollBar().getValue();
- ScilabLaTeXViewer.displayExpression(ScilabEditorPane.this, height, exp, start, end);
- } catch (BadLocationException ex) { }
- } else {
- ScilabLaTeXViewer.removeLaTeXViewer(ScilabEditorPane.this);
- }
}
- }
- });
-
- addKeywordListener(new KeywordAdapter.MouseClickedAdapter() {
- public void caughtKeyword(KeywordEvent e) {
- if (ctrlHit && ScilabLexerConstants.isClickable(e.getType())) {
+ } else {
+ if (hand) {
+ setCursor(TEXTCURSOR);
+ hand = false;
+ }
+ if (infoBarChanged && ScilabEditorPane.this.editor != null) {
+ ScilabEditorPane.this.editor.getInfoBar().setText(infoBar);
+ infoBarChanged = false;
+ }
+ if (ScilabLexerConstants.isLaTeX(e.getType())) {
try {
- hand = false;
- ctrlHit = false;
- infoBarChanged = false;
- setCursor(TEXTCURSOR);
- if (ScilabEditorPane.this.editor != null) {
- ScilabEditorPane.this.editor.getInfoBar().setText(infoBar);
- }
- String url = ((ScilabDocument) getDocument()).getText(e.getStart(), e.getLength());
- if (ScilabLexerConstants.URL == e.getType() || ScilabLexerConstants.MAIL == e.getType()) {
- WebBrowser.openUrl(url);
- } else if (ScilabLexerConstants.isOpenable(e.getType())) {
- OpenSourceFileOnKeywordAction.openSource(ScilabEditorPane.this, url);
- }
+ int start = e.getStart();
+ int end = start + e.getLength();
+ String exp = ((ScilabDocument) getDocument()).getText(start, e.getLength());
+ int height = edComponent.getScrollPane().getHeight() + edComponent.getScrollPane().getVerticalScrollBar().getValue();
+ ScilabLaTeXViewer.displayExpression(ScilabEditorPane.this, height, exp, start, end);
} catch (BadLocationException ex) { }
+ } else {
+ ScilabLaTeXViewer.removeLaTeXViewer(ScilabEditorPane.this);
}
}
- });
+ }
+ });
+
+ addKeywordListener(new KeywordAdapter.MouseClickedAdapter() {
+ public void caughtKeyword(KeywordEvent e) {
+ if (ctrlHit && ScilabLexerConstants.isClickable(e.getType())) {
+ try {
+ hand = false;
+ ctrlHit = false;
+ infoBarChanged = false;
+ setCursor(TEXTCURSOR);
+ if (ScilabEditorPane.this.editor != null) {
+ ScilabEditorPane.this.editor.getInfoBar().setText(infoBar);
+ }
+ String url = ((ScilabDocument) getDocument()).getText(e.getStart(), e.getLength());
+ if (ScilabLexerConstants.URL == e.getType() || ScilabLexerConstants.MAIL == e.getType()) {
+ WebBrowser.openUrl(url);
+ } else if (ScilabLexerConstants.isOpenable(e.getType())) {
+ OpenSourceFileOnKeywordAction.openSource(ScilabEditorPane.this, url);
+ }
+ } catch (BadLocationException ex) { }
+ }
+ }
+ });
getScrollPane().addMouseWheelListener(new MouseWheelListener() {
- public void mouseWheelMoved(MouseWheelEvent e) {
- if ((OS.get() == OS.MAC && e.isMetaDown()) || e.isControlDown()) {
- int n = e.getWheelRotation();
- SciNotes.updateFontSize(n);
- e.consume();
- }
+ public void mouseWheelMoved(MouseWheelEvent e) {
+ if ((OS.get() == OS.MAC && e.isMetaDown()) || e.isControlDown()) {
+ int n = e.getWheelRotation();
+ SciNotes.updateFontSize(n);
+ e.consume();
}
- });
+ }
+ });
addKeyListener(this);
setTransferHandler(new CopyAsHTMLAction.HTMLTransferHandler());
public void keyPressed(KeyEvent e) {
// Workaround for bug 7238
if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_NUMPAD
- && e.getKeyCode() == KeyEvent.VK_DELETE
- && e.getKeyChar() != KeyEvent.VK_DELETE) {
+ && e.getKeyCode() == KeyEvent.VK_DELETE
+ && e.getKeyChar() != KeyEvent.VK_DELETE) {
e.setKeyCode(KeyEvent.VK_DECIMAL);
ctrlHit = false;
} else if (mousePoint != null && e.getKeyCode() == KeyEvent.VK_CONTROL) {
*/
public void init(final int pos) {
SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- requestFocus();
- setCaretPosition(pos);
- }
- });
+ public void run() {
+ requestFocus();
+ setCaretPosition(pos);
+ }
+ });
}
/**
doc.getUndoManager().enableUndoRedoButtons();
if (editor != null) {
- if (checkExternalModif()) {
+ if (checkExternalModif() && lastExternalModification < getLastModification()) {
editor.getInfoBar().setText(SciNotesMessages.EXTERNAL_MODIFICATION_INFO);
+ if (ScilabModalDialog.show(editor, String.format(SciNotesMessages.ASK_TO_RELOAD, getShortName()), SciNotesMessages.RELOAD, IconType.QUESTION_ICON, ButtonType.YES_NO) == AnswerOption.YES_OPTION) {
+ editor.reload(getEditor().getTabPane().indexOfComponent(getEditorComponent()));
+ editor.getTextPane().updateInfosWhenFocused();
+ }
+ lastExternalModification = getLastModification();
} else {
editor.getInfoBar().setText(getInfoBarText());
}
}
/**
+ * Get last modification on file
+ * @return the lastModified value
+ */
+ public long getLastModification() {
+ String path = getName();
+ if (path != null) {
+ File f = new File(path);
+ if (f != null && f.exists()) {
+ return f.lastModified();
+ }
+ }
+
+ return -1;
+ }
+
+ /**
* @return the String which must be displayed in the infobar
*/
public String getInfoBarText() {
*/
public void scrollTextToPos(final int pos, final boolean setCaret, final boolean centered) {
SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- try {
- if (setCaret) {
- setCaretPosition(pos);
+ public void run() {
+ try {
+ if (setCaret) {
+ setCaretPosition(pos);
+ }
+ JScrollBar scrollbar = edComponent.getScrollPane().getVerticalScrollBar();
+ Rectangle rect = modelToView(pos);
+ if (centered) {
+ int value = scrollbar.getValue();
+ int h = scrollbar.getHeight();
+ if (rect.y < value || rect.y > value + h) {
+ scrollbar.setValue(Math.max(0, rect.y - h / 2));
}
- JScrollBar scrollbar = edComponent.getScrollPane().getVerticalScrollBar();
- Rectangle rect = modelToView(pos);
- if (centered) {
- int value = scrollbar.getValue();
- int h = scrollbar.getHeight();
- if (rect.y < value || rect.y > value + h) {
- scrollbar.setValue(Math.max(0, rect.y - h / 2));
- }
- } else {
- if (rect.y > scrollbar.getMaximum()) {
- scrollbar.setMaximum(rect.y);
- }
- scrollbar.setValue(rect.y);
+ } else {
+ if (rect.y > scrollbar.getMaximum()) {
+ scrollbar.setMaximum(rect.y);
}
- } catch (BadLocationException e) { }
- }
- });
+ scrollbar.setValue(rect.y);
+ }
+ } catch (BadLocationException e) { }
+ }
+ });
}
/**
if (lineNumber >= 1 && lineNumber <= root.getElementCount()) {
final int pos = root.getElement(lineNumber - 1).getStartOffset();
SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- scrollTextToPos(pos, setCaret, centered);
- if (highlight) {
- saveHighlightContourColor = highlightContourColor;
- highlightContourColor = null;
- saveHighlightColor = highlightColor;
- highlightColor = Color.YELLOW;
- saveHighlightEnable = highlightEnable;
- hasBeenSaved = true;
- enableHighlightedLine(false);
- enableHighlightedLine(true);
- }
+ public void run() {
+ scrollTextToPos(pos, setCaret, centered);
+ if (highlight) {
+ saveHighlightContourColor = highlightContourColor;
+ highlightContourColor = null;
+ saveHighlightColor = highlightColor;
+ highlightColor = Color.YELLOW;
+ saveHighlightEnable = highlightEnable;
+ hasBeenSaved = true;
+ enableHighlightedLine(false);
+ enableHighlightedLine(true);
}
- });
+ }
+ });
}
}
final Caret caret = new SciNotesCaret(this);
setCaretColor(getCaretColor());
SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- int blinkRate = 500;
- Object o = UIManager.get("TextComponent.caretBlinkRate");
- if ((o != null) && (o instanceof Integer)) {
- Integer rate = (Integer) o;
- blinkRate = rate.intValue();
- }
- caret.setBlinkRate(blinkRate);
- caret.setVisible(true);
+ public void run() {
+ int blinkRate = 500;
+ Object o = UIManager.get("TextComponent.caretBlinkRate");
+ if ((o != null) && (o instanceof Integer)) {
+ Integer rate = (Integer) o;
+ blinkRate = rate.intValue();
}
- });
+ caret.setBlinkRate(blinkRate);
+ caret.setVisible(true);
+ }
+ });
super.setCaret(caret);
} else {
super.setCaret(c);