Skip to content

Commit 127cbf5

Browse files
committed
Merge branch 's17n'
2 parents bc79a99 + 0a0b573 commit 127cbf5

File tree

3 files changed

+51
-25
lines changed

3 files changed

+51
-25
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ hardware/arduino/bootloaders/caterina_LUFA/Caterina.elf
1414
hardware/arduino/bootloaders/caterina_LUFA/Caterina.eep
1515
hardware/arduino/bootloaders/caterina_LUFA/.dep/
1616
.gitignore
17-
build/windows/work/
17+
build/windows/work/
18+
build/linux/work/

app/src/processing/app/Editor.java

+49-21
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);
@@ -1809,24 +1810,51 @@ protected void handleIndentOutdent(boolean indent) {
18091810
}
18101811

18111812

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-
}
1813+
protected void handleFindReference() {
1814+
String text = "";
1815+
if( textarea.getSelectedText() != null )
1816+
text = textarea.getSelectedText().trim();
1817+
1818+
try {
1819+
int current = textarea.getCaretPosition();
1820+
int startOffset = 0;
1821+
int endIndex = current;
1822+
String tmp = textarea.getDocument().getText(current,1);
1823+
// TODO probably a regexp that matches Arduino lang special chars 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+
}
1840+
else
1841+
tmp = textarea.getDocument().getText(current - startOffset, 1);
1842+
}
1843+
startOffset--;
1844+
1845+
int length = endIndex - current + startOffset;
1846+
text = textarea.getDocument().getText(current - startOffset, length);
1847+
} catch (BadLocationException bl ) {
1848+
bl.printStackTrace();
1849+
}
1850+
1851+
String referenceFile = PdeKeywords.getReference(text);
1852+
if (referenceFile == null) {
1853+
statusNotice(I18n.format(_("No reference available for \"{0}\""), text));
1854+
} else {
1855+
Base.showReference(I18n.format(_("{0}.html"), referenceFile));
1856+
}
1857+
}
18301858

18311859

18321860
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

app/src/processing/app/Resources_en.properties

-3
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,6 @@
178178
#: Editor.java:1255
179179
!Use\ Selection\ For\ Find=
180180

181-
#: Editor.java:1816
182-
!First\ select\ a\ word\ to\ find\ in\ the\ reference.=
183-
184181
#: Editor.java:1823
185182
#, java-format
186183
!No\ reference\ available\ for\ "{0}"=

0 commit comments

Comments
 (0)