win32.c: clear relative to screen
* win32/win32.c (constat_apply): clear visible screen only, not the entire buffer. [ruby-core:81883] [Bug #13707] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2c4d43082c
commit
66245e1b2b
@ -6680,6 +6680,16 @@ constat_attr(int count, const int *seq, WORD attr, WORD default_attr, int *rever
|
|||||||
return attr;
|
return attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* License: Ruby's */
|
||||||
|
static void
|
||||||
|
constat_clear(HANDLE handle, WORD attr, DWORD len, COORD pos)
|
||||||
|
{
|
||||||
|
DWORD written;
|
||||||
|
|
||||||
|
FillConsoleOutputAttribute(handle, attr, len, pos, &written);
|
||||||
|
FillConsoleOutputCharacterW(handle, L' ', len, pos, &written);
|
||||||
|
}
|
||||||
|
|
||||||
/* License: Ruby's */
|
/* License: Ruby's */
|
||||||
static void
|
static void
|
||||||
constat_apply(HANDLE handle, struct constat *s, WCHAR w)
|
constat_apply(HANDLE handle, struct constat *s, WCHAR w)
|
||||||
@ -6689,7 +6699,6 @@ constat_apply(HANDLE handle, struct constat *s, WCHAR w)
|
|||||||
int count = s->vt100.state;
|
int count = s->vt100.state;
|
||||||
int arg1 = 1;
|
int arg1 = 1;
|
||||||
COORD pos;
|
COORD pos;
|
||||||
DWORD written;
|
|
||||||
|
|
||||||
if (!GetConsoleScreenBufferInfo(handle, &csbi)) return;
|
if (!GetConsoleScreenBufferInfo(handle, &csbi)) return;
|
||||||
if (count > 0 && seq[0] > 0) arg1 = seq[0];
|
if (count > 0 && seq[0] > 0) arg1 = seq[0];
|
||||||
@ -6747,38 +6756,53 @@ constat_apply(HANDLE handle, struct constat *s, WCHAR w)
|
|||||||
case L'J':
|
case L'J':
|
||||||
switch (arg1) {
|
switch (arg1) {
|
||||||
case 0: /* erase after cursor */
|
case 0: /* erase after cursor */
|
||||||
FillConsoleOutputCharacterW(handle, L' ',
|
constat_clear(handle, csbi.wAttributes,
|
||||||
csbi.dwSize.X * (csbi.dwSize.Y - csbi.dwCursorPosition.Y) - csbi.dwCursorPosition.X,
|
(csbi.dwSize.X * (csbi.srWindow.Bottom - csbi.dwCursorPosition.Y + 1)
|
||||||
csbi.dwCursorPosition, &written);
|
- csbi.dwCursorPosition.X),
|
||||||
|
csbi.dwCursorPosition);
|
||||||
break;
|
break;
|
||||||
case 1: /* erase before cursor */
|
case 1: /* erase before cursor */
|
||||||
pos.X = 0;
|
pos.X = 0;
|
||||||
pos.Y = csbi.dwCursorPosition.Y;
|
pos.Y = csbi.srWindow.Top;
|
||||||
FillConsoleOutputCharacterW(handle, L' ',
|
constat_clear(handle, csbi.wAttributes,
|
||||||
csbi.dwSize.X * csbi.dwCursorPosition.Y + csbi.dwCursorPosition.X,
|
(csbi.dwSize.X * (csbi.dwCursorPosition.Y - csbi.srWindow.Top)
|
||||||
pos, &written);
|
+ csbi.dwCursorPosition.X),
|
||||||
|
pos);
|
||||||
break;
|
break;
|
||||||
case 2: /* erase entire screen */
|
case 2: /* erase entire screen */
|
||||||
|
pos.X = 0;
|
||||||
|
pos.Y = csbi.srWindow.Top;
|
||||||
|
constat_clear(handle, csbi.wAttributes,
|
||||||
|
(csbi.dwSize.X * (csbi.srWindow.Bottom - csbi.srWindow.Top + 1)),
|
||||||
|
pos);
|
||||||
|
break;
|
||||||
|
case 3: /* erase entire screen */
|
||||||
pos.X = 0;
|
pos.X = 0;
|
||||||
pos.Y = 0;
|
pos.Y = 0;
|
||||||
FillConsoleOutputCharacterW(handle, L' ', csbi.dwSize.X * csbi.dwSize.Y, pos, &written);
|
constat_clear(handle, csbi.wAttributes,
|
||||||
|
(csbi.dwSize.X * csbi.dwSize.Y),
|
||||||
|
pos);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case L'K':
|
case L'K':
|
||||||
switch (arg1) {
|
switch (arg1) {
|
||||||
case 0: /* erase after cursor */
|
case 0: /* erase after cursor */
|
||||||
FillConsoleOutputCharacterW(handle, L' ', csbi.dwSize.X - csbi.dwCursorPosition.X, csbi.dwCursorPosition, &written);
|
constat_clear(handle, csbi.wAttributes,
|
||||||
|
(csbi.dwSize.X - csbi.dwCursorPosition.X),
|
||||||
|
csbi.dwCursorPosition);
|
||||||
break;
|
break;
|
||||||
case 1: /* erase before cursor */
|
case 1: /* erase before cursor */
|
||||||
pos.X = 0;
|
pos.X = 0;
|
||||||
pos.Y = csbi.dwCursorPosition.Y;
|
pos.Y = csbi.dwCursorPosition.Y;
|
||||||
FillConsoleOutputCharacterW(handle, L' ', csbi.dwCursorPosition.X, pos, &written);
|
constat_clear(handle, csbi.wAttributes,
|
||||||
|
csbi.dwCursorPosition.X, pos);
|
||||||
break;
|
break;
|
||||||
case 2: /* erase entire line */
|
case 2: /* erase entire line */
|
||||||
pos.X = 0;
|
pos.X = 0;
|
||||||
pos.Y = csbi.dwCursorPosition.Y;
|
pos.Y = csbi.dwCursorPosition.Y;
|
||||||
FillConsoleOutputCharacterW(handle, L' ', csbi.dwSize.X, pos, &written);
|
constat_clear(handle, csbi.wAttributes,
|
||||||
|
csbi.dwSize.X, pos);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user