Skip to content

Commit

Permalink
Add line numbering to IDE
Browse files Browse the repository at this point in the history
Add line numbering to IDE and color update
  • Loading branch information
dbarragan committed Sep 27, 2014
1 parent 7960cbd commit 2fc65af
Show file tree
Hide file tree
Showing 21 changed files with 879 additions and 27 deletions.
6 changes: 5 additions & 1 deletion IDE/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,8 @@ public void handleOpenPrompt() {
fd.setFilenameFilter(new FilenameFilter() {
public boolean accept(File dir, String name) {
// TODO this doesn't seem to ever be used. AWESOME.
return name.toLowerCase().endsWith(".pde");
return name.toLowerCase().endsWith(".pde")
|| name.toLowerCase().endsWith(".ino");
}
});

Expand Down Expand Up @@ -1417,6 +1418,9 @@ public void actionPerformed(ActionEvent e) {
if (!subfolder.isDirectory()) continue;

File entry = new File(subfolder, list[i] + ".pde");
if (!entry.exists() && (new File(subfolder, list[i] + ".ino")).exists()) {
entry = new File(subfolder, list[i] + ".ino");
}
// if a .pde file of the same prefix as the folder exists..
if (entry.exists()) {
if (!Sketch.isSanitaryName(list[i])) {
Expand Down
8 changes: 6 additions & 2 deletions IDE/processing/app/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2053,16 +2053,20 @@ protected boolean handleOpenInternal(String path) {
String parentName = parentFile.getName();
String pdeName = parentName + ".pde";
File altFile = new File(file.getParent(), pdeName);
String inoName = parentName + ".ino";
File altInoFile = new File(file.getParent(), pdeName);

if (pdeName.equals(file.getName())) {
if (pdeName.equals(file.getName()) || inoName.equals(file.getName())) {
// no beef with this guy

} else if (altFile.exists()) {
// user selected a .java from the same sketch,
// but open the .pde instead
path = altFile.getAbsolutePath();

} else if (!path.endsWith(".pde")) {
} else if (altInoFile.exists()) {
path = altInoFile.getAbsolutePath();
} else if (!path.endsWith(".pde") && !path.endsWith(".ino")) {
Base.showWarning("Bad file selected",
"Wiring can only open its own sketches\n" +
"and other files ending in .pde", null);
Expand Down
17 changes: 16 additions & 1 deletion IDE/processing/app/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ public class Preferences {
JTextField fontSizeField;
JCheckBox autoAssociateBox;
JComboBox referenceLanguage;

JCheckBox editorHideLineNumbersBox;

// the calling editor, so updates can be applied

Editor editor;
Expand Down Expand Up @@ -296,6 +297,18 @@ public void actionPerformed(ActionEvent e) {
top += d.height + GUI_BETWEEN;


// [ ] Hide line numbers on editor

editorHideLineNumbersBox =
new JCheckBox("Show line numbers " +
"(requires restart of Wiring)");
pain.add(editorHideLineNumbersBox);
d = editorHideLineNumbersBox.getPreferredSize();
// adding +10 because ubuntu + jre 1.5 truncating items
editorHideLineNumbersBox.setBounds(left, top, d.width + 10, d.height);
right = Math.max(right, left + d.width);
top += d.height + GUI_BETWEEN;

// [ ] Increase maximum available memory to [______] MB

Container memoryBox = Box.createHorizontalBox();
Expand Down Expand Up @@ -553,6 +566,7 @@ protected void disposeFrame() {
protected void applyFrame() {
setBoolean("editor.antialias", editorAntialiasBox.isSelected());

setBoolean("gutter.collapsed", !editorHideLineNumbersBox.isSelected());
// put each of the settings into the table
// setBoolean("export.applet.separate_jar_files",
// exportSeparateBox.isSelected());
Expand Down Expand Up @@ -627,6 +641,7 @@ protected void showFrame(Editor editor) {

editorAntialiasBox.setSelected(getBoolean("editor.antialias"));

editorHideLineNumbersBox.setSelected(!getBoolean("gutter.collapsed"));
// set all settings entry boxes to their actual status
// exportSeparateBox.
// setSelected(getBoolean("export.applet.separate_jar_files"));
Expand Down
15 changes: 11 additions & 4 deletions IDE/processing/app/Sketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.beans.*;
import java.io.*;
import java.util.*;
import java.util.List;
import java.util.zip.*;

import javax.swing.*;
Expand Down Expand Up @@ -1297,7 +1298,7 @@ public String preprocess(String buildPath, PdePreprocessor preprocessor) throws
StringBuffer bigCode = new StringBuffer();
int bigCount = 0;
for (SketchCode sc : code) {
if (sc.isExtension("pde")) {
if (sc.isExtension("pde") || sc.isExtension("ino")) {
sc.setPreprocOffset(bigCount);
bigCode.append(sc.getProgram());
bigCode.append('\n');
Expand Down Expand Up @@ -1422,7 +1423,7 @@ public String preprocess(String buildPath, PdePreprocessor preprocessor) throws
}
// sc.setPreprocName(filename);

} else if (sc.isExtension("pde")) {
} else if (sc.isExtension("pde") || sc.isExtension("ino")) {
// The compiler and runner will need this to have a proper offset
//headerOffset = preprocessor.prototypeCount + preprocessor.headerCount;
sc.addPreprocOffset(headerOffset);
Expand Down Expand Up @@ -1936,7 +1937,7 @@ public boolean isReadOnly() {
* For Processing, this is true for .pde files. (Broken out for subclasses.)
*/
public boolean hideExtension(String what) {
return what.equals(getDefaultExtension());
return getHiddenExtensions().contains(what);
}


Expand Down Expand Up @@ -1977,11 +1978,17 @@ public String getDefaultExtension() {
}


static private List<String> hiddenExtensions = Arrays.asList("pde", "ino");

public List<String> getHiddenExtensions() {
return hiddenExtensions;
}

/**
* Returns a String[] array of proper extensions.
*/
public String[] getExtensions() {
return new String[] { "pde", "c", "cpp", "h" };
return new String[] { "pde", "ino", "c", "cpp", "h" };
}


Expand Down
Loading

0 comments on commit 2fc65af

Please sign in to comment.