summaryrefslogtreecommitdiff
path: root/win32/win32.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-07-03 23:42:12 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-07-03 23:42:12 (GMT)
commitda373e53941f5e2058a3d6f01b14df65713431c9 (patch)
treebe451c821ab51a7d922a9263ebebd691b8e14107 /win32/win32.c
parent66245e1b2b510c005788f56f49750808c7c80829 (diff)
win32.c: restrict cursor move
* win32/win32.c (constat_apply): restrict cursor move in visible screen only. [ruby-core:81883] [Bug #13707] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32/win32.c')
-rw-r--r--win32/win32.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 1544476..d40f0a5 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -6710,8 +6710,8 @@ constat_apply(HANDLE handle, struct constat *s, WCHAR w)
csbi.dwCursorPosition.X = 0;
case L'A':
csbi.dwCursorPosition.Y -= arg1;
- if (csbi.dwCursorPosition.Y < 0)
- csbi.dwCursorPosition.Y = 0;
+ if (csbi.dwCursorPosition.Y < csbi.srWindow.Top)
+ csbi.dwCursorPosition.Y = csbi.srWindow.Top;
SetConsoleCursorPosition(handle, csbi.dwCursorPosition);
break;
case L'E':
@@ -6719,29 +6719,35 @@ constat_apply(HANDLE handle, struct constat *s, WCHAR w)
case L'B':
case L'e':
csbi.dwCursorPosition.Y += arg1;
- if (csbi.dwCursorPosition.Y >= csbi.dwSize.Y)
- csbi.dwCursorPosition.Y = csbi.dwSize.Y;
+ if (csbi.dwCursorPosition.Y > csbi.srWindow.Bottom)
+ csbi.dwCursorPosition.Y = csbi.srWindow.Bottom;
SetConsoleCursorPosition(handle, csbi.dwCursorPosition);
break;
case L'C':
csbi.dwCursorPosition.X += arg1;
- if (csbi.dwCursorPosition.X >= csbi.dwSize.X)
- csbi.dwCursorPosition.X = csbi.dwSize.X;
+ if (csbi.dwCursorPosition.X >= csbi.srWindow.Right)
+ csbi.dwCursorPosition.X = csbi.srWindow.Right;
SetConsoleCursorPosition(handle, csbi.dwCursorPosition);
break;
case L'D':
csbi.dwCursorPosition.X -= arg1;
- if (csbi.dwCursorPosition.X < 0)
- csbi.dwCursorPosition.X = 0;
+ if (csbi.dwCursorPosition.X < csbi.srWindow.Left)
+ csbi.dwCursorPosition.X = csbi.srWindow.Left;
SetConsoleCursorPosition(handle, csbi.dwCursorPosition);
break;
case L'G':
case L'`':
- csbi.dwCursorPosition.X = (arg1 > csbi.dwSize.X ? csbi.dwSize.X : arg1) - 1;
+ arg1 += csbi.srWindow.Left;
+ if (arg1 > csbi.srWindow.Right)
+ arg1 = csbi.srWindow.Right;
+ csbi.dwCursorPosition.X = arg1;
SetConsoleCursorPosition(handle, csbi.dwCursorPosition);
break;
case L'd':
- csbi.dwCursorPosition.Y = (arg1 > csbi.dwSize.Y ? csbi.dwSize.Y : arg1) - 1;
+ arg1 += csbi.srWindow.Top;
+ if (arg1 > csbi.srWindow.Bottom)
+ arg1 = csbi.srWindow.Bottom;
+ csbi.dwCursorPosition.Y = arg1;
SetConsoleCursorPosition(handle, csbi.dwCursorPosition);
break;
case L'H':