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

Add keyword shortcuts to loop through NppGTags search results #13

Open
pidgeon777 opened this issue Dec 17, 2018 · 7 comments
Open

Add keyword shortcuts to loop through NppGTags search results #13

pidgeon777 opened this issue Dec 17, 2018 · 7 comments

Comments

@pidgeon777
Copy link

It would be cool to have two customizable keyboard shortcuts which could be assigned to:

  • Go to next search result
  • Go to previous search result

The NppGTags search results panel should show the actually selected item by highlighting the corresponding row at every activation of the shortcut (it already happens when manually clicking on the results).

@pnedev
Copy link
Owner

pnedev commented Jan 2, 2019

Hi @pidgeon777 ,

Happy New Year!

I didn't quite understand this request of yours, Could you please elaborate more?
Thanks

@pnedev pnedev added the question label Jan 2, 2019
@pidgeon777
Copy link
Author

Hello, this is an example of NppGTags search results window:

image

What I mean is to give the user a chance to browse through the search results through a combination of keyboard buttons, for example:

  • Alt + Down -> Go to next search result
  • Alt + Up -> Go to previous search result

withouth clicking on the search results panel each time. The keyboard button combinations should be assignable through the Notepad++ hotkeys window.

I wish you a successful new year, too!

@pnedev
Copy link
Owner

pnedev commented Jan 7, 2019

Hello @pidgeon777 ,

OK, and by

Go to next/previous search result

you mean actually visiting the location where the tag is found (as if you have clicked on fprintf in the results window in your example), is that correct?

@pidgeon777
Copy link
Author

pidgeon777 commented Jan 7, 2019

Exactly. But, for a greater code browsing experience, in my opinion it would be better to select the next/previous search result so that:

  • The editor automatically scrolls to the selected result, centring it vertically (as it already happens when manually clicking on the search result).
  • An editable selection automatically applies to the selected item (as it already happens when manually clicking on the search result).
  • The editor doesn't lose focus.
    • Example: if I select the next search result item through Alt + Down, then I should be able to keep typing something in the editor without clicking on it every time first to make it gain focus again.
  • The line of the selected item in the search result window get highlighted (as it already happens when I manually click on one of the listed search results)

A bonus would be something like this: be able to loop through each of the search result items, by automatically collapsing the other trees. For example, consider this starting situation:

+Main.h
-PGM.c
Line 1: asd
Line 2: asd kkkk <- selected line
+Menu.h

when I select the next item with the keyboard combination it would become:

+Main.h
+PGM.c
-Menu.h
Line 12: bfff asd <- selected line
Line 19: bbb asd

By doing so, the other results associated to the remaining trees would be hidden, for better readability. Maybe a user could decide to enable or not this behaviour through a dedicated option. But, as I repeat, this auto-collapsing tree function would just be the icing on the cake.

@pnedev
Copy link
Owner

pnedev commented Jan 8, 2019

Thanks for clarifying.

Example: if I select the next search result item through Alt + Down, then I should be able to keep typing something in the editor without clicking on it every time first to make it gain focus again.

Isn't it the case when you click on the tag in the results window?
The result window should lose focus and open the corresponding file in the editor at the tag location. That's how it is currently working.

So as far as I understood your suggestion is to simply be able to visit results without switching focus to results window at all + the current visited result to be shown in the results window (by highlighting the row). Correct me if I'm wrong.

Perhaps you know it but just to mention that currently you can assign shortcut (through Notepad++ plugins shortcuts config) to NppGTags' Toggle Results Window Focus command. It effectively toggles focus between the editor's document and the results window making the plugin completely usable only with keyboard (no mouse clicking needed).

So you can:

  1. Do your search.
  2. The focus is set to the Results window, tree collapsed. If you like you can expand it fully with Alt +.
  3. Preview and browse results and hit space when you need to visit one.
  4. The result location is opened, the focus is set to the editor's document.
  5. Use your Toggle Results Window Focus command shortcut to set the focus again to the Results window (its location won't be changed).
  6. Browse your next result of interest and continue this way.

This kind-of does what you need IMO with the extra need to toggle the focus of course.

@pidgeon777
Copy link
Author

Thanks for your reply, I've already thought about your proposed Toggle Results Window Focus solution but this would involve too many keystrokes. For example, 30 keystrokes in case I would need to select 10 search results. The sequence would indeed be:

  1. Search for a definition.
  2. Focus search window (For example, with F1).
  3. Select next item (With Down Arrow).
  4. Press Enter.
  5. Go to 1 to view the next item.

So, 1-3 are three keystrokes for every action. A further shortcut to directly select Next/Previous search result would be much simpler and "user-friendly".

Let's also consider that something like this would also integrate perfectly with the aforementioned suggestion. Let's consider a search for a definition:

image

Results window could appear with this format:

image

You can notice:

  • Results of inactive files start automatically collapsed.
  • Highlighted line is coherent with the actual line of the keyword which I selected for the search (line no. 3610).

This is where my suggestion would be very useful: you select a keyword while coding, and the hotkeys Alt + Down/Up (for example) brings you exactly before or after the keyword you selected in the editor, moving the selection exactly on the other occurrence.

What happens when you reach for example the end of the current file search result (line no. 3657)?:

image

well, thanks to the new improvement you would go to the next occurrence of the following file, automatically collapsing (eventually) the previous tree, reaching this situation:

image

This is my suggestion based on the actual implementantions of other editors where you need to frequently scan the search results, or simply navigate through the code.

@pnedev
Copy link
Owner

pnedev commented Jan 9, 2019

I agree it might be useful and that it's much more convenient for such work flow.
Will implement it when I find time, soon I suppose.
Thanks.

@pnedev pnedev removed the question label Jan 9, 2019
@pnedev pnedev added this to the v4.5 milestone Jan 9, 2019
@pnedev pnedev removed this from the v4.5 milestone Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants