Skip to content

New Editor (based on RSyntaxTextArea ) - 1.6.4 #3019

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
cab27b1
removing files from the old editor
ricardojlrufino Apr 22, 2015
e4fa449
install script for linux
ricardojlrufino Apr 22, 2015
1365d2d
arduino logo for linux icon
ricardojlrufino Apr 22, 2015
e159c16
build and run scripts - add new dependency and linux desktop icon
ricardojlrufino Apr 22, 2015
e0ed8cb
simple code refactor on PdePreprocessor
ricardojlrufino Apr 22, 2015
ac39794
add RSyntaxTexarea jar
ricardojlrufino Apr 22, 2015
a09a612
updated tests for new Textarea
ricardojlrufino Apr 22, 2015
8f9c1e5
improves font rendering
ricardojlrufino Apr 22, 2015
cb9a5de
Allow redirect logs to console
ricardojlrufino Apr 22, 2015
12d7792
new editor based on RSyntaxTextArea
ricardojlrufino Apr 22, 2015
557739e
update classpath - add new dependency
ricardojlrufino Apr 22, 2015
8603c9b
make editor folding happy
ricardojlrufino Apr 22, 2015
79539e6
remove not used interface
ricardojlrufino Apr 22, 2015
cbcc41e
preferences for syntax highlighting theme
ricardojlrufino Apr 22, 2015
3deb44f
Add 'Code Folding' preferences and fix Font-Size changes
ricardojlrufino Apr 23, 2015
8653e9f
New editor: addede missing license headers on new files
Apr 24, 2015
f8399e9
Revert "make editor folding happy"
Apr 24, 2015
71c2d69
Revert "improves font rendering"
Apr 24, 2015
14a0b45
Removed color theme selection: we currently support only one theme
Apr 24, 2015
bb74e06
New editor: removed 1px border around editor
Apr 24, 2015
09e36bd
Restoring keyword.txt loading and parsing. Added token type identifie…
Apr 27, 2015
73972fe
Fixed failing PdeKeywords test
Apr 27, 2015
c3953aa
Autoformat was generating two undo action, the first one being an emp…
Apr 27, 2015
2448c39
Added rsyntaxtextarea license file
Apr 28, 2015
4c7fbd2
MacOSX: default font size set to 12
Apr 28, 2015
4dde285
Ensure hyperlinks are coloured using theme.txt colour
Apr 28, 2015
abdb93c
hyperlinks enabled by default on comment
ricardojlrufino Apr 28, 2015
c9d3053
PdeKeywords must be read before consulting command line args
Apr 28, 2015
a5bb904
Code folding was not visible when line numbers were disabled. Fixed
Apr 29, 2015
29ba824
Merge remote-tracking branch 'arduino/master' into 1.6.4-new-editor
May 6, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
<classpathentry kind="lib" path="lib/commons-lang3-3.3.2.jar"/>
<classpathentry kind="lib" path="lib/guava-18.0.jar"/>
<classpathentry kind="lib" path="lib/java-semver-0.8.0.jar"/>
<classpathentry kind="lib" path="lib/rsyntaxtextarea-2.6.0-SNAPSHOT.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Binary file added app/lib/rsyntaxtextarea-2.6.0-SNAPSHOT.jar
Binary file not shown.
24 changes: 24 additions & 0 deletions app/lib/rsyntaxtextarea-BSD.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Copyright (c) 2012, Robert Futrell
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 changes: 44 additions & 0 deletions app/src/ArduinoIDE.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* This file is part of Arduino.
*
* Copyright 2015 Ricardo JL Rufino ([email protected])
*
* Arduino is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* As a special exception, you may use this file as part of a free software
* library without restriction. Specifically, if other files instantiate
* templates or use macros or inline functions from this file, or you compile
* this file and link it with other files to produce an executable, this
* file does not by itself cause the resulting executable to be covered by
* the GNU General Public License. This exception does not however
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*/

import processing.app.Base;

/**
* Arduino IDE Launcher class
*
* @author Ricardo JL Rufino ([email protected])
* @date 23/01/2015
*/
public class ArduinoIDE {

public static void main(String[] args) throws Exception {
Base.main(args);
}

}
46 changes: 41 additions & 5 deletions app/src/cc/arduino/packages/formatter/AStyle.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */

