Skip to content

Commit 737671c

Browse files
committed
2 parents 8aff39a + 795df1e commit 737671c

File tree

573 files changed

+244924
-4122
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

573 files changed

+244924
-4122
lines changed

.gitignore

+13-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ app/pde.jar
33
build/macosx/work/
44
core/bin/
55
core/core.jar
6-
build/macosx/arduino.xcworkspace/contents.xcworkspacedata
7-
8-
build/macosx/arduino.xcworkspace/xcuserdata/mellis.xcuserdatad/UserInterfaceState.xcuserstate
6+
hardware/arduino/bootloaders/caterina_LUFA/Descriptors.o
7+
hardware/arduino/bootloaders/caterina_LUFA/Descriptors.lst
8+
hardware/arduino/bootloaders/caterina_LUFA/Caterina.sym
9+
hardware/arduino/bootloaders/caterina_LUFA/Caterina.o
10+
hardware/arduino/bootloaders/caterina_LUFA/Caterina.map
11+
hardware/arduino/bootloaders/caterina_LUFA/Caterina.lst
12+
hardware/arduino/bootloaders/caterina_LUFA/Caterina.lss
13+
hardware/arduino/bootloaders/caterina_LUFA/Caterina.elf
14+
hardware/arduino/bootloaders/caterina_LUFA/Caterina.eep
15+
hardware/arduino/bootloaders/caterina_LUFA/.dep/
16+
.gitignore
17+
build/windows/work/
18+
build/linux/work/

app/src/processing/app/Base.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ static public void main(String args[]) {
169169
// run static initialization that grabs all the prefs
170170
Preferences.init(null);
171171

172+
// load the I18n module for internationalization
173+
I18n.init(Preferences.get("editor.languages.current"));
174+
172175
// setup the theme coloring fun
173176
Theme.init();
174177

@@ -1565,7 +1568,19 @@ static public File getSketchbookFolder() {
15651568

15661569

15671570
static public File getSketchbookLibrariesFolder() {
1568-
return new File(getSketchbookFolder(), "libraries");
1571+
File libdir = new File(getSketchbookFolder(), "libraries");
1572+
if (!libdir.exists()) {
1573+
try {
1574+
libdir.mkdirs();
1575+
File readme = new File(libdir, "readme.txt");
1576+
FileWriter freadme = new FileWriter(readme);
1577+
freadme.write(_("For information on installing libraries, see: " +
1578+
"http://arduino.cc/en/Guide/Libraries\n"));
1579+
freadme.close();
1580+
} catch (Exception e) {
1581+
}
1582+
}
1583+
return libdir;
15691584
}
15701585

15711586

app/src/processing/app/Editor.java

+60-27
Original file line numberDiff line numberDiff line change
@@ -1073,9 +1073,10 @@ public void actionPerformed(ActionEvent e) {
10731073
item = newJMenuItemShift(_("Find in Reference"), 'F');
10741074
item.addActionListener(new ActionListener() {
10751075
public void actionPerformed(ActionEvent e) {
1076-
if (textarea.isSelectionActive()) {
1077-
handleFindReference();
1078-
}
1076+
// if (textarea.isSelectionActive()) {
1077+
// handleFindReference();
1078+
// }
1079+
handleFindReference();
10791080
}
10801081
});
10811082
menu.add(item);
@@ -1808,25 +1809,58 @@ protected void handleIndentOutdent(boolean indent) {
18081809
stopCompoundEdit();
18091810
}
18101811

1811-
1812-
protected void handleFindReference() {
1813-
String text = textarea.getSelectedText().trim();
1814-
1815-
if (text.length() == 0) {
1816-
statusNotice(_("First select a word to find in the reference."));
1817-
1818-
} else {
1819-
String referenceFile = PdeKeywords.getReference(text);
1820-
//System.out.println("reference file is " + referenceFile);
1821-
if (referenceFile == null) {
1822-
statusNotice(
1823-
I18n.format(_("No reference available for \"{0}\""), text)
1824-
);
1825-
} else {
1826-
Base.showReference(I18n.format(_("{0}.html"), referenceFile));
1827-
}
1828-
}
1829-
}
1812+
protected String getCurrentKeyword() {
1813+
String text = "";
1814+
if (textarea.getSelectedText() != null)
1815+
text = textarea.getSelectedText().trim();
1816+
1817+
try {
1818+
int current = textarea.getCaretPosition();
1819+
int startOffset = 0;
1820+
int endIndex = current;
1821+
String tmp = textarea.getDocument().getText(current, 1);
1822+
// TODO probably a regexp that matches Arduino lang special chars
1823+
// already exists.
1824+
String regexp = "[\\s\\n();\\\\.!='\\[\\]{}]";
1825+
1826+
while (!tmp.matches(regexp)) {
1827+
endIndex++;
1828+
tmp = textarea.getDocument().getText(endIndex, 1);
1829+
}
1830+
// For some reason document index start at 2.
1831+
// if( current - start < 2 ) return;
1832+
1833+
tmp = "";
1834+
while (!tmp.matches(regexp)) {
1835+
startOffset++;
1836+
if (current - startOffset < 0) {
1837+
tmp = textarea.getDocument().getText(0, 1);
1838+
break;
1839+
} else
1840+
tmp = textarea.getDocument().getText(current - startOffset, 1);
1841+
}
1842+
startOffset--;
1843+
1844+
int length = endIndex - current + startOffset;
1845+
text = textarea.getDocument().getText(current - startOffset, length);
1846+
1847+
} catch (BadLocationException bl) {
1848+
bl.printStackTrace();
1849+
} finally {
1850+
return text;
1851+
}
1852+
}
1853+
1854+
protected void handleFindReference() {
1855+
String text = getCurrentKeyword();
1856+
1857+
String referenceFile = PdeKeywords.getReference(text);
1858+
if (referenceFile == null) {
1859+
statusNotice(I18n.format(_("No reference available for \"{0}\""), text));
1860+
} else {
1861+
Base.showReference(I18n.format(_("{0}.html"), referenceFile));
1862+
}
1863+
}
18301864

18311865

18321866
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
@@ -2753,16 +2787,15 @@ public void show(Component component, int x, int y) {
27532787
copyItem.setEnabled(true);
27542788
discourseItem.setEnabled(true);
27552789

2756-
String sel = textarea.getSelectedText().trim();
2757-
referenceFile = PdeKeywords.getReference(sel);
2758-
referenceItem.setEnabled(referenceFile != null);
2759-
27602790
} else {
27612791
cutItem.setEnabled(false);
27622792
copyItem.setEnabled(false);
27632793
discourseItem.setEnabled(false);
2764-
referenceItem.setEnabled(false);
27652794
}
2795+
2796+
referenceFile = PdeKeywords.getReference(getCurrentKeyword());
2797+
referenceItem.setEnabled(referenceFile != null);
2798+
27662799
super.show(component, x, y);
27672800
}
27682801
}

app/src/processing/app/EditorListener.java

+8
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,14 @@ public boolean keyPressed(KeyEvent event) {
122122
}
123123
}
124124

