summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-07-26 08:31:57 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-10-11 11:34:01 -0700
commit5d5357c423129e0bb5a1ed4783451ee219258182 (patch)
treeacb4d0f229245e36db295660e2852938d5599c46
parent07e4bec9c15d4249ba2d13d21312b3a89df59f8d (diff)
downloadcygnal-5d5357c423129e0bb5a1ed4783451ee219258182.tar.gz
cygnal-5d5357c423129e0bb5a1ed4783451ee219258182.tar.bz2
cygnal-5d5357c423129e0bb5a1ed4783451ee219258182.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 4e2834a76..44eca2087 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -1732,8 +1732,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;
@@ -1743,11 +1749,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);
}
@@ -1755,8 +1762,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