[前][次][番号順一覧][スレッド一覧]

ruby-changes:50980

From: nobu <ko1@a...>
Date: Wed, 18 Apr 2018 12:51:24 +0900 (JST)
Subject: [ruby-changes:50980] nobu:r63187 (trunk): win32.c: fix CSI sequences to delete

nobu	2018-04-18 12:51:19 +0900 (Wed, 18 Apr 2018)

  New Revision: 63187

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63187

  Log:
    win32.c: fix CSI sequences to delete
    
    * win32/win32.c (constat_apply): CSI 'J' and 'K' are defaulted to
      1, not 0.  [ruby-core:86560] [Bug #14691]
    
    * win32/win32.c (constat_apply): "delete before cursor" sequences
      include the cursor position.

  Modified files:
    trunk/win32/win32.c
Index: win32/win32.c
===================================================================
--- win32/win32.c	(revision 63186)
+++ win32/win32.c	(revision 63187)
@@ -6679,11 +6679,11 @@ constat_apply(HANDLE handle, struct cons https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L6679
     CONSOLE_SCREEN_BUFFER_INFO csbi;
     const int *seq = s->vt100.seq;
     int count = s->vt100.state;
-    int arg1 = 1;
+    int arg0, arg1 = 1;
     COORD pos;
 
     if (!GetConsoleScreenBufferInfo(handle, &csbi)) return;
-    if (count > 0 && seq[0] > 0) arg1 = seq[0];
+    if (arg0 = (count > 0 && seq[0] > 0)) arg1 = seq[0];
     switch (w) {
       case L'm':
 	SetConsoleTextAttribute(handle, constat_attr(count, seq, csbi.wAttributes, s->vt100.attr, &s->vt100.reverse));
@@ -6742,19 +6742,19 @@ constat_apply(HANDLE handle, struct cons https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L6742
 	SetConsoleCursorPosition(handle, pos);
 	break;
       case L'J':
-	switch (arg1) {
+	switch (arg0 ? arg1 : 0) {
 	  case 0:	/* erase after cursor */
 	    constat_clear(handle, csbi.wAttributes,
 			  (csbi.dwSize.X * (csbi.srWindow.Bottom - csbi.dwCursorPosition.Y + 1)
 			   - csbi.dwCursorPosition.X),
 			  csbi.dwCursorPosition);
 	    break;
-	  case 1:	/* erase before cursor */
+	  case 1:	/* erase before *and* cursor */
 	    pos.X = 0;
 	    pos.Y = csbi.srWindow.Top;
 	    constat_clear(handle, csbi.wAttributes,
 			  (csbi.dwSize.X * (csbi.dwCursorPosition.Y - csbi.srWindow.Top)
-			   + csbi.dwCursorPosition.X),
+			   + csbi.dwCursorPosition.X + 1),
 			  pos);
 	    break;
 	  case 2:	/* erase entire screen */
@@ -6774,17 +6774,17 @@ constat_apply(HANDLE handle, struct cons https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L6774
 	}
 	break;
       case L'K':
-	switch (arg1) {
+	switch (arg0 ? arg1 : 0) {
 	  case 0:	/* erase after cursor */
 	    constat_clear(handle, csbi.wAttributes,
 			  (csbi.dwSize.X - csbi.dwCursorPosition.X),
 			  csbi.dwCursorPosition);
 	    break;
-	  case 1:	/* erase before cursor */
+	  case 1:	/* erase before *and* cursor */
 	    pos.X = 0;
 	    pos.Y = csbi.dwCursorPosition.Y;
 	    constat_clear(handle, csbi.wAttributes,
-			  csbi.dwCursorPosition.X, pos);
+			  csbi.dwCursorPosition.X + 1, pos);
 	    break;
 	  case 2:	/* erase entire line */
 	    pos.X = 0;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]