diff options
Diffstat (limited to 'winsup/cygwin')
-rw-r--r-- | winsup/cygwin/fhandler.h | 1 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_console.cc | 23 |
2 files changed, 24 insertions, 0 deletions
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 4da35b7f5..53798d047 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -2020,6 +2020,7 @@ class dev_console bool iso_2022_G1; bool alternate_charset_active; bool metabit; + bool eat_newline; char backspace_keycode; bool screen_alternated; /* For xterm compatible mode only */ diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index 0b33a1370..815b952e6 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -2971,6 +2971,18 @@ do_print: if (len >= CONVERT_LIMIT) return found + trunc_buf.len; } + + /* If we output something and now x is at the left + * column, it means that we just output to the last column. + * In this case we can pretend we are still in the original + * line and swallow the next character if it is a newline, + * or a newline followed by a carriage return. + */ + { + int x, y; + cursor_get (&x, &y); + con.eat_newline = (x == 0); + } /* If there's still something in the src buffer, but it's not a truncated multibyte sequence, then we stumbled over a control character or an invalid multibyte sequence. Print it. */ @@ -2994,6 +3006,12 @@ do_print: break; case DWN: cursor_get (&x, &y); + + if (con.eat_newline) { + con.eat_newline = false; + break; + } + if (y >= srBottom) { if (y >= con.b.srWindow.Bottom && !con.scroll_region.Top) @@ -3009,11 +3027,14 @@ do_print: break; case BAK: cursor_rel (-1, 0); + con.eat_newline = false; break; case IGN: /* Up to release 3.1.3 we called cursor_rel (1, 0); to move the cursor one step to the right. However, that neither matches the terminfo for the cygwin terminal, nor the one for the xterm terminal. */ + con.eat_newline = false; + cursor_rel (1, 0); break; case CR: cursor_get (&x, &y); @@ -3041,10 +3062,12 @@ do_print: } break; case TAB: + con.eat_newline = false; cursor_get (&x, &y); cursor_set (false, 8 * (x / 8 + 1), y); break; case NOR: + con.eat_newline = false; write_replacement_char (); break; } |