annotate src/readline-2-event-hook.patch @ 7251:e3bf1ceb1511 default tip @

Mesa 3D: Fix building for Linux without libdrm. * src/mesa-1-libdrm.patch: Add new patch. * dist-files.mk: Add new file to list.
author Markus Mützel <markus.muetzel@gmx.de>
date Wed, 12 Jun 2024 20:54:42 +0200
parents 7c302266a10b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6545
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
1 diff -urN readline-8.2/input.c.orig readline-8.2/input.c
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
2 --- readline-8.2/input.c.orig 2022-04-08 21:43:24.000000000 +0200
6566
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
3 +++ readline-8.2/input.c 2022-12-12 09:58:00.410673600 +0100
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
4 @@ -176,6 +176,14 @@
5031
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
5 static unsigned char ibuffer[512];
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
6 static int ibuffer_len = sizeof (ibuffer) - 1;
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
7
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
8 +#if defined (__MINGW32__)
6545
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
9 +#include <windows.h>
6566
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
10 +static int _win32_getch (void);
5031
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
11 +static int _win32_kbhit (void);
6566
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
12 +static char _win32_buf[16] = {'0'};
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
13 +static int _win32_bufidx = 0;
5031
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
14 +#endif
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
15 +
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
16 #define any_typein (push_index != pop_index)
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
17
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
18 int
6566
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
19 @@ -187,7 +195,11 @@
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
20 int
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
21 _rl_pushed_input_available (void)
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
22 {
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
23 - return (push_index != pop_index);
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
24 + return ((push_index != pop_index)
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
25 +#if defined (__MINGW32__)
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
26 + || (_win32_bufidx > 0)
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
27 +#endif
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
28 + );
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
29 }
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
30
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
31 /* Return the amount of space available in the buffer for stuffing
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
32 @@ -306,7 +318,7 @@
5031
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
33 #if defined (__MINGW32__)
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
34 /* Use getch/_kbhit to check for available console input, in the same way
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
35 that we read it normally. */
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
36 - chars_avail = isatty (tty) ? _kbhit () : 0;
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
37 + chars_avail = isatty (tty) ? _win32_kbhit () : 0;
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
38 result = 0;
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
39 #endif
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
40
6566
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
41 @@ -404,7 +416,7 @@
6545
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
42
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
43 #if defined (__MINGW32__)
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
44 if (isatty (tty))
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
45 - return (_kbhit ());
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
46 + return (_win32_kbhit ());
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
47 #endif
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
48
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
49 return 0;
6566
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
50 @@ -799,6 +811,139 @@
5031
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
51 return (c);
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
52 }
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
53
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
54 +#if defined (__MINGW32__)
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
55 +#define _WIN32_READ_NOCHAR (-2)
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
56 +
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
57 +static int
6566
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
58 +_win32_getch_internal (int block)
5031
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
59 +{
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
60 + INPUT_RECORD rec;
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
61 + DWORD evRead, waitResult;
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
62 + HANDLE hInput = (HANDLE) _get_osfhandle (fileno (rl_instream));
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
63 +
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
64 + if (_win32_bufidx > 0)
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
65 + return _win32_buf[--_win32_bufidx];
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
66 +
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
67 + hInput = (HANDLE) _get_osfhandle (fileno (rl_instream));
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
68 +
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
69 + do
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
70 + {
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
71 + if (! block)
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
72 + {
6545
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
73 + if (WaitForSingleObject (hInput, _keyboard_input_timeout/1000) != WAIT_OBJECT_0)
5031
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
74 + return _WIN32_READ_NOCHAR;
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
75 + }
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
76 +
6566
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
77 + if (! ReadConsoleInputW (hInput, &rec, 1, &evRead) || evRead != 1)
5031
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
78 + return EOF;
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
79 +
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
80 + switch (rec.EventType)
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
81 + {
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
82 + case KEY_EVENT:
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
83 + if ((rec.Event.KeyEvent.bKeyDown &&
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
84 + (rec.Event.KeyEvent.wVirtualKeyCode < VK_SHIFT ||
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
85 + rec.Event.KeyEvent.wVirtualKeyCode > VK_MENU)) ||
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
86 + (!rec.Event.KeyEvent.bKeyDown &&
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
87 + rec.Event.KeyEvent.wVirtualKeyCode == VK_MENU &&
6545
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
88 + rec.Event.KeyEvent.uChar.UnicodeChar))
5031
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
89 + {
6545
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
90 + if (rec.Event.KeyEvent.uChar.UnicodeChar)
6566
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
91 + {
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
92 + int result = (int) rec.Event.KeyEvent.uChar.UnicodeChar;
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
93 + char charbuf[5] = {0};
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
94 + wchar_t unicode[2] = {result, 0};
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
95 + int utf16_code_units = 1;
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
96 + if ((unicode[0] & 0xF800) == 0xD800) /* outside BMP */
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
97 + {
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
98 + ReadConsoleInputW (hInput, &rec, 1, &evRead);
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
99 + unicode[1] = (int) rec.Event.KeyEvent.uChar.UnicodeChar;
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
100 + utf16_code_units++;
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
101 + }
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
102 + /* convert to current codepage or UTF-8 byte sequence */
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
103 + unsigned int codepage = CP_THREAD_ACP;
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
104 + if (_rl_utf8locale)
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
105 + codepage = CP_UTF8;
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
106 + int len = WideCharToMultiByte (codepage, 0,
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
107 + (wchar_t *) &unicode, utf16_code_units,
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
108 + charbuf, 5, NULL, NULL);
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
109 + /* buffer is read from back to front */
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
110 + for (int i=0; i<len-1; i++)
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
111 + _win32_buf[_win32_bufidx++] = (unsigned char) charbuf[len-i-1];
6545
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
112 +
6566
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
113 + return (int) (unsigned char) charbuf[0];
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
114 + }
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
115 +
6545
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
116 + switch (rec.Event.KeyEvent.wVirtualKeyCode)
5031
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
117 + {
6566
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
118 + /* buffer is read from back to front */
6545
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
119 + case VK_UP:
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
120 + _win32_buf[_win32_bufidx++] = 'A';
6566
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
121 + _win32_buf[_win32_bufidx++] = '[';
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
122 + return 0x1b; /* ESC */
6545
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
123 + case VK_DOWN:
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
124 + _win32_buf[_win32_bufidx++] = 'B';
6566
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
125 + _win32_buf[_win32_bufidx++] = '[';
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
126 + return 0x1b; /* ESC */
6545
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
127 + case VK_RIGHT:
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
128 + _win32_buf[_win32_bufidx++] = 'C';
6566
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
129 + _win32_buf[_win32_bufidx++] = '[';
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
130 + return 0x1b; /* ESC */
6545
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
131 + case VK_LEFT:
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
132 + _win32_buf[_win32_bufidx++] = 'D';
6566
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
133 + _win32_buf[_win32_bufidx++] = '[';
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
134 + return 0x1b; /* ESC */
6545
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
135 + case VK_HOME:
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
136 + _win32_buf[_win32_bufidx++] = 'H';
6566
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
137 + _win32_buf[_win32_bufidx++] = '[';
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
138 + return 0x1b; /* ESC */
6545
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
139 + case VK_END:
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
140 + _win32_buf[_win32_bufidx++] = 'F';
6566
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
141 + _win32_buf[_win32_bufidx++] = '[';
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
142 + return 0x1b; /* ESC */
6545
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
143 + case VK_DELETE:
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
144 + _win32_buf[_win32_bufidx++] = 8;
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
145 + _win32_buf[_win32_bufidx++] = 'C';
6566
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
146 + _win32_buf[_win32_bufidx++] = '[';
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
147 + return 0x1b; /* ESC */
6545
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
148 + default:
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
149 + break;
5031
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
150 + }
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
151 + }
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
152 + break;
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
153 +
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
154 + case WINDOW_BUFFER_SIZE_EVENT:
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
155 + rl_resize_terminal ();
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
156 + break;
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
157 +
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
158 + default:
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
159 + break;
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
160 + }
6545
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
161 + }
5031
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
162 + while (1);
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
163 +}
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
164 +
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
165 +static int
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
166 +_win32_kbhit (void)
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
167 +{
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
168 + int result;
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
169 +
6566
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
170 + result = _win32_getch_internal (0);
5031
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
171 + if (result == _WIN32_READ_NOCHAR
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
172 + || result == EOF)
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
173 + return 0;
6545
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
174 +
6566
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
175 + _win32_buf[_win32_bufidx++] = result;
5031
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
176 +
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
177 + return _win32_bufidx;
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
178 +}
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
179 +
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
180 +static int
6566
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
181 +_win32_getch (void)
5031
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
182 +{
6566
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
183 + return (_win32_getch_internal (1));
5031
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
184 +}
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
185 +#endif
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
186 +
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
187 int
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
188 rl_getc (FILE *stream)
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
189 {
6566
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
190 @@ -818,8 +963,8 @@
6545
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
191 /* We know at this point that _rl_caught_signal == 0 */
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
192
5031
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
193 #if defined (__MINGW32__)
6545
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
194 - if (isatty (fd)
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
195 - return (_getch ()); /* "There is no error return." */
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
196 + if (isatty (fd))
6566
7c302266a10b readline: Fix handling of escape sequences in callback mode.
Markus Mützel <markus.muetzel@gmx.de>
parents: 6554
diff changeset
197 + return (_win32_getch ());
5031
5049ab5e66f6 Re-add readline patches to work with readline 8 (Bug #55957)
John Donoghue
parents:
diff changeset
198 #endif
6545
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
199 result = 0;
a76f513700df readline: Fix issue with arrow keys in Octave CLI (bug #63400).
Markus Mützel <markus.muetzel@gmx.de>
parents: 5607
diff changeset
200 #if defined (HAVE_PSELECT) || defined (HAVE_SELECT)