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

Unable to redefine tab key action #TAB #3672

Closed
mc-butler opened this issue Aug 11, 2016 · 24 comments
Closed

Unable to redefine tab key action #TAB #3672

mc-butler opened this issue Aug 11, 2016 · 24 comments
Assignees
Labels
area: keybind Key bindings prio: medium Has the potential to affect progress
Milestone

Comments

@mc-butler
Copy link

Important

This issue was migrated from Trac:

Origin https://midnight-commander.org/ticket/3672
Reporter Argon (xxxargonxxx@….com)
Mentions xxxargonxxx@….com, zaytsev (@zyv), cri@….org
Keywords TAB, autocompletion, keybinding

I searched like 5 hours for any way to redefine default action assigned to TAB key (to not switch between panels so to be able to use it for autocompletion). I looked over all mc.keymap config files, but it doesnt contain such setting. I checked man mc, internal mc help utility and this website wiki. No information at all. Is it possible at least?

This issue adressed to problem with TAB key action rebinding (it needs to be possible to trigger autocompletion on TAB key) AND providing any information if it is:
a) possible (so, how?);
b) not possible (this should be covered in man pages, help topics and wiki as well, as special remark)

@mc-butler
Copy link
Author

Changed by Argon (xxxargonxxx@….com) on Aug 11, 2016 at 10:26 UTC (comment 1)

  • Cc set to xxxargonxxx@….com

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Aug 11, 2016 at 11:42 UTC (comment 2)

  • Milestone changed from Documentation to Future Releases

@mc-butler
Copy link
Author

Changed by Argon (xxxargonxxx@….com) on Aug 11, 2016 at 12:35 UTC (comment 3)

Also, similar qustions asked a couple of times in stackexchange/overflow and discussed a lot of times in different help forums, so many people stuck on that. This problem repels many new users out of using MC.

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Sep 14, 2016 at 10:58 UTC (comment 4)

  • Owner set to andrew_b
  • Status changed from new to accepted
  • Branch state changed from no branch to on review
  • Milestone changed from Future Releases to 4.8.18

Branch: 3672_bind_tab
[19f02a031290229a810154497d72b75f86524917]

@mc-butler
Copy link
Author

Changed by mooffie (@mooffie) on Sep 20, 2016 at 16:01 UTC (comment 5)

I haven't tested the patch, but the code looks fine.

(I guess you've investigated the possibility of putting the TAB key on the dialog_map keymap and deemed it problematic for some reason.)

Here's an idea for improvement (though I haven't thought about it much; it might be flawed):

If CK_ChangePanel returned MSG_NOT_HANDLED when there's only one panel shown (as in the case of the "Long file list" listing mode), then the TAB will be sent next the to command-line (see sequence diagram). This would let users use TAB to switch panels normally, but to auto-complete when only one panel is shown.

Other random notes, which you can ignore:

# !! untested !!
[main:empty-cmdline]
ChangePanel = tab
[main]
ChangePanel =
[input]
Complete = tab; alt-tab

@mc-butler
Copy link
Author

Changed by zaytsev (@zyv) on Sep 25, 2016 at 19:45 UTC (comment 6)

  • Cc changed from xxxargonxxx@….com to xxxargonxxx@….com, zaytsev

OT: @mooffie did you generate this nice diagram programmatically, or you drew it yourself manually? Just curious.

@mc-butler
Copy link
Author

Changed by mooffie (@mooffie) on Sep 26, 2016 at 12:41 UTC (comment 6.7)

Replying to zaytsev:

OT: @mooffie did you generate this nice diagram programmatically, or you drew it yourself manually? Just curious.


It was generated programmatically. #comment:18 Here, where I introduced this diagram, (#3664) I linked to its source script.

A little history:

Many years ago I used sequence diagrams to help me study some system. The tool I used for drawing was sdedit, which draws the diagram for you based on a textual description you give it. Unfortunately, its language is horrible for humans (IMHO), so I ended up writing a Ruby "DSL" that, given a less horrible syntax, produces input for sdedit. That's how I generated that diagram. I'd imagine that nowadays there exist nicer tools/languages for doing this.

@mc-butler
Copy link
Author

Changed by zaytsev (@zyv) on Sep 27, 2016 at 16:15 UTC (comment 8)

Ah, I see; thank you for the clarification. In that case, it's not programmatic in a sense that you have to write the DSL yourself, instead of some source code analyzer. That's what I was interested in...

@mc-butler
Copy link
Author

