Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request Web Link Pop-Up #12209

Open
PaltryProgrammer opened this issue Sep 22, 2022 · 3 comments
Open

Feature Request Web Link Pop-Up #12209

PaltryProgrammer opened this issue Sep 22, 2022 · 3 comments

Comments

@PaltryProgrammer
Copy link

Greetings and Kind Regards BowPad has a nice feature to wit i.e. upon hovering over a web link a pop-up box appears upon which can be clicked upon which then transports to the web page as per usual. The pop-up box also reminds which mouse click key combination to utilize to perform same if clicking on the link instead of the pop-up box. I find these very helpful as I do not care for combinations and as each editor requires a different such combination making memory of each uncertain and unreliable so becomes a nuisance as then one must attempt every possible combination to wit i.e. Ctrl+click , Shift+click , Alt+click or double click until one discovers the correct combination for any particular editor - Kind Regards - Cheerio
Please see attached GIF for demonstration of said web link pop-up
Request Web Link Pop-Up

@alankilborn
Copy link
Contributor

Personally, I don't like it, as it just would provide more visual clutter/distraction for me.
If it were optional I suppose it would be fine.
Perhaps something can be scripted to provide the functionality.

@alankilborn
Copy link
Contributor

This PythonScript can be used as a workaround, or as a simple demo showing it actually working in Notepad++:

# -*- coding: utf-8 -*-
from __future__ import print_function

# references:
#  https://github.com/notepad-plus-plus/notepad-plus-plus/issues/12209 "Feature Request Web Link Pop-Up"

from Npp import *

#-------------------------------------------------------------------------------

class UHT(object):

    def __init__(self):
        self.debug = True if 0 else False
        self.URL_INDIC = 8  # URL_INDIC is used in N++ source code
        editor.setMouseDwellTime(200)  # the less the value the greater the chance to get false info
        editor.callback(self.on_mouse_dwell_start_callback, [SCINTILLANOTIFICATION.DWELLSTART])

    def on_mouse_dwell_start_callback(self, args):
        self.print('DWELLSTART:', args)
        self.dwell_pos = editor.charPositionFromPointClose(args['x'], args['y'])
        (start_pos, end_pos) = self.get_indicator_range(self.URL_INDIC, self.dwell_pos)
        self.print('start_pos:', start_pos, 'end_pos:', end_pos)
        if start_pos != end_pos:
            self.call_tip_display('Double-click to follow link; single-click to edit')
        else:
            if editor.callTipActive(): editor.callTipCancel()

    def call_tip_display(self, text, above=False):
        if editor.callTipActive(): editor.callTipCancel()
        #editor.callTipSetPosition(False)  # leave this False because the N++ regex search tooltip will be affected
        editor.callTipShow(self.dwell_pos, text)

    def get_indicator_range(self, indic_number, position=None):
        # similar to ScintillaEditView::getIndicatorRange() in N++ source
        # https://github.com/notepad-plus-plus/notepad-plus-plus/blob/8f38707d33d869a5b8f5014dbb18619b166486a0/PowerEditor/src/ScitillaComponent/ScintillaEditView.h#L562
        curr_pos = editor.getCurrentPos() if position == None else position
        indic_mask = editor.indicatorAllOnFor(curr_pos)
        if (indic_mask & (1 << indic_number)) != 0:
            start_pos = editor.indicatorStart(indic_number, curr_pos)
            end_pos = editor.indicatorEnd(indic_number, curr_pos)
            if curr_pos >= start_pos and curr_pos <= end_pos:
                return (start_pos, end_pos)
        return (0, 0)

    def print(self, *args):
        if self.debug:
            #console.show()
            print('UHT:', *args)

#-------------------------------------------------------------------------------

# to run via another file, e.g., startup.py, put these lines (uncommented and unindented) in that file:
#  import UrlHoverTip
#  uht = UrlHoverTip.UHT()

if __name__ == '__main__': UHT()

Here's a screenshot of it working:

image

@alankilborn
Copy link
Contributor

Personally, I don't like it, as it just would provide more visual clutter/distraction for me.

And even while running the provided script to just experiment with it, it did indeed do that. The pop up hover tip annoys me...a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants