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 line = getLineOfOffset(textArea);
|
||||||
int lineOffset = getLineOffset(textArea, line);
|
int lineOffset = getLineOffset(textArea, line);
|
||||||
|
|
||||||
editor.getTextArea().getUndoManager().beginInternalAtomicEdit();
|
textArea.getUndoManager().beginInternalAtomicEdit();
|
||||||
|
editor.removeAllLineHighlights();
|
||||||
editor.setText(formattedText);
|
editor.setText(formattedText);
|
||||||
editor.getSketch().setModified(true);
|
editor.getSketch().setModified(true);
|
||||||
editor.getTextArea().getUndoManager().endInternalAtomicEdit();
|
textArea.getUndoManager().endInternalAtomicEdit();
|
||||||
|
|
||||||
if (line != -1 && lineOffset != -1) {
|
if (line != -1 && lineOffset != -1) {
|
||||||
try {
|
try {
|
||||||
|
@ -41,8 +41,8 @@ import processing.app.forms.PasswordAuthorizationDialog;
|
|||||||
import processing.app.helpers.OSUtils;
|
import processing.app.helpers.OSUtils;
|
||||||
import processing.app.helpers.PreferencesMapException;
|
import processing.app.helpers.PreferencesMapException;
|
||||||
import processing.app.legacy.PApplet;
|
import processing.app.legacy.PApplet;
|
||||||
import processing.app.syntax.PdeKeywords;
|
|
||||||
import processing.app.syntax.ArduinoTokenMakerFactory;
|
import processing.app.syntax.ArduinoTokenMakerFactory;
|
||||||
|
import processing.app.syntax.PdeKeywords;
|
||||||
import processing.app.syntax.SketchTextArea;
|
import processing.app.syntax.SketchTextArea;
|
||||||
import processing.app.tools.DiscourseFormat;
|
import processing.app.tools.DiscourseFormat;
|
||||||
import processing.app.tools.MenuScroller;
|
import processing.app.tools.MenuScroller;
|
||||||
@ -2006,7 +2006,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
textarea.removeAllLineHighlights();
|
removeAllLineHighlights();
|
||||||
sketch.prepare();
|
sketch.prepare();
|
||||||
sketch.build(verbose, saveHex);
|
sketch.build(verbose, saveHex);
|
||||||
statusNotice(tr("Done compiling."));
|
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 {
|
private class DefaultStopHandler implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
// TODO
|
// TODO
|
||||||
@ -2276,7 +2285,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
public boolean handleSave(boolean immediately) {
|
public boolean handleSave(boolean immediately) {
|
||||||
//stopRunner();
|
//stopRunner();
|
||||||
handleStop(); // 0136
|
handleStop(); // 0136
|
||||||
textarea.removeAllLineHighlights();
|
removeAllLineHighlights();
|
||||||
|
|
||||||
if (untitled) {
|
if (untitled) {
|
||||||
return handleSaveAs();
|
return handleSaveAs();
|
||||||
@ -2430,7 +2439,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
textarea.removeAllLineHighlights();
|
removeAllLineHighlights();
|
||||||
if (serialMonitor != null) {
|
if (serialMonitor != null) {
|
||||||
serialMonitor.suspend();
|
serialMonitor.suspend();
|
||||||
}
|
}
|
||||||
@ -2876,8 +2885,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
System.err.println(I18n.format(tr("Bad error line: {0}"), line));
|
System.err.println(I18n.format(tr("Bad error line: {0}"), line));
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
textarea.addLineHighlight(line, new Color(1, 0, 0, 0.2f));
|
addLineHighlight(line);
|
||||||
textarea.setCaretPosition(textarea.getLineStartOffset(line));
|
|
||||||
} catch (BadLocationException e1) {
|
} catch (BadLocationException e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user