jline / jline2

Jline 2.x
http://jline.github.com/jline2/
Other
713 stars 181 forks source link

Square brackets don't work properly on WINDOWS with a german keyboard #269

Closed aunkrig closed 8 years ago

aunkrig commented 8 years ago

Hi there,

german keyboards (and probably other, non-US keyboards) require Ctrl+Alt for entering characters like "{[]}\". JLINE does not handle these keystrokes correctly, because "WindowsTerminal.java"

        // support some C1 control sequences: ALT + [@-_] (and [a-z]?) => ESC <ascii>
        // http://en.wikipedia.org/wiki/C0_and_C1_control_codes#C1_set
        int altState = KEY_EVENT_RECORD.LEFT_ALT_PRESSED | KEY_EVENT_RECORD.RIGHT_ALT_PRESSED;
        if (((keyEvent.uchar >= '@' && keyEvent.uchar <= '_') || (keyEvent.uchar >= 'a' && keyEvent.uchar <= 'z'))
            && (keyEvent.controlKeyState & altState) != 0) {
            sb.append('\u001B'); // ESC
        }

falsely identifies these keystrokes as "come C1 control sequences". I believe adding

&& (keyEvent.controlKeyState & (KEY_EVENT_RECORD.LEFT_CTRL_PRESSED | KEY_EVENT_RECORD.RIGHT_CTRL_PRESSED)) == 0

to the IF statement should do the trick.

Could you please include that change?

Regards,

Arno

(Observed with JLINE 2.12.)

aunkrig commented 8 years ago

Ah! The issue seems to be addressed in JLINE 3! What is the current status of JLINE3? Is 3.0.0 stable, or should I stay with JLINE2 for the time being?

fantasyzh commented 8 years ago

already fixed since 2.12.1 ? see #175

aunkrig commented 8 years ago

You're right; sorry for the hassle. I was using version 2.12, because the README.md told me so.