mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-18 23:12:15 +08:00
Make requested console reports work
cf https://cygwin.com/ml/cygwin-patches/2012-q3/msg00019.html This enables the following ESC sequences: ESC[c sends primary device attributes ESC[>c sends secondary device attributes ESC[6n sends cursor position report * fhandler.h (class dev_console): Add console read-ahead buffer. (class fhandler_console): Add peek function for it (for select). * fhandler_console.cc (fhandler_console::setup): Init buffer. (fhandler_console::read): Check console read-aheader buffer. (fhandler_console::char_command): Put responses to terminal requests (device status and cursor position reports) into common console buffer (shared between CONOUT/CONIN) instead of fhandler buffer (separated). * select.cc (peek_console): Check console read-ahead buffer.
This commit is contained in:
parent
e8e379ff1d
commit
734656818a
@ -1352,6 +1352,8 @@ class dev_console
|
|||||||
bool ext_mouse_mode15;
|
bool ext_mouse_mode15;
|
||||||
bool use_focus;
|
bool use_focus;
|
||||||
bool raw_win32_keyboard_mode;
|
bool raw_win32_keyboard_mode;
|
||||||
|
char cons_rabuf[40]; // cannot get longer than char buf[40] in char_command
|
||||||
|
char *cons_rapoi;
|
||||||
|
|
||||||
inline UINT get_console_cp ();
|
inline UINT get_console_cp ();
|
||||||
DWORD con_to_str (char *d, int dlen, WCHAR w);
|
DWORD con_to_str (char *d, int dlen, WCHAR w);
|
||||||
@ -1449,6 +1451,10 @@ private:
|
|||||||
int init (HANDLE, DWORD, mode_t);
|
int init (HANDLE, DWORD, mode_t);
|
||||||
bool mouse_aware (MOUSE_EVENT_RECORD& mouse_event);
|
bool mouse_aware (MOUSE_EVENT_RECORD& mouse_event);
|
||||||
bool focus_aware () {return shared_console_info->con.use_focus;}
|
bool focus_aware () {return shared_console_info->con.use_focus;}
|
||||||
|
bool get_cons_readahead_valid ()
|
||||||
|
{
|
||||||
|
return shared_console_info->con.cons_rapoi != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
select_record *select_read (select_stuff *);
|
select_record *select_read (select_stuff *);
|
||||||
select_record *select_write (select_stuff *);
|
select_record *select_write (select_stuff *);
|
||||||
|
@ -196,6 +196,7 @@ fhandler_console::setup ()
|
|||||||
con.meta_mask |= RIGHT_ALT_PRESSED;
|
con.meta_mask |= RIGHT_ALT_PRESSED;
|
||||||
con.set_default_attr ();
|
con.set_default_attr ();
|
||||||
con.backspace_keycode = CERASE;
|
con.backspace_keycode = CERASE;
|
||||||
|
con.cons_rapoi = NULL;
|
||||||
shared_console_info->tty_min_state.is_console = true;
|
shared_console_info->tty_min_state.is_console = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -310,6 +311,14 @@ fhandler_console::read (void *pv, size_t& buflen)
|
|||||||
int ch;
|
int ch;
|
||||||
set_input_state ();
|
set_input_state ();
|
||||||
|
|
||||||
|
/* Check console read-ahead buffer filled from terminal requests */
|
||||||
|
if (con.cons_rapoi && *con.cons_rapoi)
|
||||||
|
{
|
||||||
|
*buf = *con.cons_rapoi++;
|
||||||
|
buflen = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int copied_chars = get_readahead_into_buffer (buf, buflen);
|
int copied_chars = get_readahead_into_buffer (buf, buflen);
|
||||||
|
|
||||||
if (copied_chars)
|
if (copied_chars)
|
||||||
@ -1899,8 +1908,11 @@ fhandler_console::char_command (char c)
|
|||||||
strcpy (buf, "\033[?6c");
|
strcpy (buf, "\033[?6c");
|
||||||
/* The generated report needs to be injected for read-ahead into the
|
/* The generated report needs to be injected for read-ahead into the
|
||||||
fhandler_console object associated with standard input.
|
fhandler_console object associated with standard input.
|
||||||
The current call does not work. */
|
So puts_readahead does not work.
|
||||||
puts_readahead (buf);
|
Use a common console read-ahead buffer instead. */
|
||||||
|
con.cons_rapoi = NULL;
|
||||||
|
strcpy (con.cons_rabuf, buf);
|
||||||
|
con.cons_rapoi = con.cons_rabuf;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
switch (con.args[0])
|
switch (con.args[0])
|
||||||
@ -1910,9 +1922,11 @@ fhandler_console::char_command (char c)
|
|||||||
y -= con.b.srWindow.Top;
|
y -= con.b.srWindow.Top;
|
||||||
/* x -= con.b.srWindow.Left; // not available yet */
|
/* x -= con.b.srWindow.Left; // not available yet */
|
||||||
__small_sprintf (buf, "\033[%d;%dR", y + 1, x + 1);
|
__small_sprintf (buf, "\033[%d;%dR", y + 1, x + 1);
|
||||||
puts_readahead (buf);
|
con.cons_rapoi = NULL;
|
||||||
|
strcpy (con.cons_rabuf, buf);
|
||||||
|
con.cons_rapoi = con.cons_rabuf;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto bad_escape;
|
goto bad_escape;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -845,6 +845,12 @@ peek_console (select_record *me, bool)
|
|||||||
if (!me->read_selected)
|
if (!me->read_selected)
|
||||||
return me->write_ready;
|
return me->write_ready;
|
||||||
|
|
||||||
|
if (fh->get_cons_readahead_valid ())
|
||||||
|
{
|
||||||
|
select_printf ("cons_readahead");
|
||||||
|
return me->read_ready = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (fh->get_readahead_valid ())
|
if (fh->get_readahead_valid ())
|
||||||
{
|
{
|
||||||
select_printf ("readahead");
|
select_printf ("readahead");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user