This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [PATCH] fhandler_console.cc


Thanks for the patch.  I'll look into including it after the next
net release.  Please remind me if you don't see it show up in
a snapshot in the next month or so.

Do you have an accompanying termcap entry, by any chance?

cgf

On Tue, May 30, 2000 at 04:27:49PM -0400, Bradley A. Town wrote:
>Below is an improved terminfo entry for cygwin and the patch to
>fhandler_console.cc it uses.  They are especially useful if you have
>programs that depend on ncurses.
>
>The patch accomplishes the following:
>. It fixes standout, reverse, bold, underline, and invisible display modes
>for screen colors other than the default.
>. It treats underline as intense background.
>. It adds codes for turning off bold, underline, reverse, and invisible
>individually according to ECMA-48.
>. It adds codes for selecting the default foreground and default background
>according to ECMA-48.
>. It no longer modifies the current mode if an unknown SGR code is given.
>. It probably breaks someone's program somewhere.  However, the patch and
>the terminfo entry have been tested with ncurses's test programs, tack,
>lynx, and frotz (the program that prompted this).
>
>The terminfo entry accomplishes the following:
>. It consolidates the individual settings into one entry.  (You might not
>like that.)
>. It uses the capabilities added with the patch.
>. It adds some keycodes.
>. It, too, probably breaks something.
>
>My mailer will wrap the terminfo lines, so you'll have to fix that before
>trying it.
>
>Brad Town
>townba at pobox dot com
>
>------ cut here ------
># Blink and dim are not implemented
># ENQ (u9) / ACK (u8) may not work as expected
>
>cygwin|ansi emulation for cygwin32,
>
>acsc=+\020\,\021-\030.^Y0\333`\004a\261f\370g\361h\260j\331k\277l\332m\300n\
>305o~p\304q\304r\304s_t\303u\264v\301w\302x\263y\363z\362{\343|\330}\234~\37
>6,
>        smso=\E[7m, rmso=\E[27m, smul=\E[4m, rmul=\E[24m,
>        rev=\E[7m, bold=\E[1m, invis=\E[8m, sgr0=\E[m,
>        sgr=\E[0%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p6%t;1%;%?%p7%t;8%;m,
>        colors#8, ncv#0, pairs#64, it#8,
>        op=\E[39;49m,
>        setaf=\E[3%p1%dm, setab=\E[4%p1%dm,
>        am, mir, msgr, xon,
>        clear=\E[2J,
>        cuu1=\E[A, cud1=\E[B, cuf1=\E[C, cub1=^H,
>        cup=\E[%i%p1%d;%p2%dH, home=\E[H,
>        is2=\E[m\E[?7h,
>        pfkey=\E[0;%p1%{58}%+%d;%p2"%s",
>        sc=\E[s, rc=\E[u,
>        u6=\E[%i%d;%dR, u7=\E[6n,
>        u8=\E[?6c, u9=\E[c,
>        el=\E[K, el1=\E[1K, ed=\E[J,
>        cr=^M, ind=^J, ht=^I, bel=^G,
>        kcuu1=\E[A, kcud1=\E[B, kcuf1=\E[C, kcub1=\E[D,
>        ka1=\E[1~, ka3=\E[5~, kb2=\E[G, kc1=\E[4~, kc3=\E[6~,
>        kdch1=\E[3~, kich1=\E[2~, khome=\E[1~, kend=\E[4~, kpp=\E[5~,
>knp=\E[6~,
>        kf1=\E[[A, kf2=\E[[B, kf3=\E[[C, kf4=\E[[D, kf5=\E[[E,
>        kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, kf10=\E[21~,
>        kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~,
>        kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf20=\E[34~,
>------ cut here ------
>
>--- fhandler_console.cc.orig	Sun May 14 12:20:24 2000
>+++ fhandler_console.cc	Tue May 30 15:42:42 2000
>@@ -724,13 +724,16 @@
> void
> fhandler_console::char_command (char c)
> {
>-  // Keep the background intensity with the colr since there doesn't seem
>-  // to be a way to set this with termcap/terminfo.
>   static int fg = default_color & (FOREGROUND_BLUE | FOREGROUND_GREEN |
> 				   FOREGROUND_RED),
> 	     bg = default_color & (BACKGROUND_BLUE | BACKGROUND_GREEN |
>-				   BACKGROUND_RED | BACKGROUND_INTENSITY),
>-			 bold = default_color & FOREGROUND_INTENSITY;
>+				   BACKGROUND_RED);
>+
>+  static bool bold = (default_color & FOREGROUND_INTENSITY) ? true : false;
>+  static bool underline = (default_color & BACKGROUND_INTENSITY) ? true :
>false;
>+  static bool reverse = false;
>+  static bool invis = false;
>+
>   int x, y;
>   char buf[40];
>
>@@ -746,56 +749,35 @@
> 	       fg = default_color & (FOREGROUND_BLUE | FOREGROUND_GREEN |
> 				     FOREGROUND_RED);
> 	       bg = default_color & (BACKGROUND_BLUE | BACKGROUND_GREEN |
>-				     BACKGROUND_RED | BACKGROUND_INTENSITY);
>-	       bold = default_color & FOREGROUND_INTENSITY;
>+				     BACKGROUND_RED);
>+	       underline = (default_color & BACKGROUND_INTENSITY) ? true : false;
>+	       reverse = false;
>+	       bold = (default_color & FOREGROUND_INTENSITY) ? true : false;
>+	       invis = false;
> 	       break;
> 	     case 1:    /* bold */
>-	       fg = default_color & (FOREGROUND_BLUE | FOREGROUND_GREEN |
>-				     FOREGROUND_RED);
>-	       bg = default_color & (BACKGROUND_BLUE | BACKGROUND_GREEN |
>-				     BACKGROUND_RED | BACKGROUND_INTENSITY);
>-	       bold = FOREGROUND_INTENSITY;
>+	       bold = true;
> 	       break;
>-	     case 4:    /* underline - simulate with cyan */
>-	       fg = FOREGROUND_BLUE | FOREGROUND_GREEN;
>-	       bg = default_color & (BACKGROUND_BLUE | BACKGROUND_GREEN |
>-				     BACKGROUND_RED | BACKGROUND_INTENSITY);
>-	       bold = default_color & FOREGROUND_INTENSITY;
>-	       break;
>-	     case 5:    /* blink mode */
>-	       fg = default_color & (FOREGROUND_BLUE | FOREGROUND_GREEN |
>-				     FOREGROUND_RED);
>-	       bg = default_color & (BACKGROUND_BLUE | BACKGROUND_GREEN |
>-				     BACKGROUND_RED | BACKGROUND_INTENSITY);
>-	       bold = default_color & FOREGROUND_INTENSITY;
>+	     case 4:    /* underline */
>+	       underline = true;
> 	       break;
> 	     case 7:    /* reverse */
>-	       fg = (default_color & BACKGROUND_BLUE) ? FOREGROUND_BLUE : 0;
>-	       fg |= (default_color & BACKGROUND_GREEN) ? FOREGROUND_GREEN : 0;
>-	       fg |= (default_color & BACKGROUND_RED) ? FOREGROUND_RED : 0;
>-	       fg |= (default_color & BACKGROUND_INTENSITY) ?
>-					     FOREGROUND_INTENSITY : 0;
>-	       bg = (default_color & FOREGROUND_BLUE) ? BACKGROUND_BLUE : 0;
>-	       bg |= (default_color & FOREGROUND_GREEN) ? BACKGROUND_GREEN : 0;
>-	       bg |= (default_color & FOREGROUND_RED) ? BACKGROUND_RED : 0;
>-	       bg |= (default_color & FOREGROUND_INTENSITY) ?
>-					     BACKGROUND_INTENSITY : 0;
>+	       reverse = true;
> 	       break;
> 	     case 8:    /* invisible */
>-	       fg = (default_color & BACKGROUND_BLUE) ? FOREGROUND_BLUE : 0;
>-	       fg |= (default_color & BACKGROUND_GREEN) ? FOREGROUND_GREEN : 0;
>-	       fg |= (default_color & BACKGROUND_RED) ? FOREGROUND_RED : 0;
>-	       bg = default_color & (BACKGROUND_BLUE | BACKGROUND_GREEN |
>-				     BACKGROUND_RED | BACKGROUND_INTENSITY);
>-	       bold = (default_color & BACKGROUND_INTENSITY) ?
>-						   FOREGROUND_INTENSITY : 0;
>+	       invis = true;
> 	       break;
>-	     case 9:    /* dim */
>-	       fg = default_color & (FOREGROUND_BLUE | FOREGROUND_GREEN |
>-				     FOREGROUND_RED);
>-	       bg = default_color & (BACKGROUND_BLUE | BACKGROUND_GREEN |
>-				     BACKGROUND_RED | BACKGROUND_INTENSITY);
>-	       bold = (fg == 0) ? FOREGROUND_INTENSITY : 0;
>+	     case 22:   /* non-bold */
>+	       bold = false;
>+	       break;
>+	     case 24:   /* non-underline */
>+	       underline = false;
>+	       break;
>+	     case 27:   /* non-reverse */
>+	       reverse = false;
>+	       break;
>+	     case 28:   /* non-invisible */
>+	       invis = false;
> 	       break;
> 	     case 30:		/* BLACK foreground */
> 	       fg = 0;
>@@ -821,6 +803,10 @@
> 	     case 37:		/* WHITE foreg */
> 	       fg = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED;
> 	       break;
>+	     case 39:		/* Default foreg */
>+	       fg = default_color & (FOREGROUND_BLUE | FOREGROUND_GREEN |
>+				     FOREGROUND_RED);
>+	       break;
> 	     case 40:		/* BLACK background */
> 	       bg = 0;
> 	       break;
>@@ -845,15 +831,39 @@
> 	     case 47:    /* WHITE background */
> 	       bg = BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED;
> 	       break;
>-	     default:
>-	       fg = default_color & (FOREGROUND_BLUE | FOREGROUND_GREEN |
>-				     FOREGROUND_RED);
>+	     case 49:    /* Default background */
> 	       bg = default_color & (BACKGROUND_BLUE | BACKGROUND_GREEN |
> 				     BACKGROUND_RED | BACKGROUND_INTENSITY);
>-	       bold = default_color & FOREGROUND_INTENSITY;
>+	       break;
>+	     default:
> 	       break;
> 	   }
>-	 SetConsoleTextAttribute (get_output_handle (), fg | bg | bold);
>+
>+      {
>+	WORD fg2 = fg;
>+	WORD bg2 = bg;
>+
>+	if (reverse) {
>+	  fg2 = ((bg & BACKGROUND_RED) ? FOREGROUND_RED : 0) |
>+		((bg & BACKGROUND_GREEN) ? FOREGROUND_GREEN : 0) |
>+		((bg & BACKGROUND_BLUE) ? FOREGROUND_BLUE : 0);
>+	  bg2 = ((fg & FOREGROUND_RED) ? BACKGROUND_RED : 0) |
>+		((fg & FOREGROUND_GREEN) ? BACKGROUND_GREEN : 0) |
>+		((fg & FOREGROUND_BLUE) ? BACKGROUND_BLUE : 0);
>+	}
>+
>+	if (bold) fg2 |= FOREGROUND_INTENSITY;
>+	if (underline) bg2 |= BACKGROUND_INTENSITY;
>+	if (invis) {
>+	  fg2 = ((bg2 & BACKGROUND_RED) ? FOREGROUND_RED : 0) |
>+		((bg2 & BACKGROUND_GREEN) ? FOREGROUND_GREEN : 0) |
>+		((bg2 & BACKGROUND_BLUE) ? FOREGROUND_BLUE : 0) |
>+		((bg2 & BACKGROUND_INTENSITY) ? FOREGROUND_INTENSITY : 0);
>+	}
>+
>+	SetConsoleTextAttribute (get_output_handle (), fg2 | bg2);
>+      }
>+
>       break;
>     case 'h':
>     case 'l':
>
>
>--
>Want to unsubscribe from this list?
>Send a message to cygwin-unsubscribe@sourceware.cygnus.com

-- 
cgf@cygnus.com                        Cygnus Solutions, a Red Hat company
http://sourceware.cygnus.com/         http://www.redhat.com/

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]