cpp-terminal icon indicating copy to clipboard operation
cpp-terminal copied to clipboard

Bug in key + metakey arithmetic

Open TobiasWallner opened this issue 1 year ago • 7 comments

While inspecting and changeing the files: https://github.com/jupyter-xeus/cpp-terminal/blob/master/cpp-terminal/key.cpp https://github.com/jupyter-xeus/cpp-terminal/blob/master/cpp-terminal/key.hpp I noticed the following possible error:

Key::Value::q + MetaKey::Value::Ctrl == Key::Value::Ctrl_Q; // returns false

The addition adds a flag bit at bit position 23 becaulse: https://github.com/jupyter-xeus/cpp-terminal/blob/83b7300a5bdd118ff2d99fed6c3e1c2f91e9a1d4/cpp-terminal/key.hpp#L249 and: https://github.com/jupyter-xeus/cpp-terminal/blob/83b7300a5bdd118ff2d99fed6c3e1c2f91e9a1d4/cpp-terminal/key.cpp#L22

so the result will not be Key::Value::Ctrl_Q https://github.com/jupyter-xeus/cpp-terminal/blob/83b7300a5bdd118ff2d99fed6c3e1c2f91e9a1d4/cpp-terminal/key.hpp#L35

When I enter Ctrl+Q on my keyboard, I would like to intuitively use the library and use Key::Value::q + MetaKey::Value::Ctrl to check against.

Currently we employ two different schools of thought and mixed and messed them up.

  1. all controll characters are from 0 to 31
  2. all controll characters have the 22nd bit set high

and both are being though of as being a controll character. We should choose one of the two. I understand the motivation of the second because it allows for the future feature of seperatelly reading the Ctrl key and storing it in a flag. However, like this the feature of adding metakeys to normal keys is pretty much useless, or am I wrong and missing something? @flagarde

TobiasWallner avatar Sep 04 '23 00:09 TobiasWallner