Mail Archives: cygwin/2000/05/28/16:27:03
In <20000528154718 DOT A6255 AT cygnus DOT com>
Chris Faylor wrote:
"Re: [cygdev] win9x ansi secseq"
| On Sun, May 28, 2000 at 09:12:00PM +0900, S.Yoshida wrote:
| >MS-DOS Console patch.
|
| Makes no sense without explanation. Sorry.
Japanse version of windows9x load Japanese Font Driver <device=jdisp.sys> In config.sys.
Some Win32 Console Api don't work, in full screen ms-dos prompt.
....Scroll (nothing), Attributes (buggy), Colors (dirty).
Please,, if( NULL != (cygenv = getenv("CYGWIN")) && 0 == strstr( cygenv, "win9xansi" ) ){
diff -Hpwr cygwin-20000525/winsup/cygwin/fhandler.h cygwin-snap/winsup/cygwin/fhandler.h
*** cygwin-20000525/winsup/cygwin/fhandler.h Fri May 12 14:09:04 2000
--- cygwin-snap/winsup/cygwin/fhandler.h Sun May 28 21:09:42 2000
*************** private:
*** 549,554 ****
--- 549,575 ----
int args_[MAXARGS];
int nargs_;
+ #ifndef DISABLE_ANSI_SNAP // S.Yoshida
+ #define ansicmd_ansi 0
+ #define ansicmd_win32 1
+ #define ansicmd_emu_linux 2 // TODO
+ int console_mode_;
+ int enable_buffer_;
+ #define MAXINTBUF 2048
+ char fifo_buffer_[ MAXINTBUF ];
+ int fifo_x_;
+ int fifo_write_( const void *p, int len );
+ int fifo_flush_( void );
+ #else
+ int fifo_write_( const void *p, int len ) {
+ DWORD done;
+ WriteFile (get_output_handle (), p, len, &done, 0 );
+ return done;
+ }
+ int fifo_flush_( void ) {
+ }
+ #endif
+
DWORD default_color;
/* Output calls */
diff -Hpwr cygwin-20000525/winsup/cygwin/fhandler_console.cc cygwin-snap/winsup/cygwin/fhandler_console.cc
*** cygwin-20000525/winsup/cygwin/fhandler_console.cc Tue Apr 25 12:55:24 2000
--- cygwin-snap/winsup/cygwin/fhandler_console.cc Mon May 29 04:30:38 2000
*************** set_console_state_for_spawn ()
*** 108,113 ****
--- 108,153 ----
return 1;
}
+
+ #ifndef DISABLE_ANSI_SNAP
+ int fhandler_console::fifo_write_( const void *p, int len )
+ {
+ if( enable_buffer_ ) {
+ const char *s = (const char *)p;
+ const char *l = s + len;
+ int e;
+
+ while( s < l ) {
+ e = MAXINTBUF - fifo_x_;
+ if( (l - s) < e ) e = l - s;
+ memcpy( fifo_buffer_ + fifo_x_, s, e );
+ fifo_x_ += e;
+ s += e;
+ if( fifo_x_ == MAXINTBUF ) {
+ fifo_flush_ ();
+ if( fifo_x_ == MAXINTBUF ) break;
+ }
+ }
+ return s - (const char *)p;
+ }
+ DWORD done = 0;
+ WriteFile (get_output_handle (), p, len, &done, 0);
+ return done;
+ }
+
+ int fhandler_console::fifo_flush_( void )
+ {
+ DWORD done = 0;
+ if( fifo_x_ ) {
+ WriteFile (get_output_handle (), fifo_buffer_, fifo_x_, &done, 0);
+ if( done != 0 && done != (DWORD)fifo_x_ )
+ memmove( fifo_buffer_, fifo_buffer_ + done, fifo_x_ - done );
+ fifo_x_ -= done;
+ }
+ return done;
+ }
+ #endif // !DISABLE_ANSI_SNAP
+
int
fhandler_console::read (void *pv, size_t buflen)
{
*************** fhandler_console::scroll_screen (int x1,
*** 257,262 ****
--- 297,303 ----
CHAR_INFO fill;
COORD dest;
+ fifo_flush_ ();
(void)fillin_info ();
sr1.Left = x1 >= 0 ? x1 : info.dwWinSize.X - 1;
if (y1 == 0)
*************** fhandler_console::open (const char *, in
*** 350,355 ****
--- 391,397 ----
int
fhandler_console::close (void)
{
+ fifo_flush_ ();
CloseHandle (get_io_handle ());
CloseHandle (get_output_handle ());
set_io_handle (INVALID_HANDLE_VALUE);
*************** fhandler_console::dup (fhandler_base *ch
*** 367,372 ****
--- 409,415 ----
{
fhandler_console *fhc = (fhandler_console *) child;
+ fifo_flush_ ();
if (!fhc->open(get_name (), get_flags (), 0))
system_printf ("error opening console, %E");
*************** fhandler_console::output_tcsetattr (int,
*** 434,439 ****
--- 477,483 ----
instantly */
/* Enable/disable LF -> CRLF conversions */
+ fifo_flush_ ();
set_w_binary ((t->c_oflag & ONLCR) ? 0 : 1);
/* All the output bits we can ignore */
*************** fhandler_console::fhandler_console (cons
*** 580,585 ****
--- 624,646 ----
set_cb (sizeof *this);
state_ = normal;
set_need_fork_fixup ();
+ #ifndef DISABLE_ANSI_SNAP
+ char *pterm = getenv("TERM");
+ console_mode_ = ansicmd_win32;
+ if( !stricmp( pterm, "pcansi" ) ) {
+ console_mode_ = ansicmd_ansi;
+ } else if( strstr( pterm, "ansi" ) ) {
+ console_mode_ = ansicmd_ansi;
+ } else {
+ // TODO linux -> ansi emulater -thru> fifo_write_
+ // console_mode_ = ansicmd_emu_linux;
+ OSVERSIONINFO osv;
+ GetVersionEx( &osv );
+ console_mode_ = ( osv.dwPlatformId == VER_PLATFORM_WIN32_NT );
+ }
+ enable_buffer_ = 1; // speedy on win9x
+ fifo_x_ = 0;
+ #endif
}
/*
*************** fhandler_console::clear_screen (int x1,
*** 593,598 ****
--- 654,660 ----
DWORD done;
int num;
+ fifo_flush_ ();
(void)fillin_info ();
if (x1 < 0)
*************** fhandler_console::cursor_set (BOOL rel_t
*** 632,637 ****
--- 694,700 ----
{
COORD pos;
+ fifo_flush_ ();
(void)fillin_info ();
if (y > info.winBottom)
y = info.winBottom;
*************** fhandler_console::cursor_set (BOOL rel_t
*** 653,658 ****
--- 716,722 ----
void
fhandler_console::cursor_rel (int x, int y)
{
+ fifo_flush_ ();
fillin_info ();
x += info.dwCursorPosition.X;
y += info.dwCursorPosition.Y;
*************** fhandler_console::cursor_rel (int x, int
*** 662,667 ****
--- 726,732 ----
void
fhandler_console::cursor_get (int *x, int *y)
{
+ fifo_flush_ ();
fillin_info ();
*y = info.dwCursorPosition.Y;
*x = info.dwCursorPosition.X;
*************** fhandler_console::char_command (char c)
*** 853,858 ****
--- 918,924 ----
bold = default_color & FOREGROUND_INTENSITY;
break;
}
+ fifo_flush_ ();
SetConsoleTextAttribute (get_output_handle (), fg | bg | bold);
break;
case 'h':
*************** fhandler_console::char_command (char c)
*** 974,980 ****
break;
case 'b': /* Repeat char #1 #2 times */
while (args_[1]--)
! WriteFile (get_output_handle (), &args_[0], 1, (DWORD *) &x, 0);
break;
case 'c': /* u9 - Terminal enquire string */
strcpy (buf, "\033[?6c");
--- 1040,1046 ----
break;
case 'b': /* Repeat char #1 #2 times */
while (args_[1]--)
! fifo_write_ ( &args_[0], 1 );
break;
case 'c': /* u9 - Terminal enquire string */
strcpy (buf, "\033[?6c");
*************** fhandler_console::write_normal (const un
*** 1012,1018 ****
const unsigned char *end)
{
/* Scan forward to see what a char which needs special treatment */
- DWORD done;
const unsigned char *found = src;
while (found < end)
--- 1078,1083 ----
*************** fhandler_console::write_normal (const un
*** 1024,1040 ****
/* Print all the base ones out */
if (found != src)
{
! if (! WriteFile (get_output_handle (), src, found - src, &done, 0))
! {
! debug_printf ("write failed, handle %p", get_output_handle ());
! __seterrno ();
! return 0;
! }
! src += done;
}
if (src < end)
{
int x, y;
switch (base_chars[*src])
{
case BEL:
--- 1089,1114 ----
/* Print all the base ones out */
if (found != src)
{
! src += fifo_write_( src, found - src );
}
if (src < end)
{
int x, y;
+ #if 1 // S.Yoshida
+ if (console_mode_ == ansicmd_ansi)
+ {
+ fifo_write_( src, 1 );
+ switch (base_chars[*src] != DWN)
+ {
+ case BEL:
+ break;
+ case DWN:
+ break;
+ default:
+ goto skip_a_char;
+ }
+ }
+ #endif
switch (base_chars[*src])
{
case BEL:
*************** fhandler_console::write_normal (const un
*** 1053,1059 ****
y--;
}
else
! WriteFile (get_output_handle (), "\n", 1, &done, 0);
}
if (!get_w_binary ())
x = 0;
--- 1127,1133 ----
y--;
}
else
! fifo_write_ ("\n", 1);
}
if (!get_w_binary ())
x = 0;
*************** fhandler_console::write_normal (const un
*** 1070,1082 ****
cursor_set (FALSE, 0, y);
break;
case ERR:
! WriteFile (get_output_handle (), src, 1, &done, 0);
break;
case TAB:
cursor_get (&x, &y);
cursor_set (FALSE, 8 * (x / 8 + 1), y);
break;
}
src ++;
}
return src;
--- 1144,1157 ----
cursor_set (FALSE, 0, y);
break;
case ERR:
! fifo_write_ (src, 1);
break;
case TAB:
cursor_get (&x, &y);
cursor_set (FALSE, 8 * (x / 8 + 1), y);
break;
}
+ skip_a_char:;
src ++;
}
return src;
*************** fhandler_console::write (const void *vsr
*** 1223,1228 ****
--- 1298,1304 ----
}
}
syscall_printf ("%d = write_console (,..%d)", len, len);
+ fifo_flush_ ();
return len;
}
---------------------------------------------------------
OR,,,
#ifndef DISABLE_ANSI_SNAP
char *cygenv = getenv("CYGWIN");
console_mode_ = ansicmd_win32;
if( NULL != cygenv && 0 == strstr( cygenv, "win9xansi" ) ){
console_mode_ = ansicmd_ansi;
}
enable_buffer_ = 1;
fifo_x_ = 0;
#endif
OR,,,
class fifo_buffer { .... }
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
- Raw text -