diff options
-rw-r--r-- | winsup/cygwin/fhandler_console.cc | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index 0d3d234d9..5fe448051 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -1311,8 +1311,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; @@ -1322,11 +1328,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); } @@ -1334,8 +1341,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 |