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

Global State for Char Mode/Line Mode #352

Closed
timor opened this issue Jan 17, 2018 · 11 comments
Closed

Global State for Char Mode/Line Mode #352

timor opened this issue Jan 17, 2018 · 11 comments

Comments

@timor
Copy link

timor commented Jan 17, 2018

Is it possible to have a global notion of char mode/line mode vs. the per-window state that is used now?

@ch11ng
Copy link
Owner

ch11ng commented Jan 21, 2018

This is not implemented yet. Switching between these two modes not only requires setting up some buffer-local variables but selecting/unselecting some events on the managed X window. Do you have any specific use case for this?

@timor
Copy link
Author

timor commented Jan 22, 2018

I am using exwm with Spacemacs. This requires a bit of fiddling, but works reasonably well. Basically, I only use char mode for interaction, and set line mode passthrough to true always. This maps pretty well to Spacemacs' notion of insert/normal state. One problem exists with minibuffer input. There are a couple of functions that need to be adviced to make sure that char mode is deactivated to allow input be sent to emacs. While this is possible, switching back to line mode reliably is not so easy, since the minibuffer-input-requiring function can change the buffer layout, and I would need to store the information of which buffer was in what mode before minibuffer input to be able to restore the correct char/line mode after the input operation finishes. One simpler alternative would be to just store a char/line mode globally for all exwm buffers, which also would reduce the mental effort to check for the buffer's state after each switch. Returning to the correct state, regardless of which buffers are visible and active, is thus also much easier.

Hope that makes sense...

@ch11ng
Copy link
Owner

ch11ng commented Feb 4, 2018

As I've mentioned earlier, switching between line-mode and char-mode for all X windows is quite expensive. An alternative is to put all X windows in line-mode and use exwm-input-line-mode-passthrough to control whether key events should be forwarded to Emacs or not (you are probably doing this already).

There are a couple of functions that need to be adviced to make sure that char mode is deactivated to allow input be sent to emacs.

Isn't this a no-op if you always stay in line-mode?

@timor
Copy link
Author

timor commented Feb 5, 2018

Is there an observable difference between char-mode and line-mode without any defined bindings?

If not, I think that may solve the problem. It would affect the intended operation modes, though. I originally had in mind:

  1. char mode, i.e. everything goes directly to the X window (think "vi insert mode")
  2. line mode with passthrough, i.e. nothing goes to the X window
  3. line mode without passthrough, used for adding simulation key bindings to specific applications.

I did not use the 3rd mode yet, so it may not make a difference, but If I wanted to have something like this, I suppose I would switch in/out the exwm mode keymap, correct?

@ch11ng
Copy link
Owner

ch11ng commented Feb 11, 2018

Line mode without any defined binding is almost equivalent to char-mode. And if you want you can disable most default bindings. So there's no need to use char mode in your case. Just stay in line-mode and use exwm-input-line-mode-passthrough to control where key events go.

@ch11ng
Copy link
Owner

ch11ng commented Oct 21, 2018

@timor With exwm-input-line-mode-passthrough you can turn line-mode into char-mode. I think this should meet your need. I'm closing this issue now.

@ch11ng ch11ng closed this as completed Oct 21, 2018
@timor
Copy link
Author

timor commented Jun 12, 2020

Line mode without any defined binding is almost equivalent to char-mode.

For reference, one case I came across where it seems to be not equivalent is at least one SDL-based application. In that case, in line-mode the keys are sent twice.

@ch11ng
Copy link
Owner

ch11ng commented Jun 14, 2020

Which application? That sounds like a new bug to me.

@timor
Copy link
Author

timor commented Jun 17, 2020

This one: https://cataclysmdda.org

@ch11ng
Copy link
Owner

ch11ng commented Jul 12, 2020

I tried cataclysm and while I totally know nothing about the game, the problem you descried do exist. However not every key press are 'sent' twice; I should say it's about 50-50 here. I suspect it's because how the application treats KeyPress and KeyRelease events as EXWM delays KeyPress events a bit, but it requires debugging that application. It's not a good idea to play games in line-mode after all, so perhaps you should always put them in char-mode via per-application configurations?

@timor
Copy link
Author

timor commented Jul 16, 2020

Yes, I suppose so. Should be acceptable as a solution. Char mode is usually only one keybinding away anyways...

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