Skip to content

Commit 1379505

Browse files
ricardojlrufinoFederico Fissore
authored and
Federico Fissore
committed
new editor based on RSyntaxTextArea
1 parent 63f153c commit 1379505

14 files changed

+934
-1156
lines changed

app/src/ArduinoIDE.java

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2+
3+
/*
4+
Part of the Processing project - http://processing.org
5+
6+
Copyright (c) 2004-10 Ben Fry and Casey Reas
7+
Copyright (c) 2001-04 Massachusetts Institute of Technology
8+
9+
This program is free software; you can redistribute it and/or modify
10+
it under the terms of the GNU General Public License version 2
11+
as published by the Free Software Foundation.
12+
13+
This program is distributed in the hope that it will be useful,
14+
but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
GNU General Public License for more details.
17+
18+
You should have received a copy of the GNU General Public License
19+
along with this program; if not, write to the Free Software Foundation,
20+
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21+
*/
22+
23+
import processing.app.Base;
24+
25+
/**
26+
* Arduino IDE Launcher class
27+
* @author Ricardo JL Rufino ([email protected])
28+
* @date 23/01/2015
29+
*/
30+
public class ArduinoIDE {
31+
32+
public static void main(String[] args) throws Exception {
33+
Base.main(args);
34+
}
35+
36+
}

app/src/cc/arduino/packages/formatter/AStyle.java

+19-11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2+
13
/*
24
* This file is part of Arduino.
35
*
@@ -29,16 +31,18 @@
2931

3032
package cc.arduino.packages.formatter;
3133

32-
import processing.app.Base;
33-
import processing.app.Editor;
34-
import processing.app.helpers.FileUtils;
35-
import processing.app.syntax.JEditTextArea;
36-
import processing.app.tools.Tool;
34+
import static processing.app.I18n._;
3735

3836
import java.io.File;
3937
import java.io.IOException;
4038

41-
import static processing.app.I18n._;
39+
import javax.swing.text.BadLocationException;
40+
41+
import processing.app.Base;
42+
import processing.app.Editor;
43+
import processing.app.helpers.FileUtils;
44+
import processing.app.syntax.SketchTextArea;
45+
import processing.app.tools.Tool;
4246

4347
public class AStyle implements Tool {
4448

@@ -84,13 +88,17 @@ public void run() {
8488
return;
8589
}
8690

87-
JEditTextArea textArea = editor.getTextArea();
88-
int line = textArea.getLineOfOffset(textArea.getCaretPosition());
89-
int lineOffset = textArea.getCaretPosition() - textArea.getLineStartOffset(line);
90-
91+
SketchTextArea textArea = editor.getTextArea();
9192
editor.setText(formattedText);
9293
editor.getSketch().setModified(true);
93-
textArea.setCaretPosition(Math.min(textArea.getLineStartOffset(line) + lineOffset, textArea.getSafeLineStopOffset(line) - 1));
94+
95+
try {
96+
int line = textArea.getLineOfOffset(textArea.getCaretPosition());
97+
int lineOffset = textArea.getCaretPosition() - textArea.getLineStartOffset(line);
98+
textArea.setCaretPosition(Math.min(textArea.getLineStartOffset(line) + lineOffset, textArea.getLineEndOffset(line) - 1));
99+
} catch (BadLocationException e) {
100+
e.printStackTrace();
101+
}
94102
// mark as finished
95103
editor.statusNotice(_("Auto Format finished."));
96104
}

app/src/processing/app/CaretAwareUndoableEdit.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package processing.app;
22

3-
import processing.app.syntax.JEditTextArea;
4-
53
import javax.swing.undo.CannotRedoException;
64
import javax.swing.undo.CannotUndoException;
75
import javax.swing.undo.UndoableEdit;
86

7+
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
8+
99
public class CaretAwareUndoableEdit implements UndoableEdit {
1010

1111
private final UndoableEdit undoableEdit;
1212
private final int caretPosition;
1313

14-
public CaretAwareUndoableEdit(UndoableEdit undoableEdit, JEditTextArea textArea) {
14+
public CaretAwareUndoableEdit(UndoableEdit undoableEdit, RSyntaxTextArea textArea) {
1515
this.undoableEdit = undoableEdit;
1616
this.caretPosition = textArea.getCaretPosition();
1717
}

0 commit comments

Comments
 (0)