Merge branch 's17n'

This commit is contained in:
David A. Mellis 2012-08-23 10:54:59 -04:00
commit 127cbf5da5
3 changed files with 51 additions and 25 deletions

3
.gitignore vendored
View File

@ -14,4 +14,5 @@ hardware/arduino/bootloaders/caterina_LUFA/Caterina.elf
hardware/arduino/bootloaders/caterina_LUFA/Caterina.eep hardware/arduino/bootloaders/caterina_LUFA/Caterina.eep
hardware/arduino/bootloaders/caterina_LUFA/.dep/ hardware/arduino/bootloaders/caterina_LUFA/.dep/
.gitignore .gitignore
build/windows/work/ build/windows/work/
build/linux/work/

View File

@ -1073,9 +1073,10 @@ public class Editor extends JFrame implements RunnerListener {
item = newJMenuItemShift(_("Find in Reference"), 'F'); item = newJMenuItemShift(_("Find in Reference"), 'F');
item.addActionListener(new ActionListener() { item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (textarea.isSelectionActive()) { // if (textarea.isSelectionActive()) {
handleFindReference(); // handleFindReference();
} // }
handleFindReference();
} }
}); });
menu.add(item); menu.add(item);
@ -1809,24 +1810,51 @@ public class Editor extends JFrame implements RunnerListener {
} }
protected void handleFindReference() { protected void handleFindReference() {
String text = textarea.getSelectedText().trim(); String text = "";
if( textarea.getSelectedText() != null )
if (text.length() == 0) { text = textarea.getSelectedText().trim();
statusNotice(_("First select a word to find in the reference."));
try {
} else { int current = textarea.getCaretPosition();
String referenceFile = PdeKeywords.getReference(text); int startOffset = 0;
//System.out.println("reference file is " + referenceFile); int endIndex = current;
if (referenceFile == null) { String tmp = textarea.getDocument().getText(current,1);
statusNotice( // TODO probably a regexp that matches Arduino lang special chars already exists.
I18n.format(_("No reference available for \"{0}\""), text) String regexp = "[\\s\\n();\\\\.!='\\[\\]{}]";
);
} else { while(!tmp.matches(regexp)) {
Base.showReference(I18n.format(_("{0}.html"), referenceFile)); endIndex++;
} tmp = textarea.getDocument().getText(endIndex,1);
} }
} // For some reason document index start at 2.
//if( current - start < 2 ) return;
tmp = "";
while(!tmp.matches(regexp)) {
startOffset++;
if( current - startOffset < 0) {
tmp = textarea.getDocument().getText(0, 1);
break;
}
else
tmp = textarea.getDocument().getText(current - startOffset, 1);
}
startOffset--;
int length = endIndex - current + startOffset;
text = textarea.getDocument().getText(current - startOffset, length);
} catch (BadLocationException bl ) {
bl.printStackTrace();
}
String referenceFile = PdeKeywords.getReference(text);
if (referenceFile == null) {
statusNotice(I18n.format(_("No reference available for \"{0}\""), text));
} else {
Base.showReference(I18n.format(_("{0}.html"), referenceFile));
}
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

View File

@ -178,9 +178,6 @@
#: Editor.java:1255 #: Editor.java:1255
!Use\ Selection\ For\ Find= !Use\ Selection\ For\ Find=
#: Editor.java:1816
!First\ select\ a\ word\ to\ find\ in\ the\ reference.=
#: Editor.java:1823 #: Editor.java:1823
#, java-format #, java-format
!No\ reference\ available\ for\ "{0}"= !No\ reference\ available\ for\ "{0}"=