/*
* This file is part of Arduino.
*
Expand Down Expand Up @@ -32,9 +34,10 @@
import processing.app.Base;
import processing.app.Editor;
import processing.app.helpers.FileUtils;
import processing.app.syntax.JEditTextArea;
import processing.app.syntax.SketchTextArea;
import processing.app.tools.Tool;

import javax.swing.text.BadLocationException;
import java.io.File;
import java.io.IOException;

Expand Down Expand Up @@ -84,17 +87,50 @@ public void run() {
return;
}

JEditTextArea textArea = editor.getTextArea();
int line = textArea.getLineOfOffset(textArea.getCaretPosition());
int lineOffset = textArea.getCaretPosition() - textArea.getLineStartOffset(line);
SketchTextArea textArea = editor.getTextArea();

int line = getLineOfOffset(textArea);
int lineOffset = getLineOffset(textArea, line);

editor.getTextArea().getUndoManager().beginInternalAtomicEdit();
editor.setText(formattedText);
editor.getSketch().setModified(true);
textArea.setCaretPosition(Math.min(textArea.getLineStartOffset(line) + lineOffset, textArea.getSafeLineStopOffset(line) - 1));
editor.getTextArea().getUndoManager().endInternalAtomicEdit();

if (line != -1 && lineOffset != -1) {
setCaretPosition(textArea, line, lineOffset);
}

// mark as finished
editor.statusNotice(_("Auto Format finished."));
}

private void setCaretPosition(SketchTextArea textArea, int line, int lineOffset) {
try {
textArea.setCaretPosition(Math.min(textArea.getLineStartOffset(line) + lineOffset, textArea.getLineEndOffset(line) - 1));
} catch (BadLocationException e) {
e.printStackTrace();
}
}

private int getLineOffset(SketchTextArea textArea, int line) {
try {
return textArea.getCaretPosition() - textArea.getLineStartOffset(line);
} catch (BadLocationException e) {
e.printStackTrace();
}
return -1;
}

private int getLineOfOffset(SketchTextArea textArea) {
try {
return textArea.getLineOfOffset(textArea.getCaretPosition());
} catch (BadLocationException e) {
e.printStackTrace();
}
return -1;
}

@Override
public String getMenuTitle() {
return _("Auto Format");
Expand Down
59 changes: 58 additions & 1 deletion app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,20 @@
import processing.app.macosx.ThinkDifferent;
import processing.app.packages.LibraryList;
import processing.app.packages.UserLibrary;
import processing.app.syntax.PdeKeywords;
import processing.app.tools.MenuScroller;
import processing.app.tools.ZipDeflater;

import javax.swing.*;

import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.util.List;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;

import static processing.app.I18n._;

Expand Down Expand Up @@ -114,6 +119,8 @@ public boolean apply(UserLibrary library) {
private List<JMenu> boardsCustomMenus;
private volatile Action openBoardsManager;

private final PdeKeywords pdeKeywords;

static public void main(String args[]) throws Exception {
System.setProperty("awt.useSystemAAFontSettings", "on");
System.setProperty("swing.aatext", "true");
Expand All @@ -137,6 +144,8 @@ static public void guardedMain(String args[]) throws Exception {

BaseNoGui.initLogger();

initLogger();

BaseNoGui.notifier = new GUIUserNotifier();

initPlatform();
Expand Down Expand Up @@ -215,6 +224,34 @@ static public void guardedMain(String args[]) throws Exception {
INSTANCE = new Base(args);
}


static public void initLogger() {
Handler consoleHandler = new ConsoleLogger();
consoleHandler.setLevel(Level.ALL);
consoleHandler.setFormatter(new LogFormatter("%1$tl:%1$tM:%1$tS [%4$7s] %2$s: %5$s%n"));

Logger globalLogger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
globalLogger.setLevel(consoleHandler.getLevel());

// Remove default
Handler[] handlers = globalLogger.getHandlers();
for(Handler handler : handlers) {
globalLogger.removeHandler(handler);
}
Logger root = Logger.getLogger("");
handlers = root.getHandlers();
for(Handler handler : handlers) {
root.removeHandler(handler);
}

globalLogger.addHandler(consoleHandler);

Logger.getLogger("cc.arduino.packages.autocomplete").setParent(globalLogger);
Logger.getLogger("br.com.criativasoft.cpluslibparser").setParent(globalLogger);
Logger.getLogger(Base.class.getPackage().getName()).setParent(globalLogger);

}


static protected void setCommandLine() {
commandLine = true;
Expand Down Expand Up @@ -275,6 +312,9 @@ public Base(String[] args) throws Exception {
// Setup board-dependent variables.
onBoardOrPortChange();

this.pdeKeywords = new PdeKeywords();
this.pdeKeywords.reload();

CommandlineParser parser = CommandlineParser.newCommandlineParser(args);

for (String path : parser.getFilenames()) {
Expand Down Expand Up @@ -2098,6 +2138,14 @@ static public void setIcon(Frame frame) {
// don't use the low-res icon on Mac OS X; the window should
// already have the right icon from the .app file.
if (OSUtils.isMacOS()) return;

// don't use the low-res icon on Linux
if (OSUtils.isLinux()){
String current = System.getProperty("user.dir");
Image image = Toolkit.getDefaultToolkit().createImage(current + "/lib/arduino.png");
frame.setIconImage(image);
return;
}

Image image = Toolkit.getDefaultToolkit().createImage(PApplet.ICON_IMAGE);
frame.setIconImage(image);
Expand Down Expand Up @@ -2152,7 +2200,12 @@ static public void showReference(String prefix, String filename) {
File referenceFile = new File(referenceFolder, filename);
if (!referenceFile.exists())
referenceFile = new File(referenceFolder, filename + ".html");
openURL(referenceFile.getAbsolutePath());

if(referenceFile.exists()){
openURL(referenceFile.getAbsolutePath());
}else{
showWarning(_("Problem Opening URL"), I18n.format(_("Could not open the URL\n{0}"), referenceFile), null);
}
}

public static void showEdisonGettingStarted() {
Expand Down Expand Up @@ -2724,4 +2777,8 @@ public List<Editor> getEditors() {
public Action getOpenBoardsManager() {
return openBoardsManager;
}

public PdeKeywords getPdeKeywords() {
return pdeKeywords;
}
}
6 changes: 3 additions & 3 deletions app/src/processing/app/CaretAwareUndoableEdit.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package processing.app;

import processing.app.syntax.JEditTextArea;

import javax.swing.undo.CannotRedoException;
import javax.swing.undo.CannotUndoException;
import javax.swing.undo.UndoableEdit;

import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;

public class CaretAwareUndoableEdit implements UndoableEdit {

private final UndoableEdit undoableEdit;
private final int caretPosition;

public CaretAwareUndoableEdit(UndoableEdit undoableEdit, JEditTextArea textArea) {
public CaretAwareUndoableEdit(UndoableEdit undoableEdit, RSyntaxTextArea textArea) {
this.undoableEdit = undoableEdit;
this.caretPosition = textArea.getCaretPosition();
}
Expand Down
Loading