diff -ur mc-4.8.0.orig/lib/tty/key.c mc-4.8.0/lib/tty/key.c
old
|
new
|
|
932 | 932 | |
933 | 933 | /* --------------------------------------------------------------------------------------------- */ |
934 | 934 | /* Parse extended mouse coordinates. |
935 | | Returns -1 if pending_keys cannot be a prefix of extended mouse coordinates. |
936 | | Returns 0 if pending_keys is a valid (but still incomplete) prefix for extended mouse |
937 | | coordinates, e.g. "^[[32;4". |
938 | | Returns 1 and fills the mouse_btn, mouse_x, mouse_y values if pending_keys is a complete extended |
939 | | mouse sequence, e.g. "^[[32;42;5M" |
| 935 | Returns -1 if pending_keys (up to seq_append) cannot be a prefix of extended mouse coordinates. |
| 936 | Returns 0 if pending_keys (up to seq_append) is a valid (but still incomplete) prefix for |
| 937 | extended mouse coordinates, e.g. "^[[32;4". |
| 938 | Returns 1 and fills the mouse_btn, mouse_x, mouse_y values if pending_keys (up to seq_append) is |
| 939 | a complete extended mouse sequence, e.g. "^[[32;42;5M" |
940 | 940 | */ |
941 | 941 | |
942 | 942 | /* Technical info (Egmont Koblinger <egmont@gmail.com>): |
943 | 943 | |
944 | | The ancient way of reporting mouse coordinates only supports coordinates up to 231, |
| 944 | The ancient way of reporting mouse coordinates only supports coordinates up to 223, |
945 | 945 | so if your terminal is wider (or taller, but that's unlikely), you cannot use your mouse |
946 | 946 | in the rightmost columns. |
947 | 947 | |
… |
… |
|
951 | 951 | <x+32> and <y+32> are single bytes. (Action is 0 for left click, 1 for middle click, |
952 | 952 | 2 for right click, 3 for release, or something like this.) |
953 | 953 | + Disadvantages of this format: |
954 | | + x and y can only go up to 231. |
| 954 | + x and y can only go up to 223. |
955 | 955 | + Coordinates above 95 are not ascii-compatible, so any character set converting |
956 | 956 | layer (e.g. luit) messes them up. |
957 | 957 | + The stream is not valid UTF-8, even if everything else is. |
… |
… |
|
988 | 988 | Currently, at least the following terminal emulators have support for these: |
989 | 989 | * xterm supports the xterm extension |
990 | 990 | * rxvt-unicode >= 9.10 supports both extensions |
991 | | * iterm2 supports both extensions. |
| 991 | * iterm2 supports both extensions |
| 992 | * vte >= 0.31 supports the urxvt extension |
992 | 993 | */ |
993 | 994 | |
994 | 995 | static int |
… |
… |
|
996 | 997 | { |
997 | 998 | int c, btn = 0, x = 0, y = 0; |
998 | 999 | const int *p = pending_keys; |
| 1000 | const int *endp = seq_append; |
999 | 1001 | |
1000 | | c = *p++; |
1001 | | if (c == 0) |
| 1002 | if (p == endp) |
1002 | 1003 | return 0; |
| 1004 | c = *p++; |
1003 | 1005 | if (c != ESC_CHAR) |
1004 | 1006 | return -1; |
1005 | 1007 | |
1006 | | c = *p++; |
1007 | | if (c == 0) |
| 1008 | if (p == endp) |
1008 | 1009 | return 0; |
| 1010 | c = *p++; |
1009 | 1011 | if (c != '[') |
1010 | 1012 | return -1; |
1011 | 1013 | |
1012 | 1014 | while (TRUE) |
1013 | 1015 | { |
1014 | | c = *p++; |
1015 | | if (c == 0) |
| 1016 | if (p == endp) |
1016 | 1017 | return 0; |
| 1018 | c = *p++; |
1017 | 1019 | if (c == ';') |
1018 | 1020 | break; |
1019 | 1021 | if (c < '0' || c > '9') |
… |
… |
|
1026 | 1028 | |
1027 | 1029 | while (TRUE) |
1028 | 1030 | { |
1029 | | c = *p++; |
1030 | | if (c == 0) |
| 1031 | if (p == endp) |
1031 | 1032 | return 0; |
| 1033 | c = *p++; |
1032 | 1034 | if (c == ';') |
1033 | 1035 | break; |
1034 | 1036 | if (c < '0' || c > '9') |
… |
… |
|
1040 | 1042 | |
1041 | 1043 | while (TRUE) |
1042 | 1044 | { |
1043 | | c = *p++; |
1044 | | if (c == 0) |
| 1045 | if (p == endp) |
1045 | 1046 | return 0; |
| 1047 | c = *p++; |
1046 | 1048 | if (c == 'M') |
1047 | 1049 | break; |
1048 | 1050 | if (c < '0' || c > '9') |