summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-07-26 08:31:57 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-11-17 09:46:16 -0800
commit64d32af4244110a157efb7cfc906fc5f1a49b0e8 (patch)
treea355ae6f1d8eac7b6640461b94a0db0c9103eaa4
parent2c6ae4de768ac4117f7e9696ab19d6887a0edf2e (diff)
downloadcygnal-64d32af4244110a157efb7cfc906fc5f1a49b0e8.tar.gz
cygnal-64d32af4244110a157efb7cfc906fc5f1a49b0e8.tar.bz2
cygnal-64d32af4244110a157efb7cfc906fc5f1a49b0e8.zip
Console: integrate end-of-line hack with cursor positioning.
The previous work for simulating the beyond-right-edge of screen cursor position is incomplete without integrating this into the cursor positioning routines. By making the cursor routines aware of the eat_newline flag, we allow cursor movements to work correctly with regard to this simulated position. * winsup/cygwin/fhandler_console.cc (fhandler_console::cursor_set): If the X position is beyond the right edge of the screen, then set the cursor to the start of the following line, rather than clipping to the right edge, set the eat_newline flag, indicating that the the true position is actually one character beyond the previous line. In all other cases, clear the eat_newline flag. (fhandler_console::cursor_rel): Do not apply the delta vector to the raw Win32 cursor position; call cursor_get and apply it to the virtual cursor position which takes into account the eat_newline flag. (fhandler_console::cursor_get): Take into account the eat_newline flag. If it is set, then report an adjusted position that is one column beyond the end of the previous line.
-rw-r--r--winsup/cygwin/fhandler_console.cc31
1 files changed, 23 insertions, 8 deletions
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index 4548b5edc..bf7899364 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -1346,8 +1346,14 @@ fhandler_console::cursor_set (bool rel_to_top, int x, int y)
else if (rel_to_top)
y += con.b.srWindow.Top;
- if (x > con.dwWinSize.X)
- x = con.dwWinSize.X - 1;
+ con.eat_newline = false;
+
+ if (x >= con.dwWinSize.X)
+ {
+ y++;
+ x = 0;
+ con.eat_newline = true;
+ }
else if (x < 0)
x = 0;
@@ -1357,11 +1363,12 @@ fhandler_console::cursor_set (bool rel_to_top, int x, int y)
}
void __reg3
-fhandler_console::cursor_rel (int x, int y)
+fhandler_console::cursor_rel (int xdelta, int ydelta)
{
- con.fillin (get_output_handle ());
- x += con.b.dwCursorPosition.X;
- y += con.b.dwCursorPosition.Y;
+ int x, y;
+ cursor_get(&x, &y);
+ x += xdelta;
+ y += ydelta;
cursor_set (false, x, y);
}
@@ -1369,8 +1376,16 @@ void __reg3
fhandler_console::cursor_get (int *x, int *y)
{
con.fillin (get_output_handle ());
- *y = con.b.dwCursorPosition.Y;
- *x = con.b.dwCursorPosition.X;
+ if (!con.eat_newline)
+ {
+ *y = con.b.dwCursorPosition.Y;
+ *x = con.b.dwCursorPosition.X;
+ }
+ else
+ {
+ *y = con.b.dwCursorPosition.Y - 1;
+ *x = con.dwWinSize.X;
+ }
}
/* VT100 line drawing graphics mode maps `abcdefghijklmnopqrstuvwxyz{|}~ to