mirror of https://github.com/noisymime/Arduino.git
Merge branch 's17n'
This commit is contained in:
commit
127cbf5da5
|
@ -15,3 +15,4 @@ hardware/arduino/bootloaders/caterina_LUFA/Caterina.eep
|
|||
hardware/arduino/bootloaders/caterina_LUFA/.dep/
|
||||
.gitignore
|
||||
build/windows/work/
|
||||
build/linux/work/
|
||||
|
|
|
@ -1073,10 +1073,11 @@ public class Editor extends JFrame implements RunnerListener {
|
|||
item = newJMenuItemShift(_("Find in Reference"), 'F');
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (textarea.isSelectionActive()) {
|
||||
// if (textarea.isSelectionActive()) {
|
||||
// handleFindReference();
|
||||
// }
|
||||
handleFindReference();
|
||||
}
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
|
@ -1810,23 +1811,50 @@ public class Editor extends JFrame implements RunnerListener {
|
|||
|
||||
|
||||
protected void handleFindReference() {
|
||||
String text = textarea.getSelectedText().trim();
|
||||
String text = "";
|
||||
if( textarea.getSelectedText() != null )
|
||||
text = textarea.getSelectedText().trim();
|
||||
|
||||
if (text.length() == 0) {
|
||||
statusNotice(_("First select a word to find in the reference."));
|
||||
try {
|
||||
int current = textarea.getCaretPosition();
|
||||
int startOffset = 0;
|
||||
int endIndex = current;
|
||||
String tmp = textarea.getDocument().getText(current,1);
|
||||
// TODO probably a regexp that matches Arduino lang special chars already exists.
|
||||
String regexp = "[\\s\\n();\\\\.!='\\[\\]{}]";
|
||||
|
||||
while(!tmp.matches(regexp)) {
|
||||
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();
|
||||
}
|
||||
|
||||
} else {
|
||||
String referenceFile = PdeKeywords.getReference(text);
|
||||
//System.out.println("reference file is " + referenceFile);
|
||||
if (referenceFile == null) {
|
||||
statusNotice(
|
||||
I18n.format(_("No reference available for \"{0}\""), text)
|
||||
);
|
||||
statusNotice(I18n.format(_("No reference available for \"{0}\""), text));
|
||||
} else {
|
||||
Base.showReference(I18n.format(_("{0}.html"), referenceFile));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
|
|
@ -178,9 +178,6 @@
|
|||
#: Editor.java:1255
|
||||
!Use\ Selection\ For\ Find=
|
||||
|
||||
#: Editor.java:1816
|
||||
!First\ select\ a\ word\ to\ find\ in\ the\ reference.=
|
||||
|
||||
#: Editor.java:1823
|
||||
#, java-format
|
||||
!No\ reference\ available\ for\ "{0}"=
|
||||
|
|
Loading…
Reference in New Issue