table) throws IOException {
- String[] lines = loadStrings(input); // Reads as UTF-8
- for (String line : lines) {
- if ((line.length() == 0) ||
- (line.charAt(0) == '#')) continue;
-
- // this won't properly handle = signs being in the text
- int equals = line.indexOf('=');
- if (equals != -1) {
- String key = line.substring(0, equals).trim();
- String value = line.substring(equals + 1).trim();
- table.put(key, value);
- }
- }
- }
-
- static public String[] loadStrings(InputStream input) {
- try {
- BufferedReader reader =
- new BufferedReader(new InputStreamReader(input, "UTF-8"));
-
- String lines[] = new String[100];
- int lineCount = 0;
- String line = null;
- while ((line = reader.readLine()) != null) {
- if (lineCount == lines.length) {
- String temp[] = new String[lineCount << 1];
- System.arraycopy(lines, 0, temp, 0, lineCount);
- lines = temp;
- }
- lines[lineCount++] = line;
- }
- reader.close();
-
- if (lineCount == lines.length) {
- return lines;
- }
-
- // resize array to appropriate amount for these lines
- String output[] = new String[lineCount];
- System.arraycopy(lines, 0, output, 0, lineCount);
- return output;
-
- } catch (IOException e) {
- e.printStackTrace();
- //throw new RuntimeException("Error inside loadStrings()");
- }
- return null;
- }
-
-
-
- // .................................................................
-
-
static protected void save() {
- if (!doSave) return;
-// try {
- // on startup, don't worry about it
- // this is trying to update the prefs for who is open
- // before Preferences.init() has been called.
- if (preferencesFile == null) return;
-
- // Fix for 0163 to properly use Unicode when writing preferences.txt
- PrintWriter writer = PApplet.createWriter(preferencesFile);
-
- String[] keys = table.keySet().toArray(new String[0]);
- Arrays.sort(keys);
- for (String key: keys) {
- if (key.startsWith("runtime."))
- continue;
- writer.println(key + "=" + table.get(key));
- }
-
- writer.flush();
- writer.close();
-
-// } catch (Exception ex) {
-// Base.showWarning(null, "Error while saving the settings file", ex);
-// }
+ PreferencesData.save();
}
// .................................................................
-
- // all the information from preferences.txt
-
- //static public String get(String attribute) {
- //return get(attribute, null);
- //}
-
static public String get(String attribute) {
- return table.get(attribute);
+ return PreferencesData.get(attribute);
}
static public String get(String attribute, String defaultValue) {
- String value = get(attribute);
-
- return (value == null) ? defaultValue : value;
+ return PreferencesData.get(attribute, defaultValue);
}
public static boolean has(String key) {
- return table.containsKey(key);
+ return PreferencesData.has(key);
}
public static void remove(String key) {
- table.remove(key);
- }
-
- static public String getDefault(String attribute) {
- return defaults.get(attribute);
+ PreferencesData.remove(key);
}
static public void set(String attribute, String value) {
- table.put(attribute, value);
- }
-
-
- static public void unset(String attribute) {
- table.remove(attribute);
+ PreferencesData.set(attribute, value);
}
static public boolean getBoolean(String attribute) {
- String value = get(attribute); //, null);
- return (new Boolean(value)).booleanValue();
-
- /*
- supposedly not needed, because anything besides 'true'
- (ignoring case) will just be false.. so if malformed -> false
- if (value == null) return defaultValue;
-
- try {
- return (new Boolean(value)).booleanValue();
- } catch (NumberFormatException e) {
- System.err.println("expecting an integer: " + attribute + " = " + value);
- }
- return defaultValue;
- */
+ return PreferencesData.getBoolean(attribute);
}
static public void setBoolean(String attribute, boolean value) {
- set(attribute, value ? "true" : "false");
+ PreferencesData.setBoolean(attribute, value);
}
- static public int getInteger(String attribute /*, int defaultValue*/) {
- return Integer.parseInt(get(attribute));
-
- /*
- String value = get(attribute, null);
- if (value == null) return defaultValue;
-
- try {
- return Integer.parseInt(value);
- } catch (NumberFormatException e) {
- // ignored will just fall through to returning the default
- System.err.println("expecting an integer: " + attribute + " = " + value);
- }
- return defaultValue;
- //if (value == null) return defaultValue;
- //return (value == null) ? defaultValue :
- //Integer.parseInt(value);
- */
+ static public int getInteger(String attribute) {
+ return PreferencesData.getInteger(attribute);
}
static public void setInteger(String key, int value) {
- set(key, String.valueOf(value));
- }
-
-
- static public Color getColor(String name) {
- Color parsed = Color.GRAY; // set a default
- String s = get(name);
- if ((s != null) && (s.indexOf("#") == 0)) {
- try {
- parsed = new Color(Integer.parseInt(s.substring(1), 16));
- } catch (Exception e) { }
- }
- return parsed;
- }
-
-
- static public void setColor(String attr, Color what) {
- set(attr, "#" + PApplet.hex(what.getRGB() & 0xffffff, 6));
+ PreferencesData.setInteger(key, value);
}
static public Font getFont(String attr) {
- boolean replace = false;
- String value = get(attr);
- if (value == null) {
- //System.out.println("reset 1");
- value = getDefault(attr);
- replace = true;
- }
-
- String[] pieces = PApplet.split(value, ',');
- if (pieces.length != 3) {
- value = getDefault(attr);
- //System.out.println("reset 2 for " + attr);
- pieces = PApplet.split(value, ',');
- //PApplet.println(pieces);
- replace = true;
- }
-
- String name = pieces[0];
- int style = Font.PLAIN; // equals zero
- if (pieces[1].indexOf("bold") != -1) {
- style |= Font.BOLD;
+ Font font = PreferencesHelper.getFont(PreferencesData.prefs, attr);
+ if (font == null) {
+ String value = PreferencesData.defaults.get(attr);
+ PreferencesData.prefs.put(attr, value);
+ font = PreferencesHelper.getFont(PreferencesData.prefs, attr);
}
- if (pieces[1].indexOf("italic") != -1) {
- style |= Font.ITALIC;
- }
- int size = PApplet.parseInt(pieces[2], 12);
- Font font = new Font(name, style, size);
-
- // replace bad font with the default
- if (replace) {
- set(attr, value);
- }
-
return font;
}
-
- static public SyntaxStyle getStyle(String what /*, String dflt*/) {
- String str = get("editor." + what + ".style"); //, dflt);
-
- StringTokenizer st = new StringTokenizer(str, ",");
-
- String s = st.nextToken();
- if (s.indexOf("#") == 0) s = s.substring(1);
- Color color = Color.DARK_GRAY;
- try {
- color = new Color(Integer.parseInt(s, 16));
- } catch (Exception e) { }
-
- s = st.nextToken();
- boolean bold = (s.indexOf("bold") != -1);
- boolean italic = (s.indexOf("italic") != -1);
- boolean underlined = (s.indexOf("underlined") != -1);
- //System.out.println(what + " = " + str + " " + bold + " " + italic);
-
- return new SyntaxStyle(color, italic, bold, underlined);
- }
-
// get a copy of the Preferences
static public PreferencesMap getMap()
{
- return new PreferencesMap(table);
+ return PreferencesData.getMap();
}
// Decide wether changed preferences will be saved. When value is
// false, Preferences.save becomes a no-op.
static public void setDoSave(boolean value)
{
- doSave = value;
+ PreferencesData.setDoSave(value);
}
}
diff --git a/app/src/processing/app/SerialMonitor.java b/app/src/processing/app/SerialMonitor.java
index 49e7006a3a3..67e90d5bbed 100644
--- a/app/src/processing/app/SerialMonitor.java
+++ b/app/src/processing/app/SerialMonitor.java
@@ -19,7 +19,7 @@
package processing.app;
import cc.arduino.packages.BoardPort;
-import processing.core.PApplet;
+import processing.app.legacy.PApplet;
import java.awt.*;
import java.awt.event.ActionEvent;
@@ -27,6 +27,7 @@
import static processing.app.I18n._;
+@SuppressWarnings("serial")
public class SerialMonitor extends AbstractMonitor {
private final String port;
diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java
index 4b2c6b44b4c..285962755e9 100644
--- a/app/src/processing/app/Sketch.java
+++ b/app/src/processing/app/Sketch.java
@@ -23,24 +23,17 @@
package processing.app;
-import cc.arduino.packages.BoardPort;
-import cc.arduino.packages.UploaderAndMonitorFactory;
-
import cc.arduino.packages.Uploader;
-import processing.app.debug.*;
import processing.app.debug.Compiler;
+import processing.app.debug.Compiler.ProgressListener;
+import processing.app.debug.RunnerException;
import processing.app.forms.PasswordAuthorizationDialog;
-import processing.app.helpers.PreferencesMap;
-import processing.app.helpers.FileUtils;
+import processing.app.helpers.OSUtils;
import processing.app.packages.Library;
-import processing.app.packages.LibraryList;
-import processing.app.preproc.*;
-import processing.core.*;
import static processing.app.I18n._;
import java.io.*;
import java.util.*;
-import java.util.List;
import javax.swing.*;
@@ -53,69 +46,24 @@ public class Sketch {
private Editor editor;
- /** main pde file for this sketch. */
- private File primaryFile;
-
- /**
- * Name of sketch, which is the name of main file
- * (without .pde or .java extension)
- */
- private String name;
-
/** true if any of the files have been modified. */
private boolean modified;
- /** folder that contains this sketch */
- private File folder;
-
- /** data folder location for this sketch (may not exist yet) */
- private File dataFolder;
-
- /** code folder location for this sketch (may not exist yet) */
- private File codeFolder;
-
- private SketchCode current;
+ private SketchCodeDocument current;
private int currentIndex;
- /**
- * Number of sketchCode objects (tabs) in the current sketch. Note that this
- * will be the same as code.length, because the getCode() method returns
- * just the code[] array, rather than a copy of it, or an array that's been
- * resized to just the relevant files themselves.
- * http://dev.processing.org/bugs/show_bug.cgi?id=940
- */
- private int codeCount;
- private SketchCode[] code;
+ private SketchData data;
+
/** Class name for the PApplet, as determined by the preprocessor. */
private String appletClassName;
- /** Class path determined during build. */
- private String classPath;
-
- /**
- * List of library folders.
- */
- private LibraryList importedLibraries;
-
- /**
- * File inside the build directory that contains the build options
- * used for the last build.
- */
- static final String BUILD_PREFS_FILE = "buildprefs.txt";
/**
* path is location of the main .pde file, because this is also
* simplest to use when opening the file from the finder/explorer.
*/
- public Sketch(Editor editor, File file) throws IOException {
- this.editor = editor;
-
- primaryFile = file;
-
- // get the name of the sketch by chopping .pde or .java
- // off of the main file name
- String mainFilename = primaryFile.getName();
- int suffixLength = getDefaultExtension().length() + 1;
- name = mainFilename.substring(0, mainFilename.length() - suffixLength);
+ public Sketch(Editor _editor, File file) throws IOException {
+ editor = _editor;
+ data = new SketchData(file);
// lib/build must exist when the application is started
// it is added to the CLASSPATH by default, but if it doesn't
@@ -136,9 +84,6 @@ public Sketch(Editor editor, File file) throws IOException {
tempBuildFolder = Base.getBuildFolder();
//Base.addBuildFolderToClassPath();
- folder = new File(file.getParent());
- //System.out.println("sketch dir is " + folder);
-
load();
}
@@ -158,69 +103,13 @@ public Sketch(Editor editor, File file) throws IOException {
* in which case the load happens each time "run" is hit.
*/
protected void load() throws IOException {
- codeFolder = new File(folder, "code");
- dataFolder = new File(folder, "data");
-
- // get list of files in the sketch folder
- String list[] = folder.list();
-
- // reset these because load() may be called after an
- // external editor event. (fix for 0099)
- codeCount = 0;
-
- code = new SketchCode[list.length];
-
- String[] extensions = getExtensions();
-
- for (String filename : list) {
- // Ignoring the dot prefix files is especially important to avoid files
- // with the ._ prefix on Mac OS X. (You'll see this with Mac files on
- // non-HFS drives, i.e. a thumb drive formatted FAT32.)
- if (filename.startsWith(".")) continue;
-
- // Don't let some wacko name a directory blah.pde or bling.java.
- if (new File(folder, filename).isDirectory()) continue;
-
- // figure out the name without any extension
- String base = filename;
- // now strip off the .pde and .java extensions
- for (String extension : extensions) {
- if (base.toLowerCase().endsWith("." + extension)) {
- base = base.substring(0, base.length() - (extension.length() + 1));
-
- // Don't allow people to use files with invalid names, since on load,
- // it would be otherwise possible to sneak in nasty filenames. [0116]
- if (Sketch.isSanitaryName(base)) {
- code[codeCount++] =
- new SketchCode(new File(folder, filename), extension);
- } else {
- editor.console.message(I18n.format("File name {0} is invalid: ignored", filename), true, false);
- }
- }
- }
- }
-
- if (codeCount == 0)
- throw new IOException(_("No valid code files found"));
-
- // Remove any code that wasn't proper
- code = (SketchCode[]) PApplet.subset(code, 0, codeCount);
+ data.load();
- // move the main class to the first tab
- // start at 1, if it's at zero, don't bother
- for (int i = 1; i < codeCount; i++) {
- //if (code[i].file.getName().equals(mainFilename)) {
- if (code[i].getFile().equals(primaryFile)) {
- SketchCode temp = code[0];
- code[0] = code[i];
- code[i] = temp;
- break;
- }
+ for (SketchCode code : data.getCodes()) {
+ if (code.getMetadata() == null)
+ code.setMetadata(new SketchCodeDocument(code));
}
- // sort the entries at the top
- sortCode();
-
// set the main file to be the current tab
if (editor != null) {
setCurrentCode(0);
@@ -228,47 +117,6 @@ protected void load() throws IOException {
}
- protected void replaceCode(SketchCode newCode) {
- for (int i = 0; i < codeCount; i++) {
- if (code[i].getFileName().equals(newCode.getFileName())) {
- code[i] = newCode;
- break;
- }
- }
- }
-
-
- protected void insertCode(SketchCode newCode) {
- // make sure the user didn't hide the sketch folder
- ensureExistence();
-
- // add file to the code/codeCount list, resort the list
- //if (codeCount == code.length) {
- code = (SketchCode[]) PApplet.append(code, newCode);
- codeCount++;
- //}
- //code[codeCount++] = newCode;
- }
-
-
- protected void sortCode() {
- // cheap-ass sort of the rest of the files
- // it's a dumb, slow sort, but there shouldn't be more than ~5 files
- for (int i = 1; i < codeCount; i++) {
- int who = i;
- for (int j = i + 1; j < codeCount; j++) {
- if (code[j].getFileName().compareTo(code[who].getFileName()) < 0) {
- who = j; // this guy is earlier in the alphabet
- }
- }
- if (who != i) { // swap with someone if changes made
- SketchCode temp = code[who];
- code[who] = code[i];
- code[i] = temp;
- }
- }
- }
-
boolean renamingCode;
/**
@@ -322,8 +170,8 @@ public void handleRenameCode() {
renamingCode = true;
String prompt = (currentIndex == 0) ?
"New name for sketch:" : "New name for file:";
- String oldName = (current.isExtension("ino")) ?
- current.getPrettyName() : current.getFileName();
+ String oldName = (current.getCode().isExtension("ino")) ?
+ current.getCode().getPrettyName() : current.getCode().getFileName();
editor.status.edit(prompt, oldName);
}
@@ -350,7 +198,7 @@ protected void nameCode(String newName) {
// (osx is case insensitive but preserving, windows insensitive,
// *nix is sensitive and preserving.. argh)
if (renamingCode) {
- if (newName.equalsIgnoreCase(current.getFileName())) {
+ if (newName.equalsIgnoreCase(current.getCode().getFileName())) {
// exit quietly for the 'rename' case.
// if it's a 'new' then an error will occur down below
return;
@@ -379,7 +227,7 @@ protected void nameCode(String newName) {
// Don't let the user create the main tab as a .java file instead of .pde
if (!isDefaultExtension(newExtension)) {
if (renamingCode) { // If creating a new tab, don't show this error
- if (current == code[0]) { // If this is the main tab, disallow
+ if (current.getCode() == data.getCode(0)) { // If this is the main tab, disallow
Base.showWarning(_("Problem with rename"),
_("The main file can't use an extension.\n" +
"(It may be time for your to graduate to a\n" +
@@ -393,7 +241,7 @@ protected void nameCode(String newName) {
// make sure the user didn't name things poo.time.pde
// or something like that (nothing against poo time)
String shortName = newName.substring(0, dot);
- String sanitaryName = Sketch.sanitizeName(shortName);
+ String sanitaryName = BaseNoGui.sanitizeName(shortName);
if (!shortName.equals(sanitaryName)) {
newName = sanitaryName + "." + newExtension;
}
@@ -401,13 +249,13 @@ protected void nameCode(String newName) {
// In Arduino, we want to allow files with the same name but different
// extensions, so compare the full names (including extensions). This
// might cause problems: http://dev.processing.org/bugs/show_bug.cgi?id=543
- for (SketchCode c : code) {
+ for (SketchCode c : data.getCodes()) {
if (newName.equalsIgnoreCase(c.getFileName())) {
Base.showMessage(_("Nope"),
I18n.format(
_("A file named \"{0}\" already exists in \"{1}\""),
c.getFileName(),
- folder.getAbsolutePath()
+ data.getFolder().getAbsolutePath()
));
return;
}
@@ -423,22 +271,20 @@ protected void nameCode(String newName) {
}
if (renamingCode && currentIndex == 0) {
- for (int i = 1; i < codeCount; i++) {
- if (sanitaryName.equalsIgnoreCase(code[i].getPrettyName()) &&
- code[i].getExtension().equalsIgnoreCase("cpp")) {
+ for (SketchCode code : data.getCodes()) {
+ if (sanitaryName.equalsIgnoreCase(code.getPrettyName()) &&
+ code.isExtension("cpp")) {
Base.showMessage(_("Nope"),
- I18n.format(
- _("You can't rename the sketch to \"{0}\"\n" +
- "because the sketch already has a .cpp file with that name."),
- sanitaryName
- ));
+ I18n.format(_("You can't rename the sketch to \"{0}\"\n"
+ + "because the sketch already has a .cpp file with that name."),
+ sanitaryName));
return;
}
}
}
- File newFile = new File(folder, newName);
+ File newFile = new File(data.getFolder(), newName);
// if (newFile.exists()) { // yay! users will try anything
// Base.showMessage("Nope",
// "A file named \"" + newFile + "\" already exists\n" +
@@ -460,7 +306,7 @@ protected void nameCode(String newName) {
if (currentIndex == 0) {
// get the new folder name/location
String folderName = newName.substring(0, newName.indexOf('.'));
- File newFolder = new File(folder.getParentFile(), folderName);
+ File newFolder = new File(data.getFolder().getParentFile(), folderName);
if (newFolder.exists()) {
Base.showWarning(_("Cannot Rename"),
I18n.format(
@@ -476,22 +322,22 @@ protected void nameCode(String newName) {
// however this *will* first save the sketch, then rename
// first get the contents of the editor text area
- if (current.isModified()) {
- current.setProgram(editor.getText());
+ if (current.getCode().isModified()) {
+ current.getCode().setProgram(editor.getText());
try {
// save this new SketchCode
- current.save();
+ current.getCode().save();
} catch (Exception e) {
Base.showWarning(_("Error"), _("Could not rename the sketch. (0)"), e);
return;
}
}
- if (!current.renameTo(newFile, newExtension)) {
+ if (!current.getCode().renameTo(newFile)) {
Base.showWarning(_("Error"),
I18n.format(
_("Could not rename \"{0}\" to \"{1}\""),
- current.getFileName(),
+ current.getCode().getFileName(),
newFile.getName()
), null);
return;
@@ -499,8 +345,8 @@ protected void nameCode(String newName) {
// save each of the other tabs because this is gonna be re-opened
try {
- for (int i = 1; i < codeCount; i++) {
- code[i].save();
+ for (SketchCode code : data.getCodes()) {
+ code.save();
}
} catch (Exception e) {
Base.showWarning(_("Error"), _("Could not rename the sketch. (1)"), e);
@@ -508,7 +354,7 @@ protected void nameCode(String newName) {
}
// now rename the sketch folder and re-open
- boolean success = folder.renameTo(newFolder);
+ boolean success = data.getFolder().renameTo(newFolder);
if (!success) {
Base.showWarning(_("Error"), _("Could not rename the sketch. (2)"), null);
return;
@@ -531,11 +377,11 @@ protected void nameCode(String newName) {
editor.base.rebuildSketchbookMenus();
} else { // else if something besides code[0]
- if (!current.renameTo(newFile, newExtension)) {
+ if (!current.getCode().renameTo(newFile)) {
Base.showWarning(_("Error"),
I18n.format(
_("Could not rename \"{0}\" to \"{1}\""),
- current.getFileName(),
+ current.getCode().getFileName(),
newFile.getName()
), null);
return;
@@ -553,17 +399,16 @@ protected void nameCode(String newName) {
I18n.format(
"Could not create the file \"{0}\" in \"{1}\"",
newFile,
- folder.getAbsolutePath()
+ data.getFolder().getAbsolutePath()
), e);
return;
}
- SketchCode newCode = new SketchCode(newFile, newExtension);
- //System.out.println("new code is named " + newCode.getPrettyName() + " " + newCode.getFile());
- insertCode(newCode);
+ ensureExistence();
+ data.addCode((new SketchCodeDocument(newFile)).getCode());
}
// sort the entries
- sortCode();
+ data.sortCode();
// set the new guy as current
setCurrentCode(newName);
@@ -594,7 +439,7 @@ public void handleDeleteCode() {
Object[] options = { _("OK"), _("Cancel") };
String prompt = (currentIndex == 0) ?
_("Are you sure you want to delete this sketch?") :
- I18n.format(_("Are you sure you want to delete \"{0}\"?"), current.getPrettyName());
+ I18n.format(_("Are you sure you want to delete \"{0}\"?"), current.getCode().getPrettyName());
int result = JOptionPane.showOptionDialog(editor,
prompt,
_("Delete"),
@@ -609,7 +454,7 @@ public void handleDeleteCode() {
// to do a save on the handleNew()
// delete the entire sketch
- Base.removeDir(folder);
+ Base.removeDir(data.getFolder());
// get the changes into the sketchbook menu
//sketchbook.rebuildMenus();
@@ -621,14 +466,14 @@ public void handleDeleteCode() {
} else {
// delete the file
- if (!current.deleteFile(tempBuildFolder)) {
+ if (!current.getCode().deleteFile(tempBuildFolder)) {
Base.showMessage(_("Couldn't do it"),
- I18n.format(_("Could not delete \"{0}\"."), current.getFileName()));
+ I18n.format(_("Could not delete \"{0}\"."), current.getCode().getFileName()));
return;
}
// remove code from the list
- removeCode(current);
+ data.removeCode(current.getCode());
// just set current tab to the main tab
setCurrentCode(0);
@@ -640,29 +485,12 @@ public void handleDeleteCode() {
}
- protected void removeCode(SketchCode which) {
- // remove it from the internal list of files
- // resort internal list of files
- for (int i = 0; i < codeCount; i++) {
- if (code[i] == which) {
- for (int j = i; j < codeCount-1; j++) {
- code[j] = code[j+1];
- }
- codeCount--;
- code = (SketchCode[]) PApplet.shorten(code);
- return;
- }
- }
- System.err.println(_("removeCode: internal error.. could not find code"));
- }
-
-
/**
* Move to the previous tab.
*/
public void handlePrevCode() {
int prev = currentIndex - 1;
- if (prev < 0) prev = codeCount-1;
+ if (prev < 0) prev = data.getCodeCount()-1;
setCurrentCode(prev);
}
@@ -671,7 +499,7 @@ public void handlePrevCode() {
* Move to the next tab.
*/
public void handleNextCode() {
- setCurrentCode((currentIndex + 1) % codeCount);
+ setCurrentCode((currentIndex + 1) % data.getCodeCount());
}
@@ -681,22 +509,22 @@ public void handleNextCode() {
public void setModified(boolean state) {
//System.out.println("setting modified to " + state);
//new Exception().printStackTrace();
- current.setModified(state);
+ current.getCode().setModified(state);
calcModified();
}
protected void calcModified() {
modified = false;
- for (int i = 0; i < codeCount; i++) {
- if (code[i].isModified()) {
+ for (SketchCode code : data.getCodes()) {
+ if (code.isModified()) {
modified = true;
break;
}
}
editor.header.repaint();
- if (Base.isMacOS()) {
+ if (OSUtils.isMacOS()) {
// http://developer.apple.com/qa/qa2001/qa1146.html
Object modifiedParam = modified ? Boolean.TRUE : Boolean.FALSE;
editor.getRootPane().putClientProperty("windowModified", modifiedParam);
@@ -717,8 +545,8 @@ public boolean save() throws IOException {
ensureExistence();
// first get the contents of the editor text area
- if (current.isModified()) {
- current.setProgram(editor.getText());
+ if (current.getCode().isModified()) {
+ current.getCode().setProgram(editor.getText());
}
// don't do anything if not actually modified
@@ -772,23 +600,20 @@ public boolean accept(File dir, String name) {
}
}
- for (int i = 0; i < codeCount; i++) {
- if (code[i].isModified())
- code[i].save();
- }
+ data.save();
calcModified();
return true;
}
protected boolean renameCodeToInoExtension(File pdeFile) {
- for (SketchCode c : code) {
+ for (SketchCode c : data.getCodes()) {
if (!c.getFile().equals(pdeFile))
continue;
String pdeName = pdeFile.getPath();
pdeName = pdeName.substring(0, pdeName.length() - 4) + ".ino";
- return c.renameTo(new File(pdeName), "ino");
+ return c.renameTo(new File(pdeName));
}
return false;
}
@@ -812,10 +637,10 @@ protected boolean saveAs() throws IOException {
if (isReadOnly() || isUntitled()) {
// default to the sketchbook folder
- fd.setSelectedFile(new File(Base.getSketchbookFolder().getAbsolutePath(), folder.getName()));
+ fd.setSelectedFile(new File(Base.getSketchbookFolder().getAbsolutePath(), data.getFolder().getName()));
} else {
// default to the parent folder of where this was
- fd.setSelectedFile(folder);
+ fd.setSelectedFile(data.getFolder());
}
int returnVal = fd.showSaveDialog(editor);
@@ -833,9 +658,9 @@ protected boolean saveAs() throws IOException {
// make sure there doesn't exist a .cpp file with that name already
// but ignore this situation for the first tab, since it's probably being
// resaved (with the same name) to another location/folder.
- for (int i = 1; i < codeCount; i++) {
- if (newName.equalsIgnoreCase(code[i].getPrettyName()) &&
- code[i].getExtension().equalsIgnoreCase("cpp")) {
+ for (SketchCode code : data.getCodes()) {
+ if (newName.equalsIgnoreCase(code.getPrettyName()) &&
+ code.isExtension("cpp")) {
Base.showMessage(_("Nope"),
I18n.format(
_("You can't save the sketch as \"{0}\"\n" +
@@ -847,7 +672,7 @@ protected boolean saveAs() throws IOException {
}
// check if the paths are identical
- if (newFolder.equals(folder)) {
+ if (newFolder.equals(data.getFolder())) {
// just use "save" here instead, because the user will have received a
// message (from the operating system) about "do you want to replace?"
return save();
@@ -856,7 +681,7 @@ protected boolean saveAs() throws IOException {
// check to see if the user is trying to save this sketch inside itself
try {
String newPath = newFolder.getCanonicalPath() + File.separator;
- String oldPath = folder.getCanonicalPath() + File.separator;
+ String oldPath = data.getFolder().getCanonicalPath() + File.separator;
if (newPath.indexOf(oldPath) == 0) {
Base.showWarning(_("How very Borges of you"),
@@ -880,31 +705,32 @@ protected boolean saveAs() throws IOException {
// grab the contents of the current tab before saving
// first get the contents of the editor text area
- if (current.isModified()) {
- current.setProgram(editor.getText());
+ if (current.getCode().isModified()) {
+ current.getCode().setProgram(editor.getText());
}
// save the other tabs to their new location
- for (int i = 1; i < codeCount; i++) {
- File newFile = new File(newFolder, code[i].getFileName());
- code[i].saveAs(newFile);
+ for (SketchCode code : data.getCodes()) {
+ if (data.indexOfCode(code) == 0) continue;
+ File newFile = new File(newFolder, code.getFileName());
+ code.saveAs(newFile);
}
// re-copy the data folder (this may take a while.. add progress bar?)
- if (dataFolder.exists()) {
+ if (data.getDataFolder().exists()) {
File newDataFolder = new File(newFolder, "data");
- Base.copyDir(dataFolder, newDataFolder);
+ Base.copyDir(data.getDataFolder(), newDataFolder);
}
// re-copy the code folder
- if (codeFolder.exists()) {
+ if (data.getCodeFolder().exists()) {
File newCodeFolder = new File(newFolder, "code");
- Base.copyDir(codeFolder, newCodeFolder);
+ Base.copyDir(data.getCodeFolder(), newCodeFolder);
}
// copy custom applet.html file if one exists
// http://dev.processing.org/bugs/show_bug.cgi?id=485
- File customHtml = new File(folder, "applet.html");
+ File customHtml = new File(data.getFolder(), "applet.html");
if (customHtml.exists()) {
File newHtml = new File(newFolder, "applet.html");
Base.copyFile(customHtml, newHtml);
@@ -912,7 +738,7 @@ protected boolean saveAs() throws IOException {
// save the main tab with its new name
File newFile = new File(newFolder, newName + ".ino");
- code[0].saveAs(newFile);
+ data.getCode(0).saveAs(newFile);
editor.handleOpenUnchecked(newFile,
currentIndex,
@@ -1003,19 +829,19 @@ public boolean addFile(File sourceFile) {
//if (!codeFolder.exists()) codeFolder.mkdirs();
prepareCodeFolder();
- destFile = new File(codeFolder, filename);
+ destFile = new File(data.getCodeFolder(), filename);
} else {
- for (String extension : getExtensions()) {
+ for (String extension : data.getExtensions()) {
String lower = filename.toLowerCase();
if (lower.endsWith("." + extension)) {
- destFile = new File(this.folder, filename);
+ destFile = new File(data.getFolder(), filename);
codeExtension = extension;
}
}
if (codeExtension == null) {
prepareDataFolder();
- destFile = new File(dataFolder, filename);
+ destFile = new File(data.getDataFolder(), filename);
}
}
@@ -1075,27 +901,28 @@ public boolean addFile(File sourceFile) {
}
if (codeExtension != null) {
- SketchCode newCode = new SketchCode(destFile, codeExtension);
+ SketchCode newCode = (new SketchCodeDocument(destFile)).getCode();
if (replacement) {
- replaceCode(newCode);
+ data.replaceCode(newCode);
} else {
- insertCode(newCode);
- sortCode();
+ ensureExistence();
+ data.addCode(newCode);
+ data.sortCode();
}
setCurrentCode(filename);
editor.header.repaint();
if (editor.untitled) { // TODO probably not necessary? problematic?
// Mark the new code as modified so that the sketch is saved
- current.setModified(true);
+ current.getCode().setModified(true);
}
} else {
if (editor.untitled) { // TODO probably not necessary? problematic?
// If a file has been added, mark the main code as modified so
// that the sketch is properly saved.
- code[0].setModified(true);
+ data.getCode(0).setModified(true);
}
}
return true;
@@ -1119,7 +946,7 @@ public void importLibrary(File jarPath) throws IOException {
// import statements into the main sketch file (code[0])
// if the current code is a .java file, insert into current
//if (current.flavor == PDE) {
- if (hasDefaultExtension(current)) {
+ if (hasDefaultExtension(current.getCode())) {
setCurrentCode(0);
}
// could also scan the text in the file to see if each import
@@ -1155,16 +982,17 @@ public void setCurrentCode(int which) {
// get the text currently being edited
if (current != null) {
- current.setState(editor.getText(),
- editor.getSelectionStart(),
- editor.getSelectionStop(),
- editor.getScrollPosition());
+ current.getCode().setProgram(editor.getText());
+ current.setSelectionStart(editor.getSelectionStart());
+ current.setSelectionStop(editor.getSelectionStop());
+ current.setScrollPosition(editor.getScrollPosition());
}
- current = code[which];
+ current = (SketchCodeDocument) data.getCode(which).getMetadata();
currentIndex = which;
editor.setCode(current);
+
editor.header.rebuild();
}
@@ -1174,58 +1002,16 @@ public void setCurrentCode(int which) {
* @param findName the file name (not pretty name) to be shown
*/
protected void setCurrentCode(String findName) {
- for (int i = 0; i < codeCount; i++) {
- if (findName.equals(code[i].getFileName()) ||
- findName.equals(code[i].getPrettyName())) {
- setCurrentCode(i);
+ for (SketchCode code : data.getCodes()) {
+ if (findName.equals(code.getFileName()) ||
+ findName.equals(code.getPrettyName())) {
+ setCurrentCode(data.indexOfCode(code));
return;
}
}
}
- /**
- * Cleanup temporary files used during a build/run.
- */
- protected void cleanup(boolean force) {
- // if the java runtime is holding onto any files in the build dir, we
- // won't be able to delete them, so we need to force a gc here
- System.gc();
-
- if (force) {
- // delete the entire directory and all contents
- // when we know something changed and all objects
- // need to be recompiled, or if the board does not
- // use setting build.dependency
- //Base.removeDir(tempBuildFolder);
-
- // note that we can't remove the builddir itself, otherwise
- // the next time we start up, internal runs using Runner won't
- // work because the build dir won't exist at startup, so the classloader
- // will ignore the fact that that dir is in the CLASSPATH in run.sh
- Base.removeDescendants(tempBuildFolder);
- } else {
- // delete only stale source files, from the previously
- // compiled sketch. This allows multiple windows to be
- // used. Keep everything else, which might be reusable
- if (tempBuildFolder.exists()) {
- String files[] = tempBuildFolder.list();
- for (String file : files) {
- if (file.endsWith(".c") || file.endsWith(".cpp") || file.endsWith(".s")) {
- File deleteMe = new File(tempBuildFolder, file);
- if (!deleteMe.delete()) {
- System.err.println("Could not delete " + deleteMe);
- }
- }
- }
- }
- }
-
- // Create a fresh applet folder (needed before preproc is run below)
- //tempBuildFolder.mkdirs();
- }
-
-
/**
* Preprocess, Compile, and Run the current code.
*
@@ -1262,7 +1048,7 @@ public void prepare() throws IOException {
// make sure the user didn't hide the sketch folder
ensureExistence();
- current.setProgram(editor.getText());
+ current.getCode().setProgram(editor.getText());
// TODO record history here
//current.history.record(program, SketchHistory.RUN);
@@ -1287,142 +1073,6 @@ public void prepare() throws IOException {
}
- /**
- * Build all the code for this sketch.
- *
- * In an advanced program, the returned class name could be different,
- * which is why the className is set based on the return value.
- * A compilation error will burp up a RunnerException.
- *
- * Setting purty to 'true' will cause exception line numbers to be incorrect.
- * Unless you know the code compiles, you should first run the preprocessor
- * with purty set to false to make sure there are no errors, then once
- * successful, re-export with purty set to true.
- *
- * @param buildPath Location to copy all the .java files
- * @return null if compilation failed, main class name if not
- */
- public void preprocess(String buildPath) throws RunnerException {
- preprocess(buildPath, new PdePreprocessor());
- }
-
- public void preprocess(String buildPath, PdePreprocessor preprocessor) throws RunnerException {
- // make sure the user didn't hide the sketch folder
- ensureExistence();
-
- classPath = buildPath;
-
-// // figure out the contents of the code folder to see if there
-// // are files that need to be added to the imports
-// if (codeFolder.exists()) {
-// libraryPath = codeFolder.getAbsolutePath();
-//
-// // get a list of .jar files in the "code" folder
-// // (class files in subfolders should also be picked up)
-// String codeFolderClassPath =
-// Compiler.contentsToClassPath(codeFolder);
-// // append the jar files in the code folder to the class path
-// classPath += File.pathSeparator + codeFolderClassPath;
-// // get list of packages found in those jars
-// codeFolderPackages =
-// Compiler.packageListFromClassPath(codeFolderClassPath);
-//
-// } else {
-// libraryPath = "";
-// }
-
- // 1. concatenate all .pde files to the 'main' pde
- // store line number for starting point of each code bit
-
- StringBuffer bigCode = new StringBuffer();
- int bigCount = 0;
- for (SketchCode sc : code) {
- if (sc.isExtension("ino") || sc.isExtension("pde")) {
- sc.setPreprocOffset(bigCount);
- // These #line directives help the compiler report errors with
- // correct the filename and line number (issue 281 & 907)
- bigCode.append("#line 1 \"" + sc.getFileName() + "\"\n");
- bigCode.append(sc.getProgram());
- bigCode.append('\n');
- bigCount += sc.getLineCount();
- }
- }
-
- // Note that the headerOffset isn't applied until compile and run, because
- // it only applies to the code after it's been written to the .java file.
- int headerOffset = 0;
- try {
- headerOffset = preprocessor.writePrefix(bigCode.toString());
- } catch (FileNotFoundException fnfe) {
- fnfe.printStackTrace();
- String msg = _("Build folder disappeared or could not be written");
- throw new RunnerException(msg);
- }
-
- // 2. run preproc on that code using the sugg class name
- // to create a single .java file and write to buildpath
-
- try {
- // Output file
- File streamFile = new File(buildPath, name + ".cpp");
- FileOutputStream outputStream = new FileOutputStream(streamFile);
- preprocessor.write(outputStream);
- outputStream.close();
- } catch (FileNotFoundException fnfe) {
- fnfe.printStackTrace();
- String msg = _("Build folder disappeared or could not be written");
- throw new RunnerException(msg);
- } catch (RunnerException pe) {
- // RunnerExceptions are caught here and re-thrown, so that they don't
- // get lost in the more general "Exception" handler below.
- throw pe;
-
- } catch (Exception ex) {
- // TODO better method for handling this?
- System.err.println(I18n.format(_("Uncaught exception type: {0}"), ex.getClass()));
- ex.printStackTrace();
- throw new RunnerException(ex.toString());
- }
-
- // grab the imports from the code just preproc'd
-
- importedLibraries = new LibraryList();
- for (String item : preprocessor.getExtraImports()) {
- Library lib = Base.importToLibraryTable.get(item);
- if (lib != null && !importedLibraries.contains(lib)) {
- importedLibraries.add(lib);
- }
- }
-
- // 3. then loop over the code[] and save each .java file
-
- for (SketchCode sc : code) {
- if (sc.isExtension("c") || sc.isExtension("cpp") || sc.isExtension("h")) {
- // no pre-processing services necessary for java files
- // just write the the contents of 'program' to a .java file
- // into the build directory. uses byte stream and reader/writer
- // shtuff so that unicode bunk is properly handled
- String filename = sc.getFileName(); //code[i].name + ".java";
- try {
- Base.saveFile(sc.getProgram(), new File(buildPath, filename));
- } catch (IOException e) {
- e.printStackTrace();
- throw new RunnerException(I18n.format(_("Problem moving {0} to the build folder"), filename));
- }
-// sc.setPreprocName(filename);
-
- } else if (sc.isExtension("ino") || sc.isExtension("pde")) {
- // The compiler and runner will need this to have a proper offset
- sc.addPreprocOffset(headerOffset);
- }
- }
- }
-
-
- public LibraryList getImportedLibraries() {
- return importedLibraries;
- }
-
/**
* Map an error from a set of processed .java files back to its location
@@ -1474,31 +1124,6 @@ public LibraryList getImportedLibraries() {
// }
- /**
- * Map an error from a set of processed .java files back to its location
- * in the actual sketch.
- * @param message The error message.
- * @param dotJavaFilename The .java file where the exception was found.
- * @param dotJavaLine Line number of the .java file for the exception (0-indexed!)
- * @return A RunnerException to be sent to the editor, or null if it wasn't
- * possible to place the exception to the sketch code.
- */
- public RunnerException placeException(String message,
- String dotJavaFilename,
- int dotJavaLine) {
- // Placing errors is simple, because we inserted #line directives
- // into the preprocessed source. The compiler gives us correct
- // the file name and line number. :-)
- for (int codeIndex = 0; codeIndex < getCodeCount(); codeIndex++) {
- SketchCode code = getCode(codeIndex);
- if (dotJavaFilename.equals(code.getFileName())) {
- return new RunnerException(message, codeIndex, dotJavaLine);
- }
- }
- return null;
- }
-
-
/**
* Run the build inside the temporary build folder.
* @return null if compilation failed, main class name if not
@@ -1508,47 +1133,6 @@ public String build(boolean verbose) throws RunnerException {
return build(tempBuildFolder.getAbsolutePath(), verbose);
}
- /**
- * Check if the build preferences used on the previous build in
- * buildPath match the ones given.
- */
- protected boolean buildPreferencesChanged(File buildPrefsFile, String newBuildPrefs) {
- // No previous build, so no match
- if (!buildPrefsFile.exists())
- return true;
-
- String previousPrefs;
- try {
- previousPrefs = FileUtils.readFileToString(buildPrefsFile);
- } catch (IOException e) {
- System.err.println(_("Could not read prevous build preferences file, rebuilding all"));
- return true;
- }
-
- if (!previousPrefs.equals(newBuildPrefs)) {
- System.out.println(_("Build options changed, rebuilding all"));
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Returns the build preferences of the given compiler as a string.
- * Only includes build-specific preferences, to make sure unrelated
- * preferences don't cause a rebuild (in particular preferences that
- * change on every start, like last.ide.xxx.daterun). */
- protected String buildPrefsString(Compiler compiler) {
- PreferencesMap buildPrefs = compiler.getBuildPreferences();
- String res = "";
- SortedSet treeSet = new TreeSet(buildPrefs.keySet());
- for (String k : treeSet) {
- if (k.startsWith("build.") || k.startsWith("compiler.") || k.startsWith("recipes."))
- res += k + " = " + buildPrefs.get(k) + "\n";
- }
- return res;
- }
-
/**
* Preprocess and compile all the code for this sketch.
*
@@ -1559,37 +1143,19 @@ protected String buildPrefsString(Compiler compiler) {
* @return null if compilation failed, main class name if not
*/
public String build(String buildPath, boolean verbose) throws RunnerException {
- String primaryClassName = name + ".cpp";
- Compiler compiler = new Compiler(this, buildPath, primaryClassName);
- File buildPrefsFile = new File(buildPath, BUILD_PREFS_FILE);
- String newBuildPrefs = buildPrefsString(compiler);
-
- // Do a forced cleanup (throw everything away) if the previous
- // build settings do not match the previous ones
- boolean prefsChanged = buildPreferencesChanged(buildPrefsFile, newBuildPrefs);
- cleanup(prefsChanged);
-
- if (prefsChanged) {
- try {
- PrintWriter out = new PrintWriter(buildPrefsFile);
- out.print(newBuildPrefs);
- out.close();
- } catch (IOException e) {
- System.err.println(_("Could not write build preferences file"));
- }
- }
-
// run the preprocessor
editor.status.progressUpdate(20);
- preprocess(buildPath);
- // compile the program. errors will happen as a RunnerException
- // that will bubble up to whomever called build().
- if (compiler.compile(verbose)) {
- size(compiler.getBuildPreferences());
- return primaryClassName;
- }
- return null;
+ ensureExistence();
+
+ ProgressListener pl = new ProgressListener() {
+ @Override
+ public void progress(int percent) {
+ editor.status.progressUpdate(percent);
+ }
+ };
+
+ return Compiler.build(data, buildPath, tempBuildFolder, pl, verbose);
}
protected boolean exportApplet(boolean usingProgrammer) throws Exception {
@@ -1627,71 +1193,9 @@ public boolean exportApplet(String appletPath, boolean usingProgrammer)
}
- public void setCompilingProgress(int percent) {
- editor.status.progressUpdate(percent);
- }
-
-
- protected void size(PreferencesMap prefs) throws RunnerException {
- String maxTextSizeString = prefs.get("upload.maximum_size");
- String maxDataSizeString = prefs.get("upload.maximum_data_size");
- if (maxTextSizeString == null)
- return;
- long maxTextSize = Integer.parseInt(maxTextSizeString);
- long maxDataSize = -1;
- if (maxDataSizeString != null)
- maxDataSize = Integer.parseInt(maxDataSizeString);
- Sizer sizer = new Sizer(prefs);
- long[] sizes;
- try {
- sizes = sizer.computeSize();
- } catch (RunnerException e) {
- System.err.println(I18n.format(_("Couldn't determine program size: {0}"),
- e.getMessage()));
- return;
- }
-
- long textSize = sizes[0];
- long dataSize = sizes[1];
- System.out.println();
- System.out.println(I18n
- .format(_("Sketch uses {0} bytes ({2}%%) of program storage space. Maximum is {1} bytes."),
- textSize, maxTextSize, textSize * 100 / maxTextSize));
- if (dataSize >= 0) {
- if (maxDataSize > 0) {
- System.out
- .println(I18n
- .format(
- _("Global variables use {0} bytes ({2}%%) of dynamic memory, leaving {3} bytes for local variables. Maximum is {1} bytes."),
- dataSize, maxDataSize, dataSize * 100 / maxDataSize,
- maxDataSize - dataSize));
- } else {
- System.out.println(I18n
- .format(_("Global variables use {0} bytes of dynamic memory."), dataSize));
- }
- }
-
- if (textSize > maxTextSize)
- throw new RunnerException(
- _("Sketch too big; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it."));
-
- if (maxDataSize > 0 && dataSize > maxDataSize)
- throw new RunnerException(
- _("Not enough memory; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing your footprint."));
-
- int warnDataPercentage = Integer.parseInt(prefs.get("build.warn_data_percentage"));
- if (maxDataSize > 0 && dataSize > maxDataSize*warnDataPercentage/100)
- System.err.println(_("Low memory available, stability problems may occur."));
- }
-
protected boolean upload(String buildPath, String suggestedClassName, boolean usingProgrammer) throws Exception {
- TargetPlatform target = Base.getTargetPlatform();
- String board = Preferences.get("board");
-
- BoardPort boardPort = Base.getDiscoveryManager().find(Preferences.get("serial.port"));
-
- Uploader uploader = new UploaderAndMonitorFactory().newUploader(target.getBoards().get(board), boardPort);
+ Uploader uploader = Compiler.getUploaderByPreferences(false);
boolean success = false;
do {
@@ -1710,7 +1214,7 @@ protected boolean upload(String buildPath, String suggestedClassName, boolean us
List warningsAccumulator = new LinkedList();
try {
- success = uploader.uploadUsingPreferences(getFolder(), buildPath, suggestedClassName, usingProgrammer, warningsAccumulator);
+ success = Compiler.upload(data, uploader, buildPath, suggestedClassName, usingProgrammer, false, warningsAccumulator);
} finally {
if (uploader.requiresAuthorization() && !success) {
Preferences.remove(uploader.getAuthorizationKey());
@@ -1758,18 +1262,18 @@ public boolean exportApplication(String destPath,
* but not its contents.
*/
protected void ensureExistence() {
- if (folder.exists()) return;
+ if (data.getFolder().exists()) return;
Base.showWarning(_("Sketch Disappeared"),
_("The sketch folder has disappeared.\n " +
"Will attempt to re-save in the same location,\n" +
"but anything besides the code will be lost."), null);
try {
- folder.mkdirs();
+ data.getFolder().mkdirs();
modified = true;
- for (int i = 0; i < codeCount; i++) {
- code[i].save(); // this will force a save
+ for (SketchCode code : data.getCodes()) {
+ code.save(); // this will force a save
}
calcModified();
@@ -1789,7 +1293,7 @@ protected void ensureExistence() {
* volumes or folders without appropriate permissions.
*/
public boolean isReadOnly() {
- String apath = folder.getAbsolutePath();
+ String apath = data.getFolder().getAbsolutePath();
for (File folder : Base.getLibrariesPath()) {
if (apath.startsWith(folder.getAbsolutePath()))
return true;
@@ -1803,9 +1307,8 @@ public boolean isReadOnly() {
// } else if (!folder.canWrite()) {
// check to see if each modified code file can be written to
- for (int i = 0; i < codeCount; i++) {
- if (code[i].isModified() && code[i].fileReadOnly() &&
- code[i].fileExists()) {
+ for (SketchCode code : data.getCodes()) {
+ if (code.isModified() && code.fileReadOnly() && code.fileExists()) {
// System.err.println("found a read-only file " + code[i].file);
return true;
}
@@ -1818,21 +1321,11 @@ public boolean isReadOnly() {
// Breaking out extension types in order to clean up the code, and make it
// easier for other environments (like Arduino) to incorporate changes.
-
- /**
- * True if the specified extension should be hidden when shown on a tab.
- * For Processing, this is true for .pde files. (Broken out for subclasses.)
- */
- public boolean hideExtension(String what) {
- return getHiddenExtensions().contains(what);
- }
-
-
/**
* True if the specified code has the default file extension.
*/
public boolean hasDefaultExtension(SketchCode code) {
- return code.getExtension().equals(getDefaultExtension());
+ return code.isExtension(getDefaultExtension());
}
@@ -1849,11 +1342,7 @@ public boolean isDefaultExtension(String what) {
* extensions.
*/
public boolean validExtension(String what) {
- String[] ext = getExtensions();
- for (int i = 0; i < ext.length; i++) {
- if (ext[i].equals(what)) return true;
- }
- return false;
+ return data.getExtensions().contains(what);
}
@@ -1861,7 +1350,7 @@ public boolean validExtension(String what) {
* Returns the default extension for this editor setup.
*/
public String getDefaultExtension() {
- return "ino";
+ return data.getDefaultExtension();
}
static private List hiddenExtensions = Arrays.asList("ino", "pde");
@@ -1870,13 +1359,6 @@ public List getHiddenExtensions() {
return hiddenExtensions;
}
- /**
- * Returns a String[] array of proper extensions.
- */
- public String[] getExtensions() {
- return new String[] { "ino", "pde", "c", "cpp", "h" };
- }
-
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
@@ -1888,15 +1370,7 @@ public String[] getExtensions() {
* Returns the name of this sketch. (The pretty name of the main tab.)
*/
public String getName() {
- return name;
- }
-
-
- /**
- * Returns a file object for the primary .pde of this sketch.
- */
- public File getPrimaryFile() {
- return primaryFile;
+ return data.getName();
}
@@ -1904,8 +1378,7 @@ public File getPrimaryFile() {
* Returns path to the main .pde file for this sketch.
*/
public String getMainFilePath() {
- return primaryFile.getAbsolutePath();
- //return code[0].file.getAbsolutePath();
+ return data.getMainFilePath();
}
@@ -1913,15 +1386,7 @@ public String getMainFilePath() {
* Returns the sketch folder.
*/
public File getFolder() {
- return folder;
- }
-
-
- /**
- * Returns the location of the sketch's data folder. (It may not exist yet.)
- */
- public File getDataFolder() {
- return dataFolder;
+ return data.getFolder();
}
@@ -1930,18 +1395,10 @@ public File getDataFolder() {
* it also returns the data folder, since it's likely about to be used.
*/
public File prepareDataFolder() {
- if (!dataFolder.exists()) {
- dataFolder.mkdirs();
+ if (!data.getDataFolder().exists()) {
+ data.getDataFolder().mkdirs();
}
- return dataFolder;
- }
-
-
- /**
- * Returns the location of the sketch's code folder. (It may not exist yet.)
- */
- public File getCodeFolder() {
- return codeFolder;
+ return data.getDataFolder();
}
@@ -1950,45 +1407,35 @@ public File getCodeFolder() {
* it also returns the code folder, since it's likely about to be used.
*/
public File prepareCodeFolder() {
- if (!codeFolder.exists()) {
- codeFolder.mkdirs();
+ if (!data.getCodeFolder().exists()) {
+ data.getCodeFolder().mkdirs();
}
- return codeFolder;
- }
-
-
- public String getClassPath() {
- return classPath;
+ return data.getCodeFolder();
}
- public SketchCode[] getCode() {
- return code;
+ public SketchCode[] getCodes() {
+ return data.getCodes();
}
public int getCodeCount() {
- return codeCount;
+ return data.getCodeCount();
}
public SketchCode getCode(int index) {
- return code[index];
+ return data.getCode(index);
}
public int getCodeIndex(SketchCode who) {
- for (int i = 0; i < codeCount; i++) {
- if (who == code[i]) {
- return i;
- }
- }
- return -1;
+ return data.indexOfCode(who);
}
public SketchCode getCurrentCode() {
- return current;
+ return current.getCode();
}
@@ -2015,7 +1462,7 @@ public String getAppletClassName2() {
* if changes were made.
*/
static public String checkName(String origName) {
- String newName = sanitizeName(origName);
+ String newName = BaseNoGui.sanitizeName(origName);
if (!newName.equals(origName)) {
String msg =
@@ -2028,55 +1475,4 @@ static public String checkName(String origName) {
}
- /**
- * Return true if the name is valid for a Processing sketch.
- */
- static public boolean isSanitaryName(String name) {
- return sanitizeName(name).equals(name);
- }
-
-
- /**
- * Produce a sanitized name that fits our standards for likely to work.
- *
- * Java classes have a wider range of names that are technically allowed
- * (supposedly any Unicode name) than what we support. The reason for
- * going more narrow is to avoid situations with text encodings and
- * converting during the process of moving files between operating
- * systems, i.e. uploading from a Windows machine to a Linux server,
- * or reading a FAT32 partition in OS X and using a thumb drive.
- *
- * This helper function replaces everything but A-Z, a-z, and 0-9 with
- * underscores. Also disallows starting the sketch name with a digit.
- */
- static public String sanitizeName(String origName) {
- char c[] = origName.toCharArray();
- StringBuffer buffer = new StringBuffer();
-
- // can't lead with a digit, so start with an underscore
- if ((c[0] >= '0') && (c[0] <= '9')) {
- buffer.append('_');
- }
- for (int i = 0; i < c.length; i++) {
- if (((c[i] >= '0') && (c[i] <= '9')) ||
- ((c[i] >= 'a') && (c[i] <= 'z')) ||
- ((c[i] >= 'A') && (c[i] <= 'Z')) ||
- ((i > 0) && (c[i] == '-')) ||
- ((i > 0) && (c[i] == '.'))) {
- buffer.append(c[i]);
- } else {
- buffer.append('_');
- }
- }
- // let's not be ridiculous about the length of filenames.
- // in fact, Mac OS 9 can handle 255 chars, though it can't really
- // deal with filenames longer than 31 chars in the Finder.
- // but limiting to that for sketches would mean setting the
- // upper-bound on the character limit here to 25 characters
- // (to handle the base name + ".class")
- if (buffer.length() > 63) {
- buffer.setLength(63);
- }
- return buffer.toString();
- }
}
diff --git a/app/src/processing/app/SketchCodeDocument.java b/app/src/processing/app/SketchCodeDocument.java
new file mode 100644
index 00000000000..857a270abc2
--- /dev/null
+++ b/app/src/processing/app/SketchCodeDocument.java
@@ -0,0 +1,79 @@
+package processing.app;
+
+import java.io.File;
+
+import javax.swing.text.Document;
+
+public class SketchCodeDocument{
+
+ private SketchCode code;
+ private Document document;
+
+ // Undo Manager for this tab, each tab keeps track of their own Editor.undo
+ // will be set to this object when this code is the tab that's currently the
+ // front.
+ private LastUndoableEditAwareUndoManager undo = new LastUndoableEditAwareUndoManager();
+
+ // saved positions from last time this tab was used
+ private int selectionStart;
+ private int selectionStop;
+ private int scrollPosition;
+
+ public SketchCodeDocument(SketchCode code) {
+ this.code = code;
+ this.code.setMetadata(this);
+ }
+
+ public SketchCodeDocument(File file) {
+ this.code = new SketchCode(file, this);
+ }
+
+ public LastUndoableEditAwareUndoManager getUndo() {
+ return undo;
+ }
+
+ public void setUndo(LastUndoableEditAwareUndoManager undo) {
+ this.undo = undo;
+ }
+
+ public int getSelectionStart() {
+ return selectionStart;
+ }
+
+ public void setSelectionStart(int selectionStart) {
+ this.selectionStart = selectionStart;
+ }
+
+ public int getSelectionStop() {
+ return selectionStop;
+ }
+
+ public void setSelectionStop(int selectionStop) {
+ this.selectionStop = selectionStop;
+ }
+
+ public int getScrollPosition() {
+ return scrollPosition;
+ }
+
+ public void setScrollPosition(int scrollPosition) {
+ this.scrollPosition = scrollPosition;
+ }
+
+ public SketchCode getCode() {
+ return code;
+ }
+
+ public void setCode(SketchCode code) {
+ this.code = code;
+ }
+
+ public Document getDocument() {
+ return document;
+ }
+
+ public void setDocument(Document document) {
+ this.document = document;
+ }
+
+}
diff --git a/app/src/processing/app/Theme.java b/app/src/processing/app/Theme.java
index b6c8ae4f0f7..7f23d3c4602 100644
--- a/app/src/processing/app/Theme.java
+++ b/app/src/processing/app/Theme.java
@@ -1,5 +1,3 @@
-/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
-
/*
Part of the Processing project - http://processing.org
@@ -23,14 +21,15 @@
package processing.app;
-import java.awt.*;
-import java.io.*;
-import java.util.*;
-
-import processing.app.syntax.*;
-import processing.core.*;
import static processing.app.I18n._;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.SystemColor;
+
+import processing.app.helpers.PreferencesHelper;
+import processing.app.helpers.PreferencesMap;
+import processing.app.syntax.SyntaxStyle;
/**
* Storage class for theme settings. This was separated from the Preferences
@@ -40,164 +39,80 @@
public class Theme {
/** Copy of the defaults in case the user mangles a preference. */
- static HashMap defaults;
+ static PreferencesMap defaults;
/** Table of attributes/values for the theme. */
- static HashMap table = new HashMap();;
-
+ static PreferencesMap table = new PreferencesMap();
static protected void init() {
try {
- load(Base.getLibStream("theme/theme.txt"));
+ table.load(Base.getLibStream("theme/theme.txt"));
} catch (Exception te) {
Base.showError(null, _("Could not read color theme settings.\n" +
"You'll need to reinstall Arduino."), te);
}
- // check for platform-specific properties in the defaults
- String platformExt = "." + Base.getPlatformName();
- int platformExtLength = platformExt.length();
- for (String key : table.keySet()) {
- if (key.endsWith(platformExt)) {
- // this is a key specific to a particular platform
- String actualKey = key.substring(0, key.length() - platformExtLength);
- String value = get(key);
- table.put(actualKey, value);
- }
- }
-
// other things that have to be set explicitly for the defaults
setColor("run.window.bgcolor", SystemColor.control);
// clone the hash table
- defaults = (HashMap) table.clone();
- }
-
-
- static protected void load(InputStream input) throws IOException {
- String[] lines = PApplet.loadStrings(input);
- for (String line : lines) {
- if ((line.length() == 0) ||
- (line.charAt(0) == '#')) continue;
-
- // this won't properly handle = signs being in the text
- int equals = line.indexOf('=');
- if (equals != -1) {
- String key = line.substring(0, equals).trim();
- String value = line.substring(equals + 1).trim();
- table.put(key, value);
- }
- }
+ defaults = new PreferencesMap(table);
}
-
static public String get(String attribute) {
- return (String) table.get(attribute);
+ return table.get(attribute);
}
-
static public String getDefault(String attribute) {
- return (String) defaults.get(attribute);
+ return defaults.get(attribute);
}
-
static public void set(String attribute, String value) {
table.put(attribute, value);
}
-
static public boolean getBoolean(String attribute) {
- String value = get(attribute);
- return (new Boolean(value)).booleanValue();
+ return table.getBoolean(attribute);
}
-
static public void setBoolean(String attribute, boolean value) {
- set(attribute, value ? "true" : "false");
+ table.putBoolean(attribute, value);
}
-
static public int getInteger(String attribute) {
return Integer.parseInt(get(attribute));
}
-
static public void setInteger(String key, int value) {
set(key, String.valueOf(value));
}
-
static public Color getColor(String name) {
- Color parsed = null;
- String s = get(name);
- if ((s != null) && (s.indexOf("#") == 0)) {
- try {
- int v = Integer.parseInt(s.substring(1), 16);
- parsed = new Color(v);
- } catch (Exception e) {
- }
- }
- return parsed;
+ return PreferencesHelper.parseColor(get(name));
}
-
- static public void setColor(String attr, Color what) {
- set(attr, "#" + PApplet.hex(what.getRGB() & 0xffffff, 6));
+ static public void setColor(String attr, Color color) {
+ PreferencesHelper.putColor(table, attr, color);
}
-
static public Font getFont(String attr) {
- boolean replace = false;
- String value = get(attr);
- if (value == null) {
- //System.out.println("reset 1");
- value = getDefault(attr);
- replace = true;
- }
-
- String[] pieces = PApplet.split(value, ',');
- if (pieces.length != 3) {
- value = getDefault(attr);
- //System.out.println("reset 2 for " + attr);
- pieces = PApplet.split(value, ',');
- //PApplet.println(pieces);
- replace = true;
- }
-
- String name = pieces[0];
- int style = Font.PLAIN; // equals zero
- if (pieces[1].indexOf("bold") != -1) {
- style |= Font.BOLD;
- }
- if (pieces[1].indexOf("italic") != -1) {
- style |= Font.ITALIC;
- }
- int size = PApplet.parseInt(pieces[2], 12);
- Font font = new Font(name, style, size);
-
- // replace bad font with the default
- if (replace) {
- //System.out.println(attr + " > " + value);
- //setString(attr, font.getName() + ",plain," + font.getSize());
+ Font font = PreferencesHelper.getFont(table, attr);
+ if (font == null) {
+ String value = getDefault(attr);
set(attr, value);
+ font = PreferencesHelper.getFont(table, attr);
}
-
return font;
}
-
static public SyntaxStyle getStyle(String what) {
- String str = get("editor." + what + ".style");
-
- StringTokenizer st = new StringTokenizer(str, ",");
+ String split[] = get("editor." + what + ".style").split(",");
- String s = st.nextToken();
- if (s.indexOf("#") == 0) s = s.substring(1);
- Color color = new Color(Integer.parseInt(s, 16));
+ Color color = PreferencesHelper.parseColor(split[0]);
- s = st.nextToken();
- boolean bold = (s.indexOf("bold") != -1);
- boolean italic = (s.indexOf("italic") != -1);
- boolean underlined = (s.indexOf("underlined") != -1);
+ String style = split[1];
+ boolean bold = style.contains("bold");
+ boolean italic = style.contains("italic");
+ boolean underlined = style.contains("underlined");
return new SyntaxStyle(color, italic, bold, underlined);
}
diff --git a/app/src/processing/app/UpdateCheck.java b/app/src/processing/app/UpdateCheck.java
index 21db25b5ce0..0e94366e92a 100644
--- a/app/src/processing/app/UpdateCheck.java
+++ b/app/src/processing/app/UpdateCheck.java
@@ -31,7 +31,7 @@
import javax.swing.JOptionPane;
-import processing.core.PApplet;
+import processing.app.legacy.PApplet;
import static processing.app.I18n._;
diff --git a/app/src/processing/app/helpers/GUIUserNotifier.java b/app/src/processing/app/helpers/GUIUserNotifier.java
new file mode 100644
index 00000000000..de20b7e3f25
--- /dev/null
+++ b/app/src/processing/app/helpers/GUIUserNotifier.java
@@ -0,0 +1,49 @@
+package processing.app.helpers;
+
+import static processing.app.I18n._;
+
+import java.awt.Frame;
+
+import javax.swing.JOptionPane;
+
+public class GUIUserNotifier extends UserNotifier {
+
+ /**
+ * Show an error message that's actually fatal to the program.
+ * This is an error that can't be recovered. Use showWarning()
+ * for errors that allow P5 to continue running.
+ */
+ public void showError(String title, String message, Throwable e, int exit_code) {
+ if (title == null) title = _("Error");
+
+ JOptionPane.showMessageDialog(new Frame(), message, title,
+ JOptionPane.ERROR_MESSAGE);
+
+ if (e != null) e.printStackTrace();
+ System.exit(exit_code);
+ }
+
+ /**
+ * "No cookie for you" type messages. Nothing fatal or all that
+ * much of a bummer, but something to notify the user about.
+ */
+ public void showMessage(String title, String message) {
+ if (title == null) title = _("Message");
+
+ JOptionPane.showMessageDialog(new Frame(), message, title,
+ JOptionPane.INFORMATION_MESSAGE);
+ }
+
+ /**
+ * Non-fatal error message with optional stack trace side dish.
+ */
+ public void showWarning(String title, String message, Exception e) {
+ if (title == null) title = _("Warning");
+
+ JOptionPane.showMessageDialog(new Frame(), message, title,
+ JOptionPane.WARNING_MESSAGE);
+
+ if (e != null) e.printStackTrace();
+ }
+
+}
diff --git a/app/src/processing/app/macosx/ThinkDifferent.java b/app/src/processing/app/macosx/ThinkDifferent.java
index 0f226dd716a..e14770a9b6d 100644
--- a/app/src/processing/app/macosx/ThinkDifferent.java
+++ b/app/src/processing/app/macosx/ThinkDifferent.java
@@ -50,7 +50,7 @@ public class ThinkDifferent implements ApplicationListener {
private Base base;
- static protected void init(Base base) {
+ static public void init(Base base) {
if (application == null) {
//application = new com.apple.eawt.Application();
application = com.apple.eawt.Application.getApplication();
diff --git a/app/src/processing/app/syntax/PdeKeywords.java b/app/src/processing/app/syntax/PdeKeywords.java
index d8e48f8e87d..ccf52531cfd 100644
--- a/app/src/processing/app/syntax/PdeKeywords.java
+++ b/app/src/processing/app/syntax/PdeKeywords.java
@@ -25,6 +25,7 @@
package processing.app.syntax;
import processing.app.*;
+import processing.app.legacy.PApplet;
import processing.app.packages.Library;
import java.io.*;
@@ -84,7 +85,7 @@ static private void getKeywords(InputStream input) throws Exception {
// in case there's any garbage on the line
//if (line.trim().length() == 0) continue;
- String pieces[] = processing.core.PApplet.split(line, '\t');
+ String pieces[] = PApplet.split(line, '\t');
if (pieces.length >= 2) {
//int tab = line.indexOf('\t');
// any line with no tab is ignored
diff --git a/app/src/processing/app/syntax/PdeTextAreaDefaults.java b/app/src/processing/app/syntax/PdeTextAreaDefaults.java
index 382c69aaff8..2ff65afa8bc 100644
--- a/app/src/processing/app/syntax/PdeTextAreaDefaults.java
+++ b/app/src/processing/app/syntax/PdeTextAreaDefaults.java
@@ -25,6 +25,7 @@
package processing.app.syntax;
import processing.app.*;
+import processing.app.helpers.OSUtils;
public class PdeTextAreaDefaults extends TextAreaDefaults {
@@ -35,7 +36,7 @@ public PdeTextAreaDefaults() {
//inputHandler.addDefaultKeyBindings(); // 0122
// use option on mac for text edit controls that are ctrl on windows/linux
- String mod = Base.isMacOS() ? "A" : "C";
+ String mod = OSUtils.isMacOS() ? "A" : "C";
// right now, ctrl-up/down is select up/down, but mod should be
// used instead, because the mac expects it to be option(alt)
@@ -94,7 +95,7 @@ public PdeTextAreaDefaults() {
inputHandler.addKeyBinding("CS+END", InputHandler.SELECT_DOC_END);
}
- if (Base.isMacOS()) {
+ if (OSUtils.isMacOS()) {
inputHandler.addKeyBinding("M+LEFT", InputHandler.HOME);
inputHandler.addKeyBinding("M+RIGHT", InputHandler.END);
inputHandler.addKeyBinding("MS+LEFT", InputHandler.SELECT_HOME); // 0122
diff --git a/app/src/processing/app/tools/AutoFormat.java b/app/src/processing/app/tools/AutoFormat.java
index 8cad91385a9..c2c109c061a 100644
--- a/app/src/processing/app/tools/AutoFormat.java
+++ b/app/src/processing/app/tools/AutoFormat.java
@@ -25,7 +25,7 @@ Bug fixes Copyright (c) 2005-09 Ben Fry and Casey Reas
package processing.app.tools;
import processing.app.*;
-import processing.core.PApplet;
+import processing.app.legacy.PApplet;
import static processing.app.I18n._;
import java.io.*;
diff --git a/app/src/processing/app/tools/ColorSelector.java b/app/src/processing/app/tools/ColorSelector.java
deleted file mode 100644
index de14022398c..00000000000
--- a/app/src/processing/app/tools/ColorSelector.java
+++ /dev/null
@@ -1,609 +0,0 @@
-/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
-
-/*
- Part of the Processing project - http://processing.org
-
- Copyright (c) 2006-08 Ben Fry and Casey Reas
-
- This program 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-package processing.app.tools;
-
-import processing.app.*;
-import processing.core.*;
-
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-import javax.swing.border.*;
-import javax.swing.event.*;
-import javax.swing.text.*;
-
-
-/**
- * Color selector tool for the Tools menu.
- *
- * Using the keyboard shortcuts, you can copy/paste the values for the
- * colors and paste them into your program. We didn't do any sort of
- * auto-insert of colorMode() or fill() or stroke() code cuz we couldn't
- * decide on a good way to do this.. your contributions welcome).
- */
-public class ColorSelector implements Tool, DocumentListener {
-
- Editor editor;
- JFrame frame;
-
- int hue, saturation, brightness; // range 360, 100, 100
- int red, green, blue; // range 256, 256, 256
-
- ColorRange range;
- ColorSlider slider;
-
- JTextField hueField, saturationField, brightnessField;
- JTextField redField, greenField, blueField;
-
- JTextField hexField;
-
- JPanel colorPanel;
-
-
- public String getMenuTitle() {
- return "Color Selector";
- }
-
-
- public void init(Editor editor) {
- this.editor = editor;
-
- frame = new JFrame("Color Selector");
- frame.getContentPane().setLayout(new BorderLayout());
-
- Box box = Box.createHorizontalBox();
- box.setBorder(new EmptyBorder(12, 12, 12, 12));
-
- range = new ColorRange();
- range.init();
- Box rangeBox = new Box(BoxLayout.Y_AXIS);
- rangeBox.setAlignmentY(0);
- rangeBox.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
- rangeBox.add(range);
- box.add(rangeBox);
- box.add(Box.createHorizontalStrut(10));
-
- slider = new ColorSlider();
- slider.init();
- Box sliderBox = new Box(BoxLayout.Y_AXIS);
- sliderBox.setAlignmentY(0);
- sliderBox.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
- sliderBox.add(slider);
- box.add(sliderBox);
- box.add(Box.createHorizontalStrut(10));
-
- box.add(createColorFields());
- box.add(Box.createHorizontalStrut(10));
-
- frame.getContentPane().add(box, BorderLayout.CENTER);
- frame.pack();
- frame.setResizable(false);
-
- // these don't help either.. they fix the component size but
- // leave a gap where the component is located
- //range.setSize(256, 256);
- //slider.setSize(256, 20);
-
- Dimension size = frame.getSize();
- Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
- frame.setLocation((screen.width - size.width) / 2,
- (screen.height - size.height) / 2);
-
- frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- frame.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- frame.setVisible(false);
- }
- });
- Base.registerWindowCloseKeys(frame.getRootPane(), new ActionListener() {
- public void actionPerformed(ActionEvent actionEvent) {
- frame.setVisible(false);
- }
- });
-
- Base.setIcon(frame);
-
- hueField.getDocument().addDocumentListener(this);
- saturationField.getDocument().addDocumentListener(this);
- brightnessField.getDocument().addDocumentListener(this);
- redField.getDocument().addDocumentListener(this);
- greenField.getDocument().addDocumentListener(this);
- blueField.getDocument().addDocumentListener(this);
- hexField.getDocument().addDocumentListener(this);
-
- hexField.setText("FFFFFF");
- }
-
-
- public void run() {
- frame.setVisible(true);
- // You've got to be f--ing kidding me.. why did the following line
- // get deprecated for the pile of s-- that follows it?
- //frame.setCursor(Cursor.CROSSHAIR_CURSOR);
- frame.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
- }
-
-
- public void changedUpdate(DocumentEvent e) {
- //System.out.println("changed");
- }
-
- public void removeUpdate(DocumentEvent e) {
- //System.out.println("remove");
- }
-
-
- boolean updating;
-
- public void insertUpdate(DocumentEvent e) {
- if (updating) return; // don't update forever recursively
- updating = true;
-
- Document doc = e.getDocument();
- if (doc == hueField.getDocument()) {
- hue = bounded(hue, hueField, 359);
- updateRGB();
- updateHex();
-
- } else if (doc == saturationField.getDocument()) {
- saturation = bounded(saturation, saturationField, 99);
- updateRGB();
- updateHex();
-
- } else if (doc == brightnessField.getDocument()) {
- brightness = bounded(brightness, brightnessField, 99);
- updateRGB();
- updateHex();
-
- } else if (doc == redField.getDocument()) {
- red = bounded(red, redField, 255);
- updateHSB();
- updateHex();
-
- } else if (doc == greenField.getDocument()) {
- green = bounded(green, greenField, 255);
- updateHSB();
- updateHex();
-
- } else if (doc == blueField.getDocument()) {
- blue = bounded(blue, blueField, 255);
- updateHSB();
- updateHex();
-
- } else if (doc == hexField.getDocument()) {
- String str = hexField.getText();
- while (str.length() < 6) {
- str += "0";
- }
- if (str.length() > 6) {
- str = str.substring(0, 6);
- }
- updateRGB2(Integer.parseInt(str, 16));
- updateHSB();
- }
- range.redraw();
- slider.redraw();
- colorPanel.repaint();
- updating = false;
- }
-
-
- /**
- * Set the RGB values based on the current HSB values.
- */
- protected void updateRGB() {
- int rgb = Color.HSBtoRGB((float)hue / 359f,
- (float)saturation / 99f,
- (float)brightness / 99f);
- updateRGB2(rgb);
- }
-
-
- /**
- * Set the RGB values based on a calculated ARGB int.
- * Used by both updateRGB() to set the color from the HSB values,
- * and by updateHex(), to unpack the hex colors and assign them.
- */
- protected void updateRGB2(int rgb) {
- red = (rgb >> 16) & 0xff;
- green = (rgb >> 8) & 0xff;
- blue = rgb & 0xff;
-
- redField.setText(String.valueOf(red));
- greenField.setText(String.valueOf(green));
- blueField.setText(String.valueOf(blue));
- }
-
-
- /**
- * Set the HSB values based on the current RGB values.
- */
- protected void updateHSB() {
- float hsb[] = new float[3];
- Color.RGBtoHSB(red, green, blue, hsb);
-
- hue = (int) (hsb[0] * 359.0f);
- saturation = (int) (hsb[1] * 99.0f);
- brightness = (int) (hsb[2] * 99.0f);
-
- hueField.setText(String.valueOf(hue));
- saturationField.setText(String.valueOf(saturation));
- brightnessField.setText(String.valueOf(brightness));
- }
-
-
- protected void updateHex() {
- hexField.setText(PApplet.hex(red, 2) +
- PApplet.hex(green, 2) +
- PApplet.hex(blue, 2));
- }
-
-
- /**
- * Get the bounded value for a specific range. If the value is outside
- * the max, you can't edit right away, so just act as if it's already
- * been bounded and return the bounded value, then fire an event to set
- * it to the value that was just returned.
- */
- protected int bounded(int current, final JTextField field, final int max) {
- String text = field.getText();
- if (text.length() == 0) {
- return 0;
- }
- try {
- int value = Integer.parseInt(text);
- if (value > max) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- field.setText(String.valueOf(max));
- }
- });
- return max;
- }
- return value;
-
- } catch (NumberFormatException e) {
- return current; // should not be reachable
- }
- }
-
-
- protected Container createColorFields() {
- Box box = Box.createVerticalBox();
- box.setAlignmentY(0);
-
- colorPanel = new JPanel() {
- public void paintComponent(Graphics g) {
- g.setColor(new Color(red, green, blue));
- Dimension size = getSize();
- g.fillRect(0, 0, size.width, size.height);
- }
- };
- colorPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
- Dimension dim = new Dimension(60, 40);
- colorPanel.setMinimumSize(dim);
- //colorPanel.setMaximumSize(dim);
- //colorPanel.setPreferredSize(dim);
- box.add(colorPanel);
- box.add(Box.createVerticalStrut(10));
-
- Box row;
-
- row = Box.createHorizontalBox();
- row.add(createFixedLabel("H:"));
- row.add(hueField = new NumberField(4, false));
- row.add(new JLabel(" \u00B0")); // degree symbol
- row.add(Box.createHorizontalGlue());
- box.add(row);
- box.add(Box.createVerticalStrut(5));
-
- row = Box.createHorizontalBox();
- row.add(createFixedLabel("S:"));
- row.add(saturationField = new NumberField(4, false));
- row.add(new JLabel(" %"));
- row.add(Box.createHorizontalGlue());
- box.add(row);
- box.add(Box.createVerticalStrut(5));
-
- row = Box.createHorizontalBox();
- row.add(createFixedLabel("B:"));
- row.add(brightnessField = new NumberField(4, false));
- row.add(new JLabel(" %"));
- row.add(Box.createHorizontalGlue());
- box.add(row);
- box.add(Box.createVerticalStrut(10));
-
- //
-
- row = Box.createHorizontalBox();
- row.add(createFixedLabel("R:"));
- row.add(redField = new NumberField(4, false));
- row.add(Box.createHorizontalGlue());
- box.add(row);
- box.add(Box.createVerticalStrut(5));
-
- row = Box.createHorizontalBox();
- row.add(createFixedLabel("G:"));
- row.add(greenField = new NumberField(4, false));
- row.add(Box.createHorizontalGlue());
- box.add(row);
- box.add(Box.createVerticalStrut(5));
-
- row = Box.createHorizontalBox();
- row.add(createFixedLabel("B:"));
- row.add(blueField = new NumberField(4, false));
- row.add(Box.createHorizontalGlue());
- box.add(row);
- box.add(Box.createVerticalStrut(10));
-
- //
-
- row = Box.createHorizontalBox();
- row.add(createFixedLabel("#"));
- row.add(hexField = new NumberField(5, true));
- row.add(Box.createHorizontalGlue());
- box.add(row);
- box.add(Box.createVerticalStrut(10));
-
- box.add(Box.createVerticalGlue());
- return box;
- }
-
-
- int labelH;
-
- /**
- * return a label of a fixed width
- */
- protected JLabel createFixedLabel(String title) {
- JLabel label = new JLabel(title);
- if (labelH == 0) {
- labelH = label.getPreferredSize().height;
- }
- Dimension dim = new Dimension(20, labelH);
- label.setPreferredSize(dim);
- label.setMinimumSize(dim);
- label.setMaximumSize(dim);
- return label;
- }
-
-
- public class ColorRange extends PApplet {
-
- static final int WIDE = 256;
- static final int HIGH = 256;
-
- int lastX, lastY;
-
-
- public void setup() {
- size(WIDE, HIGH, P3D);
- noLoop();
-
- colorMode(HSB, 360, 256, 256);
- noFill();
- rectMode(CENTER);
- }
-
- public void draw() {
- if ((g == null) || (g.pixels == null)) return;
- if ((width != WIDE) || (height < HIGH)) {
- //System.out.println("bad size " + width + " " + height);
- return;
- }
-
- int index = 0;
- for (int j = 0; j < 256; j++) {
- for (int i = 0; i < 256; i++) {
- g.pixels[index++] = color(hue, i, 255 - j);
- }
- }
-
- stroke((brightness > 50) ? 0 : 255);
- rect(lastX, lastY, 9, 9);
- }
-
- public void mousePressed() {
- updateMouse();
- }
-
- public void mouseDragged() {
- updateMouse();
- }
-
- public void updateMouse() {
- if ((mouseX >= 0) && (mouseX < 256) &&
- (mouseY >= 0) && (mouseY < 256)) {
- int nsaturation = (int) (100 * (mouseX / 255.0f));
- int nbrightness = 100 - ((int) (100 * (mouseY / 255.0f)));
- saturationField.setText(String.valueOf(nsaturation));
- brightnessField.setText(String.valueOf(nbrightness));
-
- lastX = mouseX;
- lastY = mouseY;
- }
- }
-
- public Dimension getPreferredSize() {
- return new Dimension(WIDE, HIGH);
- }
-
- public Dimension getMinimumSize() {
- return new Dimension(WIDE, HIGH);
- }
-
- public Dimension getMaximumSize() {
- return new Dimension(WIDE, HIGH);
- }
-
- public void keyPressed() {
- if (key == ESC) {
- ColorSelector.this.frame.setVisible(false);
- // don't quit out of processing
- // http://dev.processing.org/bugs/show_bug.cgi?id=1006
- key = 0;
- }
- }
- }
-
-
- public class ColorSlider extends PApplet {
-
- static final int WIDE = 20;
- static final int HIGH = 256;
-
- public void setup() {
- size(WIDE, HIGH, P3D);
- colorMode(HSB, 255, 100, 100);
- noLoop();
- }
-
- public void draw() {
- if ((g == null) || (g.pixels == null)) return;
- if ((width != WIDE) || (height < HIGH)) {
- //System.out.println("bad size " + width + " " + height);
- return;
- }
-
- int index = 0;
- int sel = 255 - (int) (255 * (hue / 359f));
- for (int j = 0; j < 256; j++) {
- int c = color(255 - j, 100, 100);
- if (j == sel) c = 0xFF000000;
- for (int i = 0; i < WIDE; i++) {
- g.pixels[index++] = c;
- }
- }
- }
-
- public void mousePressed() {
- updateMouse();
- }
-
- public void mouseDragged() {
- updateMouse();
- }
-
- public void updateMouse() {
- if ((mouseX >= 0) && (mouseX < 256) &&
- (mouseY >= 0) && (mouseY < 256)) {
- int nhue = 359 - (int) (359 * (mouseY / 255.0f));
- hueField.setText(String.valueOf(nhue));
- }
- }
-
- public Dimension getPreferredSize() {
- return new Dimension(WIDE, HIGH);
- }
-
- public Dimension getMinimumSize() {
- return new Dimension(WIDE, HIGH);
- }
-
- public Dimension getMaximumSize() {
- return new Dimension(WIDE, HIGH);
- }
-
- public void keyPressed() {
- if (key == ESC) {
- ColorSelector.this.frame.setVisible(false);
- // don't quit out of processing
- // http://dev.processing.org/bugs/show_bug.cgi?id=1006
- key = 0;
- }
- }
- }
-
-
- /**
- * Extension of JTextField that only allows numbers
- */
- class NumberField extends JTextField {
-
- public boolean allowHex;
-
- public NumberField(int cols, boolean allowHex) {
- super(cols);
- this.allowHex = allowHex;
- }
-
- protected Document createDefaultModel() {
- return new NumberDocument(this);
- }
-
- public Dimension getPreferredSize() {
- if (!allowHex) {
- return new Dimension(45, super.getPreferredSize().height);
- }
- return super.getPreferredSize();
- }
-
- public Dimension getMinimumSize() {
- return getPreferredSize();
- }
-
- public Dimension getMaximumSize() {
- return getPreferredSize();
- }
- }
-
-
- /**
- * Document model to go with JTextField that only allows numbers.
- */
- class NumberDocument extends PlainDocument {
-
- NumberField parentField;
-
- public NumberDocument(NumberField parentField) {
- this.parentField = parentField;
- //System.out.println("setting parent to " + parentSelector);
- }
-
- public void insertString(int offs, String str, AttributeSet a)
- throws BadLocationException {
-
- if (str == null) return;
-
- char chars[] = str.toCharArray();
- int charCount = 0;
- // remove any non-digit chars
- for (int i = 0; i < chars.length; i++) {
- boolean ok = Character.isDigit(chars[i]);
- if (parentField.allowHex) {
- if ((chars[i] >= 'A') && (chars[i] <= 'F')) ok = true;
- if ((chars[i] >= 'a') && (chars[i] <= 'f')) ok = true;
- }
- if (ok) {
- if (charCount != i) { // shift if necessary
- chars[charCount] = chars[i];
- }
- charCount++;
- }
- }
- super.insertString(offs, new String(chars, 0, charCount), a);
- // can't call any sort of methods on the enclosing class here
- // seems to have something to do with how Document objects are set up
- }
- }
-}
diff --git a/app/src/processing/app/tools/CreateFont.java b/app/src/processing/app/tools/CreateFont.java
deleted file mode 100644
index 62d2ce4c076..00000000000
--- a/app/src/processing/app/tools/CreateFont.java
+++ /dev/null
@@ -1,813 +0,0 @@
-/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
-
-/*
- Part of the Processing project - http://processing.org
-
- Copyright (c) 2004-10 Ben Fry and Casey Reas
- Copyright (c) 2001-04 Massachusetts Institute of Technology
-
- This program 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-package processing.app.tools;
-
-import processing.app.*;
-import processing.core.*;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.io.*;
-import java.util.*;
-
-import javax.swing.*;
-import javax.swing.border.*;
-import javax.swing.event.*;
-
-
-/**
- * GUI tool for font creation heaven/hell.
- */
-public class CreateFont extends JFrame implements Tool {
- Editor editor;
- //Sketch sketch;
-
- Dimension windowSize;
-
- JList fontSelector;
- JTextField sizeSelector;
- JButton charsetButton;
- JCheckBox smoothBox;
- JComponent sample;
- JButton okButton;
- JTextField filenameField;
-
- HashMap table;
- boolean smooth = true;
-
- Font font;
-
- String[] list;
- int selection = -1;
-
- CharacterSelector charSelector;
-
-
- public CreateFont() {
- super("Create Font");
- }
-
-
- public String getMenuTitle() {
- return "Create Font...";
- }
-
-
- public void init(Editor editor) {
- this.editor = editor;
-
- Container paine = getContentPane();
- paine.setLayout(new BorderLayout()); //10, 10));
-
- JPanel pain = new JPanel();
- pain.setBorder(new EmptyBorder(13, 13, 13, 13));
- paine.add(pain, BorderLayout.CENTER);
-
- pain.setLayout(new BoxLayout(pain, BoxLayout.Y_AXIS));
-
- String labelText =
- "Use this tool to create bitmap fonts for your program.\n" +
- "Select a font and size, and click 'OK' to generate the font.\n" +
- "It will be added to the data folder of the current sketch.";
-
- JTextArea textarea = new JTextArea(labelText);
- textarea.setBorder(new EmptyBorder(10, 10, 20, 10));
- textarea.setBackground(null);
- textarea.setEditable(false);
- textarea.setHighlighter(null);
- textarea.setFont(new Font("Dialog", Font.PLAIN, 12));
- pain.add(textarea);
-
- // don't care about families starting with . or #
- // also ignore dialog, dialoginput, monospaced, serif, sansserif
-
- // getFontList is deprecated in 1.4, so this has to be used
- GraphicsEnvironment ge =
- GraphicsEnvironment.getLocalGraphicsEnvironment();
-
- Font fonts[] = ge.getAllFonts();
-
- String flist[] = new String[fonts.length];
- table = new HashMap();
-
- int index = 0;
- for (int i = 0; i < fonts.length; i++) {
- //String psname = fonts[i].getPSName();
- //if (psname == null) System.err.println("ps name is null");
-
- flist[index++] = fonts[i].getPSName();
- table.put(fonts[i].getPSName(), fonts[i]);
- }
-
- list = new String[index];
- System.arraycopy(flist, 0, list, 0, index);
-
- fontSelector = new JList(list);
- fontSelector.addListSelectionListener(new ListSelectionListener() {
- public void valueChanged(ListSelectionEvent e) {
- if (e.getValueIsAdjusting() == false) {
- selection = fontSelector.getSelectedIndex();
- okButton.setEnabled(true);
- update();
- }
- }
- });
-
- fontSelector.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- fontSelector.setVisibleRowCount(12);
- JScrollPane fontScroller = new JScrollPane(fontSelector);
- pain.add(fontScroller);
-
- Dimension d1 = new Dimension(13, 13);
- pain.add(new Box.Filler(d1, d1, d1));
-
- sample = new SampleComponent(this);
-
- // Seems that in some instances, no default font is set
- // http://dev.processing.org/bugs/show_bug.cgi?id=777
- sample.setFont(new Font("Dialog", Font.PLAIN, 12));
-
- pain.add(sample);
-
- Dimension d2 = new Dimension(6, 6);
- pain.add(new Box.Filler(d2, d2, d2));
-
- JPanel panel = new JPanel();
- panel.add(new JLabel("Size:"));
- sizeSelector = new JTextField(" 48 ");
- sizeSelector.getDocument().addDocumentListener(new DocumentListener() {
- public void insertUpdate(DocumentEvent e) { update(); }
- public void removeUpdate(DocumentEvent e) { update(); }
- public void changedUpdate(DocumentEvent e) { }
- });
- panel.add(sizeSelector);
-
- smoothBox = new JCheckBox("Smooth");
- smoothBox.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- smooth = smoothBox.isSelected();
- update();
- }
- });
- smoothBox.setSelected(smooth);
- panel.add(smoothBox);
-
-// allBox = new JCheckBox("All Characters");
-// allBox.addActionListener(new ActionListener() {
-// public void actionPerformed(ActionEvent e) {
-// all = allBox.isSelected();
-// }
-// });
-// allBox.setSelected(all);
-// panel.add(allBox);
- charsetButton = new JButton("Characters...");
- charsetButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- //showCharacterList();
- charSelector.setVisible(true);
- }
- });
- panel.add(charsetButton);
-
- pain.add(panel);
-
- JPanel filestuff = new JPanel();
- filestuff.add(new JLabel("Filename:"));
- filestuff.add(filenameField = new JTextField(20));
- filestuff.add(new JLabel(".vlw"));
- pain.add(filestuff);
-
- JPanel buttons = new JPanel();
- JButton cancelButton = new JButton("Cancel");
- cancelButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- setVisible(false);
- }
- });
- okButton = new JButton("OK");
- okButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- build();
- }
- });
- okButton.setEnabled(false);
-
- buttons.add(cancelButton);
- buttons.add(okButton);
- pain.add(buttons);
-
- JRootPane root = getRootPane();
- root.setDefaultButton(okButton);
- ActionListener disposer = new ActionListener() {
- public void actionPerformed(ActionEvent actionEvent) {
- setVisible(false);
- }
- };
- Base.registerWindowCloseKeys(root, disposer);
- Base.setIcon(this);
-
- setResizable(false);
- pack();
-
- // do this after pack so it doesn't affect layout
- sample.setFont(new Font(list[0], Font.PLAIN, 48));
-
- fontSelector.setSelectedIndex(0);
-
- Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
- windowSize = getSize();
-
- setLocation((screen.width - windowSize.width) / 2,
- (screen.height - windowSize.height) / 2);
-
- // create this behind the scenes
- charSelector = new CharacterSelector();
- }
-
-
- public void run() {
- setVisible(true);
- }
-
-
- public void update() {
- int fontsize = 0;
- try {
- fontsize = Integer.parseInt(sizeSelector.getText().trim());
- //System.out.println("'" + sizeSelector.getText() + "'");
- } catch (NumberFormatException e2) { }
-
- // if a deselect occurred, selection will be -1
- if ((fontsize > 0) && (fontsize < 256) && (selection != -1)) {
- //font = new Font(list[selection], Font.PLAIN, fontsize);
- Font instance = (Font) table.get(list[selection]);
- font = instance.deriveFont(Font.PLAIN, fontsize);
- //System.out.println("setting font to " + font);
- sample.setFont(font);
-
- String filenameSuggestion = list[selection].replace(' ', '_');
- filenameSuggestion += "-" + fontsize;
- filenameField.setText(filenameSuggestion);
- }
- }
-
-
- public void build() {
- int fontsize = 0;
- try {
- fontsize = Integer.parseInt(sizeSelector.getText().trim());
- } catch (NumberFormatException e) { }
-
- if (fontsize <= 0) {
- JOptionPane.showMessageDialog(this, "Bad font size, try again.",
- "Badness", JOptionPane.WARNING_MESSAGE);
- return;
- }
-
- String filename = filenameField.getText().trim();
- if (filename.length() == 0) {
- JOptionPane.showMessageDialog(this, "Enter a file name for the font.",
- "Lameness", JOptionPane.WARNING_MESSAGE);
- return;
- }
- if (!filename.endsWith(".vlw")) {
- filename += ".vlw";
- }
-
- // Please implement me properly. The schematic is below, but not debugged.
- // http://dev.processing.org/bugs/show_bug.cgi?id=1464
-
-// final String filename2 = filename;
-// final int fontsize2 = fontsize;
-// SwingUtilities.invokeLater(new Runnable() {
-// public void run() {
- try {
- Font instance = (Font) table.get(list[selection]);
- font = instance.deriveFont(Font.PLAIN, fontsize);
- //PFont f = new PFont(font, smooth, all ? null : PFont.CHARSET);
- PFont f = new PFont(font, smooth, charSelector.getCharacters());
-
-// PFont f = new PFont(font, smooth, null);
-// char[] charset = charSelector.getCharacters();
-// ProgressMonitor progressMonitor = new ProgressMonitor(CreateFont.this,
-// "Creating font", "", 0, charset.length);
-// progressMonitor.setProgress(0);
-// for (int i = 0; i < charset.length; i++) {
-// System.out.println(charset[i]);
-// f.index(charset[i]); // load this char
-// progressMonitor.setProgress(i+1);
-// }
-
- // make sure the 'data' folder exists
- File folder = editor.getSketch().prepareDataFolder();
- f.save(new FileOutputStream(new File(folder, filename)));
-
- } catch (IOException e) {
- JOptionPane.showMessageDialog(CreateFont.this,
- "An error occurred while creating font.",
- "No font for you",
- JOptionPane.WARNING_MESSAGE);
- e.printStackTrace();
- }
-// }
-// });
-
- setVisible(false);
- }
-
-
- /**
- * make the window vertically resizable
- */
- public Dimension getMaximumSize() {
- return new Dimension(windowSize.width, 2000);
-}
-
-
- public Dimension getMinimumSize() {
- return windowSize;
- }
-
-
- /*
- public void show(File targetFolder) {
- this.targetFolder = targetFolder;
- show();
- }
- */
-}
-
-
-/**
- * Component that draws the sample text. This is its own subclassed component
- * because Mac OS X controls seem to reset the RenderingHints for smoothing
- * so that they cannot be overridden properly for JLabel or JTextArea.
- * @author fry
- */
-class SampleComponent extends JComponent {
- // see http://rinkworks.com/words/pangrams.shtml
- String text =
- "Forsaking monastic tradition, twelve jovial friars gave up their " +
- "vocation for a questionable existence on the flying trapeze.";
- int high = 80;
-
- CreateFont parent;
-
- public SampleComponent(CreateFont p) {
- this.parent = p;
-
- // and yet, we still need an inner class to handle the basics.
- // or no, maybe i'll refactor this as a separate class!
- // maybe a few getters and setters? mmm?
- addMouseListener(new MouseAdapter() {
- public void mousePressed(MouseEvent e) {
- String input =
- (String) JOptionPane.showInputDialog(parent,
- "Enter new sample text:",
- "Sample Text",
- JOptionPane.PLAIN_MESSAGE,
- null, // icon
- null, // choices
- text);
- if (input != null) {
- text = input;
- parent.repaint();
- }
- }
- });
- }
-
- public void paintComponent(Graphics g) {
-// System.out.println("smoothing set to " + smooth);
- Graphics2D g2 = (Graphics2D) g;
- g2.setColor(Color.WHITE);
- Dimension dim = getSize();
- g2.fillRect(0, 0, dim.width, dim.height);
- g2.setColor(Color.BLACK);
-
- g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
- parent.smooth ?
- RenderingHints.VALUE_TEXT_ANTIALIAS_ON :
- RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
- // add this one as well (after 1.0.9)
- g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- parent.smooth ?
- RenderingHints.VALUE_ANTIALIAS_ON :
- RenderingHints.VALUE_ANTIALIAS_OFF);
- //super.paintComponent(g2);
- Font font = getFont();
- int ascent = g2.getFontMetrics().getAscent();
-// System.out.println(f.getName());
- g2.setFont(font);
- g2.drawString(text, 5, dim.height - (dim.height - ascent) / 2);
- }
-
- public Dimension getPreferredSize() {
- return new Dimension(400, high);
- }
-
- public Dimension getMaximumSize() {
- return new Dimension(10000, high);
- }
-
- public Dimension getMinimumSize() {
- return new Dimension(100, high);
- }
-}
-
-
-/**
- * Frame for selecting which characters will be included with the font.
- */
-class CharacterSelector extends JFrame {
- JRadioButton defaultCharsButton;
- JRadioButton allCharsButton;
- JRadioButton unicodeCharsButton;
- JScrollPane unicodeBlockScroller;
- JList charsetList;
-
-
- public CharacterSelector() {
- super("Character Selector");
-
- charsetList = new CheckBoxList();
- DefaultListModel model = new DefaultListModel();
- charsetList.setModel(model);
- for (String item : blockNames) {
- model.addElement(new JCheckBox(item));
- }
-
- unicodeBlockScroller =
- new JScrollPane(charsetList,
- ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
- ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
-
- Container outer = getContentPane();
- outer.setLayout(new BorderLayout());
-
- JPanel pain = new JPanel();
- pain.setBorder(new EmptyBorder(13, 13, 13, 13));
- outer.add(pain, BorderLayout.CENTER);
-
- pain.setLayout(new BoxLayout(pain, BoxLayout.Y_AXIS));
-
- String labelText =
- "Default characters will include most bitmaps for Mac OS\n" +
- "and Windows Latin scripts. Including all characters may\n" +
- "require large amounts of memory for all of the bitmaps.\n" +
- "For greater control, you can select specific Unicode blocks.";
- JTextArea textarea = new JTextArea(labelText);
- textarea.setBorder(new EmptyBorder(13, 8, 13, 8));
- textarea.setBackground(null);
- textarea.setEditable(false);
- textarea.setHighlighter(null);
- textarea.setFont(new Font("Dialog", Font.PLAIN, 12));
- pain.add(textarea);
-
- ActionListener listener = new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- //System.out.println("action " + unicodeCharsButton.isSelected());
- //unicodeBlockScroller.setEnabled(unicodeCharsButton.isSelected());
- charsetList.setEnabled(unicodeCharsButton.isSelected());
- }
- };
- defaultCharsButton = new JRadioButton("Default Characters");
- allCharsButton = new JRadioButton("All Characters");
- unicodeCharsButton = new JRadioButton("Specific Unicode Blocks");
-
- defaultCharsButton.addActionListener(listener);
- allCharsButton.addActionListener(listener);
- unicodeCharsButton.addActionListener(listener);
-
- ButtonGroup group = new ButtonGroup();
- group.add(defaultCharsButton);
- group.add(allCharsButton);
- group.add(unicodeCharsButton);
-
- JPanel radioPanel = new JPanel();
- //radioPanel.setBackground(Color.red);
- radioPanel.setLayout(new BoxLayout(radioPanel, BoxLayout.Y_AXIS));
- radioPanel.add(defaultCharsButton);
- radioPanel.add(allCharsButton);
- radioPanel.add(unicodeCharsButton);
-
- JPanel rightStuff = new JPanel();
- rightStuff.setLayout(new BoxLayout(rightStuff, BoxLayout.X_AXIS));
- rightStuff.add(radioPanel);
- rightStuff.add(Box.createHorizontalGlue());
- pain.add(rightStuff);
- pain.add(Box.createVerticalStrut(13));
-
-// pain.add(radioPanel);
-
-// pain.add(defaultCharsButton);
-// pain.add(allCharsButton);
-// pain.add(unicodeCharsButton);
-
- defaultCharsButton.setSelected(true);
- charsetList.setEnabled(false);
-
- //frame.getContentPane().add(scroller);
- pain.add(unicodeBlockScroller);
- pain.add(Box.createVerticalStrut(8));
-
- JPanel buttons = new JPanel();
- JButton okButton = new JButton("OK");
- okButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- setVisible(false);
- }
- });
- okButton.setEnabled(true);
- buttons.add(okButton);
- pain.add(buttons);
-
- JRootPane root = getRootPane();
- root.setDefaultButton(okButton);
- ActionListener disposer = new ActionListener() {
- public void actionPerformed(ActionEvent actionEvent) {
- setVisible(false);
- }
- };
- Base.registerWindowCloseKeys(root, disposer);
- Base.setIcon(this);
-
- pack();
-
- Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
- Dimension windowSize = getSize();
-
- setLocation((screen.width - windowSize.width) / 2,
- (screen.height - windowSize.height) / 2);
- }
-
-
- protected char[] getCharacters() {
- if (defaultCharsButton.isSelected()) {
- return PFont.CHARSET;
- }
-
- char[] charset = new char[65536];
- if (allCharsButton.isSelected()) {
- for (int i = 0; i < 0xFFFF; i++) {
- charset[i] = (char) i;
- }
- } else {
- DefaultListModel model = (DefaultListModel) charsetList.getModel();
- int index = 0;
- for (int i = 0; i < BLOCKS.length; i++) {
- if (((JCheckBox) model.get(i)).isSelected()) {
- for (int j = blockStart[i]; j <= blockStop[i]; j++) {
- charset[index++] = (char) j;
- }
- }
- }
- charset = PApplet.subset(charset, 0, index);
- }
- //System.out.println("Creating font with " + charset.length + " characters.");
- return charset;
- }
-
-
- // http://www.unicode.org/Public/UNIDATA/Blocks.txt
- static final String[] BLOCKS = {
- "0000..007F; Basic Latin",
- "0080..00FF; Latin-1 Supplement",
- "0100..017F; Latin Extended-A",
- "0180..024F; Latin Extended-B",
- "0250..02AF; IPA Extensions",
- "02B0..02FF; Spacing Modifier Letters",
- "0300..036F; Combining Diacritical Marks",
- "0370..03FF; Greek and Coptic",
- "0400..04FF; Cyrillic",
- "0500..052F; Cyrillic Supplement",
- "0530..058F; Armenian",
- "0590..05FF; Hebrew",
- "0600..06FF; Arabic",
- "0700..074F; Syriac",
- "0750..077F; Arabic Supplement",
- "0780..07BF; Thaana",
- "07C0..07FF; NKo",
- "0800..083F; Samaritan",
- "0900..097F; Devanagari",
- "0980..09FF; Bengali",
- "0A00..0A7F; Gurmukhi",
- "0A80..0AFF; Gujarati",
- "0B00..0B7F; Oriya",
- "0B80..0BFF; Tamil",
- "0C00..0C7F; Telugu",
- "0C80..0CFF; Kannada",
- "0D00..0D7F; Malayalam",
- "0D80..0DFF; Sinhala",
- "0E00..0E7F; Thai",
- "0E80..0EFF; Lao",
- "0F00..0FFF; Tibetan",
- "1000..109F; Myanmar",
- "10A0..10FF; Georgian",
- "1100..11FF; Hangul Jamo",
- "1200..137F; Ethiopic",
- "1380..139F; Ethiopic Supplement",
- "13A0..13FF; Cherokee",
- "1400..167F; Unified Canadian Aboriginal Syllabics",
- "1680..169F; Ogham",
- "16A0..16FF; Runic",
- "1700..171F; Tagalog",
- "1720..173F; Hanunoo",
- "1740..175F; Buhid",
- "1760..177F; Tagbanwa",
- "1780..17FF; Khmer",
- "1800..18AF; Mongolian",
- "18B0..18FF; Unified Canadian Aboriginal Syllabics Extended",
- "1900..194F; Limbu",
- "1950..197F; Tai Le",
- "1980..19DF; New Tai Lue",
- "19E0..19FF; Khmer Symbols",
- "1A00..1A1F; Buginese",
- "1A20..1AAF; Tai Tham",
- "1B00..1B7F; Balinese",
- "1B80..1BBF; Sundanese",
- "1C00..1C4F; Lepcha",
- "1C50..1C7F; Ol Chiki",
- "1CD0..1CFF; Vedic Extensions",
- "1D00..1D7F; Phonetic Extensions",
- "1D80..1DBF; Phonetic Extensions Supplement",
- "1DC0..1DFF; Combining Diacritical Marks Supplement",
- "1E00..1EFF; Latin Extended Additional",
- "1F00..1FFF; Greek Extended",
- "2000..206F; General Punctuation",
- "2070..209F; Superscripts and Subscripts",
- "20A0..20CF; Currency Symbols",
- "20D0..20FF; Combining Diacritical Marks for Symbols",
- "2100..214F; Letterlike Symbols",
- "2150..218F; Number Forms",
- "2190..21FF; Arrows",
- "2200..22FF; Mathematical Operators",
- "2300..23FF; Miscellaneous Technical",
- "2400..243F; Control Pictures",
- "2440..245F; Optical Character Recognition",
- "2460..24FF; Enclosed Alphanumerics",
- "2500..257F; Box Drawing",
- "2580..259F; Block Elements",
- "25A0..25FF; Geometric Shapes",
- "2600..26FF; Miscellaneous Symbols",
- "2700..27BF; Dingbats",
- "27C0..27EF; Miscellaneous Mathematical Symbols-A",
- "27F0..27FF; Supplemental Arrows-A",
- "2800..28FF; Braille Patterns",
- "2900..297F; Supplemental Arrows-B",
- "2980..29FF; Miscellaneous Mathematical Symbols-B",
- "2A00..2AFF; Supplemental Mathematical Operators",
- "2B00..2BFF; Miscellaneous Symbols and Arrows",
- "2C00..2C5F; Glagolitic",
- "2C60..2C7F; Latin Extended-C",
- "2C80..2CFF; Coptic",
- "2D00..2D2F; Georgian Supplement",
- "2D30..2D7F; Tifinagh",
- "2D80..2DDF; Ethiopic Extended",
- "2DE0..2DFF; Cyrillic Extended-A",
- "2E00..2E7F; Supplemental Punctuation",
- "2E80..2EFF; CJK Radicals Supplement",
- "2F00..2FDF; Kangxi Radicals",
- "2FF0..2FFF; Ideographic Description Characters",
- "3000..303F; CJK Symbols and Punctuation",
- "3040..309F; Hiragana",
- "30A0..30FF; Katakana",
- "3100..312F; Bopomofo",
- "3130..318F; Hangul Compatibility Jamo",
- "3190..319F; Kanbun",
- "31A0..31BF; Bopomofo Extended",
- "31C0..31EF; CJK Strokes",
- "31F0..31FF; Katakana Phonetic Extensions",
- "3200..32FF; Enclosed CJK Letters and Months",
- "3300..33FF; CJK Compatibility",
- "3400..4DBF; CJK Unified Ideographs Extension A",
- "4DC0..4DFF; Yijing Hexagram Symbols",
- "4E00..9FFF; CJK Unified Ideographs",
- "A000..A48F; Yi Syllables",
- "A490..A4CF; Yi Radicals",
- "A4D0..A4FF; Lisu",
- "A500..A63F; Vai",
- "A640..A69F; Cyrillic Extended-B",
- "A6A0..A6FF; Bamum",
- "A700..A71F; Modifier Tone Letters",
- "A720..A7FF; Latin Extended-D",
- "A800..A82F; Syloti Nagri",
- "A830..A83F; Common Indic Number Forms",
- "A840..A87F; Phags-pa",
- "A880..A8DF; Saurashtra",
- "A8E0..A8FF; Devanagari Extended",
- "A900..A92F; Kayah Li",
- "A930..A95F; Rejang",
- "A960..A97F; Hangul Jamo Extended-A",
- "A980..A9DF; Javanese",
- "AA00..AA5F; Cham",
- "AA60..AA7F; Myanmar Extended-A",
- "AA80..AADF; Tai Viet",
- "ABC0..ABFF; Meetei Mayek",
- "AC00..D7AF; Hangul Syllables",
- "D7B0..D7FF; Hangul Jamo Extended-B",
- "D800..DB7F; High Surrogates",
- "DB80..DBFF; High Private Use Surrogates",
- "DC00..DFFF; Low Surrogates",
- "E000..F8FF; Private Use Area",
- "F900..FAFF; CJK Compatibility Ideographs",
- "FB00..FB4F; Alphabetic Presentation Forms",
- "FB50..FDFF; Arabic Presentation Forms-A",
- "FE00..FE0F; Variation Selectors",
- "FE10..FE1F; Vertical Forms",
- "FE20..FE2F; Combining Half Marks",
- "FE30..FE4F; CJK Compatibility Forms",
- "FE50..FE6F; Small Form Variants",
- "FE70..FEFF; Arabic Presentation Forms-B",
- "FF00..FFEF; Halfwidth and Fullwidth Forms",
- "FFF0..FFFF; Specials"
- };
-
- static String[] blockNames;
- static int[] blockStart;
- static int[] blockStop;
- static {
- int count = BLOCKS.length;
- blockNames = new String[count];
- blockStart = new int[count];
- blockStop = new int[count];
- for (int i = 0; i < count; i++) {
- String line = BLOCKS[i];
- blockStart[i] = PApplet.unhex(line.substring(0, 4));
- blockStop[i] = PApplet.unhex(line.substring(6, 10));
- blockNames[i] = line.substring(12);
- }
-// PApplet.println(codePointStop);
-// PApplet.println(codePoints);
- }
-}
-
-
-// Code for this CheckBoxList class found on the net, though I've lost the
-// link. If you run across the original version, please let me know so that
-// the original author can be credited properly. It was from a snippet
-// collection, but it seems to have been picked up so many places with others
-// placing their copyright on it, that I haven't been able to determine the
-// original author. [fry 20100216]
-class CheckBoxList extends JList {
- protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);
-
- public CheckBoxList() {
- setCellRenderer(new CellRenderer());
-
- addMouseListener(new MouseAdapter() {
- public void mousePressed(MouseEvent e) {
- if (isEnabled()) {
- int index = locationToIndex(e.getPoint());
-
- if (index != -1) {
- JCheckBox checkbox = (JCheckBox)
- getModel().getElementAt(index);
- checkbox.setSelected(!checkbox.isSelected());
- repaint();
- }
- }
- }
- });
- setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- }
-
-
- protected class CellRenderer implements ListCellRenderer {
- public Component getListCellRendererComponent(JList list, Object value,
- int index, boolean isSelected,
- boolean cellHasFocus) {
- JCheckBox checkbox = (JCheckBox) value;
- checkbox.setBackground(isSelected ? getSelectionBackground() : getBackground());
- checkbox.setForeground(isSelected ? getSelectionForeground() : getForeground());
- //checkbox.setEnabled(isEnabled());
- checkbox.setEnabled(list.isEnabled());
- checkbox.setFont(getFont());
- checkbox.setFocusPainted(false);
- checkbox.setBorderPainted(true);
- checkbox.setBorder(isSelected ? UIManager.getBorder("List.focusCellHighlightBorder") : noFocusBorder);
- return checkbox;
- }
- }
-}
\ No newline at end of file
diff --git a/app/src/processing/app/tools/DiscourseFormat.java b/app/src/processing/app/tools/DiscourseFormat.java
index ab5ef22fc89..a4a381c5a22 100644
--- a/app/src/processing/app/tools/DiscourseFormat.java
+++ b/app/src/processing/app/tools/DiscourseFormat.java
@@ -29,7 +29,7 @@
import processing.app.*;
import processing.app.syntax.*;
-import processing.core.PApplet;
+import processing.app.legacy.PApplet;
/**
* Format for Discourse Tool
diff --git a/app/test/processing/app/AbstractGUITest.java b/app/test/processing/app/AbstractGUITest.java
index b43ec010c78..b5a209bb051 100644
--- a/app/test/processing/app/AbstractGUITest.java
+++ b/app/test/processing/app/AbstractGUITest.java
@@ -21,7 +21,7 @@ public void startUpTheIDE() throws Exception {
Preferences.init(null);
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
Theme.init();
- Base.platform.setLookAndFeel();
+ Base.getPlatform().setLookAndFeel();
Base.untitledFolder = Base.createTempFolder("untitled");
Base.untitledFolder.deleteOnExit();
diff --git a/app/test/processing/app/I18NTest.java b/app/test/processing/app/I18NTest.java
index 150cefe5551..74c231ef7f5 100644
--- a/app/test/processing/app/I18NTest.java
+++ b/app/test/processing/app/I18NTest.java
@@ -1,5 +1,6 @@
package processing.app;
+import org.junit.Ignore;
import org.junit.Test;
import java.io.*;
@@ -40,7 +41,12 @@ private Properties loadProperties(File file) throws IOException {
return properties;
}
+ // XXX: I18NTest.class.getResource(".").getFile() no longer works, because
+ // the class is now into the arudino-core package. This test should be refactored
+ // in order to use ResourceBundles to load translations to be checked.
+
@Test
+ @Ignore
public void ensureEveryTranslationIsComplete() throws Exception {
Set keys = loadReferenceI18NKeys();
diff --git a/app/test/processing/app/debug/UploaderFactoryTest.java b/app/test/processing/app/debug/UploaderFactoryTest.java
index a785f835e24..5365f97bc95 100644
--- a/app/test/processing/app/debug/UploaderFactoryTest.java
+++ b/app/test/processing/app/debug/UploaderFactoryTest.java
@@ -2,7 +2,7 @@
import cc.arduino.packages.BoardPort;
import cc.arduino.packages.Uploader;
-import cc.arduino.packages.UploaderAndMonitorFactory;
+import cc.arduino.packages.UploaderFactory;
import cc.arduino.packages.uploaders.SSHUploader;
import cc.arduino.packages.uploaders.SerialUploader;
import org.junit.Before;
@@ -29,7 +29,7 @@ public void shouldCreateAnInstanceOfSSHUploader() throws Exception {
boardPort.setBoardName("yun");
boardPort.setAddress("192.168.0.1");
boardPort.setProtocol("network");
- Uploader uploader = new UploaderAndMonitorFactory().newUploader(board, boardPort);
+ Uploader uploader = new UploaderFactory().newUploader(board, boardPort, false);
assertTrue(uploader instanceof SSHUploader);
}
@@ -41,7 +41,7 @@ public void shouldCreateAnInstanceOfBasicUploaderWhenSSHIsUnsupported() throws E
boardPort.setBoardName("myyun");
boardPort.setAddress("192.168.0.1");
boardPort.setProtocol("network");
- Uploader uploader = new UploaderAndMonitorFactory().newUploader(board, boardPort);
+ Uploader uploader = new UploaderFactory().newUploader(board, boardPort, false);
assertTrue(uploader instanceof SerialUploader);
}
@@ -53,7 +53,7 @@ public void shouldCreateAnInstanceOfBasicUploaderWhenPortIsSerial() throws Excep
boardPort.setBoardName("Arduino Leonardo");
boardPort.setAddress("/dev/ttyACM0");
boardPort.setProtocol("serial");
- Uploader uploader = new UploaderAndMonitorFactory().newUploader(board, boardPort);
+ Uploader uploader = new UploaderFactory().newUploader(board, boardPort, false);
assertTrue(uploader instanceof SerialUploader);
}
diff --git a/arduino-builder/.classpath b/arduino-builder/.classpath
new file mode 100644
index 00000000000..3e1f72898d0
--- /dev/null
+++ b/arduino-builder/.classpath
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/core/.project b/arduino-builder/.project
similarity index 91%
rename from core/.project
rename to arduino-builder/.project
index e791e6fcde9..1e4da7c5f2b 100644
--- a/core/.project
+++ b/arduino-builder/.project
@@ -1,6 +1,6 @@
- processing-core
+ arduino-builder
diff --git a/arduino-builder/.settings/org.eclipse.jdt.core.prefs b/arduino-builder/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..8000cd6ca61
--- /dev/null
+++ b/arduino-builder/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/arduino-builder/bin/cc/arduino/builder/ArduinoBuilder.class b/arduino-builder/bin/cc/arduino/builder/ArduinoBuilder.class
new file mode 100644
index 00000000000..c7047297442
Binary files /dev/null and b/arduino-builder/bin/cc/arduino/builder/ArduinoBuilder.class differ
diff --git a/arduino-builder/src/cc/arduino/builder/ArduinoBuilder.java b/arduino-builder/src/cc/arduino/builder/ArduinoBuilder.java
new file mode 100644
index 00000000000..89b28fe3f2f
--- /dev/null
+++ b/arduino-builder/src/cc/arduino/builder/ArduinoBuilder.java
@@ -0,0 +1,11 @@
+package cc.arduino.builder;
+
+import processing.app.BaseNoGui;
+
+public class ArduinoBuilder {
+
+ public static void main(String[] args) throws Exception {
+ BaseNoGui.main(args);
+ }
+
+}
diff --git a/arduino-core/.classpath b/arduino-core/.classpath
new file mode 100644
index 00000000000..bf61b582622
--- /dev/null
+++ b/arduino-core/.classpath
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/arduino-core/.gitignore b/arduino-core/.gitignore
new file mode 100644
index 00000000000..ae3c1726048
--- /dev/null
+++ b/arduino-core/.gitignore
@@ -0,0 +1 @@
+/bin/
diff --git a/core/preproc/.project b/arduino-core/.project
similarity index 92%
rename from core/preproc/.project
rename to arduino-core/.project
index 629f1c16a34..f57b4cc1395 100644
--- a/core/preproc/.project
+++ b/arduino-core/.project
@@ -1,6 +1,6 @@
- preproc
+ arduino-core
diff --git a/arduino-core/build.xml b/arduino-core/build.xml
new file mode 100644
index 00000000000..db709c3f876
--- /dev/null
+++ b/arduino-core/build.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/arduino-core/lib/apple.LICENSE.BSD-like.txt b/arduino-core/lib/apple.LICENSE.BSD-like.txt
new file mode 100644
index 00000000000..94776cf3fc6
--- /dev/null
+++ b/arduino-core/lib/apple.LICENSE.BSD-like.txt
@@ -0,0 +1 @@
+http://developer.apple.com/library/mac/#/legacy/library/samplecode/AppleJavaExtensions/Listings/README_txt.html#//apple_ref/doc/uid/DTS10000677-README_txt-DontLinkElementID_3
diff --git a/arduino-core/lib/apple.jar b/arduino-core/lib/apple.jar
new file mode 100644
index 00000000000..160d62b669d
Binary files /dev/null and b/arduino-core/lib/apple.jar differ
diff --git a/arduino-core/lib/commons-exec-1.1.jar b/arduino-core/lib/commons-exec-1.1.jar
new file mode 100644
index 00000000000..baee06ff33f
Binary files /dev/null and b/arduino-core/lib/commons-exec-1.1.jar differ
diff --git a/arduino-core/lib/commons-exec.LICENSE.ASL-2.0.txt b/arduino-core/lib/commons-exec.LICENSE.ASL-2.0.txt
new file mode 100644
index 00000000000..d6456956733
--- /dev/null
+++ b/arduino-core/lib/commons-exec.LICENSE.ASL-2.0.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/arduino-core/lib/commons-logging-1.0.4.jar b/arduino-core/lib/commons-logging-1.0.4.jar
new file mode 100644
index 00000000000..b73a80fab64
Binary files /dev/null and b/arduino-core/lib/commons-logging-1.0.4.jar differ
diff --git a/arduino-core/lib/commons-logging.LICENSE.ASL-2.0.txt b/arduino-core/lib/commons-logging.LICENSE.ASL-2.0.txt
new file mode 100644
index 00000000000..d6456956733
--- /dev/null
+++ b/arduino-core/lib/commons-logging.LICENSE.ASL-2.0.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/arduino-core/lib/jmdns-3.4.1.jar b/arduino-core/lib/jmdns-3.4.1.jar
new file mode 100644
index 00000000000..4fcd002b4b5
Binary files /dev/null and b/arduino-core/lib/jmdns-3.4.1.jar differ
diff --git a/arduino-core/lib/jmdns.LICENSE.ASL-2.0-LGPL-2.1.txt b/arduino-core/lib/jmdns.LICENSE.ASL-2.0-LGPL-2.1.txt
new file mode 100644
index 00000000000..e2ada04556a
--- /dev/null
+++ b/arduino-core/lib/jmdns.LICENSE.ASL-2.0-LGPL-2.1.txt
@@ -0,0 +1,2 @@
+https://jmdns.svn.sourceforge.net/svnroot/jmdns/tags/jmdns-3.4.1/LICENSE-LGPL.txt
+https://jmdns.svn.sourceforge.net/svnroot/jmdns/tags/jmdns-3.4.1/LICENSE
diff --git a/arduino-core/lib/jna.LICENSE.LGPL-2.1.txt b/arduino-core/lib/jna.LICENSE.LGPL-2.1.txt
new file mode 100644
index 00000000000..006e9f09015
--- /dev/null
+++ b/arduino-core/lib/jna.LICENSE.LGPL-2.1.txt
@@ -0,0 +1 @@
+https://github.com/twall/jna/blob/master/LICENSE
diff --git a/arduino-core/lib/jna.jar b/arduino-core/lib/jna.jar
new file mode 100644
index 00000000000..5c669aff615
Binary files /dev/null and b/arduino-core/lib/jna.jar differ
diff --git a/arduino-core/lib/jsch-0.1.50.jar b/arduino-core/lib/jsch-0.1.50.jar
new file mode 100644
index 00000000000..33bbd370c56
Binary files /dev/null and b/arduino-core/lib/jsch-0.1.50.jar differ
diff --git a/arduino-core/lib/jsch.LICENSE.BSD.txt b/arduino-core/lib/jsch.LICENSE.BSD.txt
new file mode 100644
index 00000000000..66a089aa200
--- /dev/null
+++ b/arduino-core/lib/jsch.LICENSE.BSD.txt
@@ -0,0 +1 @@
+http://www.jcraft.com/jsch/LICENSE.txt
diff --git a/arduino-core/lib/jssc-2.8.0.jar b/arduino-core/lib/jssc-2.8.0.jar
new file mode 100644
index 00000000000..d2b5c070aa9
Binary files /dev/null and b/arduino-core/lib/jssc-2.8.0.jar differ
diff --git a/arduino-core/lib/jssc.LICENSE.GPL.txt b/arduino-core/lib/jssc.LICENSE.GPL.txt
new file mode 100644
index 00000000000..94a9ed024d3
--- /dev/null
+++ b/arduino-core/lib/jssc.LICENSE.GPL.txt
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program 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 3 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, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ Copyright (C)
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
diff --git a/arduino-core/lib/jssc.LICENSE.LGPL.txt b/arduino-core/lib/jssc.LICENSE.LGPL.txt
new file mode 100644
index 00000000000..65c5ca88a67
--- /dev/null
+++ b/arduino-core/lib/jssc.LICENSE.LGPL.txt
@@ -0,0 +1,165 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/app/src/cc/arduino/packages/BoardPort.java b/arduino-core/src/cc/arduino/packages/BoardPort.java
similarity index 100%
rename from app/src/cc/arduino/packages/BoardPort.java
rename to arduino-core/src/cc/arduino/packages/BoardPort.java
diff --git a/app/src/cc/arduino/packages/Discovery.java b/arduino-core/src/cc/arduino/packages/Discovery.java
similarity index 100%
rename from app/src/cc/arduino/packages/Discovery.java
rename to arduino-core/src/cc/arduino/packages/Discovery.java
diff --git a/app/src/cc/arduino/packages/DiscoveryManager.java b/arduino-core/src/cc/arduino/packages/DiscoveryManager.java
similarity index 100%
rename from app/src/cc/arduino/packages/DiscoveryManager.java
rename to arduino-core/src/cc/arduino/packages/DiscoveryManager.java
diff --git a/app/src/cc/arduino/packages/Uploader.java b/arduino-core/src/cc/arduino/packages/Uploader.java
similarity index 93%
rename from app/src/cc/arduino/packages/Uploader.java
rename to arduino-core/src/cc/arduino/packages/Uploader.java
index 012a1841890..8d91b6614d0 100644
--- a/app/src/cc/arduino/packages/Uploader.java
+++ b/arduino-core/src/cc/arduino/packages/Uploader.java
@@ -25,7 +25,7 @@
package cc.arduino.packages;
import processing.app.I18n;
-import processing.app.Preferences;
+import processing.app.PreferencesData;
import processing.app.debug.MessageConsumer;
import processing.app.debug.MessageSiphon;
import processing.app.debug.RunnerException;
@@ -64,11 +64,22 @@ public abstract class Uploader implements MessageConsumer {
private String error;
protected boolean notFoundError;
+ protected boolean noUploadPort;
protected Uploader() {
+ this.verbose = PreferencesData.getBoolean("upload.verbose");
+ init(false);
+ }
+
+ protected Uploader(boolean nup) {
+ this.verbose = PreferencesData.getBoolean("upload.verbose");
+ init(nup);
+ }
+
+ private void init(boolean nup) {
this.error = null;
- this.verbose = Preferences.getBoolean("upload.verbose");
this.notFoundError = false;
+ this.noUploadPort = nup;
}
public abstract boolean uploadUsingPreferences(File sourcePath, String buildPath, String className, boolean usingProgrammer, List warningsAccumulator) throws Exception;
diff --git a/app/src/cc/arduino/packages/UploaderAndMonitorFactory.java b/arduino-core/src/cc/arduino/packages/UploaderFactory.java
similarity index 79%
rename from app/src/cc/arduino/packages/UploaderAndMonitorFactory.java
rename to arduino-core/src/cc/arduino/packages/UploaderFactory.java
index ba6e9d54e10..8cfe44d9ee1 100644
--- a/app/src/cc/arduino/packages/UploaderAndMonitorFactory.java
+++ b/arduino-core/src/cc/arduino/packages/UploaderFactory.java
@@ -31,15 +31,14 @@
import cc.arduino.packages.uploaders.SSHUploader;
import cc.arduino.packages.uploaders.SerialUploader;
-import processing.app.AbstractMonitor;
-import processing.app.Base;
-import processing.app.NetworkMonitor;
-import processing.app.SerialMonitor;
import processing.app.debug.TargetBoard;
-public class UploaderAndMonitorFactory {
+public class UploaderFactory {
+
+ public Uploader newUploader(TargetBoard board, BoardPort port, boolean noUploadPort) {
+ if (noUploadPort)
+ return new SerialUploader(noUploadPort);
- public Uploader newUploader(TargetBoard board, BoardPort port) {
if ("true".equals(board.getPreferences().get("upload.via_ssh")) && port != null && "network".equals(port.getProtocol())) {
return new SSHUploader(port);
}
@@ -47,12 +46,4 @@ public Uploader newUploader(TargetBoard board, BoardPort port) {
return new SerialUploader();
}
- public AbstractMonitor newMonitor(BoardPort port, Base base) {
- if ("network".equals(port.getProtocol())) {
- return new NetworkMonitor(port, base);
- }
-
- return new SerialMonitor(port);
- }
-
}
diff --git a/app/src/cc/arduino/packages/discoverers/NetworkDiscovery.java b/arduino-core/src/cc/arduino/packages/discoverers/NetworkDiscovery.java
similarity index 97%
rename from app/src/cc/arduino/packages/discoverers/NetworkDiscovery.java
rename to arduino-core/src/cc/arduino/packages/discoverers/NetworkDiscovery.java
index 835d93158da..ae1c5aea4b1 100644
--- a/app/src/cc/arduino/packages/discoverers/NetworkDiscovery.java
+++ b/arduino-core/src/cc/arduino/packages/discoverers/NetworkDiscovery.java
@@ -32,7 +32,7 @@
import cc.arduino.packages.BoardPort;
import cc.arduino.packages.Discovery;
import cc.arduino.packages.discoverers.network.*;
-import processing.app.Base;
+import processing.app.BaseNoGui;
import processing.app.helpers.NetUtils;
import processing.app.helpers.PreferencesMap;
import processing.app.zeroconf.jmdns.ArduinoDNSTaskStarter;
@@ -140,7 +140,7 @@ public void serviceResolved(ServiceEvent serviceEvent) {
String label = name + " at " + address;
if (board != null) {
- String boardName = Base.getPlatform().resolveDeviceByBoardID(Base.packages, board);
+ String boardName = BaseNoGui.getPlatform().resolveDeviceByBoardID(BaseNoGui.packages, board);
label += " (" + boardName + ")";
}
diff --git a/app/src/cc/arduino/packages/discoverers/SerialDiscovery.java b/arduino-core/src/cc/arduino/packages/discoverers/SerialDiscovery.java
similarity index 93%
rename from app/src/cc/arduino/packages/discoverers/SerialDiscovery.java
rename to arduino-core/src/cc/arduino/packages/discoverers/SerialDiscovery.java
index a5f6d4f9281..10eff401cff 100644
--- a/app/src/cc/arduino/packages/discoverers/SerialDiscovery.java
+++ b/arduino-core/src/cc/arduino/packages/discoverers/SerialDiscovery.java
@@ -32,7 +32,7 @@
import java.util.ArrayList;
import java.util.List;
-import processing.app.Base;
+import processing.app.BaseNoGui;
import processing.app.Platform;
import processing.app.Serial;
import processing.app.helpers.PreferencesMap;
@@ -43,7 +43,7 @@ public class SerialDiscovery implements Discovery {
@Override
public List discovery() {
- Platform os = Base.getPlatform();
+ Platform os = BaseNoGui.getPlatform();
String devicesListOutput = os.preListAllCandidateDevices();
List res = new ArrayList();
@@ -51,7 +51,7 @@ public List discovery() {
List ports = Serial.list();
for (String port : ports) {
- String boardName = os.resolveDeviceAttachedTo(port, Base.packages, devicesListOutput);
+ String boardName = os.resolveDeviceAttachedTo(port, BaseNoGui.packages, devicesListOutput);
String label = port;
if (boardName != null)
label += " (" + boardName + ")";
diff --git a/app/src/cc/arduino/packages/discoverers/network/NetworkChecker.java b/arduino-core/src/cc/arduino/packages/discoverers/network/NetworkChecker.java
similarity index 100%
rename from app/src/cc/arduino/packages/discoverers/network/NetworkChecker.java
rename to arduino-core/src/cc/arduino/packages/discoverers/network/NetworkChecker.java
diff --git a/app/src/cc/arduino/packages/discoverers/network/NetworkTopologyListener.java b/arduino-core/src/cc/arduino/packages/discoverers/network/NetworkTopologyListener.java
similarity index 100%
rename from app/src/cc/arduino/packages/discoverers/network/NetworkTopologyListener.java
rename to arduino-core/src/cc/arduino/packages/discoverers/network/NetworkTopologyListener.java
diff --git a/app/src/cc/arduino/packages/ssh/NoInteractionUserInfo.java b/arduino-core/src/cc/arduino/packages/ssh/NoInteractionUserInfo.java
similarity index 100%
rename from app/src/cc/arduino/packages/ssh/NoInteractionUserInfo.java
rename to arduino-core/src/cc/arduino/packages/ssh/NoInteractionUserInfo.java
diff --git a/app/src/cc/arduino/packages/ssh/SCP.java b/arduino-core/src/cc/arduino/packages/ssh/SCP.java
similarity index 100%
rename from app/src/cc/arduino/packages/ssh/SCP.java
rename to arduino-core/src/cc/arduino/packages/ssh/SCP.java
diff --git a/app/src/cc/arduino/packages/ssh/SSH.java b/arduino-core/src/cc/arduino/packages/ssh/SSH.java
similarity index 100%
rename from app/src/cc/arduino/packages/ssh/SSH.java
rename to arduino-core/src/cc/arduino/packages/ssh/SSH.java
diff --git a/app/src/cc/arduino/packages/ssh/SSHClientSetupChainRing.java b/arduino-core/src/cc/arduino/packages/ssh/SSHClientSetupChainRing.java
similarity index 100%
rename from app/src/cc/arduino/packages/ssh/SSHClientSetupChainRing.java
rename to arduino-core/src/cc/arduino/packages/ssh/SSHClientSetupChainRing.java
diff --git a/app/src/cc/arduino/packages/ssh/SSHConfigFileSetup.java b/arduino-core/src/cc/arduino/packages/ssh/SSHConfigFileSetup.java
similarity index 100%
rename from app/src/cc/arduino/packages/ssh/SSHConfigFileSetup.java
rename to arduino-core/src/cc/arduino/packages/ssh/SSHConfigFileSetup.java
diff --git a/app/src/cc/arduino/packages/ssh/SSHPwdSetup.java b/arduino-core/src/cc/arduino/packages/ssh/SSHPwdSetup.java
similarity index 80%
rename from app/src/cc/arduino/packages/ssh/SSHPwdSetup.java
rename to arduino-core/src/cc/arduino/packages/ssh/SSHPwdSetup.java
index ad031541ad4..3eedcd81918 100644
--- a/app/src/cc/arduino/packages/ssh/SSHPwdSetup.java
+++ b/arduino-core/src/cc/arduino/packages/ssh/SSHPwdSetup.java
@@ -4,7 +4,7 @@
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
-import processing.app.Preferences;
+import processing.app.PreferencesData;
public class SSHPwdSetup implements SSHClientSetupChainRing {
@@ -13,7 +13,7 @@ public Session setup(BoardPort port, JSch jSch) throws JSchException {
String ipAddress = port.getAddress();
Session session = jSch.getSession("root", ipAddress, 22);
- session.setPassword(Preferences.get("runtime.pwd." + ipAddress));
+ session.setPassword(PreferencesData.get("runtime.pwd." + ipAddress));
return session;
}
diff --git a/app/src/cc/arduino/packages/uploaders/SSHUploader.java b/arduino-core/src/cc/arduino/packages/uploaders/SSHUploader.java
similarity index 94%
rename from app/src/cc/arduino/packages/uploaders/SSHUploader.java
rename to arduino-core/src/cc/arduino/packages/uploaders/SSHUploader.java
index 213d7a6648d..b99c00a5c42 100644
--- a/app/src/cc/arduino/packages/uploaders/SSHUploader.java
+++ b/arduino-core/src/cc/arduino/packages/uploaders/SSHUploader.java
@@ -35,9 +35,9 @@
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
-import processing.app.Base;
+import processing.app.BaseNoGui;
import processing.app.I18n;
-import processing.app.Preferences;
+import processing.app.PreferencesData;
import processing.app.debug.RunnerException;
import processing.app.debug.TargetPlatform;
import processing.app.helpers.PreferencesMap;
@@ -82,7 +82,7 @@ public boolean uploadUsingPreferences(File sourcePath, String buildPath, String
SSHClientSetupChainRing sshClientSetupChain = new SSHConfigFileSetup(new SSHPwdSetup());
session = sshClientSetupChain.setup(port, jSch);
- session.setUserInfo(new NoInteractionUserInfo(Preferences.get("runtime.pwd." + port.getAddress())));
+ session.setUserInfo(new NoInteractionUserInfo(PreferencesData.get("runtime.pwd." + port.getAddress())));
session.connect(30000);
scp = new SCP(session);
@@ -117,9 +117,9 @@ public boolean uploadUsingPreferences(File sourcePath, String buildPath, String
}
private boolean runAVRDude(SSH ssh) throws IOException, JSchException {
- TargetPlatform targetPlatform = Base.getTargetPlatform();
- PreferencesMap prefs = Preferences.getMap();
- prefs.putAll(Base.getBoardPreferences());
+ TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
+ PreferencesMap prefs = PreferencesData.getMap();
+ prefs.putAll(BaseNoGui.getBoardPreferences());
prefs.putAll(targetPlatform.getTool(prefs.get("upload.tool")));
String additionalParams = verbose ? prefs.get("upload.params.verbose") : prefs.get("upload.params.quiet");
diff --git a/app/src/cc/arduino/packages/uploaders/SerialUploader.java b/arduino-core/src/cc/arduino/packages/uploaders/SerialUploader.java
similarity index 84%
rename from app/src/cc/arduino/packages/uploaders/SerialUploader.java
rename to arduino-core/src/cc/arduino/packages/uploaders/SerialUploader.java
index 059fc587006..8968e678fe2 100644
--- a/app/src/cc/arduino/packages/uploaders/SerialUploader.java
+++ b/arduino-core/src/cc/arduino/packages/uploaders/SerialUploader.java
@@ -32,28 +32,39 @@
import java.util.ArrayList;
import java.util.List;
-import processing.app.Base;
+import processing.app.BaseNoGui;
import processing.app.I18n;
-import processing.app.Preferences;
+import processing.app.PreferencesData;
import processing.app.Serial;
import processing.app.SerialException;
import processing.app.debug.RunnerException;
import processing.app.debug.TargetPlatform;
+import processing.app.helpers.OSUtils;
import processing.app.helpers.PreferencesMap;
import processing.app.helpers.StringReplacer;
import cc.arduino.packages.Uploader;
public class SerialUploader extends Uploader {
+ public SerialUploader()
+ {
+ super();
+ }
+
+ public SerialUploader(boolean noUploadPort)
+ {
+ super(noUploadPort);
+ }
+
public boolean uploadUsingPreferences(File sourcePath, String buildPath, String className, boolean usingProgrammer, List warningsAccumulator) throws Exception {
// FIXME: Preferences should be reorganized
- TargetPlatform targetPlatform = Base.getTargetPlatform();
- PreferencesMap prefs = Preferences.getMap();
- prefs.putAll(Base.getBoardPreferences());
+ TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
+ PreferencesMap prefs = PreferencesData.getMap();
+ prefs.putAll(BaseNoGui.getBoardPreferences());
String tool = prefs.getOrExcept("upload.tool");
if (tool.contains(":")) {
String[] split = tool.split(":", 2);
- targetPlatform = Base.getCurrentTargetPlatformFromPackage(split[0]);
+ targetPlatform = BaseNoGui.getCurrentTargetPlatformFromPackage(split[0]);
tool = split[1];
}
prefs.putAll(targetPlatform.getTool(tool));
@@ -64,6 +75,26 @@ public boolean uploadUsingPreferences(File sourcePath, String buildPath, String
return uploadUsingProgrammer(buildPath, className);
}
+ if (noUploadPort)
+ {
+ prefs.put("build.path", buildPath);
+ prefs.put("build.project_name", className);
+ if (verbose)
+ prefs.put("upload.verbose", prefs.getOrExcept("upload.params.verbose"));
+ else
+ prefs.put("upload.verbose", prefs.getOrExcept("upload.params.quiet"));
+
+ boolean uploadResult;
+ try {
+ String pattern = prefs.getOrExcept("upload.pattern");
+ String[] cmd = StringReplacer.formatAndSplit(pattern, prefs, true);
+ uploadResult = executeUploadCommand(cmd);
+ } catch (Exception e) {
+ throw new RunnerException(e);
+ }
+ return uploadResult;
+ }
+
// need to do a little dance for Leonardo and derivatives:
// open then close the port at the magic baudrate (usually 1200 bps) first
// to signal to the sketch that it should reset into bootloader. after doing
@@ -131,7 +162,7 @@ public boolean uploadUsingPreferences(File sourcePath, String buildPath, String
try {
if (uploadResult && doTouch) {
- String uploadPort = Preferences.get("serial.port");
+ String uploadPort = PreferencesData.get("serial.port");
if (waitForUploadPort) {
// For Due/Leonardo wait until the bootloader serial port disconnects and the
// sketch serial port reconnects (or timeout after a few seconds if the
@@ -188,7 +219,7 @@ private String waitForUploadPort(String uploadPort, List before) throws
// come back, so use a longer time out before assuming that the
// selected
// port is the bootloader (not the sketch).
- if (((!Base.isWindows() && elapsed >= 500) || elapsed >= 5000) && now.contains(uploadPort)) {
+ if (((!OSUtils.isWindows() && elapsed >= 500) || elapsed >= 5000) && now.contains(uploadPort)) {
if (verbose)
System.out.println("Uploading using selected port: " + uploadPort);
return uploadPort;
@@ -201,16 +232,16 @@ private String waitForUploadPort(String uploadPort, List before) throws
public boolean uploadUsingProgrammer(String buildPath, String className) throws Exception {
- TargetPlatform targetPlatform = Base.getTargetPlatform();
- String programmer = Preferences.get("programmer");
+ TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
+ String programmer = PreferencesData.get("programmer");
if (programmer.contains(":")) {
String[] split = programmer.split(":", 2);
- targetPlatform = Base.getCurrentTargetPlatformFromPackage(split[0]);
+ targetPlatform = BaseNoGui.getCurrentTargetPlatformFromPackage(split[0]);
programmer = split[1];
}
- PreferencesMap prefs = Preferences.getMap();
- prefs.putAll(Base.getBoardPreferences());
+ PreferencesMap prefs = PreferencesData.getMap();
+ prefs.putAll(BaseNoGui.getBoardPreferences());
PreferencesMap programmerPrefs = targetPlatform.getProgrammer(programmer);
if (programmerPrefs == null)
throw new RunnerException(
@@ -244,14 +275,14 @@ public boolean uploadUsingProgrammer(String buildPath, String className) throws
}
public boolean burnBootloader() throws Exception {
- TargetPlatform targetPlatform = Base.getTargetPlatform();
+ TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
// Find preferences for the selected programmer
PreferencesMap programmerPrefs;
- String programmer = Preferences.get("programmer");
+ String programmer = PreferencesData.get("programmer");
if (programmer.contains(":")) {
String[] split = programmer.split(":", 2);
- TargetPlatform platform = Base.getCurrentTargetPlatformFromPackage(split[0]);
+ TargetPlatform platform = BaseNoGui.getCurrentTargetPlatformFromPackage(split[0]);
programmer = split[1];
programmerPrefs = platform.getProgrammer(programmer);
} else {
@@ -262,8 +293,8 @@ public boolean burnBootloader() throws Exception {
_("Please select a programmer from Tools->Programmer menu"));
// Build configuration for the current programmer
- PreferencesMap prefs = Preferences.getMap();
- prefs.putAll(Base.getBoardPreferences());
+ PreferencesMap prefs = PreferencesData.getMap();
+ prefs.putAll(BaseNoGui.getBoardPreferences());
prefs.putAll(programmerPrefs);
// Create configuration for bootloader tool
@@ -271,7 +302,7 @@ public boolean burnBootloader() throws Exception {
String tool = prefs.getOrExcept("bootloader.tool");
if (tool.contains(":")) {
String[] split = tool.split(":", 2);
- TargetPlatform platform = Base.getCurrentTargetPlatformFromPackage(split[0]);
+ TargetPlatform platform = BaseNoGui.getCurrentTargetPlatformFromPackage(split[0]);
tool = split[1];
toolPrefs.putAll(platform.getTool(tool));
if (toolPrefs.size() == 0)
diff --git a/arduino-core/src/processing/app/BaseNoGui.java b/arduino-core/src/processing/app/BaseNoGui.java
new file mode 100644
index 00000000000..825af095c68
--- /dev/null
+++ b/arduino-core/src/processing/app/BaseNoGui.java
@@ -0,0 +1,977 @@
+package processing.app;
+
+import static processing.app.I18n._;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.commons.logging.impl.LogFactoryImpl;
+import org.apache.commons.logging.impl.NoOpLog;
+
+import cc.arduino.packages.DiscoveryManager;
+import cc.arduino.packages.Uploader;
+
+import processing.app.debug.Compiler;
+import processing.app.debug.TargetBoard;
+import processing.app.debug.TargetPackage;
+import processing.app.debug.TargetPlatform;
+import processing.app.debug.TargetPlatformException;
+import processing.app.helpers.BasicUserNotifier;
+import processing.app.helpers.CommandlineParser;
+import processing.app.helpers.OSUtils;
+import processing.app.helpers.PreferencesMap;
+import processing.app.helpers.UserNotifier;
+import processing.app.helpers.filefilters.OnlyDirs;
+import processing.app.helpers.filefilters.OnlyFilesWithExtension;
+import processing.app.legacy.PApplet;
+import processing.app.packages.Library;
+import processing.app.packages.LibraryList;
+
+public class BaseNoGui {
+
+ public static final int REVISION = 158;
+ /** This might be replaced by main() if there's a lib/version.txt file. */
+ static String VERSION_NAME = "0158";
+ /** Set true if this a proper release rather than a numbered revision. */
+ static public boolean RELEASE = false;
+
+ static File buildFolder;
+
+ // Current directory to use for relative paths specified on the
+ // commandline
+ static String currentDirectory = System.getProperty("user.dir");
+
+ private static DiscoveryManager discoveryManager = new DiscoveryManager();
+
+ // these are static because they're used by Sketch
+ static private File examplesFolder;
+ static private File toolsFolder;
+
+ // maps #included files to their library folder
+ public static Map importToLibraryTable;
+
+ // maps library name to their library folder
+ static private LibraryList libraries;
+
+ static private List librariesFolders;
+
+ static UserNotifier notifier = new BasicUserNotifier();
+
+ static public Map packages;
+
+ static Platform platform;
+
+ static File portableFolder = null;
+
+ static final String portableSketchbookFolder = "sketchbook";
+
+ // Returns a File object for the given pathname. If the pathname
+ // is not absolute, it is interpreted relative to the current
+ // directory when starting the IDE (which is not the same as the
+ // current working directory!).
+ static public File absoluteFile(String path) {
+ if (path == null) return null;
+
+ File file = new File(path);
+ if (!file.isAbsolute()) {
+ file = new File(currentDirectory, path);
+ }
+ return file;
+ }
+
+ /**
+ * Get the number of lines in a file by counting the number of newline
+ * characters inside a String (and adding 1).
+ */
+ static public int countLines(String what) {
+ int count = 1;
+ for (char c : what.toCharArray()) {
+ if (c == '\n') count++;
+ }
+ return count;
+ }
+
+ /**
+ * Get the path to the platform's temporary folder, by creating
+ * a temporary temporary file and getting its parent folder.
+ *
+ * Modified for revision 0094 to actually make the folder randomized
+ * to avoid conflicts in multi-user environments. (Bug 177)
+ */
+ static public File createTempFolder(String name) {
+ try {
+ File folder = File.createTempFile(name, null);
+ //String tempPath = ignored.getParent();
+ //return new File(tempPath);
+ folder.delete();
+ folder.mkdirs();
+ return folder;
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ static public String getAvrBasePath() {
+ String path = getHardwarePath() + File.separator + "tools" +
+ File.separator + "avr" + File.separator + "bin" + File.separator;
+ if (OSUtils.isLinux() && !(new File(path)).exists()) {
+ return ""; // use distribution provided avr tools if bundled tools missing
+ }
+ return path;
+ }
+
+ static public File getBuildFolder() {
+ if (buildFolder == null) {
+ String buildPath = PreferencesData.get("build.path");
+ if (buildPath != null) {
+ buildFolder = absoluteFile(buildPath);
+ if (!buildFolder.exists())
+ buildFolder.mkdirs();
+ } else {
+ //File folder = new File(getTempFolder(), "build");
+ //if (!folder.exists()) folder.mkdirs();
+ buildFolder = createTempFolder("build");
+ buildFolder.deleteOnExit();
+ }
+ }
+ return buildFolder;
+ }
+
+ static public PreferencesMap getBoardPreferences() {
+ TargetBoard board = getTargetBoard();
+
+ PreferencesMap prefs = new PreferencesMap(board.getPreferences());
+ for (String menuId : board.getMenuIds()) {
+ String entry = PreferencesData.get("custom_" + menuId);
+ if (board.hasMenu(menuId) && entry != null &&
+ entry.startsWith(board.getId())) {
+ String selectionId = entry.substring(entry.indexOf("_") + 1);
+ prefs.putAll(board.getMenuPreferences(menuId, selectionId));
+ prefs.put("name", prefs.get("name") + ", " +
+ board.getMenuLabel(menuId, selectionId));
+ }
+ }
+ return prefs;
+ }
+
+ static public File getContentFile(String name) {
+ String path = System.getProperty("user.dir");
+
+ // Get a path to somewhere inside the .app folder
+ if (OSUtils.isMacOS()) {
+// javaroot
+// $JAVAROOT
+ String javaroot = System.getProperty("javaroot");
+ if (javaroot != null) {
+ path = javaroot;
+ }
+ }
+ File working = new File(path);
+ return new File(working, name);
+ }
+
+ static public TargetPlatform getCurrentTargetPlatformFromPackage(String pack) {
+ return getTargetPlatform(pack, PreferencesData.get("target_platform"));
+ }
+
+ static public File getDefaultSketchbookFolder() {
+ if (getPortableFolder() != null)
+ return new File(getPortableFolder(), getPortableSketchbookFolder());
+
+ File sketchbookFolder = null;
+ try {
+ sketchbookFolder = getPlatform().getDefaultSketchbookFolder();
+ } catch (Exception e) { }
+
+ return sketchbookFolder;
+ }
+
+ public static DiscoveryManager getDiscoveryManager() {
+ return discoveryManager;
+ }
+
+ static public File getExamplesFolder() {
+ return examplesFolder;
+ }
+
+ static public String getExamplesPath() {
+ return examplesFolder.getAbsolutePath();
+ }
+
+ static public File getHardwareFolder() {
+ // calculate on the fly because it's needed by Preferences.init() to find
+ // the boards.txt and programmers.txt preferences files (which happens
+ // before the other folders / paths get cached).
+ return getContentFile("hardware");
+ }
+
+ static public String getHardwarePath() {
+ return getHardwareFolder().getAbsolutePath();
+ }
+
+ static public LibraryList getLibraries() {
+ return libraries;
+ }
+
+ static public List getLibrariesPath() {
+ return librariesFolders;
+ }
+
+ /**
+ * Return an InputStream for a file inside the Processing lib folder.
+ */
+ static public InputStream getLibStream(String filename) throws IOException {
+ return new FileInputStream(new File(getContentFile("lib"), filename));
+ }
+
+ static public Platform getPlatform() {
+ return platform;
+ }
+
+ static public File getPortableFolder() {
+ return portableFolder;
+ }
+
+ static public String getPortableSketchbookFolder() {
+ return portableSketchbookFolder;
+ }
+
+ /**
+ * Convenience method to get a File object for the specified filename inside
+ * the settings folder.
+ * For now, only used by Preferences to get the preferences.txt file.
+ * @param filename A file inside the settings folder.
+ * @return filename wrapped as a File object inside the settings folder
+ */
+ static public File getSettingsFile(String filename) {
+ return new File(getSettingsFolder(), filename);
+ }
+
+ static public File getSettingsFolder() {
+ if (getPortableFolder() != null)
+ return getPortableFolder();
+
+ File settingsFolder = null;
+
+ String preferencesPath = PreferencesData.get("settings.path");
+ if (preferencesPath != null) {
+ settingsFolder = absoluteFile(preferencesPath);
+
+ } else {
+ try {
+ settingsFolder = getPlatform().getSettingsFolder();
+ } catch (Exception e) {
+ showError(_("Problem getting data folder"),
+ _("Error getting the Arduino data folder."), e);
+ }
+ }
+
+ // create the folder if it doesn't exist already
+ if (!settingsFolder.exists()) {
+ if (!settingsFolder.mkdirs()) {
+ showError(_("Settings issues"),
+ _("Arduino cannot run because it could not\n" +
+ "create a folder to store your settings."), null);
+ }
+ }
+ return settingsFolder;
+ }
+
+ static public File getSketchbookFolder() {
+ if (portableFolder != null)
+ return new File(portableFolder, PreferencesData.get("sketchbook.path"));
+ return absoluteFile(PreferencesData.get("sketchbook.path"));
+ }
+
+ static public File getSketchbookHardwareFolder() {
+ return new File(getSketchbookFolder(), "hardware");
+ }
+
+ static public File getSketchbookLibrariesFolder() {
+ File libdir = new File(getSketchbookFolder(), "libraries");
+ if (!libdir.exists()) {
+ try {
+ libdir.mkdirs();
+ File readme = new File(libdir, "readme.txt");
+ FileWriter freadme = new FileWriter(readme);
+ freadme.write(_("For information on installing libraries, see: " +
+ "http://arduino.cc/en/Guide/Libraries\n"));
+ freadme.close();
+ } catch (Exception e) {
+ }
+ }
+ return libdir;
+ }
+
+ static public String getSketchbookPath() {
+ // Get the sketchbook path, and make sure it's set properly
+ String sketchbookPath = PreferencesData.get("sketchbook.path");
+
+ // If a value is at least set, first check to see if the folder exists.
+ // If it doesn't, warn the user that the sketchbook folder is being reset.
+ if (sketchbookPath != null) {
+ File sketchbookFolder;
+ if (getPortableFolder() != null)
+ sketchbookFolder = new File(getPortableFolder(), sketchbookPath);
+ else
+ sketchbookFolder = absoluteFile(sketchbookPath);
+ if (!sketchbookFolder.exists()) {
+ showWarning(_("Sketchbook folder disappeared"),
+ _("The sketchbook folder no longer exists.\n" +
+ "Arduino will switch to the default sketchbook\n" +
+ "location, and create a new sketchbook folder if\n" +
+ "necessary. Arduino will then stop talking about\n" +
+ "himself in the third person."), null);
+ sketchbookPath = null;
+ }
+ }
+
+ return sketchbookPath;
+ }
+
+ public static TargetBoard getTargetBoard() {
+ String boardId = PreferencesData.get("board");
+ return getTargetPlatform().getBoard(boardId);
+ }
+
+ /**
+ * Returns a specific TargetPackage
+ *
+ * @param packageName
+ * @return
+ */
+ static public TargetPackage getTargetPackage(String packageName) {
+ return packages.get(packageName);
+ }
+
+ /**
+ * Returns the currently selected TargetPlatform.
+ *
+ * @return
+ */
+ static public TargetPlatform getTargetPlatform() {
+ String packageName = PreferencesData.get("target_package");
+ String platformName = PreferencesData.get("target_platform");
+ return getTargetPlatform(packageName, platformName);
+ }
+
+ /**
+ * Returns a specific TargetPlatform searching Package/Platform
+ *
+ * @param packageName
+ * @param platformName
+ * @return
+ */
+ static public TargetPlatform getTargetPlatform(String packageName,
+ String platformName) {
+ TargetPackage p = packages.get(packageName);
+ if (p == null)
+ return null;
+ return p.get(platformName);
+ }
+
+ static public File getToolsFolder() {
+ return toolsFolder;
+ }
+
+ static public String getToolsPath() {
+ return toolsFolder.getAbsolutePath();
+ }
+
+ static public LibraryList getUserLibs() {
+ if (libraries == null)
+ return new LibraryList();
+ return libraries.filterLibrariesInSubfolder(getSketchbookFolder());
+ }
+
+ /**
+ * Given a folder, return a list of the header files in that folder (but not
+ * the header files in its sub-folders, as those should be included from
+ * within the header files at the top-level).
+ */
+ static public String[] headerListFromIncludePath(File path) throws IOException {
+ String[] list = path.list(new OnlyFilesWithExtension(".h"));
+ if (list == null) {
+ throw new IOException();
+ }
+ return list;
+ }
+
+ static public void init(String[] args) {
+ getPlatform().init();
+
+ String sketchbookPath = getSketchbookPath();
+
+ // If no path is set, get the default sketchbook folder for this platform
+ if (sketchbookPath == null) {
+ if (BaseNoGui.getPortableFolder() != null)
+ PreferencesData.set("sketchbook.path", getPortableSketchbookFolder());
+ else
+ showError(_("No sketchbook"), _("Sketchbook path not defined"), null);
+ }
+
+ BaseNoGui.initPackages();
+
+ // Setup board-dependent variables.
+ onBoardOrPortChange();
+
+ CommandlineParser parser = CommandlineParser.newCommandlineParser(args);
+
+ for (String path: parser.getFilenames()) {
+ // Correctly resolve relative paths
+ File file = absoluteFile(path);
+
+ // Fix a problem with systems that use a non-ASCII languages. Paths are
+ // being passed in with 8.3 syntax, which makes the sketch loader code
+ // unhappy, since the sketch folder naming doesn't match up correctly.
+ // http://dev.processing.org/bugs/show_bug.cgi?id=1089
+ if (OSUtils.isWindows()) {
+ try {
+ file = file.getCanonicalFile();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ if (!parser.isVerifyOrUploadMode() && !parser.isGetPrefMode())
+ showError(_("Mode not supported"), _("Only --verify, --upload or --get-pref are supported"), null);
+
+ if (!parser.isForceSavePrefs())
+ PreferencesData.setDoSave(false);
+ if (!file.exists()) {
+ String mess = I18n.format(_("Failed to open sketch: \"{0}\""), path);
+ // Open failure is fatal in upload/verify mode
+ showError(null, mess, 2);
+ }
+ }
+
+ // Save the preferences. For GUI mode, this happens in the quit
+ // handler, but for other modes we should also make sure to save
+ // them.
+ PreferencesData.save();
+
+ if (parser.isVerifyOrUploadMode()) {
+ // Set verbosity for command line build
+ PreferencesData.set("build.verbose", "" + parser.isDoVerboseBuild());
+ PreferencesData.set("upload.verbose", "" + parser.isDoVerboseUpload());
+
+ // Make sure these verbosity preferences are only for the
+ // current session
+ PreferencesData.setDoSave(false);
+
+ if (parser.isUploadMode()) {
+
+ if (parser.getFilenames().size() != 1)
+ {
+ showError(_("Multiple files not supported"), _("The --upload option supports only one file at a time"), null);
+ }
+
+ List warningsAccumulator = new LinkedList();
+ boolean success = false;
+ try {
+ // costruttore di Editor carica lo sketch usando handleOpenInternal() che fa
+ // la new di Sketch che chiama load() nel suo costruttore
+ // In questo punto questo si traduce in:
+ // SketchData data = new SketchData(file);
+ // File tempBuildFolder = getBuildFolder();
+ // data.load();
+ SketchData data = new SketchData(absoluteFile(parser.getFilenames().get(0)));
+ File tempBuildFolder = getBuildFolder();
+ data.load();
+
+ // Sketch.exportApplet()
+ // - chiama Sketch.prepare() che chiama Sketch.ensureExistence()
+ // - chiama Sketch.build(verbose=false) che chiama Sketch.ensureExistence(), imposta il progressListener e chiama Compiler.build()
+ // - chiama Sketch.upload() (cfr. dopo...)
+ if (!data.getFolder().exists()) showError(_("No sketch"), _("Can't find the sketch in the specified path"), null);
+ String suggestedClassName = Compiler.build(data, tempBuildFolder.getAbsolutePath(), tempBuildFolder, null, parser.isDoVerboseBuild());
+ if (suggestedClassName == null) showError(_("Error while verifying"), _("An error occurred while verifying the sketch"), null);
+ showMessage(_("Done compiling"), _("Done compiling"));
+
+ // - chiama Sketch.upload() ... to be continued ...
+ Uploader uploader = Compiler.getUploaderByPreferences(parser.isNoUploadPort());
+ if (uploader.requiresAuthorization() && !PreferencesData.has(uploader.getAuthorizationKey())) showError(_("..."), _("..."), null);
+ try {
+ success = Compiler.upload(data, uploader, tempBuildFolder.getAbsolutePath(), suggestedClassName, parser.isDoUseProgrammer(), parser.isNoUploadPort(), warningsAccumulator);
+ showMessage(_("Done uploading"), _("Done uploading"));
+ } finally {
+ if (uploader.requiresAuthorization() && !success) {
+ PreferencesData.remove(uploader.getAuthorizationKey());
+ }
+ }
+ } catch (Exception e) {
+ showError(_("Error while verifying/uploading"), _("An error occurred while verifying/uploading the sketch"), e);
+ }
+ for (String warning : warningsAccumulator) {
+ System.out.print(_("Warning"));
+ System.out.print(": ");
+ System.out.println(warning);
+ }
+ if (!success) showError(_("Error while uploading"), _("An error occurred while uploading the sketch"), null);
+ } else {
+
+ for (String path : parser.getFilenames())
+ {
+ try {
+ // costruttore di Editor carica lo sketch usando handleOpenInternal() che fa
+ // la new di Sketch che chiama load() nel suo costruttore
+ // In questo punto questo si traduce in:
+ // SketchData data = new SketchData(file);
+ // File tempBuildFolder = getBuildFolder();
+ // data.load();
+ SketchData data = new SketchData(absoluteFile(path));
+ File tempBuildFolder = getBuildFolder();
+ data.load();
+
+ // metodo Sketch.prepare() chiama Sketch.ensureExistence()
+ // Sketch.build(verbose) chiama Sketch.ensureExistence() e poi imposta il progressListener e, finalmente, chiama Compiler.build()
+ // In questo punto questo si traduce in:
+ // if (!data.getFolder().exists()) showError(...);
+ // String ... = Compiler.build(data, tempBuildFolder.getAbsolutePath(), tempBuildFolder, null, verbose);
+ if (!data.getFolder().exists()) showError(_("No sketch"), _("Can't find the sketch in the specified path"), null);
+ String suggestedClassName = Compiler.build(data, tempBuildFolder.getAbsolutePath(), tempBuildFolder, null, parser.isDoVerboseBuild());
+ if (suggestedClassName == null) showError(_("Error while verifying"), _("An error occurred while verifying the sketch"), null);
+ showMessage(_("Done compiling"), _("Done compiling"));
+ } catch (Exception e) {
+ showError(_("Error while verifying"), _("An error occurred while verifying the sketch"), e);
+ }
+ }
+
+ }
+
+ // No errors exit gracefully
+ System.exit(0);
+ }
+ else if (parser.isGetPrefMode()) {
+ String value = PreferencesData.get(parser.getGetPref(), null);
+ if (value != null) {
+ System.out.println(value);
+ System.exit(0);
+ } else {
+ System.exit(4);
+ }
+ }
+ }
+
+ static public void initLogger() {
+ System.setProperty(LogFactoryImpl.LOG_PROPERTY, NoOpLog.class.getCanonicalName());
+ Logger.getLogger("javax.jmdns").setLevel(Level.OFF);
+ }
+
+ static public void initPackages() {
+ packages = new HashMap();
+ loadHardware(getHardwareFolder());
+ loadHardware(getSketchbookHardwareFolder());
+ if (packages.size() == 0) {
+ System.out.println(_("No valid configured cores found! Exiting..."));
+ System.exit(3);
+ }
+ }
+
+ static protected void initPlatform() {
+ try {
+ Class> platformClass = Class.forName("processing.app.Platform");
+ if (OSUtils.isMacOS()) {
+ platformClass = Class.forName("processing.app.macosx.Platform");
+ } else if (OSUtils.isWindows()) {
+ platformClass = Class.forName("processing.app.windows.Platform");
+ } else if (OSUtils.isLinux()) {
+ platformClass = Class.forName("processing.app.linux.Platform");
+ }
+ platform = (Platform) platformClass.newInstance();
+ } catch (Exception e) {
+ showError(_("Problem Setting the Platform"),
+ _("An unknown error occurred while trying to load\n" +
+ "platform-specific code for your machine."), e);
+ }
+ }
+
+ static public void initPortableFolder() {
+ // Portable folder
+ portableFolder = getContentFile("portable");
+ if (!portableFolder.exists())
+ portableFolder = null;
+ }
+
+ static public void initVersion() {
+ try {
+ File versionFile = getContentFile("lib/version.txt");
+ if (versionFile.exists()) {
+ String version = PApplet.loadStrings(versionFile)[0];
+ if (!version.equals(VERSION_NAME) && !version.equals("${version}")) {
+ VERSION_NAME = version;
+ RELEASE = true;
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // help 3rd party installers find the correct hardware path
+ PreferencesData.set("last.ide." + VERSION_NAME + ".hardwarepath", getHardwarePath());
+ PreferencesData.set("last.ide." + VERSION_NAME + ".daterun", "" + (new Date()).getTime() / 1000);
+ }
+
+ /**
+ * Return true if the name is valid for a Processing sketch.
+ */
+ static public boolean isSanitaryName(String name) {
+ return sanitizeName(name).equals(name);
+ }
+
+ static protected void loadHardware(File folder) {
+ if (!folder.isDirectory()) return;
+
+ String list[] = folder.list(new OnlyDirs());
+
+ // if a bad folder or something like that, this might come back null
+ if (list == null) return;
+
+ // alphabetize list, since it's not always alpha order
+ // replaced hella slow bubble sort with this feller for 0093
+ Arrays.sort(list, String.CASE_INSENSITIVE_ORDER);
+
+ for (String target : list) {
+ // Skip reserved 'tools' folder.
+ if (target.equals("tools"))
+ continue;
+ File subfolder = new File(folder, target);
+
+ try {
+ packages.put(target, new TargetPackage(target, subfolder));
+ } catch (TargetPlatformException e) {
+ System.out.println("WARNING: Error loading hardware folder " + target);
+ System.out.println(" " + e.getMessage());
+ }
+ }
+ }
+
+ /**
+ * Grab the contents of a file as a string.
+ */
+ static public String loadFile(File file) throws IOException {
+ String[] contents = PApplet.loadStrings(file);
+ if (contents == null) return null;
+ return PApplet.join(contents, "\n");
+ }
+
+ static public void main(String args[]) throws Exception {
+ if (args.length == 0)
+ showError(_("No parameters"), _("No command line parameters found"), null);
+
+ initPlatform();
+
+ initPortableFolder();
+
+ initParameters(args);
+
+ init(args);
+ }
+
+ static public void onBoardOrPortChange() {
+ TargetPlatform targetPlatform = getTargetPlatform();
+ if (targetPlatform == null)
+ return;
+
+ // Calculate paths for libraries and examples
+ examplesFolder = getContentFile("examples");
+ toolsFolder = getContentFile("tools");
+
+ File platformFolder = targetPlatform.getFolder();
+ librariesFolders = new ArrayList();
+ librariesFolders.add(getContentFile("libraries"));
+ String core = getBoardPreferences().get("build.core");
+ if (core.contains(":")) {
+ String referencedCore = core.split(":")[0];
+ TargetPlatform referencedPlatform = getTargetPlatform(referencedCore, targetPlatform.getId());
+ if (referencedPlatform != null) {
+ File referencedPlatformFolder = referencedPlatform.getFolder();
+ librariesFolders.add(new File(referencedPlatformFolder, "libraries"));
+ }
+ }
+ librariesFolders.add(new File(platformFolder, "libraries"));
+ librariesFolders.add(getSketchbookLibrariesFolder());
+
+ // Scan for libraries in each library folder.
+ // Libraries located in the latest folders on the list can override
+ // other libraries with the same name.
+ try {
+ scanAndUpdateLibraries(librariesFolders);
+ } catch (IOException e) {
+ showWarning(_("Error"), _("Error loading libraries"), e);
+ }
+
+ populateImportToLibraryTable();
+ }
+
+ static public void populateImportToLibraryTable() {
+ // Populate importToLibraryTable
+ importToLibraryTable = new HashMap();
+ for (Library lib : getLibraries()) {
+ try {
+ String headers[] = headerListFromIncludePath(lib.getSrcFolder());
+ for (String header : headers) {
+ Library old = importToLibraryTable.get(header);
+ if (old != null) {
+ // If a library was already found with this header, keep
+ // it if the library's name matches the header name.
+ String name = header.substring(0, header.length() - 2);
+ if (old.getFolder().getPath().endsWith(name))
+ continue;
+ }
+ importToLibraryTable.put(header, lib);
+ }
+ } catch (IOException e) {
+ showWarning(_("Error"), I18n
+ .format("Unable to list header files in {0}", lib.getSrcFolder()), e);
+ }
+ }
+ }
+
+ static public void initParameters(String args[]) {
+ String preferencesFile = null;
+
+ // Do a first pass over the commandline arguments, the rest of them
+ // will be processed by the Base constructor. Note that this loop
+ // does not look at the last element of args, to prevent crashing
+ // when no parameter was specified to an option. Later, Base() will
+ // then show an error for these.
+ for (int i = 0; i < args.length - 1; i++) {
+ if (args[i].equals("--preferences-file")) {
+ ++i;
+ preferencesFile = args[i];
+ continue;
+ }
+ if (args[i].equals("--curdir")) {
+ i++;
+ currentDirectory = args[i];
+ continue;
+ }
+ }
+
+ // run static initialization that grabs all the prefs
+ PreferencesData.init(absoluteFile(preferencesFile));
+ }
+
+ /**
+ * Recursively remove all files within a directory,
+ * used with removeDir(), or when the contents of a dir
+ * should be removed, but not the directory itself.
+ * (i.e. when cleaning temp files from lib/build)
+ */
+ static public void removeDescendants(File dir) {
+ if (!dir.exists()) return;
+
+ String files[] = dir.list();
+ for (int i = 0; i < files.length; i++) {
+ if (files[i].equals(".") || files[i].equals("..")) continue;
+ File dead = new File(dir, files[i]);
+ if (!dead.isDirectory()) {
+ if (!PreferencesData.getBoolean("compiler.save_build_files")) {
+ if (!dead.delete()) {
+ // temporarily disabled
+ System.err.println(I18n.format(_("Could not delete {0}"), dead));
+ }
+ }
+ } else {
+ removeDir(dead);
+ //dead.delete();
+ }
+ }
+ }
+
+ /**
+ * Remove all files in a directory and the directory itself.
+ */
+ static public void removeDir(File dir) {
+ if (dir.exists()) {
+ removeDescendants(dir);
+ if (!dir.delete()) {
+ System.err.println(I18n.format(_("Could not delete {0}"), dir));
+ }
+ }
+ }
+
+ /**
+ * Produce a sanitized name that fits our standards for likely to work.
+ *
+ * Java classes have a wider range of names that are technically allowed
+ * (supposedly any Unicode name) than what we support. The reason for
+ * going more narrow is to avoid situations with text encodings and
+ * converting during the process of moving files between operating
+ * systems, i.e. uploading from a Windows machine to a Linux server,
+ * or reading a FAT32 partition in OS X and using a thumb drive.
+ *
+ * This helper function replaces everything but A-Z, a-z, and 0-9 with
+ * underscores. Also disallows starting the sketch name with a digit.
+ */
+ static public String sanitizeName(String origName) {
+ char c[] = origName.toCharArray();
+ StringBuffer buffer = new StringBuffer();
+
+ // can't lead with a digit, so start with an underscore
+ if ((c[0] >= '0') && (c[0] <= '9')) {
+ buffer.append('_');
+ }
+ for (int i = 0; i < c.length; i++) {
+ if (((c[i] >= '0') && (c[i] <= '9')) ||
+ ((c[i] >= 'a') && (c[i] <= 'z')) ||
+ ((c[i] >= 'A') && (c[i] <= 'Z')) ||
+ ((i > 0) && (c[i] == '-')) ||
+ ((i > 0) && (c[i] == '.'))) {
+ buffer.append(c[i]);
+ } else {
+ buffer.append('_');
+ }
+ }
+ // let's not be ridiculous about the length of filenames.
+ // in fact, Mac OS 9 can handle 255 chars, though it can't really
+ // deal with filenames longer than 31 chars in the Finder.
+ // but limiting to that for sketches would mean setting the
+ // upper-bound on the character limit here to 25 characters
+ // (to handle the base name + ".class")
+ if (buffer.length() > 63) {
+ buffer.setLength(63);
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * Spew the contents of a String object out to a file.
+ */
+ static public void saveFile(String str, File file) throws IOException {
+ File temp = File.createTempFile(file.getName(), null, file.getParentFile());
+ PApplet.saveStrings(temp, new String[] { str });
+ if (file.exists()) {
+ boolean result = file.delete();
+ if (!result) {
+ throw new IOException(
+ I18n.format(
+ _("Could not remove old version of {0}"),
+ file.getAbsolutePath()));
+ }
+ }
+ boolean result = temp.renameTo(file);
+ if (!result) {
+ throw new IOException(
+ I18n.format(
+ _("Could not replace {0}"),
+ file.getAbsolutePath()));
+ }
+ }
+
+ static public void scanAndUpdateLibraries(List folders) throws IOException {
+ libraries = scanLibraries(folders);
+ }
+
+ static public LibraryList scanLibraries(List folders) throws IOException {
+ LibraryList res = new LibraryList();
+ for (File folder : folders)
+ res.addOrReplaceAll(scanLibraries(folder));
+ return res;
+ }
+
+ static public LibraryList scanLibraries(File folder) throws IOException {
+ LibraryList res = new LibraryList();
+
+ String list[] = folder.list(new OnlyDirs());
+ // if a bad folder or something like that, this might come back null
+ if (list == null)
+ return res;
+
+ for (String libName : list) {
+ File subfolder = new File(folder, libName);
+ if (!isSanitaryName(libName)) {
+ String mess = I18n.format(_("The library \"{0}\" cannot be used.\n"
+ + "Library names must contain only basic letters and numbers.\n"
+ + "(ASCII only and no spaces, and it cannot start with a number)"),
+ libName);
+ showMessage(_("Ignoring bad library name"), mess);
+ continue;
+ }
+
+ try {
+ Library lib = Library.create(subfolder);
+ // (also replace previously found libs with the same name)
+ if (lib != null)
+ res.addOrReplace(lib);
+ } catch (IOException e) {
+ System.out.println(I18n.format(_("Invalid library found in {0}: {1}"),
+ subfolder, e.getMessage()));
+ }
+ }
+ return res;
+ }
+
+ static public void selectBoard(TargetBoard targetBoard) {
+ TargetPlatform targetPlatform = targetBoard.getContainerPlatform();
+ TargetPackage targetPackage = targetPlatform.getContainerPackage();
+
+ PreferencesData.set("target_package", targetPackage.getId());
+ PreferencesData.set("target_platform", targetPlatform.getId());
+ PreferencesData.set("board", targetBoard.getId());
+
+ File platformFolder = targetPlatform.getFolder();
+ PreferencesData.set("runtime.platform.path", platformFolder.getAbsolutePath());
+ PreferencesData.set("runtime.hardware.path", platformFolder.getParentFile().getAbsolutePath());
+ }
+
+ public static void selectSerialPort(String port) {
+ PreferencesData.set("serial.port", port);
+ if (port.startsWith("/dev/"))
+ PreferencesData.set("serial.port.file", port.substring(5));
+ else
+ PreferencesData.set("serial.port.file", port);
+ }
+
+ public static void setBuildFolder(File newBuildFolder) {
+ buildFolder = newBuildFolder;
+ }
+
+ static public void showError(String title, String message, int exit_code) {
+ showError(title, message, null, exit_code);
+ }
+
+ static public void showError(String title, String message, Throwable e) {
+ notifier.showError(title, message, e, 1);
+ }
+
+ /**
+ * Show an error message that's actually fatal to the program.
+ * This is an error that can't be recovered. Use showWarning()
+ * for errors that allow P5 to continue running.
+ */
+ static public void showError(String title, String message, Throwable e, int exit_code) {
+ notifier.showError(title, message, e, exit_code);
+ }
+
+ /**
+ * "No cookie for you" type messages. Nothing fatal or all that
+ * much of a bummer, but something to notify the user about.
+ */
+ static public void showMessage(String title, String message) {
+ notifier.showMessage(title, message);
+ }
+
+ /**
+ * Non-fatal error message with optional stack trace side dish.
+ */
+ static public void showWarning(String title, String message, Exception e) {
+ notifier.showWarning(title, message, e);
+ }
+
+}
diff --git a/app/src/processing/app/I18n.java b/arduino-core/src/processing/app/I18n.java
similarity index 100%
rename from app/src/processing/app/I18n.java
rename to arduino-core/src/processing/app/I18n.java
diff --git a/app/src/processing/app/Platform.java b/arduino-core/src/processing/app/Platform.java
similarity index 93%
rename from app/src/processing/app/Platform.java
rename to arduino-core/src/processing/app/Platform.java
index 59ce7f8819e..0ee14fe6983 100644
--- a/app/src/processing/app/Platform.java
+++ b/arduino-core/src/processing/app/Platform.java
@@ -35,7 +35,7 @@
import processing.app.debug.TargetBoard;
import processing.app.debug.TargetPackage;
import processing.app.debug.TargetPlatform;
-import processing.core.PConstants;
+import processing.app.legacy.PConstants;
/**
@@ -54,7 +54,6 @@
* know if name is proper Java package syntax.)
*/
public class Platform {
- Base base;
/**
@@ -74,8 +73,7 @@ public void setLookAndFeel() throws Exception {
}
- public void init(Base base) {
- this.base = base;
+ public void init() {
}
@@ -112,7 +110,7 @@ public File getDefaultSketchbookFolder() throws Exception {
public void openURL(String url) throws Exception {
- String launcher = Preferences.get("launcher");
+ String launcher = PreferencesData.get("launcher");
if (launcher != null) {
Runtime.getRuntime().exec(new String[] { launcher, url });
} else {
@@ -122,12 +120,12 @@ public void openURL(String url) throws Exception {
public boolean openFolderAvailable() {
- return Preferences.get("launcher") != null;
+ return PreferencesData.get("launcher") != null;
}
public void openFolder(File file) throws Exception {
- String launcher = Preferences.get("launcher");
+ String launcher = PreferencesData.get("launcher");
if (launcher != null) {
String folder = file.getAbsolutePath();
Runtime.getRuntime().exec(new String[] { launcher, folder });
@@ -215,8 +213,8 @@ public String getName() {
protected void showLauncherWarning() {
- Base.showWarning(_("No launcher available"),
- _("Unspecified platform, no launcher available.\nTo enable opening URLs or folders, add a \n\"launcher=/path/to/app\" line to preferences.txt"),
- null);
+ BaseNoGui.showWarning(_("No launcher available"),
+ _("Unspecified platform, no launcher available.\nTo enable opening URLs or folders, add a \n\"launcher=/path/to/app\" line to preferences.txt"),
+ null);
}
}
diff --git a/arduino-core/src/processing/app/PreferencesData.java b/arduino-core/src/processing/app/PreferencesData.java
new file mode 100644
index 00000000000..c75e6f7b568
--- /dev/null
+++ b/arduino-core/src/processing/app/PreferencesData.java
@@ -0,0 +1,214 @@
+package processing.app;
+
+import static processing.app.I18n._;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.MissingResourceException;
+
+import processing.app.helpers.PreferencesMap;
+import processing.app.legacy.PApplet;
+import processing.app.legacy.PConstants;
+
+
+public class PreferencesData {
+
+ static final String PREFS_FILE = "preferences.txt";
+
+ // data model
+
+ static PreferencesMap defaults;
+ static PreferencesMap prefs = new PreferencesMap();
+ static File preferencesFile;
+ static boolean doSave = true;
+
+
+ static public void init(File file) {
+ if (file != null)
+ preferencesFile = file;
+ else
+ preferencesFile = BaseNoGui.getSettingsFile(PREFS_FILE);
+
+ // start by loading the defaults, in case something
+ // important was deleted from the user prefs
+ try {
+ prefs.load(BaseNoGui.getLibStream("preferences.txt"));
+ } catch (IOException e) {
+ BaseNoGui.showError(null, _("Could not read default settings.\n" +
+ "You'll need to reinstall Arduino."), e);
+ }
+
+ // set some runtime constants (not saved on preferences file)
+ File hardwareFolder = BaseNoGui.getHardwareFolder();
+ prefs.put("runtime.ide.path", hardwareFolder.getParentFile().getAbsolutePath());
+ prefs.put("runtime.ide.version", "" + BaseNoGui.REVISION);
+
+ // clone the hash table
+ defaults = new PreferencesMap(prefs);
+
+ if (preferencesFile.exists()) {
+ // load the previous preferences file
+ try {
+ prefs.load(preferencesFile);
+ } catch (IOException ex) {
+ BaseNoGui.showError(_("Error reading preferences"),
+ I18n.format(_("Error reading the preferences file. "
+ + "Please delete (or move)\n"
+ + "{0} and restart Arduino."),
+ preferencesFile.getAbsolutePath()), ex);
+ }
+ }
+
+ // load the I18n module for internationalization
+ try {
+ I18n.init(get("editor.languages.current"));
+ } catch (MissingResourceException e) {
+ I18n.init("en");
+ set("editor.languages.current", "en");
+ }
+
+ // set some other runtime constants (not saved on preferences file)
+ set("runtime.os", PConstants.platformNames[PApplet.platform]);
+
+ fixPreferences();
+ }
+
+ private static void fixPreferences() {
+ String baud = get("serial.debug_rate");
+ if ("14400".equals(baud) || "28800".equals(baud) || "38400".equals(baud)) {
+ set("serial.debug_rate", "9600");
+ }
+ }
+
+
+ static public String[] loadStrings(InputStream input) {
+ try {
+ BufferedReader reader =
+ new BufferedReader(new InputStreamReader(input, "UTF-8"));
+
+ String lines[] = new String[100];
+ int lineCount = 0;
+ String line = null;
+ while ((line = reader.readLine()) != null) {
+ if (lineCount == lines.length) {
+ String temp[] = new String[lineCount << 1];
+ System.arraycopy(lines, 0, temp, 0, lineCount);
+ lines = temp;
+ }
+ lines[lineCount++] = line;
+ }
+ reader.close();
+
+ if (lineCount == lines.length) {
+ return lines;
+ }
+
+ // resize array to appropriate amount for these lines
+ String output[] = new String[lineCount];
+ System.arraycopy(lines, 0, output, 0, lineCount);
+ return output;
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ //throw new RuntimeException("Error inside loadStrings()");
+ }
+ return null;
+ }
+
+
+ static protected void save() {
+ if (!doSave)
+ return;
+
+ // on startup, don't worry about it
+ // this is trying to update the prefs for who is open
+ // before Preferences.init() has been called.
+ if (preferencesFile == null) return;
+
+ // Fix for 0163 to properly use Unicode when writing preferences.txt
+ PrintWriter writer = PApplet.createWriter(preferencesFile);
+
+ String[] keys = prefs.keySet().toArray(new String[0]);
+ Arrays.sort(keys);
+ for (String key: keys) {
+ if (key.startsWith("runtime."))
+ continue;
+ writer.println(key + "=" + prefs.get(key));
+ }
+
+ writer.flush();
+ writer.close();
+ }
+
+
+ // .................................................................
+
+ static public String get(String attribute) {
+ return prefs.get(attribute);
+ }
+
+ static public String get(String attribute, String defaultValue) {
+ String value = get(attribute);
+ return (value == null) ? defaultValue : value;
+ }
+
+ public static boolean has(String key) {
+ return prefs.containsKey(key);
+ }
+
+ public static void remove(String key) {
+ prefs.remove(key);
+ }
+
+ static public String getDefault(String attribute) {
+ return defaults.get(attribute);
+ }
+
+
+ static public void set(String attribute, String value) {
+ prefs.put(attribute, value);
+ }
+
+
+ static public void unset(String attribute) {
+ prefs.remove(attribute);
+ }
+
+
+ static public boolean getBoolean(String attribute) {
+ return prefs.getBoolean(attribute);
+ }
+
+
+ static public void setBoolean(String attribute, boolean value) {
+ prefs.putBoolean(attribute, value);
+ }
+
+
+ static public int getInteger(String attribute) {
+ return Integer.parseInt(get(attribute));
+ }
+
+
+ static public void setInteger(String key, int value) {
+ set(key, String.valueOf(value));
+ }
+
+ // get a copy of the Preferences
+ static public PreferencesMap getMap()
+ {
+ return new PreferencesMap(prefs);
+ }
+
+ // Decide wether changed preferences will be saved. When value is
+ // false, Preferences.save becomes a no-op.
+ static public void setDoSave(boolean value)
+ {
+ doSave = value;
+ }
+}
diff --git a/app/src/processing/app/Serial.java b/arduino-core/src/processing/app/Serial.java
similarity index 92%
rename from app/src/processing/app/Serial.java
rename to arduino-core/src/processing/app/Serial.java
index b8acc461506..fdff1d5750f 100644
--- a/app/src/processing/app/Serial.java
+++ b/arduino-core/src/processing/app/Serial.java
@@ -63,40 +63,40 @@ public class Serial implements SerialPortEventListener {
MessageConsumer consumer;
public Serial(boolean monitor) throws SerialException {
- this(Preferences.get("serial.port"),
- Preferences.getInteger("serial.debug_rate"),
- Preferences.get("serial.parity").charAt(0),
- Preferences.getInteger("serial.databits"),
- new Float(Preferences.get("serial.stopbits")).floatValue());
+ this(PreferencesData.get("serial.port"),
+ PreferencesData.getInteger("serial.debug_rate"),
+ PreferencesData.get("serial.parity").charAt(0),
+ PreferencesData.getInteger("serial.databits"),
+ new Float(PreferencesData.get("serial.stopbits")).floatValue());
this.monitor = monitor;
}
public Serial() throws SerialException {
- this(Preferences.get("serial.port"),
- Preferences.getInteger("serial.debug_rate"),
- Preferences.get("serial.parity").charAt(0),
- Preferences.getInteger("serial.databits"),
- new Float(Preferences.get("serial.stopbits")).floatValue());
+ this(PreferencesData.get("serial.port"),
+ PreferencesData.getInteger("serial.debug_rate"),
+ PreferencesData.get("serial.parity").charAt(0),
+ PreferencesData.getInteger("serial.databits"),
+ new Float(PreferencesData.get("serial.stopbits")).floatValue());
}
public Serial(int irate) throws SerialException {
- this(Preferences.get("serial.port"), irate,
- Preferences.get("serial.parity").charAt(0),
- Preferences.getInteger("serial.databits"),
- new Float(Preferences.get("serial.stopbits")).floatValue());
+ this(PreferencesData.get("serial.port"), irate,
+ PreferencesData.get("serial.parity").charAt(0),
+ PreferencesData.getInteger("serial.databits"),
+ new Float(PreferencesData.get("serial.stopbits")).floatValue());
}
public Serial(String iname, int irate) throws SerialException {
- this(iname, irate, Preferences.get("serial.parity").charAt(0),
- Preferences.getInteger("serial.databits"),
- new Float(Preferences.get("serial.stopbits")).floatValue());
+ this(iname, irate, PreferencesData.get("serial.parity").charAt(0),
+ PreferencesData.getInteger("serial.databits"),
+ new Float(PreferencesData.get("serial.stopbits")).floatValue());
}
public Serial(String iname) throws SerialException {
- this(iname, Preferences.getInteger("serial.debug_rate"),
- Preferences.get("serial.parity").charAt(0),
- Preferences.getInteger("serial.databits"),
- new Float(Preferences.get("serial.stopbits")).floatValue());
+ this(iname, PreferencesData.getInteger("serial.debug_rate"),
+ PreferencesData.get("serial.parity").charAt(0),
+ PreferencesData.getInteger("serial.databits"),
+ new Float(PreferencesData.get("serial.stopbits")).floatValue());
}
public static boolean touchPort(String iname, int irate) throws SerialException {
diff --git a/app/src/processing/app/SerialException.java b/arduino-core/src/processing/app/SerialException.java
similarity index 97%
rename from app/src/processing/app/SerialException.java
rename to arduino-core/src/processing/app/SerialException.java
index d47e6018942..7fbc3e7ad03 100644
--- a/app/src/processing/app/SerialException.java
+++ b/arduino-core/src/processing/app/SerialException.java
@@ -22,6 +22,7 @@
import java.io.IOException;
+@SuppressWarnings("serial")
public class SerialException extends IOException {
public SerialException() {
super();
diff --git a/app/src/processing/app/SerialNotFoundException.java b/arduino-core/src/processing/app/SerialNotFoundException.java
similarity index 94%
rename from app/src/processing/app/SerialNotFoundException.java
rename to arduino-core/src/processing/app/SerialNotFoundException.java
index a3ab755b8a6..d8660c11000 100644
--- a/app/src/processing/app/SerialNotFoundException.java
+++ b/arduino-core/src/processing/app/SerialNotFoundException.java
@@ -1,5 +1,3 @@
-/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
-
/*
Copyright (c) 2007 David A. Mellis
@@ -20,6 +18,7 @@
package processing.app;
+@SuppressWarnings("serial")
public class SerialNotFoundException extends SerialException {
public SerialNotFoundException() {
super();
diff --git a/app/src/processing/app/SerialPortList.java b/arduino-core/src/processing/app/SerialPortList.java
similarity index 100%
rename from app/src/processing/app/SerialPortList.java
rename to arduino-core/src/processing/app/SerialPortList.java
diff --git a/app/src/processing/app/SketchCode.java b/arduino-core/src/processing/app/SketchCode.java
similarity index 66%
rename from app/src/processing/app/SketchCode.java
rename to arduino-core/src/processing/app/SketchCode.java
index 096d37875eb..a8f2c16f1cd 100644
--- a/app/src/processing/app/SketchCode.java
+++ b/arduino-core/src/processing/app/SketchCode.java
@@ -1,5 +1,3 @@
-/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
-
/*
SketchCode - data class for a single file inside a sketch
Part of the Processing project - http://processing.org
@@ -25,54 +23,44 @@
package processing.app;
import java.io.*;
-
-import javax.swing.text.Document;
+import java.util.List;
+import java.util.Arrays;
import static processing.app.I18n._;
-
+import processing.app.helpers.FileUtils;
/**
* Represents a single tab of a sketch.
*/
public class SketchCode {
+
/** Pretty name (no extension), not the full file name */
private String prettyName;
/** File object for where this code is located */
private File file;
- /** Extension for this file (no dots, and in lowercase). */
- private String extension;
-
/** Text of the program text for this tab */
private String program;
- /** Document object for this tab. Currently this is a SyntaxDocument. */
- private Document document;
-
- /**
- * Undo Manager for this tab, each tab keeps track of their own
- * Editor.undo will be set to this object when this code is the tab
- * that's currently the front.
- */
- private LastUndoableEditAwareUndoManager undo = new LastUndoableEditAwareUndoManager();
-
- // saved positions from last time this tab was used
- private int selectionStart;
- private int selectionStop;
- private int scrollPosition;
-
private boolean modified;
- /** name of .java file after preproc */
-// private String preprocName;
/** where this code starts relative to the concat'd code */
private int preprocOffset;
+ private Object metadata;
+
+ public SketchCode(File file) {
+ init(file, null);
+ }
+
+ public SketchCode(File file, Object metadata) {
+ init(file, metadata);
+ }
- public SketchCode(File file, String extension) {
+ private void init(File file, Object metadata) {
this.file = file;
- this.extension = extension;
+ this.metadata = metadata;
makePrettyName();
@@ -125,11 +113,10 @@ public boolean accept(File pathname) {
}
- protected boolean renameTo(File what, String ext) {
+ protected boolean renameTo(File what) {
boolean success = file.renameTo(what);
if (success) {
file = what;
- extension = ext;
makePrettyName();
}
return success;
@@ -137,7 +124,7 @@ protected boolean renameTo(File what, String ext) {
protected void copyTo(File dest) throws IOException {
- Base.saveFile(program, dest);
+ BaseNoGui.saveFile(program, dest);
}
@@ -151,13 +138,12 @@ public String getPrettyName() {
}
- public String getExtension() {
- return extension;
+ public boolean isExtension(String... extensions) {
+ return isExtension(Arrays.asList(extensions));
}
-
-
- public boolean isExtension(String what) {
- return extension.equals(what);
+
+ public boolean isExtension(List extensions) {
+ return FileUtils.hasExtension(file, extensions);
}
@@ -172,7 +158,7 @@ public void setProgram(String replacement) {
public int getLineCount() {
- return Base.countLines(program);
+ return BaseNoGui.countLines(program);
}
@@ -186,16 +172,6 @@ public boolean isModified() {
}
-// public void setPreprocName(String preprocName) {
-// this.preprocName = preprocName;
-// }
-//
-//
-// public String getPreprocName() {
-// return preprocName;
-// }
-
-
public void setPreprocOffset(int preprocOffset) {
this.preprocOffset = preprocOffset;
}
@@ -211,51 +187,6 @@ public void addPreprocOffset(int extra) {
}
- public Document getDocument() {
- return document;
- }
-
-
- public void setDocument(Document d) {
- document = d;
- }
-
-
- public LastUndoableEditAwareUndoManager getUndo() {
- return undo;
- }
-
-
- // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
-
-
- // TODO these could probably be handled better, since it's a general state
- // issue that's read/write from only one location in Editor (on tab switch.)
-
-
- public int getSelectionStart() {
- return selectionStart;
- }
-
-
- public int getSelectionStop() {
- return selectionStop;
- }
-
-
- public int getScrollPosition() {
- return scrollPosition;
- }
-
-
- protected void setState(String p, int start, int stop, int pos) {
- program = p;
- selectionStart = start;
- selectionStop = stop;
- scrollPosition = pos;
- }
-
-
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
@@ -263,7 +194,7 @@ protected void setState(String p, int start, int stop, int pos) {
* Load this piece of code from a file.
*/
public void load() throws IOException {
- program = Base.loadFile(file);
+ program = BaseNoGui.loadFile(file);
if (program.indexOf('\uFFFD') != -1) {
System.err.println(
@@ -291,7 +222,7 @@ public void save() throws IOException {
// TODO re-enable history
//history.record(s, SketchHistory.SAVE);
- Base.saveFile(program, file);
+ BaseNoGui.saveFile(program, file);
setModified(false);
}
@@ -300,6 +231,16 @@ public void save() throws IOException {
* Save this file to another location, used by Sketch.saveAs()
*/
public void saveAs(File newFile) throws IOException {
- Base.saveFile(program, newFile);
+ BaseNoGui.saveFile(program, newFile);
+ }
+
+
+ public Object getMetadata() {
+ return metadata;
+ }
+
+
+ public void setMetadata(Object metadata) {
+ this.metadata = metadata;
}
}
diff --git a/arduino-core/src/processing/app/SketchData.java b/arduino-core/src/processing/app/SketchData.java
new file mode 100644
index 00000000000..36f5a8fceab
--- /dev/null
+++ b/arduino-core/src/processing/app/SketchData.java
@@ -0,0 +1,266 @@
+package processing.app;
+
+import static processing.app.I18n._;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+public class SketchData {
+
+ /** main pde file for this sketch. */
+ private File primaryFile;
+
+ /** folder that contains this sketch */
+ private File folder;
+
+ /** data folder location for this sketch (may not exist yet) */
+ private File dataFolder;
+
+ /** code folder location for this sketch (may not exist yet) */
+ private File codeFolder;
+
+ /**
+ * Name of sketch, which is the name of main file (without .pde or .java
+ * extension)
+ */
+ private String name;
+
+ private List codes = new ArrayList();
+
+ private static final Comparator CODE_DOCS_COMPARATOR = new Comparator() {
+ @Override
+ public int compare(SketchCode x, SketchCode y) {
+ return x.getFileName().compareTo(y.getFileName());
+ }
+ };
+
+ SketchData(File file) {
+ primaryFile = file;
+
+ // get the name of the sketch by chopping .pde or .java
+ // off of the main file name
+ String mainFilename = primaryFile.getName();
+ int suffixLength = getDefaultExtension().length() + 1;
+ name = mainFilename.substring(0, mainFilename.length() - suffixLength);
+
+ folder = new File(file.getParent());
+ //System.out.println("sketch dir is " + folder);
+ }
+
+ static public File checkSketchFile(File file) {
+ // check to make sure that this .pde file is
+ // in a folder of the same name
+ String fileName = file.getName();
+ File parent = file.getParentFile();
+ String parentName = parent.getName();
+ String pdeName = parentName + ".pde";
+ File altPdeFile = new File(parent, pdeName);
+ String inoName = parentName + ".ino";
+ File altInoFile = new File(parent, inoName);
+
+ if (pdeName.equals(fileName) || inoName.equals(fileName))
+ return file;
+
+ if (altPdeFile.exists())
+ return altPdeFile;
+
+ if (altInoFile.exists())
+ return altInoFile;
+
+ return null;
+ }
+
+ /**
+ * Build the list of files.
+ *
+ * Generally this is only done once, rather than
+ * each time a change is made, because otherwise it gets to be
+ * a nightmare to keep track of what files went where, because
+ * not all the data will be saved to disk.
+ *
+ * This also gets called when the main sketch file is renamed,
+ * because the sketch has to be reloaded from a different folder.
+ *
+ * Another exception is when an external editor is in use,
+ * in which case the load happens each time "run" is hit.
+ */
+ protected void load() throws IOException {
+ codeFolder = new File(folder, "code");
+ dataFolder = new File(folder, "data");
+
+ // get list of files in the sketch folder
+ String list[] = folder.list();
+
+ // reset these because load() may be called after an
+ // external editor event. (fix for 0099)
+// codeDocs = new SketchCodeDoc[list.length];
+ clearCodeDocs();
+// data.setCodeDocs(codeDocs);
+
+ List extensions = getExtensions();
+
+ for (String filename : list) {
+ // Ignoring the dot prefix files is especially important to avoid files
+ // with the ._ prefix on Mac OS X. (You'll see this with Mac files on
+ // non-HFS drives, i.e. a thumb drive formatted FAT32.)
+ if (filename.startsWith(".")) continue;
+
+ // Don't let some wacko name a directory blah.pde or bling.java.
+ if (new File(folder, filename).isDirectory()) continue;
+
+ // figure out the name without any extension
+ String base = filename;
+ // now strip off the .pde and .java extensions
+ for (String extension : extensions) {
+ if (base.toLowerCase().endsWith("." + extension)) {
+ base = base.substring(0, base.length() - (extension.length() + 1));
+
+ // Don't allow people to use files with invalid names, since on load,
+ // it would be otherwise possible to sneak in nasty filenames. [0116]
+ if (BaseNoGui.isSanitaryName(base)) {
+ addCode(new SketchCode(new File(folder, filename)));
+ } else {
+ System.err.println(I18n.format("File name {0} is invalid: ignored", filename));
+ }
+ }
+ }
+ }
+
+ if (getCodeCount() == 0)
+ throw new IOException(_("No valid code files found"));
+
+ // move the main class to the first tab
+ // start at 1, if it's at zero, don't bother
+ for (SketchCode code : getCodes()) {
+ //if (code[i].file.getName().equals(mainFilename)) {
+ if (code.getFile().equals(primaryFile)) {
+ moveCodeToFront(code);
+ break;
+ }
+ }
+
+ // sort the entries at the top
+ sortCode();
+ }
+
+ public void save() throws IOException {
+ for (SketchCode code : getCodes()) {
+ if (code.isModified())
+ code.save();
+ }
+ }
+
+ public int getCodeCount() {
+ return codes.size();
+ }
+
+ public SketchCode[] getCodes() {
+ return codes.toArray(new SketchCode[0]);
+ }
+
+ /**
+ * Returns the default extension for this editor setup.
+ */
+ public String getDefaultExtension() {
+ return "ino";
+ }
+
+ /**
+ * Returns a String[] array of proper extensions.
+ */
+ public List getExtensions() {
+ return Arrays.asList("ino", "pde", "c", "cpp", "h");
+ }
+
+ /**
+ * Returns a file object for the primary .pde of this sketch.
+ */
+ public File getPrimaryFile() {
+ return primaryFile;
+ }
+
+ /**
+ * Returns path to the main .pde file for this sketch.
+ */
+ public String getMainFilePath() {
+ return primaryFile.getAbsolutePath();
+ //return code[0].file.getAbsolutePath();
+ }
+
+ public void addCode(SketchCode sketchCode) {
+ codes.add(sketchCode);
+ }
+
+ public void moveCodeToFront(SketchCode codeDoc) {
+ codes.remove(codeDoc);
+ codes.add(0, codeDoc);
+ }
+
+ protected void replaceCode(SketchCode newCode) {
+ for (SketchCode code : codes) {
+ if (code.getFileName().equals(newCode.getFileName())) {
+ codes.set(codes.indexOf(code), newCode);
+ return;
+ }
+ }
+ }
+
+ protected void sortCode() {
+ if (codes.size() < 2)
+ return;
+ SketchCode first = codes.remove(0);
+ Collections.sort(codes, CODE_DOCS_COMPARATOR);
+ codes.add(0, first);
+ }
+
+ public SketchCode getCode(int i) {
+ return codes.get(i);
+ }
+
+ protected void removeCode(SketchCode which) {
+ for (SketchCode code : codes) {
+ if (code == which) {
+ codes.remove(code);
+ return;
+ }
+ }
+ System.err.println("removeCode: internal error.. could not find code");
+ }
+
+ public int indexOfCode(SketchCode who) {
+ for (SketchCode code : codes) {
+ if (code == who)
+ return codes.indexOf(code);
+ }
+ return -1;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void clearCodeDocs() {
+ codes.clear();
+ }
+
+ public File getFolder() {
+ return folder;
+ }
+
+ public File getDataFolder() {
+ return dataFolder;
+ }
+
+ public File getCodeFolder() {
+ return codeFolder;
+ }
+}
diff --git a/app/src/processing/app/debug/Compiler.java b/arduino-core/src/processing/app/debug/Compiler.java
similarity index 63%
rename from app/src/processing/app/debug/Compiler.java
rename to arduino-core/src/processing/app/debug/Compiler.java
index 0f43840a303..2088bc5f182 100644
--- a/app/src/processing/app/debug/Compiler.java
+++ b/arduino-core/src/processing/app/debug/Compiler.java
@@ -27,69 +27,336 @@
import java.io.BufferedReader;
import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeSet;
-import processing.app.Base;
+import cc.arduino.packages.BoardPort;
+import cc.arduino.packages.Uploader;
+import cc.arduino.packages.UploaderFactory;
+
+import processing.app.BaseNoGui;
import processing.app.I18n;
-import processing.app.Preferences;
-import processing.app.Sketch;
+import processing.app.PreferencesData;
import processing.app.SketchCode;
+import processing.app.SketchData;
import processing.app.helpers.FileUtils;
import processing.app.helpers.PreferencesMap;
import processing.app.helpers.ProcessUtils;
import processing.app.helpers.StringReplacer;
import processing.app.helpers.filefilters.OnlyDirs;
import processing.app.packages.Library;
-import processing.core.PApplet;
+import processing.app.packages.LibraryList;
+import processing.app.preproc.PdePreprocessor;
+import processing.app.legacy.PApplet;
public class Compiler implements MessageConsumer {
- private Sketch sketch;
-
- private List objectFiles;
+ /**
+ * File inside the build directory that contains the build options
+ * used for the last build.
+ */
+ static final public String BUILD_PREFS_FILE = "buildprefs.txt";
+ private SketchData sketch;
private PreferencesMap prefs;
private boolean verbose;
+
+ private List objectFiles;
+
private boolean sketchIsCompiled;
- private String targetArch;
private RunnerException exception;
+ /**
+ * Listener interface for progress update on the GUI
+ */
+ public interface ProgressListener {
+ public void progress(int percent);
+ }
+
+ private ProgressListener progressListener;
+
+ static public String build(SketchData data, String buildPath, File tempBuildFolder, ProgressListener progListener, boolean verbose) throws RunnerException {
+ if (SketchData.checkSketchFile(data.getPrimaryFile()) == null)
+ BaseNoGui.showError(_("Bad file selected"),
+ _("Bad sketch primary file or bad sketck directory structure"), null);
+
+ String primaryClassName = data.getName() + ".cpp";
+ Compiler compiler = new Compiler(data, buildPath, primaryClassName);
+ File buildPrefsFile = new File(buildPath, BUILD_PREFS_FILE);
+ String newBuildPrefs = compiler.buildPrefsString();
+
+ // Do a forced cleanup (throw everything away) if the previous
+ // build settings do not match the previous ones
+ boolean prefsChanged = compiler.buildPreferencesChanged(buildPrefsFile, newBuildPrefs);
+ compiler.cleanup(prefsChanged, tempBuildFolder);
+
+ if (prefsChanged) {
+ try {
+ PrintWriter out = new PrintWriter(buildPrefsFile);
+ out.print(newBuildPrefs);
+ out.close();
+ } catch (IOException e) {
+ System.err.println(_("Could not write build preferences file"));
+ }
+ }
+
+ compiler.setProgressListener(progListener);
+
+ // compile the program. errors will happen as a RunnerException
+ // that will bubble up to whomever called build().
+ if (compiler.compile(verbose)) {
+ compiler.size(compiler.getBuildPreferences());
+ return primaryClassName;
+ }
+ return null;
+ }
+
+ static public Uploader getUploaderByPreferences(boolean noUploadPort) {
+ TargetPlatform target = BaseNoGui.getTargetPlatform();
+ String board = PreferencesData.get("board");
+
+ if (noUploadPort)
+ {
+ return new UploaderFactory().newUploader(target.getBoards().get(board), null, noUploadPort);
+ }
+ else
+ {
+ BoardPort boardPort = BaseNoGui.getDiscoveryManager().find(PreferencesData.get("serial.port"));
+ return new UploaderFactory().newUploader(target.getBoards().get(board), boardPort, noUploadPort);
+ }
+ }
+
+ static public boolean upload(SketchData data, Uploader uploader, String buildPath, String suggestedClassName, boolean usingProgrammer, boolean noUploadPort, List warningsAccumulator) throws Exception {
+
+ if (uploader == null)
+ uploader = getUploaderByPreferences(noUploadPort);
+
+ boolean success = false;
+
+ if (uploader.requiresAuthorization() && !PreferencesData.has(uploader.getAuthorizationKey())) {
+ BaseNoGui.showError(_("Authorization required"),
+ _("No athorization data found"), null);
+ }
+
+ boolean useNewWarningsAccumulator = false;
+ if (warningsAccumulator == null) {
+ warningsAccumulator = new LinkedList();
+ useNewWarningsAccumulator = true;
+ }
+
+ try {
+ success = uploader.uploadUsingPreferences(data.getFolder(), buildPath, suggestedClassName, usingProgrammer, warningsAccumulator);
+ } finally {
+ if (uploader.requiresAuthorization() && !success) {
+ PreferencesData.remove(uploader.getAuthorizationKey());
+ }
+ }
+
+ if (useNewWarningsAccumulator) {
+ for (String warning : warningsAccumulator) {
+ System.out.print(_("Warning"));
+ System.out.print(": ");
+ System.out.println(warning);
+ }
+ }
+
+ return success;
+ }
+
/**
* Create a new Compiler
* @param _sketch Sketch object to be compiled.
* @param _buildPath Where the temporary files live and will be built from.
* @param _primaryClassName the name of the combined sketch file w/ extension
*/
- public Compiler(Sketch _sketch, String _buildPath, String _primaryClassName)
+ public Compiler(SketchData _sketch, String _buildPath, String _primaryClassName)
throws RunnerException {
sketch = _sketch;
prefs = createBuildPreferences(_buildPath, _primaryClassName);
+
+ // Start with an empty progress listener
+ progressListener = new ProgressListener() {
+ @Override
+ public void progress(int percent) {
+ }
+ };
+ }
+
+ /**
+ * Check if the build preferences used on the previous build in
+ * buildPath match the ones given.
+ */
+ protected boolean buildPreferencesChanged(File buildPrefsFile, String newBuildPrefs) {
+ // No previous build, so no match
+ if (!buildPrefsFile.exists())
+ return true;
+
+ String previousPrefs;
+ try {
+ previousPrefs = FileUtils.readFileToString(buildPrefsFile);
+ } catch (IOException e) {
+ System.err.println(_("Could not read prevous build preferences file, rebuilding all"));
+ return true;
+ }
+
+ if (!previousPrefs.equals(newBuildPrefs)) {
+ System.out.println(_("Build options changed, rebuilding all"));
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Returns the build preferences of the given compiler as a string.
+ * Only includes build-specific preferences, to make sure unrelated
+ * preferences don't cause a rebuild (in particular preferences that
+ * change on every start, like last.ide.xxx.daterun). */
+ protected String buildPrefsString() {
+ PreferencesMap buildPrefs = getBuildPreferences();
+ String res = "";
+ SortedSet treeSet = new TreeSet(buildPrefs.keySet());
+ for (String k : treeSet) {
+ if (k.startsWith("build.") || k.startsWith("compiler.") || k.startsWith("recipes."))
+ res += k + " = " + buildPrefs.get(k) + "\n";
+ }
+ return res;
+ }
+
+ protected void setProgressListener(ProgressListener _progressListener) {
+ progressListener = (_progressListener == null ?
+ new ProgressListener() {
+ @Override
+ public void progress(int percent) {
+ }
+ } : _progressListener);
+ }
+
+ /**
+ * Cleanup temporary files used during a build/run.
+ */
+ protected void cleanup(boolean force, File tempBuildFolder) {
+ // if the java runtime is holding onto any files in the build dir, we
+ // won't be able to delete them, so we need to force a gc here
+ System.gc();
+
+ if (force) {
+ // delete the entire directory and all contents
+ // when we know something changed and all objects
+ // need to be recompiled, or if the board does not
+ // use setting build.dependency
+ //Base.removeDir(tempBuildFolder);
+
+ // note that we can't remove the builddir itself, otherwise
+ // the next time we start up, internal runs using Runner won't
+ // work because the build dir won't exist at startup, so the classloader
+ // will ignore the fact that that dir is in the CLASSPATH in run.sh
+ BaseNoGui.removeDescendants(tempBuildFolder);
+ } else {
+ // delete only stale source files, from the previously
+ // compiled sketch. This allows multiple windows to be
+ // used. Keep everything else, which might be reusable
+ if (tempBuildFolder.exists()) {
+ String files[] = tempBuildFolder.list();
+ for (String file : files) {
+ if (file.endsWith(".c") || file.endsWith(".cpp") || file.endsWith(".s")) {
+ File deleteMe = new File(tempBuildFolder, file);
+ if (!deleteMe.delete()) {
+ System.err.println("Could not delete " + deleteMe);
+ }
+ }
+ }
+ }
+ }
+
+ // Create a fresh applet folder (needed before preproc is run below)
+ //tempBuildFolder.mkdirs();
+ }
+
+ protected void size(PreferencesMap prefs) throws RunnerException {
+ String maxTextSizeString = prefs.get("upload.maximum_size");
+ String maxDataSizeString = prefs.get("upload.maximum_data_size");
+ if (maxTextSizeString == null)
+ return;
+ long maxTextSize = Integer.parseInt(maxTextSizeString);
+ long maxDataSize = -1;
+ if (maxDataSizeString != null)
+ maxDataSize = Integer.parseInt(maxDataSizeString);
+ Sizer sizer = new Sizer(prefs);
+ long[] sizes;
+ try {
+ sizes = sizer.computeSize();
+ } catch (RunnerException e) {
+ System.err.println(I18n.format(_("Couldn't determine program size: {0}"),
+ e.getMessage()));
+ return;
+ }
+
+ long textSize = sizes[0];
+ long dataSize = sizes[1];
+ System.out.println();
+ System.out.println(I18n
+ .format(_("Sketch uses {0} bytes ({2}%%) of program storage space. Maximum is {1} bytes."),
+ textSize, maxTextSize, textSize * 100 / maxTextSize));
+ if (dataSize >= 0) {
+ if (maxDataSize > 0) {
+ System.out
+ .println(I18n
+ .format(
+ _("Global variables use {0} bytes ({2}%%) of dynamic memory, leaving {3} bytes for local variables. Maximum is {1} bytes."),
+ dataSize, maxDataSize, dataSize * 100 / maxDataSize,
+ maxDataSize - dataSize));
+ } else {
+ System.out.println(I18n
+ .format(_("Global variables use {0} bytes of dynamic memory."), dataSize));
+ }
+ }
+
+ if (textSize > maxTextSize)
+ throw new RunnerException(
+ _("Sketch too big; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it."));
+
+ if (maxDataSize > 0 && dataSize > maxDataSize)
+ throw new RunnerException(
+ _("Not enough memory; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing your footprint."));
+
+ int warnDataPercentage = Integer.parseInt(prefs.get("build.warn_data_percentage"));
+ if (maxDataSize > 0 && dataSize > maxDataSize*warnDataPercentage/100)
+ System.err.println(_("Low memory available, stability problems may occur."));
}
/**
* Compile sketch.
+ * @param buildPath
*
* @return true if successful.
* @throws RunnerException Only if there's a problem. Only then.
*/
public boolean compile(boolean _verbose) throws RunnerException {
- verbose = _verbose || Preferences.getBoolean("build.verbose");
+ preprocess(prefs.get("build.path"));
+
+ verbose = _verbose || PreferencesData.getBoolean("build.verbose");
sketchIsCompiled = false;
objectFiles = new ArrayList();
// 0. include paths for core + all libraries
- sketch.setCompilingProgress(20);
+ progressListener.progress(20);
List includeFolders = new ArrayList();
includeFolders.add(prefs.getFile("build.core.path"));
if (prefs.getFile("build.variant.path") != null)
includeFolders.add(prefs.getFile("build.variant.path"));
- for (Library lib : sketch.getImportedLibraries()) {
+ for (Library lib : importedLibraries) {
if (verbose)
System.out.println(I18n
.format(_("Using library {0} in folder: {1} {2}"), lib.getName(),
@@ -100,12 +367,12 @@ public boolean compile(boolean _verbose) throws RunnerException {
System.out.println();
List archs = new ArrayList();
- archs.add(Base.getTargetPlatform().getId());
+ archs.add(BaseNoGui.getTargetPlatform().getId());
if (prefs.containsKey("architecture.override_check")) {
String[] overrides = prefs.get("architecture.override_check").split(",");
archs.addAll(Arrays.asList(overrides));
}
- for (Library lib : sketch.getImportedLibraries()) {
+ for (Library lib : importedLibraries) {
if (!lib.supportsArchitecture(archs)) {
System.err.println(I18n
.format(_("WARNING: library {0} claims to run on {1} "
@@ -117,33 +384,33 @@ public boolean compile(boolean _verbose) throws RunnerException {
}
// 1. compile the sketch (already in the buildPath)
- sketch.setCompilingProgress(30);
+ progressListener.progress(30);
compileSketch(includeFolders);
sketchIsCompiled = true;
// 2. compile the libraries, outputting .o files to: //
// Doesn't really use configPreferences
- sketch.setCompilingProgress(40);
+ progressListener.progress(40);
compileLibraries(includeFolders);
// 3. compile the core, outputting .o files to and then
// collecting them into the core.a library file.
- sketch.setCompilingProgress(50);
+ progressListener.progress(50);
compileCore();
// 4. link it all together into the .elf file
- sketch.setCompilingProgress(60);
+ progressListener.progress(60);
compileLink();
// 5. extract EEPROM data (from EEMEM directive) to .eep file.
- sketch.setCompilingProgress(70);
+ progressListener.progress(70);
compileEep();
// 6. build the .hex file
- sketch.setCompilingProgress(80);
+ progressListener.progress(80);
compileHex();
- sketch.setCompilingProgress(90);
+ progressListener.progress(90);
return true;
}
@@ -151,7 +418,7 @@ private PreferencesMap createBuildPreferences(String _buildPath,
String _primaryClassName)
throws RunnerException {
- if (Base.getBoardPreferences() == null) {
+ if (BaseNoGui.getBoardPreferences() == null) {
RunnerException re = new RunnerException(
_("No board selected; please choose a board from the Tools > Board menu."));
re.hideStackTrace();
@@ -159,14 +426,14 @@ private PreferencesMap createBuildPreferences(String _buildPath,
}
// Check if the board needs a platform from another package
- TargetPlatform targetPlatform = Base.getTargetPlatform();
+ TargetPlatform targetPlatform = BaseNoGui.getTargetPlatform();
TargetPlatform corePlatform = null;
- PreferencesMap boardPreferences = Base.getBoardPreferences();
+ PreferencesMap boardPreferences = BaseNoGui.getBoardPreferences();
String core = boardPreferences.get("build.core");
if (core.contains(":")) {
String[] split = core.split(":");
core = split[1];
- corePlatform = Base.getTargetPlatform(split[0], targetPlatform.getId());
+ corePlatform = BaseNoGui.getTargetPlatform(split[0], targetPlatform.getId());
if (corePlatform == null) {
RunnerException re = new RunnerException(I18n
.format(_("Selected board depends on '{0}' core (not installed)."),
@@ -178,11 +445,11 @@ private PreferencesMap createBuildPreferences(String _buildPath,
// Merge all the global preference configuration in order of priority
PreferencesMap p = new PreferencesMap();
- p.putAll(Preferences.getMap());
+ p.putAll(PreferencesData.getMap());
if (corePlatform != null)
p.putAll(corePlatform.getPreferences());
p.putAll(targetPlatform.getPreferences());
- p.putAll(Base.getBoardPreferences());
+ p.putAll(BaseNoGui.getBoardPreferences());
for (String k : p.keySet()) {
if (p.get(k) == null)
p.put(k, "");
@@ -190,8 +457,7 @@ private PreferencesMap createBuildPreferences(String _buildPath,
p.put("build.path", _buildPath);
p.put("build.project_name", _primaryClassName);
- targetArch = targetPlatform.getId();
- p.put("build.arch", targetArch.toUpperCase());
+ p.put("build.arch", targetPlatform.getId().toUpperCase());
// Platform.txt should define its own compiler.path. For
// compatibility with earlier 1.5 versions, we define a (ugly,
@@ -199,7 +465,7 @@ private PreferencesMap createBuildPreferences(String _buildPath,
// point.
if (!p.containsKey("compiler.path")) {
System.err.println(_("Third-party platform.txt does not define compiler.path. Please report this to the third-party hardware maintainer."));
- p.put("compiler.path", Base.getAvrBasePath());
+ p.put("compiler.path", BaseNoGui.getAvrBasePath());
}
// Core folder
@@ -224,7 +490,7 @@ private PreferencesMap createBuildPreferences(String _buildPath,
t = targetPlatform;
} else {
String[] split = variant.split(":", 2);
- t = Base.getTargetPlatform(split[0], targetPlatform.getId());
+ t = BaseNoGui.getTargetPlatform(split[0], targetPlatform.getId());
variant = split[1];
}
File variantFolder = new File(t.getFolder(), "variants");
@@ -356,8 +622,6 @@ private boolean isAlreadyCompiled(File src, File obj, File dep, Map includeFolders,
throws RunnerException {
String includes = prepareIncludes(includeFolders);
PreferencesMap dict = new PreferencesMap(prefs);
- dict.put("ide_version", "" + Base.REVISION);
+ dict.put("ide_version", "" + BaseNoGui.REVISION);
dict.put("includes", includes);
dict.put("source_file", sourceFile.getAbsolutePath());
dict.put("object_file", objectFile.getAbsolutePath());
@@ -577,7 +838,7 @@ private String[] getCommandCompilerC(List includeFolders,
String includes = prepareIncludes(includeFolders);
PreferencesMap dict = new PreferencesMap(prefs);
- dict.put("ide_version", "" + Base.REVISION);
+ dict.put("ide_version", "" + BaseNoGui.REVISION);
dict.put("includes", includes);
dict.put("source_file", sourceFile.getAbsolutePath());
dict.put("object_file", objectFile.getAbsolutePath());
@@ -596,7 +857,7 @@ private String[] getCommandCompilerCPP(List includeFolders,
String includes = prepareIncludes(includeFolders);
PreferencesMap dict = new PreferencesMap(prefs);
- dict.put("ide_version", "" + Base.REVISION);
+ dict.put("ide_version", "" + BaseNoGui.REVISION);
dict.put("includes", includes);
dict.put("source_file", sourceFile.getAbsolutePath());
dict.put("object_file", objectFile.getAbsolutePath());
@@ -656,7 +917,7 @@ void compileSketch(List includeFolders) throws RunnerException {
// 2. compile the libraries, outputting .o files to:
// //
void compileLibraries(List includeFolders) throws RunnerException {
- for (Library lib : sketch.getImportedLibraries()) {
+ for (Library lib : importedLibraries) {
compileLibrary(lib, includeFolders);
}
}
@@ -758,7 +1019,7 @@ void compileCore()
for (File file : coreObjectFiles) {
PreferencesMap dict = new PreferencesMap(prefs);
- dict.put("ide_version", "" + Base.REVISION);
+ dict.put("ide_version", "" + BaseNoGui.REVISION);
dict.put("archive_file", afile.getName());
dict.put("object_file", file.getAbsolutePath());
@@ -799,7 +1060,7 @@ void compileLink()
dict.put("compiler.c.elf.flags", flags);
dict.put("archive_file", "core.a");
dict.put("object_files", objectFileList);
- dict.put("ide_version", "" + Base.REVISION);
+ dict.put("ide_version", "" + BaseNoGui.REVISION);
String[] cmdArray;
try {
@@ -814,7 +1075,7 @@ void compileLink()
// 5. extract EEPROM data (from EEMEM directive) to .eep file.
void compileEep() throws RunnerException {
PreferencesMap dict = new PreferencesMap(prefs);
- dict.put("ide_version", "" + Base.REVISION);
+ dict.put("ide_version", "" + BaseNoGui.REVISION);
String[] cmdArray;
try {
@@ -829,7 +1090,7 @@ void compileEep() throws RunnerException {
// 6. build the .hex file
void compileHex() throws RunnerException {
PreferencesMap dict = new PreferencesMap(prefs);
- dict.put("ide_version", "" + Base.REVISION);
+ dict.put("ide_version", "" + BaseNoGui.REVISION);
String[] cmdArray;
try {
@@ -853,4 +1114,141 @@ private static String prepareIncludes(List includeFolders) {
public PreferencesMap getBuildPreferences() {
return prefs;
}
+
+ /**
+ * Build all the code for this sketch.
+ *
+ * In an advanced program, the returned class name could be different,
+ * which is why the className is set based on the return value.
+ * A compilation error will burp up a RunnerException.
+ *
+ * Setting purty to 'true' will cause exception line numbers to be incorrect.
+ * Unless you know the code compiles, you should first run the preprocessor
+ * with purty set to false to make sure there are no errors, then once
+ * successful, re-export with purty set to true.
+ *
+ * @param buildPath Location to copy all the .java files
+ * @return null if compilation failed, main class name if not
+ */
+ public void preprocess(String buildPath) throws RunnerException {
+ preprocess(buildPath, new PdePreprocessor());
+ }
+
+ public void preprocess(String buildPath, PdePreprocessor preprocessor) throws RunnerException {
+
+ // 1. concatenate all .pde files to the 'main' pde
+ // store line number for starting point of each code bit
+
+ StringBuffer bigCode = new StringBuffer();
+ int bigCount = 0;
+ for (SketchCode sc : sketch.getCodes()) {
+ if (sc.isExtension("ino") || sc.isExtension("pde")) {
+ sc.setPreprocOffset(bigCount);
+ // These #line directives help the compiler report errors with
+ // correct the filename and line number (issue 281 & 907)
+ bigCode.append("#line 1 \"" + sc.getFileName() + "\"\n");
+ bigCode.append(sc.getProgram());
+ bigCode.append('\n');
+ bigCount += sc.getLineCount();
+ }
+ }
+
+ // Note that the headerOffset isn't applied until compile and run, because
+ // it only applies to the code after it's been written to the .java file.
+ int headerOffset = 0;
+ try {
+ headerOffset = preprocessor.writePrefix(bigCode.toString());
+ } catch (FileNotFoundException fnfe) {
+ fnfe.printStackTrace();
+ String msg = _("Build folder disappeared or could not be written");
+ throw new RunnerException(msg);
+ }
+
+ // 2. run preproc on that code using the sugg class name
+ // to create a single .java file and write to buildpath
+
+ try {
+ // Output file
+ File streamFile = new File(buildPath, sketch.getName() + ".cpp");
+ FileOutputStream outputStream = new FileOutputStream(streamFile);
+ preprocessor.write(outputStream);
+ outputStream.close();
+ } catch (FileNotFoundException fnfe) {
+ fnfe.printStackTrace();
+ String msg = _("Build folder disappeared or could not be written");
+ throw new RunnerException(msg);
+ } catch (RunnerException pe) {
+ // RunnerExceptions are caught here and re-thrown, so that they don't
+ // get lost in the more general "Exception" handler below.
+ throw pe;
+
+ } catch (Exception ex) {
+ // TODO better method for handling this?
+ System.err.println(I18n.format(_("Uncaught exception type: {0}"), ex.getClass()));
+ ex.printStackTrace();
+ throw new RunnerException(ex.toString());
+ }
+
+ // grab the imports from the code just preproc'd
+
+ importedLibraries = new LibraryList();
+ for (String item : preprocessor.getExtraImports()) {
+ Library lib = BaseNoGui.importToLibraryTable.get(item);
+ if (lib != null && !importedLibraries.contains(lib)) {
+ importedLibraries.add(lib);
+ }
+ }
+
+ // 3. then loop over the code[] and save each .java file
+
+ for (SketchCode sc : sketch.getCodes()) {
+ if (sc.isExtension("c") || sc.isExtension("cpp") || sc.isExtension("h")) {
+ // no pre-processing services necessary for java files
+ // just write the the contents of 'program' to a .java file
+ // into the build directory. uses byte stream and reader/writer
+ // shtuff so that unicode bunk is properly handled
+ String filename = sc.getFileName(); //code[i].name + ".java";
+ try {
+ BaseNoGui.saveFile(sc.getProgram(), new File(buildPath, filename));
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new RunnerException(I18n.format(_("Problem moving {0} to the build folder"), filename));
+ }
+
+ } else if (sc.isExtension("ino") || sc.isExtension("pde")) {
+ // The compiler and runner will need this to have a proper offset
+ sc.addPreprocOffset(headerOffset);
+ }
+ }
+ }
+
+
+ /**
+ * List of library folders.
+ */
+ private LibraryList importedLibraries;
+
+ /**
+ * Map an error from a set of processed .java files back to its location
+ * in the actual sketch.
+ * @param message The error message.
+ * @param dotJavaFilename The .java file where the exception was found.
+ * @param dotJavaLine Line number of the .java file for the exception (0-indexed!)
+ * @return A RunnerException to be sent to the editor, or null if it wasn't
+ * possible to place the exception to the sketch code.
+ */
+ public RunnerException placeException(String message,
+ String dotJavaFilename,
+ int dotJavaLine) {
+ // Placing errors is simple, because we inserted #line directives
+ // into the preprocessed source. The compiler gives us correct
+ // the file name and line number. :-)
+ for (SketchCode code : sketch.getCodes()) {
+ if (dotJavaFilename.equals(code.getFileName())) {
+ return new RunnerException(message, sketch.indexOfCode(code), dotJavaLine);
+ }
+ }
+ return null;
+ }
+
}
diff --git a/app/src/processing/app/debug/MessageConsumer.java b/arduino-core/src/processing/app/debug/MessageConsumer.java
similarity index 100%
rename from app/src/processing/app/debug/MessageConsumer.java
rename to arduino-core/src/processing/app/debug/MessageConsumer.java
diff --git a/app/src/processing/app/debug/MessageSiphon.java b/arduino-core/src/processing/app/debug/MessageSiphon.java
similarity index 100%
rename from app/src/processing/app/debug/MessageSiphon.java
rename to arduino-core/src/processing/app/debug/MessageSiphon.java
diff --git a/app/src/processing/app/debug/RunnerException.java b/arduino-core/src/processing/app/debug/RunnerException.java
similarity index 100%
rename from app/src/processing/app/debug/RunnerException.java
rename to arduino-core/src/processing/app/debug/RunnerException.java
diff --git a/app/src/processing/app/debug/Sizer.java b/arduino-core/src/processing/app/debug/Sizer.java
similarity index 100%
rename from app/src/processing/app/debug/Sizer.java
rename to arduino-core/src/processing/app/debug/Sizer.java
diff --git a/app/src/processing/app/debug/TargetBoard.java b/arduino-core/src/processing/app/debug/TargetBoard.java
similarity index 100%
rename from app/src/processing/app/debug/TargetBoard.java
rename to arduino-core/src/processing/app/debug/TargetBoard.java
diff --git a/app/src/processing/app/debug/TargetPackage.java b/arduino-core/src/processing/app/debug/TargetPackage.java
similarity index 100%
rename from app/src/processing/app/debug/TargetPackage.java
rename to arduino-core/src/processing/app/debug/TargetPackage.java
diff --git a/app/src/processing/app/debug/TargetPlatform.java b/arduino-core/src/processing/app/debug/TargetPlatform.java
similarity index 100%
rename from app/src/processing/app/debug/TargetPlatform.java
rename to arduino-core/src/processing/app/debug/TargetPlatform.java
diff --git a/app/src/processing/app/debug/TargetPlatformException.java b/arduino-core/src/processing/app/debug/TargetPlatformException.java
similarity index 100%
rename from app/src/processing/app/debug/TargetPlatformException.java
rename to arduino-core/src/processing/app/debug/TargetPlatformException.java
diff --git a/arduino-core/src/processing/app/helpers/BasicUserNotifier.java b/arduino-core/src/processing/app/helpers/BasicUserNotifier.java
new file mode 100644
index 00000000000..f1e2b4d7b1f
--- /dev/null
+++ b/arduino-core/src/processing/app/helpers/BasicUserNotifier.java
@@ -0,0 +1,38 @@
+package processing.app.helpers;
+
+import static processing.app.I18n._;
+
+public class BasicUserNotifier extends UserNotifier {
+
+ /**
+ * Show an error message that's actually fatal to the program.
+ * This is an error that can't be recovered. Use showWarning()
+ * for errors that allow P5 to continue running.
+ */
+ public void showError(String title, String message, Throwable e, int exit_code) {
+ if (title == null) title = _("Error");
+
+ System.err.println(title + ": " + message);
+
+ if (e != null) e.printStackTrace();
+ System.exit(exit_code);
+ }
+
+ public void showMessage(String title, String message) {
+ if (title == null) title = _("Message");
+
+ System.out.println(title + ": " + message);
+ }
+
+ /**
+ * Non-fatal error message with optional stack trace side dish.
+ */
+ public void showWarning(String title, String message, Exception e) {
+ if (title == null) title = _("Warning");
+
+ System.out.println(title + ": " + message);
+
+ if (e != null) e.printStackTrace();
+ }
+
+}
diff --git a/arduino-core/src/processing/app/helpers/CommandlineParser.java b/arduino-core/src/processing/app/helpers/CommandlineParser.java
new file mode 100644
index 00000000000..f29e48a1db0
--- /dev/null
+++ b/arduino-core/src/processing/app/helpers/CommandlineParser.java
@@ -0,0 +1,283 @@
+package processing.app.helpers;
+
+import static processing.app.I18n._;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import processing.app.BaseNoGui;
+import processing.app.I18n;
+import processing.app.PreferencesData;
+import processing.app.debug.TargetBoard;
+import processing.app.debug.TargetPackage;
+import processing.app.debug.TargetPlatform;
+import processing.app.legacy.PApplet;
+
+public class CommandlineParser {
+
+ protected static enum ACTION { GUI, NOOP, VERIFY, UPLOAD, GET_PREF };
+
+ private ACTION action = ACTION.GUI;
+ private boolean doVerboseBuild = false;
+ private boolean doVerboseUpload = false;
+ private boolean doUseProgrammer = false;
+ private boolean noUploadPort = false;
+ private boolean forceSavePrefs = false;
+ private String getPref = null;
+ private List filenames = new LinkedList();
+
+ public static CommandlineParser newCommandlineParser(String[] args) {
+ return new CommandlineParser(args);
+ }
+
+ private CommandlineParser(String[] args) {
+ parseArguments(args);
+ checkAction();
+ }
+
+ private void parseArguments(String[] args) {
+ // Map of possible actions and corresponding options
+ final Map actions = new HashMap();
+ actions.put("--verify", ACTION.VERIFY);
+ actions.put("--upload", ACTION.UPLOAD);
+ actions.put("--get-pref", ACTION.GET_PREF);
+
+ // Check if any files were passed in on the command line
+ for (int i = 0; i < args.length; i++) {
+ ACTION a = actions.get(args[i]);
+ if (a != null) {
+ if (action != ACTION.GUI && action != ACTION.NOOP) {
+ String[] valid = actions.keySet().toArray(new String[0]);
+ String mess = I18n.format(_("Can only pass one of: {0}"), PApplet.join(valid, ", "));
+ BaseNoGui.showError(null, mess, 3);
+ }
+ if (a == ACTION.GET_PREF) {
+ i++;
+ if (i >= args.length)
+ BaseNoGui.showError(null, _("Argument required for --get-pref"), 3);
+ getPref = args[i];
+ }
+ action = a;
+ continue;
+ }
+ if (args[i].equals("--verbose") || args[i].equals("-v")) {
+ doVerboseBuild = true;
+ doVerboseUpload = true;
+ if (action == ACTION.GUI)
+ action = ACTION.NOOP;
+ continue;
+ }
+ if (args[i].equals("--verbose-build")) {
+ doVerboseBuild = true;
+ if (action == ACTION.GUI)
+ action = ACTION.NOOP;
+ continue;
+ }
+ if (args[i].equals("--verbose-upload")) {
+ doVerboseUpload = true;
+ if (action == ACTION.GUI)
+ action = ACTION.NOOP;
+ continue;
+ }
+ if (args[i].equals("--useprogrammer")) {
+ doUseProgrammer = true;
+ if (action == ACTION.GUI)
+ action = ACTION.NOOP;
+ continue;
+ }
+ if (args[i].equals("--nouploadport")) {
+ noUploadPort = true;
+ if (action == ACTION.GUI)
+ action = ACTION.NOOP;
+ continue;
+ }
+ if (args[i].equals("--board")) {
+ i++;
+ if (i >= args.length)
+ BaseNoGui.showError(null, _("Argument required for --board"), 3);
+ processBoardArgument(args[i]);
+ if (action == ACTION.GUI)
+ action = ACTION.NOOP;
+ continue;
+ }
+ if (args[i].equals("--port")) {
+ i++;
+ if (i >= args.length)
+ BaseNoGui.showError(null, _("Argument required for --port"), 3);
+ BaseNoGui.selectSerialPort(args[i]);
+ if (action == ACTION.GUI)
+ action = ACTION.NOOP;
+ continue;
+ }
+ if (args[i].equals("--curdir")) {
+ i++;
+ if (i >= args.length)
+ BaseNoGui.showError(null, _("Argument required for --curdir"), 3);
+ // Argument should be already processed by Base.main(...)
+ continue;
+ }
+ if (args[i].equals("--buildpath")) {
+ i++;
+ if (i >= args.length) {
+ BaseNoGui.showError(null, "Argument required for --buildpath", 3);
+ }
+ File buildFolder = new File(args[i]);
+ if (!buildFolder.exists()) {
+ BaseNoGui.showError(null, "The build path doesn't exist", 3);
+ }
+ if (!buildFolder.isDirectory()) {
+ BaseNoGui.showError(null, "The build path is not a folder", 3);
+ }
+ BaseNoGui.setBuildFolder(buildFolder);
+ continue;
+ }
+ if (args[i].equals("--pref")) {
+ i++;
+ if (i >= args.length)
+ BaseNoGui.showError(null, _("Argument required for --pref"), 3);
+ processPrefArgument(args[i]);
+ if (action == ACTION.GUI)
+ action = ACTION.NOOP;
+ continue;
+ }
+ if (args[i].equals("--save-prefs")) {
+ forceSavePrefs = true;
+ continue;
+ }
+ if (args[i].equals("--preferences-file")) {
+ i++;
+ if (i >= args.length)
+ BaseNoGui.showError(null, _("Argument required for --preferences-file"), 3);
+ // Argument should be already processed by Base.main(...)
+ continue;
+ }
+ if (args[i].startsWith("--"))
+ BaseNoGui.showError(null, I18n.format(_("unknown option: {0}"), args[i]), 3);
+
+ filenames.add(args[i]);
+ }
+ }
+
+ private void checkAction() {
+ if ((action == ACTION.UPLOAD || action == ACTION.VERIFY) && filenames.size() != 1)
+ BaseNoGui.showError(null, _("Must specify exactly one sketch file"), 3);
+
+ if ((action == ACTION.NOOP || action == ACTION.GET_PREF) && filenames.size() != 0)
+ BaseNoGui.showError(null, _("Cannot specify any sketch files"), 3);
+
+ if ((action != ACTION.UPLOAD && action != ACTION.VERIFY) && (doVerboseBuild || doVerboseUpload))
+ BaseNoGui.showError(null, _("--verbose, --verbose-upload and --verbose-build can only be used together with --verify or --upload"), 3);
+ }
+
+ private void processBoardArgument(String selectBoard) {
+ // No board selected? Nothing to do
+ if (selectBoard == null)
+ return;
+
+ String[] split = selectBoard.split(":", 4);
+
+ if (split.length < 3) {
+ BaseNoGui.showError(null, I18n.format(_("{0}: Invalid board name, it should be of the form \"package:arch:board\" or \"package:arch:board:options\""), selectBoard), 3);
+ }
+
+ TargetPackage targetPackage = BaseNoGui.getTargetPackage(split[0]);
+ if (targetPackage == null) {
+ BaseNoGui.showError(null, I18n.format(_("{0}: Unknown package"), split[0]), 3);
+ }
+
+ TargetPlatform targetPlatform = targetPackage.get(split[1]);
+ if (targetPlatform == null) {
+ BaseNoGui.showError(null, I18n.format(_("{0}: Unknown architecture"), split[1]), 3);
+ }
+
+ TargetBoard targetBoard = targetPlatform.getBoard(split[2]);
+ if (targetBoard == null) {
+ BaseNoGui.showError(null, I18n.format(_("{0}: Unknown board"), split[2]), 3);
+ }
+
+ BaseNoGui.selectBoard(targetBoard);
+
+ if (split.length > 3) {
+ String[] options = split[3].split(",");
+ for (String option : options) {
+ String[] keyValue = option.split("=", 2);
+
+ if (keyValue.length != 2)
+ BaseNoGui.showError(null, I18n.format(_("{0}: Invalid option, should be of the form \"name=value\""), option, targetBoard.getId()), 3);
+ String key = keyValue[0].trim();
+ String value = keyValue[1].trim();
+
+ if (!targetBoard.hasMenu(key))
+ BaseNoGui.showError(null, I18n.format(_("{0}: Invalid option for board \"{1}\""), key, targetBoard.getId()), 3);
+ if (targetBoard.getMenuLabel(key, value) == null)
+ BaseNoGui.showError(null, I18n.format(_("{0}: Invalid option for \"{1}\" option for board \"{2}\""), value, key, targetBoard.getId()), 3);
+
+ PreferencesData.set("custom_" + key, targetBoard.getId() + "_" + value);
+ }
+ }
+ }
+
+ private void processPrefArgument(String arg) {
+ String[] split = arg.split("=", 2);
+ if (split.length != 2 || split[0].isEmpty())
+ BaseNoGui.showError(null, I18n.format(_("{0}: Invalid argument to --pref, should be of the form \"pref=value\""), arg), 3);
+
+ PreferencesData.set(split[0], split[1]);
+ }
+
+ public boolean isDoVerboseBuild() {
+ return doVerboseBuild;
+ }
+
+ public boolean isDoVerboseUpload() {
+ return doVerboseUpload;
+ }
+
+ public boolean isForceSavePrefs() {
+ return forceSavePrefs;
+ }
+
+ public String getGetPref() {
+ return getPref;
+ }
+
+ public List getFilenames() {
+ return filenames;
+ }
+
+ public boolean isGetPrefMode() {
+ return action == ACTION.GET_PREF;
+ }
+
+ public boolean isGuiMode() {
+ return action == ACTION.GUI;
+ }
+
+ public boolean isNoOpMode() {
+ return action == ACTION.NOOP;
+ }
+
+ public boolean isUploadMode() {
+ return action == ACTION.UPLOAD;
+ }
+
+ public boolean isVerifyMode() {
+ return action == ACTION.VERIFY;
+ }
+
+ public boolean isVerifyOrUploadMode() {
+ return isVerifyMode() || isUploadMode();
+ }
+
+ public boolean isDoUseProgrammer() {
+ return doUseProgrammer;
+ }
+
+ public boolean isNoUploadPort() {
+ return noUploadPort;
+ }
+
+}
diff --git a/app/src/processing/app/helpers/FileUtils.java b/arduino-core/src/processing/app/helpers/FileUtils.java
similarity index 100%
rename from app/src/processing/app/helpers/FileUtils.java
rename to arduino-core/src/processing/app/helpers/FileUtils.java
diff --git a/app/src/processing/app/helpers/NetUtils.java b/arduino-core/src/processing/app/helpers/NetUtils.java
similarity index 100%
rename from app/src/processing/app/helpers/NetUtils.java
rename to arduino-core/src/processing/app/helpers/NetUtils.java
diff --git a/arduino-core/src/processing/app/helpers/OSUtils.java b/arduino-core/src/processing/app/helpers/OSUtils.java
new file mode 100644
index 00000000000..5efb77e29b3
--- /dev/null
+++ b/arduino-core/src/processing/app/helpers/OSUtils.java
@@ -0,0 +1,29 @@
+package processing.app.helpers;
+
+public class OSUtils {
+
+ /**
+ * returns true if running on windows.
+ */
+ static public boolean isWindows() {
+ //return PApplet.platform == PConstants.WINDOWS;
+ return System.getProperty("os.name").indexOf("Windows") != -1;
+ }
+
+ /**
+ * true if running on linux.
+ */
+ static public boolean isLinux() {
+ //return PApplet.platform == PConstants.LINUX;
+ return System.getProperty("os.name").indexOf("Linux") != -1;
+ }
+
+ /**
+ * returns true if Processing is running on a Mac OS X machine.
+ */
+ static public boolean isMacOS() {
+ //return PApplet.platform == PConstants.MACOSX;
+ return System.getProperty("os.name").indexOf("Mac") != -1;
+ }
+
+}
diff --git a/arduino-core/src/processing/app/helpers/PreferencesHelper.java b/arduino-core/src/processing/app/helpers/PreferencesHelper.java
new file mode 100644
index 00000000000..0e096e7f665
--- /dev/null
+++ b/arduino-core/src/processing/app/helpers/PreferencesHelper.java
@@ -0,0 +1,103 @@
+package processing.app.helpers;
+
+import java.awt.Color;
+import java.awt.Font;
+
+public abstract class PreferencesHelper {
+
+// /**
+// * Create a Color with the value of the specified key. The format of the color
+// * should be an hexadecimal number of 6 digit, eventually prefixed with a '#'.
+// *
+// * @param name
+// * @return A Color object or null if the key is not found or the format
+// * is wrong
+// */
+// static public Color getColor(PreferencesMap prefs, String name) {
+// Color parsed = parseColor(prefs.get(name));
+// if (parsed != null)
+// return parsed;
+// return Color.GRAY; // set a default
+// }
+//
+//
+// static public void setColor(PreferencesMap prefs, String attr, Color what) {
+// putColor(prefs, attr, what);
+// }
+//
+//
+// static public Font getFontWithDefault(PreferencesMap prefs, PreferencesMap defaults, String attr) {
+// Font font = getFont(prefs, attr);
+// if (font == null) {
+// String value = defaults.get(attr);
+// prefs.put(attr, value);
+// font = getFont(prefs, attr);
+// }
+// return font;
+// }
+//
+// static public SyntaxStyle getStyle(PreferencesMap prefs, String what) {
+// String str = prefs.get("editor." + what + ".style");
+//
+// StringTokenizer st = new StringTokenizer(str, ",");
+//
+// String s = st.nextToken();
+// if (s.indexOf("#") == 0) s = s.substring(1);
+// Color color = Color.DARK_GRAY;
+// try {
+// color = new Color(Integer.parseInt(s, 16));
+// } catch (Exception e) { }
+//
+// s = st.nextToken();
+// boolean bold = (s.indexOf("bold") != -1);
+// boolean italic = (s.indexOf("italic") != -1);
+// boolean underlined = (s.indexOf("underlined") != -1);
+//
+// return new SyntaxStyle(color, italic, bold, underlined);
+// }
+
+ /**
+ * Set the value of the specified key based on the Color passed as parameter.
+ *
+ * @param attr
+ * @param color
+ */
+ public static void putColor(PreferencesMap prefs, String attr, Color color) {
+ prefs.put(attr, "#" + String.format("%06x", color.getRGB() & 0xffffff));
+ }
+
+ public static Color parseColor(String v) {
+ try {
+ if (v.indexOf("#") == 0)
+ v = v.substring(1);
+ return new Color(Integer.parseInt(v, 16));
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ public static Font getFont(PreferencesMap prefs, String key) {
+ String value = prefs.get(key);
+ if (value == null)
+ return null;
+ String[] split = value.split(",");
+ if (split.length != 3)
+ return null;
+
+ String name = split[0];
+ int style = Font.PLAIN;
+ if (split[1].contains("bold"))
+ style |= Font.BOLD;
+ if (split[1].contains("italic"))
+ style |= Font.ITALIC;
+ int size;
+ try {
+ // ParseDouble handle numbers with decimals too
+ size = (int) Double.parseDouble(split[2]);
+ } catch (NumberFormatException e) {
+ // for wrong formatted size pick the default
+ size = 12;
+ }
+ return new Font(name, style, size);
+ }
+}
diff --git a/app/src/processing/app/helpers/PreferencesMap.java b/arduino-core/src/processing/app/helpers/PreferencesMap.java
similarity index 87%
rename from app/src/processing/app/helpers/PreferencesMap.java
rename to arduino-core/src/processing/app/helpers/PreferencesMap.java
index b4f60848a83..b40b8c97a59 100644
--- a/app/src/processing/app/helpers/PreferencesMap.java
+++ b/arduino-core/src/processing/app/helpers/PreferencesMap.java
@@ -3,7 +3,7 @@
to handle preferences.
Part of the Arduino project - http://www.arduino.cc/
- Copyright (c) 2011 Cristian Maglie
+ Copyright (c) 2014 Cristian Maglie
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -27,14 +27,11 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
import java.util.Map;
-import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
-import processing.app.Base;
-import processing.core.PApplet;
+import processing.app.legacy.PApplet;
@SuppressWarnings("serial")
public class PreferencesMap extends LinkedHashMap {
@@ -107,9 +104,9 @@ public void load(InputStream input) throws IOException {
String key = line.substring(0, equals).trim();
String value = line.substring(equals + 1).trim();
- key = processPlatformSuffix(key, ".linux", Base.isLinux());
- key = processPlatformSuffix(key, ".windows", Base.isWindows());
- key = processPlatformSuffix(key, ".macosx", Base.isMacOS());
+ key = processPlatformSuffix(key, ".linux", OSUtils.isLinux());
+ key = processPlatformSuffix(key, ".windows", OSUtils.isWindows());
+ key = processPlatformSuffix(key, ".macosx", OSUtils.isMacOS());
if (key != null)
put(key, value);
@@ -296,4 +293,30 @@ public File getFile(String key, String subFolder) {
return null;
return new File(file, subFolder);
}
+
+ /**
+ * Return the value of the specified key as boolean.
+ *
+ * @param key
+ * @return true if the value of the key is the string "true" (case
+ * insensitive compared), false in any other case
+ */
+ public boolean getBoolean(String key) {
+ return new Boolean(get(key));
+ }
+
+ /**
+ * Sets the value of the specified key to the string "true" or
+ * "false" based on value of the boolean parameter
+ *
+ * @param key
+ * @param value
+ * @return true if the previous value of the key was the string "true"
+ * (case insensitive compared), false in any other case
+ */
+ public boolean putBoolean(String key, boolean value) {
+ String prev = put(key, value ? "true" : "false");
+ return new Boolean(prev);
+ }
+
}
diff --git a/app/src/processing/app/helpers/PreferencesMapException.java b/arduino-core/src/processing/app/helpers/PreferencesMapException.java
similarity index 100%
rename from app/src/processing/app/helpers/PreferencesMapException.java
rename to arduino-core/src/processing/app/helpers/PreferencesMapException.java
diff --git a/app/src/processing/app/helpers/ProcessUtils.java b/arduino-core/src/processing/app/helpers/ProcessUtils.java
similarity index 94%
rename from app/src/processing/app/helpers/ProcessUtils.java
rename to arduino-core/src/processing/app/helpers/ProcessUtils.java
index d378f991d4b..1fb74cc7994 100644
--- a/app/src/processing/app/helpers/ProcessUtils.java
+++ b/arduino-core/src/processing/app/helpers/ProcessUtils.java
@@ -1,7 +1,5 @@
package processing.app.helpers;
-import processing.app.Base;
-
import java.io.IOException;
import java.util.Map;
@@ -9,7 +7,7 @@ public class ProcessUtils {
public static Process exec(String[] command) throws IOException {
// No problems on linux and mac
- if (!Base.isWindows()) {
+ if (!OSUtils.isWindows()) {
return Runtime.getRuntime().exec(command);
}
diff --git a/app/src/processing/app/helpers/StringReplacer.java b/arduino-core/src/processing/app/helpers/StringReplacer.java
similarity index 100%
rename from app/src/processing/app/helpers/StringReplacer.java
rename to arduino-core/src/processing/app/helpers/StringReplacer.java
diff --git a/app/src/processing/app/helpers/StringUtils.java b/arduino-core/src/processing/app/helpers/StringUtils.java
similarity index 100%
rename from app/src/processing/app/helpers/StringUtils.java
rename to arduino-core/src/processing/app/helpers/StringUtils.java
diff --git a/arduino-core/src/processing/app/helpers/UserNotifier.java b/arduino-core/src/processing/app/helpers/UserNotifier.java
new file mode 100644
index 00000000000..dc5bae14eee
--- /dev/null
+++ b/arduino-core/src/processing/app/helpers/UserNotifier.java
@@ -0,0 +1,19 @@
+package processing.app.helpers;
+
+public abstract class UserNotifier {
+
+ public void showError(String title, String message, int exit_code) {
+ showError(title, message, null, exit_code);
+ }
+
+ public void showError(String title, String message, Throwable e) {
+ showError(title, message, e, 1);
+ }
+
+ public abstract void showError(String title, String message, Throwable e, int exit_code);
+
+ public abstract void showMessage(String title, String message);
+
+ public abstract void showWarning(String title, String message, Exception e);
+
+}
diff --git a/app/src/processing/app/helpers/filefilters/OnlyDirs.java b/arduino-core/src/processing/app/helpers/filefilters/OnlyDirs.java
similarity index 100%
rename from app/src/processing/app/helpers/filefilters/OnlyDirs.java
rename to arduino-core/src/processing/app/helpers/filefilters/OnlyDirs.java
diff --git a/app/src/processing/app/helpers/filefilters/OnlyFilesWithExtension.java b/arduino-core/src/processing/app/helpers/filefilters/OnlyFilesWithExtension.java
similarity index 100%
rename from app/src/processing/app/helpers/filefilters/OnlyFilesWithExtension.java
rename to arduino-core/src/processing/app/helpers/filefilters/OnlyFilesWithExtension.java
diff --git a/app/src/processing/app/i18n/README.md b/arduino-core/src/processing/app/i18n/README.md
similarity index 100%
rename from app/src/processing/app/i18n/README.md
rename to arduino-core/src/processing/app/i18n/README.md
diff --git a/app/src/processing/app/i18n/Resources_an.po b/arduino-core/src/processing/app/i18n/Resources_an.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_an.po
rename to arduino-core/src/processing/app/i18n/Resources_an.po
diff --git a/app/src/processing/app/i18n/Resources_an.properties b/arduino-core/src/processing/app/i18n/Resources_an.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_an.properties
rename to arduino-core/src/processing/app/i18n/Resources_an.properties
diff --git a/app/src/processing/app/i18n/Resources_ar.po b/arduino-core/src/processing/app/i18n/Resources_ar.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_ar.po
rename to arduino-core/src/processing/app/i18n/Resources_ar.po
diff --git a/app/src/processing/app/i18n/Resources_ar.properties b/arduino-core/src/processing/app/i18n/Resources_ar.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_ar.properties
rename to arduino-core/src/processing/app/i18n/Resources_ar.properties
diff --git a/app/src/processing/app/i18n/Resources_ast.po b/arduino-core/src/processing/app/i18n/Resources_ast.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_ast.po
rename to arduino-core/src/processing/app/i18n/Resources_ast.po
diff --git a/app/src/processing/app/i18n/Resources_ast.properties b/arduino-core/src/processing/app/i18n/Resources_ast.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_ast.properties
rename to arduino-core/src/processing/app/i18n/Resources_ast.properties
diff --git a/app/src/processing/app/i18n/Resources_be.po b/arduino-core/src/processing/app/i18n/Resources_be.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_be.po
rename to arduino-core/src/processing/app/i18n/Resources_be.po
diff --git a/app/src/processing/app/i18n/Resources_be.properties b/arduino-core/src/processing/app/i18n/Resources_be.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_be.properties
rename to arduino-core/src/processing/app/i18n/Resources_be.properties
diff --git a/app/src/processing/app/i18n/Resources_bg.po b/arduino-core/src/processing/app/i18n/Resources_bg.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_bg.po
rename to arduino-core/src/processing/app/i18n/Resources_bg.po
diff --git a/app/src/processing/app/i18n/Resources_bg.properties b/arduino-core/src/processing/app/i18n/Resources_bg.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_bg.properties
rename to arduino-core/src/processing/app/i18n/Resources_bg.properties
diff --git a/app/src/processing/app/i18n/Resources_bs.po b/arduino-core/src/processing/app/i18n/Resources_bs.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_bs.po
rename to arduino-core/src/processing/app/i18n/Resources_bs.po
diff --git a/app/src/processing/app/i18n/Resources_bs.properties b/arduino-core/src/processing/app/i18n/Resources_bs.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_bs.properties
rename to arduino-core/src/processing/app/i18n/Resources_bs.properties
diff --git a/app/src/processing/app/i18n/Resources_ca.po b/arduino-core/src/processing/app/i18n/Resources_ca.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_ca.po
rename to arduino-core/src/processing/app/i18n/Resources_ca.po
diff --git a/app/src/processing/app/i18n/Resources_ca.properties b/arduino-core/src/processing/app/i18n/Resources_ca.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_ca.properties
rename to arduino-core/src/processing/app/i18n/Resources_ca.properties
diff --git a/app/src/processing/app/i18n/Resources_cs_CZ.po b/arduino-core/src/processing/app/i18n/Resources_cs_CZ.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_cs_CZ.po
rename to arduino-core/src/processing/app/i18n/Resources_cs_CZ.po
diff --git a/app/src/processing/app/i18n/Resources_cs_CZ.properties b/arduino-core/src/processing/app/i18n/Resources_cs_CZ.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_cs_CZ.properties
rename to arduino-core/src/processing/app/i18n/Resources_cs_CZ.properties
diff --git a/app/src/processing/app/i18n/Resources_da_DK.po b/arduino-core/src/processing/app/i18n/Resources_da_DK.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_da_DK.po
rename to arduino-core/src/processing/app/i18n/Resources_da_DK.po
diff --git a/app/src/processing/app/i18n/Resources_da_DK.properties b/arduino-core/src/processing/app/i18n/Resources_da_DK.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_da_DK.properties
rename to arduino-core/src/processing/app/i18n/Resources_da_DK.properties
diff --git a/app/src/processing/app/i18n/Resources_de_DE.po b/arduino-core/src/processing/app/i18n/Resources_de_DE.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_de_DE.po
rename to arduino-core/src/processing/app/i18n/Resources_de_DE.po
diff --git a/app/src/processing/app/i18n/Resources_de_DE.properties b/arduino-core/src/processing/app/i18n/Resources_de_DE.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_de_DE.properties
rename to arduino-core/src/processing/app/i18n/Resources_de_DE.properties
diff --git a/app/src/processing/app/i18n/Resources_el_GR.po b/arduino-core/src/processing/app/i18n/Resources_el_GR.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_el_GR.po
rename to arduino-core/src/processing/app/i18n/Resources_el_GR.po
diff --git a/app/src/processing/app/i18n/Resources_el_GR.properties b/arduino-core/src/processing/app/i18n/Resources_el_GR.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_el_GR.properties
rename to arduino-core/src/processing/app/i18n/Resources_el_GR.properties
diff --git a/app/src/processing/app/i18n/Resources_en.po b/arduino-core/src/processing/app/i18n/Resources_en.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_en.po
rename to arduino-core/src/processing/app/i18n/Resources_en.po
diff --git a/app/src/processing/app/i18n/Resources_en.properties b/arduino-core/src/processing/app/i18n/Resources_en.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_en.properties
rename to arduino-core/src/processing/app/i18n/Resources_en.properties
diff --git a/app/src/processing/app/i18n/Resources_en_GB.po b/arduino-core/src/processing/app/i18n/Resources_en_GB.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_en_GB.po
rename to arduino-core/src/processing/app/i18n/Resources_en_GB.po
diff --git a/app/src/processing/app/i18n/Resources_en_GB.properties b/arduino-core/src/processing/app/i18n/Resources_en_GB.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_en_GB.properties
rename to arduino-core/src/processing/app/i18n/Resources_en_GB.properties
diff --git a/app/src/processing/app/i18n/Resources_es.po b/arduino-core/src/processing/app/i18n/Resources_es.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_es.po
rename to arduino-core/src/processing/app/i18n/Resources_es.po
diff --git a/app/src/processing/app/i18n/Resources_es.properties b/arduino-core/src/processing/app/i18n/Resources_es.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_es.properties
rename to arduino-core/src/processing/app/i18n/Resources_es.properties
diff --git a/app/src/processing/app/i18n/Resources_et.po b/arduino-core/src/processing/app/i18n/Resources_et.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_et.po
rename to arduino-core/src/processing/app/i18n/Resources_et.po
diff --git a/app/src/processing/app/i18n/Resources_et.properties b/arduino-core/src/processing/app/i18n/Resources_et.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_et.properties
rename to arduino-core/src/processing/app/i18n/Resources_et.properties
diff --git a/app/src/processing/app/i18n/Resources_et_EE.po b/arduino-core/src/processing/app/i18n/Resources_et_EE.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_et_EE.po
rename to arduino-core/src/processing/app/i18n/Resources_et_EE.po
diff --git a/app/src/processing/app/i18n/Resources_et_EE.properties b/arduino-core/src/processing/app/i18n/Resources_et_EE.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_et_EE.properties
rename to arduino-core/src/processing/app/i18n/Resources_et_EE.properties
diff --git a/app/src/processing/app/i18n/Resources_fa.po b/arduino-core/src/processing/app/i18n/Resources_fa.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_fa.po
rename to arduino-core/src/processing/app/i18n/Resources_fa.po
diff --git a/app/src/processing/app/i18n/Resources_fa.properties b/arduino-core/src/processing/app/i18n/Resources_fa.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_fa.properties
rename to arduino-core/src/processing/app/i18n/Resources_fa.properties
diff --git a/app/src/processing/app/i18n/Resources_fi.po b/arduino-core/src/processing/app/i18n/Resources_fi.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_fi.po
rename to arduino-core/src/processing/app/i18n/Resources_fi.po
diff --git a/app/src/processing/app/i18n/Resources_fi.properties b/arduino-core/src/processing/app/i18n/Resources_fi.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_fi.properties
rename to arduino-core/src/processing/app/i18n/Resources_fi.properties
diff --git a/app/src/processing/app/i18n/Resources_fil.po b/arduino-core/src/processing/app/i18n/Resources_fil.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_fil.po
rename to arduino-core/src/processing/app/i18n/Resources_fil.po
diff --git a/app/src/processing/app/i18n/Resources_fil.properties b/arduino-core/src/processing/app/i18n/Resources_fil.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_fil.properties
rename to arduino-core/src/processing/app/i18n/Resources_fil.properties
diff --git a/app/src/processing/app/i18n/Resources_fr.po b/arduino-core/src/processing/app/i18n/Resources_fr.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_fr.po
rename to arduino-core/src/processing/app/i18n/Resources_fr.po
diff --git a/app/src/processing/app/i18n/Resources_fr.properties b/arduino-core/src/processing/app/i18n/Resources_fr.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_fr.properties
rename to arduino-core/src/processing/app/i18n/Resources_fr.properties
diff --git a/app/src/processing/app/i18n/Resources_fr_CA.po b/arduino-core/src/processing/app/i18n/Resources_fr_CA.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_fr_CA.po
rename to arduino-core/src/processing/app/i18n/Resources_fr_CA.po
diff --git a/app/src/processing/app/i18n/Resources_fr_CA.properties b/arduino-core/src/processing/app/i18n/Resources_fr_CA.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_fr_CA.properties
rename to arduino-core/src/processing/app/i18n/Resources_fr_CA.properties
diff --git a/app/src/processing/app/i18n/Resources_gl.po b/arduino-core/src/processing/app/i18n/Resources_gl.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_gl.po
rename to arduino-core/src/processing/app/i18n/Resources_gl.po
diff --git a/app/src/processing/app/i18n/Resources_gl.properties b/arduino-core/src/processing/app/i18n/Resources_gl.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_gl.properties
rename to arduino-core/src/processing/app/i18n/Resources_gl.properties
diff --git a/app/src/processing/app/i18n/Resources_hi.po b/arduino-core/src/processing/app/i18n/Resources_hi.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_hi.po
rename to arduino-core/src/processing/app/i18n/Resources_hi.po
diff --git a/app/src/processing/app/i18n/Resources_hi.properties b/arduino-core/src/processing/app/i18n/Resources_hi.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_hi.properties
rename to arduino-core/src/processing/app/i18n/Resources_hi.properties
diff --git a/app/src/processing/app/i18n/Resources_hr_HR.po b/arduino-core/src/processing/app/i18n/Resources_hr_HR.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_hr_HR.po
rename to arduino-core/src/processing/app/i18n/Resources_hr_HR.po
diff --git a/app/src/processing/app/i18n/Resources_hr_HR.properties b/arduino-core/src/processing/app/i18n/Resources_hr_HR.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_hr_HR.properties
rename to arduino-core/src/processing/app/i18n/Resources_hr_HR.properties
diff --git a/app/src/processing/app/i18n/Resources_hu.po b/arduino-core/src/processing/app/i18n/Resources_hu.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_hu.po
rename to arduino-core/src/processing/app/i18n/Resources_hu.po
diff --git a/app/src/processing/app/i18n/Resources_hu.properties b/arduino-core/src/processing/app/i18n/Resources_hu.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_hu.properties
rename to arduino-core/src/processing/app/i18n/Resources_hu.properties
diff --git a/app/src/processing/app/i18n/Resources_hy.po b/arduino-core/src/processing/app/i18n/Resources_hy.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_hy.po
rename to arduino-core/src/processing/app/i18n/Resources_hy.po
diff --git a/app/src/processing/app/i18n/Resources_hy.properties b/arduino-core/src/processing/app/i18n/Resources_hy.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_hy.properties
rename to arduino-core/src/processing/app/i18n/Resources_hy.properties
diff --git a/app/src/processing/app/i18n/Resources_in.po b/arduino-core/src/processing/app/i18n/Resources_in.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_in.po
rename to arduino-core/src/processing/app/i18n/Resources_in.po
diff --git a/app/src/processing/app/i18n/Resources_in.properties b/arduino-core/src/processing/app/i18n/Resources_in.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_in.properties
rename to arduino-core/src/processing/app/i18n/Resources_in.properties
diff --git a/app/src/processing/app/i18n/Resources_it_IT.po b/arduino-core/src/processing/app/i18n/Resources_it_IT.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_it_IT.po
rename to arduino-core/src/processing/app/i18n/Resources_it_IT.po
diff --git a/app/src/processing/app/i18n/Resources_it_IT.properties b/arduino-core/src/processing/app/i18n/Resources_it_IT.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_it_IT.properties
rename to arduino-core/src/processing/app/i18n/Resources_it_IT.properties
diff --git a/app/src/processing/app/i18n/Resources_iw.po b/arduino-core/src/processing/app/i18n/Resources_iw.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_iw.po
rename to arduino-core/src/processing/app/i18n/Resources_iw.po
diff --git a/app/src/processing/app/i18n/Resources_iw.properties b/arduino-core/src/processing/app/i18n/Resources_iw.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_iw.properties
rename to arduino-core/src/processing/app/i18n/Resources_iw.properties
diff --git a/app/src/processing/app/i18n/Resources_ja_JP.po b/arduino-core/src/processing/app/i18n/Resources_ja_JP.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_ja_JP.po
rename to arduino-core/src/processing/app/i18n/Resources_ja_JP.po
diff --git a/app/src/processing/app/i18n/Resources_ja_JP.properties b/arduino-core/src/processing/app/i18n/Resources_ja_JP.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_ja_JP.properties
rename to arduino-core/src/processing/app/i18n/Resources_ja_JP.properties
diff --git a/app/src/processing/app/i18n/Resources_ka_GE.po b/arduino-core/src/processing/app/i18n/Resources_ka_GE.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_ka_GE.po
rename to arduino-core/src/processing/app/i18n/Resources_ka_GE.po
diff --git a/app/src/processing/app/i18n/Resources_ka_GE.properties b/arduino-core/src/processing/app/i18n/Resources_ka_GE.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_ka_GE.properties
rename to arduino-core/src/processing/app/i18n/Resources_ka_GE.properties
diff --git a/app/src/processing/app/i18n/Resources_ko_KR.po b/arduino-core/src/processing/app/i18n/Resources_ko_KR.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_ko_KR.po
rename to arduino-core/src/processing/app/i18n/Resources_ko_KR.po
diff --git a/app/src/processing/app/i18n/Resources_ko_KR.properties b/arduino-core/src/processing/app/i18n/Resources_ko_KR.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_ko_KR.properties
rename to arduino-core/src/processing/app/i18n/Resources_ko_KR.properties
diff --git a/app/src/processing/app/i18n/Resources_lt_LT.po b/arduino-core/src/processing/app/i18n/Resources_lt_LT.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_lt_LT.po
rename to arduino-core/src/processing/app/i18n/Resources_lt_LT.po
diff --git a/app/src/processing/app/i18n/Resources_lt_LT.properties b/arduino-core/src/processing/app/i18n/Resources_lt_LT.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_lt_LT.properties
rename to arduino-core/src/processing/app/i18n/Resources_lt_LT.properties
diff --git a/app/src/processing/app/i18n/Resources_lv_LV.po b/arduino-core/src/processing/app/i18n/Resources_lv_LV.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_lv_LV.po
rename to arduino-core/src/processing/app/i18n/Resources_lv_LV.po
diff --git a/app/src/processing/app/i18n/Resources_lv_LV.properties b/arduino-core/src/processing/app/i18n/Resources_lv_LV.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_lv_LV.properties
rename to arduino-core/src/processing/app/i18n/Resources_lv_LV.properties
diff --git a/app/src/processing/app/i18n/Resources_mr.po b/arduino-core/src/processing/app/i18n/Resources_mr.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_mr.po
rename to arduino-core/src/processing/app/i18n/Resources_mr.po
diff --git a/app/src/processing/app/i18n/Resources_mr.properties b/arduino-core/src/processing/app/i18n/Resources_mr.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_mr.properties
rename to arduino-core/src/processing/app/i18n/Resources_mr.properties
diff --git a/app/src/processing/app/i18n/Resources_my_MM.po b/arduino-core/src/processing/app/i18n/Resources_my_MM.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_my_MM.po
rename to arduino-core/src/processing/app/i18n/Resources_my_MM.po
diff --git a/app/src/processing/app/i18n/Resources_my_MM.properties b/arduino-core/src/processing/app/i18n/Resources_my_MM.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_my_MM.properties
rename to arduino-core/src/processing/app/i18n/Resources_my_MM.properties
diff --git a/app/src/processing/app/i18n/Resources_nb_NO.po b/arduino-core/src/processing/app/i18n/Resources_nb_NO.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_nb_NO.po
rename to arduino-core/src/processing/app/i18n/Resources_nb_NO.po
diff --git a/app/src/processing/app/i18n/Resources_nb_NO.properties b/arduino-core/src/processing/app/i18n/Resources_nb_NO.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_nb_NO.properties
rename to arduino-core/src/processing/app/i18n/Resources_nb_NO.properties
diff --git a/app/src/processing/app/i18n/Resources_ne.po b/arduino-core/src/processing/app/i18n/Resources_ne.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_ne.po
rename to arduino-core/src/processing/app/i18n/Resources_ne.po
diff --git a/app/src/processing/app/i18n/Resources_ne.properties b/arduino-core/src/processing/app/i18n/Resources_ne.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_ne.properties
rename to arduino-core/src/processing/app/i18n/Resources_ne.properties
diff --git a/app/src/processing/app/i18n/Resources_nl.po b/arduino-core/src/processing/app/i18n/Resources_nl.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_nl.po
rename to arduino-core/src/processing/app/i18n/Resources_nl.po
diff --git a/app/src/processing/app/i18n/Resources_nl.properties b/arduino-core/src/processing/app/i18n/Resources_nl.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_nl.properties
rename to arduino-core/src/processing/app/i18n/Resources_nl.properties
diff --git a/app/src/processing/app/i18n/Resources_nl_NL.po b/arduino-core/src/processing/app/i18n/Resources_nl_NL.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_nl_NL.po
rename to arduino-core/src/processing/app/i18n/Resources_nl_NL.po
diff --git a/app/src/processing/app/i18n/Resources_nl_NL.properties b/arduino-core/src/processing/app/i18n/Resources_nl_NL.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_nl_NL.properties
rename to arduino-core/src/processing/app/i18n/Resources_nl_NL.properties
diff --git a/app/src/processing/app/i18n/Resources_pl.po b/arduino-core/src/processing/app/i18n/Resources_pl.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_pl.po
rename to arduino-core/src/processing/app/i18n/Resources_pl.po
diff --git a/app/src/processing/app/i18n/Resources_pl.properties b/arduino-core/src/processing/app/i18n/Resources_pl.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_pl.properties
rename to arduino-core/src/processing/app/i18n/Resources_pl.properties
diff --git a/app/src/processing/app/i18n/Resources_pt.po b/arduino-core/src/processing/app/i18n/Resources_pt.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_pt.po
rename to arduino-core/src/processing/app/i18n/Resources_pt.po
diff --git a/app/src/processing/app/i18n/Resources_pt.properties b/arduino-core/src/processing/app/i18n/Resources_pt.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_pt.properties
rename to arduino-core/src/processing/app/i18n/Resources_pt.properties
diff --git a/app/src/processing/app/i18n/Resources_pt_BR.po b/arduino-core/src/processing/app/i18n/Resources_pt_BR.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_pt_BR.po
rename to arduino-core/src/processing/app/i18n/Resources_pt_BR.po
diff --git a/app/src/processing/app/i18n/Resources_pt_BR.properties b/arduino-core/src/processing/app/i18n/Resources_pt_BR.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_pt_BR.properties
rename to arduino-core/src/processing/app/i18n/Resources_pt_BR.properties
diff --git a/app/src/processing/app/i18n/Resources_pt_PT.po b/arduino-core/src/processing/app/i18n/Resources_pt_PT.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_pt_PT.po
rename to arduino-core/src/processing/app/i18n/Resources_pt_PT.po
diff --git a/app/src/processing/app/i18n/Resources_pt_PT.properties b/arduino-core/src/processing/app/i18n/Resources_pt_PT.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_pt_PT.properties
rename to arduino-core/src/processing/app/i18n/Resources_pt_PT.properties
diff --git a/app/src/processing/app/i18n/Resources_ro.po b/arduino-core/src/processing/app/i18n/Resources_ro.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_ro.po
rename to arduino-core/src/processing/app/i18n/Resources_ro.po
diff --git a/app/src/processing/app/i18n/Resources_ro.properties b/arduino-core/src/processing/app/i18n/Resources_ro.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_ro.properties
rename to arduino-core/src/processing/app/i18n/Resources_ro.properties
diff --git a/app/src/processing/app/i18n/Resources_ru.po b/arduino-core/src/processing/app/i18n/Resources_ru.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_ru.po
rename to arduino-core/src/processing/app/i18n/Resources_ru.po
diff --git a/app/src/processing/app/i18n/Resources_ru.properties b/arduino-core/src/processing/app/i18n/Resources_ru.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_ru.properties
rename to arduino-core/src/processing/app/i18n/Resources_ru.properties
diff --git a/app/src/processing/app/i18n/Resources_sl_SI.po b/arduino-core/src/processing/app/i18n/Resources_sl_SI.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_sl_SI.po
rename to arduino-core/src/processing/app/i18n/Resources_sl_SI.po
diff --git a/app/src/processing/app/i18n/Resources_sl_SI.properties b/arduino-core/src/processing/app/i18n/Resources_sl_SI.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_sl_SI.properties
rename to arduino-core/src/processing/app/i18n/Resources_sl_SI.properties
diff --git a/app/src/processing/app/i18n/Resources_sq.po b/arduino-core/src/processing/app/i18n/Resources_sq.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_sq.po
rename to arduino-core/src/processing/app/i18n/Resources_sq.po
diff --git a/app/src/processing/app/i18n/Resources_sq.properties b/arduino-core/src/processing/app/i18n/Resources_sq.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_sq.properties
rename to arduino-core/src/processing/app/i18n/Resources_sq.properties
diff --git a/app/src/processing/app/i18n/Resources_sv.po b/arduino-core/src/processing/app/i18n/Resources_sv.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_sv.po
rename to arduino-core/src/processing/app/i18n/Resources_sv.po
diff --git a/app/src/processing/app/i18n/Resources_sv.properties b/arduino-core/src/processing/app/i18n/Resources_sv.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_sv.properties
rename to arduino-core/src/processing/app/i18n/Resources_sv.properties
diff --git a/app/src/processing/app/i18n/Resources_ta.po b/arduino-core/src/processing/app/i18n/Resources_ta.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_ta.po
rename to arduino-core/src/processing/app/i18n/Resources_ta.po
diff --git a/app/src/processing/app/i18n/Resources_ta.properties b/arduino-core/src/processing/app/i18n/Resources_ta.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_ta.properties
rename to arduino-core/src/processing/app/i18n/Resources_ta.properties
diff --git a/app/src/processing/app/i18n/Resources_tr.po b/arduino-core/src/processing/app/i18n/Resources_tr.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_tr.po
rename to arduino-core/src/processing/app/i18n/Resources_tr.po
diff --git a/app/src/processing/app/i18n/Resources_tr.properties b/arduino-core/src/processing/app/i18n/Resources_tr.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_tr.properties
rename to arduino-core/src/processing/app/i18n/Resources_tr.properties
diff --git a/app/src/processing/app/i18n/Resources_uk.po b/arduino-core/src/processing/app/i18n/Resources_uk.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_uk.po
rename to arduino-core/src/processing/app/i18n/Resources_uk.po
diff --git a/app/src/processing/app/i18n/Resources_uk.properties b/arduino-core/src/processing/app/i18n/Resources_uk.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_uk.properties
rename to arduino-core/src/processing/app/i18n/Resources_uk.properties
diff --git a/app/src/processing/app/i18n/Resources_vi.po b/arduino-core/src/processing/app/i18n/Resources_vi.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_vi.po
rename to arduino-core/src/processing/app/i18n/Resources_vi.po
diff --git a/app/src/processing/app/i18n/Resources_vi.properties b/arduino-core/src/processing/app/i18n/Resources_vi.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_vi.properties
rename to arduino-core/src/processing/app/i18n/Resources_vi.properties
diff --git a/app/src/processing/app/i18n/Resources_zh_CN.po b/arduino-core/src/processing/app/i18n/Resources_zh_CN.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_zh_CN.po
rename to arduino-core/src/processing/app/i18n/Resources_zh_CN.po
diff --git a/app/src/processing/app/i18n/Resources_zh_CN.properties b/arduino-core/src/processing/app/i18n/Resources_zh_CN.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_zh_CN.properties
rename to arduino-core/src/processing/app/i18n/Resources_zh_CN.properties
diff --git a/app/src/processing/app/i18n/Resources_zh_HK.po b/arduino-core/src/processing/app/i18n/Resources_zh_HK.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_zh_HK.po
rename to arduino-core/src/processing/app/i18n/Resources_zh_HK.po
diff --git a/app/src/processing/app/i18n/Resources_zh_HK.properties b/arduino-core/src/processing/app/i18n/Resources_zh_HK.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_zh_HK.properties
rename to arduino-core/src/processing/app/i18n/Resources_zh_HK.properties
diff --git a/app/src/processing/app/i18n/Resources_zh_TW.Big5.po b/arduino-core/src/processing/app/i18n/Resources_zh_TW.Big5.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_zh_TW.Big5.po
rename to arduino-core/src/processing/app/i18n/Resources_zh_TW.Big5.po
diff --git a/app/src/processing/app/i18n/Resources_zh_TW.Big5.properties b/arduino-core/src/processing/app/i18n/Resources_zh_TW.Big5.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_zh_TW.Big5.properties
rename to arduino-core/src/processing/app/i18n/Resources_zh_TW.Big5.properties
diff --git a/app/src/processing/app/i18n/Resources_zh_TW.po b/arduino-core/src/processing/app/i18n/Resources_zh_TW.po
similarity index 100%
rename from app/src/processing/app/i18n/Resources_zh_TW.po
rename to arduino-core/src/processing/app/i18n/Resources_zh_TW.po
diff --git a/app/src/processing/app/i18n/Resources_zh_TW.properties b/arduino-core/src/processing/app/i18n/Resources_zh_TW.properties
similarity index 100%
rename from app/src/processing/app/i18n/Resources_zh_TW.properties
rename to arduino-core/src/processing/app/i18n/Resources_zh_TW.properties
diff --git a/app/src/processing/app/i18n/pull.sh b/arduino-core/src/processing/app/i18n/pull.sh
similarity index 100%
rename from app/src/processing/app/i18n/pull.sh
rename to arduino-core/src/processing/app/i18n/pull.sh
diff --git a/app/src/processing/app/i18n/push.sh b/arduino-core/src/processing/app/i18n/push.sh
similarity index 100%
rename from app/src/processing/app/i18n/push.sh
rename to arduino-core/src/processing/app/i18n/push.sh
diff --git a/app/src/processing/app/i18n/python/.gitignore b/arduino-core/src/processing/app/i18n/python/.gitignore
similarity index 100%
rename from app/src/processing/app/i18n/python/.gitignore
rename to arduino-core/src/processing/app/i18n/python/.gitignore
diff --git a/app/src/processing/app/i18n/python/pull.py b/arduino-core/src/processing/app/i18n/python/pull.py
similarity index 100%
rename from app/src/processing/app/i18n/python/pull.py
rename to arduino-core/src/processing/app/i18n/python/pull.py
diff --git a/app/src/processing/app/i18n/python/push.py b/arduino-core/src/processing/app/i18n/python/push.py
similarity index 100%
rename from app/src/processing/app/i18n/python/push.py
rename to arduino-core/src/processing/app/i18n/python/push.py
diff --git a/app/src/processing/app/i18n/python/requests/__init__.py b/arduino-core/src/processing/app/i18n/python/requests/__init__.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/__init__.py
rename to arduino-core/src/processing/app/i18n/python/requests/__init__.py
diff --git a/app/src/processing/app/i18n/python/requests/adapters.py b/arduino-core/src/processing/app/i18n/python/requests/adapters.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/adapters.py
rename to arduino-core/src/processing/app/i18n/python/requests/adapters.py
diff --git a/app/src/processing/app/i18n/python/requests/api.py b/arduino-core/src/processing/app/i18n/python/requests/api.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/api.py
rename to arduino-core/src/processing/app/i18n/python/requests/api.py
diff --git a/app/src/processing/app/i18n/python/requests/auth.py b/arduino-core/src/processing/app/i18n/python/requests/auth.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/auth.py
rename to arduino-core/src/processing/app/i18n/python/requests/auth.py
diff --git a/app/src/processing/app/i18n/python/requests/cacert.pem b/arduino-core/src/processing/app/i18n/python/requests/cacert.pem
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/cacert.pem
rename to arduino-core/src/processing/app/i18n/python/requests/cacert.pem
diff --git a/app/src/processing/app/i18n/python/requests/certs.py b/arduino-core/src/processing/app/i18n/python/requests/certs.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/certs.py
rename to arduino-core/src/processing/app/i18n/python/requests/certs.py
diff --git a/app/src/processing/app/i18n/python/requests/compat.py b/arduino-core/src/processing/app/i18n/python/requests/compat.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/compat.py
rename to arduino-core/src/processing/app/i18n/python/requests/compat.py
diff --git a/app/src/processing/app/i18n/python/requests/cookies.py b/arduino-core/src/processing/app/i18n/python/requests/cookies.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/cookies.py
rename to arduino-core/src/processing/app/i18n/python/requests/cookies.py
diff --git a/app/src/processing/app/i18n/python/requests/exceptions.py b/arduino-core/src/processing/app/i18n/python/requests/exceptions.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/exceptions.py
rename to arduino-core/src/processing/app/i18n/python/requests/exceptions.py
diff --git a/app/src/processing/app/i18n/python/requests/hooks.py b/arduino-core/src/processing/app/i18n/python/requests/hooks.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/hooks.py
rename to arduino-core/src/processing/app/i18n/python/requests/hooks.py
diff --git a/app/src/processing/app/i18n/python/requests/models.py b/arduino-core/src/processing/app/i18n/python/requests/models.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/models.py
rename to arduino-core/src/processing/app/i18n/python/requests/models.py
diff --git a/app/src/processing/app/i18n/python/requests/packages/__init__.py b/arduino-core/src/processing/app/i18n/python/requests/packages/__init__.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/packages/__init__.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/__init__.py
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/__init__.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/__init__.py
similarity index 97%
rename from app/src/processing/app/i18n/python/requests/packages/charade/__init__.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/__init__.py
index 5d580b3da47..26378d45325 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/__init__.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/__init__.py
@@ -1,27 +1,27 @@
-######################## BEGIN LICENSE BLOCK ########################
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-__version__ = "1.0.1"
-
-
-def detect(aBuf):
- from . import universaldetector
- u = universaldetector.UniversalDetector()
- u.reset()
- u.feed(aBuf)
- u.close()
- return u.result
+######################## BEGIN LICENSE BLOCK ########################
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+__version__ = "1.0.1"
+
+
+def detect(aBuf):
+ from . import universaldetector
+ u = universaldetector.UniversalDetector()
+ u.reset()
+ u.feed(aBuf)
+ u.close()
+ return u.result
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/big5freq.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/big5freq.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/packages/charade/big5freq.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/big5freq.py
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/big5prober.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/big5prober.py
similarity index 97%
rename from app/src/processing/app/i18n/python/requests/packages/charade/big5prober.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/big5prober.py
index 7382f7c5d49..becce81e5e8 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/big5prober.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/big5prober.py
@@ -1,42 +1,42 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is Mozilla Communicator client code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-from .mbcharsetprober import MultiByteCharSetProber
-from .codingstatemachine import CodingStateMachine
-from .chardistribution import Big5DistributionAnalysis
-from .mbcssm import Big5SMModel
-
-
-class Big5Prober(MultiByteCharSetProber):
- def __init__(self):
- MultiByteCharSetProber.__init__(self)
- self._mCodingSM = CodingStateMachine(Big5SMModel)
- self._mDistributionAnalyzer = Big5DistributionAnalysis()
- self.reset()
-
- def get_charset_name(self):
- return "Big5"
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is Mozilla Communicator client code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+from .mbcharsetprober import MultiByteCharSetProber
+from .codingstatemachine import CodingStateMachine
+from .chardistribution import Big5DistributionAnalysis
+from .mbcssm import Big5SMModel
+
+
+class Big5Prober(MultiByteCharSetProber):
+ def __init__(self):
+ MultiByteCharSetProber.__init__(self)
+ self._mCodingSM = CodingStateMachine(Big5SMModel)
+ self._mDistributionAnalyzer = Big5DistributionAnalysis()
+ self.reset()
+
+ def get_charset_name(self):
+ return "Big5"
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/chardistribution.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/chardistribution.py
similarity index 97%
rename from app/src/processing/app/i18n/python/requests/packages/charade/chardistribution.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/chardistribution.py
index 981bd1a5333..253408f287a 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/chardistribution.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/chardistribution.py
@@ -1,230 +1,230 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is Mozilla Communicator client code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-from .euctwfreq import (EUCTWCharToFreqOrder, EUCTW_TABLE_SIZE,
- EUCTW_TYPICAL_DISTRIBUTION_RATIO)
-from .euckrfreq import (EUCKRCharToFreqOrder, EUCKR_TABLE_SIZE,
- EUCKR_TYPICAL_DISTRIBUTION_RATIO)
-from .gb2312freq import (GB2312CharToFreqOrder, GB2312_TABLE_SIZE,
- GB2312_TYPICAL_DISTRIBUTION_RATIO)
-from .big5freq import (Big5CharToFreqOrder, BIG5_TABLE_SIZE,
- BIG5_TYPICAL_DISTRIBUTION_RATIO)
-from .jisfreq import (JISCharToFreqOrder, JIS_TABLE_SIZE,
- JIS_TYPICAL_DISTRIBUTION_RATIO)
-from .compat import wrap_ord
-
-ENOUGH_DATA_THRESHOLD = 1024
-SURE_YES = 0.99
-SURE_NO = 0.01
-
-
-class CharDistributionAnalysis:
- def __init__(self):
- # Mapping table to get frequency order from char order (get from
- # GetOrder())
- self._mCharToFreqOrder = None
- self._mTableSize = None # Size of above table
- # This is a constant value which varies from language to language,
- # used in calculating confidence. See
- # http://www.mozilla.org/projects/intl/UniversalCharsetDetection.html
- # for further detail.
- self._mTypicalDistributionRatio = None
- self.reset()
-
- def reset(self):
- """reset analyser, clear any state"""
- # If this flag is set to True, detection is done and conclusion has
- # been made
- self._mDone = False
- self._mTotalChars = 0 # Total characters encountered
- # The number of characters whose frequency order is less than 512
- self._mFreqChars = 0
-
- def feed(self, aBuf, aCharLen):
- """feed a character with known length"""
- if aCharLen == 2:
- # we only care about 2-bytes character in our distribution analysis
- order = self.get_order(aBuf)
- else:
- order = -1
- if order >= 0:
- self._mTotalChars += 1
- # order is valid
- if order < self._mTableSize:
- if 512 > self._mCharToFreqOrder[order]:
- self._mFreqChars += 1
-
- def get_confidence(self):
- """return confidence based on existing data"""
- # if we didn't receive any character in our consideration range,
- # return negative answer
- if self._mTotalChars <= 0:
- return SURE_NO
-
- if self._mTotalChars != self._mFreqChars:
- r = (self._mFreqChars / ((self._mTotalChars - self._mFreqChars)
- * self._mTypicalDistributionRatio))
- if r < SURE_YES:
- return r
-
- # normalize confidence (we don't want to be 100% sure)
- return SURE_YES
-
- def got_enough_data(self):
- # It is not necessary to receive all data to draw conclusion.
- # For charset detection, certain amount of data is enough
- return self._mTotalChars > ENOUGH_DATA_THRESHOLD
-
- def get_order(self, aBuf):
- # We do not handle characters based on the original encoding string,
- # but convert this encoding string to a number, here called order.
- # This allows multiple encodings of a language to share one frequency
- # table.
- return -1
-
-
-class EUCTWDistributionAnalysis(CharDistributionAnalysis):
- def __init__(self):
- CharDistributionAnalysis.__init__(self)
- self._mCharToFreqOrder = EUCTWCharToFreqOrder
- self._mTableSize = EUCTW_TABLE_SIZE
- self._mTypicalDistributionRatio = EUCTW_TYPICAL_DISTRIBUTION_RATIO
-
- def get_order(self, aBuf):
- # for euc-TW encoding, we are interested
- # first byte range: 0xc4 -- 0xfe
- # second byte range: 0xa1 -- 0xfe
- # no validation needed here. State machine has done that
- first_char = wrap_ord(aBuf[0])
- if first_char >= 0xC4:
- return 94 * (first_char - 0xC4) + wrap_ord(aBuf[1]) - 0xA1
- else:
- return -1
-
-
-class EUCKRDistributionAnalysis(CharDistributionAnalysis):
- def __init__(self):
- CharDistributionAnalysis.__init__(self)
- self._mCharToFreqOrder = EUCKRCharToFreqOrder
- self._mTableSize = EUCKR_TABLE_SIZE
- self._mTypicalDistributionRatio = EUCKR_TYPICAL_DISTRIBUTION_RATIO
-
- def get_order(self, aBuf):
- # for euc-KR encoding, we are interested
- # first byte range: 0xb0 -- 0xfe
- # second byte range: 0xa1 -- 0xfe
- # no validation needed here. State machine has done that
- first_char = wrap_ord(aBuf[0])
- if first_char >= 0xB0:
- return 94 * (first_char - 0xB0) + wrap_ord(aBuf[1]) - 0xA1
- else:
- return -1
-
-
-class GB2312DistributionAnalysis(CharDistributionAnalysis):
- def __init__(self):
- CharDistributionAnalysis.__init__(self)
- self._mCharToFreqOrder = GB2312CharToFreqOrder
- self._mTableSize = GB2312_TABLE_SIZE
- self._mTypicalDistributionRatio = GB2312_TYPICAL_DISTRIBUTION_RATIO
-
- def get_order(self, aBuf):
- # for GB2312 encoding, we are interested
- # first byte range: 0xb0 -- 0xfe
- # second byte range: 0xa1 -- 0xfe
- # no validation needed here. State machine has done that
- first_char, second_char = wrap_ord(aBuf[0]), wrap_ord(aBuf[1])
- if (first_char >= 0xB0) and (second_char >= 0xA1):
- return 94 * (first_char - 0xB0) + second_char - 0xA1
- else:
- return -1
-
-
-class Big5DistributionAnalysis(CharDistributionAnalysis):
- def __init__(self):
- CharDistributionAnalysis.__init__(self)
- self._mCharToFreqOrder = Big5CharToFreqOrder
- self._mTableSize = BIG5_TABLE_SIZE
- self._mTypicalDistributionRatio = BIG5_TYPICAL_DISTRIBUTION_RATIO
-
- def get_order(self, aBuf):
- # for big5 encoding, we are interested
- # first byte range: 0xa4 -- 0xfe
- # second byte range: 0x40 -- 0x7e , 0xa1 -- 0xfe
- # no validation needed here. State machine has done that
- first_char, second_char = wrap_ord(aBuf[0]), wrap_ord(aBuf[1])
- if first_char >= 0xA4:
- if second_char >= 0xA1:
- return 157 * (first_char - 0xA4) + second_char - 0xA1 + 63
- else:
- return 157 * (first_char - 0xA4) + second_char - 0x40
- else:
- return -1
-
-
-class SJISDistributionAnalysis(CharDistributionAnalysis):
- def __init__(self):
- CharDistributionAnalysis.__init__(self)
- self._mCharToFreqOrder = JISCharToFreqOrder
- self._mTableSize = JIS_TABLE_SIZE
- self._mTypicalDistributionRatio = JIS_TYPICAL_DISTRIBUTION_RATIO
-
- def get_order(self, aBuf):
- # for sjis encoding, we are interested
- # first byte range: 0x81 -- 0x9f , 0xe0 -- 0xfe
- # second byte range: 0x40 -- 0x7e, 0x81 -- oxfe
- # no validation needed here. State machine has done that
- first_char, second_char = wrap_ord(aBuf[0]), wrap_ord(aBuf[1])
- if (first_char >= 0x81) and (first_char <= 0x9F):
- order = 188 * (first_char - 0x81)
- elif (first_char >= 0xE0) and (first_char <= 0xEF):
- order = 188 * (first_char - 0xE0 + 31)
- else:
- return -1
- order = order + second_char - 0x40
- if second_char > 0x7F:
- order = -1
- return order
-
-
-class EUCJPDistributionAnalysis(CharDistributionAnalysis):
- def __init__(self):
- CharDistributionAnalysis.__init__(self)
- self._mCharToFreqOrder = JISCharToFreqOrder
- self._mTableSize = JIS_TABLE_SIZE
- self._mTypicalDistributionRatio = JIS_TYPICAL_DISTRIBUTION_RATIO
-
- def get_order(self, aBuf):
- # for euc-JP encoding, we are interested
- # first byte range: 0xa0 -- 0xfe
- # second byte range: 0xa1 -- 0xfe
- # no validation needed here. State machine has done that
- char = wrap_ord(aBuf[0])
- if char >= 0xA0:
- return 94 * (char - 0xA1) + wrap_ord(aBuf[1]) - 0xa1
- else:
- return -1
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is Mozilla Communicator client code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+from .euctwfreq import (EUCTWCharToFreqOrder, EUCTW_TABLE_SIZE,
+ EUCTW_TYPICAL_DISTRIBUTION_RATIO)
+from .euckrfreq import (EUCKRCharToFreqOrder, EUCKR_TABLE_SIZE,
+ EUCKR_TYPICAL_DISTRIBUTION_RATIO)
+from .gb2312freq import (GB2312CharToFreqOrder, GB2312_TABLE_SIZE,
+ GB2312_TYPICAL_DISTRIBUTION_RATIO)
+from .big5freq import (Big5CharToFreqOrder, BIG5_TABLE_SIZE,
+ BIG5_TYPICAL_DISTRIBUTION_RATIO)
+from .jisfreq import (JISCharToFreqOrder, JIS_TABLE_SIZE,
+ JIS_TYPICAL_DISTRIBUTION_RATIO)
+from .compat import wrap_ord
+
+ENOUGH_DATA_THRESHOLD = 1024
+SURE_YES = 0.99
+SURE_NO = 0.01
+
+
+class CharDistributionAnalysis:
+ def __init__(self):
+ # Mapping table to get frequency order from char order (get from
+ # GetOrder())
+ self._mCharToFreqOrder = None
+ self._mTableSize = None # Size of above table
+ # This is a constant value which varies from language to language,
+ # used in calculating confidence. See
+ # http://www.mozilla.org/projects/intl/UniversalCharsetDetection.html
+ # for further detail.
+ self._mTypicalDistributionRatio = None
+ self.reset()
+
+ def reset(self):
+ """reset analyser, clear any state"""
+ # If this flag is set to True, detection is done and conclusion has
+ # been made
+ self._mDone = False
+ self._mTotalChars = 0 # Total characters encountered
+ # The number of characters whose frequency order is less than 512
+ self._mFreqChars = 0
+
+ def feed(self, aBuf, aCharLen):
+ """feed a character with known length"""
+ if aCharLen == 2:
+ # we only care about 2-bytes character in our distribution analysis
+ order = self.get_order(aBuf)
+ else:
+ order = -1
+ if order >= 0:
+ self._mTotalChars += 1
+ # order is valid
+ if order < self._mTableSize:
+ if 512 > self._mCharToFreqOrder[order]:
+ self._mFreqChars += 1
+
+ def get_confidence(self):
+ """return confidence based on existing data"""
+ # if we didn't receive any character in our consideration range,
+ # return negative answer
+ if self._mTotalChars <= 0:
+ return SURE_NO
+
+ if self._mTotalChars != self._mFreqChars:
+ r = (self._mFreqChars / ((self._mTotalChars - self._mFreqChars)
+ * self._mTypicalDistributionRatio))
+ if r < SURE_YES:
+ return r
+
+ # normalize confidence (we don't want to be 100% sure)
+ return SURE_YES
+
+ def got_enough_data(self):
+ # It is not necessary to receive all data to draw conclusion.
+ # For charset detection, certain amount of data is enough
+ return self._mTotalChars > ENOUGH_DATA_THRESHOLD
+
+ def get_order(self, aBuf):
+ # We do not handle characters based on the original encoding string,
+ # but convert this encoding string to a number, here called order.
+ # This allows multiple encodings of a language to share one frequency
+ # table.
+ return -1
+
+
+class EUCTWDistributionAnalysis(CharDistributionAnalysis):
+ def __init__(self):
+ CharDistributionAnalysis.__init__(self)
+ self._mCharToFreqOrder = EUCTWCharToFreqOrder
+ self._mTableSize = EUCTW_TABLE_SIZE
+ self._mTypicalDistributionRatio = EUCTW_TYPICAL_DISTRIBUTION_RATIO
+
+ def get_order(self, aBuf):
+ # for euc-TW encoding, we are interested
+ # first byte range: 0xc4 -- 0xfe
+ # second byte range: 0xa1 -- 0xfe
+ # no validation needed here. State machine has done that
+ first_char = wrap_ord(aBuf[0])
+ if first_char >= 0xC4:
+ return 94 * (first_char - 0xC4) + wrap_ord(aBuf[1]) - 0xA1
+ else:
+ return -1
+
+
+class EUCKRDistributionAnalysis(CharDistributionAnalysis):
+ def __init__(self):
+ CharDistributionAnalysis.__init__(self)
+ self._mCharToFreqOrder = EUCKRCharToFreqOrder
+ self._mTableSize = EUCKR_TABLE_SIZE
+ self._mTypicalDistributionRatio = EUCKR_TYPICAL_DISTRIBUTION_RATIO
+
+ def get_order(self, aBuf):
+ # for euc-KR encoding, we are interested
+ # first byte range: 0xb0 -- 0xfe
+ # second byte range: 0xa1 -- 0xfe
+ # no validation needed here. State machine has done that
+ first_char = wrap_ord(aBuf[0])
+ if first_char >= 0xB0:
+ return 94 * (first_char - 0xB0) + wrap_ord(aBuf[1]) - 0xA1
+ else:
+ return -1
+
+
+class GB2312DistributionAnalysis(CharDistributionAnalysis):
+ def __init__(self):
+ CharDistributionAnalysis.__init__(self)
+ self._mCharToFreqOrder = GB2312CharToFreqOrder
+ self._mTableSize = GB2312_TABLE_SIZE
+ self._mTypicalDistributionRatio = GB2312_TYPICAL_DISTRIBUTION_RATIO
+
+ def get_order(self, aBuf):
+ # for GB2312 encoding, we are interested
+ # first byte range: 0xb0 -- 0xfe
+ # second byte range: 0xa1 -- 0xfe
+ # no validation needed here. State machine has done that
+ first_char, second_char = wrap_ord(aBuf[0]), wrap_ord(aBuf[1])
+ if (first_char >= 0xB0) and (second_char >= 0xA1):
+ return 94 * (first_char - 0xB0) + second_char - 0xA1
+ else:
+ return -1
+
+
+class Big5DistributionAnalysis(CharDistributionAnalysis):
+ def __init__(self):
+ CharDistributionAnalysis.__init__(self)
+ self._mCharToFreqOrder = Big5CharToFreqOrder
+ self._mTableSize = BIG5_TABLE_SIZE
+ self._mTypicalDistributionRatio = BIG5_TYPICAL_DISTRIBUTION_RATIO
+
+ def get_order(self, aBuf):
+ # for big5 encoding, we are interested
+ # first byte range: 0xa4 -- 0xfe
+ # second byte range: 0x40 -- 0x7e , 0xa1 -- 0xfe
+ # no validation needed here. State machine has done that
+ first_char, second_char = wrap_ord(aBuf[0]), wrap_ord(aBuf[1])
+ if first_char >= 0xA4:
+ if second_char >= 0xA1:
+ return 157 * (first_char - 0xA4) + second_char - 0xA1 + 63
+ else:
+ return 157 * (first_char - 0xA4) + second_char - 0x40
+ else:
+ return -1
+
+
+class SJISDistributionAnalysis(CharDistributionAnalysis):
+ def __init__(self):
+ CharDistributionAnalysis.__init__(self)
+ self._mCharToFreqOrder = JISCharToFreqOrder
+ self._mTableSize = JIS_TABLE_SIZE
+ self._mTypicalDistributionRatio = JIS_TYPICAL_DISTRIBUTION_RATIO
+
+ def get_order(self, aBuf):
+ # for sjis encoding, we are interested
+ # first byte range: 0x81 -- 0x9f , 0xe0 -- 0xfe
+ # second byte range: 0x40 -- 0x7e, 0x81 -- oxfe
+ # no validation needed here. State machine has done that
+ first_char, second_char = wrap_ord(aBuf[0]), wrap_ord(aBuf[1])
+ if (first_char >= 0x81) and (first_char <= 0x9F):
+ order = 188 * (first_char - 0x81)
+ elif (first_char >= 0xE0) and (first_char <= 0xEF):
+ order = 188 * (first_char - 0xE0 + 31)
+ else:
+ return -1
+ order = order + second_char - 0x40
+ if second_char > 0x7F:
+ order = -1
+ return order
+
+
+class EUCJPDistributionAnalysis(CharDistributionAnalysis):
+ def __init__(self):
+ CharDistributionAnalysis.__init__(self)
+ self._mCharToFreqOrder = JISCharToFreqOrder
+ self._mTableSize = JIS_TABLE_SIZE
+ self._mTypicalDistributionRatio = JIS_TYPICAL_DISTRIBUTION_RATIO
+
+ def get_order(self, aBuf):
+ # for euc-JP encoding, we are interested
+ # first byte range: 0xa0 -- 0xfe
+ # second byte range: 0xa1 -- 0xfe
+ # no validation needed here. State machine has done that
+ char = wrap_ord(aBuf[0])
+ if char >= 0xA0:
+ return 94 * (char - 0xA1) + wrap_ord(aBuf[1]) - 0xa1
+ else:
+ return -1
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/charsetgroupprober.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/charsetgroupprober.py
similarity index 97%
rename from app/src/processing/app/i18n/python/requests/packages/charade/charsetgroupprober.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/charsetgroupprober.py
index 29596547489..85e7a1c67db 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/charsetgroupprober.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/charsetgroupprober.py
@@ -1,106 +1,106 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is Mozilla Communicator client code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-from . import constants
-import sys
-from .charsetprober import CharSetProber
-
-
-class CharSetGroupProber(CharSetProber):
- def __init__(self):
- CharSetProber.__init__(self)
- self._mActiveNum = 0
- self._mProbers = []
- self._mBestGuessProber = None
-
- def reset(self):
- CharSetProber.reset(self)
- self._mActiveNum = 0
- for prober in self._mProbers:
- if prober:
- prober.reset()
- prober.active = True
- self._mActiveNum += 1
- self._mBestGuessProber = None
-
- def get_charset_name(self):
- if not self._mBestGuessProber:
- self.get_confidence()
- if not self._mBestGuessProber:
- return None
-# self._mBestGuessProber = self._mProbers[0]
- return self._mBestGuessProber.get_charset_name()
-
- def feed(self, aBuf):
- for prober in self._mProbers:
- if not prober:
- continue
- if not prober.active:
- continue
- st = prober.feed(aBuf)
- if not st:
- continue
- if st == constants.eFoundIt:
- self._mBestGuessProber = prober
- return self.get_state()
- elif st == constants.eNotMe:
- prober.active = False
- self._mActiveNum -= 1
- if self._mActiveNum <= 0:
- self._mState = constants.eNotMe
- return self.get_state()
- return self.get_state()
-
- def get_confidence(self):
- st = self.get_state()
- if st == constants.eFoundIt:
- return 0.99
- elif st == constants.eNotMe:
- return 0.01
- bestConf = 0.0
- self._mBestGuessProber = None
- for prober in self._mProbers:
- if not prober:
- continue
- if not prober.active:
- if constants._debug:
- sys.stderr.write(prober.get_charset_name()
- + ' not active\n')
- continue
- cf = prober.get_confidence()
- if constants._debug:
- sys.stderr.write('%s confidence = %s\n' %
- (prober.get_charset_name(), cf))
- if bestConf < cf:
- bestConf = cf
- self._mBestGuessProber = prober
- if not self._mBestGuessProber:
- return 0.0
- return bestConf
-# else:
-# self._mBestGuessProber = self._mProbers[0]
-# return self._mBestGuessProber.get_confidence()
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is Mozilla Communicator client code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+from . import constants
+import sys
+from .charsetprober import CharSetProber
+
+
+class CharSetGroupProber(CharSetProber):
+ def __init__(self):
+ CharSetProber.__init__(self)
+ self._mActiveNum = 0
+ self._mProbers = []
+ self._mBestGuessProber = None
+
+ def reset(self):
+ CharSetProber.reset(self)
+ self._mActiveNum = 0
+ for prober in self._mProbers:
+ if prober:
+ prober.reset()
+ prober.active = True
+ self._mActiveNum += 1
+ self._mBestGuessProber = None
+
+ def get_charset_name(self):
+ if not self._mBestGuessProber:
+ self.get_confidence()
+ if not self._mBestGuessProber:
+ return None
+# self._mBestGuessProber = self._mProbers[0]
+ return self._mBestGuessProber.get_charset_name()
+
+ def feed(self, aBuf):
+ for prober in self._mProbers:
+ if not prober:
+ continue
+ if not prober.active:
+ continue
+ st = prober.feed(aBuf)
+ if not st:
+ continue
+ if st == constants.eFoundIt:
+ self._mBestGuessProber = prober
+ return self.get_state()
+ elif st == constants.eNotMe:
+ prober.active = False
+ self._mActiveNum -= 1
+ if self._mActiveNum <= 0:
+ self._mState = constants.eNotMe
+ return self.get_state()
+ return self.get_state()
+
+ def get_confidence(self):
+ st = self.get_state()
+ if st == constants.eFoundIt:
+ return 0.99
+ elif st == constants.eNotMe:
+ return 0.01
+ bestConf = 0.0
+ self._mBestGuessProber = None
+ for prober in self._mProbers:
+ if not prober:
+ continue
+ if not prober.active:
+ if constants._debug:
+ sys.stderr.write(prober.get_charset_name()
+ + ' not active\n')
+ continue
+ cf = prober.get_confidence()
+ if constants._debug:
+ sys.stderr.write('%s confidence = %s\n' %
+ (prober.get_charset_name(), cf))
+ if bestConf < cf:
+ bestConf = cf
+ self._mBestGuessProber = prober
+ if not self._mBestGuessProber:
+ return 0.0
+ return bestConf
+# else:
+# self._mBestGuessProber = self._mProbers[0]
+# return self._mBestGuessProber.get_confidence()
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/charsetprober.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/charsetprober.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/packages/charade/charsetprober.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/charsetprober.py
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/codingstatemachine.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/codingstatemachine.py
similarity index 97%
rename from app/src/processing/app/i18n/python/requests/packages/charade/codingstatemachine.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/codingstatemachine.py
index 1bda9ff1620..8dd8c917983 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/codingstatemachine.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/codingstatemachine.py
@@ -1,61 +1,61 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is mozilla.org code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-from .constants import eStart
-from .compat import wrap_ord
-
-
-class CodingStateMachine:
- def __init__(self, sm):
- self._mModel = sm
- self._mCurrentBytePos = 0
- self._mCurrentCharLen = 0
- self.reset()
-
- def reset(self):
- self._mCurrentState = eStart
-
- def next_state(self, c):
- # for each byte we get its class
- # if it is first byte, we also get byte length
- # PY3K: aBuf is a byte stream, so c is an int, not a byte
- byteCls = self._mModel['classTable'][wrap_ord(c)]
- if self._mCurrentState == eStart:
- self._mCurrentBytePos = 0
- self._mCurrentCharLen = self._mModel['charLenTable'][byteCls]
- # from byte's class and stateTable, we get its next state
- curr_state = (self._mCurrentState * self._mModel['classFactor']
- + byteCls)
- self._mCurrentState = self._mModel['stateTable'][curr_state]
- self._mCurrentBytePos += 1
- return self._mCurrentState
-
- def get_current_charlen(self):
- return self._mCurrentCharLen
-
- def get_coding_state_machine(self):
- return self._mModel['name']
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+from .constants import eStart
+from .compat import wrap_ord
+
+
+class CodingStateMachine:
+ def __init__(self, sm):
+ self._mModel = sm
+ self._mCurrentBytePos = 0
+ self._mCurrentCharLen = 0
+ self.reset()
+
+ def reset(self):
+ self._mCurrentState = eStart
+
+ def next_state(self, c):
+ # for each byte we get its class
+ # if it is first byte, we also get byte length
+ # PY3K: aBuf is a byte stream, so c is an int, not a byte
+ byteCls = self._mModel['classTable'][wrap_ord(c)]
+ if self._mCurrentState == eStart:
+ self._mCurrentBytePos = 0
+ self._mCurrentCharLen = self._mModel['charLenTable'][byteCls]
+ # from byte's class and stateTable, we get its next state
+ curr_state = (self._mCurrentState * self._mModel['classFactor']
+ + byteCls)
+ self._mCurrentState = self._mModel['stateTable'][curr_state]
+ self._mCurrentBytePos += 1
+ return self._mCurrentState
+
+ def get_current_charlen(self):
+ return self._mCurrentCharLen
+
+ def get_coding_state_machine(self):
+ return self._mModel['name']
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/compat.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/compat.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/packages/charade/compat.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/compat.py
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/constants.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/constants.py
similarity index 97%
rename from app/src/processing/app/i18n/python/requests/packages/charade/constants.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/constants.py
index a3d27de250b..e4d148b3c5b 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/constants.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/constants.py
@@ -1,39 +1,39 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is Mozilla Universal charset detector code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 2001
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-# Shy Shalom - original C code
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-_debug = 0
-
-eDetecting = 0
-eFoundIt = 1
-eNotMe = 2
-
-eStart = 0
-eError = 1
-eItsMe = 2
-
-SHORTCUT_THRESHOLD = 0.95
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is Mozilla Universal charset detector code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 2001
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+# Shy Shalom - original C code
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+_debug = 0
+
+eDetecting = 0
+eFoundIt = 1
+eNotMe = 2
+
+eStart = 0
+eError = 1
+eItsMe = 2
+
+SHORTCUT_THRESHOLD = 0.95
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/escprober.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/escprober.py
similarity index 97%
rename from app/src/processing/app/i18n/python/requests/packages/charade/escprober.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/escprober.py
index 0063935ce65..80a844ff34c 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/escprober.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/escprober.py
@@ -1,86 +1,86 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is mozilla.org code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-from . import constants
-from .escsm import (HZSMModel, ISO2022CNSMModel, ISO2022JPSMModel,
- ISO2022KRSMModel)
-from .charsetprober import CharSetProber
-from .codingstatemachine import CodingStateMachine
-from .compat import wrap_ord
-
-
-class EscCharSetProber(CharSetProber):
- def __init__(self):
- CharSetProber.__init__(self)
- self._mCodingSM = [
- CodingStateMachine(HZSMModel),
- CodingStateMachine(ISO2022CNSMModel),
- CodingStateMachine(ISO2022JPSMModel),
- CodingStateMachine(ISO2022KRSMModel)
- ]
- self.reset()
-
- def reset(self):
- CharSetProber.reset(self)
- for codingSM in self._mCodingSM:
- if not codingSM:
- continue
- codingSM.active = True
- codingSM.reset()
- self._mActiveSM = len(self._mCodingSM)
- self._mDetectedCharset = None
-
- def get_charset_name(self):
- return self._mDetectedCharset
-
- def get_confidence(self):
- if self._mDetectedCharset:
- return 0.99
- else:
- return 0.00
-
- def feed(self, aBuf):
- for c in aBuf:
- # PY3K: aBuf is a byte array, so c is an int, not a byte
- for codingSM in self._mCodingSM:
- if not codingSM:
- continue
- if not codingSM.active:
- continue
- codingState = codingSM.next_state(wrap_ord(c))
- if codingState == constants.eError:
- codingSM.active = False
- self._mActiveSM -= 1
- if self._mActiveSM <= 0:
- self._mState = constants.eNotMe
- return self.get_state()
- elif codingState == constants.eItsMe:
- self._mState = constants.eFoundIt
- self._mDetectedCharset = codingSM.get_coding_state_machine() # nopep8
- return self.get_state()
-
- return self.get_state()
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+from . import constants
+from .escsm import (HZSMModel, ISO2022CNSMModel, ISO2022JPSMModel,
+ ISO2022KRSMModel)
+from .charsetprober import CharSetProber
+from .codingstatemachine import CodingStateMachine
+from .compat import wrap_ord
+
+
+class EscCharSetProber(CharSetProber):
+ def __init__(self):
+ CharSetProber.__init__(self)
+ self._mCodingSM = [
+ CodingStateMachine(HZSMModel),
+ CodingStateMachine(ISO2022CNSMModel),
+ CodingStateMachine(ISO2022JPSMModel),
+ CodingStateMachine(ISO2022KRSMModel)
+ ]
+ self.reset()
+
+ def reset(self):
+ CharSetProber.reset(self)
+ for codingSM in self._mCodingSM:
+ if not codingSM:
+ continue
+ codingSM.active = True
+ codingSM.reset()
+ self._mActiveSM = len(self._mCodingSM)
+ self._mDetectedCharset = None
+
+ def get_charset_name(self):
+ return self._mDetectedCharset
+
+ def get_confidence(self):
+ if self._mDetectedCharset:
+ return 0.99
+ else:
+ return 0.00
+
+ def feed(self, aBuf):
+ for c in aBuf:
+ # PY3K: aBuf is a byte array, so c is an int, not a byte
+ for codingSM in self._mCodingSM:
+ if not codingSM:
+ continue
+ if not codingSM.active:
+ continue
+ codingState = codingSM.next_state(wrap_ord(c))
+ if codingState == constants.eError:
+ codingSM.active = False
+ self._mActiveSM -= 1
+ if self._mActiveSM <= 0:
+ self._mState = constants.eNotMe
+ return self.get_state()
+ elif codingState == constants.eItsMe:
+ self._mState = constants.eFoundIt
+ self._mDetectedCharset = codingSM.get_coding_state_machine() # nopep8
+ return self.get_state()
+
+ return self.get_state()
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/escsm.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/escsm.py
similarity index 97%
rename from app/src/processing/app/i18n/python/requests/packages/charade/escsm.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/escsm.py
index 1cf3aa6db6d..bd302b4c61d 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/escsm.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/escsm.py
@@ -1,242 +1,242 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is mozilla.org code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-from .constants import eStart, eError, eItsMe
-
-HZ_cls = (
-1,0,0,0,0,0,0,0, # 00 - 07
-0,0,0,0,0,0,0,0, # 08 - 0f
-0,0,0,0,0,0,0,0, # 10 - 17
-0,0,0,1,0,0,0,0, # 18 - 1f
-0,0,0,0,0,0,0,0, # 20 - 27
-0,0,0,0,0,0,0,0, # 28 - 2f
-0,0,0,0,0,0,0,0, # 30 - 37
-0,0,0,0,0,0,0,0, # 38 - 3f
-0,0,0,0,0,0,0,0, # 40 - 47
-0,0,0,0,0,0,0,0, # 48 - 4f
-0,0,0,0,0,0,0,0, # 50 - 57
-0,0,0,0,0,0,0,0, # 58 - 5f
-0,0,0,0,0,0,0,0, # 60 - 67
-0,0,0,0,0,0,0,0, # 68 - 6f
-0,0,0,0,0,0,0,0, # 70 - 77
-0,0,0,4,0,5,2,0, # 78 - 7f
-1,1,1,1,1,1,1,1, # 80 - 87
-1,1,1,1,1,1,1,1, # 88 - 8f
-1,1,1,1,1,1,1,1, # 90 - 97
-1,1,1,1,1,1,1,1, # 98 - 9f
-1,1,1,1,1,1,1,1, # a0 - a7
-1,1,1,1,1,1,1,1, # a8 - af
-1,1,1,1,1,1,1,1, # b0 - b7
-1,1,1,1,1,1,1,1, # b8 - bf
-1,1,1,1,1,1,1,1, # c0 - c7
-1,1,1,1,1,1,1,1, # c8 - cf
-1,1,1,1,1,1,1,1, # d0 - d7
-1,1,1,1,1,1,1,1, # d8 - df
-1,1,1,1,1,1,1,1, # e0 - e7
-1,1,1,1,1,1,1,1, # e8 - ef
-1,1,1,1,1,1,1,1, # f0 - f7
-1,1,1,1,1,1,1,1, # f8 - ff
-)
-
-HZ_st = (
-eStart,eError, 3,eStart,eStart,eStart,eError,eError,# 00-07
-eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,# 08-0f
-eItsMe,eItsMe,eError,eError,eStart,eStart, 4,eError,# 10-17
- 5,eError, 6,eError, 5, 5, 4,eError,# 18-1f
- 4,eError, 4, 4, 4,eError, 4,eError,# 20-27
- 4,eItsMe,eStart,eStart,eStart,eStart,eStart,eStart,# 28-2f
-)
-
-HZCharLenTable = (0, 0, 0, 0, 0, 0)
-
-HZSMModel = {'classTable': HZ_cls,
- 'classFactor': 6,
- 'stateTable': HZ_st,
- 'charLenTable': HZCharLenTable,
- 'name': "HZ-GB-2312"}
-
-ISO2022CN_cls = (
-2,0,0,0,0,0,0,0, # 00 - 07
-0,0,0,0,0,0,0,0, # 08 - 0f
-0,0,0,0,0,0,0,0, # 10 - 17
-0,0,0,1,0,0,0,0, # 18 - 1f
-0,0,0,0,0,0,0,0, # 20 - 27
-0,3,0,0,0,0,0,0, # 28 - 2f
-0,0,0,0,0,0,0,0, # 30 - 37
-0,0,0,0,0,0,0,0, # 38 - 3f
-0,0,0,4,0,0,0,0, # 40 - 47
-0,0,0,0,0,0,0,0, # 48 - 4f
-0,0,0,0,0,0,0,0, # 50 - 57
-0,0,0,0,0,0,0,0, # 58 - 5f
-0,0,0,0,0,0,0,0, # 60 - 67
-0,0,0,0,0,0,0,0, # 68 - 6f
-0,0,0,0,0,0,0,0, # 70 - 77
-0,0,0,0,0,0,0,0, # 78 - 7f
-2,2,2,2,2,2,2,2, # 80 - 87
-2,2,2,2,2,2,2,2, # 88 - 8f
-2,2,2,2,2,2,2,2, # 90 - 97
-2,2,2,2,2,2,2,2, # 98 - 9f
-2,2,2,2,2,2,2,2, # a0 - a7
-2,2,2,2,2,2,2,2, # a8 - af
-2,2,2,2,2,2,2,2, # b0 - b7
-2,2,2,2,2,2,2,2, # b8 - bf
-2,2,2,2,2,2,2,2, # c0 - c7
-2,2,2,2,2,2,2,2, # c8 - cf
-2,2,2,2,2,2,2,2, # d0 - d7
-2,2,2,2,2,2,2,2, # d8 - df
-2,2,2,2,2,2,2,2, # e0 - e7
-2,2,2,2,2,2,2,2, # e8 - ef
-2,2,2,2,2,2,2,2, # f0 - f7
-2,2,2,2,2,2,2,2, # f8 - ff
-)
-
-ISO2022CN_st = (
-eStart, 3,eError,eStart,eStart,eStart,eStart,eStart,# 00-07
-eStart,eError,eError,eError,eError,eError,eError,eError,# 08-0f
-eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,# 10-17
-eItsMe,eItsMe,eItsMe,eError,eError,eError, 4,eError,# 18-1f
-eError,eError,eError,eItsMe,eError,eError,eError,eError,# 20-27
- 5, 6,eError,eError,eError,eError,eError,eError,# 28-2f
-eError,eError,eError,eItsMe,eError,eError,eError,eError,# 30-37
-eError,eError,eError,eError,eError,eItsMe,eError,eStart,# 38-3f
-)
-
-ISO2022CNCharLenTable = (0, 0, 0, 0, 0, 0, 0, 0, 0)
-
-ISO2022CNSMModel = {'classTable': ISO2022CN_cls,
- 'classFactor': 9,
- 'stateTable': ISO2022CN_st,
- 'charLenTable': ISO2022CNCharLenTable,
- 'name': "ISO-2022-CN"}
-
-ISO2022JP_cls = (
-2,0,0,0,0,0,0,0, # 00 - 07
-0,0,0,0,0,0,2,2, # 08 - 0f
-0,0,0,0,0,0,0,0, # 10 - 17
-0,0,0,1,0,0,0,0, # 18 - 1f
-0,0,0,0,7,0,0,0, # 20 - 27
-3,0,0,0,0,0,0,0, # 28 - 2f
-0,0,0,0,0,0,0,0, # 30 - 37
-0,0,0,0,0,0,0,0, # 38 - 3f
-6,0,4,0,8,0,0,0, # 40 - 47
-0,9,5,0,0,0,0,0, # 48 - 4f
-0,0,0,0,0,0,0,0, # 50 - 57
-0,0,0,0,0,0,0,0, # 58 - 5f
-0,0,0,0,0,0,0,0, # 60 - 67
-0,0,0,0,0,0,0,0, # 68 - 6f
-0,0,0,0,0,0,0,0, # 70 - 77
-0,0,0,0,0,0,0,0, # 78 - 7f
-2,2,2,2,2,2,2,2, # 80 - 87
-2,2,2,2,2,2,2,2, # 88 - 8f
-2,2,2,2,2,2,2,2, # 90 - 97
-2,2,2,2,2,2,2,2, # 98 - 9f
-2,2,2,2,2,2,2,2, # a0 - a7
-2,2,2,2,2,2,2,2, # a8 - af
-2,2,2,2,2,2,2,2, # b0 - b7
-2,2,2,2,2,2,2,2, # b8 - bf
-2,2,2,2,2,2,2,2, # c0 - c7
-2,2,2,2,2,2,2,2, # c8 - cf
-2,2,2,2,2,2,2,2, # d0 - d7
-2,2,2,2,2,2,2,2, # d8 - df
-2,2,2,2,2,2,2,2, # e0 - e7
-2,2,2,2,2,2,2,2, # e8 - ef
-2,2,2,2,2,2,2,2, # f0 - f7
-2,2,2,2,2,2,2,2, # f8 - ff
-)
-
-ISO2022JP_st = (
-eStart, 3,eError,eStart,eStart,eStart,eStart,eStart,# 00-07
-eStart,eStart,eError,eError,eError,eError,eError,eError,# 08-0f
-eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,# 10-17
-eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,eError,# 18-1f
-eError, 5,eError,eError,eError, 4,eError,eError,# 20-27
-eError,eError,eError, 6,eItsMe,eError,eItsMe,eError,# 28-2f
-eError,eError,eError,eError,eError,eError,eItsMe,eItsMe,# 30-37
-eError,eError,eError,eItsMe,eError,eError,eError,eError,# 38-3f
-eError,eError,eError,eError,eItsMe,eError,eStart,eStart,# 40-47
-)
-
-ISO2022JPCharLenTable = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
-
-ISO2022JPSMModel = {'classTable': ISO2022JP_cls,
- 'classFactor': 10,
- 'stateTable': ISO2022JP_st,
- 'charLenTable': ISO2022JPCharLenTable,
- 'name': "ISO-2022-JP"}
-
-ISO2022KR_cls = (
-2,0,0,0,0,0,0,0, # 00 - 07
-0,0,0,0,0,0,0,0, # 08 - 0f
-0,0,0,0,0,0,0,0, # 10 - 17
-0,0,0,1,0,0,0,0, # 18 - 1f
-0,0,0,0,3,0,0,0, # 20 - 27
-0,4,0,0,0,0,0,0, # 28 - 2f
-0,0,0,0,0,0,0,0, # 30 - 37
-0,0,0,0,0,0,0,0, # 38 - 3f
-0,0,0,5,0,0,0,0, # 40 - 47
-0,0,0,0,0,0,0,0, # 48 - 4f
-0,0,0,0,0,0,0,0, # 50 - 57
-0,0,0,0,0,0,0,0, # 58 - 5f
-0,0,0,0,0,0,0,0, # 60 - 67
-0,0,0,0,0,0,0,0, # 68 - 6f
-0,0,0,0,0,0,0,0, # 70 - 77
-0,0,0,0,0,0,0,0, # 78 - 7f
-2,2,2,2,2,2,2,2, # 80 - 87
-2,2,2,2,2,2,2,2, # 88 - 8f
-2,2,2,2,2,2,2,2, # 90 - 97
-2,2,2,2,2,2,2,2, # 98 - 9f
-2,2,2,2,2,2,2,2, # a0 - a7
-2,2,2,2,2,2,2,2, # a8 - af
-2,2,2,2,2,2,2,2, # b0 - b7
-2,2,2,2,2,2,2,2, # b8 - bf
-2,2,2,2,2,2,2,2, # c0 - c7
-2,2,2,2,2,2,2,2, # c8 - cf
-2,2,2,2,2,2,2,2, # d0 - d7
-2,2,2,2,2,2,2,2, # d8 - df
-2,2,2,2,2,2,2,2, # e0 - e7
-2,2,2,2,2,2,2,2, # e8 - ef
-2,2,2,2,2,2,2,2, # f0 - f7
-2,2,2,2,2,2,2,2, # f8 - ff
-)
-
-ISO2022KR_st = (
-eStart, 3,eError,eStart,eStart,eStart,eError,eError,# 00-07
-eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,# 08-0f
-eItsMe,eItsMe,eError,eError,eError, 4,eError,eError,# 10-17
-eError,eError,eError,eError, 5,eError,eError,eError,# 18-1f
-eError,eError,eError,eItsMe,eStart,eStart,eStart,eStart,# 20-27
-)
-
-ISO2022KRCharLenTable = (0, 0, 0, 0, 0, 0)
-
-ISO2022KRSMModel = {'classTable': ISO2022KR_cls,
- 'classFactor': 6,
- 'stateTable': ISO2022KR_st,
- 'charLenTable': ISO2022KRCharLenTable,
- 'name': "ISO-2022-KR"}
-
-# flake8: noqa
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+from .constants import eStart, eError, eItsMe
+
+HZ_cls = (
+1,0,0,0,0,0,0,0, # 00 - 07
+0,0,0,0,0,0,0,0, # 08 - 0f
+0,0,0,0,0,0,0,0, # 10 - 17
+0,0,0,1,0,0,0,0, # 18 - 1f
+0,0,0,0,0,0,0,0, # 20 - 27
+0,0,0,0,0,0,0,0, # 28 - 2f
+0,0,0,0,0,0,0,0, # 30 - 37
+0,0,0,0,0,0,0,0, # 38 - 3f
+0,0,0,0,0,0,0,0, # 40 - 47
+0,0,0,0,0,0,0,0, # 48 - 4f
+0,0,0,0,0,0,0,0, # 50 - 57
+0,0,0,0,0,0,0,0, # 58 - 5f
+0,0,0,0,0,0,0,0, # 60 - 67
+0,0,0,0,0,0,0,0, # 68 - 6f
+0,0,0,0,0,0,0,0, # 70 - 77
+0,0,0,4,0,5,2,0, # 78 - 7f
+1,1,1,1,1,1,1,1, # 80 - 87
+1,1,1,1,1,1,1,1, # 88 - 8f
+1,1,1,1,1,1,1,1, # 90 - 97
+1,1,1,1,1,1,1,1, # 98 - 9f
+1,1,1,1,1,1,1,1, # a0 - a7
+1,1,1,1,1,1,1,1, # a8 - af
+1,1,1,1,1,1,1,1, # b0 - b7
+1,1,1,1,1,1,1,1, # b8 - bf
+1,1,1,1,1,1,1,1, # c0 - c7
+1,1,1,1,1,1,1,1, # c8 - cf
+1,1,1,1,1,1,1,1, # d0 - d7
+1,1,1,1,1,1,1,1, # d8 - df
+1,1,1,1,1,1,1,1, # e0 - e7
+1,1,1,1,1,1,1,1, # e8 - ef
+1,1,1,1,1,1,1,1, # f0 - f7
+1,1,1,1,1,1,1,1, # f8 - ff
+)
+
+HZ_st = (
+eStart,eError, 3,eStart,eStart,eStart,eError,eError,# 00-07
+eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,# 08-0f
+eItsMe,eItsMe,eError,eError,eStart,eStart, 4,eError,# 10-17
+ 5,eError, 6,eError, 5, 5, 4,eError,# 18-1f
+ 4,eError, 4, 4, 4,eError, 4,eError,# 20-27
+ 4,eItsMe,eStart,eStart,eStart,eStart,eStart,eStart,# 28-2f
+)
+
+HZCharLenTable = (0, 0, 0, 0, 0, 0)
+
+HZSMModel = {'classTable': HZ_cls,
+ 'classFactor': 6,
+ 'stateTable': HZ_st,
+ 'charLenTable': HZCharLenTable,
+ 'name': "HZ-GB-2312"}
+
+ISO2022CN_cls = (
+2,0,0,0,0,0,0,0, # 00 - 07
+0,0,0,0,0,0,0,0, # 08 - 0f
+0,0,0,0,0,0,0,0, # 10 - 17
+0,0,0,1,0,0,0,0, # 18 - 1f
+0,0,0,0,0,0,0,0, # 20 - 27
+0,3,0,0,0,0,0,0, # 28 - 2f
+0,0,0,0,0,0,0,0, # 30 - 37
+0,0,0,0,0,0,0,0, # 38 - 3f
+0,0,0,4,0,0,0,0, # 40 - 47
+0,0,0,0,0,0,0,0, # 48 - 4f
+0,0,0,0,0,0,0,0, # 50 - 57
+0,0,0,0,0,0,0,0, # 58 - 5f
+0,0,0,0,0,0,0,0, # 60 - 67
+0,0,0,0,0,0,0,0, # 68 - 6f
+0,0,0,0,0,0,0,0, # 70 - 77
+0,0,0,0,0,0,0,0, # 78 - 7f
+2,2,2,2,2,2,2,2, # 80 - 87
+2,2,2,2,2,2,2,2, # 88 - 8f
+2,2,2,2,2,2,2,2, # 90 - 97
+2,2,2,2,2,2,2,2, # 98 - 9f
+2,2,2,2,2,2,2,2, # a0 - a7
+2,2,2,2,2,2,2,2, # a8 - af
+2,2,2,2,2,2,2,2, # b0 - b7
+2,2,2,2,2,2,2,2, # b8 - bf
+2,2,2,2,2,2,2,2, # c0 - c7
+2,2,2,2,2,2,2,2, # c8 - cf
+2,2,2,2,2,2,2,2, # d0 - d7
+2,2,2,2,2,2,2,2, # d8 - df
+2,2,2,2,2,2,2,2, # e0 - e7
+2,2,2,2,2,2,2,2, # e8 - ef
+2,2,2,2,2,2,2,2, # f0 - f7
+2,2,2,2,2,2,2,2, # f8 - ff
+)
+
+ISO2022CN_st = (
+eStart, 3,eError,eStart,eStart,eStart,eStart,eStart,# 00-07
+eStart,eError,eError,eError,eError,eError,eError,eError,# 08-0f
+eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,# 10-17
+eItsMe,eItsMe,eItsMe,eError,eError,eError, 4,eError,# 18-1f
+eError,eError,eError,eItsMe,eError,eError,eError,eError,# 20-27
+ 5, 6,eError,eError,eError,eError,eError,eError,# 28-2f
+eError,eError,eError,eItsMe,eError,eError,eError,eError,# 30-37
+eError,eError,eError,eError,eError,eItsMe,eError,eStart,# 38-3f
+)
+
+ISO2022CNCharLenTable = (0, 0, 0, 0, 0, 0, 0, 0, 0)
+
+ISO2022CNSMModel = {'classTable': ISO2022CN_cls,
+ 'classFactor': 9,
+ 'stateTable': ISO2022CN_st,
+ 'charLenTable': ISO2022CNCharLenTable,
+ 'name': "ISO-2022-CN"}
+
+ISO2022JP_cls = (
+2,0,0,0,0,0,0,0, # 00 - 07
+0,0,0,0,0,0,2,2, # 08 - 0f
+0,0,0,0,0,0,0,0, # 10 - 17
+0,0,0,1,0,0,0,0, # 18 - 1f
+0,0,0,0,7,0,0,0, # 20 - 27
+3,0,0,0,0,0,0,0, # 28 - 2f
+0,0,0,0,0,0,0,0, # 30 - 37
+0,0,0,0,0,0,0,0, # 38 - 3f
+6,0,4,0,8,0,0,0, # 40 - 47
+0,9,5,0,0,0,0,0, # 48 - 4f
+0,0,0,0,0,0,0,0, # 50 - 57
+0,0,0,0,0,0,0,0, # 58 - 5f
+0,0,0,0,0,0,0,0, # 60 - 67
+0,0,0,0,0,0,0,0, # 68 - 6f
+0,0,0,0,0,0,0,0, # 70 - 77
+0,0,0,0,0,0,0,0, # 78 - 7f
+2,2,2,2,2,2,2,2, # 80 - 87
+2,2,2,2,2,2,2,2, # 88 - 8f
+2,2,2,2,2,2,2,2, # 90 - 97
+2,2,2,2,2,2,2,2, # 98 - 9f
+2,2,2,2,2,2,2,2, # a0 - a7
+2,2,2,2,2,2,2,2, # a8 - af
+2,2,2,2,2,2,2,2, # b0 - b7
+2,2,2,2,2,2,2,2, # b8 - bf
+2,2,2,2,2,2,2,2, # c0 - c7
+2,2,2,2,2,2,2,2, # c8 - cf
+2,2,2,2,2,2,2,2, # d0 - d7
+2,2,2,2,2,2,2,2, # d8 - df
+2,2,2,2,2,2,2,2, # e0 - e7
+2,2,2,2,2,2,2,2, # e8 - ef
+2,2,2,2,2,2,2,2, # f0 - f7
+2,2,2,2,2,2,2,2, # f8 - ff
+)
+
+ISO2022JP_st = (
+eStart, 3,eError,eStart,eStart,eStart,eStart,eStart,# 00-07
+eStart,eStart,eError,eError,eError,eError,eError,eError,# 08-0f
+eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,# 10-17
+eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,eError,# 18-1f
+eError, 5,eError,eError,eError, 4,eError,eError,# 20-27
+eError,eError,eError, 6,eItsMe,eError,eItsMe,eError,# 28-2f
+eError,eError,eError,eError,eError,eError,eItsMe,eItsMe,# 30-37
+eError,eError,eError,eItsMe,eError,eError,eError,eError,# 38-3f
+eError,eError,eError,eError,eItsMe,eError,eStart,eStart,# 40-47
+)
+
+ISO2022JPCharLenTable = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
+
+ISO2022JPSMModel = {'classTable': ISO2022JP_cls,
+ 'classFactor': 10,
+ 'stateTable': ISO2022JP_st,
+ 'charLenTable': ISO2022JPCharLenTable,
+ 'name': "ISO-2022-JP"}
+
+ISO2022KR_cls = (
+2,0,0,0,0,0,0,0, # 00 - 07
+0,0,0,0,0,0,0,0, # 08 - 0f
+0,0,0,0,0,0,0,0, # 10 - 17
+0,0,0,1,0,0,0,0, # 18 - 1f
+0,0,0,0,3,0,0,0, # 20 - 27
+0,4,0,0,0,0,0,0, # 28 - 2f
+0,0,0,0,0,0,0,0, # 30 - 37
+0,0,0,0,0,0,0,0, # 38 - 3f
+0,0,0,5,0,0,0,0, # 40 - 47
+0,0,0,0,0,0,0,0, # 48 - 4f
+0,0,0,0,0,0,0,0, # 50 - 57
+0,0,0,0,0,0,0,0, # 58 - 5f
+0,0,0,0,0,0,0,0, # 60 - 67
+0,0,0,0,0,0,0,0, # 68 - 6f
+0,0,0,0,0,0,0,0, # 70 - 77
+0,0,0,0,0,0,0,0, # 78 - 7f
+2,2,2,2,2,2,2,2, # 80 - 87
+2,2,2,2,2,2,2,2, # 88 - 8f
+2,2,2,2,2,2,2,2, # 90 - 97
+2,2,2,2,2,2,2,2, # 98 - 9f
+2,2,2,2,2,2,2,2, # a0 - a7
+2,2,2,2,2,2,2,2, # a8 - af
+2,2,2,2,2,2,2,2, # b0 - b7
+2,2,2,2,2,2,2,2, # b8 - bf
+2,2,2,2,2,2,2,2, # c0 - c7
+2,2,2,2,2,2,2,2, # c8 - cf
+2,2,2,2,2,2,2,2, # d0 - d7
+2,2,2,2,2,2,2,2, # d8 - df
+2,2,2,2,2,2,2,2, # e0 - e7
+2,2,2,2,2,2,2,2, # e8 - ef
+2,2,2,2,2,2,2,2, # f0 - f7
+2,2,2,2,2,2,2,2, # f8 - ff
+)
+
+ISO2022KR_st = (
+eStart, 3,eError,eStart,eStart,eStart,eError,eError,# 00-07
+eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,# 08-0f
+eItsMe,eItsMe,eError,eError,eError, 4,eError,eError,# 10-17
+eError,eError,eError,eError, 5,eError,eError,eError,# 18-1f
+eError,eError,eError,eItsMe,eStart,eStart,eStart,eStart,# 20-27
+)
+
+ISO2022KRCharLenTable = (0, 0, 0, 0, 0, 0)
+
+ISO2022KRSMModel = {'classTable': ISO2022KR_cls,
+ 'classFactor': 6,
+ 'stateTable': ISO2022KR_st,
+ 'charLenTable': ISO2022KRCharLenTable,
+ 'name': "ISO-2022-KR"}
+
+# flake8: noqa
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/eucjpprober.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/eucjpprober.py
similarity index 97%
rename from app/src/processing/app/i18n/python/requests/packages/charade/eucjpprober.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/eucjpprober.py
index d70cfbbb017..8e64fdcc266 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/eucjpprober.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/eucjpprober.py
@@ -1,90 +1,90 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is mozilla.org code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-import sys
-from . import constants
-from .mbcharsetprober import MultiByteCharSetProber
-from .codingstatemachine import CodingStateMachine
-from .chardistribution import EUCJPDistributionAnalysis
-from .jpcntx import EUCJPContextAnalysis
-from .mbcssm import EUCJPSMModel
-
-
-class EUCJPProber(MultiByteCharSetProber):
- def __init__(self):
- MultiByteCharSetProber.__init__(self)
- self._mCodingSM = CodingStateMachine(EUCJPSMModel)
- self._mDistributionAnalyzer = EUCJPDistributionAnalysis()
- self._mContextAnalyzer = EUCJPContextAnalysis()
- self.reset()
-
- def reset(self):
- MultiByteCharSetProber.reset(self)
- self._mContextAnalyzer.reset()
-
- def get_charset_name(self):
- return "EUC-JP"
-
- def feed(self, aBuf):
- aLen = len(aBuf)
- for i in range(0, aLen):
- # PY3K: aBuf is a byte array, so aBuf[i] is an int, not a byte
- codingState = self._mCodingSM.next_state(aBuf[i])
- if codingState == constants.eError:
- if constants._debug:
- sys.stderr.write(self.get_charset_name()
- + ' prober hit error at byte ' + str(i)
- + '\n')
- self._mState = constants.eNotMe
- break
- elif codingState == constants.eItsMe:
- self._mState = constants.eFoundIt
- break
- elif codingState == constants.eStart:
- charLen = self._mCodingSM.get_current_charlen()
- if i == 0:
- self._mLastChar[1] = aBuf[0]
- self._mContextAnalyzer.feed(self._mLastChar, charLen)
- self._mDistributionAnalyzer.feed(self._mLastChar, charLen)
- else:
- self._mContextAnalyzer.feed(aBuf[i - 1:i + 1], charLen)
- self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1],
- charLen)
-
- self._mLastChar[0] = aBuf[aLen - 1]
-
- if self.get_state() == constants.eDetecting:
- if (self._mContextAnalyzer.got_enough_data() and
- (self.get_confidence() > constants.SHORTCUT_THRESHOLD)):
- self._mState = constants.eFoundIt
-
- return self.get_state()
-
- def get_confidence(self):
- contxtCf = self._mContextAnalyzer.get_confidence()
- distribCf = self._mDistributionAnalyzer.get_confidence()
- return max(contxtCf, distribCf)
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+import sys
+from . import constants
+from .mbcharsetprober import MultiByteCharSetProber
+from .codingstatemachine import CodingStateMachine
+from .chardistribution import EUCJPDistributionAnalysis
+from .jpcntx import EUCJPContextAnalysis
+from .mbcssm import EUCJPSMModel
+
+
+class EUCJPProber(MultiByteCharSetProber):
+ def __init__(self):
+ MultiByteCharSetProber.__init__(self)
+ self._mCodingSM = CodingStateMachine(EUCJPSMModel)
+ self._mDistributionAnalyzer = EUCJPDistributionAnalysis()
+ self._mContextAnalyzer = EUCJPContextAnalysis()
+ self.reset()
+
+ def reset(self):
+ MultiByteCharSetProber.reset(self)
+ self._mContextAnalyzer.reset()
+
+ def get_charset_name(self):
+ return "EUC-JP"
+
+ def feed(self, aBuf):
+ aLen = len(aBuf)
+ for i in range(0, aLen):
+ # PY3K: aBuf is a byte array, so aBuf[i] is an int, not a byte
+ codingState = self._mCodingSM.next_state(aBuf[i])
+ if codingState == constants.eError:
+ if constants._debug:
+ sys.stderr.write(self.get_charset_name()
+ + ' prober hit error at byte ' + str(i)
+ + '\n')
+ self._mState = constants.eNotMe
+ break
+ elif codingState == constants.eItsMe:
+ self._mState = constants.eFoundIt
+ break
+ elif codingState == constants.eStart:
+ charLen = self._mCodingSM.get_current_charlen()
+ if i == 0:
+ self._mLastChar[1] = aBuf[0]
+ self._mContextAnalyzer.feed(self._mLastChar, charLen)
+ self._mDistributionAnalyzer.feed(self._mLastChar, charLen)
+ else:
+ self._mContextAnalyzer.feed(aBuf[i - 1:i + 1], charLen)
+ self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1],
+ charLen)
+
+ self._mLastChar[0] = aBuf[aLen - 1]
+
+ if self.get_state() == constants.eDetecting:
+ if (self._mContextAnalyzer.got_enough_data() and
+ (self.get_confidence() > constants.SHORTCUT_THRESHOLD)):
+ self._mState = constants.eFoundIt
+
+ return self.get_state()
+
+ def get_confidence(self):
+ contxtCf = self._mContextAnalyzer.get_confidence()
+ distribCf = self._mDistributionAnalyzer.get_confidence()
+ return max(contxtCf, distribCf)
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/euckrfreq.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/euckrfreq.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/packages/charade/euckrfreq.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/euckrfreq.py
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/euckrprober.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/euckrprober.py
similarity index 97%
rename from app/src/processing/app/i18n/python/requests/packages/charade/euckrprober.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/euckrprober.py
index def3e429028..5982a46b606 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/euckrprober.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/euckrprober.py
@@ -1,42 +1,42 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is mozilla.org code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-from .mbcharsetprober import MultiByteCharSetProber
-from .codingstatemachine import CodingStateMachine
-from .chardistribution import EUCKRDistributionAnalysis
-from .mbcssm import EUCKRSMModel
-
-
-class EUCKRProber(MultiByteCharSetProber):
- def __init__(self):
- MultiByteCharSetProber.__init__(self)
- self._mCodingSM = CodingStateMachine(EUCKRSMModel)
- self._mDistributionAnalyzer = EUCKRDistributionAnalysis()
- self.reset()
-
- def get_charset_name(self):
- return "EUC-KR"
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+from .mbcharsetprober import MultiByteCharSetProber
+from .codingstatemachine import CodingStateMachine
+from .chardistribution import EUCKRDistributionAnalysis
+from .mbcssm import EUCKRSMModel
+
+
+class EUCKRProber(MultiByteCharSetProber):
+ def __init__(self):
+ MultiByteCharSetProber.__init__(self)
+ self._mCodingSM = CodingStateMachine(EUCKRSMModel)
+ self._mDistributionAnalyzer = EUCKRDistributionAnalysis()
+ self.reset()
+
+ def get_charset_name(self):
+ return "EUC-KR"
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/euctwfreq.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/euctwfreq.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/packages/charade/euctwfreq.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/euctwfreq.py
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/euctwprober.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/euctwprober.py
similarity index 97%
rename from app/src/processing/app/i18n/python/requests/packages/charade/euctwprober.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/euctwprober.py
index e601adfdc60..fe652fe37a9 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/euctwprober.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/euctwprober.py
@@ -1,41 +1,41 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is mozilla.org code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-from .mbcharsetprober import MultiByteCharSetProber
-from .codingstatemachine import CodingStateMachine
-from .chardistribution import EUCTWDistributionAnalysis
-from .mbcssm import EUCTWSMModel
-
-class EUCTWProber(MultiByteCharSetProber):
- def __init__(self):
- MultiByteCharSetProber.__init__(self)
- self._mCodingSM = CodingStateMachine(EUCTWSMModel)
- self._mDistributionAnalyzer = EUCTWDistributionAnalysis()
- self.reset()
-
- def get_charset_name(self):
- return "EUC-TW"
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+from .mbcharsetprober import MultiByteCharSetProber
+from .codingstatemachine import CodingStateMachine
+from .chardistribution import EUCTWDistributionAnalysis
+from .mbcssm import EUCTWSMModel
+
+class EUCTWProber(MultiByteCharSetProber):
+ def __init__(self):
+ MultiByteCharSetProber.__init__(self)
+ self._mCodingSM = CodingStateMachine(EUCTWSMModel)
+ self._mDistributionAnalyzer = EUCTWDistributionAnalysis()
+ self.reset()
+
+ def get_charset_name(self):
+ return "EUC-TW"
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/gb2312freq.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/gb2312freq.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/packages/charade/gb2312freq.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/gb2312freq.py
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/gb2312prober.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/gb2312prober.py
similarity index 97%
rename from app/src/processing/app/i18n/python/requests/packages/charade/gb2312prober.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/gb2312prober.py
index 643fe2519e7..0325a2d8614 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/gb2312prober.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/gb2312prober.py
@@ -1,41 +1,41 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is mozilla.org code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-from .mbcharsetprober import MultiByteCharSetProber
-from .codingstatemachine import CodingStateMachine
-from .chardistribution import GB2312DistributionAnalysis
-from .mbcssm import GB2312SMModel
-
-class GB2312Prober(MultiByteCharSetProber):
- def __init__(self):
- MultiByteCharSetProber.__init__(self)
- self._mCodingSM = CodingStateMachine(GB2312SMModel)
- self._mDistributionAnalyzer = GB2312DistributionAnalysis()
- self.reset()
-
- def get_charset_name(self):
- return "GB2312"
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+from .mbcharsetprober import MultiByteCharSetProber
+from .codingstatemachine import CodingStateMachine
+from .chardistribution import GB2312DistributionAnalysis
+from .mbcssm import GB2312SMModel
+
+class GB2312Prober(MultiByteCharSetProber):
+ def __init__(self):
+ MultiByteCharSetProber.__init__(self)
+ self._mCodingSM = CodingStateMachine(GB2312SMModel)
+ self._mDistributionAnalyzer = GB2312DistributionAnalysis()
+ self.reset()
+
+ def get_charset_name(self):
+ return "GB2312"
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/hebrewprober.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/hebrewprober.py
similarity index 97%
rename from app/src/processing/app/i18n/python/requests/packages/charade/hebrewprober.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/hebrewprober.py
index 90d171f302d..ba225c5ef43 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/hebrewprober.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/hebrewprober.py
@@ -1,283 +1,283 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is Mozilla Universal charset detector code.
-#
-# The Initial Developer of the Original Code is
-# Shy Shalom
-# Portions created by the Initial Developer are Copyright (C) 2005
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-from .charsetprober import CharSetProber
-from .constants import eNotMe, eDetecting
-from .compat import wrap_ord
-
-# This prober doesn't actually recognize a language or a charset.
-# It is a helper prober for the use of the Hebrew model probers
-
-### General ideas of the Hebrew charset recognition ###
-#
-# Four main charsets exist in Hebrew:
-# "ISO-8859-8" - Visual Hebrew
-# "windows-1255" - Logical Hebrew
-# "ISO-8859-8-I" - Logical Hebrew
-# "x-mac-hebrew" - ?? Logical Hebrew ??
-#
-# Both "ISO" charsets use a completely identical set of code points, whereas
-# "windows-1255" and "x-mac-hebrew" are two different proper supersets of
-# these code points. windows-1255 defines additional characters in the range
-# 0x80-0x9F as some misc punctuation marks as well as some Hebrew-specific
-# diacritics and additional 'Yiddish' ligature letters in the range 0xc0-0xd6.
-# x-mac-hebrew defines similar additional code points but with a different
-# mapping.
-#
-# As far as an average Hebrew text with no diacritics is concerned, all four
-# charsets are identical with respect to code points. Meaning that for the
-# main Hebrew alphabet, all four map the same values to all 27 Hebrew letters
-# (including final letters).
-#
-# The dominant difference between these charsets is their directionality.
-# "Visual" directionality means that the text is ordered as if the renderer is
-# not aware of a BIDI rendering algorithm. The renderer sees the text and
-# draws it from left to right. The text itself when ordered naturally is read
-# backwards. A buffer of Visual Hebrew generally looks like so:
-# "[last word of first line spelled backwards] [whole line ordered backwards
-# and spelled backwards] [first word of first line spelled backwards]
-# [end of line] [last word of second line] ... etc' "
-# adding punctuation marks, numbers and English text to visual text is
-# naturally also "visual" and from left to right.
-#
-# "Logical" directionality means the text is ordered "naturally" according to
-# the order it is read. It is the responsibility of the renderer to display
-# the text from right to left. A BIDI algorithm is used to place general
-# punctuation marks, numbers and English text in the text.
-#
-# Texts in x-mac-hebrew are almost impossible to find on the Internet. From
-# what little evidence I could find, it seems that its general directionality
-# is Logical.
-#
-# To sum up all of the above, the Hebrew probing mechanism knows about two
-# charsets:
-# Visual Hebrew - "ISO-8859-8" - backwards text - Words and sentences are
-# backwards while line order is natural. For charset recognition purposes
-# the line order is unimportant (In fact, for this implementation, even
-# word order is unimportant).
-# Logical Hebrew - "windows-1255" - normal, naturally ordered text.
-#
-# "ISO-8859-8-I" is a subset of windows-1255 and doesn't need to be
-# specifically identified.
-# "x-mac-hebrew" is also identified as windows-1255. A text in x-mac-hebrew
-# that contain special punctuation marks or diacritics is displayed with
-# some unconverted characters showing as question marks. This problem might
-# be corrected using another model prober for x-mac-hebrew. Due to the fact
-# that x-mac-hebrew texts are so rare, writing another model prober isn't
-# worth the effort and performance hit.
-#
-#### The Prober ####
-#
-# The prober is divided between two SBCharSetProbers and a HebrewProber,
-# all of which are managed, created, fed data, inquired and deleted by the
-# SBCSGroupProber. The two SBCharSetProbers identify that the text is in
-# fact some kind of Hebrew, Logical or Visual. The final decision about which
-# one is it is made by the HebrewProber by combining final-letter scores
-# with the scores of the two SBCharSetProbers to produce a final answer.
-#
-# The SBCSGroupProber is responsible for stripping the original text of HTML
-# tags, English characters, numbers, low-ASCII punctuation characters, spaces
-# and new lines. It reduces any sequence of such characters to a single space.
-# The buffer fed to each prober in the SBCS group prober is pure text in
-# high-ASCII.
-# The two SBCharSetProbers (model probers) share the same language model:
-# Win1255Model.
-# The first SBCharSetProber uses the model normally as any other
-# SBCharSetProber does, to recognize windows-1255, upon which this model was
-# built. The second SBCharSetProber is told to make the pair-of-letter
-# lookup in the language model backwards. This in practice exactly simulates
-# a visual Hebrew model using the windows-1255 logical Hebrew model.
-#
-# The HebrewProber is not using any language model. All it does is look for
-# final-letter evidence suggesting the text is either logical Hebrew or visual
-# Hebrew. Disjointed from the model probers, the results of the HebrewProber
-# alone are meaningless. HebrewProber always returns 0.00 as confidence
-# since it never identifies a charset by itself. Instead, the pointer to the
-# HebrewProber is passed to the model probers as a helper "Name Prober".
-# When the Group prober receives a positive identification from any prober,
-# it asks for the name of the charset identified. If the prober queried is a
-# Hebrew model prober, the model prober forwards the call to the
-# HebrewProber to make the final decision. In the HebrewProber, the
-# decision is made according to the final-letters scores maintained and Both
-# model probers scores. The answer is returned in the form of the name of the
-# charset identified, either "windows-1255" or "ISO-8859-8".
-
-# windows-1255 / ISO-8859-8 code points of interest
-FINAL_KAF = 0xea
-NORMAL_KAF = 0xeb
-FINAL_MEM = 0xed
-NORMAL_MEM = 0xee
-FINAL_NUN = 0xef
-NORMAL_NUN = 0xf0
-FINAL_PE = 0xf3
-NORMAL_PE = 0xf4
-FINAL_TSADI = 0xf5
-NORMAL_TSADI = 0xf6
-
-# Minimum Visual vs Logical final letter score difference.
-# If the difference is below this, don't rely solely on the final letter score
-# distance.
-MIN_FINAL_CHAR_DISTANCE = 5
-
-# Minimum Visual vs Logical model score difference.
-# If the difference is below this, don't rely at all on the model score
-# distance.
-MIN_MODEL_DISTANCE = 0.01
-
-VISUAL_HEBREW_NAME = "ISO-8859-8"
-LOGICAL_HEBREW_NAME = "windows-1255"
-
-
-class HebrewProber(CharSetProber):
- def __init__(self):
- CharSetProber.__init__(self)
- self._mLogicalProber = None
- self._mVisualProber = None
- self.reset()
-
- def reset(self):
- self._mFinalCharLogicalScore = 0
- self._mFinalCharVisualScore = 0
- # The two last characters seen in the previous buffer,
- # mPrev and mBeforePrev are initialized to space in order to simulate
- # a word delimiter at the beginning of the data
- self._mPrev = ' '
- self._mBeforePrev = ' '
- # These probers are owned by the group prober.
-
- def set_model_probers(self, logicalProber, visualProber):
- self._mLogicalProber = logicalProber
- self._mVisualProber = visualProber
-
- def is_final(self, c):
- return wrap_ord(c) in [FINAL_KAF, FINAL_MEM, FINAL_NUN, FINAL_PE,
- FINAL_TSADI]
-
- def is_non_final(self, c):
- # The normal Tsadi is not a good Non-Final letter due to words like
- # 'lechotet' (to chat) containing an apostrophe after the tsadi. This
- # apostrophe is converted to a space in FilterWithoutEnglishLetters
- # causing the Non-Final tsadi to appear at an end of a word even
- # though this is not the case in the original text.
- # The letters Pe and Kaf rarely display a related behavior of not being
- # a good Non-Final letter. Words like 'Pop', 'Winamp' and 'Mubarak'
- # for example legally end with a Non-Final Pe or Kaf. However, the
- # benefit of these letters as Non-Final letters outweighs the damage
- # since these words are quite rare.
- return wrap_ord(c) in [NORMAL_KAF, NORMAL_MEM, NORMAL_NUN, NORMAL_PE]
-
- def feed(self, aBuf):
- # Final letter analysis for logical-visual decision.
- # Look for evidence that the received buffer is either logical Hebrew
- # or visual Hebrew.
- # The following cases are checked:
- # 1) A word longer than 1 letter, ending with a final letter. This is
- # an indication that the text is laid out "naturally" since the
- # final letter really appears at the end. +1 for logical score.
- # 2) A word longer than 1 letter, ending with a Non-Final letter. In
- # normal Hebrew, words ending with Kaf, Mem, Nun, Pe or Tsadi,
- # should not end with the Non-Final form of that letter. Exceptions
- # to this rule are mentioned above in isNonFinal(). This is an
- # indication that the text is laid out backwards. +1 for visual
- # score
- # 3) A word longer than 1 letter, starting with a final letter. Final
- # letters should not appear at the beginning of a word. This is an
- # indication that the text is laid out backwards. +1 for visual
- # score.
- #
- # The visual score and logical score are accumulated throughout the
- # text and are finally checked against each other in GetCharSetName().
- # No checking for final letters in the middle of words is done since
- # that case is not an indication for either Logical or Visual text.
- #
- # We automatically filter out all 7-bit characters (replace them with
- # spaces) so the word boundary detection works properly. [MAP]
-
- if self.get_state() == eNotMe:
- # Both model probers say it's not them. No reason to continue.
- return eNotMe
-
- aBuf = self.filter_high_bit_only(aBuf)
-
- for cur in aBuf:
- if cur == ' ':
- # We stand on a space - a word just ended
- if self._mBeforePrev != ' ':
- # next-to-last char was not a space so self._mPrev is not a
- # 1 letter word
- if self.is_final(self._mPrev):
- # case (1) [-2:not space][-1:final letter][cur:space]
- self._mFinalCharLogicalScore += 1
- elif self.is_non_final(self._mPrev):
- # case (2) [-2:not space][-1:Non-Final letter][
- # cur:space]
- self._mFinalCharVisualScore += 1
- else:
- # Not standing on a space
- if ((self._mBeforePrev == ' ') and
- (self.is_final(self._mPrev)) and (cur != ' ')):
- # case (3) [-2:space][-1:final letter][cur:not space]
- self._mFinalCharVisualScore += 1
- self._mBeforePrev = self._mPrev
- self._mPrev = cur
-
- # Forever detecting, till the end or until both model probers return
- # eNotMe (handled above)
- return eDetecting
-
- def get_charset_name(self):
- # Make the decision: is it Logical or Visual?
- # If the final letter score distance is dominant enough, rely on it.
- finalsub = self._mFinalCharLogicalScore - self._mFinalCharVisualScore
- if finalsub >= MIN_FINAL_CHAR_DISTANCE:
- return LOGICAL_HEBREW_NAME
- if finalsub <= -MIN_FINAL_CHAR_DISTANCE:
- return VISUAL_HEBREW_NAME
-
- # It's not dominant enough, try to rely on the model scores instead.
- modelsub = (self._mLogicalProber.get_confidence()
- - self._mVisualProber.get_confidence())
- if modelsub > MIN_MODEL_DISTANCE:
- return LOGICAL_HEBREW_NAME
- if modelsub < -MIN_MODEL_DISTANCE:
- return VISUAL_HEBREW_NAME
-
- # Still no good, back to final letter distance, maybe it'll save the
- # day.
- if finalsub < 0.0:
- return VISUAL_HEBREW_NAME
-
- # (finalsub > 0 - Logical) or (don't know what to do) default to
- # Logical.
- return LOGICAL_HEBREW_NAME
-
- def get_state(self):
- # Remain active as long as any of the model probers are active.
- if (self._mLogicalProber.get_state() == eNotMe) and \
- (self._mVisualProber.get_state() == eNotMe):
- return eNotMe
- return eDetecting
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is Mozilla Universal charset detector code.
+#
+# The Initial Developer of the Original Code is
+# Shy Shalom
+# Portions created by the Initial Developer are Copyright (C) 2005
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+from .charsetprober import CharSetProber
+from .constants import eNotMe, eDetecting
+from .compat import wrap_ord
+
+# This prober doesn't actually recognize a language or a charset.
+# It is a helper prober for the use of the Hebrew model probers
+
+### General ideas of the Hebrew charset recognition ###
+#
+# Four main charsets exist in Hebrew:
+# "ISO-8859-8" - Visual Hebrew
+# "windows-1255" - Logical Hebrew
+# "ISO-8859-8-I" - Logical Hebrew
+# "x-mac-hebrew" - ?? Logical Hebrew ??
+#
+# Both "ISO" charsets use a completely identical set of code points, whereas
+# "windows-1255" and "x-mac-hebrew" are two different proper supersets of
+# these code points. windows-1255 defines additional characters in the range
+# 0x80-0x9F as some misc punctuation marks as well as some Hebrew-specific
+# diacritics and additional 'Yiddish' ligature letters in the range 0xc0-0xd6.
+# x-mac-hebrew defines similar additional code points but with a different
+# mapping.
+#
+# As far as an average Hebrew text with no diacritics is concerned, all four
+# charsets are identical with respect to code points. Meaning that for the
+# main Hebrew alphabet, all four map the same values to all 27 Hebrew letters
+# (including final letters).
+#
+# The dominant difference between these charsets is their directionality.
+# "Visual" directionality means that the text is ordered as if the renderer is
+# not aware of a BIDI rendering algorithm. The renderer sees the text and
+# draws it from left to right. The text itself when ordered naturally is read
+# backwards. A buffer of Visual Hebrew generally looks like so:
+# "[last word of first line spelled backwards] [whole line ordered backwards
+# and spelled backwards] [first word of first line spelled backwards]
+# [end of line] [last word of second line] ... etc' "
+# adding punctuation marks, numbers and English text to visual text is
+# naturally also "visual" and from left to right.
+#
+# "Logical" directionality means the text is ordered "naturally" according to
+# the order it is read. It is the responsibility of the renderer to display
+# the text from right to left. A BIDI algorithm is used to place general
+# punctuation marks, numbers and English text in the text.
+#
+# Texts in x-mac-hebrew are almost impossible to find on the Internet. From
+# what little evidence I could find, it seems that its general directionality
+# is Logical.
+#
+# To sum up all of the above, the Hebrew probing mechanism knows about two
+# charsets:
+# Visual Hebrew - "ISO-8859-8" - backwards text - Words and sentences are
+# backwards while line order is natural. For charset recognition purposes
+# the line order is unimportant (In fact, for this implementation, even
+# word order is unimportant).
+# Logical Hebrew - "windows-1255" - normal, naturally ordered text.
+#
+# "ISO-8859-8-I" is a subset of windows-1255 and doesn't need to be
+# specifically identified.
+# "x-mac-hebrew" is also identified as windows-1255. A text in x-mac-hebrew
+# that contain special punctuation marks or diacritics is displayed with
+# some unconverted characters showing as question marks. This problem might
+# be corrected using another model prober for x-mac-hebrew. Due to the fact
+# that x-mac-hebrew texts are so rare, writing another model prober isn't
+# worth the effort and performance hit.
+#
+#### The Prober ####
+#
+# The prober is divided between two SBCharSetProbers and a HebrewProber,
+# all of which are managed, created, fed data, inquired and deleted by the
+# SBCSGroupProber. The two SBCharSetProbers identify that the text is in
+# fact some kind of Hebrew, Logical or Visual. The final decision about which
+# one is it is made by the HebrewProber by combining final-letter scores
+# with the scores of the two SBCharSetProbers to produce a final answer.
+#
+# The SBCSGroupProber is responsible for stripping the original text of HTML
+# tags, English characters, numbers, low-ASCII punctuation characters, spaces
+# and new lines. It reduces any sequence of such characters to a single space.
+# The buffer fed to each prober in the SBCS group prober is pure text in
+# high-ASCII.
+# The two SBCharSetProbers (model probers) share the same language model:
+# Win1255Model.
+# The first SBCharSetProber uses the model normally as any other
+# SBCharSetProber does, to recognize windows-1255, upon which this model was
+# built. The second SBCharSetProber is told to make the pair-of-letter
+# lookup in the language model backwards. This in practice exactly simulates
+# a visual Hebrew model using the windows-1255 logical Hebrew model.
+#
+# The HebrewProber is not using any language model. All it does is look for
+# final-letter evidence suggesting the text is either logical Hebrew or visual
+# Hebrew. Disjointed from the model probers, the results of the HebrewProber
+# alone are meaningless. HebrewProber always returns 0.00 as confidence
+# since it never identifies a charset by itself. Instead, the pointer to the
+# HebrewProber is passed to the model probers as a helper "Name Prober".
+# When the Group prober receives a positive identification from any prober,
+# it asks for the name of the charset identified. If the prober queried is a
+# Hebrew model prober, the model prober forwards the call to the
+# HebrewProber to make the final decision. In the HebrewProber, the
+# decision is made according to the final-letters scores maintained and Both
+# model probers scores. The answer is returned in the form of the name of the
+# charset identified, either "windows-1255" or "ISO-8859-8".
+
+# windows-1255 / ISO-8859-8 code points of interest
+FINAL_KAF = 0xea
+NORMAL_KAF = 0xeb
+FINAL_MEM = 0xed
+NORMAL_MEM = 0xee
+FINAL_NUN = 0xef
+NORMAL_NUN = 0xf0
+FINAL_PE = 0xf3
+NORMAL_PE = 0xf4
+FINAL_TSADI = 0xf5
+NORMAL_TSADI = 0xf6
+
+# Minimum Visual vs Logical final letter score difference.
+# If the difference is below this, don't rely solely on the final letter score
+# distance.
+MIN_FINAL_CHAR_DISTANCE = 5
+
+# Minimum Visual vs Logical model score difference.
+# If the difference is below this, don't rely at all on the model score
+# distance.
+MIN_MODEL_DISTANCE = 0.01
+
+VISUAL_HEBREW_NAME = "ISO-8859-8"
+LOGICAL_HEBREW_NAME = "windows-1255"
+
+
+class HebrewProber(CharSetProber):
+ def __init__(self):
+ CharSetProber.__init__(self)
+ self._mLogicalProber = None
+ self._mVisualProber = None
+ self.reset()
+
+ def reset(self):
+ self._mFinalCharLogicalScore = 0
+ self._mFinalCharVisualScore = 0
+ # The two last characters seen in the previous buffer,
+ # mPrev and mBeforePrev are initialized to space in order to simulate
+ # a word delimiter at the beginning of the data
+ self._mPrev = ' '
+ self._mBeforePrev = ' '
+ # These probers are owned by the group prober.
+
+ def set_model_probers(self, logicalProber, visualProber):
+ self._mLogicalProber = logicalProber
+ self._mVisualProber = visualProber
+
+ def is_final(self, c):
+ return wrap_ord(c) in [FINAL_KAF, FINAL_MEM, FINAL_NUN, FINAL_PE,
+ FINAL_TSADI]
+
+ def is_non_final(self, c):
+ # The normal Tsadi is not a good Non-Final letter due to words like
+ # 'lechotet' (to chat) containing an apostrophe after the tsadi. This
+ # apostrophe is converted to a space in FilterWithoutEnglishLetters
+ # causing the Non-Final tsadi to appear at an end of a word even
+ # though this is not the case in the original text.
+ # The letters Pe and Kaf rarely display a related behavior of not being
+ # a good Non-Final letter. Words like 'Pop', 'Winamp' and 'Mubarak'
+ # for example legally end with a Non-Final Pe or Kaf. However, the
+ # benefit of these letters as Non-Final letters outweighs the damage
+ # since these words are quite rare.
+ return wrap_ord(c) in [NORMAL_KAF, NORMAL_MEM, NORMAL_NUN, NORMAL_PE]
+
+ def feed(self, aBuf):
+ # Final letter analysis for logical-visual decision.
+ # Look for evidence that the received buffer is either logical Hebrew
+ # or visual Hebrew.
+ # The following cases are checked:
+ # 1) A word longer than 1 letter, ending with a final letter. This is
+ # an indication that the text is laid out "naturally" since the
+ # final letter really appears at the end. +1 for logical score.
+ # 2) A word longer than 1 letter, ending with a Non-Final letter. In
+ # normal Hebrew, words ending with Kaf, Mem, Nun, Pe or Tsadi,
+ # should not end with the Non-Final form of that letter. Exceptions
+ # to this rule are mentioned above in isNonFinal(). This is an
+ # indication that the text is laid out backwards. +1 for visual
+ # score
+ # 3) A word longer than 1 letter, starting with a final letter. Final
+ # letters should not appear at the beginning of a word. This is an
+ # indication that the text is laid out backwards. +1 for visual
+ # score.
+ #
+ # The visual score and logical score are accumulated throughout the
+ # text and are finally checked against each other in GetCharSetName().
+ # No checking for final letters in the middle of words is done since
+ # that case is not an indication for either Logical or Visual text.
+ #
+ # We automatically filter out all 7-bit characters (replace them with
+ # spaces) so the word boundary detection works properly. [MAP]
+
+ if self.get_state() == eNotMe:
+ # Both model probers say it's not them. No reason to continue.
+ return eNotMe
+
+ aBuf = self.filter_high_bit_only(aBuf)
+
+ for cur in aBuf:
+ if cur == ' ':
+ # We stand on a space - a word just ended
+ if self._mBeforePrev != ' ':
+ # next-to-last char was not a space so self._mPrev is not a
+ # 1 letter word
+ if self.is_final(self._mPrev):
+ # case (1) [-2:not space][-1:final letter][cur:space]
+ self._mFinalCharLogicalScore += 1
+ elif self.is_non_final(self._mPrev):
+ # case (2) [-2:not space][-1:Non-Final letter][
+ # cur:space]
+ self._mFinalCharVisualScore += 1
+ else:
+ # Not standing on a space
+ if ((self._mBeforePrev == ' ') and
+ (self.is_final(self._mPrev)) and (cur != ' ')):
+ # case (3) [-2:space][-1:final letter][cur:not space]
+ self._mFinalCharVisualScore += 1
+ self._mBeforePrev = self._mPrev
+ self._mPrev = cur
+
+ # Forever detecting, till the end or until both model probers return
+ # eNotMe (handled above)
+ return eDetecting
+
+ def get_charset_name(self):
+ # Make the decision: is it Logical or Visual?
+ # If the final letter score distance is dominant enough, rely on it.
+ finalsub = self._mFinalCharLogicalScore - self._mFinalCharVisualScore
+ if finalsub >= MIN_FINAL_CHAR_DISTANCE:
+ return LOGICAL_HEBREW_NAME
+ if finalsub <= -MIN_FINAL_CHAR_DISTANCE:
+ return VISUAL_HEBREW_NAME
+
+ # It's not dominant enough, try to rely on the model scores instead.
+ modelsub = (self._mLogicalProber.get_confidence()
+ - self._mVisualProber.get_confidence())
+ if modelsub > MIN_MODEL_DISTANCE:
+ return LOGICAL_HEBREW_NAME
+ if modelsub < -MIN_MODEL_DISTANCE:
+ return VISUAL_HEBREW_NAME
+
+ # Still no good, back to final letter distance, maybe it'll save the
+ # day.
+ if finalsub < 0.0:
+ return VISUAL_HEBREW_NAME
+
+ # (finalsub > 0 - Logical) or (don't know what to do) default to
+ # Logical.
+ return LOGICAL_HEBREW_NAME
+
+ def get_state(self):
+ # Remain active as long as any of the model probers are active.
+ if (self._mLogicalProber.get_state() == eNotMe) and \
+ (self._mVisualProber.get_state() == eNotMe):
+ return eNotMe
+ return eDetecting
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/jisfreq.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/jisfreq.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/packages/charade/jisfreq.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/jisfreq.py
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/jpcntx.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/jpcntx.py
similarity index 98%
rename from app/src/processing/app/i18n/python/requests/packages/charade/jpcntx.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/jpcntx.py
index b4e6af44a98..f7f69ba4cda 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/jpcntx.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/jpcntx.py
@@ -1,219 +1,219 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is Mozilla Communicator client code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-from .compat import wrap_ord
-
-NUM_OF_CATEGORY = 6
-DONT_KNOW = -1
-ENOUGH_REL_THRESHOLD = 100
-MAX_REL_THRESHOLD = 1000
-MINIMUM_DATA_THRESHOLD = 4
-
-# This is hiragana 2-char sequence table, the number in each cell represents its frequency category
-jp2CharContext = (
-(0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1),
-(2,4,0,4,0,3,0,4,0,3,4,4,4,2,4,3,3,4,3,2,3,3,4,2,3,3,3,2,4,1,4,3,3,1,5,4,3,4,3,4,3,5,3,0,3,5,4,2,0,3,1,0,3,3,0,3,3,0,1,1,0,4,3,0,3,3,0,4,0,2,0,3,5,5,5,5,4,0,4,1,0,3,4),
-(0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2),
-(0,4,0,5,0,5,0,4,0,4,5,4,4,3,5,3,5,1,5,3,4,3,4,4,3,4,3,3,4,3,5,4,4,3,5,5,3,5,5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3,3,3,4,4,4,3,3,3,3,4,3,5,3,3,1,3,2,4,5,5,5,5,4,3,4,5,5,3,2,2,3,3,3,3,2,3,3,1,2,3,2,4,3,3,3,4,0,4,0,2,0,4,3,2,2,1,2,0,3,0,0,4,1),
-)
-
-class JapaneseContextAnalysis:
- def __init__(self):
- self.reset()
-
- def reset(self):
- self._mTotalRel = 0 # total sequence received
- # category counters, each interger counts sequence in its category
- self._mRelSample = [0] * NUM_OF_CATEGORY
- # if last byte in current buffer is not the last byte of a character,
- # we need to know how many bytes to skip in next buffer
- self._mNeedToSkipCharNum = 0
- self._mLastCharOrder = -1 # The order of previous char
- # If this flag is set to True, detection is done and conclusion has
- # been made
- self._mDone = False
-
- def feed(self, aBuf, aLen):
- if self._mDone:
- return
-
- # The buffer we got is byte oriented, and a character may span in more than one
- # buffers. In case the last one or two byte in last buffer is not
- # complete, we record how many byte needed to complete that character
- # and skip these bytes here. We can choose to record those bytes as
- # well and analyse the character once it is complete, but since a
- # character will not make much difference, by simply skipping
- # this character will simply our logic and improve performance.
- i = self._mNeedToSkipCharNum
- while i < aLen:
- order, charLen = self.get_order(aBuf[i:i + 2])
- i += charLen
- if i > aLen:
- self._mNeedToSkipCharNum = i - aLen
- self._mLastCharOrder = -1
- else:
- if (order != -1) and (self._mLastCharOrder != -1):
- self._mTotalRel += 1
- if self._mTotalRel > MAX_REL_THRESHOLD:
- self._mDone = True
- break
- self._mRelSample[jp2CharContext[self._mLastCharOrder][order]] += 1
- self._mLastCharOrder = order
-
- def got_enough_data(self):
- return self._mTotalRel > ENOUGH_REL_THRESHOLD
-
- def get_confidence(self):
- # This is just one way to calculate confidence. It works well for me.
- if self._mTotalRel > MINIMUM_DATA_THRESHOLD:
- return (self._mTotalRel - self._mRelSample[0]) / self._mTotalRel
- else:
- return DONT_KNOW
-
- def get_order(self, aBuf):
- return -1, 1
-
-class SJISContextAnalysis(JapaneseContextAnalysis):
- def get_order(self, aBuf):
- if not aBuf:
- return -1, 1
- # find out current char's byte length
- first_char = wrap_ord(aBuf[0])
- if ((0x81 <= first_char <= 0x9F) or (0xE0 <= first_char <= 0xFC)):
- charLen = 2
- else:
- charLen = 1
-
- # return its order if it is hiragana
- if len(aBuf) > 1:
- second_char = wrap_ord(aBuf[1])
- if (first_char == 202) and (0x9F <= second_char <= 0xF1):
- return second_char - 0x9F, charLen
-
- return -1, charLen
-
-class EUCJPContextAnalysis(JapaneseContextAnalysis):
- def get_order(self, aBuf):
- if not aBuf:
- return -1, 1
- # find out current char's byte length
- first_char = wrap_ord(aBuf[0])
- if (first_char == 0x8E) or (0xA1 <= first_char <= 0xFE):
- charLen = 2
- elif first_char == 0x8F:
- charLen = 3
- else:
- charLen = 1
-
- # return its order if it is hiragana
- if len(aBuf) > 1:
- second_char = wrap_ord(aBuf[1])
- if (first_char == 0xA4) and (0xA1 <= second_char <= 0xF3):
- return second_char - 0xA1, charLen
-
- return -1, charLen
-
-# flake8: noqa
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is Mozilla Communicator client code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+from .compat import wrap_ord
+
+NUM_OF_CATEGORY = 6
+DONT_KNOW = -1
+ENOUGH_REL_THRESHOLD = 100
+MAX_REL_THRESHOL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,3,1,4,3,4,0,4,3,3,3,2,3,2,5,3,4,3,2,2,3,0,0,3,0,2,1,0,1,2,0,0,0,0,2,1,1,3,1,0,2,0,4,0,3,4,4,4,5,2,0,2,0,0,1,3),
+(0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,0,0,1,1,0,0,0,4,2,1,1,0,1,0,3,2,0,0,3,1,1,1,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,1,0,0,0,2,0,0,0,1,4,0,4,2,1,0,0,0,0,0,1),
+(0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,1,0,0,0,0,0,0,1,0,1,0,0,0,0,3,1,0,0,0,2,0,2,1,0,0,1,2,1,0,1,1,0,0,3,0,0,0,0,0,0,0,0,0,0,0,1,3,1,0,0,0,0,0,1,0,0,2,1,0,0,0,0,0,0,0,0,2),
+(0,4,0,4,0,4,0,3,0,4,4,3,4,2,4,3,2,0,4,4,4,3,5,3,5,3,3,2,4,2,4,3,4,3,1,4,0,2,3,4,4,4,3,3,3,4,4,4,3,4,1,3,4,3,2,1,2,1,3,3,3,4,4,3,3,5,0,4,0,3,0,4,3,3,3,2,1,0,3,0,0,3,3),
+(0,4,0,3,0,3,0,3,0,3,5,5,3,3,3,3,4,3,4,3,3,3,4,4,4,3,3,3,3,4,3,5,3,3,1,3,2,4,5,5,5,5,4,3,4,5,5,3,2,2,3,3,3,3,2,3,3,1,2,3,2,4,3,3,3,4,0,4,0,2,0,4,3,2,2,1,2,0,3,0,0,4,1),
+)
+
+class JapaneseContextAnalysis:
+ def __init__(self):
+ self.reset()
+
+ def reset(self):
+ self._mTotalRel = 0 # total sequence received
+ # category counters, each interger counts sequence in its category
+ self._mRelSample = [0] * NUM_OF_CATEGORY
+ # if last byte in current buffer is not the last byte of a character,
+ # we need to know how many bytes to skip in next buffer
+ self._mNeedToSkipCharNum = 0
+ self._mLastCharOrder = -1 # The order of previous char
+ # If this flag is set to True, detection is done and conclusion has
+ # been made
+ self._mDone = False
+
+ def feed(self, aBuf, aLen):
+ if self._mDone:
+ return
+
+ # The buffer we got is byte oriented, and a character may span in more than one
+ # buffers. In case the last one or two byte in last buffer is not
+ # complete, we record how many byte needed to complete that character
+ # and skip these bytes here. We can choose to record those bytes as
+ # well and analyse the character once it is complete, but since a
+ # character will not make much difference, by simply skipping
+ # this character will simply our logic and improve performance.
+ i = self._mNeedToSkipCharNum
+ while i < aLen:
+ order, charLen = self.get_order(aBuf[i:i + 2])
+ i += charLen
+ if i > aLen:
+ self._mNeedToSkipCharNum = i - aLen
+ self._mLastCharOrder = -1
+ else:
+ if (order != -1) and (self._mLastCharOrder != -1):
+ self._mTotalRel += 1
+ if self._mTotalRel > MAX_REL_THRESHOLD:
+ self._mDone = True
+ break
+ self._mRelSample[jp2CharContext[self._mLastCharOrder][order]] += 1
+ self._mLastCharOrder = order
+
+ def got_enough_data(self):
+ return self._mTotalRel > ENOUGH_REL_THRESHOLD
+
+ def get_confidence(self):
+ # This is just one way to calculate confidence. It works well for me.
+ if self._mTotalRel > MINIMUM_DATA_THRESHOLD:
+ return (self._mTotalRel - self._mRelSample[0]) / self._mTotalRel
+ else:
+ return DONT_KNOW
+
+ def get_order(self, aBuf):
+ return -1, 1
+
+class SJISContextAnalysis(JapaneseContextAnalysis):
+ def get_order(self, aBuf):
+ if not aBuf:
+ return -1, 1
+ # find out current char's byte length
+ first_char = wrap_ord(aBuf[0])
+ if ((0x81 <= first_char <= 0x9F) or (0xE0 <= first_char <= 0xFC)):
+ charLen = 2
+ else:
+ charLen = 1
+
+ # return its order if it is hiragana
+ if len(aBuf) > 1:
+ second_char = wrap_ord(aBuf[1])
+ if (first_char == 202) and (0x9F <= second_char <= 0xF1):
+ return second_char - 0x9F, charLen
+
+ return -1, charLen
+
+class EUCJPContextAnalysis(JapaneseContextAnalysis):
+ def get_order(self, aBuf):
+ if not aBuf:
+ return -1, 1
+ # find out current char's byte length
+ first_char = wrap_ord(aBuf[0])
+ if (first_char == 0x8E) or (0xA1 <= first_char <= 0xFE):
+ charLen = 2
+ elif first_char == 0x8F:
+ charLen = 3
+ else:
+ charLen = 1
+
+ # return its order if it is hiragana
+ if len(aBuf) > 1:
+ second_char = wrap_ord(aBuf[1])
+ if (first_char == 0xA4) and (0xA1 <= second_char <= 0xF3):
+ return second_char - 0xA1, charLen
+
+ return -1, charLen
+
+# flake8: noqa
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/langbulgarianmodel.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/langbulgarianmodel.py
similarity index 98%
rename from app/src/processing/app/i18n/python/requests/packages/charade/langbulgarianmodel.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/langbulgarianmodel.py
index ea5a60ba043..e5788fc64a6 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/langbulgarianmodel.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/langbulgarianmodel.py
@@ -1,229 +1,229 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is Mozilla Communicator client code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-# 255: Control characters that usually does not exist in any text
-# 254: Carriage/Return
-# 253: symbol (punctuation) that does not belong to word
-# 252: 0 - 9
-
-# Character Mapping Table:
-# this table is modified base on win1251BulgarianCharToOrderMap, so
-# only number <64 is sure valid
-
-Latin5_BulgarianCharToOrderMap = (
-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
-253, 77, 90, 99,100, 72,109,107,101, 79,185, 81,102, 76, 94, 82, # 40
-110,186,108, 91, 74,119, 84, 96,111,187,115,253,253,253,253,253, # 50
-253, 65, 69, 70, 66, 63, 68,112,103, 92,194,104, 95, 86, 87, 71, # 60
-116,195, 85, 93, 97,113,196,197,198,199,200,253,253,253,253,253, # 70
-194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209, # 80
-210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225, # 90
- 81,226,227,228,229,230,105,231,232,233,234,235,236, 45,237,238, # a0
- 31, 32, 35, 43, 37, 44, 55, 47, 40, 59, 33, 46, 38, 36, 41, 30, # b0
- 39, 28, 34, 51, 48, 49, 53, 50, 54, 57, 61,239, 67,240, 60, 56, # c0
- 1, 18, 9, 20, 11, 3, 23, 15, 2, 26, 12, 10, 14, 6, 4, 13, # d0
- 7, 8, 5, 19, 29, 25, 22, 21, 27, 24, 17, 75, 52,241, 42, 16, # e0
- 62,242,243,244, 58,245, 98,246,247,248,249,250,251, 91,252,253, # f0
-)
-
-win1251BulgarianCharToOrderMap = (
-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
-253, 77, 90, 99,100, 72,109,107,101, 79,185, 81,102, 76, 94, 82, # 40
-110,186,108, 91, 74,119, 84, 96,111,187,115,253,253,253,253,253, # 50
-253, 65, 69, 70, 66, 63, 68,112,103, 92,194,104, 95, 86, 87, 71, # 60
-116,195, 85, 93, 97,113,196,197,198,199,200,253,253,253,253,253, # 70
-206,207,208,209,210,211,212,213,120,214,215,216,217,218,219,220, # 80
-221, 78, 64, 83,121, 98,117,105,222,223,224,225,226,227,228,229, # 90
- 88,230,231,232,233,122, 89,106,234,235,236,237,238, 45,239,240, # a0
- 73, 80,118,114,241,242,243,244,245, 62, 58,246,247,248,249,250, # b0
- 31, 32, 35, 43, 37, 44, 55, 47, 40, 59, 33, 46, 38, 36, 41, 30, # c0
- 39, 28, 34, 51, 48, 49, 53, 50, 54, 57, 61,251, 67,252, 60, 56, # d0
- 1, 18, 9, 20, 11, 3, 23, 15, 2, 26, 12, 10, 14, 6, 4, 13, # e0
- 7, 8, 5, 19, 29, 25, 22, 21, 27, 24, 17, 75, 52,253, 42, 16, # f0
-)
-
-# Model Table:
-# total sequences: 100%
-# first 512 sequences: 96.9392%
-# first 1024 sequences:3.0618%
-# rest sequences: 0.2992%
-# negative sequences: 0.0020%
-BulgarianLangModel = (
-0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,2,3,3,3,3,3,
-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,3,3,3,2,2,3,2,2,1,2,2,
-3,1,3,3,2,3,3,3,3,3,3,3,3,3,3,3,3,0,3,3,3,3,3,3,3,3,3,3,0,3,0,1,
-0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,2,3,3,3,3,3,3,3,3,0,3,1,0,
-0,1,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
-3,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,2,3,3,3,3,3,3,3,3,0,3,0,0,
-0,0,0,0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,0,0,0,0,0,0,0,0,
-3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-1,0,0,1,2,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,
-0,1,1,0,1,1,1,0,0,1,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,
-1,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,1,0,2,0,0,2,0,1,0,0,1,0,0,1,
-1,1,0,0,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,
-1,1,1,1,1,1,1,2,0,0,0,0,0,0,2,1,0,1,1,0,0,1,1,1,0,1,0,0,0,0,0,0,
-2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,0,1,1,1,1,1,0,1,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
-)
-
-Latin5BulgarianModel = {
- 'charToOrderMap': Latin5_BulgarianCharToOrderMap,
- 'precedenceMatrix': BulgarianLangModel,
- 'mTypicalPositiveRatio': 0.969392,
- 'keepEnglishLetter': False,
- 'charsetName': "ISO-8859-5"
-}
-
-Win1251BulgarianModel = {
- 'charToOrderMap': win1251BulgarianCharToOrderMap,
- 'precedenceMatrix': BulgarianLangModel,
- 'mTypicalPositiveRatio': 0.969392,
- 'keepEnglishLetter': False,
- 'charsetName': "windows-1251"
-}
-
-
-# flake8: noqa
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is Mozilla Communicator client code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+# 255: Control characters that usually does not exist in any text
+# 254: Carriage/Return
+# 253: symbol (punctuation) that does not belong to word
+# 252: 0 - 9
+
+# Character Mapping Table:
+# this table is modified base on win1251BulgarianCharToOrderMap, so
+# only number <64 is sure valid
+
+Latin5_BulgarianCharToOrderMap = (
+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
+253, 77, 90, 99,100, 72,109,107,101, 79,185, 81,102, 76, 94, 82, # 40
+110,186,108, 91, 74,119, 84, 96,111,187,115,253,253,253,253,253, # 50
+253, 65, 69, 70, 66, 63, 68,112,103, 92,194,104, 95, 86, 87, 71, # 60
+116,195, 85, 93, 97,113,196,197,198,199,200,253,253,253,253,253, # 70
+194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209, # 80
+210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225, # 90
+ 81,226,227,228,229,230,105,231,232,233,234,235,236, 45,237,238, # a0
+ 31, 32, 35, 43, 37, 44, 55, 47, 40, 59, 33, 46, 38, 36, 41, 30, # b0
+ 39, 28, 34, 51, 48, 49, 53, 50, 54, 57, 61,239, 67,240, 60, 56, # c0
+ 1, 18, 9, 20, 11, 3, 23, 15, 2, 26, 12, 10, 14, 6, 4, 13, # d0
+ 7, 8, 5, 19, 29, 25, 22, 21, 27, 24, 17, 75, 52,241, 42, 16, # e0
+ 62,242,243,244, 58,245, 98,246,247,248,249,250,251, 91,252,253, # f0
+)
+
+win1251BulgarianCharToOrderMap = (
+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
+253, 77, 90, 99,100, 72,109,107,101, 79,185, 81,102, 76, 94, 82, # 40
+110,186,108, 91, 74,119, 84, 96,111,187,115,253,253,253,253,253, # 50
+253, 65, 69, 70, 66, 63, 68,112,103, 92,194,104, 95, 86, 87, 71, # 60
+116,195, 85, 93, 97,113,196,197,198,199,200,253,253,253,253,253, # 70
+206,207,208,209,210,211,212,213,120,214,215,216,217,218,219,220, # 80
+221, 78, 64, 83,121, 98,117,105,222,223,224,225,226,227,228,229, # 90
+ 88,230,231,232,233,122, 89,106,234,235,236,237,238, 45,239,240, # a0
+ 73, 80,118,114,241,242,243,244,245, 62, 58,246,247,248,249,250, # b0
+ 31, 32, 35, 43, 37, 44, 55, 47, 40, 59, 33, 46, 38, 36, 41, 30, # c0
+ 39, 28, 34, 51, 48, 49, 53, 50, 54, 57, 61,251, 67,252, 60, 56, # d0
+ 1, 18, 9, 20, 11, 3, 23, 15, 2, 26, 12, 10, 14, 6, 4, 13, # e0
+ 7, 8, 5, 19, 29, 25, 22, 21, 27, 24, 17, 75, 52,253, 42, 16, # f0
+)
+
+# Model Table:
+# total sequences: 100%
+# first 512 sequences: 96.9392%
+# first 1024 sequences:3.0618%
+# rest sequences: 0.2992%
+# negative sequences: 0.0020%
+BulgarianLangModel = (
+0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,2,3,3,3,3,3,
+3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,3,3,3,2,2,3,2,2,1,2,2,
+3,1,3,3,2,3,3,3,3,3,3,3,3,3,3,3,3,0,3,3,3,3,3,3,3,3,3,3,0,3,0,1,
+0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
+3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,2,3,3,3,3,3,3,3,3,0,3,1,0,
+0,1,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
+3,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,2,3,3,3,3,3,3,3,3,0,3,0,0,
+0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+3,2,3,3,2,3,3,3,3,3,3,3,3,3,3,3,3,1,3,2,3,3,3,3,3,3,3,3,0,3,0,0,
+0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+3,3,3,3,3,3,3,3,3,3,3,2,3,2,2,1,3,3,3,3,2,2,2,1,1,2,0,1,0,1,0,0,
+0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,1,
+3,3,3,3,3,3,3,2,3,2,2,3,3,1,1,2,3,3,2,3,3,3,3,2,1,2,0,2,0,3,0,0,
+0,0,0,0,0,0,0,1,0,0,2,0,0,0,0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,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,
+1,1,1,1,1,1,1,2,0,0,0,0,0,0,2,1,0,1,1,0,0,1,1,1,0,1,0,0,0,0,0,0,
+2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,0,1,1,1,1,1,0,1,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
+)
+
+Latin5BulgarianModel = {
+ 'charToOrderMap': Latin5_BulgarianCharToOrderMap,
+ 'precedenceMatrix': BulgarianLangModel,
+ 'mTypicalPositiveRatio': 0.969392,
+ 'keepEnglishLetter': False,
+ 'charsetName': "ISO-8859-5"
+}
+
+Win1251BulgarianModel = {
+ 'charToOrderMap': win1251BulgarianCharToOrderMap,
+ 'precedenceMatrix': BulgarianLangModel,
+ 'mTypicalPositiveRatio': 0.969392,
+ 'keepEnglishLetter': False,
+ 'charsetName': "windows-1251"
+}
+
+
+# flake8: noqa
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/langcyrillicmodel.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/langcyrillicmodel.py
similarity index 98%
rename from app/src/processing/app/i18n/python/requests/packages/charade/langcyrillicmodel.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/langcyrillicmodel.py
index 4b69c821c8b..f0b9af27f71 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/langcyrillicmodel.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/langcyrillicmodel.py
@@ -1,331 +1,331 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is Mozilla Communicator client code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-from . import constants
-
-# KOI8-R language model
-# Character Mapping Table:
-KOI8R_CharToOrderMap = (
-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
-253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40
-155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50
-253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60
- 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70
-191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206, # 80
-207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222, # 90
-223,224,225, 68,226,227,228,229,230,231,232,233,234,235,236,237, # a0
-238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253, # b0
- 27, 3, 21, 28, 13, 2, 39, 19, 26, 4, 23, 11, 8, 12, 5, 1, # c0
- 15, 16, 9, 7, 6, 14, 24, 10, 17, 18, 20, 25, 30, 29, 22, 54, # d0
- 59, 37, 44, 58, 41, 48, 53, 46, 55, 42, 60, 36, 49, 38, 31, 34, # e0
- 35, 43, 45, 32, 40, 52, 56, 33, 61, 62, 51, 57, 47, 63, 50, 70, # f0
-)
-
-win1251_CharToOrderMap = (
-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
-253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40
-155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50
-253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60
- 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70
-191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,
-207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,
-223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,
-239,240,241,242,243,244,245,246, 68,247,248,249,250,251,252,253,
- 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,
- 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,
- 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,
- 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16,
-)
-
-latin5_CharToOrderMap = (
-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
-253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40
-155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50
-253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60
- 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70
-191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,
-207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,
-223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,
- 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,
- 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,
- 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,
- 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16,
-239, 68,240,241,242,243,244,245,246,247,248,249,250,251,252,255,
-)
-
-macCyrillic_CharToOrderMap = (
-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
-253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40
-155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50
-253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60
- 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70
- 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,
- 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,
-191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,
-207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,
-223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,
-239,240,241,242,243,244,245,246,247,248,249,250,251,252, 68, 16,
- 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,
- 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27,255,
-)
-
-IBM855_CharToOrderMap = (
-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
-253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40
-155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50
-253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60
- 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70
-191,192,193,194, 68,195,196,197,198,199,200,201,202,203,204,205,
-206,207,208,209,210,211,212,213,214,215,216,217, 27, 59, 54, 70,
- 3, 37, 21, 44, 28, 58, 13, 41, 2, 48, 39, 53, 19, 46,218,219,
-220,221,222,223,224, 26, 55, 4, 42,225,226,227,228, 23, 60,229,
-230,231,232,233,234,235, 11, 36,236,237,238,239,240,241,242,243,
- 8, 49, 12, 38, 5, 31, 1, 34, 15,244,245,246,247, 35, 16,248,
- 43, 9, 45, 7, 32, 6, 40, 14, 52, 24, 56, 10, 33, 17, 61,249,
-250, 18, 62, 20, 51, 25, 57, 30, 47, 29, 63, 22, 50,251,252,255,
-)
-
-IBM866_CharToOrderMap = (
-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
-253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40
-155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50
-253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60
- 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70
- 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,
- 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,
- 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,
-191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,
-207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,
-223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,
- 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16,
-239, 68,240,241,242,243,244,245,246,247,248,249,250,251,252,255,
-)
-
-# Model Table:
-# total sequences: 100%
-# first 512 sequences: 97.6601%
-# first 1024 sequences: 2.3389%
-# rest sequences: 0.1237%
-# negative sequences: 0.0009%
-RussianLangModel = (
-0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,1,3,3,3,2,3,2,3,3,
-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,3,2,2,2,2,2,0,0,2,
-3,3,3,2,3,3,3,3,3,3,3,3,3,3,2,3,3,0,0,3,3,3,3,3,3,3,3,3,2,3,2,0,
-0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-3,3,3,2,2,3,3,3,3,3,3,3,3,3,2,3,3,0,0,3,3,3,3,3,3,3,3,2,3,3,1,0,
-0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-3,2,3,2,3,3,3,3,3,3,3,3,3,3,3,3,3,0,0,3,3,3,3,3,3,3,3,3,3,3,2,1,
-0,0,0,0,0,0,0,2,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-3,3,3,3,3,3,3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,1,0,0,0,0,
-0,0,1,0,1,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,
-1,0,0,0,0,2,0,1,2,1,0,1,1,1,0,1,0,0,0,1,0,1,0,0,1,0,1,0,0,0,0,1,
-0,0,0,0,0,1,0,0,1,1,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,
-2,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
-1,0,0,0,1,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,
-2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
-1,1,1,0,1,0,1,0,0,1,1,1,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,1,0,0,0,0,
-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
-1,1,0,1,1,0,1,0,1,0,0,0,0,1,1,0,1,1,0,0,0,0,0,1,0,1,1,0,1,0,0,0,
-0,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,
-)
-
-Koi8rModel = {
- 'charToOrderMap': KOI8R_CharToOrderMap,
- 'precedenceMatrix': RussianLangModel,
- 'mTypicalPositiveRatio': 0.976601,
- 'keepEnglishLetter': False,
- 'charsetName': "KOI8-R"
-}
-
-Win1251CyrillicModel = {
- 'charToOrderMap': win1251_CharToOrderMap,
- 'precedenceMatrix': RussianLangModel,
- 'mTypicalPositiveRatio': 0.976601,
- 'keepEnglishLetter': False,
- 'charsetName': "windows-1251"
-}
-
-Latin5CyrillicModel = {
- 'charToOrderMap': latin5_CharToOrderMap,
- 'precedenceMatrix': RussianLangModel,
- 'mTypicalPositiveRatio': 0.976601,
- 'keepEnglishLetter': False,
- 'charsetName': "ISO-8859-5"
-}
-
-MacCyrillicModel = {
- 'charToOrderMap': macCyrillic_CharToOrderMap,
- 'precedenceMatrix': RussianLangModel,
- 'mTypicalPositiveRatio': 0.976601,
- 'keepEnglishLetter': False,
- 'charsetName': "MacCyrillic"
-};
-
-Ibm866Model = {
- 'charToOrderMap': IBM866_CharToOrderMap,
- 'precedenceMatrix': RussianLangModel,
- 'mTypicalPositiveRatio': 0.976601,
- 'keepEnglishLetter': False,
- 'charsetName': "IBM866"
-}
-
-Ibm855Model = {
- 'charToOrderMap': IBM855_CharToOrderMap,
- 'precedenceMatrix': RussianLangModel,
- 'mTypicalPositiveRatio': 0.976601,
- 'keepEnglishLetter': False,
- 'charsetName': "IBM855"
-}
-
-# flake8: noqa
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is Mozilla Communicator client code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+from . import constants
+
+# KOI8-R language model
+# Character Mapping Table:
+KOI8R_CharToOrderMap = (
+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
+253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40
+155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50
+253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60
+ 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70
+191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206, # 80
+207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222, # 90
+223,224,225, 68,226,227,228,229,230,231,232,233,234,235,236,237, # a0
+238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253, # b0
+ 27, 3, 21, 28, 13, 2, 39, 19, 26, 4, 23, 11, 8, 12, 5, 1, # c0
+ 15, 16, 9, 7, 6, 14, 24, 10, 17, 18, 20, 25, 30, 29, 22, 54, # d0
+ 59, 37, 44, 58, 41, 48, 53, 46, 55, 42, 60, 36, 49, 38, 31, 34, # e0
+ 35, 43, 45, 32, 40, 52, 56, 33, 61, 62, 51, 57, 47, 63, 50, 70, # f0
+)
+
+win1251_CharToOrderMap = (
+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
+253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40
+155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50
+253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60
+ 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70
+191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,
+207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,
+223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,
+239,240,241,242,243,244,245,246, 68,247,248,249,250,251,252,253,
+ 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,
+ 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,
+ 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,
+ 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16,
+)
+
+latin5_CharToOrderMap = (
+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
+253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40
+155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50
+253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60
+ 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70
+191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,
+207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,
+223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,
+ 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,
+ 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,
+ 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,
+ 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16,
+239, 68,240,241,242,243,244,245,246,247,248,249,250,251,252,255,
+)
+
+macCyrillic_CharToOrderMap = (
+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
+253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40
+155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50
+253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60
+ 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70
+ 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,
+ 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,
+191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,
+207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,
+223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,
+239,240,241,242,243,244,245,246,247,248,249,250,251,252, 68, 16,
+ 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,
+ 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27,255,
+)
+
+IBM855_CharToOrderMap = (
+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
+253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40
+155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50
+253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60
+ 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70
+191,192,193,194, 68,195,196,197,198,199,200,201,202,203,204,205,
+206,207,208,209,210,211,212,213,214,215,216,217, 27, 59, 54, 70,
+ 3, 37, 21, 44, 28, 58, 13, 41, 2, 48, 39, 53, 19, 46,218,219,
+220,221,222,223,224, 26, 55, 4, 42,225,226,227,228, 23, 60,229,
+230,231,232,233,234,235, 11, 36,236,237,238,239,240,241,242,243,
+ 8, 49, 12, 38, 5, 31, 1, 34, 15,244,245,246,247, 35, 16,248,
+ 43, 9, 45, 7, 32, 6, 40, 14, 52, 24, 56, 10, 33, 17, 61,249,
+250, 18, 62, 20, 51, 25, 57, 30, 47, 29, 63, 22, 50,251,252,255,
+)
+
+IBM866_CharToOrderMap = (
+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
+253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40
+155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50
+253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60
+ 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70
+ 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,
+ 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,
+ 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,
+191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,
+207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,
+223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,
+ 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16,
+239, 68,240,241,242,243,244,245,246,247,248,249,250,251,252,255,
+)
+
+# Model Table:
+# total sequences: 100%
+# first 512 sequences: 97.6601%
+# first 1024 sequences: 2.3389%
+# rest sequences: 0.1237%
+# negative sequences: 0.0009%
+RussianLangModel = (
+0,3,3,3,3,3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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
+1,1,0,1,1,0,1,0,1,0,0,0,0,1,1,0,1,1,0,0,0,0,0,1,0,1,1,0,1,0,0,0,
+0,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,
+)
+
+Koi8rModel = {
+ 'charToOrderMap': KOI8R_CharToOrderMap,
+ 'precedenceMatrix': RussianLangModel,
+ 'mTypicalPositiveRatio': 0.976601,
+ 'keepEnglishLetter': False,
+ 'charsetName': "KOI8-R"
+}
+
+Win1251CyrillicModel = {
+ 'charToOrderMap': win1251_CharToOrderMap,
+ 'precedenceMatrix': RussianLangModel,
+ 'mTypicalPositiveRatio': 0.976601,
+ 'keepEnglishLetter': False,
+ 'charsetName': "windows-1251"
+}
+
+Latin5CyrillicModel = {
+ 'charToOrderMap': latin5_CharToOrderMap,
+ 'precedenceMatrix': RussianLangModel,
+ 'mTypicalPositiveRatio': 0.976601,
+ 'keepEnglishLetter': False,
+ 'charsetName': "ISO-8859-5"
+}
+
+MacCyrillicModel = {
+ 'charToOrderMap': macCyrillic_CharToOrderMap,
+ 'precedenceMatrix': RussianLangModel,
+ 'mTypicalPositiveRatio': 0.976601,
+ 'keepEnglishLetter': False,
+ 'charsetName': "MacCyrillic"
+};
+
+Ibm866Model = {
+ 'charToOrderMap': IBM866_CharToOrderMap,
+ 'precedenceMatrix': RussianLangModel,
+ 'mTypicalPositiveRatio': 0.976601,
+ 'keepEnglishLetter': False,
+ 'charsetName': "IBM866"
+}
+
+Ibm855Model = {
+ 'charToOrderMap': IBM855_CharToOrderMap,
+ 'precedenceMatrix': RussianLangModel,
+ 'mTypicalPositiveRatio': 0.976601,
+ 'keepEnglishLetter': False,
+ 'charsetName': "IBM855"
+}
+
+# flake8: noqa
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/langgreekmodel.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/langgreekmodel.py
similarity index 98%
rename from app/src/processing/app/i18n/python/requests/packages/charade/langgreekmodel.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/langgreekmodel.py
index 78e9ce60106..891fe3420dc 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/langgreekmodel.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/langgreekmodel.py
@@ -1,227 +1,227 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is Mozilla Communicator client code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-from . import constants
-
-# 255: Control characters that usually does not exist in any text
-# 254: Carriage/Return
-# 253: symbol (punctuation) that does not belong to word
-# 252: 0 - 9
-
-# Character Mapping Table:
-Latin7_CharToOrderMap = (
-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
-253, 82,100,104, 94, 98,101,116,102,111,187,117, 92, 88,113, 85, # 40
- 79,118,105, 83, 67,114,119, 95, 99,109,188,253,253,253,253,253, # 50
-253, 72, 70, 80, 81, 60, 96, 93, 89, 68,120, 97, 77, 86, 69, 55, # 60
- 78,115, 65, 66, 58, 76,106,103, 87,107,112,253,253,253,253,253, # 70
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 80
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 90
-253,233, 90,253,253,253,253,253,253,253,253,253,253, 74,253,253, # a0
-253,253,253,253,247,248, 61, 36, 46, 71, 73,253, 54,253,108,123, # b0
-110, 31, 51, 43, 41, 34, 91, 40, 52, 47, 44, 53, 38, 49, 59, 39, # c0
- 35, 48,250, 37, 33, 45, 56, 50, 84, 57,120,121, 17, 18, 22, 15, # d0
-124, 1, 29, 20, 21, 3, 32, 13, 25, 5, 11, 16, 10, 6, 30, 4, # e0
- 9, 8, 14, 7, 2, 12, 28, 23, 42, 24, 64, 75, 19, 26, 27,253, # f0
-)
-
-win1253_CharToOrderMap = (
-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
-253, 82,100,104, 94, 98,101,116,102,111,187,117, 92, 88,113, 85, # 40
- 79,118,105, 83, 67,114,119, 95, 99,109,188,253,253,253,253,253, # 50
-253, 72, 70, 80, 81, 60, 96, 93, 89, 68,120, 97, 77, 86, 69, 55, # 60
- 78,115, 65, 66, 58, 76,106,103, 87,107,112,253,253,253,253,253, # 70
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 80
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 90
-253,233, 61,253,253,253,253,253,253,253,253,253,253, 74,253,253, # a0
-253,253,253,253,247,253,253, 36, 46, 71, 73,253, 54,253,108,123, # b0
-110, 31, 51, 43, 41, 34, 91, 40, 52, 47, 44, 53, 38, 49, 59, 39, # c0
- 35, 48,250, 37, 33, 45, 56, 50, 84, 57,120,121, 17, 18, 22, 15, # d0
-124, 1, 29, 20, 21, 3, 32, 13, 25, 5, 11, 16, 10, 6, 30, 4, # e0
- 9, 8, 14, 7, 2, 12, 28, 23, 42, 24, 64, 75, 19, 26, 27,253, # f0
-)
-
-# Model Table:
-# total sequences: 100%
-# first 512 sequences: 98.2851%
-# first 1024 sequences:1.7001%
-# rest sequences: 0.0359%
-# negative sequences: 0.0148%
-GreekLangModel = (
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,3,2,2,3,3,3,3,3,3,3,3,1,3,3,3,0,2,2,3,3,0,3,0,3,2,0,3,3,3,0,
-3,0,0,0,2,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,3,3,3,3,3,0,3,3,0,3,2,3,3,0,3,2,3,3,3,0,0,3,0,3,0,3,3,2,0,0,0,
-2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,
-0,2,3,2,2,3,3,3,3,3,3,3,3,0,3,3,3,3,0,2,3,3,0,3,3,3,3,2,3,3,3,0,
-2,0,0,0,2,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,2,3,3,2,3,3,3,3,3,3,3,3,3,3,3,3,0,2,1,3,3,3,3,2,3,3,2,3,3,2,0,
-0,0,0,0,2,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,3,3,3,3,0,3,3,3,3,3,3,0,3,3,0,3,3,3,3,3,3,3,3,3,3,0,3,2,3,3,0,
-2,0,1,0,2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,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,2,0,2,0,0,0,
-0,0,0,0,0,0,0,0,2,1,0,0,0,0,0,0,2,0,0,0,1,2,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-)
-
-Latin7GreekModel = {
- 'charToOrderMap': Latin7_CharToOrderMap,
- 'precedenceMatrix': GreekLangModel,
- 'mTypicalPositiveRatio': 0.982851,
- 'keepEnglishLetter': False,
- 'charsetName': "ISO-8859-7"
-}
-
-Win1253GreekModel = {
- 'charToOrderMap': win1253_CharToOrderMap,
- 'precedenceMatrix': GreekLangModel,
- 'mTypicalPositiveRatio': 0.982851,
- 'keepEnglishLetter': False,
- 'charsetName': "windows-1253"
-}
-
-# flake8: noqa
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is Mozilla Communicator client code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+from . import constants
+
+# 255: Control characters that usually does not exist in any text
+# 254: Carriage/Return
+# 253: symbol (punctuation) that does not belong to word
+# 252: 0 - 9
+
+# Character Mapping Table:
+Latin7_CharToOrderMap = (
+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
+253, 82,100,104, 94, 98,101,116,102,111,187,117, 92, 88,113, 85, # 40
+ 79,118,105, 83, 67,114,119, 95, 99,109,188,253,253,253,253,253, # 50
+253, 72, 70, 80, 81, 60, 96, 93, 89, 68,120, 97, 77, 86, 69, 55, # 60
+ 78,115, 65, 66, 58, 76,106,103, 87,107,112,253,253,253,253,253, # 70
+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 80
+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 90
+253,233, 90,253,253,253,253,253,253,253,253,253,253, 74,253,253, # a0
+253,253,253,253,247,248, 61, 36, 46, 71, 73,253, 54,253,108,123, # b0
+110, 31, 51, 43, 41, 34, 91, 40, 52, 47, 44, 53, 38, 49, 59, 39, # c0
+ 35, 48,250, 37, 33, 45, 56, 50, 84, 57,120,121, 17, 18, 22, 15, # d0
+124, 1, 29, 20, 21, 3, 32, 13, 25, 5, 11, 16, 10, 6, 30, 4, # e0
+ 9, 8, 14, 7, 2, 12, 28, 23, 42, 24, 64, 75, 19, 26, 27,253, # f0
+)
+
+win1253_CharToOrderMap = (
+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
+253, 82,100,104, 94, 98,101,116,102,111,187,117, 92, 88,113, 85, # 40
+ 79,118,105, 83, 67,114,119, 95, 99,109,188,253,253,253,253,253, # 50
+253, 72, 70, 80, 81, 60, 96, 93, 89, 68,120, 97, 77, 86, 69, 55, # 60
+ 78,115, 65, 66, 58, 76,106,103, 87,107,112,253,253,253,253,253, # 70
+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 80
+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 90
+253,233, 61,253,253,253,253,253,253,253,253,253,253, 74,253,253, # a0
+253,253,253,253,247,253,253, 36, 46, 71, 73,253, 54,253,108,123, # b0
+110, 31, 51, 43, 41, 34, 91, 40, 52, 47, 44, 53, 38, 49, 59, 39, # c0
+ 35, 48,250, 37, 33, 45, 56, 50, 84, 57,120,121, 17, 18, 22, 15, # d0
+124, 1, 29, 20, 21, 3, 32, 13, 25, 5, 11, 16, 10, 6, 30, 4, # e0
+ 9, 8, 14, 7, 2, 12, 28, 23, 42, 24, 64, 75, 19, 26, 27,253, # f0
+)
+
+# Model Table:
+# total sequences: 100%
+# first 512 sequences: 98.2851%
+# first 1024 sequences:1.7001%
+# rest sequences: 0.0359%
+# negative sequences: 0.0148%
+GreekLangModel = (
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,3,2,2,3,3,3,3,3,3,3,3,1,3,3,3,0,2,2,3,3,0,3,0,3,2,0,3,3,3,0,
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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+)
+
+Latin7GreekModel = {
+ 'charToOrderMap': Latin7_CharToOrderMap,
+ 'precedenceMatrix': GreekLangModel,
+ 'mTypicalPositiveRatio': 0.982851,
+ 'keepEnglishLetter': False,
+ 'charsetName': "ISO-8859-7"
+}
+
+Win1253GreekModel = {
+ 'charToOrderMap': win1253_CharToOrderMap,
+ 'precedenceMatrix': GreekLangModel,
+ 'mTypicalPositiveRatio': 0.982851,
+ 'keepEnglishLetter': False,
+ 'charsetName': "windows-1253"
+}
+
+# flake8: noqa
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/langhebrewmodel.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/langhebrewmodel.py
similarity index 98%
rename from app/src/processing/app/i18n/python/requests/packages/charade/langhebrewmodel.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/langhebrewmodel.py
index 4c6b3ce1189..248b02aa033 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/langhebrewmodel.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/langhebrewmodel.py
@@ -1,203 +1,203 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is Mozilla Universal charset detector code.
-#
-# The Initial Developer of the Original Code is
-# Simon Montagu
-# Portions created by the Initial Developer are Copyright (C) 2005
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-# Shy Shalom - original C code
-# Shoshannah Forbes - original C code (?)
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-from . import constants
-
-# 255: Control characters that usually does not exist in any text
-# 254: Carriage/Return
-# 253: symbol (punctuation) that does not belong to word
-# 252: 0 - 9
-
-# Windows-1255 language model
-# Character Mapping Table:
-win1255_CharToOrderMap = (
-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
-253, 69, 91, 79, 80, 92, 89, 97, 90, 68,111,112, 82, 73, 95, 85, # 40
- 78,121, 86, 71, 67,102,107, 84,114,103,115,253,253,253,253,253, # 50
-253, 50, 74, 60, 61, 42, 76, 70, 64, 53,105, 93, 56, 65, 54, 49, # 60
- 66,110, 51, 43, 44, 63, 81, 77, 98, 75,108,253,253,253,253,253, # 70
-124,202,203,204,205, 40, 58,206,207,208,209,210,211,212,213,214,
-215, 83, 52, 47, 46, 72, 32, 94,216,113,217,109,218,219,220,221,
- 34,116,222,118,100,223,224,117,119,104,125,225,226, 87, 99,227,
-106,122,123,228, 55,229,230,101,231,232,120,233, 48, 39, 57,234,
- 30, 59, 41, 88, 33, 37, 36, 31, 29, 35,235, 62, 28,236,126,237,
-238, 38, 45,239,240,241,242,243,127,244,245,246,247,248,249,250,
- 9, 8, 20, 16, 3, 2, 24, 14, 22, 1, 25, 15, 4, 11, 6, 23,
- 12, 19, 13, 26, 18, 27, 21, 17, 7, 10, 5,251,252,128, 96,253,
-)
-
-# Model Table:
-# total sequences: 100%
-# first 512 sequences: 98.4004%
-# first 1024 sequences: 1.5981%
-# rest sequences: 0.087%
-# negative sequences: 0.0015%
-HebrewLangModel = (
-0,3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,3,3,3,2,3,2,1,2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,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,1,2,1,0,0,0,0,0,1,1,1,1,1,0,1,0,0,0,1,1,0,0,
-)
-
-Win1255HebrewModel = {
- 'charToOrderMap': win1255_CharToOrderMap,
- 'precedenceMatrix': HebrewLangModel,
- 'mTypicalPositiveRatio': 0.984004,
- 'keepEnglishLetter': False,
- 'charsetName': "windows-1255"
-}
-
-# flake8: noqa
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is Mozilla Universal charset detector code.
+#
+# The Initial Developer of the Original Code is
+# Simon Montagu
+# Portions created by the Initial Developer are Copyright (C) 2005
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+# Shy Shalom - original C code
+# Shoshannah Forbes - original C code (?)
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+from . import constants
+
+# 255: Control characters that usually does not exist in any text
+# 254: Carriage/Return
+# 253: symbol (punctuation) that does not belong to word
+# 252: 0 - 9
+
+# Windows-1255 language model
+# Character Mapping Table:
+win1255_CharToOrderMap = (
+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
+253, 69, 91, 79, 80, 92, 89, 97, 90, 68,111,112, 82, 73, 95, 85, # 40
+ 78,121, 86, 71, 67,102,107, 84,114,103,115,253,253,253,253,253, # 50
+253, 50, 74, 60, 61, 42, 76, 70, 64, 53,105, 93, 56, 65, 54, 49, # 60
+ 66,110, 51, 43, 44, 63, 81, 77, 98, 75,108,253,253,253,253,253, # 70
+124,202,203,204,205, 40, 58,206,207,208,209,210,211,212,213,214,
+215, 83, 52, 47, 46, 72, 32, 94,216,113,217,109,218,219,220,221,
+ 34,116,222,118,100,223,224,117,119,104,125,225,226, 87, 99,227,
+106,122,123,228, 55,229,230,101,231,232,120,233, 48, 39, 57,234,
+ 30, 59, 41, 88, 33, 37, 36, 31, 29, 35,235, 62, 28,236,126,237,
+238, 38, 45,239,240,241,242,243,127,244,245,246,247,248,249,250,
+ 9, 8, 20, 16, 3, 2, 24, 14, 22, 1, 25, 15, 4, 11, 6, 23,
+ 12, 19, 13, 26, 18, 27, 21, 17, 7, 10, 5,251,252,128, 96,253,
+)
+
+# Model Table:
+# total sequences: 100%
+# first 512 sequences: 98.4004%
+# first 1024 sequences: 1.5981%
+# rest sequences: 0.087%
+# negative sequences: 0.0015%
+HebrewLangModel = (
+0,3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,3,3,3,2,3,2,1,2,0,1,0,0,
+3,0,3,1,0,0,1,3,2,0,1,1,2,0,2,2,2,1,1,1,1,2,1,1,1,2,0,0,2,2,0,1,
+3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,
+1,2,1,2,1,2,0,0,2,0,0,0,0,0,1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,
+3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,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TypicalPositiveRatio': 0.984004,
+ 'keepEnglishLetter': False,
+ 'charsetName': "windows-1255"
+}
+
+# flake8: noqa
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/langhungarianmodel.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/langhungarianmodel.py
similarity index 98%
rename from app/src/processing/app/i18n/python/requests/packages/charade/langhungarianmodel.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/langhungarianmodel.py
index bd7f5055de6..c748d280c45 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/langhungarianmodel.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/langhungarianmodel.py
@@ -1,227 +1,227 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is Mozilla Communicator client code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-from . import constants
-
-# 255: Control characters that usually does not exist in any text
-# 254: Carriage/Return
-# 253: symbol (punctuation) that does not belong to word
-# 252: 0 - 9
-
-# Character Mapping Table:
-Latin2_HungarianCharToOrderMap = (
-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
-253, 28, 40, 54, 45, 32, 50, 49, 38, 39, 53, 36, 41, 34, 35, 47,
- 46, 71, 43, 33, 37, 57, 48, 64, 68, 55, 52,253,253,253,253,253,
-253, 2, 18, 26, 17, 1, 27, 12, 20, 9, 22, 7, 6, 13, 4, 8,
- 23, 67, 10, 5, 3, 21, 19, 65, 62, 16, 11,253,253,253,253,253,
-159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,
-175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,
-191,192,193,194,195,196,197, 75,198,199,200,201,202,203,204,205,
- 79,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,
-221, 51, 81,222, 78,223,224,225,226, 44,227,228,229, 61,230,231,
-232,233,234, 58,235, 66, 59,236,237,238, 60, 69, 63,239,240,241,
- 82, 14, 74,242, 70, 80,243, 72,244, 15, 83, 77, 84, 30, 76, 85,
-245,246,247, 25, 73, 42, 24,248,249,250, 31, 56, 29,251,252,253,
-)
-
-win1250HungarianCharToOrderMap = (
-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
-253, 28, 40, 54, 45, 32, 50, 49, 38, 39, 53, 36, 41, 34, 35, 47,
- 46, 72, 43, 33, 37, 57, 48, 64, 68, 55, 52,253,253,253,253,253,
-253, 2, 18, 26, 17, 1, 27, 12, 20, 9, 22, 7, 6, 13, 4, 8,
- 23, 67, 10, 5, 3, 21, 19, 65, 62, 16, 11,253,253,253,253,253,
-161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,
-177,178,179,180, 78,181, 69,182,183,184,185,186,187,188,189,190,
-191,192,193,194,195,196,197, 76,198,199,200,201,202,203,204,205,
- 81,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,
-221, 51, 83,222, 80,223,224,225,226, 44,227,228,229, 61,230,231,
-232,233,234, 58,235, 66, 59,236,237,238, 60, 70, 63,239,240,241,
- 84, 14, 75,242, 71, 82,243, 73,244, 15, 85, 79, 86, 30, 77, 87,
-245,246,247, 25, 74, 42, 24,248,249,250, 31, 56, 29,251,252,253,
-)
-
-# Model Table:
-# total sequences: 100%
-# first 512 sequences: 94.7368%
-# first 1024 sequences:5.2623%
-# rest sequences: 0.8894%
-# negative sequences: 0.0009%
-HungarianLangModel = (
-0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
-3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,2,2,3,3,1,1,2,2,2,2,2,1,2,
-3,2,2,3,3,3,3,3,2,3,3,3,3,3,3,1,2,3,3,3,3,2,3,3,1,1,3,3,0,1,1,1,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,
-3,2,1,3,3,3,3,3,2,3,3,3,3,3,1,1,2,3,3,3,3,3,3,3,1,1,3,2,0,1,1,1,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,
-3,3,3,3,3,3,3,3,3,3,3,1,1,2,3,3,3,1,3,3,3,3,3,1,3,3,2,2,0,3,2,3,
-0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,
-3,3,3,3,3,3,2,3,3,3,2,3,3,2,3,3,3,3,3,2,3,3,2,2,3,2,3,2,0,3,2,2,
-0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,
-3,3,3,3,3,3,2,3,3,3,3,3,2,3,3,3,1,2,3,2,2,3,1,2,3,3,2,2,0,3,3,3,
-0,0,0,0,0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,0,0,0,0,0,0,0,
-1,0,0,1,1,1,0,0,0,0,1,0,2,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,
-0,1,1,1,1,1,0,0,1,1,0,1,0,1,0,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,
-0,0,0,1,0,0,0,0,0,0,1,1,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,1,1,1,0,1,0,0,1,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,
-2,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,0,0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-1,0,0,1,1,1,1,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,
-0,1,1,1,1,1,1,0,1,1,0,1,0,1,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,
-)
-
-Latin2HungarianModel = {
- 'charToOrderMap': Latin2_HungarianCharToOrderMap,
- 'precedenceMatrix': HungarianLangModel,
- 'mTypicalPositiveRatio': 0.947368,
- 'keepEnglishLetter': True,
- 'charsetName': "ISO-8859-2"
-}
-
-Win1250HungarianModel = {
- 'charToOrderMap': win1250HungarianCharToOrderMap,
- 'precedenceMatrix': HungarianLangModel,
- 'mTypicalPositiveRatio': 0.947368,
- 'keepEnglishLetter': True,
- 'charsetName': "windows-1250"
-}
-
-# flake8: noqa
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is Mozilla Communicator client code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+from . import constants
+
+# 255: Control characters that usually does not exist in any text
+# 254: Carriage/Return
+# 253: symbol (punctuation) that does not belong to word
+# 252: 0 - 9
+
+# Character Mapping Table:
+Latin2_HungarianCharToOrderMap = (
+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
+253, 28, 40, 54, 45, 32, 50, 49, 38, 39, 53, 36, 41, 34, 35, 47,
+ 46, 71, 43, 33, 37, 57, 48, 64, 68, 55, 52,253,253,253,253,253,
+253, 2, 18, 26, 17, 1, 27, 12, 20, 9, 22, 7, 6, 13, 4, 8,
+ 23, 67, 10, 5, 3, 21, 19, 65, 62, 16, 11,253,253,253,253,253,
+159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,
+175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,
+191,192,193,194,195,196,197, 75,198,199,200,201,202,203,204,205,
+ 79,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,
+221, 51, 81,222, 78,223,224,225,226, 44,227,228,229, 61,230,231,
+232,233,234, 58,235, 66, 59,236,237,238, 60, 69, 63,239,240,241,
+ 82, 14, 74,242, 70, 80,243, 72,244, 15, 83, 77, 84, 30, 76, 85,
+245,246,247, 25, 73, 42, 24,248,249,250, 31, 56, 29,251,252,253,
+)
+
+win1250HungarianCharToOrderMap = (
+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
+253, 28, 40, 54, 45, 32, 50, 49, 38, 39, 53, 36, 41, 34, 35, 47,
+ 46, 72, 43, 33, 37, 57, 48, 64, 68, 55, 52,253,253,253,253,253,
+253, 2, 18, 26, 17, 1, 27, 12, 20, 9, 22, 7, 6, 13, 4, 8,
+ 23, 67, 10, 5, 3, 21, 19, 65, 62, 16, 11,253,253,253,253,253,
+161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,
+177,178,179,180, 78,181, 69,182,183,184,185,186,187,188,189,190,
+191,192,193,194,195,196,197, 76,198,199,200,201,202,203,204,205,
+ 81,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,
+221, 51, 83,222, 80,223,224,225,226, 44,227,228,229, 61,230,231,
+232,233,234, 58,235, 66, 59,236,237,238, 60, 70, 63,239,240,241,
+ 84, 14, 75,242, 71, 82,243, 73,244, 15, 85, 79, 86, 30, 77, 87,
+245,246,247, 25, 74, 42, 24,248,249,250, 31, 56, 29,251,252,253,
+)
+
+# Model Table:
+# total sequences: 100%
+# first 512 sequences: 94.7368%
+# first 1024 sequences:5.2623%
+# rest sequences: 0.8894%
+# negative sequences: 0.0009%
+HungarianLangModel = (
+0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
+3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,2,2,3,3,1,1,2,2,2,2,2,1,2,
+3,2,2,3,3,3,3,3,2,3,3,3,3,3,3,1,2,3,3,3,3,2,3,3,1,1,3,3,0,1,1,1,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,
+3,2,1,3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= {
+ 'charToOrderMap': Latin2_HungarianCharToOrderMap,
+ 'precedenceMatrix': HungarianLangModel,
+ 'mTypicalPositiveRatio': 0.947368,
+ 'keepEnglishLetter': True,
+ 'charsetName': "ISO-8859-2"
+}
+
+Win1250HungarianModel = {
+ 'charToOrderMap': win1250HungarianCharToOrderMap,
+ 'precedenceMatrix': HungarianLangModel,
+ 'mTypicalPositiveRatio': 0.947368,
+ 'keepEnglishLetter': True,
+ 'charsetName': "windows-1250"
+}
+
+# flake8: noqa
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/langthaimodel.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/langthaimodel.py
similarity index 98%
rename from app/src/processing/app/i18n/python/requests/packages/charade/langthaimodel.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/langthaimodel.py
index df343a74732..0508b1b1abc 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/langthaimodel.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/langthaimodel.py
@@ -1,200 +1,200 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is Mozilla Communicator client code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-# 255: Control characters that usually does not exist in any text
-# 254: Carriage/Return
-# 253: symbol (punctuation) that does not belong to word
-# 252: 0 - 9
-
-# The following result for thai was collected from a limited sample (1M).
-
-# Character Mapping Table:
-TIS620CharToOrderMap = (
-255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
-253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
-252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
-253,182,106,107,100,183,184,185,101, 94,186,187,108,109,110,111, # 40
-188,189,190, 89, 95,112,113,191,192,193,194,253,253,253,253,253, # 50
-253, 64, 72, 73,114, 74,115,116,102, 81,201,117, 90,103, 78, 82, # 60
- 96,202, 91, 79, 84,104,105, 97, 98, 92,203,253,253,253,253,253, # 70
-209,210,211,212,213, 88,214,215,216,217,218,219,220,118,221,222,
-223,224, 99, 85, 83,225,226,227,228,229,230,231,232,233,234,235,
-236, 5, 30,237, 24,238, 75, 8, 26, 52, 34, 51,119, 47, 58, 57,
- 49, 53, 55, 43, 20, 19, 44, 14, 48, 3, 17, 25, 39, 62, 31, 54,
- 45, 9, 16, 2, 61, 15,239, 12, 42, 46, 18, 21, 76, 4, 66, 63,
- 22, 10, 1, 36, 23, 13, 40, 27, 32, 35, 86,240,241,242,243,244,
- 11, 28, 41, 29, 33,245, 50, 37, 6, 7, 67, 77, 38, 93,246,247,
- 68, 56, 59, 65, 69, 60, 70, 80, 71, 87,248,249,250,251,252,253,
-)
-
-# Model Table:
-# total sequences: 100%
-# first 512 sequences: 92.6386%
-# first 1024 sequences:7.3177%
-# rest sequences: 1.0230%
-# negative sequences: 0.0436%
-ThaiLangModel = (
-0,1,3,3,3,3,0,0,3,3,0,3,3,0,3,3,3,3,3,3,3,3,0,0,3,3,3,0,3,3,3,3,
-0,3,3,0,0,0,1,3,0,3,3,2,3,3,0,1,2,3,3,3,3,0,2,0,2,0,0,3,2,1,2,2,
-3,0,3,3,2,3,0,0,3,3,0,3,3,0,3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,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-)
-
-TIS620ThaiModel = {
- 'charToOrderMap': TIS620CharToOrderMap,
- 'precedenceMatrix': ThaiLangModel,
- 'mTypicalPositiveRatio': 0.926386,
- 'keepEnglishLetter': False,
- 'charsetName': "TIS-620"
-}
-
-# flake8: noqa
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is Mozilla Communicator client code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+# 255: Control characters that usually does not exist in any text
+# 254: Carriage/Return
+# 253: symbol (punctuation) that does not belong to word
+# 252: 0 - 9
+
+# The following result for thai was collected from a limited sample (1M).
+
+# Character Mapping Table:
+TIS620CharToOrderMap = (
+255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
+255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
+253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
+252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
+253,182,106,107,100,183,184,185,101, 94,186,187,108,109,110,111, # 40
+188,189,190, 89, 95,112,113,191,192,193,194,253,253,253,253,253, # 50
+253, 64, 72, 73,114, 74,115,116,102, 81,201,117, 90,103, 78, 82, # 60
+ 96,202, 91, 79, 84,104,105, 97, 98, 92,203,253,253,253,253,253, # 70
+209,210,211,212,213, 88,214,215,216,217,218,219,220,118,221,222,
+223,224, 99, 85, 83,225,226,227,228,229,230,231,232,233,234,235,
+236, 5, 30,237, 24,238, 75, 8, 26, 52, 34, 51,119, 47, 58, 57,
+ 49, 53, 55, 43, 20, 19, 44, 14, 48, 3, 17, 25, 39, 62, 31, 54,
+ 45, 9, 16, 2, 61, 15,239, 12, 42, 46, 18, 21, 76, 4, 66, 63,
+ 22, 10, 1, 36, 23, 13, 40, 27, 32, 35, 86,240,241,242,243,244,
+ 11, 28, 41, 29, 33,245, 50, 37, 6, 7, 67, 77, 38, 93,246,247,
+ 68, 56, 59, 65, 69, 60, 70, 80, 71, 87,248,249,250,251,252,253,
+)
+
+# Model Table:
+# total sequences: 100%
+# first 512 sequences: 92.6386%
+# first 1024 sequences:7.3177%
+# rest sequences: 1.0230%
+# negative sequences: 0.0436%
+ThaiLangModel = (
+0,1,3,3,3,3,0,0,3,3,0,3,3,0,3,3,3,3,3,3,3,3,0,0,3,3,3,0,3,3,3,3,
+0,3,3,0,0,0,1,3,0,3,3,2,3,3,0,1,2,3,3,3,3,0,2,0,2,0,0,3,2,1,2,2,
+3,0,3,3,2,3,0,0,3,3,0,3,3,0,3,3,3,3,3,3,3,3,3,0,3,2,3,0,2,2,2,3,
+0,2,3,0,0,0,0,1,0,1,2,3,1,1,3,2,2,0,1,1,0,0,1,0,0,0,0,0,0,0,1,1,
+3,3,3,2,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,3,3,2,3,2,3,3,2,2,2,
+3,1,2,3,0,3,3,2,2,1,2,3,3,1,2,0,1,3,0,1,0,0,1,0,0,0,0,0,0,0,1,1,
+3,3,2,2,3,3,3,3,1,2,3,3,3,3,3,2,2,2,2,3,3,2,2,3,3,2,2,3,2,3,2,2,
+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0,0,0,0,0,0,0,0,0,0,0,0,
+2,0,0,0,0,2,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,3,0,0,0,
+2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,1,0,0,0,0,
+1,0,0,0,0,0,0,0,0,1,0,0,0,0,2,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,1,1,0,0,2,1,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+)
+
+TIS620ThaiModel = {
+ 'charToOrderMap': TIS620CharToOrderMap,
+ 'precedenceMatrix': ThaiLangModel,
+ 'mTypicalPositiveRatio': 0.926386,
+ 'keepEnglishLetter': False,
+ 'charsetName': "TIS-620"
+}
+
+# flake8: noqa
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/latin1prober.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/latin1prober.py
similarity index 97%
rename from app/src/processing/app/i18n/python/requests/packages/charade/latin1prober.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/latin1prober.py
index bebe1bcb02f..ad695f57a72 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/latin1prober.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/latin1prober.py
@@ -1,139 +1,139 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is Mozilla Universal charset detector code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 2001
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-# Shy Shalom - original C code
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-from .charsetprober import CharSetProber
-from .constants import eNotMe
-from .compat import wrap_ord
-
-FREQ_CAT_NUM = 4
-
-UDF = 0 # undefined
-OTH = 1 # other
-ASC = 2 # ascii capital letter
-ASS = 3 # ascii small letter
-ACV = 4 # accent capital vowel
-ACO = 5 # accent capital other
-ASV = 6 # accent small vowel
-ASO = 7 # accent small other
-CLASS_NUM = 8 # total classes
-
-Latin1_CharToClass = (
- OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 00 - 07
- OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 08 - 0F
- OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 10 - 17
- OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 18 - 1F
- OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 20 - 27
- OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 28 - 2F
- OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 30 - 37
- OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 38 - 3F
- OTH, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 40 - 47
- ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 48 - 4F
- ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 50 - 57
- ASC, ASC, ASC, OTH, OTH, OTH, OTH, OTH, # 58 - 5F
- OTH, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 60 - 67
- ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 68 - 6F
- ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 70 - 77
- ASS, ASS, ASS, OTH, OTH, OTH, OTH, OTH, # 78 - 7F
- OTH, UDF, OTH, ASO, OTH, OTH, OTH, OTH, # 80 - 87
- OTH, OTH, ACO, OTH, ACO, UDF, ACO, UDF, # 88 - 8F
- UDF, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 90 - 97
- OTH, OTH, ASO, OTH, ASO, UDF, ASO, ACO, # 98 - 9F
- OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # A0 - A7
- OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # A8 - AF
- OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # B0 - B7
- OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # B8 - BF
- ACV, ACV, ACV, ACV, ACV, ACV, ACO, ACO, # C0 - C7
- ACV, ACV, ACV, ACV, ACV, ACV, ACV, ACV, # C8 - CF
- ACO, ACO, ACV, ACV, ACV, ACV, ACV, OTH, # D0 - D7
- ACV, ACV, ACV, ACV, ACV, ACO, ACO, ACO, # D8 - DF
- ASV, ASV, ASV, ASV, ASV, ASV, ASO, ASO, # E0 - E7
- ASV, ASV, ASV, ASV, ASV, ASV, ASV, ASV, # E8 - EF
- ASO, ASO, ASV, ASV, ASV, ASV, ASV, OTH, # F0 - F7
- ASV, ASV, ASV, ASV, ASV, ASO, ASO, ASO, # F8 - FF
-)
-
-# 0 : illegal
-# 1 : very unlikely
-# 2 : normal
-# 3 : very likely
-Latin1ClassModel = (
- # UDF OTH ASC ASS ACV ACO ASV ASO
- 0, 0, 0, 0, 0, 0, 0, 0, # UDF
- 0, 3, 3, 3, 3, 3, 3, 3, # OTH
- 0, 3, 3, 3, 3, 3, 3, 3, # ASC
- 0, 3, 3, 3, 1, 1, 3, 3, # ASS
- 0, 3, 3, 3, 1, 2, 1, 2, # ACV
- 0, 3, 3, 3, 3, 3, 3, 3, # ACO
- 0, 3, 1, 3, 1, 1, 1, 3, # ASV
- 0, 3, 1, 3, 1, 1, 3, 3, # ASO
-)
-
-
-class Latin1Prober(CharSetProber):
- def __init__(self):
- CharSetProber.__init__(self)
- self.reset()
-
- def reset(self):
- self._mLastCharClass = OTH
- self._mFreqCounter = [0] * FREQ_CAT_NUM
- CharSetProber.reset(self)
-
- def get_charset_name(self):
- return "windows-1252"
-
- def feed(self, aBuf):
- aBuf = self.filter_with_english_letters(aBuf)
- for c in aBuf:
- charClass = Latin1_CharToClass[wrap_ord(c)]
- freq = Latin1ClassModel[(self._mLastCharClass * CLASS_NUM)
- + charClass]
- if freq == 0:
- self._mState = eNotMe
- break
- self._mFreqCounter[freq] += 1
- self._mLastCharClass = charClass
-
- return self.get_state()
-
- def get_confidence(self):
- if self.get_state() == eNotMe:
- return 0.01
-
- total = sum(self._mFreqCounter)
- if total < 0.01:
- confidence = 0.0
- else:
- confidence = ((self._mFreqCounter[3] / total)
- - (self._mFreqCounter[1] * 20.0 / total))
- if confidence < 0.0:
- confidence = 0.0
- # lower the confidence of latin1 so that other more accurate
- # detector can take priority.
- confidence = confidence * 0.5
- return confidence
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is Mozilla Universal charset detector code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 2001
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+# Shy Shalom - original C code
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+from .charsetprober import CharSetProber
+from .constants import eNotMe
+from .compat import wrap_ord
+
+FREQ_CAT_NUM = 4
+
+UDF = 0 # undefined
+OTH = 1 # other
+ASC = 2 # ascii capital letter
+ASS = 3 # ascii small letter
+ACV = 4 # accent capital vowel
+ACO = 5 # accent capital other
+ASV = 6 # accent small vowel
+ASO = 7 # accent small other
+CLASS_NUM = 8 # total classes
+
+Latin1_CharToClass = (
+ OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 00 - 07
+ OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 08 - 0F
+ OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 10 - 17
+ OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 18 - 1F
+ OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 20 - 27
+ OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 28 - 2F
+ OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 30 - 37
+ OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 38 - 3F
+ OTH, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 40 - 47
+ ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 48 - 4F
+ ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 50 - 57
+ ASC, ASC, ASC, OTH, OTH, OTH, OTH, OTH, # 58 - 5F
+ OTH, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 60 - 67
+ ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 68 - 6F
+ ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 70 - 77
+ ASS, ASS, ASS, OTH, OTH, OTH, OTH, OTH, # 78 - 7F
+ OTH, UDF, OTH, ASO, OTH, OTH, OTH, OTH, # 80 - 87
+ OTH, OTH, ACO, OTH, ACO, UDF, ACO, UDF, # 88 - 8F
+ UDF, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 90 - 97
+ OTH, OTH, ASO, OTH, ASO, UDF, ASO, ACO, # 98 - 9F
+ OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # A0 - A7
+ OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # A8 - AF
+ OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # B0 - B7
+ OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # B8 - BF
+ ACV, ACV, ACV, ACV, ACV, ACV, ACO, ACO, # C0 - C7
+ ACV, ACV, ACV, ACV, ACV, ACV, ACV, ACV, # C8 - CF
+ ACO, ACO, ACV, ACV, ACV, ACV, ACV, OTH, # D0 - D7
+ ACV, ACV, ACV, ACV, ACV, ACO, ACO, ACO, # D8 - DF
+ ASV, ASV, ASV, ASV, ASV, ASV, ASO, ASO, # E0 - E7
+ ASV, ASV, ASV, ASV, ASV, ASV, ASV, ASV, # E8 - EF
+ ASO, ASO, ASV, ASV, ASV, ASV, ASV, OTH, # F0 - F7
+ ASV, ASV, ASV, ASV, ASV, ASO, ASO, ASO, # F8 - FF
+)
+
+# 0 : illegal
+# 1 : very unlikely
+# 2 : normal
+# 3 : very likely
+Latin1ClassModel = (
+ # UDF OTH ASC ASS ACV ACO ASV ASO
+ 0, 0, 0, 0, 0, 0, 0, 0, # UDF
+ 0, 3, 3, 3, 3, 3, 3, 3, # OTH
+ 0, 3, 3, 3, 3, 3, 3, 3, # ASC
+ 0, 3, 3, 3, 1, 1, 3, 3, # ASS
+ 0, 3, 3, 3, 1, 2, 1, 2, # ACV
+ 0, 3, 3, 3, 3, 3, 3, 3, # ACO
+ 0, 3, 1, 3, 1, 1, 1, 3, # ASV
+ 0, 3, 1, 3, 1, 1, 3, 3, # ASO
+)
+
+
+class Latin1Prober(CharSetProber):
+ def __init__(self):
+ CharSetProber.__init__(self)
+ self.reset()
+
+ def reset(self):
+ self._mLastCharClass = OTH
+ self._mFreqCounter = [0] * FREQ_CAT_NUM
+ CharSetProber.reset(self)
+
+ def get_charset_name(self):
+ return "windows-1252"
+
+ def feed(self, aBuf):
+ aBuf = self.filter_with_english_letters(aBuf)
+ for c in aBuf:
+ charClass = Latin1_CharToClass[wrap_ord(c)]
+ freq = Latin1ClassModel[(self._mLastCharClass * CLASS_NUM)
+ + charClass]
+ if freq == 0:
+ self._mState = eNotMe
+ break
+ self._mFreqCounter[freq] += 1
+ self._mLastCharClass = charClass
+
+ return self.get_state()
+
+ def get_confidence(self):
+ if self.get_state() == eNotMe:
+ return 0.01
+
+ total = sum(self._mFreqCounter)
+ if total < 0.01:
+ confidence = 0.0
+ else:
+ confidence = ((self._mFreqCounter[3] / total)
+ - (self._mFreqCounter[1] * 20.0 / total))
+ if confidence < 0.0:
+ confidence = 0.0
+ # lower the confidence of latin1 so that other more accurate
+ # detector can take priority.
+ confidence = confidence * 0.5
+ return confidence
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/mbcharsetprober.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/mbcharsetprober.py
similarity index 97%
rename from app/src/processing/app/i18n/python/requests/packages/charade/mbcharsetprober.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/mbcharsetprober.py
index 1eee253c047..bb42f2fb5e8 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/mbcharsetprober.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/mbcharsetprober.py
@@ -1,86 +1,86 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is Mozilla Universal charset detector code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 2001
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-# Shy Shalom - original C code
-# Proofpoint, Inc.
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-import sys
-from . import constants
-from .charsetprober import CharSetProber
-
-
-class MultiByteCharSetProber(CharSetProber):
- def __init__(self):
- CharSetProber.__init__(self)
- self._mDistributionAnalyzer = None
- self._mCodingSM = None
- self._mLastChar = [0, 0]
-
- def reset(self):
- CharSetProber.reset(self)
- if self._mCodingSM:
- self._mCodingSM.reset()
- if self._mDistributionAnalyzer:
- self._mDistributionAnalyzer.reset()
- self._mLastChar = [0, 0]
-
- def get_charset_name(self):
- pass
-
- def feed(self, aBuf):
- aLen = len(aBuf)
- for i in range(0, aLen):
- codingState = self._mCodingSM.next_state(aBuf[i])
- if codingState == constants.eError:
- if constants._debug:
- sys.stderr.write(self.get_charset_name()
- + ' prober hit error at byte ' + str(i)
- + '\n')
- self._mState = constants.eNotMe
- break
- elif codingState == constants.eItsMe:
- self._mState = constants.eFoundIt
- break
- elif codingState == constants.eStart:
- charLen = self._mCodingSM.get_current_charlen()
- if i == 0:
- self._mLastChar[1] = aBuf[0]
- self._mDistributionAnalyzer.feed(self._mLastChar, charLen)
- else:
- self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1],
- charLen)
-
- self._mLastChar[0] = aBuf[aLen - 1]
-
- if self.get_state() == constants.eDetecting:
- if (self._mDistributionAnalyzer.got_enough_data() and
- (self.get_confidence() > constants.SHORTCUT_THRESHOLD)):
- self._mState = constants.eFoundIt
-
- return self.get_state()
-
- def get_confidence(self):
- return self._mDistributionAnalyzer.get_confidence()
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is Mozilla Universal charset detector code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 2001
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+# Shy Shalom - original C code
+# Proofpoint, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+import sys
+from . import constants
+from .charsetprober import CharSetProber
+
+
+class MultiByteCharSetProber(CharSetProber):
+ def __init__(self):
+ CharSetProber.__init__(self)
+ self._mDistributionAnalyzer = None
+ self._mCodingSM = None
+ self._mLastChar = [0, 0]
+
+ def reset(self):
+ CharSetProber.reset(self)
+ if self._mCodingSM:
+ self._mCodingSM.reset()
+ if self._mDistributionAnalyzer:
+ self._mDistributionAnalyzer.reset()
+ self._mLastChar = [0, 0]
+
+ def get_charset_name(self):
+ pass
+
+ def feed(self, aBuf):
+ aLen = len(aBuf)
+ for i in range(0, aLen):
+ codingState = self._mCodingSM.next_state(aBuf[i])
+ if codingState == constants.eError:
+ if constants._debug:
+ sys.stderr.write(self.get_charset_name()
+ + ' prober hit error at byte ' + str(i)
+ + '\n')
+ self._mState = constants.eNotMe
+ break
+ elif codingState == constants.eItsMe:
+ self._mState = constants.eFoundIt
+ break
+ elif codingState == constants.eStart:
+ charLen = self._mCodingSM.get_current_charlen()
+ if i == 0:
+ self._mLastChar[1] = aBuf[0]
+ self._mDistributionAnalyzer.feed(self._mLastChar, charLen)
+ else:
+ self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1],
+ charLen)
+
+ self._mLastChar[0] = aBuf[aLen - 1]
+
+ if self.get_state() == constants.eDetecting:
+ if (self._mDistributionAnalyzer.got_enough_data() and
+ (self.get_confidence() > constants.SHORTCUT_THRESHOLD)):
+ self._mState = constants.eFoundIt
+
+ return self.get_state()
+
+ def get_confidence(self):
+ return self._mDistributionAnalyzer.get_confidence()
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/mbcsgroupprober.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/mbcsgroupprober.py
similarity index 97%
rename from app/src/processing/app/i18n/python/requests/packages/charade/mbcsgroupprober.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/mbcsgroupprober.py
index ebe93d08d37..e349a9b6b33 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/mbcsgroupprober.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/mbcsgroupprober.py
@@ -1,52 +1,52 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is Mozilla Universal charset detector code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 2001
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-# Shy Shalom - original C code
-# Proofpoint, Inc.
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-from .charsetgroupprober import CharSetGroupProber
-from .utf8prober import UTF8Prober
-from .sjisprober import SJISProber
-from .eucjpprober import EUCJPProber
-from .gb2312prober import GB2312Prober
-from .euckrprober import EUCKRProber
-from .big5prober import Big5Prober
-from .euctwprober import EUCTWProber
-
-
-class MBCSGroupProber(CharSetGroupProber):
- def __init__(self):
- CharSetGroupProber.__init__(self)
- self._mProbers = [
- UTF8Prober(),
- SJISProber(),
- EUCJPProber(),
- GB2312Prober(),
- EUCKRProber(),
- Big5Prober(),
- EUCTWProber()
- ]
- self.reset()
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is Mozilla Universal charset detector code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 2001
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+# Shy Shalom - original C code
+# Proofpoint, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+from .charsetgroupprober import CharSetGroupProber
+from .utf8prober import UTF8Prober
+from .sjisprober import SJISProber
+from .eucjpprober import EUCJPProber
+from .gb2312prober import GB2312Prober
+from .euckrprober import EUCKRProber
+from .big5prober import Big5Prober
+from .euctwprober import EUCTWProber
+
+
+class MBCSGroupProber(CharSetGroupProber):
+ def __init__(self):
+ CharSetGroupProber.__init__(self)
+ self._mProbers = [
+ UTF8Prober(),
+ SJISProber(),
+ EUCJPProber(),
+ GB2312Prober(),
+ EUCKRProber(),
+ Big5Prober(),
+ EUCTWProber()
+ ]
+ self.reset()
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/mbcssm.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/mbcssm.py
similarity index 97%
rename from app/src/processing/app/i18n/python/requests/packages/charade/mbcssm.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/mbcssm.py
index 3a720c9a9af..fc7904a9a50 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/mbcssm.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/mbcssm.py
@@ -1,535 +1,535 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is mozilla.org code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-from .constants import eStart, eError, eItsMe
-
-# BIG5
-
-BIG5_cls = (
- 1,1,1,1,1,1,1,1, # 00 - 07 #allow 0x00 as legal value
- 1,1,1,1,1,1,0,0, # 08 - 0f
- 1,1,1,1,1,1,1,1, # 10 - 17
- 1,1,1,0,1,1,1,1, # 18 - 1f
- 1,1,1,1,1,1,1,1, # 20 - 27
- 1,1,1,1,1,1,1,1, # 28 - 2f
- 1,1,1,1,1,1,1,1, # 30 - 37
- 1,1,1,1,1,1,1,1, # 38 - 3f
- 2,2,2,2,2,2,2,2, # 40 - 47
- 2,2,2,2,2,2,2,2, # 48 - 4f
- 2,2,2,2,2,2,2,2, # 50 - 57
- 2,2,2,2,2,2,2,2, # 58 - 5f
- 2,2,2,2,2,2,2,2, # 60 - 67
- 2,2,2,2,2,2,2,2, # 68 - 6f
- 2,2,2,2,2,2,2,2, # 70 - 77
- 2,2,2,2,2,2,2,1, # 78 - 7f
- 4,4,4,4,4,4,4,4, # 80 - 87
- 4,4,4,4,4,4,4,4, # 88 - 8f
- 4,4,4,4,4,4,4,4, # 90 - 97
- 4,4,4,4,4,4,4,4, # 98 - 9f
- 4,3,3,3,3,3,3,3, # a0 - a7
- 3,3,3,3,3,3,3,3, # a8 - af
- 3,3,3,3,3,3,3,3, # b0 - b7
- 3,3,3,3,3,3,3,3, # b8 - bf
- 3,3,3,3,3,3,3,3, # c0 - c7
- 3,3,3,3,3,3,3,3, # c8 - cf
- 3,3,3,3,3,3,3,3, # d0 - d7
- 3,3,3,3,3,3,3,3, # d8 - df
- 3,3,3,3,3,3,3,3, # e0 - e7
- 3,3,3,3,3,3,3,3, # e8 - ef
- 3,3,3,3,3,3,3,3, # f0 - f7
- 3,3,3,3,3,3,3,0 # f8 - ff
-)
-
-BIG5_st = (
- eError,eStart,eStart, 3,eError,eError,eError,eError,#00-07
- eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,#08-0f
- eError,eStart,eStart,eStart,eStart,eStart,eStart,eStart#10-17
-)
-
-Big5CharLenTable = (0, 1, 1, 2, 0)
-
-Big5SMModel = {'classTable': BIG5_cls,
- 'classFactor': 5,
- 'stateTable': BIG5_st,
- 'charLenTable': Big5CharLenTable,
- 'name': 'Big5'}
-
-# EUC-JP
-
-EUCJP_cls = (
- 4,4,4,4,4,4,4,4, # 00 - 07
- 4,4,4,4,4,4,5,5, # 08 - 0f
- 4,4,4,4,4,4,4,4, # 10 - 17
- 4,4,4,5,4,4,4,4, # 18 - 1f
- 4,4,4,4,4,4,4,4, # 20 - 27
- 4,4,4,4,4,4,4,4, # 28 - 2f
- 4,4,4,4,4,4,4,4, # 30 - 37
- 4,4,4,4,4,4,4,4, # 38 - 3f
- 4,4,4,4,4,4,4,4, # 40 - 47
- 4,4,4,4,4,4,4,4, # 48 - 4f
- 4,4,4,4,4,4,4,4, # 50 - 57
- 4,4,4,4,4,4,4,4, # 58 - 5f
- 4,4,4,4,4,4,4,4, # 60 - 67
- 4,4,4,4,4,4,4,4, # 68 - 6f
- 4,4,4,4,4,4,4,4, # 70 - 77
- 4,4,4,4,4,4,4,4, # 78 - 7f
- 5,5,5,5,5,5,5,5, # 80 - 87
- 5,5,5,5,5,5,1,3, # 88 - 8f
- 5,5,5,5,5,5,5,5, # 90 - 97
- 5,5,5,5,5,5,5,5, # 98 - 9f
- 5,2,2,2,2,2,2,2, # a0 - a7
- 2,2,2,2,2,2,2,2, # a8 - af
- 2,2,2,2,2,2,2,2, # b0 - b7
- 2,2,2,2,2,2,2,2, # b8 - bf
- 2,2,2,2,2,2,2,2, # c0 - c7
- 2,2,2,2,2,2,2,2, # c8 - cf
- 2,2,2,2,2,2,2,2, # d0 - d7
- 2,2,2,2,2,2,2,2, # d8 - df
- 0,0,0,0,0,0,0,0, # e0 - e7
- 0,0,0,0,0,0,0,0, # e8 - ef
- 0,0,0,0,0,0,0,0, # f0 - f7
- 0,0,0,0,0,0,0,5 # f8 - ff
-)
-
-EUCJP_st = (
- 3, 4, 3, 5,eStart,eError,eError,eError,#00-07
- eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,#08-0f
- eItsMe,eItsMe,eStart,eError,eStart,eError,eError,eError,#10-17
- eError,eError,eStart,eError,eError,eError, 3,eError,#18-1f
- 3,eError,eError,eError,eStart,eStart,eStart,eStart#20-27
-)
-
-EUCJPCharLenTable = (2, 2, 2, 3, 1, 0)
-
-EUCJPSMModel = {'classTable': EUCJP_cls,
- 'classFactor': 6,
- 'stateTable': EUCJP_st,
- 'charLenTable': EUCJPCharLenTable,
- 'name': 'EUC-JP'}
-
-# EUC-KR
-
-EUCKR_cls = (
- 1,1,1,1,1,1,1,1, # 00 - 07
- 1,1,1,1,1,1,0,0, # 08 - 0f
- 1,1,1,1,1,1,1,1, # 10 - 17
- 1,1,1,0,1,1,1,1, # 18 - 1f
- 1,1,1,1,1,1,1,1, # 20 - 27
- 1,1,1,1,1,1,1,1, # 28 - 2f
- 1,1,1,1,1,1,1,1, # 30 - 37
- 1,1,1,1,1,1,1,1, # 38 - 3f
- 1,1,1,1,1,1,1,1, # 40 - 47
- 1,1,1,1,1,1,1,1, # 48 - 4f
- 1,1,1,1,1,1,1,1, # 50 - 57
- 1,1,1,1,1,1,1,1, # 58 - 5f
- 1,1,1,1,1,1,1,1, # 60 - 67
- 1,1,1,1,1,1,1,1, # 68 - 6f
- 1,1,1,1,1,1,1,1, # 70 - 77
- 1,1,1,1,1,1,1,1, # 78 - 7f
- 0,0,0,0,0,0,0,0, # 80 - 87
- 0,0,0,0,0,0,0,0, # 88 - 8f
- 0,0,0,0,0,0,0,0, # 90 - 97
- 0,0,0,0,0,0,0,0, # 98 - 9f
- 0,2,2,2,2,2,2,2, # a0 - a7
- 2,2,2,2,2,3,3,3, # a8 - af
- 2,2,2,2,2,2,2,2, # b0 - b7
- 2,2,2,2,2,2,2,2, # b8 - bf
- 2,2,2,2,2,2,2,2, # c0 - c7
- 2,3,2,2,2,2,2,2, # c8 - cf
- 2,2,2,2,2,2,2,2, # d0 - d7
- 2,2,2,2,2,2,2,2, # d8 - df
- 2,2,2,2,2,2,2,2, # e0 - e7
- 2,2,2,2,2,2,2,2, # e8 - ef
- 2,2,2,2,2,2,2,2, # f0 - f7
- 2,2,2,2,2,2,2,0 # f8 - ff
-)
-
-EUCKR_st = (
- eError,eStart, 3,eError,eError,eError,eError,eError,#00-07
- eItsMe,eItsMe,eItsMe,eItsMe,eError,eError,eStart,eStart #08-0f
-)
-
-EUCKRCharLenTable = (0, 1, 2, 0)
-
-EUCKRSMModel = {'classTable': EUCKR_cls,
- 'classFactor': 4,
- 'stateTable': EUCKR_st,
- 'charLenTable': EUCKRCharLenTable,
- 'name': 'EUC-KR'}
-
-# EUC-TW
-
-EUCTW_cls = (
- 2,2,2,2,2,2,2,2, # 00 - 07
- 2,2,2,2,2,2,0,0, # 08 - 0f
- 2,2,2,2,2,2,2,2, # 10 - 17
- 2,2,2,0,2,2,2,2, # 18 - 1f
- 2,2,2,2,2,2,2,2, # 20 - 27
- 2,2,2,2,2,2,2,2, # 28 - 2f
- 2,2,2,2,2,2,2,2, # 30 - 37
- 2,2,2,2,2,2,2,2, # 38 - 3f
- 2,2,2,2,2,2,2,2, # 40 - 47
- 2,2,2,2,2,2,2,2, # 48 - 4f
- 2,2,2,2,2,2,2,2, # 50 - 57
- 2,2,2,2,2,2,2,2, # 58 - 5f
- 2,2,2,2,2,2,2,2, # 60 - 67
- 2,2,2,2,2,2,2,2, # 68 - 6f
- 2,2,2,2,2,2,2,2, # 70 - 77
- 2,2,2,2,2,2,2,2, # 78 - 7f
- 0,0,0,0,0,0,0,0, # 80 - 87
- 0,0,0,0,0,0,6,0, # 88 - 8f
- 0,0,0,0,0,0,0,0, # 90 - 97
- 0,0,0,0,0,0,0,0, # 98 - 9f
- 0,3,4,4,4,4,4,4, # a0 - a7
- 5,5,1,1,1,1,1,1, # a8 - af
- 1,1,1,1,1,1,1,1, # b0 - b7
- 1,1,1,1,1,1,1,1, # b8 - bf
- 1,1,3,1,3,3,3,3, # c0 - c7
- 3,3,3,3,3,3,3,3, # c8 - cf
- 3,3,3,3,3,3,3,3, # d0 - d7
- 3,3,3,3,3,3,3,3, # d8 - df
- 3,3,3,3,3,3,3,3, # e0 - e7
- 3,3,3,3,3,3,3,3, # e8 - ef
- 3,3,3,3,3,3,3,3, # f0 - f7
- 3,3,3,3,3,3,3,0 # f8 - ff
-)
-
-EUCTW_st = (
- eError,eError,eStart, 3, 3, 3, 4,eError,#00-07
- eError,eError,eError,eError,eError,eError,eItsMe,eItsMe,#08-0f
- eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,eStart,eError,#10-17
- eStart,eStart,eStart,eError,eError,eError,eError,eError,#18-1f
- 5,eError,eError,eError,eStart,eError,eStart,eStart,#20-27
- eStart,eError,eStart,eStart,eStart,eStart,eStart,eStart #28-2f
-)
-
-EUCTWCharLenTable = (0, 0, 1, 2, 2, 2, 3)
-
-EUCTWSMModel = {'classTable': EUCTW_cls,
- 'classFactor': 7,
- 'stateTable': EUCTW_st,
- 'charLenTable': EUCTWCharLenTable,
- 'name': 'x-euc-tw'}
-
-# GB2312
-
-GB2312_cls = (
- 1,1,1,1,1,1,1,1, # 00 - 07
- 1,1,1,1,1,1,0,0, # 08 - 0f
- 1,1,1,1,1,1,1,1, # 10 - 17
- 1,1,1,0,1,1,1,1, # 18 - 1f
- 1,1,1,1,1,1,1,1, # 20 - 27
- 1,1,1,1,1,1,1,1, # 28 - 2f
- 3,3,3,3,3,3,3,3, # 30 - 37
- 3,3,1,1,1,1,1,1, # 38 - 3f
- 2,2,2,2,2,2,2,2, # 40 - 47
- 2,2,2,2,2,2,2,2, # 48 - 4f
- 2,2,2,2,2,2,2,2, # 50 - 57
- 2,2,2,2,2,2,2,2, # 58 - 5f
- 2,2,2,2,2,2,2,2, # 60 - 67
- 2,2,2,2,2,2,2,2, # 68 - 6f
- 2,2,2,2,2,2,2,2, # 70 - 77
- 2,2,2,2,2,2,2,4, # 78 - 7f
- 5,6,6,6,6,6,6,6, # 80 - 87
- 6,6,6,6,6,6,6,6, # 88 - 8f
- 6,6,6,6,6,6,6,6, # 90 - 97
- 6,6,6,6,6,6,6,6, # 98 - 9f
- 6,6,6,6,6,6,6,6, # a0 - a7
- 6,6,6,6,6,6,6,6, # a8 - af
- 6,6,6,6,6,6,6,6, # b0 - b7
- 6,6,6,6,6,6,6,6, # b8 - bf
- 6,6,6,6,6,6,6,6, # c0 - c7
- 6,6,6,6,6,6,6,6, # c8 - cf
- 6,6,6,6,6,6,6,6, # d0 - d7
- 6,6,6,6,6,6,6,6, # d8 - df
- 6,6,6,6,6,6,6,6, # e0 - e7
- 6,6,6,6,6,6,6,6, # e8 - ef
- 6,6,6,6,6,6,6,6, # f0 - f7
- 6,6,6,6,6,6,6,0 # f8 - ff
-)
-
-GB2312_st = (
- eError,eStart,eStart,eStart,eStart,eStart, 3,eError,#00-07
- eError,eError,eError,eError,eError,eError,eItsMe,eItsMe,#08-0f
- eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,eError,eStart,#10-17
- 4,eError,eStart,eStart,eError,eError,eError,eError,#18-1f
- eError,eError, 5,eError,eError,eError,eItsMe,eError,#20-27
- eError,eError,eStart,eStart,eStart,eStart,eStart,eStart #28-2f
-)
-
-# To be accurate, the length of class 6 can be either 2 or 4.
-# But it is not necessary to discriminate between the two since
-# it is used for frequency analysis only, and we are validing
-# each code range there as well. So it is safe to set it to be
-# 2 here.
-GB2312CharLenTable = (0, 1, 1, 1, 1, 1, 2)
-
-GB2312SMModel = {'classTable': GB2312_cls,
- 'classFactor': 7,
- 'stateTable': GB2312_st,
- 'charLenTable': GB2312CharLenTable,
- 'name': 'GB2312'}
-
-# Shift_JIS
-
-SJIS_cls = (
- 1,1,1,1,1,1,1,1, # 00 - 07
- 1,1,1,1,1,1,0,0, # 08 - 0f
- 1,1,1,1,1,1,1,1, # 10 - 17
- 1,1,1,0,1,1,1,1, # 18 - 1f
- 1,1,1,1,1,1,1,1, # 20 - 27
- 1,1,1,1,1,1,1,1, # 28 - 2f
- 1,1,1,1,1,1,1,1, # 30 - 37
- 1,1,1,1,1,1,1,1, # 38 - 3f
- 2,2,2,2,2,2,2,2, # 40 - 47
- 2,2,2,2,2,2,2,2, # 48 - 4f
- 2,2,2,2,2,2,2,2, # 50 - 57
- 2,2,2,2,2,2,2,2, # 58 - 5f
- 2,2,2,2,2,2,2,2, # 60 - 67
- 2,2,2,2,2,2,2,2, # 68 - 6f
- 2,2,2,2,2,2,2,2, # 70 - 77
- 2,2,2,2,2,2,2,1, # 78 - 7f
- 3,3,3,3,3,3,3,3, # 80 - 87
- 3,3,3,3,3,3,3,3, # 88 - 8f
- 3,3,3,3,3,3,3,3, # 90 - 97
- 3,3,3,3,3,3,3,3, # 98 - 9f
- #0xa0 is illegal in sjis encoding, but some pages does
- #contain such byte. We need to be more error forgiven.
- 2,2,2,2,2,2,2,2, # a0 - a7
- 2,2,2,2,2,2,2,2, # a8 - af
- 2,2,2,2,2,2,2,2, # b0 - b7
- 2,2,2,2,2,2,2,2, # b8 - bf
- 2,2,2,2,2,2,2,2, # c0 - c7
- 2,2,2,2,2,2,2,2, # c8 - cf
- 2,2,2,2,2,2,2,2, # d0 - d7
- 2,2,2,2,2,2,2,2, # d8 - df
- 3,3,3,3,3,3,3,3, # e0 - e7
- 3,3,3,3,3,4,4,4, # e8 - ef
- 4,4,4,4,4,4,4,4, # f0 - f7
- 4,4,4,4,4,0,0,0 # f8 - ff
-)
-
-
-SJIS_st = (
- eError,eStart,eStart, 3,eError,eError,eError,eError,#00-07
- eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,#08-0f
- eItsMe,eItsMe,eError,eError,eStart,eStart,eStart,eStart #10-17
-)
-
-SJISCharLenTable = (0, 1, 1, 2, 0, 0)
-
-SJISSMModel = {'classTable': SJIS_cls,
- 'classFactor': 6,
- 'stateTable': SJIS_st,
- 'charLenTable': SJISCharLenTable,
- 'name': 'Shift_JIS'}
-
-# UCS2-BE
-
-UCS2BE_cls = (
- 0,0,0,0,0,0,0,0, # 00 - 07
- 0,0,1,0,0,2,0,0, # 08 - 0f
- 0,0,0,0,0,0,0,0, # 10 - 17
- 0,0,0,3,0,0,0,0, # 18 - 1f
- 0,0,0,0,0,0,0,0, # 20 - 27
- 0,3,3,3,3,3,0,0, # 28 - 2f
- 0,0,0,0,0,0,0,0, # 30 - 37
- 0,0,0,0,0,0,0,0, # 38 - 3f
- 0,0,0,0,0,0,0,0, # 40 - 47
- 0,0,0,0,0,0,0,0, # 48 - 4f
- 0,0,0,0,0,0,0,0, # 50 - 57
- 0,0,0,0,0,0,0,0, # 58 - 5f
- 0,0,0,0,0,0,0,0, # 60 - 67
- 0,0,0,0,0,0,0,0, # 68 - 6f
- 0,0,0,0,0,0,0,0, # 70 - 77
- 0,0,0,0,0,0,0,0, # 78 - 7f
- 0,0,0,0,0,0,0,0, # 80 - 87
- 0,0,0,0,0,0,0,0, # 88 - 8f
- 0,0,0,0,0,0,0,0, # 90 - 97
- 0,0,0,0,0,0,0,0, # 98 - 9f
- 0,0,0,0,0,0,0,0, # a0 - a7
- 0,0,0,0,0,0,0,0, # a8 - af
- 0,0,0,0,0,0,0,0, # b0 - b7
- 0,0,0,0,0,0,0,0, # b8 - bf
- 0,0,0,0,0,0,0,0, # c0 - c7
- 0,0,0,0,0,0,0,0, # c8 - cf
- 0,0,0,0,0,0,0,0, # d0 - d7
- 0,0,0,0,0,0,0,0, # d8 - df
- 0,0,0,0,0,0,0,0, # e0 - e7
- 0,0,0,0,0,0,0,0, # e8 - ef
- 0,0,0,0,0,0,0,0, # f0 - f7
- 0,0,0,0,0,0,4,5 # f8 - ff
-)
-
-UCS2BE_st = (
- 5, 7, 7,eError, 4, 3,eError,eError,#00-07
- eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,#08-0f
- eItsMe,eItsMe, 6, 6, 6, 6,eError,eError,#10-17
- 6, 6, 6, 6, 6,eItsMe, 6, 6,#18-1f
- 6, 6, 6, 6, 5, 7, 7,eError,#20-27
- 5, 8, 6, 6,eError, 6, 6, 6,#28-2f
- 6, 6, 6, 6,eError,eError,eStart,eStart #30-37
-)
-
-UCS2BECharLenTable = (2, 2, 2, 0, 2, 2)
-
-UCS2BESMModel = {'classTable': UCS2BE_cls,
- 'classFactor': 6,
- 'stateTable': UCS2BE_st,
- 'charLenTable': UCS2BECharLenTable,
- 'name': 'UTF-16BE'}
-
-# UCS2-LE
-
-UCS2LE_cls = (
- 0,0,0,0,0,0,0,0, # 00 - 07
- 0,0,1,0,0,2,0,0, # 08 - 0f
- 0,0,0,0,0,0,0,0, # 10 - 17
- 0,0,0,3,0,0,0,0, # 18 - 1f
- 0,0,0,0,0,0,0,0, # 20 - 27
- 0,3,3,3,3,3,0,0, # 28 - 2f
- 0,0,0,0,0,0,0,0, # 30 - 37
- 0,0,0,0,0,0,0,0, # 38 - 3f
- 0,0,0,0,0,0,0,0, # 40 - 47
- 0,0,0,0,0,0,0,0, # 48 - 4f
- 0,0,0,0,0,0,0,0, # 50 - 57
- 0,0,0,0,0,0,0,0, # 58 - 5f
- 0,0,0,0,0,0,0,0, # 60 - 67
- 0,0,0,0,0,0,0,0, # 68 - 6f
- 0,0,0,0,0,0,0,0, # 70 - 77
- 0,0,0,0,0,0,0,0, # 78 - 7f
- 0,0,0,0,0,0,0,0, # 80 - 87
- 0,0,0,0,0,0,0,0, # 88 - 8f
- 0,0,0,0,0,0,0,0, # 90 - 97
- 0,0,0,0,0,0,0,0, # 98 - 9f
- 0,0,0,0,0,0,0,0, # a0 - a7
- 0,0,0,0,0,0,0,0, # a8 - af
- 0,0,0,0,0,0,0,0, # b0 - b7
- 0,0,0,0,0,0,0,0, # b8 - bf
- 0,0,0,0,0,0,0,0, # c0 - c7
- 0,0,0,0,0,0,0,0, # c8 - cf
- 0,0,0,0,0,0,0,0, # d0 - d7
- 0,0,0,0,0,0,0,0, # d8 - df
- 0,0,0,0,0,0,0,0, # e0 - e7
- 0,0,0,0,0,0,0,0, # e8 - ef
- 0,0,0,0,0,0,0,0, # f0 - f7
- 0,0,0,0,0,0,4,5 # f8 - ff
-)
-
-UCS2LE_st = (
- 6, 6, 7, 6, 4, 3,eError,eError,#00-07
- eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,#08-0f
- eItsMe,eItsMe, 5, 5, 5,eError,eItsMe,eError,#10-17
- 5, 5, 5,eError, 5,eError, 6, 6,#18-1f
- 7, 6, 8, 8, 5, 5, 5,eError,#20-27
- 5, 5, 5,eError,eError,eError, 5, 5,#28-2f
- 5, 5, 5,eError, 5,eError,eStart,eStart #30-37
-)
-
-UCS2LECharLenTable = (2, 2, 2, 2, 2, 2)
-
-UCS2LESMModel = {'classTable': UCS2LE_cls,
- 'classFactor': 6,
- 'stateTable': UCS2LE_st,
- 'charLenTable': UCS2LECharLenTable,
- 'name': 'UTF-16LE'}
-
-# UTF-8
-
-UTF8_cls = (
- 1,1,1,1,1,1,1,1, # 00 - 07 #allow 0x00 as a legal value
- 1,1,1,1,1,1,0,0, # 08 - 0f
- 1,1,1,1,1,1,1,1, # 10 - 17
- 1,1,1,0,1,1,1,1, # 18 - 1f
- 1,1,1,1,1,1,1,1, # 20 - 27
- 1,1,1,1,1,1,1,1, # 28 - 2f
- 1,1,1,1,1,1,1,1, # 30 - 37
- 1,1,1,1,1,1,1,1, # 38 - 3f
- 1,1,1,1,1,1,1,1, # 40 - 47
- 1,1,1,1,1,1,1,1, # 48 - 4f
- 1,1,1,1,1,1,1,1, # 50 - 57
- 1,1,1,1,1,1,1,1, # 58 - 5f
- 1,1,1,1,1,1,1,1, # 60 - 67
- 1,1,1,1,1,1,1,1, # 68 - 6f
- 1,1,1,1,1,1,1,1, # 70 - 77
- 1,1,1,1,1,1,1,1, # 78 - 7f
- 2,2,2,2,3,3,3,3, # 80 - 87
- 4,4,4,4,4,4,4,4, # 88 - 8f
- 4,4,4,4,4,4,4,4, # 90 - 97
- 4,4,4,4,4,4,4,4, # 98 - 9f
- 5,5,5,5,5,5,5,5, # a0 - a7
- 5,5,5,5,5,5,5,5, # a8 - af
- 5,5,5,5,5,5,5,5, # b0 - b7
- 5,5,5,5,5,5,5,5, # b8 - bf
- 0,0,6,6,6,6,6,6, # c0 - c7
- 6,6,6,6,6,6,6,6, # c8 - cf
- 6,6,6,6,6,6,6,6, # d0 - d7
- 6,6,6,6,6,6,6,6, # d8 - df
- 7,8,8,8,8,8,8,8, # e0 - e7
- 8,8,8,8,8,9,8,8, # e8 - ef
- 10,11,11,11,11,11,11,11, # f0 - f7
- 12,13,13,13,14,15,0,0 # f8 - ff
-)
-
-UTF8_st = (
- eError,eStart,eError,eError,eError,eError, 12, 10,#00-07
- 9, 11, 8, 7, 6, 5, 4, 3,#08-0f
- eError,eError,eError,eError,eError,eError,eError,eError,#10-17
- eError,eError,eError,eError,eError,eError,eError,eError,#18-1f
- eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,#20-27
- eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,#28-2f
- eError,eError, 5, 5, 5, 5,eError,eError,#30-37
- eError,eError,eError,eError,eError,eError,eError,eError,#38-3f
- eError,eError,eError, 5, 5, 5,eError,eError,#40-47
- eError,eError,eError,eError,eError,eError,eError,eError,#48-4f
- eError,eError, 7, 7, 7, 7,eError,eError,#50-57
- eError,eError,eError,eError,eError,eError,eError,eError,#58-5f
- eError,eError,eError,eError, 7, 7,eError,eError,#60-67
- eError,eError,eError,eError,eError,eError,eError,eError,#68-6f
- eError,eError, 9, 9, 9, 9,eError,eError,#70-77
- eError,eError,eError,eError,eError,eError,eError,eError,#78-7f
- eError,eError,eError,eError,eError, 9,eError,eError,#80-87
- eError,eError,eError,eError,eError,eError,eError,eError,#88-8f
- eError,eError, 12, 12, 12, 12,eError,eError,#90-97
- eError,eError,eError,eError,eError,eError,eError,eError,#98-9f
- eError,eError,eError,eError,eError, 12,eError,eError,#a0-a7
- eError,eError,eError,eError,eError,eError,eError,eError,#a8-af
- eError,eError, 12, 12, 12,eError,eError,eError,#b0-b7
- eError,eError,eError,eError,eError,eError,eError,eError,#b8-bf
- eError,eError,eStart,eStart,eStart,eStart,eError,eError,#c0-c7
- eError,eError,eError,eError,eError,eError,eError,eError #c8-cf
-)
-
-UTF8CharLenTable = (0, 1, 0, 0, 0, 0, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6)
-
-UTF8SMModel = {'classTable': UTF8_cls,
- 'classFactor': 16,
- 'stateTable': UTF8_st,
- 'charLenTable': UTF8CharLenTable,
- 'name': 'UTF-8'}
-
-# flake8: noqa
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+from .constants import eStart, eError, eItsMe
+
+# BIG5
+
+BIG5_cls = (
+ 1,1,1,1,1,1,1,1, # 00 - 07 #allow 0x00 as legal value
+ 1,1,1,1,1,1,0,0, # 08 - 0f
+ 1,1,1,1,1,1,1,1, # 10 - 17
+ 1,1,1,0,1,1,1,1, # 18 - 1f
+ 1,1,1,1,1,1,1,1, # 20 - 27
+ 1,1,1,1,1,1,1,1, # 28 - 2f
+ 1,1,1,1,1,1,1,1, # 30 - 37
+ 1,1,1,1,1,1,1,1, # 38 - 3f
+ 2,2,2,2,2,2,2,2, # 40 - 47
+ 2,2,2,2,2,2,2,2, # 48 - 4f
+ 2,2,2,2,2,2,2,2, # 50 - 57
+ 2,2,2,2,2,2,2,2, # 58 - 5f
+ 2,2,2,2,2,2,2,2, # 60 - 67
+ 2,2,2,2,2,2,2,2, # 68 - 6f
+ 2,2,2,2,2,2,2,2, # 70 - 77
+ 2,2,2,2,2,2,2,1, # 78 - 7f
+ 4,4,4,4,4,4,4,4, # 80 - 87
+ 4,4,4,4,4,4,4,4, # 88 - 8f
+ 4,4,4,4,4,4,4,4, # 90 - 97
+ 4,4,4,4,4,4,4,4, # 98 - 9f
+ 4,3,3,3,3,3,3,3, # a0 - a7
+ 3,3,3,3,3,3,3,3, # a8 - af
+ 3,3,3,3,3,3,3,3, # b0 - b7
+ 3,3,3,3,3,3,3,3, # b8 - bf
+ 3,3,3,3,3,3,3,3, # c0 - c7
+ 3,3,3,3,3,3,3,3, # c8 - cf
+ 3,3,3,3,3,3,3,3, # d0 - d7
+ 3,3,3,3,3,3,3,3, # d8 - df
+ 3,3,3,3,3,3,3,3, # e0 - e7
+ 3,3,3,3,3,3,3,3, # e8 - ef
+ 3,3,3,3,3,3,3,3, # f0 - f7
+ 3,3,3,3,3,3,3,0 # f8 - ff
+)
+
+BIG5_st = (
+ eError,eStart,eStart, 3,eError,eError,eError,eError,#00-07
+ eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,#08-0f
+ eError,eStart,eStart,eStart,eStart,eStart,eStart,eStart#10-17
+)
+
+Big5CharLenTable = (0, 1, 1, 2, 0)
+
+Big5SMModel = {'classTable': BIG5_cls,
+ 'classFactor': 5,
+ 'stateTable': BIG5_st,
+ 'charLenTable': Big5CharLenTable,
+ 'name': 'Big5'}
+
+# EUC-JP
+
+EUCJP_cls = (
+ 4,4,4,4,4,4,4,4, # 00 - 07
+ 4,4,4,4,4,4,5,5, # 08 - 0f
+ 4,4,4,4,4,4,4,4, # 10 - 17
+ 4,4,4,5,4,4,4,4, # 18 - 1f
+ 4,4,4,4,4,4,4,4, # 20 - 27
+ 4,4,4,4,4,4,4,4, # 28 - 2f
+ 4,4,4,4,4,4,4,4, # 30 - 37
+ 4,4,4,4,4,4,4,4, # 38 - 3f
+ 4,4,4,4,4,4,4,4, # 40 - 47
+ 4,4,4,4,4,4,4,4, # 48 - 4f
+ 4,4,4,4,4,4,4,4, # 50 - 57
+ 4,4,4,4,4,4,4,4, # 58 - 5f
+ 4,4,4,4,4,4,4,4, # 60 - 67
+ 4,4,4,4,4,4,4,4, # 68 - 6f
+ 4,4,4,4,4,4,4,4, # 70 - 77
+ 4,4,4,4,4,4,4,4, # 78 - 7f
+ 5,5,5,5,5,5,5,5, # 80 - 87
+ 5,5,5,5,5,5,1,3, # 88 - 8f
+ 5,5,5,5,5,5,5,5, # 90 - 97
+ 5,5,5,5,5,5,5,5, # 98 - 9f
+ 5,2,2,2,2,2,2,2, # a0 - a7
+ 2,2,2,2,2,2,2,2, # a8 - af
+ 2,2,2,2,2,2,2,2, # b0 - b7
+ 2,2,2,2,2,2,2,2, # b8 - bf
+ 2,2,2,2,2,2,2,2, # c0 - c7
+ 2,2,2,2,2,2,2,2, # c8 - cf
+ 2,2,2,2,2,2,2,2, # d0 - d7
+ 2,2,2,2,2,2,2,2, # d8 - df
+ 0,0,0,0,0,0,0,0, # e0 - e7
+ 0,0,0,0,0,0,0,0, # e8 - ef
+ 0,0,0,0,0,0,0,0, # f0 - f7
+ 0,0,0,0,0,0,0,5 # f8 - ff
+)
+
+EUCJP_st = (
+ 3, 4, 3, 5,eStart,eError,eError,eError,#00-07
+ eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,#08-0f
+ eItsMe,eItsMe,eStart,eError,eStart,eError,eError,eError,#10-17
+ eError,eError,eStart,eError,eError,eError, 3,eError,#18-1f
+ 3,eError,eError,eError,eStart,eStart,eStart,eStart#20-27
+)
+
+EUCJPCharLenTable = (2, 2, 2, 3, 1, 0)
+
+EUCJPSMModel = {'classTable': EUCJP_cls,
+ 'classFactor': 6,
+ 'stateTable': EUCJP_st,
+ 'charLenTable': EUCJPCharLenTable,
+ 'name': 'EUC-JP'}
+
+# EUC-KR
+
+EUCKR_cls = (
+ 1,1,1,1,1,1,1,1, # 00 - 07
+ 1,1,1,1,1,1,0,0, # 08 - 0f
+ 1,1,1,1,1,1,1,1, # 10 - 17
+ 1,1,1,0,1,1,1,1, # 18 - 1f
+ 1,1,1,1,1,1,1,1, # 20 - 27
+ 1,1,1,1,1,1,1,1, # 28 - 2f
+ 1,1,1,1,1,1,1,1, # 30 - 37
+ 1,1,1,1,1,1,1,1, # 38 - 3f
+ 1,1,1,1,1,1,1,1, # 40 - 47
+ 1,1,1,1,1,1,1,1, # 48 - 4f
+ 1,1,1,1,1,1,1,1, # 50 - 57
+ 1,1,1,1,1,1,1,1, # 58 - 5f
+ 1,1,1,1,1,1,1,1, # 60 - 67
+ 1,1,1,1,1,1,1,1, # 68 - 6f
+ 1,1,1,1,1,1,1,1, # 70 - 77
+ 1,1,1,1,1,1,1,1, # 78 - 7f
+ 0,0,0,0,0,0,0,0, # 80 - 87
+ 0,0,0,0,0,0,0,0, # 88 - 8f
+ 0,0,0,0,0,0,0,0, # 90 - 97
+ 0,0,0,0,0,0,0,0, # 98 - 9f
+ 0,2,2,2,2,2,2,2, # a0 - a7
+ 2,2,2,2,2,3,3,3, # a8 - af
+ 2,2,2,2,2,2,2,2, # b0 - b7
+ 2,2,2,2,2,2,2,2, # b8 - bf
+ 2,2,2,2,2,2,2,2, # c0 - c7
+ 2,3,2,2,2,2,2,2, # c8 - cf
+ 2,2,2,2,2,2,2,2, # d0 - d7
+ 2,2,2,2,2,2,2,2, # d8 - df
+ 2,2,2,2,2,2,2,2, # e0 - e7
+ 2,2,2,2,2,2,2,2, # e8 - ef
+ 2,2,2,2,2,2,2,2, # f0 - f7
+ 2,2,2,2,2,2,2,0 # f8 - ff
+)
+
+EUCKR_st = (
+ eError,eStart, 3,eError,eError,eError,eError,eError,#00-07
+ eItsMe,eItsMe,eItsMe,eItsMe,eError,eError,eStart,eStart #08-0f
+)
+
+EUCKRCharLenTable = (0, 1, 2, 0)
+
+EUCKRSMModel = {'classTable': EUCKR_cls,
+ 'classFactor': 4,
+ 'stateTable': EUCKR_st,
+ 'charLenTable': EUCKRCharLenTable,
+ 'name': 'EUC-KR'}
+
+# EUC-TW
+
+EUCTW_cls = (
+ 2,2,2,2,2,2,2,2, # 00 - 07
+ 2,2,2,2,2,2,0,0, # 08 - 0f
+ 2,2,2,2,2,2,2,2, # 10 - 17
+ 2,2,2,0,2,2,2,2, # 18 - 1f
+ 2,2,2,2,2,2,2,2, # 20 - 27
+ 2,2,2,2,2,2,2,2, # 28 - 2f
+ 2,2,2,2,2,2,2,2, # 30 - 37
+ 2,2,2,2,2,2,2,2, # 38 - 3f
+ 2,2,2,2,2,2,2,2, # 40 - 47
+ 2,2,2,2,2,2,2,2, # 48 - 4f
+ 2,2,2,2,2,2,2,2, # 50 - 57
+ 2,2,2,2,2,2,2,2, # 58 - 5f
+ 2,2,2,2,2,2,2,2, # 60 - 67
+ 2,2,2,2,2,2,2,2, # 68 - 6f
+ 2,2,2,2,2,2,2,2, # 70 - 77
+ 2,2,2,2,2,2,2,2, # 78 - 7f
+ 0,0,0,0,0,0,0,0, # 80 - 87
+ 0,0,0,0,0,0,6,0, # 88 - 8f
+ 0,0,0,0,0,0,0,0, # 90 - 97
+ 0,0,0,0,0,0,0,0, # 98 - 9f
+ 0,3,4,4,4,4,4,4, # a0 - a7
+ 5,5,1,1,1,1,1,1, # a8 - af
+ 1,1,1,1,1,1,1,1, # b0 - b7
+ 1,1,1,1,1,1,1,1, # b8 - bf
+ 1,1,3,1,3,3,3,3, # c0 - c7
+ 3,3,3,3,3,3,3,3, # c8 - cf
+ 3,3,3,3,3,3,3,3, # d0 - d7
+ 3,3,3,3,3,3,3,3, # d8 - df
+ 3,3,3,3,3,3,3,3, # e0 - e7
+ 3,3,3,3,3,3,3,3, # e8 - ef
+ 3,3,3,3,3,3,3,3, # f0 - f7
+ 3,3,3,3,3,3,3,0 # f8 - ff
+)
+
+EUCTW_st = (
+ eError,eError,eStart, 3, 3, 3, 4,eError,#00-07
+ eError,eError,eError,eError,eError,eError,eItsMe,eItsMe,#08-0f
+ eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,eStart,eError,#10-17
+ eStart,eStart,eStart,eError,eError,eError,eError,eError,#18-1f
+ 5,eError,eError,eError,eStart,eError,eStart,eStart,#20-27
+ eStart,eError,eStart,eStart,eStart,eStart,eStart,eStart #28-2f
+)
+
+EUCTWCharLenTable = (0, 0, 1, 2, 2, 2, 3)
+
+EUCTWSMModel = {'classTable': EUCTW_cls,
+ 'classFactor': 7,
+ 'stateTable': EUCTW_st,
+ 'charLenTable': EUCTWCharLenTable,
+ 'name': 'x-euc-tw'}
+
+# GB2312
+
+GB2312_cls = (
+ 1,1,1,1,1,1,1,1, # 00 - 07
+ 1,1,1,1,1,1,0,0, # 08 - 0f
+ 1,1,1,1,1,1,1,1, # 10 - 17
+ 1,1,1,0,1,1,1,1, # 18 - 1f
+ 1,1,1,1,1,1,1,1, # 20 - 27
+ 1,1,1,1,1,1,1,1, # 28 - 2f
+ 3,3,3,3,3,3,3,3, # 30 - 37
+ 3,3,1,1,1,1,1,1, # 38 - 3f
+ 2,2,2,2,2,2,2,2, # 40 - 47
+ 2,2,2,2,2,2,2,2, # 48 - 4f
+ 2,2,2,2,2,2,2,2, # 50 - 57
+ 2,2,2,2,2,2,2,2, # 58 - 5f
+ 2,2,2,2,2,2,2,2, # 60 - 67
+ 2,2,2,2,2,2,2,2, # 68 - 6f
+ 2,2,2,2,2,2,2,2, # 70 - 77
+ 2,2,2,2,2,2,2,4, # 78 - 7f
+ 5,6,6,6,6,6,6,6, # 80 - 87
+ 6,6,6,6,6,6,6,6, # 88 - 8f
+ 6,6,6,6,6,6,6,6, # 90 - 97
+ 6,6,6,6,6,6,6,6, # 98 - 9f
+ 6,6,6,6,6,6,6,6, # a0 - a7
+ 6,6,6,6,6,6,6,6, # a8 - af
+ 6,6,6,6,6,6,6,6, # b0 - b7
+ 6,6,6,6,6,6,6,6, # b8 - bf
+ 6,6,6,6,6,6,6,6, # c0 - c7
+ 6,6,6,6,6,6,6,6, # c8 - cf
+ 6,6,6,6,6,6,6,6, # d0 - d7
+ 6,6,6,6,6,6,6,6, # d8 - df
+ 6,6,6,6,6,6,6,6, # e0 - e7
+ 6,6,6,6,6,6,6,6, # e8 - ef
+ 6,6,6,6,6,6,6,6, # f0 - f7
+ 6,6,6,6,6,6,6,0 # f8 - ff
+)
+
+GB2312_st = (
+ eError,eStart,eStart,eStart,eStart,eStart, 3,eError,#00-07
+ eError,eError,eError,eError,eError,eError,eItsMe,eItsMe,#08-0f
+ eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,eError,eStart,#10-17
+ 4,eError,eStart,eStart,eError,eError,eError,eError,#18-1f
+ eError,eError, 5,eError,eError,eError,eItsMe,eError,#20-27
+ eError,eError,eStart,eStart,eStart,eStart,eStart,eStart #28-2f
+)
+
+# To be accurate, the length of class 6 can be either 2 or 4.
+# But it is not necessary to discriminate between the two since
+# it is used for frequency analysis only, and we are validing
+# each code range there as well. So it is safe to set it to be
+# 2 here.
+GB2312CharLenTable = (0, 1, 1, 1, 1, 1, 2)
+
+GB2312SMModel = {'classTable': GB2312_cls,
+ 'classFactor': 7,
+ 'stateTable': GB2312_st,
+ 'charLenTable': GB2312CharLenTable,
+ 'name': 'GB2312'}
+
+# Shift_JIS
+
+SJIS_cls = (
+ 1,1,1,1,1,1,1,1, # 00 - 07
+ 1,1,1,1,1,1,0,0, # 08 - 0f
+ 1,1,1,1,1,1,1,1, # 10 - 17
+ 1,1,1,0,1,1,1,1, # 18 - 1f
+ 1,1,1,1,1,1,1,1, # 20 - 27
+ 1,1,1,1,1,1,1,1, # 28 - 2f
+ 1,1,1,1,1,1,1,1, # 30 - 37
+ 1,1,1,1,1,1,1,1, # 38 - 3f
+ 2,2,2,2,2,2,2,2, # 40 - 47
+ 2,2,2,2,2,2,2,2, # 48 - 4f
+ 2,2,2,2,2,2,2,2, # 50 - 57
+ 2,2,2,2,2,2,2,2, # 58 - 5f
+ 2,2,2,2,2,2,2,2, # 60 - 67
+ 2,2,2,2,2,2,2,2, # 68 - 6f
+ 2,2,2,2,2,2,2,2, # 70 - 77
+ 2,2,2,2,2,2,2,1, # 78 - 7f
+ 3,3,3,3,3,3,3,3, # 80 - 87
+ 3,3,3,3,3,3,3,3, # 88 - 8f
+ 3,3,3,3,3,3,3,3, # 90 - 97
+ 3,3,3,3,3,3,3,3, # 98 - 9f
+ #0xa0 is illegal in sjis encoding, but some pages does
+ #contain such byte. We need to be more error forgiven.
+ 2,2,2,2,2,2,2,2, # a0 - a7
+ 2,2,2,2,2,2,2,2, # a8 - af
+ 2,2,2,2,2,2,2,2, # b0 - b7
+ 2,2,2,2,2,2,2,2, # b8 - bf
+ 2,2,2,2,2,2,2,2, # c0 - c7
+ 2,2,2,2,2,2,2,2, # c8 - cf
+ 2,2,2,2,2,2,2,2, # d0 - d7
+ 2,2,2,2,2,2,2,2, # d8 - df
+ 3,3,3,3,3,3,3,3, # e0 - e7
+ 3,3,3,3,3,4,4,4, # e8 - ef
+ 4,4,4,4,4,4,4,4, # f0 - f7
+ 4,4,4,4,4,0,0,0 # f8 - ff
+)
+
+
+SJIS_st = (
+ eError,eStart,eStart, 3,eError,eError,eError,eError,#00-07
+ eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,#08-0f
+ eItsMe,eItsMe,eError,eError,eStart,eStart,eStart,eStart #10-17
+)
+
+SJISCharLenTable = (0, 1, 1, 2, 0, 0)
+
+SJISSMModel = {'classTable': SJIS_cls,
+ 'classFactor': 6,
+ 'stateTable': SJIS_st,
+ 'charLenTable': SJISCharLenTable,
+ 'name': 'Shift_JIS'}
+
+# UCS2-BE
+
+UCS2BE_cls = (
+ 0,0,0,0,0,0,0,0, # 00 - 07
+ 0,0,1,0,0,2,0,0, # 08 - 0f
+ 0,0,0,0,0,0,0,0, # 10 - 17
+ 0,0,0,3,0,0,0,0, # 18 - 1f
+ 0,0,0,0,0,0,0,0, # 20 - 27
+ 0,3,3,3,3,3,0,0, # 28 - 2f
+ 0,0,0,0,0,0,0,0, # 30 - 37
+ 0,0,0,0,0,0,0,0, # 38 - 3f
+ 0,0,0,0,0,0,0,0, # 40 - 47
+ 0,0,0,0,0,0,0,0, # 48 - 4f
+ 0,0,0,0,0,0,0,0, # 50 - 57
+ 0,0,0,0,0,0,0,0, # 58 - 5f
+ 0,0,0,0,0,0,0,0, # 60 - 67
+ 0,0,0,0,0,0,0,0, # 68 - 6f
+ 0,0,0,0,0,0,0,0, # 70 - 77
+ 0,0,0,0,0,0,0,0, # 78 - 7f
+ 0,0,0,0,0,0,0,0, # 80 - 87
+ 0,0,0,0,0,0,0,0, # 88 - 8f
+ 0,0,0,0,0,0,0,0, # 90 - 97
+ 0,0,0,0,0,0,0,0, # 98 - 9f
+ 0,0,0,0,0,0,0,0, # a0 - a7
+ 0,0,0,0,0,0,0,0, # a8 - af
+ 0,0,0,0,0,0,0,0, # b0 - b7
+ 0,0,0,0,0,0,0,0, # b8 - bf
+ 0,0,0,0,0,0,0,0, # c0 - c7
+ 0,0,0,0,0,0,0,0, # c8 - cf
+ 0,0,0,0,0,0,0,0, # d0 - d7
+ 0,0,0,0,0,0,0,0, # d8 - df
+ 0,0,0,0,0,0,0,0, # e0 - e7
+ 0,0,0,0,0,0,0,0, # e8 - ef
+ 0,0,0,0,0,0,0,0, # f0 - f7
+ 0,0,0,0,0,0,4,5 # f8 - ff
+)
+
+UCS2BE_st = (
+ 5, 7, 7,eError, 4, 3,eError,eError,#00-07
+ eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,#08-0f
+ eItsMe,eItsMe, 6, 6, 6, 6,eError,eError,#10-17
+ 6, 6, 6, 6, 6,eItsMe, 6, 6,#18-1f
+ 6, 6, 6, 6, 5, 7, 7,eError,#20-27
+ 5, 8, 6, 6,eError, 6, 6, 6,#28-2f
+ 6, 6, 6, 6,eError,eError,eStart,eStart #30-37
+)
+
+UCS2BECharLenTable = (2, 2, 2, 0, 2, 2)
+
+UCS2BESMModel = {'classTable': UCS2BE_cls,
+ 'classFactor': 6,
+ 'stateTable': UCS2BE_st,
+ 'charLenTable': UCS2BECharLenTable,
+ 'name': 'UTF-16BE'}
+
+# UCS2-LE
+
+UCS2LE_cls = (
+ 0,0,0,0,0,0,0,0, # 00 - 07
+ 0,0,1,0,0,2,0,0, # 08 - 0f
+ 0,0,0,0,0,0,0,0, # 10 - 17
+ 0,0,0,3,0,0,0,0, # 18 - 1f
+ 0,0,0,0,0,0,0,0, # 20 - 27
+ 0,3,3,3,3,3,0,0, # 28 - 2f
+ 0,0,0,0,0,0,0,0, # 30 - 37
+ 0,0,0,0,0,0,0,0, # 38 - 3f
+ 0,0,0,0,0,0,0,0, # 40 - 47
+ 0,0,0,0,0,0,0,0, # 48 - 4f
+ 0,0,0,0,0,0,0,0, # 50 - 57
+ 0,0,0,0,0,0,0,0, # 58 - 5f
+ 0,0,0,0,0,0,0,0, # 60 - 67
+ 0,0,0,0,0,0,0,0, # 68 - 6f
+ 0,0,0,0,0,0,0,0, # 70 - 77
+ 0,0,0,0,0,0,0,0, # 78 - 7f
+ 0,0,0,0,0,0,0,0, # 80 - 87
+ 0,0,0,0,0,0,0,0, # 88 - 8f
+ 0,0,0,0,0,0,0,0, # 90 - 97
+ 0,0,0,0,0,0,0,0, # 98 - 9f
+ 0,0,0,0,0,0,0,0, # a0 - a7
+ 0,0,0,0,0,0,0,0, # a8 - af
+ 0,0,0,0,0,0,0,0, # b0 - b7
+ 0,0,0,0,0,0,0,0, # b8 - bf
+ 0,0,0,0,0,0,0,0, # c0 - c7
+ 0,0,0,0,0,0,0,0, # c8 - cf
+ 0,0,0,0,0,0,0,0, # d0 - d7
+ 0,0,0,0,0,0,0,0, # d8 - df
+ 0,0,0,0,0,0,0,0, # e0 - e7
+ 0,0,0,0,0,0,0,0, # e8 - ef
+ 0,0,0,0,0,0,0,0, # f0 - f7
+ 0,0,0,0,0,0,4,5 # f8 - ff
+)
+
+UCS2LE_st = (
+ 6, 6, 7, 6, 4, 3,eError,eError,#00-07
+ eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,#08-0f
+ eItsMe,eItsMe, 5, 5, 5,eError,eItsMe,eError,#10-17
+ 5, 5, 5,eError, 5,eError, 6, 6,#18-1f
+ 7, 6, 8, 8, 5, 5, 5,eError,#20-27
+ 5, 5, 5,eError,eError,eError, 5, 5,#28-2f
+ 5, 5, 5,eError, 5,eError,eStart,eStart #30-37
+)
+
+UCS2LECharLenTable = (2, 2, 2, 2, 2, 2)
+
+UCS2LESMModel = {'classTable': UCS2LE_cls,
+ 'classFactor': 6,
+ 'stateTable': UCS2LE_st,
+ 'charLenTable': UCS2LECharLenTable,
+ 'name': 'UTF-16LE'}
+
+# UTF-8
+
+UTF8_cls = (
+ 1,1,1,1,1,1,1,1, # 00 - 07 #allow 0x00 as a legal value
+ 1,1,1,1,1,1,0,0, # 08 - 0f
+ 1,1,1,1,1,1,1,1, # 10 - 17
+ 1,1,1,0,1,1,1,1, # 18 - 1f
+ 1,1,1,1,1,1,1,1, # 20 - 27
+ 1,1,1,1,1,1,1,1, # 28 - 2f
+ 1,1,1,1,1,1,1,1, # 30 - 37
+ 1,1,1,1,1,1,1,1, # 38 - 3f
+ 1,1,1,1,1,1,1,1, # 40 - 47
+ 1,1,1,1,1,1,1,1, # 48 - 4f
+ 1,1,1,1,1,1,1,1, # 50 - 57
+ 1,1,1,1,1,1,1,1, # 58 - 5f
+ 1,1,1,1,1,1,1,1, # 60 - 67
+ 1,1,1,1,1,1,1,1, # 68 - 6f
+ 1,1,1,1,1,1,1,1, # 70 - 77
+ 1,1,1,1,1,1,1,1, # 78 - 7f
+ 2,2,2,2,3,3,3,3, # 80 - 87
+ 4,4,4,4,4,4,4,4, # 88 - 8f
+ 4,4,4,4,4,4,4,4, # 90 - 97
+ 4,4,4,4,4,4,4,4, # 98 - 9f
+ 5,5,5,5,5,5,5,5, # a0 - a7
+ 5,5,5,5,5,5,5,5, # a8 - af
+ 5,5,5,5,5,5,5,5, # b0 - b7
+ 5,5,5,5,5,5,5,5, # b8 - bf
+ 0,0,6,6,6,6,6,6, # c0 - c7
+ 6,6,6,6,6,6,6,6, # c8 - cf
+ 6,6,6,6,6,6,6,6, # d0 - d7
+ 6,6,6,6,6,6,6,6, # d8 - df
+ 7,8,8,8,8,8,8,8, # e0 - e7
+ 8,8,8,8,8,9,8,8, # e8 - ef
+ 10,11,11,11,11,11,11,11, # f0 - f7
+ 12,13,13,13,14,15,0,0 # f8 - ff
+)
+
+UTF8_st = (
+ eError,eStart,eError,eError,eError,eError, 12, 10,#00-07
+ 9, 11, 8, 7, 6, 5, 4, 3,#08-0f
+ eError,eError,eError,eError,eError,eError,eError,eError,#10-17
+ eError,eError,eError,eError,eError,eError,eError,eError,#18-1f
+ eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,#20-27
+ eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,#28-2f
+ eError,eError, 5, 5, 5, 5,eError,eError,#30-37
+ eError,eError,eError,eError,eError,eError,eError,eError,#38-3f
+ eError,eError,eError, 5, 5, 5,eError,eError,#40-47
+ eError,eError,eError,eError,eError,eError,eError,eError,#48-4f
+ eError,eError, 7, 7, 7, 7,eError,eError,#50-57
+ eError,eError,eError,eError,eError,eError,eError,eError,#58-5f
+ eError,eError,eError,eError, 7, 7,eError,eError,#60-67
+ eError,eError,eError,eError,eError,eError,eError,eError,#68-6f
+ eError,eError, 9, 9, 9, 9,eError,eError,#70-77
+ eError,eError,eError,eError,eError,eError,eError,eError,#78-7f
+ eError,eError,eError,eError,eError, 9,eError,eError,#80-87
+ eError,eError,eError,eError,eError,eError,eError,eError,#88-8f
+ eError,eError, 12, 12, 12, 12,eError,eError,#90-97
+ eError,eError,eError,eError,eError,eError,eError,eError,#98-9f
+ eError,eError,eError,eError,eError, 12,eError,eError,#a0-a7
+ eError,eError,eError,eError,eError,eError,eError,eError,#a8-af
+ eError,eError, 12, 12, 12,eError,eError,eError,#b0-b7
+ eError,eError,eError,eError,eError,eError,eError,eError,#b8-bf
+ eError,eError,eStart,eStart,eStart,eStart,eError,eError,#c0-c7
+ eError,eError,eError,eError,eError,eError,eError,eError #c8-cf
+)
+
+UTF8CharLenTable = (0, 1, 0, 0, 0, 0, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6)
+
+UTF8SMModel = {'classTable': UTF8_cls,
+ 'classFactor': 16,
+ 'stateTable': UTF8_st,
+ 'charLenTable': UTF8CharLenTable,
+ 'name': 'UTF-8'}
+
+# flake8: noqa
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/sbcharsetprober.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/sbcharsetprober.py
similarity index 97%
rename from app/src/processing/app/i18n/python/requests/packages/charade/sbcharsetprober.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/sbcharsetprober.py
index da26715cfcd..37291bd27a9 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/sbcharsetprober.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/sbcharsetprober.py
@@ -1,120 +1,120 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is Mozilla Universal charset detector code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 2001
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-# Shy Shalom - original C code
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-import sys
-from . import constants
-from .charsetprober import CharSetProber
-from .compat import wrap_ord
-
-SAMPLE_SIZE = 64
-SB_ENOUGH_REL_THRESHOLD = 1024
-POSITIVE_SHORTCUT_THRESHOLD = 0.95
-NEGATIVE_SHORTCUT_THRESHOLD = 0.05
-SYMBOL_CAT_ORDER = 250
-NUMBER_OF_SEQ_CAT = 4
-POSITIVE_CAT = NUMBER_OF_SEQ_CAT - 1
-#NEGATIVE_CAT = 0
-
-
-class SingleByteCharSetProber(CharSetProber):
- def __init__(self, model, reversed=False, nameProber=None):
- CharSetProber.__init__(self)
- self._mModel = model
- # TRUE if we need to reverse every pair in the model lookup
- self._mReversed = reversed
- # Optional auxiliary prober for name decision
- self._mNameProber = nameProber
- self.reset()
-
- def reset(self):
- CharSetProber.reset(self)
- # char order of last character
- self._mLastOrder = 255
- self._mSeqCounters = [0] * NUMBER_OF_SEQ_CAT
- self._mTotalSeqs = 0
- self._mTotalChar = 0
- # characters that fall in our sampling range
- self._mFreqChar = 0
-
- def get_charset_name(self):
- if self._mNameProber:
- return self._mNameProber.get_charset_name()
- else:
- return self._mModel['charsetName']
-
- def feed(self, aBuf):
- if not self._mModel['keepEnglishLetter']:
- aBuf = self.filter_without_english_letters(aBuf)
- aLen = len(aBuf)
- if not aLen:
- return self.get_state()
- for c in aBuf:
- order = self._mModel['charToOrderMap'][wrap_ord(c)]
- if order < SYMBOL_CAT_ORDER:
- self._mTotalChar += 1
- if order < SAMPLE_SIZE:
- self._mFreqChar += 1
- if self._mLastOrder < SAMPLE_SIZE:
- self._mTotalSeqs += 1
- if not self._mReversed:
- i = (self._mLastOrder * SAMPLE_SIZE) + order
- model = self._mModel['precedenceMatrix'][i]
- else: # reverse the order of the letters in the lookup
- i = (order * SAMPLE_SIZE) + self._mLastOrder
- model = self._mModel['precedenceMatrix'][i]
- self._mSeqCounters[model] += 1
- self._mLastOrder = order
-
- if self.get_state() == constants.eDetecting:
- if self._mTotalSeqs > SB_ENOUGH_REL_THRESHOLD:
- cf = self.get_confidence()
- if cf > POSITIVE_SHORTCUT_THRESHOLD:
- if constants._debug:
- sys.stderr.write('%s confidence = %s, we have a'
- 'winner\n' %
- (self._mModel['charsetName'], cf))
- self._mState = constants.eFoundIt
- elif cf < NEGATIVE_SHORTCUT_THRESHOLD:
- if constants._debug:
- sys.stderr.write('%s confidence = %s, below negative'
- 'shortcut threshhold %s\n' %
- (self._mModel['charsetName'], cf,
- NEGATIVE_SHORTCUT_THRESHOLD))
- self._mState = constants.eNotMe
-
- return self.get_state()
-
- def get_confidence(self):
- r = 0.01
- if self._mTotalSeqs > 0:
- r = ((1.0 * self._mSeqCounters[POSITIVE_CAT]) / self._mTotalSeqs
- / self._mModel['mTypicalPositiveRatio'])
- r = r * self._mFreqChar / self._mTotalChar
- if r >= 1.0:
- r = 0.99
- return r
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is Mozilla Universal charset detector code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 2001
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+# Shy Shalom - original C code
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+import sys
+from . import constants
+from .charsetprober import CharSetProber
+from .compat import wrap_ord
+
+SAMPLE_SIZE = 64
+SB_ENOUGH_REL_THRESHOLD = 1024
+POSITIVE_SHORTCUT_THRESHOLD = 0.95
+NEGATIVE_SHORTCUT_THRESHOLD = 0.05
+SYMBOL_CAT_ORDER = 250
+NUMBER_OF_SEQ_CAT = 4
+POSITIVE_CAT = NUMBER_OF_SEQ_CAT - 1
+#NEGATIVE_CAT = 0
+
+
+class SingleByteCharSetProber(CharSetProber):
+ def __init__(self, model, reversed=False, nameProber=None):
+ CharSetProber.__init__(self)
+ self._mModel = model
+ # TRUE if we need to reverse every pair in the model lookup
+ self._mReversed = reversed
+ # Optional auxiliary prober for name decision
+ self._mNameProber = nameProber
+ self.reset()
+
+ def reset(self):
+ CharSetProber.reset(self)
+ # char order of last character
+ self._mLastOrder = 255
+ self._mSeqCounters = [0] * NUMBER_OF_SEQ_CAT
+ self._mTotalSeqs = 0
+ self._mTotalChar = 0
+ # characters that fall in our sampling range
+ self._mFreqChar = 0
+
+ def get_charset_name(self):
+ if self._mNameProber:
+ return self._mNameProber.get_charset_name()
+ else:
+ return self._mModel['charsetName']
+
+ def feed(self, aBuf):
+ if not self._mModel['keepEnglishLetter']:
+ aBuf = self.filter_without_english_letters(aBuf)
+ aLen = len(aBuf)
+ if not aLen:
+ return self.get_state()
+ for c in aBuf:
+ order = self._mModel['charToOrderMap'][wrap_ord(c)]
+ if order < SYMBOL_CAT_ORDER:
+ self._mTotalChar += 1
+ if order < SAMPLE_SIZE:
+ self._mFreqChar += 1
+ if self._mLastOrder < SAMPLE_SIZE:
+ self._mTotalSeqs += 1
+ if not self._mReversed:
+ i = (self._mLastOrder * SAMPLE_SIZE) + order
+ model = self._mModel['precedenceMatrix'][i]
+ else: # reverse the order of the letters in the lookup
+ i = (order * SAMPLE_SIZE) + self._mLastOrder
+ model = self._mModel['precedenceMatrix'][i]
+ self._mSeqCounters[model] += 1
+ self._mLastOrder = order
+
+ if self.get_state() == constants.eDetecting:
+ if self._mTotalSeqs > SB_ENOUGH_REL_THRESHOLD:
+ cf = self.get_confidence()
+ if cf > POSITIVE_SHORTCUT_THRESHOLD:
+ if constants._debug:
+ sys.stderr.write('%s confidence = %s, we have a'
+ 'winner\n' %
+ (self._mModel['charsetName'], cf))
+ self._mState = constants.eFoundIt
+ elif cf < NEGATIVE_SHORTCUT_THRESHOLD:
+ if constants._debug:
+ sys.stderr.write('%s confidence = %s, below negative'
+ 'shortcut threshhold %s\n' %
+ (self._mModel['charsetName'], cf,
+ NEGATIVE_SHORTCUT_THRESHOLD))
+ self._mState = constants.eNotMe
+
+ return self.get_state()
+
+ def get_confidence(self):
+ r = 0.01
+ if self._mTotalSeqs > 0:
+ r = ((1.0 * self._mSeqCounters[POSITIVE_CAT]) / self._mTotalSeqs
+ / self._mModel['mTypicalPositiveRatio'])
+ r = r * self._mFreqChar / self._mTotalChar
+ if r >= 1.0:
+ r = 0.99
+ return r
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/sbcsgroupprober.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/sbcsgroupprober.py
similarity index 97%
rename from app/src/processing/app/i18n/python/requests/packages/charade/sbcsgroupprober.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/sbcsgroupprober.py
index b224814568f..1b6196cd16c 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/sbcsgroupprober.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/sbcsgroupprober.py
@@ -1,69 +1,69 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is Mozilla Universal charset detector code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 2001
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-# Shy Shalom - original C code
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-from .charsetgroupprober import CharSetGroupProber
-from .sbcharsetprober import SingleByteCharSetProber
-from .langcyrillicmodel import (Win1251CyrillicModel, Koi8rModel,
- Latin5CyrillicModel, MacCyrillicModel,
- Ibm866Model, Ibm855Model)
-from .langgreekmodel import Latin7GreekModel, Win1253GreekModel
-from .langbulgarianmodel import Latin5BulgarianModel, Win1251BulgarianModel
-from .langhungarianmodel import Latin2HungarianModel, Win1250HungarianModel
-from .langthaimodel import TIS620ThaiModel
-from .langhebrewmodel import Win1255HebrewModel
-from .hebrewprober import HebrewProber
-
-
-class SBCSGroupProber(CharSetGroupProber):
- def __init__(self):
- CharSetGroupProber.__init__(self)
- self._mProbers = [
- SingleByteCharSetProber(Win1251CyrillicModel),
- SingleByteCharSetProber(Koi8rModel),
- SingleByteCharSetProber(Latin5CyrillicModel),
- SingleByteCharSetProber(MacCyrillicModel),
- SingleByteCharSetProber(Ibm866Model),
- SingleByteCharSetProber(Ibm855Model),
- SingleByteCharSetProber(Latin7GreekModel),
- SingleByteCharSetProber(Win1253GreekModel),
- SingleByteCharSetProber(Latin5BulgarianModel),
- SingleByteCharSetProber(Win1251BulgarianModel),
- SingleByteCharSetProber(Latin2HungarianModel),
- SingleByteCharSetProber(Win1250HungarianModel),
- SingleByteCharSetProber(TIS620ThaiModel),
- ]
- hebrewProber = HebrewProber()
- logicalHebrewProber = SingleByteCharSetProber(Win1255HebrewModel,
- False, hebrewProber)
- visualHebrewProber = SingleByteCharSetProber(Win1255HebrewModel, True,
- hebrewProber)
- hebrewProber.set_model_probers(logicalHebrewProber, visualHebrewProber)
- self._mProbers.extend([hebrewProber, logicalHebrewProber,
- visualHebrewProber])
-
- self.reset()
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is Mozilla Universal charset detector code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 2001
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+# Shy Shalom - original C code
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+from .charsetgroupprober import CharSetGroupProber
+from .sbcharsetprober import SingleByteCharSetProber
+from .langcyrillicmodel import (Win1251CyrillicModel, Koi8rModel,
+ Latin5CyrillicModel, MacCyrillicModel,
+ Ibm866Model, Ibm855Model)
+from .langgreekmodel import Latin7GreekModel, Win1253GreekModel
+from .langbulgarianmodel import Latin5BulgarianModel, Win1251BulgarianModel
+from .langhungarianmodel import Latin2HungarianModel, Win1250HungarianModel
+from .langthaimodel import TIS620ThaiModel
+from .langhebrewmodel import Win1255HebrewModel
+from .hebrewprober import HebrewProber
+
+
+class SBCSGroupProber(CharSetGroupProber):
+ def __init__(self):
+ CharSetGroupProber.__init__(self)
+ self._mProbers = [
+ SingleByteCharSetProber(Win1251CyrillicModel),
+ SingleByteCharSetProber(Koi8rModel),
+ SingleByteCharSetProber(Latin5CyrillicModel),
+ SingleByteCharSetProber(MacCyrillicModel),
+ SingleByteCharSetProber(Ibm866Model),
+ SingleByteCharSetProber(Ibm855Model),
+ SingleByteCharSetProber(Latin7GreekModel),
+ SingleByteCharSetProber(Win1253GreekModel),
+ SingleByteCharSetProber(Latin5BulgarianModel),
+ SingleByteCharSetProber(Win1251BulgarianModel),
+ SingleByteCharSetProber(Latin2HungarianModel),
+ SingleByteCharSetProber(Win1250HungarianModel),
+ SingleByteCharSetProber(TIS620ThaiModel),
+ ]
+ hebrewProber = HebrewProber()
+ logicalHebrewProber = SingleByteCharSetProber(Win1255HebrewModel,
+ False, hebrewProber)
+ visualHebrewProber = SingleByteCharSetProber(Win1255HebrewModel, True,
+ hebrewProber)
+ hebrewProber.set_model_probers(logicalHebrewProber, visualHebrewProber)
+ self._mProbers.extend([hebrewProber, logicalHebrewProber,
+ visualHebrewProber])
+
+ self.reset()
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/sjisprober.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/sjisprober.py
similarity index 97%
rename from app/src/processing/app/i18n/python/requests/packages/charade/sjisprober.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/sjisprober.py
index 9bb0cdcf1fd..b173614e682 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/sjisprober.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/sjisprober.py
@@ -1,91 +1,91 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is mozilla.org code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-import sys
-from .mbcharsetprober import MultiByteCharSetProber
-from .codingstatemachine import CodingStateMachine
-from .chardistribution import SJISDistributionAnalysis
-from .jpcntx import SJISContextAnalysis
-from .mbcssm import SJISSMModel
-from . import constants
-
-
-class SJISProber(MultiByteCharSetProber):
- def __init__(self):
- MultiByteCharSetProber.__init__(self)
- self._mCodingSM = CodingStateMachine(SJISSMModel)
- self._mDistributionAnalyzer = SJISDistributionAnalysis()
- self._mContextAnalyzer = SJISContextAnalysis()
- self.reset()
-
- def reset(self):
- MultiByteCharSetProber.reset(self)
- self._mContextAnalyzer.reset()
-
- def get_charset_name(self):
- return "SHIFT_JIS"
-
- def feed(self, aBuf):
- aLen = len(aBuf)
- for i in range(0, aLen):
- codingState = self._mCodingSM.next_state(aBuf[i])
- if codingState == constants.eError:
- if constants._debug:
- sys.stderr.write(self.get_charset_name()
- + ' prober hit error at byte ' + str(i)
- + '\n')
- self._mState = constants.eNotMe
- break
- elif codingState == constants.eItsMe:
- self._mState = constants.eFoundIt
- break
- elif codingState == constants.eStart:
- charLen = self._mCodingSM.get_current_charlen()
- if i == 0:
- self._mLastChar[1] = aBuf[0]
- self._mContextAnalyzer.feed(self._mLastChar[2 - charLen:],
- charLen)
- self._mDistributionAnalyzer.feed(self._mLastChar, charLen)
- else:
- self._mContextAnalyzer.feed(aBuf[i + 1 - charLen:i + 3
- - charLen], charLen)
- self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1],
- charLen)
-
- self._mLastChar[0] = aBuf[aLen - 1]
-
- if self.get_state() == constants.eDetecting:
- if (self._mContextAnalyzer.got_enough_data() and
- (self.get_confidence() > constants.SHORTCUT_THRESHOLD)):
- self._mState = constants.eFoundIt
-
- return self.get_state()
-
- def get_confidence(self):
- contxtCf = self._mContextAnalyzer.get_confidence()
- distribCf = self._mDistributionAnalyzer.get_confidence()
- return max(contxtCf, distribCf)
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+import sys
+from .mbcharsetprober import MultiByteCharSetProber
+from .codingstatemachine import CodingStateMachine
+from .chardistribution import SJISDistributionAnalysis
+from .jpcntx import SJISContextAnalysis
+from .mbcssm import SJISSMModel
+from . import constants
+
+
+class SJISProber(MultiByteCharSetProber):
+ def __init__(self):
+ MultiByteCharSetProber.__init__(self)
+ self._mCodingSM = CodingStateMachine(SJISSMModel)
+ self._mDistributionAnalyzer = SJISDistributionAnalysis()
+ self._mContextAnalyzer = SJISContextAnalysis()
+ self.reset()
+
+ def reset(self):
+ MultiByteCharSetProber.reset(self)
+ self._mContextAnalyzer.reset()
+
+ def get_charset_name(self):
+ return "SHIFT_JIS"
+
+ def feed(self, aBuf):
+ aLen = len(aBuf)
+ for i in range(0, aLen):
+ codingState = self._mCodingSM.next_state(aBuf[i])
+ if codingState == constants.eError:
+ if constants._debug:
+ sys.stderr.write(self.get_charset_name()
+ + ' prober hit error at byte ' + str(i)
+ + '\n')
+ self._mState = constants.eNotMe
+ break
+ elif codingState == constants.eItsMe:
+ self._mState = constants.eFoundIt
+ break
+ elif codingState == constants.eStart:
+ charLen = self._mCodingSM.get_current_charlen()
+ if i == 0:
+ self._mLastChar[1] = aBuf[0]
+ self._mContextAnalyzer.feed(self._mLastChar[2 - charLen:],
+ charLen)
+ self._mDistributionAnalyzer.feed(self._mLastChar, charLen)
+ else:
+ self._mContextAnalyzer.feed(aBuf[i + 1 - charLen:i + 3
+ - charLen], charLen)
+ self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1],
+ charLen)
+
+ self._mLastChar[0] = aBuf[aLen - 1]
+
+ if self.get_state() == constants.eDetecting:
+ if (self._mContextAnalyzer.got_enough_data() and
+ (self.get_confidence() > constants.SHORTCUT_THRESHOLD)):
+ self._mState = constants.eFoundIt
+
+ return self.get_state()
+
+ def get_confidence(self):
+ contxtCf = self._mContextAnalyzer.get_confidence()
+ distribCf = self._mDistributionAnalyzer.get_confidence()
+ return max(contxtCf, distribCf)
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/universaldetector.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/universaldetector.py
similarity index 97%
rename from app/src/processing/app/i18n/python/requests/packages/charade/universaldetector.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/universaldetector.py
index adaae720704..3d5336b0324 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/universaldetector.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/universaldetector.py
@@ -1,171 +1,171 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is Mozilla Universal charset detector code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 2001
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-# Shy Shalom - original C code
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-from . import constants
-import sys
-from .latin1prober import Latin1Prober # windows-1252
-from .mbcsgroupprober import MBCSGroupProber # multi-byte character sets
-from .sbcsgroupprober import SBCSGroupProber # single-byte character sets
-from .escprober import EscCharSetProber # ISO-2122, etc.
-import re
-
-MINIMUM_THRESHOLD = 0.20
-ePureAscii = 0
-eEscAscii = 1
-eHighbyte = 2
-
-
-class UniversalDetector:
- def __init__(self):
- self._highBitDetector = re.compile(b'[\x80-\xFF]')
- self._escDetector = re.compile(b'(\033|~{)')
- self._mEscCharSetProber = None
- self._mCharSetProbers = []
- self.reset()
-
- def reset(self):
- self.result = {'encoding': None, 'confidence': 0.0}
- self.done = False
- self._mStart = True
- self._mGotData = False
- self._mInputState = ePureAscii
- self._mLastChar = b''
- if self._mEscCharSetProber:
- self._mEscCharSetProber.reset()
- for prober in self._mCharSetProbers:
- prober.reset()
-
- def feed(self, aBuf):
- if self.done:
- return
-
- aLen = len(aBuf)
- if not aLen:
- return
-
- if not self._mGotData:
- # If the data starts with BOM, we know it is UTF
- if aBuf[:3] == '\xEF\xBB\xBF':
- # EF BB BF UTF-8 with BOM
- self.result = {'encoding': "UTF-8", 'confidence': 1.0}
- elif aBuf[:4] == '\xFF\xFE\x00\x00':
- # FF FE 00 00 UTF-32, little-endian BOM
- self.result = {'encoding': "UTF-32LE", 'confidence': 1.0}
- elif aBuf[:4] == '\x00\x00\xFE\xFF':
- # 00 00 FE FF UTF-32, big-endian BOM
- self.result = {'encoding': "UTF-32BE", 'confidence': 1.0}
- elif aBuf[:4] == '\xFE\xFF\x00\x00':
- # FE FF 00 00 UCS-4, unusual octet order BOM (3412)
- self.result = {
- 'encoding': "X-ISO-10646-UCS-4-3412",
- 'confidence': 1.0
- }
- elif aBuf[:4] == '\x00\x00\xFF\xFE':
- # 00 00 FF FE UCS-4, unusual octet order BOM (2143)
- self.result = {
- 'encoding': "X-ISO-10646-UCS-4-2143",
- 'confidence': 1.0
- }
- elif aBuf[:2] == '\xFF\xFE':
- # FF FE UTF-16, little endian BOM
- self.result = {'encoding': "UTF-16LE", 'confidence': 1.0}
- elif aBuf[:2] == '\xFE\xFF':
- # FE FF UTF-16, big endian BOM
- self.result = {'encoding': "UTF-16BE", 'confidence': 1.0}
-
- self._mGotData = True
- if self.result['encoding'] and (self.result['confidence'] > 0.0):
- self.done = True
- return
-
- if self._mInputState == ePureAscii:
- if self._highBitDetector.search(aBuf):
- self._mInputState = eHighbyte
- elif ((self._mInputState == ePureAscii) and
- self._escDetector.search(self._mLastChar + aBuf)):
- self._mInputState = eEscAscii
-
- self._mLastChar = aBuf[-1:]
-
- if self._mInputState == eEscAscii:
- if not self._mEscCharSetProber:
- self._mEscCharSetProber = EscCharSetProber()
- if self._mEscCharSetProber.feed(aBuf) == constants.eFoundIt:
- self.result = {
- 'encoding': self._mEscCharSetProber.get_charset_name(),
- 'confidence': self._mEscCharSetProber.get_confidence()
- }
- self.done = True
- elif self._mInputState == eHighbyte:
- if not self._mCharSetProbers:
- self._mCharSetProbers = [MBCSGroupProber(), SBCSGroupProber(),
- Latin1Prober()]
- for prober in self._mCharSetProbers:
- if prober.feed(aBuf) == constants.eFoundIt:
- self.result = {'encoding': prober.get_charset_name(),
- 'confidence': prober.get_confidence()}
- self.done = True
- break
-
- def close(self):
- if self.done:
- return
- if not self._mGotData:
- if constants._debug:
- sys.stderr.write('no data received!\n')
- return
- self.done = True
-
- if self._mInputState == ePureAscii:
- self.result = {'encoding': 'ascii', 'confidence': 1.0}
- return self.result
-
- if self._mInputState == eHighbyte:
- proberConfidence = None
- maxProberConfidence = 0.0
- maxProber = None
- for prober in self._mCharSetProbers:
- if not prober:
- continue
- proberConfidence = prober.get_confidence()
- if proberConfidence > maxProberConfidence:
- maxProberConfidence = proberConfidence
- maxProber = prober
- if maxProber and (maxProberConfidence > MINIMUM_THRESHOLD):
- self.result = {'encoding': maxProber.get_charset_name(),
- 'confidence': maxProber.get_confidence()}
- return self.result
-
- if constants._debug:
- sys.stderr.write('no probers hit minimum threshhold\n')
- for prober in self._mCharSetProbers[0].mProbers:
- if not prober:
- continue
- sys.stderr.write('%s confidence = %s\n' %
- (prober.get_charset_name(),
- prober.get_confidence()))
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is Mozilla Universal charset detector code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 2001
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+# Shy Shalom - original C code
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+from . import constants
+import sys
+from .latin1prober import Latin1Prober # windows-1252
+from .mbcsgroupprober import MBCSGroupProber # multi-byte character sets
+from .sbcsgroupprober import SBCSGroupProber # single-byte character sets
+from .escprober import EscCharSetProber # ISO-2122, etc.
+import re
+
+MINIMUM_THRESHOLD = 0.20
+ePureAscii = 0
+eEscAscii = 1
+eHighbyte = 2
+
+
+class UniversalDetector:
+ def __init__(self):
+ self._highBitDetector = re.compile(b'[\x80-\xFF]')
+ self._escDetector = re.compile(b'(\033|~{)')
+ self._mEscCharSetProber = None
+ self._mCharSetProbers = []
+ self.reset()
+
+ def reset(self):
+ self.result = {'encoding': None, 'confidence': 0.0}
+ self.done = False
+ self._mStart = True
+ self._mGotData = False
+ self._mInputState = ePureAscii
+ self._mLastChar = b''
+ if self._mEscCharSetProber:
+ self._mEscCharSetProber.reset()
+ for prober in self._mCharSetProbers:
+ prober.reset()
+
+ def feed(self, aBuf):
+ if self.done:
+ return
+
+ aLen = len(aBuf)
+ if not aLen:
+ return
+
+ if not self._mGotData:
+ # If the data starts with BOM, we know it is UTF
+ if aBuf[:3] == '\xEF\xBB\xBF':
+ # EF BB BF UTF-8 with BOM
+ self.result = {'encoding': "UTF-8", 'confidence': 1.0}
+ elif aBuf[:4] == '\xFF\xFE\x00\x00':
+ # FF FE 00 00 UTF-32, little-endian BOM
+ self.result = {'encoding': "UTF-32LE", 'confidence': 1.0}
+ elif aBuf[:4] == '\x00\x00\xFE\xFF':
+ # 00 00 FE FF UTF-32, big-endian BOM
+ self.result = {'encoding': "UTF-32BE", 'confidence': 1.0}
+ elif aBuf[:4] == '\xFE\xFF\x00\x00':
+ # FE FF 00 00 UCS-4, unusual octet order BOM (3412)
+ self.result = {
+ 'encoding': "X-ISO-10646-UCS-4-3412",
+ 'confidence': 1.0
+ }
+ elif aBuf[:4] == '\x00\x00\xFF\xFE':
+ # 00 00 FF FE UCS-4, unusual octet order BOM (2143)
+ self.result = {
+ 'encoding': "X-ISO-10646-UCS-4-2143",
+ 'confidence': 1.0
+ }
+ elif aBuf[:2] == '\xFF\xFE':
+ # FF FE UTF-16, little endian BOM
+ self.result = {'encoding': "UTF-16LE", 'confidence': 1.0}
+ elif aBuf[:2] == '\xFE\xFF':
+ # FE FF UTF-16, big endian BOM
+ self.result = {'encoding': "UTF-16BE", 'confidence': 1.0}
+
+ self._mGotData = True
+ if self.result['encoding'] and (self.result['confidence'] > 0.0):
+ self.done = True
+ return
+
+ if self._mInputState == ePureAscii:
+ if self._highBitDetector.search(aBuf):
+ self._mInputState = eHighbyte
+ elif ((self._mInputState == ePureAscii) and
+ self._escDetector.search(self._mLastChar + aBuf)):
+ self._mInputState = eEscAscii
+
+ self._mLastChar = aBuf[-1:]
+
+ if self._mInputState == eEscAscii:
+ if not self._mEscCharSetProber:
+ self._mEscCharSetProber = EscCharSetProber()
+ if self._mEscCharSetProber.feed(aBuf) == constants.eFoundIt:
+ self.result = {
+ 'encoding': self._mEscCharSetProber.get_charset_name(),
+ 'confidence': self._mEscCharSetProber.get_confidence()
+ }
+ self.done = True
+ elif self._mInputState == eHighbyte:
+ if not self._mCharSetProbers:
+ self._mCharSetProbers = [MBCSGroupProber(), SBCSGroupProber(),
+ Latin1Prober()]
+ for prober in self._mCharSetProbers:
+ if prober.feed(aBuf) == constants.eFoundIt:
+ self.result = {'encoding': prober.get_charset_name(),
+ 'confidence': prober.get_confidence()}
+ self.done = True
+ break
+
+ def close(self):
+ if self.done:
+ return
+ if not self._mGotData:
+ if constants._debug:
+ sys.stderr.write('no data received!\n')
+ return
+ self.done = True
+
+ if self._mInputState == ePureAscii:
+ self.result = {'encoding': 'ascii', 'confidence': 1.0}
+ return self.result
+
+ if self._mInputState == eHighbyte:
+ proberConfidence = None
+ maxProberConfidence = 0.0
+ maxProber = None
+ for prober in self._mCharSetProbers:
+ if not prober:
+ continue
+ proberConfidence = prober.get_confidence()
+ if proberConfidence > maxProberConfidence:
+ maxProberConfidence = proberConfidence
+ maxProber = prober
+ if maxProber and (maxProberConfidence > MINIMUM_THRESHOLD):
+ self.result = {'encoding': maxProber.get_charset_name(),
+ 'confidence': maxProber.get_confidence()}
+ return self.result
+
+ if constants._debug:
+ sys.stderr.write('no probers hit minimum threshhold\n')
+ for prober in self._mCharSetProbers[0].mProbers:
+ if not prober:
+ continue
+ sys.stderr.write('%s confidence = %s\n' %
+ (prober.get_charset_name(),
+ prober.get_confidence()))
diff --git a/app/src/processing/app/i18n/python/requests/packages/charade/utf8prober.py b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/utf8prober.py
similarity index 97%
rename from app/src/processing/app/i18n/python/requests/packages/charade/utf8prober.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/charade/utf8prober.py
index 72c8d3d6a9b..1c0bb5d8fda 100644
--- a/app/src/processing/app/i18n/python/requests/packages/charade/utf8prober.py
+++ b/arduino-core/src/processing/app/i18n/python/requests/packages/charade/utf8prober.py
@@ -1,76 +1,76 @@
-######################## BEGIN LICENSE BLOCK ########################
-# The Original Code is mozilla.org code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mark Pilgrim - port to Python
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA
-######################### END LICENSE BLOCK #########################
-
-from . import constants
-from .charsetprober import CharSetProber
-from .codingstatemachine import CodingStateMachine
-from .mbcssm import UTF8SMModel
-
-ONE_CHAR_PROB = 0.5
-
-
-class UTF8Prober(CharSetProber):
- def __init__(self):
- CharSetProber.__init__(self)
- self._mCodingSM = CodingStateMachine(UTF8SMModel)
- self.reset()
-
- def reset(self):
- CharSetProber.reset(self)
- self._mCodingSM.reset()
- self._mNumOfMBChar = 0
-
- def get_charset_name(self):
- return "utf-8"
-
- def feed(self, aBuf):
- for c in aBuf:
- codingState = self._mCodingSM.next_state(c)
- if codingState == constants.eError:
- self._mState = constants.eNotMe
- break
- elif codingState == constants.eItsMe:
- self._mState = constants.eFoundIt
- break
- elif codingState == constants.eStart:
- if self._mCodingSM.get_current_charlen() >= 2:
- self._mNumOfMBChar += 1
-
- if self.get_state() == constants.eDetecting:
- if self.get_confidence() > constants.SHORTCUT_THRESHOLD:
- self._mState = constants.eFoundIt
-
- return self.get_state()
-
- def get_confidence(self):
- unlike = 0.99
- if self._mNumOfMBChar < 6:
- for i in range(0, self._mNumOfMBChar):
- unlike = unlike * ONE_CHAR_PROB
- return 1.0 - unlike
- else:
- return unlike
+######################## BEGIN LICENSE BLOCK ########################
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Mark Pilgrim - port to Python
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+######################### END LICENSE BLOCK #########################
+
+from . import constants
+from .charsetprober import CharSetProber
+from .codingstatemachine import CodingStateMachine
+from .mbcssm import UTF8SMModel
+
+ONE_CHAR_PROB = 0.5
+
+
+class UTF8Prober(CharSetProber):
+ def __init__(self):
+ CharSetProber.__init__(self)
+ self._mCodingSM = CodingStateMachine(UTF8SMModel)
+ self.reset()
+
+ def reset(self):
+ CharSetProber.reset(self)
+ self._mCodingSM.reset()
+ self._mNumOfMBChar = 0
+
+ def get_charset_name(self):
+ return "utf-8"
+
+ def feed(self, aBuf):
+ for c in aBuf:
+ codingState = self._mCodingSM.next_state(c)
+ if codingState == constants.eError:
+ self._mState = constants.eNotMe
+ break
+ elif codingState == constants.eItsMe:
+ self._mState = constants.eFoundIt
+ break
+ elif codingState == constants.eStart:
+ if self._mCodingSM.get_current_charlen() >= 2:
+ self._mNumOfMBChar += 1
+
+ if self.get_state() == constants.eDetecting:
+ if self.get_confidence() > constants.SHORTCUT_THRESHOLD:
+ self._mState = constants.eFoundIt
+
+ return self.get_state()
+
+ def get_confidence(self):
+ unlike = 0.99
+ if self._mNumOfMBChar < 6:
+ for i in range(0, self._mNumOfMBChar):
+ unlike = unlike * ONE_CHAR_PROB
+ return 1.0 - unlike
+ else:
+ return unlike
diff --git a/app/src/processing/app/i18n/python/requests/packages/urllib3/__init__.py b/arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/__init__.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/packages/urllib3/__init__.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/__init__.py
diff --git a/app/src/processing/app/i18n/python/requests/packages/urllib3/_collections.py b/arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/_collections.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/packages/urllib3/_collections.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/_collections.py
diff --git a/app/src/processing/app/i18n/python/requests/packages/urllib3/connectionpool.py b/arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/connectionpool.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/packages/urllib3/connectionpool.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/connectionpool.py
diff --git a/app/src/processing/app/i18n/python/requests/packages/urllib3/contrib/__init__.py b/arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/contrib/__init__.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/packages/urllib3/contrib/__init__.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/contrib/__init__.py
diff --git a/app/src/processing/app/i18n/python/requests/packages/urllib3/contrib/ntlmpool.py b/arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/contrib/ntlmpool.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/packages/urllib3/contrib/ntlmpool.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/contrib/ntlmpool.py
diff --git a/app/src/processing/app/i18n/python/requests/packages/urllib3/exceptions.py b/arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/exceptions.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/packages/urllib3/exceptions.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/exceptions.py
diff --git a/app/src/processing/app/i18n/python/requests/packages/urllib3/filepost.py b/arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/filepost.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/packages/urllib3/filepost.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/filepost.py
diff --git a/app/src/processing/app/i18n/python/requests/packages/urllib3/packages/__init__.py b/arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/packages/__init__.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/packages/urllib3/packages/__init__.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/packages/__init__.py
diff --git a/app/src/processing/app/i18n/python/requests/packages/urllib3/packages/ordered_dict.py b/arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/packages/ordered_dict.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/packages/urllib3/packages/ordered_dict.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/packages/ordered_dict.py
diff --git a/app/src/processing/app/i18n/python/requests/packages/urllib3/packages/six.py b/arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/packages/six.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/packages/urllib3/packages/six.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/packages/six.py
diff --git a/app/src/processing/app/i18n/python/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py b/arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py
diff --git a/app/src/processing/app/i18n/python/requests/packages/urllib3/poolmanager.py b/arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/poolmanager.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/packages/urllib3/poolmanager.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/poolmanager.py
diff --git a/app/src/processing/app/i18n/python/requests/packages/urllib3/request.py b/arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/request.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/packages/urllib3/request.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/request.py
diff --git a/app/src/processing/app/i18n/python/requests/packages/urllib3/response.py b/arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/response.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/packages/urllib3/response.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/response.py
diff --git a/app/src/processing/app/i18n/python/requests/packages/urllib3/util.py b/arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/util.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/packages/urllib3/util.py
rename to arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/util.py
diff --git a/app/src/processing/app/i18n/python/requests/sessions.py b/arduino-core/src/processing/app/i18n/python/requests/sessions.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/sessions.py
rename to arduino-core/src/processing/app/i18n/python/requests/sessions.py
diff --git a/app/src/processing/app/i18n/python/requests/status_codes.py b/arduino-core/src/processing/app/i18n/python/requests/status_codes.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/status_codes.py
rename to arduino-core/src/processing/app/i18n/python/requests/status_codes.py
diff --git a/app/src/processing/app/i18n/python/requests/structures.py b/arduino-core/src/processing/app/i18n/python/requests/structures.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/structures.py
rename to arduino-core/src/processing/app/i18n/python/requests/structures.py
diff --git a/app/src/processing/app/i18n/python/requests/utils.py b/arduino-core/src/processing/app/i18n/python/requests/utils.py
similarity index 100%
rename from app/src/processing/app/i18n/python/requests/utils.py
rename to arduino-core/src/processing/app/i18n/python/requests/utils.py
diff --git a/app/src/processing/app/i18n/python/transifex.py b/arduino-core/src/processing/app/i18n/python/transifex.py
similarity index 100%
rename from app/src/processing/app/i18n/python/transifex.py
rename to arduino-core/src/processing/app/i18n/python/transifex.py
diff --git a/app/src/processing/app/i18n/python/update.py b/arduino-core/src/processing/app/i18n/python/update.py
similarity index 100%
rename from app/src/processing/app/i18n/python/update.py
rename to arduino-core/src/processing/app/i18n/python/update.py
diff --git a/app/src/processing/app/i18n/update.sh b/arduino-core/src/processing/app/i18n/update.sh
similarity index 100%
rename from app/src/processing/app/i18n/update.sh
rename to arduino-core/src/processing/app/i18n/update.sh
diff --git a/arduino-core/src/processing/app/legacy/PApplet.java b/arduino-core/src/processing/app/legacy/PApplet.java
new file mode 100644
index 00000000000..c444a3b2f5f
--- /dev/null
+++ b/arduino-core/src/processing/app/legacy/PApplet.java
@@ -0,0 +1,729 @@
+package processing.app.legacy;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+public class PApplet {
+
+ /** Path to sketch folder */
+ public String sketchPath; //folder;
+
+ /**
+ * Full name of the Java version (i.e. 1.5.0_11).
+ * Prior to 0125, this was only the first three digits.
+ */
+ public static final String javaVersionName =
+ System.getProperty("java.version");
+
+ /**
+ * Version of Java that's in use, whether 1.1 or 1.3 or whatever,
+ * stored as a float.
+ *
+ * Note that because this is stored as a float, the values may
+ * not be exactly 1.3 or 1.4. Instead, make sure you're
+ * comparing against 1.3f or 1.4f, which will have the same amount
+ * of error (i.e. 1.40000001). This could just be a double, but
+ * since Processing only uses floats, it's safer for this to be a float
+ * because there's no good way to specify a double with the preproc.
+ */
+ public static final float javaVersion =
+ new Float(javaVersionName.substring(0, 3)).floatValue();
+
+ /**
+ * Current platform in use, one of the
+ * PConstants WINDOWS, MACOSX, MACOS9, LINUX or OTHER.
+ */
+ static public int platform;
+
+ /**
+ * Name associated with the current 'platform' (see PConstants.platformNames)
+ */
+ //static public String platformName;
+
+ static {
+ String osname = System.getProperty("os.name");
+
+ if (osname.indexOf("Mac") != -1) {
+ platform = PConstants.MACOSX;
+
+ } else if (osname.indexOf("Windows") != -1) {
+ platform = PConstants.WINDOWS;
+
+ } else if (osname.equals("Linux")) { // true for the ibm vm
+ platform = PConstants.LINUX;
+
+ } else {
+ platform = PConstants.OTHER;
+ }
+ }
+
+ /**
+ * GIF image of the Processing logo.
+ */
+ static public final byte[] ICON_IMAGE = {
+ 71, 73, 70, 56, 57, 97, 16, 0, 16, 0, -60, 0, 0, 0, 0, 0,
+ 0, 0, -127, 0, -127, 0, 0, -127, -127, -127, 0, 0, -127, 0, -127, -127,
+ -127, 0, -127, -127, -127, -63, -63, -63, 0, 0, -1, 0, -1, 0, 0, -1,
+ -1, -1, 0, 0, -1, 0, -1, -1, -1, 0, -1, -1, -1, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, -7, 4,
+ 9, 0, 0, 16, 0, 44, 0, 0, 0, 0, 16, 0, 16, 0, 0, 5,
+ 75, 32, 36, -118, -57, 96, 14, -57, -88, 66, -27, -23, -90, -86, 43, -97,
+ 99, 59, -65, -30, 125, -77, 3, -14, -4, 8, -109, 15, -120, -22, 61, 78,
+ 15, -124, 15, 25, 28, 28, 93, 63, -45, 115, -22, -116, 90, -83, 82, 89,
+ -44, -103, 61, 44, -91, -54, -89, 19, -111, 50, 18, -51, -55, 1, 73, -121,
+ -53, -79, 77, 43, -101, 12, -74, -30, -99, -24, -94, 16, 0, 59,
+ };
+
+ /**
+ * Split the provided String at wherever whitespace occurs. Multiple
+ * whitespace (extra spaces or tabs or whatever) between items will count as a
+ * single break.
+ *
+ * The whitespace characters are "\t\n\r\f", which are the defaults for
+ * java.util.StringTokenizer, plus the unicode non-breaking space character,
+ * which is found commonly on files created by or used in conjunction with Mac
+ * OS X (character 160, or 0x00A0 in hex).
+ *
+ *
+ * i.e. splitTokens("a b") -> { "a", "b" }
+ * splitTokens("a b") -> { "a", "b" }
+ * splitTokens("a\tb") -> { "a", "b" }
+ * splitTokens("a \t b ") -> { "a", "b" }
+ *
+ */
+ static public String[] splitTokens(String what) {
+ return splitTokens(what, PConstants.WHITESPACE);
+ }
+
+ /**
+ * Splits a string into pieces, using any of the chars in the String 'delim'
+ * as separator characters. For instance, in addition to white space, you
+ * might want to treat commas as a separator. The delimeter characters won't
+ * appear in the returned String array.
+ *
+ *
+ * i.e. splitTokens("a, b", " ,") -> { "a", "b" }
+ *
+ *
+ * To include all the whitespace possibilities, use the variable WHITESPACE,
+ * found in PConstants:
+ *
+ *
+ * i.e. splitTokens("a | b", WHITESPACE + "|"); -> { "a", "b" }
+ *
+ */
+ static public String[] splitTokens(String what, String delim) {
+ StringTokenizer toker = new StringTokenizer(what, delim);
+ String pieces[] = new String[toker.countTokens()];
+
+ int index = 0;
+ while (toker.hasMoreTokens()) {
+ pieces[index++] = toker.nextToken();
+ }
+ return pieces;
+ }
+
+ /**
+ * Split a string into pieces along a specific character. Most commonly used
+ * to break up a String along a space or a tab character.
+ *
+ * This operates differently than the others, where the single delimeter is
+ * the only breaking point, and consecutive delimeters will produce an empty
+ * string (""). This way, one can split on tab characters, but maintain the
+ * column alignments (of say an excel file) where there are empty columns.
+ */
+ static public String[] split(String what, char delim) {
+ // do this so that the exception occurs inside the user's
+ // program, rather than appearing to be a bug inside split()
+ if (what == null)
+ return null;
+
+ char chars[] = what.toCharArray();
+ int splitCount = 0; // 1;
+ for (int i = 0; i < chars.length; i++) {
+ if (chars[i] == delim)
+ splitCount++;
+ }
+ if (splitCount == 0) {
+ String splits[] = new String[1];
+ splits[0] = new String(what);
+ return splits;
+ }
+ String splits[] = new String[splitCount + 1];
+ int splitIndex = 0;
+ int startIndex = 0;
+ for (int i = 0; i < chars.length; i++) {
+ if (chars[i] == delim) {
+ splits[splitIndex++] = new String(chars, startIndex, i - startIndex);
+ startIndex = i + 1;
+ }
+ }
+ splits[splitIndex] = new String(chars, startIndex, chars.length
+ - startIndex);
+ return splits;
+ }
+
+ static public String[] subset(String list[], int start, int count) {
+ String output[] = new String[count];
+ System.arraycopy(list, start, output, 0, count);
+ return output;
+ }
+
+
+ /**
+ * Join an array of Strings together as a single String,
+ * separated by the whatever's passed in for the separator.
+ */
+ static public String join(String str[], char separator) {
+ return join(str, String.valueOf(separator));
+ }
+
+
+ /**
+ * Join an array of Strings together as a single String,
+ * separated by the whatever's passed in for the separator.
+ *
+ * To use this on numbers, first pass the array to nf() or nfs()
+ * to get a list of String objects, then use join on that.
+ *
+ * e.g. String stuff[] = { "apple", "bear", "cat" };
+ * String list = join(stuff, ", ");
+ * // list is now "apple, bear, cat"
+ */
+ static public String join(String str[], String separator) {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < str.length; i++) {
+ if (i != 0) buffer.append(separator);
+ buffer.append(str[i]);
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * Parse a String into an int value. Returns 0 if the value is bad.
+ */
+ static final public int parseInt(String what) {
+ return parseInt(what, 0);
+ }
+
+ /**
+ * Parse a String to an int, and provide an alternate value that
+ * should be used when the number is invalid.
+ */
+ static final public int parseInt(String what, int otherwise) {
+ try {
+ int offset = what.indexOf('.');
+ if (offset == -1) {
+ return Integer.parseInt(what);
+ } else {
+ return Integer.parseInt(what.substring(0, offset));
+ }
+ } catch (NumberFormatException e) { }
+ return otherwise;
+ }
+
+ /**
+ * Make an array of int elements from an array of String objects.
+ * If the String can't be parsed as a number, it will be set to zero.
+ *
+ * String s[] = { "1", "300", "44" };
+ * int numbers[] = parseInt(s);
+ *
+ * numbers will contain { 1, 300, 44 }
+ */
+ static public int[] parseInt(String what[]) {
+ return parseInt(what, 0);
+ }
+
+ /**
+ * Make an array of int elements from an array of String objects.
+ * If the String can't be parsed as a number, its entry in the
+ * array will be set to the value of the "missing" parameter.
+ *
+ * String s[] = { "1", "300", "apple", "44" };
+ * int numbers[] = parseInt(s, 9999);
+ *
+ * numbers will contain { 1, 300, 9999, 44 }
+ */
+ static public int[] parseInt(String what[], int missing) {
+ int output[] = new int[what.length];
+ for (int i = 0; i < what.length; i++) {
+ try {
+ output[i] = Integer.parseInt(what[i]);
+ } catch (NumberFormatException e) {
+ output[i] = missing;
+ }
+ }
+ return output;
+ }
+
+ static public String[] loadStrings(File file) {
+ InputStream is = createInput(file);
+ if (is != null) return loadStrings(is);
+ return null;
+ }
+
+ static public String[] loadStrings(InputStream input) {
+ try {
+ BufferedReader reader =
+ new BufferedReader(new InputStreamReader(input, "UTF-8"));
+
+ String lines[] = new String[100];
+ int lineCount = 0;
+ String line = null;
+ while ((line = reader.readLine()) != null) {
+ if (lineCount == lines.length) {
+ String temp[] = new String[lineCount << 1];
+ System.arraycopy(lines, 0, temp, 0, lineCount);
+ lines = temp;
+ }
+ lines[lineCount++] = line;
+ }
+ reader.close();
+
+ if (lineCount == lines.length) {
+ return lines;
+ }
+
+ // resize array to appropriate amount for these lines
+ String output[] = new String[lineCount];
+ System.arraycopy(lines, 0, output, 0, lineCount);
+ return output;
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ //throw new RuntimeException("Error inside loadStrings()");
+ }
+ return null;
+ }
+
+ public void saveStrings(String filename, String strings[]) {
+ saveStrings(saveFile(filename), strings);
+ }
+
+
+ static public void saveStrings(File file, String strings[]) {
+ saveStrings(createOutput(file), strings);
+ }
+
+
+ static public void saveStrings(OutputStream output, String strings[]) {
+ PrintWriter writer = createWriter(output);
+ for (int i = 0; i < strings.length; i++) {
+ writer.println(strings[i]);
+ }
+ writer.flush();
+ writer.close();
+ }
+
+
+ static public int[] expand(int list[]) {
+ return expand(list, list.length << 1);
+ }
+
+ static public int[] expand(int list[], int newSize) {
+ int temp[] = new int[newSize];
+ System.arraycopy(list, 0, temp, 0, Math.min(newSize, list.length));
+ return temp;
+ }
+
+ static final public String hex(int what, int digits) {
+ String stuff = Integer.toHexString(what).toUpperCase();
+
+ int length = stuff.length();
+ if (length > digits) {
+ return stuff.substring(length - digits);
+
+ } else if (length < digits) {
+ return "00000000".substring(8 - (digits-length)) + stuff;
+ }
+ return stuff;
+ }
+
+ static public final int constrain(int amt, int low, int high) {
+ return (amt < low) ? low : ((amt > high) ? high : amt);
+ }
+
+ static public final float constrain(float amt, float low, float high) {
+ return (amt < low) ? low : ((amt > high) ? high : amt);
+ }
+
+ /**
+ * Attempts to open an application or file using your platform's launcher. The file parameter is a String specifying the file name and location. The location parameter must be a full path name, or the name of an executable in the system's PATH. In most cases, using a full path is the best option, rather than relying on the system PATH. Be sure to make the file executable before attempting to open it (chmod +x).
+ *
+ * The args parameter is a String or String array which is passed to the command line. If you have multiple parameters, e.g. an application and a document, or a command with multiple switches, use the version that takes a String array, and place each individual item in a separate element.
+ *
+ * If args is a String (not an array), then it can only be a single file or application with no parameters. It's not the same as executing that String using a shell. For instance, open("jikes -help") will not work properly.
+ *
+ * This function behaves differently on each platform. On Windows, the parameters are sent to the Windows shell via "cmd /c". On Mac OS X, the "open" command is used (type "man open" in Terminal.app for documentation). On Linux, it first tries gnome-open, then kde-open, but if neither are available, it sends the command to the shell without any alterations.
+ *
+ * For users familiar with Java, this is not quite the same as Runtime.exec(), because the launcher command is prepended. Instead, the exec(String[]) function is a shortcut for Runtime.getRuntime.exec(String[]).
+ *
+ * @webref input:files
+ * @param filename name of the file
+ * @usage Application
+ */
+ static public void open(String filename) {
+ open(new String[] { filename });
+ }
+
+ static String openLauncher;
+
+ /**
+ * Launch a process using a platforms shell. This version uses an array
+ * to make it easier to deal with spaces in the individual elements.
+ * (This avoids the situation of trying to put single or double quotes
+ * around different bits).
+ *
+ * @param list of commands passed to the command line
+ */
+ static public Process open(String argv[]) {
+ String[] params = null;
+
+ if (platform == PConstants.WINDOWS) {
+ // just launching the .html file via the shell works
+ // but make sure to chmod +x the .html files first
+ // also place quotes around it in case there's a space
+ // in the user.dir part of the url
+ params = new String[] { "cmd", "/c" };
+
+ } else if (platform == PConstants.MACOSX) {
+ params = new String[] { "open" };
+
+ } else if (platform == PConstants.LINUX) {
+ if (openLauncher == null) {
+ // Attempt to use gnome-open
+ try {
+ Process p = Runtime.getRuntime().exec(new String[] { "gnome-open" });
+ /*int result =*/ p.waitFor();
+ // Not installed will throw an IOException (JDK 1.4.2, Ubuntu 7.04)
+ openLauncher = "gnome-open";
+ } catch (Exception e) { }
+ }
+ if (openLauncher == null) {
+ // Attempt with kde-open
+ try {
+ Process p = Runtime.getRuntime().exec(new String[] { "kde-open" });
+ /*int result =*/ p.waitFor();
+ openLauncher = "kde-open";
+ } catch (Exception e) { }
+ }
+ if (openLauncher == null) {
+ System.err.println("Could not find gnome-open or kde-open, " +
+ "the open() command may not work.");
+ }
+ if (openLauncher != null) {
+ params = new String[] { openLauncher };
+ }
+ //} else { // give up and just pass it to Runtime.exec()
+ //open(new String[] { filename });
+ //params = new String[] { filename };
+ }
+ if (params != null) {
+ // If the 'open', 'gnome-open' or 'cmd' are already included
+ if (params[0].equals(argv[0])) {
+ // then don't prepend those params again
+ return exec(argv);
+ } else {
+ params = concat(params, argv);
+ return exec(params);
+ }
+ } else {
+ return exec(argv);
+ }
+ }
+
+ static public Process exec(String[] argv) {
+ try {
+ return Runtime.getRuntime().exec(argv);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException("Could not open " + join(argv, ' '));
+ }
+ }
+
+ static public String[] concat(String a[], String b[]) {
+ String c[] = new String[a.length + b.length];
+ System.arraycopy(a, 0, c, 0, a.length);
+ System.arraycopy(b, 0, c, a.length, b.length);
+ return c;
+ }
+
+ /**
+ * Identical to match(), except that it returns an array of all matches in
+ * the specified String, rather than just the first.
+ */
+ static public String[][] matchAll(String what, String regexp) {
+ Pattern p = Pattern.compile(regexp, Pattern.MULTILINE | Pattern.DOTALL);
+ Matcher m = p.matcher(what);
+ ArrayList results = new ArrayList();
+ int count = m.groupCount() + 1;
+ while (m.find()) {
+ String[] groups = new String[count];
+ for (int i = 0; i < count; i++) {
+ groups[i] = m.group(i);
+ }
+ results.add(groups);
+ }
+ if (results.isEmpty()) {
+ return null;
+ }
+ String[][] matches = new String[results.size()][count];
+ for (int i = 0; i < matches.length; i++) {
+ matches[i] = (String[]) results.get(i);
+ }
+ return matches;
+ }
+
+ /**
+ * Match a string with a regular expression, and returns the match as an
+ * array. The first index is the matching expression, and array elements
+ * [1] and higher represent each of the groups (sequences found in parens).
+ *
+ * This uses multiline matching (Pattern.MULTILINE) and dotall mode
+ * (Pattern.DOTALL) by default, so that ^ and $ match the beginning and
+ * end of any lines found in the source, and the . operator will also
+ * pick up newline characters.
+ */
+ static public String[] match(String what, String regexp) {
+ Pattern p = Pattern.compile(regexp, Pattern.MULTILINE | Pattern.DOTALL);
+ Matcher m = p.matcher(what);
+ if (m.find()) {
+ int count = m.groupCount() + 1;
+ String[] groups = new String[count];
+ for (int i = 0; i < count; i++) {
+ groups[i] = m.group(i);
+ }
+ return groups;
+ }
+ return null;
+ }
+
+ /**
+ * Integer number formatter.
+ */
+ static private NumberFormat int_nf;
+ static private int int_nf_digits;
+ static private boolean int_nf_commas;
+
+ static public String[] nf(int num[], int digits) {
+ String formatted[] = new String[num.length];
+ for (int i = 0; i < formatted.length; i++) {
+ formatted[i] = nf(num[i], digits);
+ }
+ return formatted;
+ }
+
+ static public String nf(int num, int digits) {
+ if ((int_nf != null) &&
+ (int_nf_digits == digits) &&
+ !int_nf_commas) {
+ return int_nf.format(num);
+ }
+
+ int_nf = NumberFormat.getInstance();
+ int_nf.setGroupingUsed(false); // no commas
+ int_nf_commas = false;
+ int_nf.setMinimumIntegerDigits(digits);
+ int_nf_digits = digits;
+ return int_nf.format(num);
+ }
+
+ static final public String[] str(int x[]) {
+ String s[] = new String[x.length];
+ for (int i = 0; i < x.length; i++) s[i] = String.valueOf(x[i]);
+ return s;
+ }
+
+ /**
+ * I want to print lines to a file. I have RSI from typing these
+ * eight lines of code so many times.
+ */
+ static public PrintWriter createWriter(File file) {
+ try {
+ createPath(file); // make sure in-between folders exist
+ OutputStream output = new FileOutputStream(file);
+ if (file.getName().toLowerCase().endsWith(".gz")) {
+ output = new GZIPOutputStream(output);
+ }
+ return createWriter(output);
+
+ } catch (Exception e) {
+ if (file == null) {
+ throw new RuntimeException("File passed to createWriter() was null");
+ } else {
+ e.printStackTrace();
+ throw new RuntimeException("Couldn't create a writer for " +
+ file.getAbsolutePath());
+ }
+ }
+ //return null;
+ }
+
+
+ /**
+ * I want to print lines to a file. Why am I always explaining myself?
+ * It's the JavaSoft API engineers who need to explain themselves.
+ */
+ static public PrintWriter createWriter(OutputStream output) {
+ try {
+ OutputStreamWriter osw = new OutputStreamWriter(output, "UTF-8");
+ return new PrintWriter(osw);
+ } catch (UnsupportedEncodingException e) { } // not gonna happen
+ return null;
+ }
+
+ static public InputStream createInput(File file) {
+ if (file == null) {
+ throw new IllegalArgumentException("File passed to createInput() was null");
+ }
+ try {
+ InputStream input = new FileInputStream(file);
+ if (file.getName().toLowerCase().endsWith(".gz")) {
+ return new GZIPInputStream(input);
+ }
+ return input;
+
+ } catch (IOException e) {
+ System.err.println("Could not createInput() for " + file);
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ /**
+ * Returns a path inside the applet folder to save to. Like sketchPath(),
+ * but creates any in-between folders so that things save properly.
+ *
+ * All saveXxxx() functions use the path to the sketch folder, rather than
+ * its data folder. Once exported, the data folder will be found inside the
+ * jar file of the exported application or applet. In this case, it's not
+ * possible to save data into the jar file, because it will often be running
+ * from a server, or marked in-use if running from a local file system.
+ * With this in mind, saving to the data path doesn't make sense anyway.
+ * If you know you're running locally, and want to save to the data folder,
+ * use saveXxxx("data/blah.dat").
+ */
+ public String savePath(String where) {
+ if (where == null) return null;
+ String filename = sketchPath(where);
+ createPath(filename);
+ return filename;
+ }
+
+
+ /**
+ * Identical to savePath(), but returns a File object.
+ */
+ public File saveFile(String where) {
+ return new File(savePath(where));
+ }
+
+ /**
+ * Similar to createInput() (formerly openStream), this creates a Java
+ * OutputStream for a given filename or path. The file will be created in
+ * the sketch folder, or in the same folder as an exported application.
+ *
+ * If the path does not exist, intermediate folders will be created. If an
+ * exception occurs, it will be printed to the console, and null will be
+ * returned.
+ *
+ * Future releases may also add support for handling HTTP POST via this
+ * method (for better symmetry with createInput), however that's maybe a
+ * little too clever (and then we'd have to add the same features to the
+ * other file functions like createWriter). Who you callin' bloated?
+ */
+ public OutputStream createOutput(String filename) {
+ return createOutput(saveFile(filename));
+ }
+
+
+ static public OutputStream createOutput(File file) {
+ try {
+ createPath(file); // make sure the path exists
+ FileOutputStream fos = new FileOutputStream(file);
+ if (file.getName().toLowerCase().endsWith(".gz")) {
+ return new GZIPOutputStream(fos);
+ }
+ return fos;
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ /**
+ * Prepend the sketch folder path to the filename (or path) that is
+ * passed in. External libraries should use this function to save to
+ * the sketch folder.
+ *
+ * Note that when running as an applet inside a web browser,
+ * the sketchPath will be set to null, because security restrictions
+ * prevent applets from accessing that information.
+ *
+ * This will also cause an error if the sketch is not inited properly,
+ * meaning that init() was never called on the PApplet when hosted
+ * my some other main() or by other code. For proper use of init(),
+ * see the examples in the main description text for PApplet.
+ */
+ public String sketchPath(String where) {
+ if (sketchPath == null) {
+ return where;
+// throw new RuntimeException("The applet was not inited properly, " +
+// "or security restrictions prevented " +
+// "it from determining its path.");
+ }
+ // isAbsolute() could throw an access exception, but so will writing
+ // to the local disk using the sketch path, so this is safe here.
+ // for 0120, added a try/catch anyways.
+ try {
+ if (new File(where).isAbsolute()) return where;
+ } catch (Exception e) { }
+
+ return sketchPath + File.separator + where;
+ }
+
+ /**
+ * Takes a path and creates any in-between folders if they don't
+ * already exist. Useful when trying to save to a subfolder that
+ * may not actually exist.
+ */
+ static public void createPath(String path) {
+ createPath(new File(path));
+ }
+
+
+ static public void createPath(File file) {
+ try {
+ String parent = file.getParent();
+ if (parent != null) {
+ File unit = new File(parent);
+ if (!unit.exists()) unit.mkdirs();
+ }
+ } catch (SecurityException se) {
+ System.err.println("You don't have permissions to create " +
+ file.getAbsolutePath());
+ }
+ }
+
+
+}
diff --git a/arduino-core/src/processing/app/legacy/PConstants.java b/arduino-core/src/processing/app/legacy/PConstants.java
new file mode 100644
index 00000000000..3b1d491d559
--- /dev/null
+++ b/arduino-core/src/processing/app/legacy/PConstants.java
@@ -0,0 +1,22 @@
+package processing.app.legacy;
+
+public class PConstants {
+
+ // platform IDs for PApplet.platform
+
+ public static final int OTHER = 0;
+ public static final int WINDOWS = 1;
+ public static final int MACOSX = 2;
+ public static final int LINUX = 3;
+
+ public static final String[] platformNames = {
+ "other", "windows", "macosx", "linux"
+ };
+
+
+ // used by split, all the standard whitespace chars
+ // (also includes unicode nbsp, that little bostage)
+
+ static final String WHITESPACE = " \t\n\r\f\u00A0";
+
+}
diff --git a/app/src/processing/app/linux/Platform.java b/arduino-core/src/processing/app/linux/Platform.java
similarity index 92%
rename from app/src/processing/app/linux/Platform.java
rename to arduino-core/src/processing/app/linux/Platform.java
index 7f4afefd52b..b0ea0b0c95d 100644
--- a/app/src/processing/app/linux/Platform.java
+++ b/arduino-core/src/processing/app/linux/Platform.java
@@ -24,10 +24,10 @@
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.Executor;
-import processing.app.Preferences;
+import processing.app.PreferencesData;
import processing.app.debug.TargetPackage;
import processing.app.tools.ExternalProcessExecutor;
-import processing.core.PConstants;
+import processing.app.legacy.PConstants;
import java.io.*;
import java.util.Map;
@@ -64,7 +64,7 @@ public File getDefaultSketchbookFolder() throws Exception {
public void openURL(String url) throws Exception {
if (openFolderAvailable()) {
- String launcher = Preferences.get("launcher");
+ String launcher = PreferencesData.get("launcher");
if (launcher != null) {
Runtime.getRuntime().exec(new String[] { launcher, url });
}
@@ -73,7 +73,7 @@ public void openURL(String url) throws Exception {
public boolean openFolderAvailable() {
- if (Preferences.get("launcher") != null) {
+ if (PreferencesData.get("launcher") != null) {
return true;
}
@@ -81,7 +81,7 @@ public boolean openFolderAvailable() {
try {
Process p = Runtime.getRuntime().exec(new String[] { "xdg-open" });
p.waitFor();
- Preferences.set("launcher", "xdg-open");
+ PreferencesData.set("launcher", "xdg-open");
return true;
} catch (Exception e) { }
@@ -90,7 +90,7 @@ public boolean openFolderAvailable() {
Process p = Runtime.getRuntime().exec(new String[] { "gnome-open" });
p.waitFor();
// Not installed will throw an IOException (JDK 1.4.2, Ubuntu 7.04)
- Preferences.set("launcher", "gnome-open");
+ PreferencesData.set("launcher", "gnome-open");
return true;
} catch (Exception e) { }
@@ -98,7 +98,7 @@ public boolean openFolderAvailable() {
try {
Process p = Runtime.getRuntime().exec(new String[] { "kde-open" });
p.waitFor();
- Preferences.set("launcher", "kde-open");
+ PreferencesData.set("launcher", "kde-open");
return true;
} catch (Exception e) { }
@@ -108,7 +108,7 @@ public boolean openFolderAvailable() {
public void openFolder(File file) throws Exception {
if (openFolderAvailable()) {
- String launcher = Preferences.get("launcher");
+ String launcher = PreferencesData.get("launcher");
try {
String[] params = new String[] { launcher, file.getAbsolutePath() };
//processing.core.PApplet.println(params);
diff --git a/app/src/processing/app/linux/UDevAdmParser.java b/arduino-core/src/processing/app/linux/UDevAdmParser.java
similarity index 100%
rename from app/src/processing/app/linux/UDevAdmParser.java
rename to arduino-core/src/processing/app/linux/UDevAdmParser.java
diff --git a/app/src/processing/app/macosx/Platform.java b/arduino-core/src/processing/app/macosx/Platform.java
similarity index 97%
rename from app/src/processing/app/macosx/Platform.java
rename to arduino-core/src/processing/app/macosx/Platform.java
index 7bbe749846d..486a986ad43 100644
--- a/app/src/processing/app/macosx/Platform.java
+++ b/arduino-core/src/processing/app/macosx/Platform.java
@@ -25,11 +25,10 @@
import com.apple.eio.FileManager;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.Executor;
-import processing.app.Base;
import processing.app.debug.TargetPackage;
import processing.app.tools.ExternalProcessExecutor;
-import processing.core.PApplet;
-import processing.core.PConstants;
+import processing.app.legacy.PApplet;
+import processing.app.legacy.PConstants;
import javax.swing.*;
import java.awt.*;
@@ -58,9 +57,8 @@ public Platform() {
Toolkit.getDefaultToolkit();
}
- public void init(Base base) {
+ public void init() {
System.setProperty("apple.laf.useScreenMenuBar", "true");
- ThinkDifferent.init(base);
/*
try {
String name = "processing.app.macosx.ThinkDifferent";
@@ -129,7 +127,7 @@ public void openURL(String url) throws Exception {
} else {
// Assume this is a file instead, and just open it.
// Extension of http://dev.processing.org/bugs/show_bug.cgi?id=1010
- processing.core.PApplet.open(url);
+ PApplet.open(url);
}
} else {
try {
@@ -162,7 +160,7 @@ public boolean openFolderAvailable() {
public void openFolder(File file) throws Exception {
//openURL(file.getAbsolutePath()); // handles char replacement, etc
- processing.core.PApplet.open(file.getAbsolutePath());
+ PApplet.open(file.getAbsolutePath());
}
diff --git a/app/src/processing/app/macosx/SystemProfilerParser.java b/arduino-core/src/processing/app/macosx/SystemProfilerParser.java
similarity index 100%
rename from app/src/processing/app/macosx/SystemProfilerParser.java
rename to arduino-core/src/processing/app/macosx/SystemProfilerParser.java
diff --git a/app/src/processing/app/packages/Library.java b/arduino-core/src/processing/app/packages/Library.java
similarity index 93%
rename from app/src/processing/app/packages/Library.java
rename to arduino-core/src/processing/app/packages/Library.java
index 9c505fe4e41..bf69c4edd72 100644
--- a/app/src/processing/app/packages/Library.java
+++ b/arduino-core/src/processing/app/packages/Library.java
@@ -23,10 +23,11 @@ public class Library {
private String license;
private List architectures;
private File folder;
- private File srcFolder;
- private boolean useRecursion;
private boolean isLegacy;
+ private enum LibraryLayout { FLAT, RECURSIVE };
+ private LibraryLayout layout;
+
private static final List MANDATORY_PROPERTIES = Arrays
.asList(new String[] { "name", "version", "author", "maintainer",
"sentence", "paragraph", "url" });
@@ -82,12 +83,12 @@ private static Library createLibrary(File libFolder) throws IOException {
throw new IOException("Missing '" + p + "' from library");
// Check layout
- boolean useRecursion;
+ LibraryLayout layout;
File srcFolder = new File(libFolder, "src");
if (srcFolder.exists() && srcFolder.isDirectory()) {
// Layout with a single "src" folder and recursive compilation
- useRecursion = true;
+ layout = LibraryLayout.RECURSIVE;
File utilFolder = new File(libFolder, "utility");
if (utilFolder.exists() && utilFolder.isDirectory()) {
@@ -96,8 +97,7 @@ private static Library createLibrary(File libFolder) throws IOException {
}
} else {
// Layout with source code on library's root and "utility" folders
- srcFolder = libFolder;
- useRecursion = false;
+ layout = LibraryLayout.FLAT;
}
// Warn if root folder contains development leftovers
@@ -134,7 +134,6 @@ private static Library createLibrary(File libFolder) throws IOException {
Library res = new Library();
res.folder = libFolder;
- res.srcFolder = srcFolder;
res.name = properties.get("name").trim();
res.version = properties.get("version").trim();
res.author = properties.get("author").trim();
@@ -145,8 +144,8 @@ private static Library createLibrary(File libFolder) throws IOException {
res.category = category.trim();
res.license = license.trim();
res.architectures = archs;
- res.useRecursion = useRecursion;
res.isLegacy = false;
+ res.layout = layout;
return res;
}
@@ -154,8 +153,7 @@ private static Library createLegacyLibrary(File libFolder) {
// construct an old style library
Library res = new Library();
res.folder = libFolder;
- res.srcFolder = libFolder;
- res.useRecursion = false;
+ res.layout = LibraryLayout.FLAT;
res.name = libFolder.getName();
res.architectures = Arrays.asList("*");
res.isLegacy = true;
@@ -246,11 +244,18 @@ public String getMaintainer() {
}
public boolean useRecursion() {
- return useRecursion;
+ return (layout == LibraryLayout.RECURSIVE);
}
public File getSrcFolder() {
- return srcFolder;
+ switch (layout) {
+ case FLAT:
+ return folder;
+ case RECURSIVE:
+ return new File(folder, "src");
+ default:
+ return null; // Keep compiler happy :-(
+ }
}
public boolean isLegacy() {
diff --git a/app/src/processing/app/packages/LibraryList.java b/arduino-core/src/processing/app/packages/LibraryList.java
similarity index 100%
rename from app/src/processing/app/packages/LibraryList.java
rename to arduino-core/src/processing/app/packages/LibraryList.java
diff --git a/app/src/processing/app/preproc/.cvsignore b/arduino-core/src/processing/app/preproc/.cvsignore
similarity index 100%
rename from app/src/processing/app/preproc/.cvsignore
rename to arduino-core/src/processing/app/preproc/.cvsignore
diff --git a/app/src/processing/app/preproc/PdePreprocessor.java b/arduino-core/src/processing/app/preproc/PdePreprocessor.java
similarity index 99%
rename from app/src/processing/app/preproc/PdePreprocessor.java
rename to arduino-core/src/processing/app/preproc/PdePreprocessor.java
index 10e4b3dd592..576f7468b9d 100644
--- a/app/src/processing/app/preproc/PdePreprocessor.java
+++ b/arduino-core/src/processing/app/preproc/PdePreprocessor.java
@@ -31,11 +31,10 @@ Processing version Copyright (c) 2004-05 Ben Fry and Casey Reas
import static processing.app.I18n._;
import processing.app.*;
-import processing.core.*;
+import processing.app.legacy.PApplet;
import java.io.*;
import java.util.*;
-
import java.util.regex.*;
@@ -90,7 +89,7 @@ public int writePrefix(String program)
program = scrubComments(program);
// If there are errors, an exception is thrown and this fxn exits.
- if (Preferences.getBoolean("preproc.substitute_unicode")) {
+ if (PreferencesData.getBoolean("preproc.substitute_unicode")) {
program = substituteUnicode(program);
}
diff --git a/app/src/processing/app/tools/ExternalProcessExecutor.java b/arduino-core/src/processing/app/tools/ExternalProcessExecutor.java
similarity index 100%
rename from app/src/processing/app/tools/ExternalProcessExecutor.java
rename to arduino-core/src/processing/app/tools/ExternalProcessExecutor.java
diff --git a/app/src/processing/app/windows/Advapi32.java b/arduino-core/src/processing/app/windows/Advapi32.java
similarity index 96%
rename from app/src/processing/app/windows/Advapi32.java
rename to arduino-core/src/processing/app/windows/Advapi32.java
index 0534d6b2175..203fb74d7ed 100644
--- a/app/src/processing/app/windows/Advapi32.java
+++ b/arduino-core/src/processing/app/windows/Advapi32.java
@@ -1,335 +1,335 @@
-package processing.app.windows;
-
-/*
- * Advapi32.java
- *
- * Created on 6. August 2007, 11:24
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
-
-import com.sun.jna.*;
-import com.sun.jna.ptr.*;
-import com.sun.jna.win32.*;
-
-/**
- *
- * @author TB
- */
-public interface Advapi32 extends StdCallLibrary {
- Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32", Advapi32.class, Options.UNICODE_OPTIONS);
-
-/*
-BOOL WINAPI LookupAccountName(
- LPCTSTR lpSystemName,
- LPCTSTR lpAccountName,
- PSID Sid,
- LPDWORD cbSid,
- LPTSTR ReferencedDomainName,
- LPDWORD cchReferencedDomainName,
- PSID_NAME_USE peUse
-);*/
- public boolean LookupAccountName(String lpSystemName, String lpAccountName,
- byte[] Sid, IntByReference cbSid, char[] ReferencedDomainName,
- IntByReference cchReferencedDomainName, PointerByReference peUse);
-
-/*
-BOOL WINAPI LookupAccountSid(
- LPCTSTR lpSystemName,
- PSID lpSid,
- LPTSTR lpName,
- LPDWORD cchName,
- LPTSTR lpReferencedDomainName,
- LPDWORD cchReferencedDomainName,
- PSID_NAME_USE peUse
-);*/
- public boolean LookupAccountSid(String lpSystemName, byte[] Sid,
- char[] lpName, IntByReference cchName, char[] ReferencedDomainName,
- IntByReference cchReferencedDomainName, PointerByReference peUse);
-
-/*
-BOOL ConvertSidToStringSid(
- PSID Sid,
- LPTSTR* StringSid
-);*/
- public boolean ConvertSidToStringSid(byte[] Sid, PointerByReference StringSid);
-
-/*
-BOOL WINAPI ConvertStringSidToSid(
- LPCTSTR StringSid,
- PSID* Sid
-);*/
- public boolean ConvertStringSidToSid(String StringSid, PointerByReference Sid);
-
-/*
-SC_HANDLE WINAPI OpenSCManager(
- LPCTSTR lpMachineName,
- LPCTSTR lpDatabaseName,
- DWORD dwDesiredAccess
-);*/
- public Pointer OpenSCManager(String lpMachineName, WString lpDatabaseName, int dwDesiredAccess);
-
-/*
-BOOL WINAPI CloseServiceHandle(
- SC_HANDLE hSCObject
-);*/
- public boolean CloseServiceHandle(Pointer hSCObject);
-
-/*
-SC_HANDLE WINAPI OpenService(
- SC_HANDLE hSCManager,
- LPCTSTR lpServiceName,
- DWORD dwDesiredAccess
-);*/
- public Pointer OpenService(Pointer hSCManager, String lpServiceName, int dwDesiredAccess);
-
-/*
-BOOL WINAPI StartService(
- SC_HANDLE hService,
- DWORD dwNumServiceArgs,
- LPCTSTR* lpServiceArgVectors
-);*/
- public boolean StartService(Pointer hService, int dwNumServiceArgs, char[] lpServiceArgVectors);
-
-/*
-BOOL WINAPI ControlService(
- SC_HANDLE hService,
- DWORD dwControl,
- LPSERVICE_STATUS lpServiceStatus
-);*/
- public boolean ControlService(Pointer hService, int dwControl, SERVICE_STATUS lpServiceStatus);
-
-/*
-BOOL WINAPI StartServiceCtrlDispatcher(
- const SERVICE_TABLE_ENTRY* lpServiceTable
-);*/
- public boolean StartServiceCtrlDispatcher(Structure[] lpServiceTable);
-
-/*
-SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandler(
- LPCTSTR lpServiceName,
- LPHANDLER_FUNCTION lpHandlerProc
-);*/
- public Pointer RegisterServiceCtrlHandler(String lpServiceName, Handler lpHandlerProc);
-
-/*
-SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerEx(
- LPCTSTR lpServiceName,
- LPHANDLER_FUNCTION_EX lpHandlerProc,
- LPVOID lpContext
-);*/
- public Pointer RegisterServiceCtrlHandlerEx(String lpServiceName, HandlerEx lpHandlerProc, Pointer lpContext);
-
-/*
-BOOL WINAPI SetServiceStatus(
- SERVICE_STATUS_HANDLE hServiceStatus,
- LPSERVICE_STATUS lpServiceStatus
-);*/
- public boolean SetServiceStatus(Pointer hServiceStatus, SERVICE_STATUS lpServiceStatus);
-
-/*
-SC_HANDLE WINAPI CreateService(
- SC_HANDLE hSCManager,
- LPCTSTR lpServiceName,
- LPCTSTR lpDisplayName,
- DWORD dwDesiredAccess,
- DWORD dwServiceType,
- DWORD dwStartType,
- DWORD dwErrorControl,
- LPCTSTR lpBinaryPathName,
- LPCTSTR lpLoadOrderGroup,
- LPDWORD lpdwTagId,
- LPCTSTR lpDependencies,
- LPCTSTR lpServiceStartName,
- LPCTSTR lpPassword
-);*/
- public Pointer CreateService(Pointer hSCManager, String lpServiceName, String lpDisplayName,
- int dwDesiredAccess, int dwServiceType, int dwStartType, int dwErrorControl,
- String lpBinaryPathName, String lpLoadOrderGroup, IntByReference lpdwTagId,
- String lpDependencies, String lpServiceStartName, String lpPassword);
-
-/*
-BOOL WINAPI DeleteService(
- SC_HANDLE hService
-);*/
- public boolean DeleteService(Pointer hService);
-
-/*
-BOOL WINAPI ChangeServiceConfig2(
- SC_HANDLE hService,
- DWORD dwInfoLevel,
- LPVOID lpInfo
-);*/
- public boolean ChangeServiceConfig2(Pointer hService, int dwInfoLevel, ChangeServiceConfig2Info lpInfo);
-
-/*
-LONG WINAPI RegOpenKeyEx(
- HKEY hKey,
- LPCTSTR lpSubKey,
- DWORD ulOptions,
- REGSAM samDesired,
- PHKEY phkResult
-);*/
- public int RegOpenKeyEx(int hKey, String lpSubKey, int ulOptions, int samDesired, IntByReference phkResult);
-
-/*
-LONG WINAPI RegQueryValueEx(
- HKEY hKey,
- LPCTSTR lpValueName,
- LPDWORD lpReserved,
- LPDWORD lpType,
- LPBYTE lpData,
- LPDWORD lpcbData
-);*/
- public int RegQueryValueEx(int hKey, String lpValueName, IntByReference lpReserved, IntByReference lpType, byte[] lpData, IntByReference lpcbData);
-
-/*
-LONG WINAPI RegCloseKey(
- HKEY hKey
-);*/
- public int RegCloseKey(int hKey);
-
-/*
-LONG WINAPI RegDeleteValue(
- HKEY hKey,
- LPCTSTR lpValueName
-);*/
- public int RegDeleteValue(int hKey, String lpValueName);
-
-/*
-LONG WINAPI RegSetValueEx(
- HKEY hKey,
- LPCTSTR lpValueName,
- DWORD Reserved,
- DWORD dwType,
- const BYTE* lpData,
- DWORD cbData
-);*/
- public int RegSetValueEx(int hKey, String lpValueName, int Reserved, int dwType, byte[] lpData, int cbData);
-
-/*
-LONG WINAPI RegCreateKeyEx(
- HKEY hKey,
- LPCTSTR lpSubKey,
- DWORD Reserved,
- LPTSTR lpClass,
- DWORD dwOptions,
- REGSAM samDesired,
- LPSECURITY_ATTRIBUTES lpSecurityAttributes,
- PHKEY phkResult,
- LPDWORD lpdwDisposition
-);*/
- public int RegCreateKeyEx(int hKey, String lpSubKey, int Reserved, String lpClass, int dwOptions,
- int samDesired, WINBASE.SECURITY_ATTRIBUTES lpSecurityAttributes, IntByReference phkResult,
- IntByReference lpdwDisposition);
-
-/*
-LONG WINAPI RegDeleteKey(
- HKEY hKey,
- LPCTSTR lpSubKey
-);*/
- public int RegDeleteKey(int hKey, String name);
-
-/*
-LONG WINAPI RegEnumKeyEx(
- HKEY hKey,
- DWORD dwIndex,
- LPTSTR lpName,
- LPDWORD lpcName,
- LPDWORD lpReserved,
- LPTSTR lpClass,
- LPDWORD lpcClass,
- PFILETIME lpftLastWriteTime
-);*/
- public int RegEnumKeyEx(int hKey, int dwIndex, char[] lpName, IntByReference lpcName, IntByReference reserved,
- char[] lpClass, IntByReference lpcClass, WINBASE.FILETIME lpftLastWriteTime);
-
-/*
-LONG WINAPI RegEnumValue(
- HKEY hKey,
- DWORD dwIndex,
- LPTSTR lpValueName,
- LPDWORD lpcchValueName,
- LPDWORD lpReserved,
- LPDWORD lpType,
- LPBYTE lpData,
- LPDWORD lpcbData
-);*/
- public int RegEnumValue(int hKey, int dwIndex, char[] lpValueName, IntByReference lpcchValueName, IntByReference reserved,
- IntByReference lpType, byte[] lpData, IntByReference lpcbData);
-
- interface SERVICE_MAIN_FUNCTION extends StdCallCallback {
- /*
- VOID WINAPI ServiceMain(
- DWORD dwArgc,
- LPTSTR* lpszArgv
- );*/
- public void callback(int dwArgc, Pointer lpszArgv);
- }
-
- interface Handler extends StdCallCallback {
- /*
- VOID WINAPI Handler(
- DWORD fdwControl
- );*/
- public void callback(int fdwControl);
- }
-
- interface HandlerEx extends StdCallCallback {
- /*
- DWORD WINAPI HandlerEx(
- DWORD dwControl,
- DWORD dwEventType,
- LPVOID lpEventData,
- LPVOID lpContext
- );*/
- public void callback(int dwControl, int dwEventType, Pointer lpEventData, Pointer lpContext);
- }
-
-/*
-typedef struct _SERVICE_STATUS {
- DWORD dwServiceType;
- DWORD dwCurrentState;
- DWORD dwControlsAccepted;
- DWORD dwWin32ExitCode;
- DWORD dwServiceSpecificExitCode;
- DWORD dwCheckPoint;
- DWORD dwWaitHint;
-} SERVICE_STATUS,
- *LPSERVICE_STATUS;*/
- public static class SERVICE_STATUS extends Structure {
- public int dwServiceType;
- public int dwCurrentState;
- public int dwControlsAccepted;
- public int dwWin32ExitCode;
- public int dwServiceSpecificExitCode;
- public int dwCheckPoint;
- public int dwWaitHint;
- }
-
-/*
-typedef struct _SERVICE_TABLE_ENTRY {
- LPTSTR lpServiceName;
- LPSERVICE_MAIN_FUNCTION lpServiceProc;
-} SERVICE_TABLE_ENTRY,
- *LPSERVICE_TABLE_ENTRY;*/
- public static class SERVICE_TABLE_ENTRY extends Structure {
- public String lpServiceName;
- public SERVICE_MAIN_FUNCTION lpServiceProc;
- }
-
- public static class ChangeServiceConfig2Info extends Structure {
- }
-
-/*
- typedef struct _SERVICE_DESCRIPTION {
- LPTSTR lpDescription;
-} SERVICE_DESCRIPTION,
- *LPSERVICE_DESCRIPTION;*/
- public static class SERVICE_DESCRIPTION extends ChangeServiceConfig2Info {
- public String lpDescription;
- }
-}
-
-
+package processing.app.windows;
+
+/*
+ * Advapi32.java
+ *
+ * Created on 6. August 2007, 11:24
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+import com.sun.jna.*;
+import com.sun.jna.ptr.*;
+import com.sun.jna.win32.*;
+
+/**
+ *
+ * @author TB
+ */
+public interface Advapi32 extends StdCallLibrary {
+ Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32", Advapi32.class, Options.UNICODE_OPTIONS);
+
+/*
+BOOL WINAPI LookupAccountName(
+ LPCTSTR lpSystemName,
+ LPCTSTR lpAccountName,
+ PSID Sid,
+ LPDWORD cbSid,
+ LPTSTR ReferencedDomainName,
+ LPDWORD cchReferencedDomainName,
+ PSID_NAME_USE peUse
+);*/
+ public boolean LookupAccountName(String lpSystemName, String lpAccountName,
+ byte[] Sid, IntByReference cbSid, char[] ReferencedDomainName,
+ IntByReference cchReferencedDomainName, PointerByReference peUse);
+
+/*
+BOOL WINAPI LookupAccountSid(
+ LPCTSTR lpSystemName,
+ PSID lpSid,
+ LPTSTR lpName,
+ LPDWORD cchName,
+ LPTSTR lpReferencedDomainName,
+ LPDWORD cchReferencedDomainName,
+ PSID_NAME_USE peUse
+);*/
+ public boolean LookupAccountSid(String lpSystemName, byte[] Sid,
+ char[] lpName, IntByReference cchName, char[] ReferencedDomainName,
+ IntByReference cchReferencedDomainName, PointerByReference peUse);
+
+/*
+BOOL ConvertSidToStringSid(
+ PSID Sid,
+ LPTSTR* StringSid
+);*/
+ public boolean ConvertSidToStringSid(byte[] Sid, PointerByReference StringSid);
+
+/*
+BOOL WINAPI ConvertStringSidToSid(
+ LPCTSTR StringSid,
+ PSID* Sid
+);*/
+ public boolean ConvertStringSidToSid(String StringSid, PointerByReference Sid);
+
+/*
+SC_HANDLE WINAPI OpenSCManager(
+ LPCTSTR lpMachineName,
+ LPCTSTR lpDatabaseName,
+ DWORD dwDesiredAccess
+);*/
+ public Pointer OpenSCManager(String lpMachineName, WString lpDatabaseName, int dwDesiredAccess);
+
+/*
+BOOL WINAPI CloseServiceHandle(
+ SC_HANDLE hSCObject
+);*/
+ public boolean CloseServiceHandle(Pointer hSCObject);
+
+/*
+SC_HANDLE WINAPI OpenService(
+ SC_HANDLE hSCManager,
+ LPCTSTR lpServiceName,
+ DWORD dwDesiredAccess
+);*/
+ public Pointer OpenService(Pointer hSCManager, String lpServiceName, int dwDesiredAccess);
+
+/*
+BOOL WINAPI StartService(
+ SC_HANDLE hService,
+ DWORD dwNumServiceArgs,
+ LPCTSTR* lpServiceArgVectors
+);*/
+ public boolean StartService(Pointer hService, int dwNumServiceArgs, char[] lpServiceArgVectors);
+
+/*
+BOOL WINAPI ControlService(
+ SC_HANDLE hService,
+ DWORD dwControl,
+ LPSERVICE_STATUS lpServiceStatus
+);*/
+ public boolean ControlService(Pointer hService, int dwControl, SERVICE_STATUS lpServiceStatus);
+
+/*
+BOOL WINAPI StartServiceCtrlDispatcher(
+ const SERVICE_TABLE_ENTRY* lpServiceTable
+);*/
+ public boolean StartServiceCtrlDispatcher(Structure[] lpServiceTable);
+
+/*
+SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandler(
+ LPCTSTR lpServiceName,
+ LPHANDLER_FUNCTION lpHandlerProc
+);*/
+ public Pointer RegisterServiceCtrlHandler(String lpServiceName, Handler lpHandlerProc);
+
+/*
+SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerEx(
+ LPCTSTR lpServiceName,
+ LPHANDLER_FUNCTION_EX lpHandlerProc,
+ LPVOID lpContext
+);*/
+ public Pointer RegisterServiceCtrlHandlerEx(String lpServiceName, HandlerEx lpHandlerProc, Pointer lpContext);
+
+/*
+BOOL WINAPI SetServiceStatus(
+ SERVICE_STATUS_HANDLE hServiceStatus,
+ LPSERVICE_STATUS lpServiceStatus
+);*/
+ public boolean SetServiceStatus(Pointer hServiceStatus, SERVICE_STATUS lpServiceStatus);
+
+/*
+SC_HANDLE WINAPI CreateService(
+ SC_HANDLE hSCManager,
+ LPCTSTR lpServiceName,
+ LPCTSTR lpDisplayName,
+ DWORD dwDesiredAccess,
+ DWORD dwServiceType,
+ DWORD dwStartType,
+ DWORD dwErrorControl,
+ LPCTSTR lpBinaryPathName,
+ LPCTSTR lpLoadOrderGroup,
+ LPDWORD lpdwTagId,
+ LPCTSTR lpDependencies,
+ LPCTSTR lpServiceStartName,
+ LPCTSTR lpPassword
+);*/
+ public Pointer CreateService(Pointer hSCManager, String lpServiceName, String lpDisplayName,
+ int dwDesiredAccess, int dwServiceType, int dwStartType, int dwErrorControl,
+ String lpBinaryPathName, String lpLoadOrderGroup, IntByReference lpdwTagId,
+ String lpDependencies, String lpServiceStartName, String lpPassword);
+
+/*
+BOOL WINAPI DeleteService(
+ SC_HANDLE hService
+);*/
+ public boolean DeleteService(Pointer hService);
+
+/*
+BOOL WINAPI ChangeServiceConfig2(
+ SC_HANDLE hService,
+ DWORD dwInfoLevel,
+ LPVOID lpInfo
+);*/
+ public boolean ChangeServiceConfig2(Pointer hService, int dwInfoLevel, ChangeServiceConfig2Info lpInfo);
+
+/*
+LONG WINAPI RegOpenKeyEx(
+ HKEY hKey,
+ LPCTSTR lpSubKey,
+ DWORD ulOptions,
+ REGSAM samDesired,
+ PHKEY phkResult
+);*/
+ public int RegOpenKeyEx(int hKey, String lpSubKey, int ulOptions, int samDesired, IntByReference phkResult);
+
+/*
+LONG WINAPI RegQueryValueEx(
+ HKEY hKey,
+ LPCTSTR lpValueName,
+ LPDWORD lpReserved,
+ LPDWORD lpType,
+ LPBYTE lpData,
+ LPDWORD lpcbData
+);*/
+ public int RegQueryValueEx(int hKey, String lpValueName, IntByReference lpReserved, IntByReference lpType, byte[] lpData, IntByReference lpcbData);
+
+/*
+LONG WINAPI RegCloseKey(
+ HKEY hKey
+);*/
+ public int RegCloseKey(int hKey);
+
+/*
+LONG WINAPI RegDeleteValue(
+ HKEY hKey,
+ LPCTSTR lpValueName
+);*/
+ public int RegDeleteValue(int hKey, String lpValueName);
+
+/*
+LONG WINAPI RegSetValueEx(
+ HKEY hKey,
+ LPCTSTR lpValueName,
+ DWORD Reserved,
+ DWORD dwType,
+ const BYTE* lpData,
+ DWORD cbData
+);*/
+ public int RegSetValueEx(int hKey, String lpValueName, int Reserved, int dwType, byte[] lpData, int cbData);
+
+/*
+LONG WINAPI RegCreateKeyEx(
+ HKEY hKey,
+ LPCTSTR lpSubKey,
+ DWORD Reserved,
+ LPTSTR lpClass,
+ DWORD dwOptions,
+ REGSAM samDesired,
+ LPSECURITY_ATTRIBUTES lpSecurityAttributes,
+ PHKEY phkResult,
+ LPDWORD lpdwDisposition
+);*/
+ public int RegCreateKeyEx(int hKey, String lpSubKey, int Reserved, String lpClass, int dwOptions,
+ int samDesired, WINBASE.SECURITY_ATTRIBUTES lpSecurityAttributes, IntByReference phkResult,
+ IntByReference lpdwDisposition);
+
+/*
+LONG WINAPI RegDeleteKey(
+ HKEY hKey,
+ LPCTSTR lpSubKey
+);*/
+ public int RegDeleteKey(int hKey, String name);
+
+/*
+LONG WINAPI RegEnumKeyEx(
+ HKEY hKey,
+ DWORD dwIndex,
+ LPTSTR lpName,
+ LPDWORD lpcName,
+ LPDWORD lpReserved,
+ LPTSTR lpClass,
+ LPDWORD lpcClass,
+ PFILETIME lpftLastWriteTime
+);*/
+ public int RegEnumKeyEx(int hKey, int dwIndex, char[] lpName, IntByReference lpcName, IntByReference reserved,
+ char[] lpClass, IntByReference lpcClass, WINBASE.FILETIME lpftLastWriteTime);
+
+/*
+LONG WINAPI RegEnumValue(
+ HKEY hKey,
+ DWORD dwIndex,
+ LPTSTR lpValueName,
+ LPDWORD lpcchValueName,
+ LPDWORD lpReserved,
+ LPDWORD lpType,
+ LPBYTE lpData,
+ LPDWORD lpcbData
+);*/
+ public int RegEnumValue(int hKey, int dwIndex, char[] lpValueName, IntByReference lpcchValueName, IntByReference reserved,
+ IntByReference lpType, byte[] lpData, IntByReference lpcbData);
+
+ interface SERVICE_MAIN_FUNCTION extends StdCallCallback {
+ /*
+ VOID WINAPI ServiceMain(
+ DWORD dwArgc,
+ LPTSTR* lpszArgv
+ );*/
+ public void callback(int dwArgc, Pointer lpszArgv);
+ }
+
+ interface Handler extends StdCallCallback {
+ /*
+ VOID WINAPI Handler(
+ DWORD fdwControl
+ );*/
+ public void callback(int fdwControl);
+ }
+
+ interface HandlerEx extends StdCallCallback {
+ /*
+ DWORD WINAPI HandlerEx(
+ DWORD dwControl,
+ DWORD dwEventType,
+ LPVOID lpEventData,
+ LPVOID lpContext
+ );*/
+ public void callback(int dwControl, int dwEventType, Pointer lpEventData, Pointer lpContext);
+ }
+
+/*
+typedef struct _SERVICE_STATUS {
+ DWORD dwServiceType;
+ DWORD dwCurrentState;
+ DWORD dwControlsAccepted;
+ DWORD dwWin32ExitCode;
+ DWORD dwServiceSpecificExitCode;
+ DWORD dwCheckPoint;
+ DWORD dwWaitHint;
+} SERVICE_STATUS,
+ *LPSERVICE_STATUS;*/
+ public static class SERVICE_STATUS extends Structure {
+ public int dwServiceType;
+ public int dwCurrentState;
+ public int dwControlsAccepted;
+ public int dwWin32ExitCode;
+ public int dwServiceSpecificExitCode;
+ public int dwCheckPoint;
+ public int dwWaitHint;
+ }
+
+/*
+typedef struct _SERVICE_TABLE_ENTRY {
+ LPTSTR lpServiceName;
+ LPSERVICE_MAIN_FUNCTION lpServiceProc;
+} SERVICE_TABLE_ENTRY,
+ *LPSERVICE_TABLE_ENTRY;*/
+ public static class SERVICE_TABLE_ENTRY extends Structure {
+ public String lpServiceName;
+ public SERVICE_MAIN_FUNCTION lpServiceProc;
+ }
+
+ public static class ChangeServiceConfig2Info extends Structure {
+ }
+
+/*
+ typedef struct _SERVICE_DESCRIPTION {
+ LPTSTR lpDescription;
+} SERVICE_DESCRIPTION,
+ *LPSERVICE_DESCRIPTION;*/
+ public static class SERVICE_DESCRIPTION extends ChangeServiceConfig2Info {
+ public String lpDescription;
+ }
+}
+
+
diff --git a/app/src/processing/app/windows/ListComPortsParser.java b/arduino-core/src/processing/app/windows/ListComPortsParser.java
similarity index 100%
rename from app/src/processing/app/windows/ListComPortsParser.java
rename to arduino-core/src/processing/app/windows/ListComPortsParser.java
diff --git a/app/src/processing/app/windows/Options.java b/arduino-core/src/processing/app/windows/Options.java
similarity index 95%
rename from app/src/processing/app/windows/Options.java
rename to arduino-core/src/processing/app/windows/Options.java
index f5cff28888d..6f5239172a5 100644
--- a/app/src/processing/app/windows/Options.java
+++ b/arduino-core/src/processing/app/windows/Options.java
@@ -1,27 +1,27 @@
-/*
- * Options.java
- *
- * Created on 8. August 2007, 17:07
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
-
-package processing.app.windows;
-
-import static com.sun.jna.Library.*;
-import com.sun.jna.win32.*;
-import java.util.*;
-
-/**
- *
- * @author TB
- */
-public interface Options {
- Map UNICODE_OPTIONS = new HashMap() {
- {
- put(OPTION_TYPE_MAPPER, W32APITypeMapper.UNICODE);
- put(OPTION_FUNCTION_MAPPER, W32APIFunctionMapper.UNICODE);
- }
- };
-}
+/*
+ * Options.java
+ *
+ * Created on 8. August 2007, 17:07
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package processing.app.windows;
+
+import static com.sun.jna.Library.*;
+import com.sun.jna.win32.*;
+import java.util.*;
+
+/**
+ *
+ * @author TB
+ */
+public interface Options {
+ Map UNICODE_OPTIONS = new HashMap() {
+ {
+ put(OPTION_TYPE_MAPPER, W32APITypeMapper.UNICODE);
+ put(OPTION_FUNCTION_MAPPER, W32APIFunctionMapper.UNICODE);
+ }
+ };
+}
diff --git a/app/src/processing/app/windows/Platform.java b/arduino-core/src/processing/app/windows/Platform.java
similarity index 96%
rename from app/src/processing/app/windows/Platform.java
rename to arduino-core/src/processing/app/windows/Platform.java
index e340da4176e..a35f7c195da 100644
--- a/app/src/processing/app/windows/Platform.java
+++ b/arduino-core/src/processing/app/windows/Platform.java
@@ -24,15 +24,16 @@
import com.sun.jna.Library;
import com.sun.jna.Native;
+
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.Executor;
-import processing.app.Base;
-import processing.app.Preferences;
+
+import processing.app.PreferencesData;
import processing.app.debug.TargetPackage;
+import processing.app.legacy.PApplet;
+import processing.app.legacy.PConstants;
import processing.app.tools.ExternalProcessExecutor;
import processing.app.windows.Registry.REGISTRY_ROOT_KEY;
-import processing.core.PApplet;
-import processing.core.PConstants;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -54,8 +55,8 @@ public class Platform extends processing.app.Platform {
"\\arduino.exe \"%1\"";
static final String DOC = "Arduino.Document";
- public void init(Base base) {
- super.init(base);
+ public void init() {
+ super.init();
checkAssociations();
checkQuickTime();
@@ -72,13 +73,13 @@ protected void checkAssociations() {
Registry.getStringValue(REGISTRY_ROOT_KEY.CLASSES_ROOT,
DOC + "\\shell\\open\\command", "");
if (knownCommand == null) {
- if (Preferences.getBoolean("platform.auto_file_type_associations")) {
+ if (PreferencesData.getBoolean("platform.auto_file_type_associations")) {
setAssociations();
}
} else if (!knownCommand.equals(openCommand)) {
// If the value is set differently, just change the registry setting.
- if (Preferences.getBoolean("platform.auto_file_type_associations")) {
+ if (PreferencesData.getBoolean("platform.auto_file_type_associations")) {
setAssociations();
}
}
@@ -114,7 +115,7 @@ protected void setAssociations() throws UnsupportedEncodingException {
// hooray!
} else {
- Preferences.setBoolean("platform.auto_file_type_associations", false);
+ PreferencesData.setBoolean("platform.auto_file_type_associations", false);
}
}
diff --git a/app/src/processing/app/windows/Registry.java b/arduino-core/src/processing/app/windows/Registry.java
similarity index 100%
rename from app/src/processing/app/windows/Registry.java
rename to arduino-core/src/processing/app/windows/Registry.java
diff --git a/app/src/processing/app/windows/WINBASE.java b/arduino-core/src/processing/app/windows/WINBASE.java
similarity index 95%
rename from app/src/processing/app/windows/WINBASE.java
rename to arduino-core/src/processing/app/windows/WINBASE.java
index c4807cc903c..78a386f0467 100644
--- a/app/src/processing/app/windows/WINBASE.java
+++ b/arduino-core/src/processing/app/windows/WINBASE.java
@@ -1,43 +1,43 @@
-/*
- * WINBASE.java
- *
- * Created on 5. September 2007, 11:24
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
-
-package processing.app.windows;
-
-import com.sun.jna.Pointer;
-import com.sun.jna.Structure;
-
-/**
- *
- * @author TB
- */
-public interface WINBASE {
-/*
-typedef struct _SECURITY_ATTRIBUTES {
- DWORD nLength;
- LPVOID lpSecurityDescriptor;
- BOOL bInheritHandle;
-} SECURITY_ATTRIBUTES,
- *PSECURITY_ATTRIBUTES,
- *LPSECURITY_ATTRIBUTES;*/
- public static class SECURITY_ATTRIBUTES extends Structure {
- public int nLength;
- public Pointer lpSecurityDescriptor;
- public boolean bInheritHandle;
- }
-
-/*
-typedef struct _FILETIME {
- DWORD dwLowDateTime;
- DWORD dwHighDateTime;
-} FILETIME, *PFILETIME, *LPFILETIME;*/
- public static class FILETIME extends Structure {
- public int dwLowDateTime;
- public int dwHighDateTime;
- }
-}
+/*
+ * WINBASE.java
+ *
+ * Created on 5. September 2007, 11:24
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package processing.app.windows;
+
+import com.sun.jna.Pointer;
+import com.sun.jna.Structure;
+
+/**
+ *
+ * @author TB
+ */
+public interface WINBASE {
+/*
+typedef struct _SECURITY_ATTRIBUTES {
+ DWORD nLength;
+ LPVOID lpSecurityDescriptor;
+ BOOL bInheritHandle;
+} SECURITY_ATTRIBUTES,
+ *PSECURITY_ATTRIBUTES,
+ *LPSECURITY_ATTRIBUTES;*/
+ public static class SECURITY_ATTRIBUTES extends Structure {
+ public int nLength;
+ public Pointer lpSecurityDescriptor;
+ public boolean bInheritHandle;
+ }
+
+/*
+typedef struct _FILETIME {
+ DWORD dwLowDateTime;
+ DWORD dwHighDateTime;
+} FILETIME, *PFILETIME, *LPFILETIME;*/
+ public static class FILETIME extends Structure {
+ public int dwLowDateTime;
+ public int dwHighDateTime;
+ }
+}
diff --git a/app/src/processing/app/windows/WINERROR.java b/arduino-core/src/processing/app/windows/WINERROR.java
similarity index 95%
rename from app/src/processing/app/windows/WINERROR.java
rename to arduino-core/src/processing/app/windows/WINERROR.java
index 3e1146e93a6..a9382cfcbcf 100644
--- a/app/src/processing/app/windows/WINERROR.java
+++ b/arduino-core/src/processing/app/windows/WINERROR.java
@@ -1,22 +1,22 @@
-/*
- * WINERROR.java
- *
- * Created on 7. August 2007, 08:09
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
-
-package processing.app.windows;
-
-
-/**
- *
- * @author TB
- */
-public interface WINERROR {
- public final static int ERROR_SUCCESS = 0;
- public final static int NO_ERROR = 0;
- public final static int ERROR_FILE_NOT_FOUND = 2;
- public final static int ERROR_MORE_DATA = 234;
-}
+/*
+ * WINERROR.java
+ *
+ * Created on 7. August 2007, 08:09
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package processing.app.windows;
+
+
+/**
+ *
+ * @author TB
+ */
+public interface WINERROR {
+ public final static int ERROR_SUCCESS = 0;
+ public final static int NO_ERROR = 0;
+ public final static int ERROR_FILE_NOT_FOUND = 2;
+ public final static int ERROR_MORE_DATA = 234;
+}
diff --git a/app/src/processing/app/windows/WINNT.java b/arduino-core/src/processing/app/windows/WINNT.java
similarity index 98%
rename from app/src/processing/app/windows/WINNT.java
rename to arduino-core/src/processing/app/windows/WINNT.java
index 89aa3616804..c08c9f5a3fc 100644
--- a/app/src/processing/app/windows/WINNT.java
+++ b/arduino-core/src/processing/app/windows/WINNT.java
@@ -1,73 +1,73 @@
-/*
- * WINNT.java
- *
- * Created on 8. August 2007, 13:41
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
-
-package processing.app.windows;
-
-/**
- *
- * @author TB
- */
-public interface WINNT {
- public final static int DELETE = 0x00010000;
- public final static int READ_CONTROL = 0x00020000;
- public final static int WRITE_DAC = 0x00040000;
- public final static int WRITE_OWNER = 0x00080000;
- public final static int SYNCHRONIZE = 0x00100000;
-
- public final static int STANDARD_RIGHTS_REQUIRED = 0x000F0000;
-
- public final static int STANDARD_RIGHTS_READ = READ_CONTROL;
- public final static int STANDARD_RIGHTS_WRITE = READ_CONTROL;
- public final static int STANDARD_RIGHTS_EXECUTE = READ_CONTROL;
-
- public final static int STANDARD_RIGHTS_ALL = 0x001F0000;
-
- public final static int SPECIFIC_RIGHTS_ALL = 0x0000FFFF;
-
- public final static int GENERIC_EXECUTE = 0x20000000;
-
- public final static int SERVICE_WIN32_OWN_PROCESS = 0x00000010;
-
- public final static int KEY_QUERY_VALUE = 0x0001;
- public final static int KEY_SET_VALUE = 0x0002;
- public final static int KEY_CREATE_SUB_KEY = 0x0004;
- public final static int KEY_ENUMERATE_SUB_KEYS = 0x0008;
- public final static int KEY_NOTIFY = 0x0010;
- public final static int KEY_CREATE_LINK = 0x0020;
-
- public final static int KEY_READ = ((STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY) & (~SYNCHRONIZE));
- public final static int KEY_WRITE = ((STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY) & (~SYNCHRONIZE));
-
- public final static int REG_NONE = 0; // No value type
- public final static int REG_SZ = 1; // Unicode nul terminated string
- public final static int REG_EXPAND_SZ = 2; // Unicode nul terminated string
- // (with environment variable references)
- public final static int REG_BINARY = 3; // Free form binary
- public final static int REG_DWORD = 4; // 32-bit number
- public final static int REG_DWORD_LITTLE_ENDIAN = 4; // 32-bit number (same as REG_DWORD)
- public final static int REG_DWORD_BIG_ENDIAN = 5; // 32-bit number
- public final static int REG_LINK = 6; // Symbolic Link (unicode)
- public final static int REG_MULTI_SZ = 7; // Multiple Unicode strings
- public final static int REG_RESOURCE_LIST = 8; // Resource list in the resource map
- public final static int REG_FULL_RESOURCE_DESCRIPTOR = 9; // Resource list in the hardware description
- public final static int REG_RESOURCE_REQUIREMENTS_LIST = 10;
-
- public final static int REG_OPTION_RESERVED = 0x00000000; // Parameter is reserved
- public final static int REG_OPTION_NON_VOLATILE = 0x00000000; // Key is preserved
- // when system is rebooted
- public final static int REG_OPTION_VOLATILE = 0x00000001; // Key is not preserved
- // when system is rebooted
- public final static int REG_OPTION_CREATE_LINK = 0x00000002; // Created key is a
- // symbolic link
- public final static int REG_OPTION_BACKUP_RESTORE = 0x00000004; // open for backup or restore
- // special access rules
- // privilege required
- public final static int REG_OPTION_OPEN_LINK = 0x00000008; // Open symbolic link
-
-}
+/*
+ * WINNT.java
+ *
+ * Created on 8. August 2007, 13:41
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package processing.app.windows;
+
+/**
+ *
+ * @author TB
+ */
+public interface WINNT {
+ public final static int DELETE = 0x00010000;
+ public final static int READ_CONTROL = 0x00020000;
+ public final static int WRITE_DAC = 0x00040000;
+ public final static int WRITE_OWNER = 0x00080000;
+ public final static int SYNCHRONIZE = 0x00100000;
+
+ public final static int STANDARD_RIGHTS_REQUIRED = 0x000F0000;
+
+ public final static int STANDARD_RIGHTS_READ = READ_CONTROL;
+ public final static int STANDARD_RIGHTS_WRITE = READ_CONTROL;
+ public final static int STANDARD_RIGHTS_EXECUTE = READ_CONTROL;
+
+ public final static int STANDARD_RIGHTS_ALL = 0x001F0000;
+
+ public final static int SPECIFIC_RIGHTS_ALL = 0x0000FFFF;
+
+ public final static int GENERIC_EXECUTE = 0x20000000;
+
+ public final static int SERVICE_WIN32_OWN_PROCESS = 0x00000010;
+
+ public final static int KEY_QUERY_VALUE = 0x0001;
+ public final static int KEY_SET_VALUE = 0x0002;
+ public final static int KEY_CREATE_SUB_KEY = 0x0004;
+ public final static int KEY_ENUMERATE_SUB_KEYS = 0x0008;
+ public final static int KEY_NOTIFY = 0x0010;
+ public final static int KEY_CREATE_LINK = 0x0020;
+
+ public final static int KEY_READ = ((STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY) & (~SYNCHRONIZE));
+ public final static int KEY_WRITE = ((STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY) & (~SYNCHRONIZE));
+
+ public final static int REG_NONE = 0; // No value type
+ public final static int REG_SZ = 1; // Unicode nul terminated string
+ public final static int REG_EXPAND_SZ = 2; // Unicode nul terminated string
+ // (with environment variable references)
+ public final static int REG_BINARY = 3; // Free form binary
+ public final static int REG_DWORD = 4; // 32-bit number
+ public final static int REG_DWORD_LITTLE_ENDIAN = 4; // 32-bit number (same as REG_DWORD)
+ public final static int REG_DWORD_BIG_ENDIAN = 5; // 32-bit number
+ public final static int REG_LINK = 6; // Symbolic Link (unicode)
+ public final static int REG_MULTI_SZ = 7; // Multiple Unicode strings
+ public final static int REG_RESOURCE_LIST = 8; // Resource list in the resource map
+ public final static int REG_FULL_RESOURCE_DESCRIPTOR = 9; // Resource list in the hardware description
+ public final static int REG_RESOURCE_REQUIREMENTS_LIST = 10;
+
+ public final static int REG_OPTION_RESERVED = 0x00000000; // Parameter is reserved
+ public final static int REG_OPTION_NON_VOLATILE = 0x00000000; // Key is preserved
+ // when system is rebooted
+ public final static int REG_OPTION_VOLATILE = 0x00000001; // Key is not preserved
+ // when system is rebooted
+ public final static int REG_OPTION_CREATE_LINK = 0x00000002; // Created key is a
+ // symbolic link
+ public final static int REG_OPTION_BACKUP_RESTORE = 0x00000004; // open for backup or restore
+ // special access rules
+ // privilege required
+ public final static int REG_OPTION_OPEN_LINK = 0x00000008; // Open symbolic link
+
+}
diff --git a/app/src/processing/app/windows/WINREG.java b/arduino-core/src/processing/app/windows/WINREG.java
similarity index 95%
rename from app/src/processing/app/windows/WINREG.java
rename to arduino-core/src/processing/app/windows/WINREG.java
index 988f7ef3658..07a7c23cb94 100644
--- a/app/src/processing/app/windows/WINREG.java
+++ b/arduino-core/src/processing/app/windows/WINREG.java
@@ -1,21 +1,21 @@
-/*
- * WINREG.java
- *
- * Created on 17. August 2007, 14:32
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
-
-package processing.app.windows;
-
-/**
- *
- * @author TB
- */
-public interface WINREG {
- public final static int HKEY_CLASSES_ROOT = 0x80000000;
- public final static int HKEY_CURRENT_USER = 0x80000001;
- public final static int HKEY_LOCAL_MACHINE = 0x80000002;
- public final static int HKEY_USERS = 0x80000003;
-}
+/*
+ * WINREG.java
+ *
+ * Created on 17. August 2007, 14:32
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package processing.app.windows;
+
+/**
+ *
+ * @author TB
+ */
+public interface WINREG {
+ public final static int HKEY_CLASSES_ROOT = 0x80000000;
+ public final static int HKEY_CURRENT_USER = 0x80000001;
+ public final static int HKEY_LOCAL_MACHINE = 0x80000002;
+ public final static int HKEY_USERS = 0x80000003;
+}
diff --git a/app/src/processing/app/zeroconf/jmdns/ArduinoDNSTaskStarter.java b/arduino-core/src/processing/app/zeroconf/jmdns/ArduinoDNSTaskStarter.java
similarity index 100%
rename from app/src/processing/app/zeroconf/jmdns/ArduinoDNSTaskStarter.java
rename to arduino-core/src/processing/app/zeroconf/jmdns/ArduinoDNSTaskStarter.java
diff --git a/build/build.xml b/build/build.xml
index 4427239bb47..229640ebec0 100644
--- a/build/build.xml
+++ b/build/build.xml
@@ -39,7 +39,7 @@
-
+
@@ -84,12 +84,12 @@
-
+
-
+
@@ -163,7 +163,7 @@
-
@@ -173,7 +173,7 @@
-
+