Skip to content

Commit 3d8219c

Browse files
author
Federico Fissore
committed
Ensure hyperlinks are coloured using theme.txt colour
Enabling [CTRL,CMD]+click to open hyperlinks
1 parent f83f6cb commit 3d8219c

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

app/src/processing/app/Editor.java

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -927,23 +927,32 @@ protected String findClassInZipFile(String base, File file) {
927927
return null;
928928
}
929929

930-
930+
931931
protected SketchTextArea createTextArea() throws IOException {
932-
SketchTextArea textArea = new SketchTextArea(base.getPdeKeywords());
933-
textArea.requestFocusInWindow();
934-
textArea.setMarkOccurrences(true);
935-
textArea.setMarginLineEnabled(false);
936-
textArea.setCodeFoldingEnabled(Preferences.getBoolean("editor.codefolding"));
937-
textArea.setAntiAliasingEnabled(Preferences.getBoolean("editor.antialias"));
938-
// textArea.setClearWhitespaceLinesEnabled(false);
939-
textArea.setTabsEmulated(Preferences.getBoolean("editor.tabs.expand"));
940-
textArea.setTabSize(Preferences.getInteger("editor.tabs.size"));
941-
textArea.setEditorListener(new EditorListener(this));
942-
943-
ToolTipManager.sharedInstance().registerComponent(textArea);
944-
945-
configurePopupMenu(textArea);
946-
return textArea;
932+
SketchTextArea textArea = new SketchTextArea(base.getPdeKeywords());
933+
textArea.requestFocusInWindow();
934+
textArea.setMarkOccurrences(true);
935+
textArea.setMarginLineEnabled(false);
936+
textArea.setCodeFoldingEnabled(Preferences.getBoolean("editor.codefolding"));
937+
textArea.setAntiAliasingEnabled(Preferences.getBoolean("editor.antialias"));
938+
textArea.setTabsEmulated(Preferences.getBoolean("editor.tabs.expand"));
939+
textArea.setTabSize(Preferences.getInteger("editor.tabs.size"));
940+
textArea.setEditorListener(new EditorListener(this));
941+
textArea.addHyperlinkListener(new HyperlinkListener() {
942+
@Override
943+
public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) {
944+
try {
945+
base.getPlatform().openURL(hyperlinkEvent.getURL().toExternalForm());
946+
} catch (Exception e) {
947+
Base.showWarning(e.getMessage(), e.getMessage(), e);
948+
}
949+
}
950+
});
951+
952+
ToolTipManager.sharedInstance().registerComponent(textArea);
953+
954+
configurePopupMenu(textArea);
955+
return textArea;
947956
}
948957

949958
protected JMenuItem createToolMenuItem(String className) {

app/src/processing/app/syntax/SketchTextArea.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public void setTheme(String name) throws IOException {
103103
setUseSelectedTextColor(false);
104104
setSelectionColor(processing.app.Theme.getColor("editor.selection.color"));
105105
setMatchedBracketBorderColor(processing.app.Theme.getColor("editor.brackethighlight.color"));
106+
setHyperlinkForeground((Color) processing.app.Theme.getStyledFont("url", getFont()).get("color"));
106107

107108
setSyntaxTheme(TokenTypes.DATA_TYPE, "data_type");
108109
setSyntaxTheme(TokenTypes.FUNCTION, "function");

0 commit comments

Comments
 (0)