From eb42243475d59a83d991169e7a80e63d9489c5e5 Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Tue, 28 Apr 2015 12:36:42 +0200 Subject: [PATCH] Ensure hyperlinks are coloured using theme.txt colour Enabling [CTRL,CMD]+click to open hyperlinks --- app/src/processing/app/Editor.java | 41 +++++++++++-------- .../processing/app/syntax/SketchTextArea.java | 1 + 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 3c9d5d59a..44691510d 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -956,23 +956,32 @@ public class Editor extends JFrame implements RunnerListener { return null; } - + protected SketchTextArea createTextArea() throws IOException { - SketchTextArea textArea = new SketchTextArea(base.getPdeKeywords()); - textArea.requestFocusInWindow(); - textArea.setMarkOccurrences(true); - textArea.setMarginLineEnabled(false); - textArea.setCodeFoldingEnabled(PreferencesData.getBoolean("editor.codefolding")); - textArea.setAntiAliasingEnabled(PreferencesData.getBoolean("editor.antialias")); -// textArea.setClearWhitespaceLinesEnabled(false); - textArea.setTabsEmulated(PreferencesData.getBoolean("editor.tabs.expand")); - textArea.setTabSize(PreferencesData.getInteger("editor.tabs.size")); - textArea.setEditorListener(new EditorListener(this)); - - ToolTipManager.sharedInstance().registerComponent(textArea); - - configurePopupMenu(textArea); - return textArea; + SketchTextArea textArea = new SketchTextArea(base.getPdeKeywords()); + textArea.requestFocusInWindow(); + textArea.setMarkOccurrences(true); + textArea.setMarginLineEnabled(false); + textArea.setCodeFoldingEnabled(PreferencesData.getBoolean("editor.codefolding")); + textArea.setAntiAliasingEnabled(PreferencesData.getBoolean("editor.antialias")); + textArea.setTabsEmulated(PreferencesData.getBoolean("editor.tabs.expand")); + textArea.setTabSize(PreferencesData.getInteger("editor.tabs.size")); + textArea.setEditorListener(new EditorListener(this)); + textArea.addHyperlinkListener(new HyperlinkListener() { + @Override + public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) { + try { + base.getPlatform().openURL(hyperlinkEvent.getURL().toExternalForm()); + } catch (Exception e) { + Base.showWarning(e.getMessage(), e.getMessage(), e); + } + } + }); + + ToolTipManager.sharedInstance().registerComponent(textArea); + + configurePopupMenu(textArea); + return textArea; } protected JMenuItem createToolMenuItem(String className) { diff --git a/app/src/processing/app/syntax/SketchTextArea.java b/app/src/processing/app/syntax/SketchTextArea.java index 8d5381cbe..b54660757 100644 --- a/app/src/processing/app/syntax/SketchTextArea.java +++ b/app/src/processing/app/syntax/SketchTextArea.java @@ -112,6 +112,7 @@ public class SketchTextArea extends RSyntaxTextArea { setUseSelectedTextColor(false); setSelectionColor(processing.app.Theme.getColor("editor.selection.color")); setMatchedBracketBorderColor(processing.app.Theme.getColor("editor.brackethighlight.color")); + setHyperlinkForeground((Color) processing.app.Theme.getStyledFont("url", getFont()).get("color")); setSyntaxTheme(TokenTypes.DATA_TYPE, "data_type"); setSyntaxTheme(TokenTypes.FUNCTION, "function");