Author Topic: Keyboard Shortcuts for non menu items  (Read 7863 times)

Timbo

  • Guest
Keyboard Shortcuts for non menu items
« on: June 09, 2008, 05:28:41 pm »
If I right click on a variable there is a menu with the entries "Find declaration of :'...'" and "Find implementation of :'...'".
Is there a way to set shortcuts for these comands.
The Keyboards Shortcuts plugin doesn't work since these commands aren't in the normal menu (or I couldn't find them there).

sory139

  • Guest
Re: Keyboard Shortcuts for non menu items
« Reply #1 on: June 13, 2008, 04:32:42 pm »
I've created a patch that adds two new menu items (Go to declaration / Go to implementation) that you can map to any key combination.

The downside is that you need to get c::b from svn, patch it and build it.

[attachment deleted by admin]

Offline Kos

  • Single posting newcomer
  • *
  • Posts: 7
Re: Keyboard Shortcuts for non menu items
« Reply #2 on: June 15, 2008, 02:16:18 pm »
Good job. I apply that it should be added in the next nightly.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Keyboard Shortcuts for non menu items
« Reply #3 on: June 16, 2008, 01:11:43 pm »
I wanted to apply it, but there were some berlios issues last weekend, so I will apply it this evening.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Keyboard Shortcuts for non menu items
« Reply #4 on: June 16, 2008, 04:55:09 pm »
I wanted to apply it, but there were some berlios issues last weekend, so I will apply it this evening.
I am testing here, too... so far no issues. But I would welcome some more testing... especially under Linux. As you know: CC modifications should always be applied with extra care... ;-)

Edit: one thing I noticed: If your cursor is outside a method / keyword you get a strange error just stating:
---------------------------
Warning
---------------------------
Not found:
---------------------------
OK   
---------------------------

This should be fixed. Either the menu gets disabled or the error message really states *something* meaningful.
« Last Edit: June 16, 2008, 04:58:47 pm by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Keyboard Shortcuts for non menu items
« Reply #5 on: June 16, 2008, 05:49:10 pm »
I have done some testing, and have a similar conclusion.
Now when the focus is not on a variable or the function declaration/implementation signature, the right click menu doesn't allow you to Find/Jump to declaration/definition.
But the new menu entries and keyboard shortcuts do allow you to trigger the methods, which then say they didn't find anything.
So we need the check to see if the menu should be enabled, and as such also (un)block the keyboard shortcuts.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Keyboard Shortcuts for non menu items
« Reply #6 on: June 16, 2008, 10:05:22 pm »
I have refactored and implemented the requirement that the menu entries are only enabled when it makes sense (same requirements as with the right click context pop up menu).
However the shortcuts are not disabled and still can be called whenever you like (eg after start up while the cursor is on whitespace).

Is there a way so the shortcuts follow the enable/disable status of what they are the shortcut for ??
Or am I enforced even on invocation to do the necessary check on the requirements and then in the end silently ignore the non fulfillment, otherwise we get that nasty message box again.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Keyboard Shortcuts for non menu items
« Reply #7 on: June 16, 2008, 10:40:09 pm »
Implemented (question about shortcuts getting disabled with their menu entry still stands though, but could  solve the issue without this knowledge).

There might be much more ideas that could be of interest for improvements to the current way (now and before my changes) :

1) go to declaration of the method enclosing the position of the cursor
1bis) go to the start of the method enclosing the position of the cursor

2) after you jumped to declaration or definition : the cursor is at the beginning of the line : you can NOT jump back to the point you came from (in the sense of find declaration/implementation) because your cursor has to be on the method name. Counter example what if the first word on the line is the return value of a user defined type (enum, struct, class) where does the user expects to jump to then [one could argue if the return value is not such a type then jump to the method name]

3) goto declaration of local variables does NOT work (it never did), make it work ;-)

4) goto definition of the class containing the method enclosing the position of the cursor


PS : currently I still have 1 difference :

void CodeCompletion::BuildMenu(wxMenuBar* menuBar)

put the cursor somewhere on 'CodeCompletion', through the right click I can jump to declaration or definition, but not with the menu or short cuts.

EDIT : last issue also solved, this happened in the case that there was more then 1 match, I have no idea why the partial check I commented out now was needed. The method was always called in this context (right click : idGotoImplementation or idGotoDeclaration) and now also from the menu context. So the original patch where I started from was suffering from this bug too.
Code
                if ((/*event.GetId() == idGotoImplementation &&*/ !sel->GetImplFilename().IsEmpty()) ||
                    (/*event.GetId() == idGotoDeclaration &&*/ !sel->GetFilename().IsEmpty()))
« Last Edit: June 16, 2008, 11:28:01 pm by killerbot »

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Keyboard Shortcuts for non menu items
« Reply #8 on: June 17, 2008, 07:04:12 am »

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Keyboard Shortcuts for non menu items
« Reply #9 on: June 17, 2008, 10:04:11 am »
strange that a patch like this is now acceptable:

http://developer.berlios.de/patch/?func=detailpatch&patch_id=2074&group_id=5358

I will also implement the open include file part of it.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Keyboard Shortcuts for non menu items
« Reply #10 on: June 18, 2008, 10:06:20 pm »
open include file part is implemented : shortcut: ctrl-alt-.

Offline fabrizio.benedetti

  • Multiple posting newcomer
  • *
  • Posts: 25
Re: Keyboard Shortcuts for non menu items
« Reply #11 on: October 16, 2008, 11:59:22 am »
open include file part is implemented : shortcut: ctrl-alt-.

How can it be changed? If I open the settings for the keyboard shortcuts I can see that the sequence is "already assigned to 'open include file'" but since the "open include file" command cannot be found anywhere in the menus tree to the left, the shortcut to the "open include file" command cannot be changed...  :?:

  Ciao
    Fabrizio

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2777
Re: Keyboard Shortcuts for non menu items
« Reply #12 on: October 16, 2008, 03:10:28 pm »
open include file part is implemented : shortcut: ctrl-alt-.

How can it be changed? If I open the settings for the keyboard shortcuts I can see that the sequence is "already assigned to 'open include file'" but since the "open include file" command cannot be found anywhere in the menus tree to the left, the shortcut to the "open include file" command cannot be changed...  :?:

  Ciao
    Fabrizio

Works for me...
It's under the search menu.

« Last Edit: October 16, 2008, 03:24:33 pm by Pecan »

Offline fabrizio.benedetti

  • Multiple posting newcomer
  • *
  • Posts: 25
Re: Keyboard Shortcuts for non menu items
« Reply #13 on: October 16, 2008, 03:19:40 pm »
open include file part is implemented : shortcut: ctrl-alt-.
How can it be changed?
Works for me...

  I didn't notice it under "Search"!  :o OK, it works for me too, thanks!

    Fabrizio