Skip to content

Commit

Permalink
make links action to ctrl+click
Browse files Browse the repository at this point in the history
  • Loading branch information
RamanaReddy0M committed Sep 11, 2024
1 parent e5757d1 commit 948cb70
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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();
}
Expand All @@ -275,7 +275,6 @@ public void mouseClicked(MouseEvent e) {
return textEditor;
}


private String getUrlAtOffset(RSyntaxTextArea textEditor, int offset) {
try {
int start = offset;
Expand All @@ -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());
Expand Down Expand Up @@ -567,4 +565,4 @@ private void executeButtonClick() {
this.nucleiGeneratorSettings::logError);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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" +
Expand Down

0 comments on commit 948cb70

Please sign in to comment.