Skip to content

Commit eb42243

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

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
@@ -956,23 +956,32 @@ protected String findClassInZipFile(String base, File file) {
956956
return null;
957957
}
958958

959-
959+
960960
protected SketchTextArea createTextArea() throws IOException {
961-
SketchTextArea textArea = new SketchTextArea(base.getPdeKeywords());
962-
textArea.requestFocusInWindow();
963-
textArea.setMarkOccurrences(true);
964-
textArea.setMarginLineEnabled(false);
965-
textArea.setCodeFoldingEnabled(PreferencesData.getBoolean("editor.codefolding"));
966-
textArea.setAntiAliasingEnabled(PreferencesData.getBoolean("editor.antialias"));
967-
// textArea.setClearWhitespaceLinesEnabled(false);
968-
textArea.setTabsEmulated(PreferencesData.getBoolean("editor.tabs.expand"));
969-
textArea.setTabSize(PreferencesData.getInteger("editor.tabs.size"));
970-
textArea.setEditorListener(new EditorListener(this));
971-
972-
ToolTipManager.sharedInstance().registerComponent(textArea);
973-
974-
configurePopupMenu(textArea);
975-
return textArea;
961+
SketchTextArea textArea = new SketchTextArea(base.getPdeKeywords());
962+
textArea.requestFocusInWindow();
963+
textArea.setMarkOccurrences(true);
964+
textArea.setMarginLineEnabled(false);
965+
textArea.setCodeFoldingEnabled(PreferencesData.getBoolean("editor.codefolding"));
966+
textArea.setAntiAliasingEnabled(PreferencesData.getBoolean("editor.antialias"));
967+
textArea.setTabsEmulated(PreferencesData.getBoolean("editor.tabs.expand"));
968+
textArea.setTabSize(PreferencesData.getInteger("editor.tabs.size"));
969+
textArea.setEditorListener(new EditorListener(this));
970+
textArea.addHyperlinkListener(new HyperlinkListener() {
971+
@Override
972+
public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) {
973+
try {
974+
base.getPlatform().openURL(hyperlinkEvent.getURL().toExternalForm());
975+
} catch (Exception e) {
976+
Base.showWarning(e.getMessage(), e.getMessage(), e);
977+
}
978+
}
979+
});
980+
981+
ToolTipManager.sharedInstance().registerComponent(textArea);
982+
983+
configurePopupMenu(textArea);
984+
return textArea;
976985
}
977986

978987
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
@@ -112,6 +112,7 @@ public void setTheme(String name) throws IOException {
112112
setUseSelectedTextColor(false);
113113
setSelectionColor(processing.app.Theme.getColor("editor.selection.color"));
114114
setMatchedBracketBorderColor(processing.app.Theme.getColor("editor.brackethighlight.color"));
115+
setHyperlinkForeground((Color) processing.app.Theme.getStyledFont("url", getFont()).get("color"));
115116

116117
setSyntaxTheme(TokenTypes.DATA_TYPE, "data_type");
117118
setSyntaxTheme(TokenTypes.FUNCTION, "function");

0 commit comments

Comments
 (0)