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

CtrlH not work but others CtrlA,CtrlB... can #903

Open
dty2 opened this issue Jul 23, 2024 · 1 comment
Open

CtrlH not work but others CtrlA,CtrlB... can #903

dty2 opened this issue Jul 23, 2024 · 1 comment

Comments

@dty2
Copy link

dty2 commented Jul 23, 2024

...
  auto etui = CatchEvent(rtui, [&](Event event){
    if(event == Event::CtrlH) {
      screen->Exit();
      return true;
    }
    return false;
  });
  this->content = etui;
  std::thread t([&]{
    function->postevent = std::bind(&Tui::postevent, this, std::placeholders::_1);
    function->start();
  });
  screen->Loop(content);
  delete screen;
...

this is my code, and the question is write in title
I try other ctrl + key ,which like CtrlY,CtrlA,CtrlB, all of them can work
only CtrlH can not
then I try Event::Speical("\x08"), it can't work too.
so I guess the problem is my terminal "alacritty" or my keyboard, but both of them are good
then I run sudo showkey to press CtrlH, it show these

keycode  29 press
^Hkeycode  35 press
keycode  35 release
keycode  29 release

and I don't use alias in my .zshrc
I don't know what's wrong with CtrlH, so I try to check issue like #869
and your answer is

My terminal kitty doesn't send any key when I press CTRL + Shift + C. This is mapped to "copy".

I don't believe this is possible today to receive a different code for CTRL+C and CTRL+Shift+C, due to the current xterm specification. Terminal should send the same sequence for both:
https://superuser.com/a/722895

About overriding the default CTRL-C behavior, you can:

Call ScreenInteractive::ForceHandleCtrlC(false) [(source)](https://github.com/ArthurSonzogni/FTXUI/blob/main/src/ftxui/component/screen_interactive.cpp#L562-L566)
Your component must "catch" the CTRL-C event, by returning true in some handler.

So I find some codes in source, like

/// @brief Force FTXUI to handle or not handle Ctrl-C, even if the component
/// catches the Event::CtrlC.
void ScreenInteractive::ForceHandleCtrlC(bool force) {
  force_handle_ctrl_c_ = force;
}

/// @brief Force FTXUI to handle or not handle Ctrl-Z, even if the component
/// catches the Event::CtrlZ.
void ScreenInteractive::ForceHandleCtrlZ(bool force) {
  force_handle_ctrl_z_ = force;
}

but I notice that there is no function like "ScreenInteractive::ForceHandleCtrlH"
so, I can't use the answer like "overriding the default CTRL-C behavior"

Please help me, I don't want to use other keys like CtrlU to replace CtrlH....

@ArthurSonzogni
Copy link
Owner

Yes, some mapping are already reserved by some terminal emulators. They won't let FTXUI know about them unfortunately.

I don't believe you can do anything to know about them.

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