125+
if ((event.getModifiers() & KeyEvent.CTRL_MASK) != 0) {
126+
// Consume ctrl-m(carriage return) keypresses
127+
if (code == KeyEvent.VK_M) {
128+
event.consume(); // does nothing
129+
return false;
130+
}
131+
}
132+
125133
if ((event.getModifiers() & KeyEvent.META_MASK) != 0) {
126134
//event.consume(); // does nothing
127135
return false;

app/src/processing/app/I18n.java

+14
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,25 @@
1212
*/
1313

1414
package processing.app;
15+
1516
import java.util.*;
17+
import java.util.Locale.*;
1618
import java.text.MessageFormat;
1719

1820
public class I18n {
21+
// start using current locale but still allow using the dropdown list later
1922
private static ResourceBundle i18n = ResourceBundle.getBundle("processing.app.Resources");
23+
public static Locale locale;
24+
25+
static protected void init (String language) {
26+
// there might be a null pointer exception ... most likely will never happen but the jvm gets mad
27+
try {
28+
if (language == null || language.trim().length() == 0) locale = Locale.getDefault();
29+
else locale = new Locale(language);
30+
i18n = ResourceBundle.getBundle("processing.app.Resources", locale);
31+
} catch (java.lang.NullPointerException e) {
32+
}
33+
}
2034

2135
public static String _(String s) {
2236
try {

app/src/processing/app/Preferences.java

+93-3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,75 @@ public class Preferences {
7979
static final String PROMPT_OK = _("OK");
8080
static final String PROMPT_BROWSE = _("Browse");
8181

82+
String[] languages = {
83+
_("System Default"),
84+
"العربية" + " (" + _("Arabic") + ")",
85+
"Aragonés" + " (" + _("Aragonese") + ")",
86+
"Català" + " (" + _("Catalan") + ")",
87+
"简体中文" + " (" + _("Chinese Simplified") + ")",
88+
"繁體中文" + " (" + _("Chinese Traditional") + ")",
89+
"Dansk" + " (" + _("Danish") + ")",
90+
"Nederlands" + " (" + _("Dutch") + ")",
91+
"English" + " (" + _("English") + ")",
92+
"Eesti" + " (" + _("Estonian") + ")",
93+
"Pilipino" + " (" + _("Filipino") + ")",
94+
"Français" + " (" + _("French") + ")",
95+
"Galego" + " (" + _("Galician") + ")",
96+
"Deutsch" + " (" + _("German") + ")",
97+
"ελληνικά" + " (" + _("Greek") + ")",
98+
"Magyar" + " (" + _("Hindi") + ")",
99+
"Magyar" + " (" + _("Hungarian") + ")",
100+
"Bahasa Indonesia" + " (" + _("Indonesian") + ")",
101+
"Italiano" + " (" + _("Italian") + ")",
102+
"日本語" + " (" + _("Japanese") + ")",
103+
"한국어" + " (" + _("Korean") + ")",
104+
"Latviešu" + " (" + _("Latvian") + ")",
105+
"Lietuvių Kalba" + " (" + _("Lithuaninan") + ")",
106+
"मराठी" + " (" + _("Marathi") + ")",
107+
"Norsk" + " (" + _("Norwegian") + ")",
108+
"فارسی" + " (" + _("Persian") + ")",
109+
"Język Polski" + " (" + _("Polish") + ")",
110+
"Português" + " (" + _("Portuguese") + " - Brazil)",
111+
"Português" + " (" + _("Portuguese") + " - Portugal)",
112+
"Română" + " (" + _("Romanian") + ")",
113+
"Русский" + " (" + _("Russian") + ")",
114+
"Español" + " (" + _("Spanish") + ")",
115+
"தமிழ்" + " (" + _("Tamil") + ")"};
116+
String[] languagesISO = {
117+
"",
118+
"ar",
119+
"an",
120+
"ca",
121+
"zh_cn",
122+
"zh_tw",
123+
"da",
124+
"nl",
125+
"en",
126+
"et",
127+
"tl",
128+
"fr",
129+
"gl",
130+
"de",
131+
"el",
132+
"hi",
133+
"hu",
134+
"id",
135+
"it",
136+
"ja",
137+
"ko",
138+
"lv",
139+
"lt",
140+
"mr",
141+
"no_nb",
142+
"fa",
143+
"pl",
144+
"pt_br",
145+
"pt_pt",
146+
"ro",
147+
"ru",
148+
"es",
149+
"ta"};
150+
82151
/**
83152
* Standardized width for buttons. Mac OS X 10.3 wants 70 as its default,
84153
* Windows XP needs 66, and my Ubuntu machine needs 80+, so 80 seems proper.
@@ -124,6 +193,7 @@ public class Preferences {
124193
JTextField fontSizeField;
125194
JCheckBox updateExtensionBox;
126195
JCheckBox autoAssociateBox;
196+
JComboBox comboLanguage;
127197

128198

129199
// the calling editor, so updates can be applied
@@ -270,9 +340,25 @@ public void actionPerformed(ActionEvent e) {
270340
top += vmax + GUI_BETWEEN;
271341

272342

343+
// Preferred language: [ ] (requires restart of Arduino)
344+
Container box = Box.createHorizontalBox();
345+
label = new JLabel(_("Editor language: "));
346+
box.add(label);
347+
comboLanguage = new JComboBox(languages);
348+
comboLanguage.setSelectedIndex((Arrays.asList(languagesISO)).indexOf(Preferences.get("editor.languages.current")));
349+
box.add(comboLanguage);
350+
label = new JLabel(_(" (requires restart of Arduino)"));
351+
box.add(label);
352+
pain.add(box);
353+
d = box.getPreferredSize();
354+
box.setForeground(Color.gray);
355+
box.setBounds(left, top, d.width, d.height);
356+
right = Math.max(right, left + d.width);
357+
top += d.height + GUI_BETWEEN;
358+
273359
// Editor font size [ ]
274360

275-
Container box = Box.createHorizontalBox();
361+
box = Box.createHorizontalBox();
276362
label = new JLabel(_("Editor font size: "));
277363
box.add(label);
278364
fontSizeField = new JTextField(4);
@@ -303,7 +389,7 @@ public void actionPerformed(ActionEvent e) {
303389

304390
// [ ] Verify code after upload
305391

306-
verifyUploadBox = new JCheckBox("Verify code after upload");
392+
verifyUploadBox = new JCheckBox(_("Verify code after upload"));
307393
pain.add(verifyUploadBox);
308394
d = verifyUploadBox.getPreferredSize();
309395
verifyUploadBox.setBounds(left, top, d.width + 10, d.height);
@@ -350,7 +436,6 @@ public void actionPerformed(ActionEvent e) {
350436
top += d.height + GUI_BETWEEN;
351437
}
352438

353-
354439
// More preferences are in the ...
355440

356441
label = new JLabel(_("More preferences can be edited directly in the file"));
@@ -539,6 +624,11 @@ protected void applyFrame() {
539624

540625
setBoolean("editor.update_extension", updateExtensionBox.isSelected());
541626

627+
// adds the selected language to the preferences file
628+
Object newItem = comboLanguage.getSelectedItem();
629+
int pos = (Arrays.asList(languages)).indexOf(newItem.toString()); // position in the languages array
630+
set("editor.languages.current",(Arrays.asList(languagesISO)).get(pos));
631+
542632
editor.applyPreferences();
543633
}
544634

0 commit comments

Comments
 (0)