Mercurial > vim
comparison src/term.c @ 179:7fd70926e2e1 v7.0055
updated for version 7.0055
author | vimboss |
---|---|
date | Fri, 04 Mar 2005 23:39:37 +0000 |
parents | 4d9eabb1396e |
children | 7e70fc748752 |
comparison
equal
deleted
inserted
replaced
178:4d53c2a2af94 | 179:7fd70926e2e1 |
---|---|
929 {(int)KS_MS, "y"}, | 929 {(int)KS_MS, "y"}, |
930 # endif | 930 # endif |
931 # endif | 931 # endif |
932 | 932 |
933 # if defined(UNIX) || defined(ALL_BUILTIN_TCAPS) || defined(SOME_BUILTIN_TCAPS) || defined(__EMX__) | 933 # if defined(UNIX) || defined(ALL_BUILTIN_TCAPS) || defined(SOME_BUILTIN_TCAPS) || defined(__EMX__) |
934 /* | |
935 * The xterm termcap is missing F14 and F15, because they send the same | |
936 * codes as the undo and help key, although they don't work on all keyboards. | |
937 */ | |
938 {(int)KS_NAME, "xterm"}, | 934 {(int)KS_NAME, "xterm"}, |
939 {(int)KS_CE, IF_EB("\033[K", ESC_STR "[K")}, | 935 {(int)KS_CE, IF_EB("\033[K", ESC_STR "[K")}, |
940 {(int)KS_AL, IF_EB("\033[L", ESC_STR "[L")}, | 936 {(int)KS_AL, IF_EB("\033[L", ESC_STR "[L")}, |
941 # ifdef TERMINFO | 937 # ifdef TERMINFO |
942 {(int)KS_CAL, IF_EB("\033[%p1%dL", ESC_STR "[%p1%dL")}, | 938 {(int)KS_CAL, IF_EB("\033[%p1%dL", ESC_STR "[%p1%dL")}, |
1011 /* An extra set of function keys for vt100 mode */ | 1007 /* An extra set of function keys for vt100 mode */ |
1012 {K_XF1, IF_EB("\033OP", ESC_STR "OP")}, | 1008 {K_XF1, IF_EB("\033OP", ESC_STR "OP")}, |
1013 {K_XF2, IF_EB("\033OQ", ESC_STR "OQ")}, | 1009 {K_XF2, IF_EB("\033OQ", ESC_STR "OQ")}, |
1014 {K_XF3, IF_EB("\033OR", ESC_STR "OR")}, | 1010 {K_XF3, IF_EB("\033OR", ESC_STR "OR")}, |
1015 {K_XF4, IF_EB("\033OS", ESC_STR "OS")}, | 1011 {K_XF4, IF_EB("\033OS", ESC_STR "OS")}, |
1016 {K_F1, IF_EB("\033[11~", ESC_STR "[11~")}, | 1012 {K_F1, IF_EB("\033[11;*~", ESC_STR "[11;*~")}, |
1017 {K_F2, IF_EB("\033[12~", ESC_STR "[12~")}, | 1013 {K_F2, IF_EB("\033[12;*~", ESC_STR "[12;*~")}, |
1018 {K_F3, IF_EB("\033[13~", ESC_STR "[13~")}, | 1014 {K_F3, IF_EB("\033[13;*~", ESC_STR "[13;*~")}, |
1019 {K_F4, IF_EB("\033[14~", ESC_STR "[14~")}, | 1015 {K_F4, IF_EB("\033[14;*~", ESC_STR "[14;*~")}, |
1020 {K_F5, IF_EB("\033[15~", ESC_STR "[15~")}, | 1016 {K_F5, IF_EB("\033[15;*~", ESC_STR "[15;*~")}, |
1021 {K_F6, IF_EB("\033[17~", ESC_STR "[17~")}, | 1017 {K_F6, IF_EB("\033[17;*~", ESC_STR "[17;*~")}, |
1022 {K_F7, IF_EB("\033[18~", ESC_STR "[18~")}, | 1018 {K_F7, IF_EB("\033[18;*~", ESC_STR "[18;*~")}, |
1023 {K_F8, IF_EB("\033[19~", ESC_STR "[19~")}, | 1019 {K_F8, IF_EB("\033[19;*~", ESC_STR "[19;*~")}, |
1024 {K_F9, IF_EB("\033[20~", ESC_STR "[20~")}, | 1020 {K_F9, IF_EB("\033[20;*~", ESC_STR "[20;*~")}, |
1025 {K_F10, IF_EB("\033[21~", ESC_STR "[21~")}, | 1021 {K_F10, IF_EB("\033[21;*~", ESC_STR "[21;*~")}, |
1026 {K_F11, IF_EB("\033[23~", ESC_STR "[23~")}, | 1022 {K_F11, IF_EB("\033[23;*~", ESC_STR "[23;*~")}, |
1027 {K_F12, IF_EB("\033[24~", ESC_STR "[24~")}, | 1023 {K_F12, IF_EB("\033[24;*~", ESC_STR "[24;*~")}, |
1028 {K_S_XF1, IF_EB("\033O2P", ESC_STR "O2P")}, | 1024 {K_S_XF1, IF_EB("\033O2P", ESC_STR "O2P")}, |
1029 {K_S_XF2, IF_EB("\033O2Q", ESC_STR "O2Q")}, | 1025 {K_S_XF2, IF_EB("\033O2Q", ESC_STR "O2Q")}, |
1030 {K_S_XF3, IF_EB("\033O2R", ESC_STR "O2R")}, | 1026 {K_S_XF3, IF_EB("\033O2R", ESC_STR "O2R")}, |
1031 {K_S_XF4, IF_EB("\033O2S", ESC_STR "O2S")}, | 1027 {K_S_XF4, IF_EB("\033O2S", ESC_STR "O2S")}, |
1032 {K_S_F1, IF_EB("\033[11;2~", ESC_STR "[11;2~")}, | |
1033 {K_S_F2, IF_EB("\033[12;2~", ESC_STR "[12;2~")}, | |
1034 {K_S_F3, IF_EB("\033[13;2~", ESC_STR "[13;2~")}, | |
1035 {K_S_F4, IF_EB("\033[14;2~", ESC_STR "[14;2~")}, | |
1036 {K_S_F5, IF_EB("\033[15;2~", ESC_STR "[15;2~")}, | |
1037 {K_S_F6, IF_EB("\033[17;2~", ESC_STR "[17;2~")}, | |
1038 {K_S_F7, IF_EB("\033[18;2~", ESC_STR "[18;2~")}, | |
1039 {K_S_F8, IF_EB("\033[19;2~", ESC_STR "[19;2~")}, | |
1040 {K_S_F9, IF_EB("\033[20;2~", ESC_STR "[20;2~")}, | |
1041 {K_S_F10, IF_EB("\033[21;2~", ESC_STR "[21;2~")}, | |
1042 {K_S_F11, IF_EB("\033[23;2~", ESC_STR "[23;2~")}, | |
1043 {K_S_F12, IF_EB("\033[24;2~", ESC_STR "[24;2~")}, | |
1044 {K_S_TAB, IF_EB("\033[Z", ESC_STR "[Z")}, | 1028 {K_S_TAB, IF_EB("\033[Z", ESC_STR "[Z")}, |
1045 {K_HELP, IF_EB("\033[28~", ESC_STR "[28~")}, | 1029 {K_HELP, IF_EB("\033[28;*~", ESC_STR "[28;*~")}, |
1046 {K_UNDO, IF_EB("\033[26~", ESC_STR "[26~")}, | 1030 {K_UNDO, IF_EB("\033[26;*~", ESC_STR "[26;*~")}, |
1047 {K_INS, IF_EB("\033[2~", ESC_STR "[2~")}, | 1031 {K_INS, IF_EB("\033[2;*~", ESC_STR "[2;*~")}, |
1048 {K_HOME, IF_EB("\033[7~", ESC_STR "[7~")}, | 1032 {K_HOME, IF_EB("\033[1;*H", ESC_STR "[1;*H")}, |
1049 {K_S_HOME, IF_EB("\033O2H", ESC_STR "O2H")}, | 1033 {K_S_HOME, IF_EB("\033O2H", ESC_STR "O2H")}, |
1050 {K_C_HOME, IF_EB("\033O5H", ESC_STR "O5H")}, | 1034 {K_C_HOME, IF_EB("\033O5H", ESC_STR "O5H")}, |
1051 {K_KHOME, IF_EB("\033[1~", ESC_STR "[1~")}, | 1035 {K_KHOME, IF_EB("\033[7;*~", ESC_STR "[7;*~")}, |
1052 {K_XHOME, IF_EB("\033OH", ESC_STR "OH")}, /* alternate Home */ | 1036 {K_XHOME, IF_EB("\033OH", ESC_STR "OH")}, /* alternate Home */ |
1053 {K_END, IF_EB("\033[8~", ESC_STR "[8~")}, | 1037 {K_END, IF_EB("\033[1;*F", ESC_STR "[1;*F")}, |
1054 {K_S_END, IF_EB("\033O2F", ESC_STR "O2F")}, | 1038 {K_S_END, IF_EB("\033O2F", ESC_STR "O2F")}, |
1055 {K_C_END, IF_EB("\033O5F", ESC_STR "O5F")}, | 1039 {K_C_END, IF_EB("\033O5F", ESC_STR "O5F")}, |
1056 {K_KEND, IF_EB("\033[4~", ESC_STR "[4~")}, | 1040 {K_KEND, IF_EB("\033[4;*~", ESC_STR "[4;*~")}, |
1057 {K_XEND, IF_EB("\033OF", ESC_STR "OF")}, /* alternate End */ | 1041 {K_XEND, IF_EB("\033OF", ESC_STR "OF")}, /* alternate End */ |
1058 {K_PAGEUP, IF_EB("\033[5~", ESC_STR "[5~")}, | 1042 {K_PAGEUP, IF_EB("\033[5;*~", ESC_STR "[5;*~")}, |
1059 {K_PAGEDOWN, IF_EB("\033[6~", ESC_STR "[6~")}, | 1043 {K_PAGEDOWN, IF_EB("\033[6;*~", ESC_STR "[6;*~")}, |
1060 {K_KPLUS, IF_EB("\033Ok", ESC_STR "Ok")}, /* keypad plus */ | 1044 {K_KPLUS, IF_EB("\033Ok", ESC_STR "Ok")}, /* keypad plus */ |
1061 {K_KMINUS, IF_EB("\033Om", ESC_STR "Om")}, /* keypad minus */ | 1045 {K_KMINUS, IF_EB("\033Om", ESC_STR "Om")}, /* keypad minus */ |
1062 {K_KDIVIDE, IF_EB("\033Oo", ESC_STR "Oo")}, /* keypad / */ | 1046 {K_KDIVIDE, IF_EB("\033Oo", ESC_STR "Oo")}, /* keypad / */ |
1063 {K_KMULTIPLY, IF_EB("\033Oj", ESC_STR "Oj")}, /* keypad * */ | 1047 {K_KMULTIPLY, IF_EB("\033Oj", ESC_STR "Oj")}, /* keypad * */ |
1064 {K_KENTER, IF_EB("\033OM", ESC_STR "OM")}, /* keypad Enter */ | 1048 {K_KENTER, IF_EB("\033OM", ESC_STR "OM")}, /* keypad Enter */ |
1065 {K_KDEL, IF_EB("\033[3~", ESC_STR "[3~")}, /* keypad Del */ | 1049 {K_KPOINT, IF_EB("\033On", ESC_STR "On")}, /* keypad . */ |
1050 {K_KDEL, IF_EB("\033[3;*~", ESC_STR "[3;*~")}, /* keypad Del */ | |
1066 | 1051 |
1067 {BT_EXTRA_KEYS, ""}, | 1052 {BT_EXTRA_KEYS, ""}, |
1068 {TERMCAP2KEY('k', '0'), IF_EB("\033[10~", ESC_STR "[10~")}, /* F0 */ | 1053 {TERMCAP2KEY('k', '0'), IF_EB("\033[10;*~", ESC_STR "[10;*~")}, /* F0 */ |
1069 {TERMCAP2KEY('F', '3'), IF_EB("\033[25~", ESC_STR "[25~")}, /* F13 */ | 1054 {TERMCAP2KEY('F', '3'), IF_EB("\033[25;*~", ESC_STR "[25;*~")}, /* F13 */ |
1070 {TERMCAP2KEY('F', '6'), IF_EB("\033[29~", ESC_STR "[29~")}, /* F16 */ | 1055 /* F14 and F15 are missing, because they send the same codes as the undo |
1071 {TERMCAP2KEY('F', '7'), IF_EB("\033[31~", ESC_STR "[31~")}, /* F17 */ | 1056 * and help key, although they don't work on all keyboards. */ |
1072 {TERMCAP2KEY('F', '8'), IF_EB("\033[32~", ESC_STR "[32~")}, /* F18 */ | 1057 {TERMCAP2KEY('F', '6'), IF_EB("\033[29;*~", ESC_STR "[29;*~")}, /* F16 */ |
1073 {TERMCAP2KEY('F', '9'), IF_EB("\033[33~", ESC_STR "[33~")}, /* F19 */ | 1058 {TERMCAP2KEY('F', '7'), IF_EB("\033[31;*~", ESC_STR "[31;*~")}, /* F17 */ |
1074 {TERMCAP2KEY('F', 'A'), IF_EB("\033[34~", ESC_STR "[34~")}, /* F20 */ | 1059 {TERMCAP2KEY('F', '8'), IF_EB("\033[32;*~", ESC_STR "[32;*~")}, /* F18 */ |
1060 {TERMCAP2KEY('F', '9'), IF_EB("\033[33;*~", ESC_STR "[33;*~")}, /* F19 */ | |
1061 {TERMCAP2KEY('F', 'A'), IF_EB("\033[34;*~", ESC_STR "[34;*~")}, /* F20 */ | |
1062 | |
1063 {TERMCAP2KEY('F', 'B'), IF_EB("\033[42;*~", ESC_STR "[42;*~")}, /* F21 */ | |
1064 {TERMCAP2KEY('F', 'C'), IF_EB("\033[43;*~", ESC_STR "[43;*~")}, /* F22 */ | |
1065 {TERMCAP2KEY('F', 'D'), IF_EB("\033[44;*~", ESC_STR "[44;*~")}, /* F23 */ | |
1066 {TERMCAP2KEY('F', 'E'), IF_EB("\033[45;*~", ESC_STR "[45;*~")}, /* F24 */ | |
1067 {TERMCAP2KEY('F', 'F'), IF_EB("\033[46;*~", ESC_STR "[46;*~")}, /* F25 */ | |
1068 {TERMCAP2KEY('F', 'G'), IF_EB("\033[47;*~", ESC_STR "[47;*~")}, /* F26 */ | |
1069 {TERMCAP2KEY('F', 'H'), IF_EB("\033[48;*~", ESC_STR "[48;*~")}, /* F27 */ | |
1070 {TERMCAP2KEY('F', 'I'), IF_EB("\033[49;*~", ESC_STR "[49;*~")}, /* F28 */ | |
1071 {TERMCAP2KEY('F', 'J'), IF_EB("\033[50;*~", ESC_STR "[50;*~")}, /* F29 */ | |
1072 {TERMCAP2KEY('F', 'K'), IF_EB("\033[51;*~", ESC_STR "[51;*~")}, /* F30 */ | |
1073 | |
1074 {TERMCAP2KEY('F', 'L'), IF_EB("\033[52;*~", ESC_STR "[52;*~")}, /* F31 */ | |
1075 {TERMCAP2KEY('F', 'M'), IF_EB("\033[53;*~", ESC_STR "[53;*~")}, /* F32 */ | |
1076 {TERMCAP2KEY('F', 'N'), IF_EB("\033[54;*~", ESC_STR "[54;*~")}, /* F33 */ | |
1077 {TERMCAP2KEY('F', 'O'), IF_EB("\033[55;*~", ESC_STR "[55;*~")}, /* F34 */ | |
1078 {TERMCAP2KEY('F', 'P'), IF_EB("\033[56;*~", ESC_STR "[56;*~")}, /* F35 */ | |
1079 {TERMCAP2KEY('F', 'Q'), IF_EB("\033[57;*~", ESC_STR "[57;*~")}, /* F36 */ | |
1080 {TERMCAP2KEY('F', 'R'), IF_EB("\033[58;*~", ESC_STR "[58;*~")}, /* F37 */ | |
1075 # endif | 1081 # endif |
1076 | 1082 |
1077 # if defined(UNIX) || defined(ALL_BUILTIN_TCAPS) | 1083 # if defined(UNIX) || defined(ALL_BUILTIN_TCAPS) |
1078 /* | 1084 /* |
1079 * iris-ansi for Silicon Graphics machines. | 1085 * iris-ansi for Silicon Graphics machines. |
1562 "su", "sd", /* Termcap code made up! */ | 1568 "su", "sd", /* Termcap code made up! */ |
1563 # endif | 1569 # endif |
1564 "#2", "#4", "%i", "*7", | 1570 "#2", "#4", "%i", "*7", |
1565 "k1", "k2", "k3", "k4", "k5", "k6", | 1571 "k1", "k2", "k3", "k4", "k5", "k6", |
1566 "k7", "k8", "k9", "k;", "F1", "F2", | 1572 "k7", "k8", "k9", "k;", "F1", "F2", |
1573 "F3", "F4", "F5", "F6", "F7", "F8", | |
1574 "F9", "FA", "FB", "FC", "FD", "FE", | |
1575 "FF", "FG", "FH", "FI", "FJ", "FK", | |
1576 "FL", "FM", "FN", "FO", "FP", "FQ", "FR", | |
1567 "%1", "&8", "kb", "kI", "kD", "kh", | 1577 "%1", "&8", "kb", "kI", "kD", "kh", |
1568 "@7", "kP", "kN", "K1", "K3", "K4", "K5", "kB", | 1578 "@7", "kP", "kN", "K1", "K3", "K4", "K5", "kB", |
1569 NULL | 1579 NULL |
1570 }; | 1580 }; |
1571 #endif | 1581 #endif |
2994 if (old_Rows != Rows || old_Columns != Columns) | 3004 if (old_Rows != Rows || old_Columns != Columns) |
2995 ui_new_shellsize(); | 3005 ui_new_shellsize(); |
2996 if (old_Rows != Rows) | 3006 if (old_Rows != Rows) |
2997 { | 3007 { |
2998 /* if 'window' uses the whole screen, keep it using that */ | 3008 /* if 'window' uses the whole screen, keep it using that */ |
2999 if (p_window == old_Rows - 1) | 3009 if (p_window == old_Rows - 1 || old_Rows == 0) |
3000 p_window = Rows - 1; | 3010 p_window = Rows - 1; |
3001 old_Rows = Rows; | 3011 old_Rows = Rows; |
3002 shell_new_rows(); /* update window sizes */ | 3012 shell_new_rows(); /* update window sizes */ |
3003 } | 3013 } |
3004 if (old_Columns != Columns) | 3014 if (old_Columns != Columns) |
3479 struct termcode | 3489 struct termcode |
3480 { | 3490 { |
3481 char_u name[2]; /* termcap name of entry */ | 3491 char_u name[2]; /* termcap name of entry */ |
3482 char_u *code; /* terminal code (in allocated memory) */ | 3492 char_u *code; /* terminal code (in allocated memory) */ |
3483 int len; /* STRLEN(code) */ | 3493 int len; /* STRLEN(code) */ |
3494 int modlen; /* length of part before ";*~". */ | |
3484 } *termcodes = NULL; | 3495 } *termcodes = NULL; |
3485 | 3496 |
3486 static int tc_max_len = 0; /* number of entries that termcodes[] can hold */ | 3497 static int tc_max_len = 0; /* number of entries that termcodes[] can hold */ |
3487 static int tc_len = 0; /* current number of entries in termcodes[] */ | 3498 static int tc_len = 0; /* current number of entries in termcodes[] */ |
3488 | 3499 |
3516 int use_8bit; /* replace 7-bit control by 8-bit one */ | 3527 int use_8bit; /* replace 7-bit control by 8-bit one */ |
3517 { | 3528 { |
3518 struct termcode *new_tc; | 3529 struct termcode *new_tc; |
3519 int i, j; | 3530 int i, j; |
3520 char_u *s; | 3531 char_u *s; |
3532 int len; | |
3521 | 3533 |
3522 if (string == NULL || *string == NUL) | 3534 if (string == NULL || *string == NUL) |
3523 { | 3535 { |
3524 del_termcode(name); | 3536 del_termcode(name); |
3525 return; | 3537 return; |
3533 if (use_8bit && term_7to8bit(string) != 0) | 3545 if (use_8bit && term_7to8bit(string) != 0) |
3534 { | 3546 { |
3535 mch_memmove(s, s + 1, STRLEN(s)); | 3547 mch_memmove(s, s + 1, STRLEN(s)); |
3536 s[0] = term_7to8bit(string); | 3548 s[0] = term_7to8bit(string); |
3537 } | 3549 } |
3550 len = (int)STRLEN(s); | |
3538 | 3551 |
3539 need_gather = TRUE; /* need to fill termleader[] */ | 3552 need_gather = TRUE; /* need to fill termleader[] */ |
3540 | 3553 |
3541 /* | 3554 /* |
3542 * need to make space for more entries | 3555 * need to make space for more entries |
3570 { | 3583 { |
3571 if (termcodes[i].name[1] < name[1]) | 3584 if (termcodes[i].name[1] < name[1]) |
3572 continue; | 3585 continue; |
3573 /* | 3586 /* |
3574 * Exact match: Replace old code. | 3587 * Exact match: Replace old code. |
3588 * But don't replace ESC[123;*X with another. | |
3575 */ | 3589 */ |
3576 if (termcodes[i].name[1] == name[1]) | 3590 if (termcodes[i].name[1] == name[1]) |
3577 { | 3591 { |
3578 vim_free(termcodes[i].code); | 3592 if (termcodes[i].len >= 4 |
3579 --tc_len; | 3593 && STRNCMP(termcodes[i].code + termcodes[i].len - 3, |
3580 break; | 3594 ";*", 2) == 0) |
3595 { | |
3596 /* if they are equal but for the ";*" don't add it */ | |
3597 if (len == termcodes[i].len - 2 | |
3598 && STRNCMP(s, termcodes[i].code, len - 1) == 0 | |
3599 && s[len - 1] == termcodes[i].code[len + 1]) | |
3600 { | |
3601 vim_free(s); | |
3602 return; | |
3603 } | |
3604 } | |
3605 else | |
3606 { | |
3607 vim_free(termcodes[i].code); | |
3608 --tc_len; | |
3609 break; | |
3610 } | |
3581 } | 3611 } |
3582 } | 3612 } |
3583 /* | 3613 /* |
3584 * Found alphabetical larger entry, move rest to insert new entry | 3614 * Found alphabetical larger entry, move rest to insert new entry |
3585 */ | 3615 */ |
3589 } | 3619 } |
3590 | 3620 |
3591 termcodes[i].name[0] = name[0]; | 3621 termcodes[i].name[0] = name[0]; |
3592 termcodes[i].name[1] = name[1]; | 3622 termcodes[i].name[1] = name[1]; |
3593 termcodes[i].code = s; | 3623 termcodes[i].code = s; |
3594 termcodes[i].len = (int)STRLEN(s); | 3624 termcodes[i].len = len; |
3625 /* recognize special code like "ESC[42;*X" that accepts modifiers */ | |
3626 if (len >= 5 && STRNCMP(s + len - 3, ";*", 2) == 0) | |
3627 termcodes[i].modlen = len - 3; | |
3628 else | |
3629 termcodes[i].modlen = 0; | |
3595 ++tc_len; | 3630 ++tc_len; |
3596 } | 3631 } |
3597 | 3632 |
3598 char_u * | 3633 char_u * |
3599 find_termcode(name) | 3634 find_termcode(name) |
3883 | 3918 |
3884 key_name[0] = termcodes[idx].name[0]; | 3919 key_name[0] = termcodes[idx].name[0]; |
3885 key_name[1] = termcodes[idx].name[1]; | 3920 key_name[1] = termcodes[idx].name[1]; |
3886 | 3921 |
3887 break; | 3922 break; |
3923 } | |
3924 | |
3925 /* | |
3926 * Check for code with modifier, like xterm uses: | |
3927 * ESC[123;2X (shift) ESC[123;3X (alt), etc. | |
3928 */ | |
3929 if (termcodes[idx].modlen > 0) | |
3930 { | |
3931 slen = termcodes[idx].modlen; | |
3932 if (cpo_koffset && offset && len < slen) | |
3933 continue; | |
3934 if (STRNCMP(termcodes[idx].code, tp, | |
3935 (size_t)(slen > len ? len : slen)) == 0) | |
3936 { | |
3937 int n; | |
3938 int mod; | |
3939 | |
3940 if (len <= slen) /* got a partial sequence */ | |
3941 return -1; /* need to get more chars */ | |
3942 | |
3943 if (tp[slen] == termcodes[idx].code[slen + 2]) | |
3944 ++slen; /* no modifiers */ | |
3945 else if (tp[slen] != ';') | |
3946 continue; /* no match */ | |
3947 else | |
3948 { | |
3949 /* Skip over the digits, the final char must | |
3950 * follow. */ | |
3951 for (j = slen + 1; j < len && isdigit(tp[j]); ++j) | |
3952 ; | |
3953 ++j; | |
3954 if (len < j) /* got a partial sequence */ | |
3955 return -1; /* need to get more chars */ | |
3956 if (tp[j - 1] != termcodes[idx].code[slen + 2]) | |
3957 continue; | |
3958 | |
3959 /* Match! Convert modifier bits. */ | |
3960 n = atoi((char *)tp + slen + 1) - 1; | |
3961 mod = 0x0; | |
3962 if (n & 1) | |
3963 mod |= MOD_MASK_SHIFT; | |
3964 if (n & 2) | |
3965 mod |= MOD_MASK_ALT; | |
3966 if (n & 4) | |
3967 mod |= MOD_MASK_CTRL; | |
3968 if (n & 8) | |
3969 mod |= MOD_MASK_META; | |
3970 | |
3971 /* Add the modifier codes to our string */ | |
3972 if (mod != 0) | |
3973 { | |
3974 string[new_slen++] = K_SPECIAL; | |
3975 string[new_slen++] = (int)KS_MODIFIER; | |
3976 string[new_slen++] = mod; | |
3977 } | |
3978 | |
3979 slen = j; | |
3980 } | |
3981 key_name[0] = termcodes[idx].name[0]; | |
3982 key_name[1] = termcodes[idx].name[1]; | |
3983 | |
3984 break; | |
3985 } | |
3888 } | 3986 } |
3889 } | 3987 } |
3890 } | 3988 } |
3891 | 3989 |
3892 #ifdef FEAT_TERMRESPONSE | 3990 #ifdef FEAT_TERMRESPONSE |