Restored current line/current selected lines display on lower left of the IDE. Fixes #3134

This commit is contained in:
Federico Fissore 2015-05-14 15:55:49 +02:00
parent 54da4d6d37
commit d57681c442
3 changed files with 14 additions and 19 deletions

View File

@ -251,7 +251,7 @@ public class Editor extends JFrame implements RunnerListener {
console.setBorder(null); console.setBorder(null);
consolePanel.add(console, BorderLayout.CENTER); consolePanel.add(console, BorderLayout.CENTER);
lineStatus = new EditorLineStatus(textarea); lineStatus = new EditorLineStatus();
consolePanel.add(lineStatus, BorderLayout.SOUTH); consolePanel.add(lineStatus, BorderLayout.SOUTH);
// RTextScrollPane // RTextScrollPane
@ -957,7 +957,7 @@ public class Editor extends JFrame implements RunnerListener {
protected SketchTextArea createTextArea() throws IOException { protected SketchTextArea createTextArea() throws IOException {
SketchTextArea textArea = new SketchTextArea(base.getPdeKeywords()); final SketchTextArea textArea = new SketchTextArea(base.getPdeKeywords());
textArea.requestFocusInWindow(); textArea.requestFocusInWindow();
textArea.setMarkOccurrences(PreferencesData.getBoolean("editor.advanced")); textArea.setMarkOccurrences(PreferencesData.getBoolean("editor.advanced"));
textArea.setMarginLineEnabled(false); textArea.setMarginLineEnabled(false);
@ -976,6 +976,17 @@ public class Editor extends JFrame implements RunnerListener {
} }
} }
}); });
textArea.addCaretListener(new CaretListener() {
@Override
public void caretUpdate(CaretEvent e) {
int lineStart = textArea.getDocument().getDefaultRootElement().getElementIndex(e.getMark());
int lineEnd = textArea.getDocument().getDefaultRootElement().getElementIndex(e.getDot());
lineStatus.set(lineStart, lineEnd);
}
});
ToolTipManager.sharedInstance().registerComponent(textArea); ToolTipManager.sharedInstance().registerComponent(textArea);

View File

@ -37,8 +37,6 @@ import processing.app.syntax.SketchTextArea;
* Li'l status bar fella that shows the line number. * Li'l status bar fella that shows the line number.
*/ */
public class EditorLineStatus extends JComponent { public class EditorLineStatus extends JComponent {
SketchTextArea textarea;
int start = -1, stop; int start = -1, stop;
Image resize; Image resize;
@ -55,11 +53,7 @@ public class EditorLineStatus extends JComponent {
String serialport = ""; String serialport = "";
public EditorLineStatus(SketchTextArea textarea) { public EditorLineStatus() {
this.textarea = textarea;
textarea.setEditorLineStatus(this);
background = Theme.getColor("linestatus.bgcolor"); background = Theme.getColor("linestatus.bgcolor");
font = Theme.getFont("linestatus.font"); font = Theme.getFont("linestatus.font");
foreground = Theme.getColor("linestatus.color"); foreground = Theme.getColor("linestatus.color");

View File

@ -76,11 +76,6 @@ public class SketchTextArea extends RSyntaxTextArea {
*/ */
private FocusableTip docTooltip; private FocusableTip docTooltip;
/**
* The component that tracks the current line number.
*/
protected EditorLineStatus editorLineStatus;
private EditorListener editorListener; private EditorListener editorListener;
private final PdeKeywords pdeKeywords; private final PdeKeywords pdeKeywords;
@ -168,14 +163,9 @@ public class SketchTextArea extends RSyntaxTextArea {
} }
public void setEditorLineStatus(EditorLineStatus editorLineStatus) {
this.editorLineStatus = editorLineStatus;
}
@Override @Override
public void select(int selectionStart, int selectionEnd) { public void select(int selectionStart, int selectionEnd) {
super.select(selectionStart, selectionEnd); super.select(selectionStart, selectionEnd);
if (editorLineStatus != null) editorLineStatus.set(selectionStart, selectionEnd);
} }
public boolean isSelectionActive() { public boolean isSelectionActive() {