Changed by Argon (xxxargonxxx@….com) on Sep 28, 2016 at 15:14 UTC (comment 5.9)

Replying to mooffie:

(I guess you've investigated the possibility of putting the TAB key on the dialog_map keymap and deemed it problematic for some reason.)

Yes, I tried in many ways (using mc.keymap in user's home dir and also global mc.keymap file in /etc/mc). My settings just ignored/overwritten.

Here's an idea for improvement (though I haven't thought about it much; it might be flawed):

If CK_ChangePanel returned MSG_NOT_HANDLED when there's only one panel shown (as in the case of the "Long file list" listing mode), then the TAB will be sent next the to command-line (see sequence diagram). This would let users use TAB to switch panels normally, but to auto-complete when only one panel is shown.

I like this idea as last resort case, I don't think this is the best idea because one key must do same action no matter how many pannels in screen, thats a good practice for any UI. Users will get used to press TAB for some action being in one panel view mode and will be confused trying to make same action in another view.

  • BTW, if the user wants TAB to ChangePanel only if the cmdline is empty, and Complete otherwise <...>

The bad thing here is that you will be unable to switch if command line is not empty (like in case if you want to put to cmd string some file name from other panel).

Generally, it should be possibly to redefine TAB for autocomplete action and TAB+something for panel switch. Alternatively it also will be useful to make some checkbox for inverting ESC-TAB (M-TAB) with TAB (so ESC-TAB will switch and TAB will autocomplete) - it is easy for configuration and hotkeys will act evenly in any cases. May be last solution is even better than making option for arbitrary redefinition, at least I use panel switching quite rarely and wont be annoyed to press two keys to switch (like now when I annoyed of having to press two key for autocompletion).

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Oct 6, 2016 at 10:20 UTC (comment 10)

  • Votes set to andrew_b
  • Branch state changed from on review to approved

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Oct 6, 2016 at 10:22 UTC (comment 11)

  • Resolution set to fixed
  • Status changed from accepted to testing
  • Branch state changed from approved to merged
  • Votes changed from andrew_b to committed-master

Merged to master: [8bf560c].

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Oct 6, 2016 at 10:23 UTC (comment 12)

  • Status changed from testing to closed

@mc-butler
Copy link
Author

Changed by Argon (xxxargonxxx@….com) on Oct 6, 2016 at 10:47 UTC (comment 12.13)

Replying to andrew_b:
Nice, thanks! I guess using apt-get for update wont get it because it is not released yet.
What is a proper way to get this patch? Or better to wait until new version release?

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Oct 6, 2016 at 15:12 UTC (comment 13.14)

Replying to Argon:

What is a proper way to get this patch?

You can try a one of nightly builds.

Or better to wait until new version release?

The next release will be after a long time (several months).

@mc-butler
Copy link
Author

Changed by cri (cri@….org) on Oct 3, 2017 at 11:26 UTC (comment 15)

Hi, please note that

[input]
...
Complete = tab

will autocomplete on the command line, but not on text fields in dialog windows (e.g. copy file, etc).

Is it possible to have Complete = tab also for dialog windows? I tried putting it in the [dialog] section of my mc.keymap file but it doesn't work.
Of course if this is implemented, we should also need to define another key to navigate through dialog fields (instead of tab).

So far, I'm using this suboptimal workaround:

[input]
...
Complete = tab ; alt-tab

... so I get tab completion on the command line, and old-style esc-tab completion on text dialog fields.

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Oct 3, 2017 at 17:24 UTC (comment 15.16)

Replying to cri:

will autocomplete on the command line, but not on text fields in dialog windows (e.g. copy file, etc).

File name completion via alt (or esc)-tab works fine for me in the copy/move dialog, in the "Save as" dialog in mcedit, etc.

Is it possible to have Complete = tab also for dialog windows?

Complete what? Each input line has its own specific stuff: file names, words, etc. For example, the file name completion for "Content" field of "Find file" dialog in pointless.

@mc-butler
Copy link
Author

Changed by cri (cri@….org) on Oct 3, 2017 at 19:16 UTC (comment 16.17)

Replying to andrew_b:

File name completion via alt (or esc)-tab works fine for me in the copy/move dialog, in the "Save as" dialog in mcedit, etc.

Indeed, my message was about completion via tab (after setting Complete = tab), not via alt/esc-tab.

Complete what? Each input line has its own specific stuff: file names, words, etc.

Nothing new, I meant to have the same completions that are available now on each input line, only using tab instead of alt/esc-tab.

(and to be able to define another key, instead of tab, to move across fields)

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Oct 7, 2017 at 15:50 UTC (comment 17.18)

Replying to cri:

Indeed, my message was about completion via tab (after setting Complete = tab), not via alt/esc-tab.

Unfortunately, Tab and Shift-Tab keys are hardcoded to switch current widget in a dialog.

@mc-butler
Copy link
Author

Changed by cri (cri@….org) on Sep 10, 2019 at 13:19 UTC (comment 18.19)

Replying to andrew_b:

Unfortunately, Tab and Shift-Tab keys are hardcoded to switch current widget in a dialog.

Well I guess the problem is "how hard" they are hard-coded :)

