1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-11-29 10:24:12 +01:00

Refresh lineStatus when tab gets focus

Fixes #9138
This commit is contained in:
Martino Facchin 2019-08-12 10:07:32 +02:00
parent 19c3def582
commit 452ac63200
2 changed files with 13 additions and 1 deletions

View File

@ -80,6 +80,8 @@ import javax.swing.TransferHandler;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.Element;
import org.fife.ui.rsyntaxtextarea.folding.FoldManager;

View File

@ -30,7 +30,8 @@ import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.io.IOException;
import javax.swing.Action;
@ -175,6 +176,15 @@ public class EditorTab extends JPanel implements SketchFile.TextStorage {
editor.lineStatus.set(lineStart, lineEnd);
});
textArea.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
Element root = textArea.getDocument().getDefaultRootElement();
int lineStart = root.getElementIndex(textArea.getCaret().getMark());
int lineEnd = root.getElementIndex(textArea.getCaret().getDot());
editor.lineStatus.set(lineStart, lineEnd);
};
public void focusLost(FocusEvent e) {};
});
ToolTipManager.sharedInstance().registerComponent(textArea);
configurePopupMenu(textArea);