mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-18 07:52:14 +01:00
Removing highlight when autoformatting. Fixes #3988.
Current highlighting logic is a bit buggy: see https://github.com/bobbylight/RSyntaxTextArea/issues/150.
This commit is contained in:
parent
cc1ed440e5
commit
421508268c
@ -91,10 +91,11 @@ public class AStyle implements Tool {
|
||||
int line = getLineOfOffset(textArea);
|
||||
int lineOffset = getLineOffset(textArea, line);
|
||||
|
||||
editor.getTextArea().getUndoManager().beginInternalAtomicEdit();
|
||||
textArea.getUndoManager().beginInternalAtomicEdit();
|
||||
editor.removeAllLineHighlights();
|
||||
editor.setText(formattedText);
|
||||
editor.getSketch().setModified(true);
|
||||
editor.getTextArea().getUndoManager().endInternalAtomicEdit();
|
||||
textArea.getUndoManager().endInternalAtomicEdit();
|
||||
|
||||
if (line != -1 && lineOffset != -1) {
|
||||
try {
|
||||
|
@ -41,8 +41,8 @@ import processing.app.forms.PasswordAuthorizationDialog;
|
||||
import processing.app.helpers.OSUtils;
|
||||
import processing.app.helpers.PreferencesMapException;
|
||||
import processing.app.legacy.PApplet;
|
||||
import processing.app.syntax.PdeKeywords;
|
||||
import processing.app.syntax.ArduinoTokenMakerFactory;
|
||||
import processing.app.syntax.PdeKeywords;
|
||||
import processing.app.syntax.SketchTextArea;
|
||||
import processing.app.tools.DiscourseFormat;
|
||||
import processing.app.tools.MenuScroller;
|
||||
@ -2006,7 +2006,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
textarea.removeAllLineHighlights();
|
||||
removeAllLineHighlights();
|
||||
sketch.prepare();
|
||||
sketch.build(verbose, saveHex);
|
||||
statusNotice(tr("Done compiling."));
|
||||
@ -2024,6 +2024,15 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
}
|
||||
}
|
||||
|
||||
public void removeAllLineHighlights() {
|
||||
textarea.removeAllLineHighlights();
|
||||
}
|
||||
|
||||
public void addLineHighlight(int line) throws BadLocationException {
|
||||
textarea.addLineHighlight(line, new Color(1, 0, 0, 0.2f));
|
||||
textarea.setCaretPosition(textarea.getLineStartOffset(line));
|
||||
}
|
||||
|
||||
private class DefaultStopHandler implements Runnable {
|
||||
public void run() {
|
||||
// TODO
|
||||
@ -2276,7 +2285,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
public boolean handleSave(boolean immediately) {
|
||||
//stopRunner();
|
||||
handleStop(); // 0136
|
||||
textarea.removeAllLineHighlights();
|
||||
removeAllLineHighlights();
|
||||
|
||||
if (untitled) {
|
||||
return handleSaveAs();
|
||||
@ -2430,7 +2439,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
public void run() {
|
||||
|
||||
try {
|
||||
textarea.removeAllLineHighlights();
|
||||
removeAllLineHighlights();
|
||||
if (serialMonitor != null) {
|
||||
serialMonitor.suspend();
|
||||
}
|
||||
@ -2876,8 +2885,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
System.err.println(I18n.format(tr("Bad error line: {0}"), line));
|
||||
} else {
|
||||
try {
|
||||
textarea.addLineHighlight(line, new Color(1, 0, 0, 0.2f));
|
||||
textarea.setCaretPosition(textarea.getLineStartOffset(line));
|
||||
addLineHighlight(line);
|
||||
} catch (BadLocationException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user