File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -1042,13 +1042,32 @@ console_key_pressed_p(VALUE io, VALUE k)
1042
1042
return GetKeyState (vk ) & 0x80 ? Qtrue : Qfalse ;
1043
1043
}
1044
1044
#else
1045
+ static int
1046
+ direct_query (VALUE io , VALUE query )
1047
+ {
1048
+ if (RB_TYPE_P (io , T_FILE )) {
1049
+ rb_io_t * fptr ;
1050
+ VALUE wio ;
1051
+ GetOpenFile (io , fptr );
1052
+ wio = fptr -> tied_io_for_writing ;
1053
+ if (wio ) {
1054
+ rb_io_write (wio , query );
1055
+ rb_io_flush (wio );
1056
+ return 1 ;
1057
+ }
1058
+ if (write (fptr -> fd , RSTRING_PTR (query ), RSTRING_LEN (query )) != -1 ) {
1059
+ return 1 ;
1060
+ }
1061
+ }
1062
+ return 0 ;
1063
+ }
1064
+
1045
1065
static VALUE
1046
1066
read_vt_response (VALUE io , VALUE query )
1047
1067
{
1048
1068
VALUE result , b ;
1049
1069
int num = 0 ;
1050
- if (!NIL_P (query )) rb_io_write (io , query );
1051
- rb_io_flush (io );
1070
+ if (!NIL_P (query ) && !direct_query (io , query )) return Qnil ;
1052
1071
if (rb_io_getbyte (io ) != INT2FIX (0x1b )) return Qnil ;
1053
1072
if (rb_io_getbyte (io ) != INT2FIX ('[' )) return Qnil ;
1054
1073
result = rb_ary_new ();
You can’t perform that action at this time.
0 commit comments