...but I can't judge that, or even come up with patches, so I'll just repeat my suggestion: now that we are able to redefine tab for completion on the command line, it would be really nice to have the same behavior also on widget text fields.

@mc-butler
Copy link
Author

Changed by cri (cri@….org) on Dec 7, 2021 at 13:26 UTC (comment 20)

  • Status changed from closed to reopened
  • Resolution fixed deleted

Reopening, because the support for redefining tab action introduced with this ticket got broken in mc 4.8.26.

More specifically, in ~/.config/mc/mc.keymap:

  • [main] section: the ChangePanel setting seems to ignore any value, whatever value I set, the tab key has always the effect of changing panels.
  • [input] section: the Complete setting still works for values different from tab (e.g. alt-tab, or shift-tab), but setting tab here has no effect anymore

So the tab key seems to be hardwired again to only change panels, it's not possible anymore to use it for command completion.

Looking at https://midnight-commander.org/wiki/NEWS-4.8.26 initially I thought that the fix in #4107 could have introduced the regression, but I tried rebuilding 4.8.26 without that fix and the support is still broken.

The other tab-related fix mentioned in NEWS-4.8.26 is #2269; so maybe the regression was introduced by that fix, or/and by some other changes occurred between 4.8.25 (which works OK) and 4.8.26. Any help?

Another (maybe related?) minor issue: assigning ChangePanel = ctrl-tab has never worked for me (only shift-tab worked); it would be nice to be able to use ctrl-tab to change panels (i.e. the same keys used to change tabs in web browser windows). Maybe this can be fixed while debugging the main problem described above? Otherwise I'll open a different ticket for this.

@mc-butler
Copy link
Author

Changed by cri (cri@….org) on Dec 7, 2021 at 16:56 UTC (comment 21)

  • Cc changed from xxxargonxxx@….com, zaytsev to xxxargonxxx@….com, zaytsev, cri@….org

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Dec 7, 2021 at 17:02 UTC (comment 20.22)

Replying to cri:

  • [main] section: the ChangePanel setting seems to ignore any value, whatever value I set, the tab key has always the effect of changing panels.

[main] was renamed to [filemanager]: [1869dff]. Sorry, this change is missed in NEWS-4.8.26.

@mc-butler
Copy link
Author

Changed by cri (cri@….org) on Dec 8, 2021 at 14:01 UTC (comment 22.23)

Replying to andrew_b:

[main] was renamed to [filemanager]: [1869dff]. Sorry, this change is missed in NEWS-4.8.26.

Ouch, I missed that too when diffing old/new config files. Thanks!

Re the ctrl-tab problem I mentioned above, actually it's just a small quirk: ChangePanel = ctrl-tab for switching panels usually works fine, with one exception: if I run mc after becoming root via su -, it stops working: ctrl-tab behaves just like tab.

Some more tests I did:

  • Using a non X virtual console is OK, so it must be related to the X server
  • Running X as root is OK
  • Using su (instead of su -) is OK
  • Using another shell instead of bash: same behaviour, so it's not a bash specific problem
  • Using another xterminal emulator instead of xterm: same behaviour, so it's not a xterm problem

I'm not even sure this is a midnight commander bug (so I guess you can close this ticket): a quick googling reveals that ctrl-tab is often problematic in X for some applications and/or terminal emulators, and there are all sorts of suggested fixes that involve hacking ~./Xresources, xmodmap etc to get ctrl-tab working properly, but I eventually gave up.

I'm using the following workaround instead: ChangePanel = ctrl-tab; shift-tab, so when ctrl-tab doesn't work, I can use shift-tab.

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Dec 8, 2021 at 18:26 UTC (comment 24)

  • Resolution set to fixed
  • Status changed from reopened to closed

Ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: keybind Key bindings prio: medium Has the potential to affect progress
Development

No branches or pull requests

2 participants