Author Topic: How to un-indent the code, it looks like the shift+TAB key got hooked by others  (Read 2461 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Normally, I think when I select some text in the editor, press the TAB key will indent the code, while "shift+TAB" key will un-indent the code.

But actually, I see that "shift+TAB" key just switch the editor panels, not do the "un-intent" code.

Any way to solve this issue.

I just search the forum, back in year 2007, this feature is already implemented, see here: Indent and unindent commands in Edit.

I just looked at the key-binding(short-cut key) plugin's setting, I don't see any "indent" or "un-indent" command in the menus.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2778
Shift-Tab is a global key binding hard coded in main.cpp.
It has special handling in keybinder contrib.

It works here for HEAD revision.
Keybinder tries to keep your previous key bindings even when the Main menu assignments get changed. It may have gotten confused.

Try this to get keybinder to rebuild the keybindings.
1) disable keybinder
2) Restart CodeBlocks
3) Does shift-tab now work?

4) Enable Keybinder
5) restart Codeblocks
6) Does shift-tab still work?

What rev are you using, so I can try to re-create the problem.
« Last Edit: July 03, 2023, 07:18:34 am by Pecan »

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Shift-Tab is a global key binding hard coded in main.cpp.
It has special handling in keybinder contrib.

It works here for HEAD revision.
Hi, thanks for the reply. I'm using the latest svn HEAD version I build several hours ago(rev 13317). Once I build a new version, I just copy all the files in the src\output32_64 to the installed folder to overwrite the old ones.


Quote
Try this to see if it's being overridden by another plugin.
1) disable keybinder
2) Restart CodeBlocks
3) Does shift-tab now work?
I just did this, and "shift-tab" works in this case.



Quote
4) Enable Keybinder
5) restart Codeblocks
6) Does shift-tab still work?
Strange, "shift-tab" works OK now.

So, my guess is that disable the keybinder and enable it fixes some wrong configuration?  :)



If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1563
Panel switching is associated to Ctrl-Tab, somehow it is converted inside Keybinder to Shift-Tab (wrong flag?).

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2778
Looks to me like Keybinder is getting confused by the new HEAD configuration vs users previous CB configuration.

At startup, Keybinder merges its view of the menu structure with the users previous <personality>.Keybinder20.conf, and rewrites it.

Disabling/Re-enabling keybinder makes it do a clean rebuild of both it's view of the current menu structure and the users previous settings.

I suspect that keybinder is mistakenly using the global keybinding id of a previous CB version instead of the current HEAD setting during the merge of old to new bindings.  Global key bindings are a bitch to handle. They have no label. If an old (or non-existent) id is assigned to the global, it'll be connected to a galaxy far far away.

I'll take a look at it. It'll take some time.
Debugging Keybinder is always a time sink.

Reference: main.cpp line 761
m_pAccelEntries[6].Set(wxACCEL_SHIFT,                 WXK_TAB,   idShiftTab);

@Miguel Gimenez
Are you saying that you are experiencing that Ctrl-Tab is doing the function of Shift-Tab ?
« Last Edit: July 03, 2023, 08:24:06 pm by Pecan »

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1563
Quote
Are you saying that you are experiencing that Ctrl-Tab is doing the function of Shift-Tab ?
I had Ctrl-Tab binded to "Switch tabs" (defeult binding), I did never use it and Shift-Tab worked as expected (reduce indentation).

Last week, suddenly, Shift-Tab started switching tabs in two different computers (one at home and other at work, both always at HEAD). I deleted the Ctrl-Tab association using KeyBinder and Shift-Tab started working again as it should.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2778
Quote
Are you saying that you are experiencing that Ctrl-Tab is doing the function of Shift-Tab ?
I had Ctrl-Tab binded to "Switch tabs" (defeult binding), I did never use it and Shift-Tab worked as expected (reduce indentation).

Last week, suddenly, Shift-Tab started switching tabs in two different computers (one at home and other at work, both always at HEAD). I deleted the Ctrl-Tab association using KeyBinder and Shift-Tab started working again as it should.

Can you tell me which revision you switch to HEAD from?
I'd like to download the rev before you updated to HEAD to try and catch the error.

Thanks

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1563
I was at r13311 since it was commited (june 4), about 20 days later the issue appeared without new commits (r13312 is six days old), so I do not think it is commit-related.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2778
Fixed HEAD rev 13318.

Keybinder was not accounting for multiple duplicate menu id's coming from the hard coded accelerator table that referenced menu entries.

Using the global table is not necessary for the time being.
I'll figure out how to eliminate the conflicts some time in the future.

For now, I doubt that any one will notice they're gone. Especially since (over time) most have been defined in the menu structure anyway.

Thanks for the help.