-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from Squareys/scripteditor-cleanup
Overhaul the script editor with cleaned up style, javadoc, and better separation of concerns via decoupling the TextEditor and EditorPane.
- Loading branch information
Showing
15 changed files
with
1,675 additions
and
1,240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
package net.imagej.ui.swing.script; | ||
|
||
import javax.swing.text.BadLocationException; | ||
|
||
import org.fife.ui.rtextarea.GutterIconInfo; | ||
|
||
/** | ||
* A "bookmark" is a stored location (line, file) in the text editor. | ||
* | ||
* @author Johannes Schindelin | ||
* @author Jonathan Hale | ||
*/ | ||
public class Bookmark { | ||
|
||
TextEditorTab tab; | ||
GutterIconInfo info; | ||
|
||
public Bookmark(final TextEditorTab tab, final GutterIconInfo info) { | ||
this.tab = tab; | ||
this.info = info; | ||
} | ||
|
||
public int getLineNumber() { | ||
try { | ||
return tab.editorPane.getLineOfOffset(info.getMarkedOffset()); | ||
} | ||
catch (final BadLocationException e) { | ||
return -1; | ||
} | ||
} | ||
|
||
public void setCaret() { | ||
tab.requestFocus(); | ||
tab.editorPane.setCaretPosition(info.getMarkedOffset()); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Line " + (getLineNumber() + 1) + " (" + tab.editorPane.getFileName() + ")"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.