ArthurSonzogni / FTXUI

:computer: C++ Functional Terminal User Interface. :heart:
MIT License
6.87k stars 414 forks source link

on_enter callback doesn't work #337

Closed brokensword2018 closed 2 years ago

brokensword2018 commented 2 years ago

Normally, it works well。 in ubuntu, when I use bind command to start my program based on FTXUI. the on_enter callback of input doesn,t work. like this. add "bind -x '"\C-g":" to ~/.bashrc. so I can use 'ctrl+g' to start my program.

ArthurSonzogni commented 2 years ago

What are you trying to achieve with bind, and ctrl+g?

brokensword2018 commented 2 years ago

my program based on FTXUI, I use ctrl+g to start my program

ArthurSonzogni commented 2 years ago

Could you execute the example: https://arthursonzogni.com/FTXUI/examples/?file=component/print_key_press Using your "bind"?

And see what is sent for the "enter" and "space" characters?

ArthurSonzogni commented 2 years ago

@brokensword2018 ?

brokensword2018 commented 2 years ago

@brokensword2018 ?

enter is ( 13 ) -> (special) space is ( 32 ) -> character( )

ArthurSonzogni commented 2 years ago

It seems to be working fine. If you believe this is a bug in FTXUI, could you post a reproducer?

It is probably an issue with you program. I can't really say what, because you haven't posted it.

brokensword2018 commented 2 years ago

@brokensword2018 ?

enter is ( 13 ) -> (special) space is ( 32 ) -> character( )

brokensword2018 commented 2 years ago

It seems to be working fine. If you believe this is a bug in FTXUI, could you post a reproducer?

It is probably an issue with you program. I can't really say what, because you haven't posted it.

https://github.com/brokensword2018/ftxui-starter you can use this to reproduce the problem . add bind -x '"\C-m":the abs path of ftxui-starter' to ~/.bashrc , then source ~/.bashrc, and press ctrl + m. use the way to start the program, there no "press enter" in 1.log。 and a strang thing is that press enter will start the program.

brokensword2018 commented 2 years ago

It seems to be working fine. If you believe this is a bug in FTXUI, could you post a reproducer? It is probably an issue with you program. I can't really say what, because you haven't posted it.

https://github.com/brokensword2018/ftxui-starter you can use this to reproduce the problem . add bind -x '"\C-m":' to ~/.bashrc , then source ~/.bashrc, and press ctrl + m. use the way to start the program, there no "press enter" int 1.log。 and enter will start the program.

os : Ubuntu 20.04.3 LTS

ArthurSonzogni commented 2 years ago

Thanks! I can reproduce.

Instead of sending "10" (New line) when pressing Enter, it sounds like we get "13" (Carriage Return) when going through "bind". I am not sure why bind works this way.

ArthurSonzogni commented 2 years ago

I think what I can do, is converting 10/13 code into one of the two. This would make Window / non-Window consistent. This would also make Linux / Linux+Bind consistent.

brokensword2018 commented 2 years ago

good job! waitting for you to fix this problem.