From c36abe1c152311a66dfc813317d831838416a633 Mon Sep 17 00:00:00 2001 From: james Date: Mon, 23 Jan 2023 22:37:24 +0200 Subject: [PATCH] Attempted to add clear to end of line support. But have no way to check windows version. --- terminal.d | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/terminal.d b/terminal.d index 2dca0c2..4e2278d 100644 --- a/terminal.d +++ b/terminal.d @@ -2330,6 +2330,25 @@ http://msdn.microsoft.com/en-us/library/windows/desktop/ms683193%28v=vs.85%29.as _cursorY = 0; } + ///Clears the current line from the cursor onwards + void clearLine() { + if(UseVtSequences) { + writeStringRaw("\033[0K"); + } + else version(Windows) { + updateCursorPosition(); + auto x = _cursorX; + auto y = _cursorY; + DWORD c; + CONSOLE_SCREEN_BUFFER_INFO csbi; + DWORD conSize = width-x; + GetConsoleScreenBufferInfo(hConsole, &csbi); + auto coordScreen = COORD(x,y); + FillConsoleOutputCharacterA(hConsole, ' ', conSize, coordScreen, &c); + FillConsoleOutputAttribute(hConsole, csbi.wAttributes, conSize, coordScreen, &c); + moveTo(x, y, ForceOption.alwaysSend); + } + } /++ Gets a line, including user editing. Convenience method around the [LineGetter] class and [RealTimeConsoleInput] facilities - use them if you need more control.