mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-01 12:24:14 +01:00
Code cleanup
This commit is contained in:
parent
ffff480e9b
commit
6848614ce2
@ -86,7 +86,7 @@ public class SketchTextArea extends RSyntaxTextArea {
|
||||
installFeatures();
|
||||
}
|
||||
|
||||
protected void installFeatures() throws IOException {
|
||||
private void installFeatures() throws IOException {
|
||||
setTheme(PreferencesData.get("editor.syntax_theme", "default"));
|
||||
|
||||
setLinkGenerator(new DocLinkGenerator(pdeKeywords));
|
||||
@ -96,7 +96,7 @@ public class SketchTextArea extends RSyntaxTextArea {
|
||||
setSyntaxEditingStyle(SYNTAX_STYLE_CPLUSPLUS);
|
||||
}
|
||||
|
||||
public void setTheme(String name) throws IOException {
|
||||
private void setTheme(String name) throws IOException {
|
||||
FileInputStream defaultXmlInputStream = null;
|
||||
try {
|
||||
defaultXmlInputStream = new FileInputStream(new File(BaseNoGui.getContentFile("lib"), "theme/syntax/" + name + ".xml"));
|
||||
@ -143,7 +143,7 @@ public class SketchTextArea extends RSyntaxTextArea {
|
||||
|
||||
// Removing the default focus traversal keys
|
||||
// This is because the DefaultKeyboardFocusManager handles the keypress and consumes the event
|
||||
protected void fixControlTab() {
|
||||
private void fixControlTab() {
|
||||
removeCTRLTabFromFocusTraversal();
|
||||
|
||||
removeCTRLSHIFTTabFromFocusTraversal();
|
||||
@ -151,23 +151,18 @@ public class SketchTextArea extends RSyntaxTextArea {
|
||||
|
||||
private void removeCTRLSHIFTTabFromFocusTraversal() {
|
||||
KeyStroke ctrlShiftTab = KeyStroke.getKeyStroke("ctrl shift TAB");
|
||||
Set<AWTKeyStroke> backwardKeys = new HashSet<AWTKeyStroke>(this.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
|
||||
Set<AWTKeyStroke> backwardKeys = new HashSet<>(this.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
|
||||
backwardKeys.remove(ctrlShiftTab);
|
||||
}
|
||||
|
||||
private void removeCTRLTabFromFocusTraversal() {
|
||||
KeyStroke ctrlTab = KeyStroke.getKeyStroke("ctrl TAB");
|
||||
Set<AWTKeyStroke> forwardKeys = new HashSet<AWTKeyStroke>(this.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
|
||||
Set<AWTKeyStroke> forwardKeys = new HashSet<>(this.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
|
||||
forwardKeys.remove(ctrlTab);
|
||||
this.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forwardKeys);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void select(int selectionStart, int selectionEnd) {
|
||||
super.select(selectionStart, selectionEnd);
|
||||
}
|
||||
|
||||
public boolean isSelectionActive() {
|
||||
return this.getSelectedText() != null;
|
||||
}
|
||||
@ -221,17 +216,6 @@ public class SketchTextArea extends RSyntaxTextArea {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JPopupMenu createPopupMenu() {
|
||||
JPopupMenu menu = super.createPopupMenu();
|
||||
return menu;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configurePopupMenu(JPopupMenu popupMenu) {
|
||||
super.configurePopupMenu(popupMenu);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RTAMouseListener createMouseListener() {
|
||||
return new SketchTextAreaMouseListener(this);
|
||||
@ -242,7 +226,7 @@ public class SketchTextArea extends RSyntaxTextArea {
|
||||
int offset = getLineStartOffset(line);
|
||||
int end = getLineEndOffset(line);
|
||||
getDocument().getText(offset, end - offset, segment);
|
||||
} catch (BadLocationException e) {
|
||||
} catch (BadLocationException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@ -271,16 +255,16 @@ public class SketchTextArea extends RSyntaxTextArea {
|
||||
|
||||
@Override
|
||||
public LinkGeneratorResult isLinkAtOffset(RSyntaxTextArea textArea, final int offs) {
|
||||
Token token = textArea.modelToToken(offs);
|
||||
if (token == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final Token token = textArea.modelToToken(offs);
|
||||
String reference = pdeKeywords.getReference(token.getLexeme());
|
||||
|
||||
final String reference = pdeKeywords.getReference(token.getLexeme());
|
||||
if (reference != null || (token.getType() == TokenTypes.DATA_TYPE || token.getType() == TokenTypes.VARIABLE || token.getType() == TokenTypes.FUNCTION)) {
|
||||
|
||||
// LOG.fine("reference: " + reference + ", match: " + (token.getType() == TokenTypes.DATA_TYPE || token.getType() == TokenTypes.VARIABLE || token.getType() == TokenTypes.FUNCTION));
|
||||
|
||||
if (token != null && (reference != null || (token.getType() == TokenTypes.DATA_TYPE || token.getType() == TokenTypes.VARIABLE || token.getType() == TokenTypes.FUNCTION))) {
|
||||
|
||||
LinkGeneratorResult generatorResult = new LinkGeneratorResult() {
|
||||
return new LinkGeneratorResult() {
|
||||
|
||||
@Override
|
||||
public int getSourceOffset() {
|
||||
@ -297,8 +281,6 @@ public class SketchTextArea extends RSyntaxTextArea {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
return generatorResult;
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -316,7 +298,7 @@ public class SketchTextArea extends RSyntaxTextArea {
|
||||
private boolean isScanningForLinks;
|
||||
private int hoveredOverLinkOffset = -1;
|
||||
|
||||
protected SketchTextAreaMouseListener(RTextArea textArea) {
|
||||
SketchTextAreaMouseListener(RTextArea textArea) {
|
||||
super(textArea);
|
||||
insets = new Insets(0, 0, 0, 0);
|
||||
}
|
||||
@ -458,7 +440,7 @@ public class SketchTextArea extends RSyntaxTextArea {
|
||||
if (isScanningForLinks) {
|
||||
Cursor c = getCursor();
|
||||
isScanningForLinks = false;
|
||||
if (c != null && c.getType() == Cursor.HAND_CURSOR) {
|
||||
if (c.getType() == Cursor.HAND_CURSOR) {
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
|
||||
repaint(); // TODO: Repaint just the affected line.
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user