[load_ncinput] always capitalize ASCII when Ctrl is used

This commit is contained in:
nick black 2022-01-07 22:10:53 -05:00
parent 92bda51996
commit de02ceed91
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
2 changed files with 24 additions and 13 deletions

View File

@ -207,17 +207,17 @@ In API4, the various **bool** modifier fields will go away, and these statuses
will be merged into the ***modifiers*** bitmask. You are encouraged to use
**ncinput_shift_p** and friends to future-proof your code.
When support is detected, the Kitty keyboard disambiguation protocol will be
requested. This eliminates most of the **BUGS** mentioned below.
# BUGS
The Shift key is not indicated in conjunction with typical Unicode text.
If e.g. Shift is used to generate a capital letter 'A', ***id*** will equal 'A',
and ***shift*** will be **false**. Similarly, when Ctrl is pressed along with a
letter, the letter will currently always be reported in its uppercase form.
E.g., if Shift, Ctrl, and 'a' are all pressed, this is indistinguishable from
Ctrl and 'A'.
Notcurses attempts to use the XTMODKEYS and Kitty keyboard disambiguation
protocols. When supported, they eliminate most of these issues.
The Shift key is traditionally not indicated in conjunction with typical
Unicode text. If e.g. Shift is used to generate a capital letter 'A', ***id***
will equal 'A', and ***shift*** will be **false**. Similarly, when Ctrl is
pressed along with a letter, the letter will currently always be reported in
its uppercase form. E.g., if Shift, Ctrl, and 'a' are all pressed, this is
indistinguishable from Ctrl and 'A'.
Ctrl pressed along with 'J' or 'M', whether Shift is pressed or not,
currently registers as **NCKEY_ENTER**. This will likely change in the

View File

@ -476,16 +476,27 @@ mark_pipe_ready(ipipe pipes[static 2]){
}
}
// shove the assembled input |tni| into the input queue (if there's room,
// and we're not draining, and we haven't hit EOF). send any synthesized
// signal as the last thing we do.
// shove the assembled input |tni| into the input queue (if there's room, and
// we're not draining, and we haven't hit EOF). send any synthesized signal as
// the last thing we do. if Ctrl is among the modifiers, we replace any
// lowercase letter with its uppercase form, to maintain compatibility with
// other input methods.
static void
load_ncinput(inputctx* ictx, const ncinput *tni, int synthsig){
load_ncinput(inputctx* ictx, ncinput *tni, int synthsig){
inc_input_events(ictx);
if(ictx->drain || ictx->stdineof){
send_synth_signal(synthsig);
return;
}
if(tni->modifiers & NCKEY_MOD_CTRL){
// when ctrl is used with an ASCII (0..127) lowercase letter, we always
// supply the capitalized form, to maintain compatibility among solutions
if(tni->id < 0x7f){
if(islower(tni->id)){
tni->id = toupper(tni->id);
}
}
}
pthread_mutex_lock(&ictx->ilock);
if(ictx->ivalid == ictx->isize){
pthread_mutex_unlock(&ictx->ilock);