mirror of https://github.com/noisymime/Arduino.git
Merge branch 's17n'
This commit is contained in:
commit
f32ff0022e
|
@ -1809,8 +1809,7 @@ public class Editor extends JFrame implements RunnerListener {
|
|||
stopCompoundEdit();
|
||||
}
|
||||
|
||||
|
||||
protected void handleFindReference() {
|
||||
protected String getCurrentKeyword() {
|
||||
String text = "";
|
||||
if (textarea.getSelectedText() != null)
|
||||
text = textarea.getSelectedText().trim();
|
||||
|
@ -1820,7 +1819,8 @@ public class Editor extends JFrame implements RunnerListener {
|
|||
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.
|
||||
// TODO probably a regexp that matches Arduino lang special chars
|
||||
// already exists.
|
||||
String regexp = "[\\s\\n();\\\\.!='\\[\\]{}]";
|
||||
|
||||
while (!tmp.matches(regexp)) {
|
||||
|
@ -1836,17 +1836,23 @@ public class Editor extends JFrame implements RunnerListener {
|
|||
if (current - startOffset < 0) {
|
||||
tmp = textarea.getDocument().getText(0, 1);
|
||||
break;
|
||||
}
|
||||
else
|
||||
} 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();
|
||||
} finally {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleFindReference() {
|
||||
String text = getCurrentKeyword();
|
||||
|
||||
String referenceFile = PdeKeywords.getReference(text);
|
||||
if (referenceFile == null) {
|
||||
|
@ -2781,16 +2787,15 @@ public class Editor extends JFrame implements RunnerListener {
|
|||
copyItem.setEnabled(true);
|
||||
discourseItem.setEnabled(true);
|
||||
|
||||
String sel = textarea.getSelectedText().trim();
|
||||
referenceFile = PdeKeywords.getReference(sel);
|
||||
referenceItem.setEnabled(referenceFile != null);
|
||||
|
||||
} else {
|
||||
cutItem.setEnabled(false);
|
||||
copyItem.setEnabled(false);
|
||||
discourseItem.setEnabled(false);
|
||||
referenceItem.setEnabled(false);
|
||||
}
|
||||
|
||||
referenceFile = PdeKeywords.getReference(getCurrentKeyword());
|
||||
referenceItem.setEnabled(referenceFile != null);
|
||||
|
||||
super.show(component, x, y);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue