Skip to content

Bug in key + metakey arithmetic #288

Open
@TobiasWallner

Description

@TobiasWallner

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:

Ctrl = (1 << 23),

and:
return Key(static_cast<Term::Key::Value>(key + Value::Ctrl)); // FIXME maybe a better check;

so the result will not be Key::Value::Ctrl_Q

Ctrl_Q = 17,

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions