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

Termwiz bugs #2511

Open
axdank opened this issue Sep 13, 2022 · 3 comments
Open

Termwiz bugs #2511

axdank opened this issue Sep 13, 2022 · 3 comments
Labels
bug Something isn't working termwiz

Comments

@axdank
Copy link

axdank commented Sep 13, 2022

What Operating System(s) are you seeing this problem on?

Windows

Which Wayland compositor or X11 Window manager(s) are you using?

No response

WezTerm version

20220908-191626-25cd05a8

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

No, and I'll explain why below

Describe the bug

Hi @wez i need your help. (It is related to the termwiz crate).
I don't know if it's exactly a bug or something I'm not configuring well.

The first is about the pool_input function, which returns the InputEvent, but not in the correct way, for example this sequence (using the example termwiz/examples/key_tester.rs):

entered value: Shift + A
result:

KeyEvent { key: Shift, modifiers: SHIFT }
KeyEvent { key: Char('A'), modifiers: NONE }

expected: KeyEvent { key: Char('A'), modifiers: SHIFT}

entered value: Control + j
result:

KeyEvent { key: Control, modifiers: CTRL }
KeyEvent { key: Enter, modifiers: NONE }

expected: KeyEvent { key: Char('j'), modifiers: CTRL }

entered value: Control + h
result:

KeyEvent { key: Control, modifiers: CTRL }
KeyEvent { key: Backspace, modifiers: NONE }

expected: KeyEvent { key: Char('h'), modifiers: CTRL }

entered value: Shift + :
result:

KeyEvent { key: Shift, modifiers: SHIFT }
KeyEvent { key: Char(':'), modifiers: NONE }

expected: KeyEvent { key: Char(':'), modifiers: SHIFT }

entered value: Shift + Tab
result:

KeyEvent { key: Escape, modifiers: NONE }
KeyEvent { key: Char('['), modifiers: NONE }
KeyEvent { key: Char('Z'), modifiers: NONE }

well, the desired is to return only one InputEvent for each interaction and with the correct data.

and secondly, is it normal that ColorAttribute::TrueColorWithPaletteFallback() never works (always returns black) ? I can't get it to show the colors when converting rgb to rgbatuple, only the ansi colors works.

running the example: termwiz/examples/widgets_basic.rs
imagen

Is it necessary to detail some additional function for the initialization of the terminal to solve these errors ? or are they some kind of error ?

To Reproduce

No response

Configuration

no config

Expected Behavior

No response

Logs

No response

Anything else?

No response

@axdank axdank added the bug Something isn't working label Sep 13, 2022
@wez wez added the termwiz label Sep 22, 2022
wez added a commit that referenced this issue Sep 22, 2022
When in raw mode, go to level 2, but use level 1 for cooked
so that we don't obfuscate ctrl-c.

A consequnce of this is that CTRL-C is now reported to the app
as CTRL-lowercase-c where we previously reported as CTRL-uppercase-C.
Made a note of the breaking nature of this change in a new changelog
file.

Fixed recognizing SHIFT-TAB

refs: #2511
@wez
Copy link
Owner

wez commented Sep 22, 2022

entered value: Shift + A
expected: KeyEvent { key: Char('A'), modifiers: SHIFT}

Shift-A sends only A with no shift modifier key in the standard keyboard encoding, so we don't know if SHIFT was actually pressed in order to produce that input: it's very difficult to make that kind of determination unless you know the active keyboard layout on the user's machine, and that may not even be local to the system where your console application is running.

Same goes for :.

entered value: Control + j
result: KeyEvent { key: Enter, modifiers: NONE }

Control-<alpha> is delivered as a control code in the standard key encoding, so CTRL-J is indistinguishable from Enter, CTRL-H is backspace and so on. These are famously ambiguous sequences to map in an application. https://wezfurlong.org/wezterm/config/key-encoding.html has more background on this.

termwiz could request modifyOtherKeys to resolve this for terminals that respect that sequence (42f855d does that. There might need to be something different done for windows terminals), but it's worth noting that there is no 100% perfect cross platform way to unambiguously differentiate those key presses: there will always be someone that is going to hit this.

Shift-Tab

Thanks; fixed in 42f855d

is it normal that ColorAttribute::TrueColorWithPaletteFallback() never works (always returns black) ? I can't get it to show the colors when converting rgb to rgbatuple, only the ansi colors works.

If wezterm doesn't think the terminal supports 24-bit color, then it will use the palette fallback.
Going to need more info on the environment to understand whether that is working correctly.

@wez wez added the waiting-on-op Waiting for more information from the original poster label Sep 22, 2022
@axdank
Copy link
Author

axdank commented Sep 22, 2022

Thanks wez, I understand a little more how it works, as for the rgb colors, I find it strange, because the terminal is truecolor, when testing with crossterm, it gives me back the rgb colors without problems, but in termwiz I use:

Change::Attribute(AttributeChange::Foreground(
    ColorAttribute::TrueColorWithPaletteFallback(
        RgbColor::new_8bpc(color.0, color.1, color.2).to_tuple_rgba(),
        AnsiColor::Blue.into(),
    ),
)),

but neither the blue color returns me in case of failure.

Crossterm: Termwiz:
imagen imagen

@github-actions github-actions bot removed the waiting-on-op Waiting for more information from the original poster label Sep 22, 2022
@wez
Copy link
Owner

wez commented Nov 19, 2022

The indexed color stuff is potentially related to:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working termwiz
Projects
None yet
Development

No branches or pull requests

2 participants