Skip to content

Commit d57681c

Browse files
author
Federico Fissore
committed
Restored current line/current selected lines display on lower left of the IDE. Fixes #3134
1 parent 54da4d6 commit d57681c

File tree

3 files changed

+14
-19
lines changed

3 files changed

+14
-19
lines changed

app/src/processing/app/Editor.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public void windowDeactivated(WindowEvent e) {
251251
console.setBorder(null);
252252
consolePanel.add(console, BorderLayout.CENTER);
253253

254-
lineStatus = new EditorLineStatus(textarea);
254+
lineStatus = new EditorLineStatus();
255255
consolePanel.add(lineStatus, BorderLayout.SOUTH);
256256

257257
// RTextScrollPane
@@ -957,7 +957,7 @@ protected String findClassInZipFile(String base, File file) {
957957

958958

959959
protected SketchTextArea createTextArea() throws IOException {
960-
SketchTextArea textArea = new SketchTextArea(base.getPdeKeywords());
960+
final SketchTextArea textArea = new SketchTextArea(base.getPdeKeywords());
961961
textArea.requestFocusInWindow();
962962
textArea.setMarkOccurrences(PreferencesData.getBoolean("editor.advanced"));
963963
textArea.setMarginLineEnabled(false);
@@ -976,6 +976,17 @@ public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) {
976976
}
977977
}
978978
});
979+
textArea.addCaretListener(new CaretListener() {
980+
981+
@Override
982+
public void caretUpdate(CaretEvent e) {
983+
int lineStart = textArea.getDocument().getDefaultRootElement().getElementIndex(e.getMark());
984+
int lineEnd = textArea.getDocument().getDefaultRootElement().getElementIndex(e.getDot());
985+
986+
lineStatus.set(lineStart, lineEnd);
987+
}
988+
989+
});
979990

980991
ToolTipManager.sharedInstance().registerComponent(textArea);
981992

app/src/processing/app/EditorLineStatus.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
* Li'l status bar fella that shows the line number.
3838
*/
3939
public class EditorLineStatus extends JComponent {
40-
SketchTextArea textarea;
41-
4240
int start = -1, stop;
4341

4442
Image resize;
@@ -55,11 +53,7 @@ public class EditorLineStatus extends JComponent {
5553
String serialport = "";
5654

5755

58-
public EditorLineStatus(SketchTextArea textarea) {
59-
60-
this.textarea = textarea;
61-
textarea.setEditorLineStatus(this);
62-
56+
public EditorLineStatus() {
6357
background = Theme.getColor("linestatus.bgcolor");
6458
font = Theme.getFont("linestatus.font");
6559
foreground = Theme.getColor("linestatus.color");

app/src/processing/app/syntax/SketchTextArea.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@ public class SketchTextArea extends RSyntaxTextArea {
7676
*/
7777
private FocusableTip docTooltip;
7878

79-
/**
80-
* The component that tracks the current line number.
81-
*/
82-
protected EditorLineStatus editorLineStatus;
83-
8479
private EditorListener editorListener;
8580

8681
private final PdeKeywords pdeKeywords;
@@ -168,14 +163,9 @@ private void removeCTRLTabFromFocusTraversal() {
168163
}
169164

170165

171-
public void setEditorLineStatus(EditorLineStatus editorLineStatus) {
172-
this.editorLineStatus = editorLineStatus;
173-
}
174-
175166
@Override
176167
public void select(int selectionStart, int selectionEnd) {
177168
super.select(selectionStart, selectionEnd);
178-
if (editorLineStatus != null) editorLineStatus.set(selectionStart, selectionEnd);
179169
}
180170

181171
public boolean isSelectionActive() {

0 commit comments

Comments
 (0)