mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 09:09:03 -04:00
some subtle input changes
When CapsLock is detected, and we're working with ASCII input, capitalize it, just as we do with Shift or Ctrl. Don't consider CapsLock or NumLock for ncinput_equals_p(). Closes #2555.
This commit is contained in:
parent
b85c1f1dad
commit
7e46e5fbe4
@ -1196,7 +1196,8 @@ ncinput_numlock_p(const ncinput* n){
|
||||
}
|
||||
|
||||
// compare two ncinput structs for data equality. NCTYPE_PRESS and
|
||||
// NCTYPE_UNKNOWN are considered to be equivalent.
|
||||
// NCTYPE_UNKNOWN are considered to be equivalent. NCKEY_MOD_CAPSLOCK
|
||||
// and NCKEY_MOD_NUMLOCK are not considered relevant.
|
||||
static inline bool
|
||||
ncinput_equal_p(const ncinput* n1, const ncinput* n2){
|
||||
// don't need to check ->utf8; it's derived from id
|
||||
@ -1207,7 +1208,8 @@ ncinput_equal_p(const ncinput* n1, const ncinput* n2){
|
||||
return false;
|
||||
}
|
||||
// don't need to check deprecated alt, ctrl, shift
|
||||
if(n1->modifiers != n2->modifiers){
|
||||
if((n1->modifiers & ~(NCKEY_MOD_CAPSLOCK | NCKEY_MOD_NUMLOCK))
|
||||
!= (n2->modifiers & ~(NCKEY_MOD_CAPSLOCK | NCKEY_MOD_NUMLOCK))){
|
||||
return false;
|
||||
}
|
||||
if(n1->evtype != n2->evtype){
|
||||
|
28
src/lib/in.c
28
src/lib/in.c
@ -487,14 +487,21 @@ mark_pipe_ready(ipipe pipes[static 2]){
|
||||
static void
|
||||
load_ncinput(inputctx* ictx, ncinput *tni){
|
||||
int synth = 0;
|
||||
if(tni->modifiers & (NCKEY_MOD_CTRL | NCKEY_MOD_SHIFT | NCKEY_MOD_CAPSLOCK)){
|
||||
// when ctrl/shift are used with an ASCII (0..127) lowercase letter, always
|
||||
// supply the capitalized form, to maintain compatibility among solutions.
|
||||
if(tni->id < 0x7f){
|
||||
if(islower(tni->id)){
|
||||
tni->id = toupper(tni->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(tni->modifiers == NCKEY_MOD_CTRL){ // exclude all other modifiers
|
||||
if(ictx->linesigs){
|
||||
if(isalpha(tni->id)){
|
||||
if(toupper(tni->id) == 'C'){
|
||||
synth = SIGINT;
|
||||
}else if(toupper(tni->id) == 'Z'){
|
||||
synth = SIGSTOP;
|
||||
}
|
||||
if(tni->id == 'C'){
|
||||
synth = SIGINT;
|
||||
}else if(tni->id == 'Z'){
|
||||
synth = SIGSTOP;
|
||||
}else if(tni->id == '\\'){
|
||||
synth = SIGQUIT;
|
||||
}
|
||||
@ -505,15 +512,6 @@ load_ncinput(inputctx* ictx, ncinput *tni){
|
||||
send_synth_signal(synth);
|
||||
return;
|
||||
}
|
||||
if(tni->modifiers & (NCKEY_MOD_CTRL | NCKEY_MOD_SHIFT)){
|
||||
// when ctrl/shift are used with an ASCII (0..127) lowercase letter, 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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user