From 948cb7095fa257be08a583328a719db43bf2aab8 Mon Sep 17 00:00:00 2001 From: Ramana Reddy Date: Wed, 11 Sep 2024 10:59:06 +0530 Subject: [PATCH] make links action to ctrl+click --- .../nuclei/gui/TemplateGeneratorTab.java | 10 ++++------ .../nuclei/gui/TemplateGeneratorWindow.java | 2 ++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/projectdiscovery/nuclei/gui/TemplateGeneratorTab.java b/src/main/java/io/projectdiscovery/nuclei/gui/TemplateGeneratorTab.java index 61d4e2c..fe8fc0d 100644 --- a/src/main/java/io/projectdiscovery/nuclei/gui/TemplateGeneratorTab.java +++ b/src/main/java/io/projectdiscovery/nuclei/gui/TemplateGeneratorTab.java @@ -226,7 +226,6 @@ private void setupAutoCompletion(RSyntaxTextArea textEditor) { } } - private RSyntaxTextArea createSmartTextEditor(String templateYaml) { // TODO https://github.com/bobbylight/RSyntaxTextArea/issues/269 JTextComponent.removeKeymap("RTextAreaKeymap"); @@ -255,15 +254,16 @@ private RSyntaxTextArea createSmartTextEditor(String templateYaml) { setupAutoCompletion(textEditor); + // Add mouse listener for Ctrl + Click textEditor.addMouseListener(new MouseInputAdapter() { @Override public void mouseClicked(MouseEvent e) { - if (e.getClickCount() == 2) { // Trigger on double-click + if (e.getClickCount() == 1 && e.isControlDown()) { // Trigger on Ctrl + Click int offset = textEditor.viewToModel2D(e.getPoint()); String url = getUrlAtOffset(textEditor, offset); if (url != null) { try { - Desktop.getDesktop().browse(new URI(url)); + SwingUtils.openWebPage(new URI(url).toURL()); } catch (IOException | URISyntaxException ex) { ex.printStackTrace(); } @@ -275,7 +275,6 @@ public void mouseClicked(MouseEvent e) { return textEditor; } - private String getUrlAtOffset(RSyntaxTextArea textEditor, int offset) { try { int start = offset; @@ -297,7 +296,6 @@ private String getUrlAtOffset(RSyntaxTextArea textEditor, int offset) { return null; } - private JMenu createTemplateEditorMenuItems() { final JMenu templateMenu = new JMenu("Add"); templateMenu.add(createTemplateEditorClassificationMenu()); @@ -567,4 +565,4 @@ private void executeButtonClick() { this.nucleiGeneratorSettings::logError); } } -} +} \ No newline at end of file diff --git a/src/main/java/io/projectdiscovery/nuclei/gui/TemplateGeneratorWindow.java b/src/main/java/io/projectdiscovery/nuclei/gui/TemplateGeneratorWindow.java index 9085ea6..d7fa187 100644 --- a/src/main/java/io/projectdiscovery/nuclei/gui/TemplateGeneratorWindow.java +++ b/src/main/java/io/projectdiscovery/nuclei/gui/TemplateGeneratorWindow.java @@ -113,6 +113,8 @@ public static void main(String[] args) throws Exception { " author: forgedhallpass\n" + " name: Template Name\n" + " severity: info\n" + + "reference:\n"+ + " - https://github.com/projectdiscovery/nuclei-templates\n"+ "http:\n" + " - raw:\n" + " - |\n" +