From: *jeffdb AT netzone DOT nospam DOT com ("Mikey") Subject: Re: ncurses/termcap, just won't clear the screen? 23 May 1997 15:20:24 -0700 Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <199705220304.UAA06282.cygnus.gnu-win32@nz1.netzone.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_01BC652F.0791DF80" X-Mailer: Microsoft Outlook Express 4.71.0544.0 Original-To: "Sergey Okhapkin" Original-Cc: "cygnus gnu-win32 mailing list" X-Priority: 3 X-MSMail-Priority: Normal X-MimeOLE: Produced By Microsoft MimeOLE Engine V4.71.0544.0 Original-Sender: owner-gnu-win32 AT cygnus DOT com This is a multi-part message in MIME format. ------=_NextPart_000_01BC652F.0791DF80 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit The diff that I sent out before causes random crashes during compiles under win95, apparently micros*** lied about the output chars stacking up see remarks below. The corrected diff is attached.The WriteConsoleOutputCharacter function copies a number of characters to consecutive cells of a console screen buffer, beginning at a specified location. BOOL WriteConsoleOutputCharacter( HANDLE hConsoleOutput, // handle to a console screen buffer LPCTSTR lpCharacter, // pointer to buffer to write characters from DWORD nLength, // number of character cells to write to COORD dwWriteCoord, // coordinates of first cell to write to LPDWORD lpNumberOfCharsWritten // pointer to number of cells written to ); Parameters (b) hConsoleOutput Identifies the screen buffer. The handle must have GENERIC_WRITE access. (c) lpCharacter Points to a buffer that contains the characters to write to the screen buffer. (d) nLength Specifies the number of screen buffer character cells to write to. (e) dwWriteCoord Specifies the column and row coordinates of the first cell in the screen buffer to write to. (f) lpNumberOfCharsWritten Points to a 32-bit variable that receives the number of characters actually written. Return Values If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError. Remarks If the number of characters to be written to extends beyond the end of the specified row in the screen buffer, characters are written to the next row. If the number of characters to be written to extends beyond the end of the screen buffer, characters are written up to the end of the screen buffer. The attribute values at the positions written to are not changed. Windows NT: This function uses either Unicode characters or 8-bit characters from the console's current codepage. The console's codepage defaults initially to the system's OEM codepage. To change the console's codepage, use the SetConsoleCP or SetConsoleOutputCP functions, or use the chcp or mode con cp select= commands. (*jeffdb AT netzone DOT com) the return address for this message is anti spammed remove * from the above address to reply. Mikey ------=_NextPart_000_01BC652F.0791DF80 Content-Type: application/octet-stream; name="current.dif" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="current.dif" --- Makefile.in 1997/05/12 23:37:39 18.0 +++ Makefile.in 1997/05/12 20:06:55 @@ -38,6 +38,7 @@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DIRS = @INSTALL@ -d CC = @CC@ # FIXME: Which is it, CC or CC_FOR_TARGET? @@ -74,7 +75,8 @@ AR="$(AR)" \ RANLIB="$(RANLIB)" \ LD="$(LD)" \ - DLLTOOL="$(DLLTOOL)" + DLLTOOL="$(DLLTOOL)" \ + prefix="$(prefix)" # This is the final name of the cygwin.dll. @@ -152,10 +154,12 @@ readme.info:$(srcdir)/doc/readme.texinfo $(MAKEINFO) -I$(srcdir)/doc $< -install: $(THEIRLIBS) $(LIBNAME) new-$(DLLNAME) real-headers +install-theirlibs: $(THEIRLIBS) $(LIBNAME) for i in $(THEIRLIBS) $(LIBNAME); do \ $(INSTALL_DATA) $$i $(tooldir)/lib/$$i ; \ done + +install-dll: new-$(DLLNAME) for i in $(DLLNAME); do \ $(INSTALL_DATA) new-$$i $(tooldir)/lib/$$i ; \ binname=`t='$(program_transform_name)'; echo "$$i" | sed -e $$t` ; \ @@ -163,16 +167,23 @@ rm -f $(bindir)/$$binname ; \ ln $(tooldir)/lib/$$i $(bindir)/$$binname >/dev/null 2>&1 || $(INSTALL_DATA) new-$$i $(bindir)/$$binname ; \ done + for i in $(DLLNAME);do stripdll $(bindir)/$$i;done + +install-real-headers: real-headers for sub in include include/arpa include/asm include/Windows32 \ include/cygwin32 include/net include/netinet include/sys ; do \ + $(INSTALL_DIRS) $(tooldir)/$$sub; \ for i in $(srcdir)/$$sub/*.h ; do \ $(INSTALL_DATA) $$i $(tooldir)/$$sub/`basename $$i` ; \ done ; \ done + +install-utils: rootme=`pwd` ; export rootme ; \ rootsrc=`(cd $(srcdir) ; pwd)` ; export rootsrc ; \ cd utils; $(MAKE) install $(FLAGS_TO_PASS) +install: install-theirlibs install-dll install-real-headers install-utils # this will only work if you've maked stmp_ms_include below. # if [ -e ms_include/windows.h ] ; then \ # for i in ms_include/*.h ; do \ @@ -293,6 +304,13 @@ clean: -rm -f *.o *.dll *.a *.exp junk *.base + $(MAKE) -C glob $@ + $(MAKE) -C utils $@ + +distclean: clean + -rm -f Makefile config.status config.cache config.log cygwin.def + $(MAKE) -C glob $@ + $(MAKE) -C utils $@ maintainer-clean realclean: clean @echo "This command is intended for maintainers to use;" @@ -321,7 +339,7 @@ # which contains the headers (My linux machine is dual boot, and C: is under # /dosc, so this works for me) -SDK_H=/dosc/mstools/h +SDK_H=/dos/m/msdn/include real-headers: # $(srcdir)/mspatches/*.patch if [ -f $(SDK_H)/windows.h ] ; then \ --- console.cc 1997/05/12 23:37:39 18.0 +++ console.cc 1997/05/20 21:18:01 @@ -452,19 +452,20 @@ } void -fhandler_console::clear_screen () +fhandler_console::clear_screen (int x, int y) { CONSOLE_SCREEN_BUFFER_INFO info; - COORD tlc = {0,0}; + COORD tlc = {x,y}; DWORD done; GetConsoleScreenBufferInfo (get_output_handle (), &info); + int out=((info.dwSize.Y * info.dwSize.X) - (y * info.dwSize.X + x)); FillConsoleOutputCharacterA (get_output_handle (), ' ', - info.dwSize.X * info.dwSize.Y, + out, tlc, &done); FillConsoleOutputAttribute (get_output_handle(), FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_RED, - info.dwSize.X * info.dwSize.Y, + out, tlc, &done); } @@ -530,9 +531,15 @@ *x = info.dwCursorPosition.X; } +void +fhandler_console::switchCP(int CP) +{ /* FIXME code to actually switch goes here */ +} + #define BAK 1 #define ESC 2 #define NOR 0 +#define EOT 3 /* delete forward */ #define IGN 4 #define ERR 5 #define DWN 6 @@ -543,7 +550,7 @@ static const char base_chars[256] = { -/*00 01 02 03 04 05 06 07 */ IGN, ERR, ERR, NOR, NOR, NOR, NOR, BEL, +/*00 01 02 03 04 05 06 07 */ IGN, ERR, ERR, NOR, EOT, NOR, NOR, BEL, /*08 09 0A 0B 0C 0D 0E 0F */ BAK, TAB, DWN, ERR, ERR, CR, ERR, IGN, /*10 11 12 13 14 15 16 17 */ NOR, NOR, ERR, ERR, ERR, ERR, ERR, ERR, /*18 19 1A 1B 1C 1D 1E 1F */ NOR, NOR, ERR, ESC, ERR, ERR, ERR, ERR, @@ -585,6 +592,7 @@ { static int fg=7,bg=0,bold=0; int x, y; + DWORD done; char buf[40]; switch (c) @@ -620,6 +628,9 @@ bg=BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED; bold=0; break; + case 8: /* invis */ + bg=0; + bold=0; case 30: /* BLACK foreground */ fg = 0; break; @@ -685,12 +696,19 @@ { case 0: /* Clear to end of screen */ cursor_get(&x, &y); - scroll_screen(get_output_handle(), 0, y, -1, -1, -1, -1); - scroll_screen(get_output_handle(), -1, -1, -1, -1, 0, y); - clear_to_eol(); + clear_screen(x,y); + break; + case 1: /* erase from start to cursor */ + cursor_get(&savex, &savey); + scroll_screen (get_output_handle (), x, y, -1, y, 0, y); + scroll_screen (get_output_handle (), 0, y, -1, y, x, y); + for (y = 0;y < savey;y++) { + cursor_set(0, y); + clear_to_eol (); } + cursor_set(savex, savey); break; case 2: /* Clear screen */ - clear_screen (); + clear_screen (0,0); cursor_set (0,0); break; default: @@ -815,8 +833,7 @@ break; default: bad_escape: - small_printf("Bad escape %d, %d %d (%c)\n", args_[0], args_[1], c,c); - sleep (1); + small_printf("Bad escape %d, %d %d (%c). Please check TERM environment variable.\n", args_[0], args_[1], c,c); break; } } @@ -854,12 +871,19 @@ break; case ESC: state_ = gotesc; + debug_printf("\nESCAPE is %s\n", src); break; case DWN: /* WriteFile("\n") always adds CR... */ cursor_get(&x, &y); - WriteFile (get_output_handle (), "\n", 1, &done, 0); - if (get_w_binary ()) - cursor_rel (x, 0); + if (get_w_binary ()) /* this must come first. */ + cursor_rel (0, 1); + else + WriteFile (get_output_handle (), "\r\n", 2, &done, 0); + break; + case EOT: /* delete forward */ + cursor_get(&x, &y); + scroll_screen(get_output_handle(), x+1, y, -1, y, x, y); + scroll_screen(get_output_handle(), x, y, -1, y, x+1, y); break; case BAK: cursor_rel (-1, 0); @@ -875,7 +899,8 @@ cursor_set(8*(x/8+1), y); break; case ERR: - small_printf ("Got %d\n", *src); + if (!is_tty()) + WriteFile (get_output_handle (), src, 1, &done, 0); break; } src ++; @@ -917,7 +942,7 @@ } else if (*src == 'c') /* Reset Linux terminal */ { - clear_screen(); + clear_screen(0,0); cursor_set(0, 0); state_ = normal; } @@ -937,9 +962,34 @@ state_ = normal; else { - small_printf ("Bad escape %d (%c)\n", *src,*src); - sleep (1); state_ = normal; + int CP = 4; + switch (*src) + { + case '(': CP = 0; /* ASCII */ + break; + case ')': CP = 1; + break; + case '*': CP = 2; + break; + case '+': CP = 3; + break; + default: + break; + } + if (CP != 4) + { + src++; + if (*src != 'B') + { + src--; + small_printf ("Bad escape %d (%c) Please check TERM environment variable\n", *src, *src); + } + else + { + switchCP(CP); + } + } } src++; break; @@ -1024,18 +1074,19 @@ /* if things are special, just do what we used to */ if ((!res) || (ov != 0)) - { return ReadFile (hndl, pv, lenin, done, ov); - } if (flags & ENABLE_LINE_INPUT) { - FlushConsoleInputBuffer (hndl); + FlushConsoleInputBuffer(hndl); return ReadFile (hndl, pv, lenin, done, ov); } /* otherwise, do something that works */ unsigned int num_events = 0, ne2, st; + if(ndelay_set == 1) + need_chars=0; + st = GetNumberOfConsoleInputEvents (hndl, &num_events); debug_printf ("FakeReadFile, GetNumberOfConsoleInputEvents returned = %d\n", st); @@ -1054,6 +1105,15 @@ need_chars = 1; } + if(ndelay_set == 1) + { + need_chars = 0; + } + else + { + need_chars = 1; + } + INPUT_RECORD input_rec; buf = (char*)pv; @@ -1172,7 +1232,19 @@ need_chars = 0; } *done = copied_chars; - return 1; /* success == true */ + + /* if we haven't got anything of interest, and we don't want to wait for + anything (O_NDELAY is set) force the calling read to error (ret 0) */ + + if (copied_chars == 0 && need_chars == 0) + { + return 0; + } + else + { + return 1; + } /* success == true */ + } int --- cygwin.din 1997/05/20 06:07:04 1.1 +++ cygwin.din 1997/05/20 06:13:13 @@ -885,8 +885,8 @@ _getpwent = getpwent endpwent _endpwent = endpwent -setpwend -_setpwend = setpwend +setpwent +_setpwent = setpwent getpwduid _getpwduid = getpwduid getpwnam @@ -945,8 +945,6 @@ _closelog = closelog openlog _openlog = openlog -tgetent -_tgetent = tgetent vhangup _vhangup = vhangup nice --- fcntl.cc 1997/05/12 23:37:39 18.0 +++ fcntl.cc 1997/05/12 06:49:25 @@ -20,6 +20,8 @@ #include #include "winsup.h" +int ndelay_set; + extern "C" int _fcntl (int fd, int cmd,...) @@ -88,6 +90,10 @@ res |= O_WRONLY; if (this_procinfo ()->hmap[fd].h->get_access () & GENERIC_ALL) res |= O_RDWR; + if (ndelay_set) + res |= O_NDELAY; + syscall_printf ("fcntl (F_GETFL, %d);\n", res); + goto done; case F_SETFL: @@ -101,6 +107,14 @@ temp |= GENERIC_READ; if (arg & O_WRONLY) temp |= GENERIC_WRITE; + if (arg & O_NDELAY) + { + ndelay_set = 1; + } + else + { + ndelay_set = 0; + } syscall_printf ("fcntl (%d, F_SETFL, %d);\n", arg); --- fhandler.h 1997/05/12 23:37:39 18.0 +++ fhandler.h 1997/05/12 11:14:55 @@ -21,6 +21,8 @@ #include +extern int ndelay_set; /* for fcntl O_NDELAY in FakeReadFile */ + /* Classes fhandler_base normal I/O @@ -237,7 +239,7 @@ /* Output calls */ - void clear_screen (); + void clear_screen (int x, int y); void cursor_set (int x, int y); void cursor_get (int *x, int *y); void clear_to_eol (); @@ -246,6 +248,7 @@ const unsigned char * write_normal (unsigned const char*, unsigned const char *); void char_command (char); int output_tcsetattr (int a, const struct termios *t); + void switchCP (int CP); /* Input state */ /* Bits are.. --- misc.cc 1997/05/20 06:21:41 1.1 +++ misc.cc 1997/05/20 06:22:03 @@ -103,13 +103,6 @@ extern "C" int -tgetent () -{ - return -1; -} - -extern "C" -int vhangup () { set_errno (ENOSYS); --- passwd.cc 1997/05/20 06:08:26 1.1 +++ passwd.cc 1997/05/20 06:08:53 @@ -204,7 +204,7 @@ extern "C" void -setpwend (void) +setpwent (void) { i = curr_lines - 1; } --- signal.cc 1997/05/13 21:11:43 1.1 +++ signal.cc 1997/05/13 21:13:59 @@ -54,8 +54,8 @@ sleep (unsigned int seconds) { syscall_printf ("sleep (%d);\n", seconds); - Sleep (seconds * 1000); - syscall_printf ("0 = sleep (%d);\n", seconds); + WaitForSingleObject (u->signal_arrived, seconds * 1000); + syscall_printf ("0 = sleep (%d)\n", seconds); return 0; } @@ -64,7 +64,7 @@ usleep (unsigned int useconds) { syscall_printf ("usleep (%d)\n", useconds); - Sleep ((useconds + 500) / 1000); + WaitForSingleObject (u->signal_arrived, (useconds + 500) / 1000); syscall_printf ("0 = usleep (%d)\n", useconds); return 0; } --- termcap 1997/05/12 20:02:05 1.1 +++ utils/termcap 1997/05/13 11:23:03 @@ -69,13 +69,13 @@ :..sa=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1%;%?%p7%t;8%;%?%p8%t;11%;%?%p9%t;12%;m:\ :se=\E[m:sf=^J:so=\E[7m:st=\EH:ta=^I:ue=\E[m:up=\E[A:\ :us=\E[4m: -pcansi-mono25|ansi25|ibm-pc terminal programs with 25 lines (mono mode):\ +pcansi-mono25|ansi25-m|ibm-pc terminal programs with 25 lines (mono mode):\ :li#25:\ :tc=pcansi-mono: -pcansi-mono33|ansi33|ibm-pc terminal programs with 33 lines (mono mode):\ +pcansi-mono33|ansi33-m|ibm-pc terminal programs with 33 lines (mono mode):\ :li#33:\ :tc=pcansi-mono: -pcansi-mono43|ansi43|ibm-pc terminal programs with 43 lines (mono mode):\ +pcansi-mono43|ansi43-m|ibm-pc terminal programs with 43 lines (mono mode):\ :li#43:\ :tc=pcansi-mono: # The color versions. All PC emulators do color... @@ -116,6 +116,12 @@ ansi|ansi/pc-term compatible with color:\ :u6=\E[%d;%dR:u7=\E[6n:..u8=\E[?%[;0123456789]c:\ :u9=\E[c:tc=ansi-pc-color:tc=ansi-mono: + +w32ansi|ansi console window w/function keys under cygwin32:\ + :li=#50:k1=\E[[A:k2=\E[[B:k3=\E[[C:k4=\E[[D:\ + :k5=\E[[E:k6=\E[17~:k7=\E[18~:k8=\E[19~:k9=\E[20~:k;=\E[21~:kI=\E[2~:\ + :kh=\E[1~:kD=\E[3~:@7=\E[4~:kP=\E[5~:kN=\E[6~:\ + :K1=\E[1~:K3=\E[5~:K4=\E[4~:K5=\E[6~:st@:ct@:tc=ansi: # # ANSI.SYS entries ------=_NextPart_000_01BC652F.0791DF80-- - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".