digitalmars.D.learn - How to update terminal output?
- dog2002 (4/4) Mar 28 2021 I mean, I want to write a string without a new line. For example,
- Mark Lagodych (8/12) Mar 28 2021 See http://www.climagic.org/mirrors/VT100_Escape_Codes.html
- Adam D. Ruppe (4/7) Mar 28 2021 Windows can support them all if you enable the setting.
-
dog2002
(2/16)
Mar 28 2021
Thank you. Seems like \033[
A\r does work. - Zardoz (6/10) Mar 28 2021 You must use ANSI control codes to repositionate the cursor or
- Jack (11/15) Mar 28 2021 you have to erase the line when you're about to display a new
I mean, I want to write a string without a new line. For example, some command line applications have progress bars. For a single line string I use \r. But it doesn't work for a multiple line string - the application is just adding new lines.
Mar 28 2021
On Sunday, 28 March 2021 at 16:45:29 UTC, dog2002 wrote:I mean, I want to write a string without a new line. For example, some command line applications have progress bars. For a single line string I use \r. But it doesn't work for a multiple line string - the application is just adding new lines.See http://www.climagic.org/mirrors/VT100_Escape_Codes.html Basically, you just need to do this: writeln("\033[" ~ cmd); where cmd is your VT100 command and \033 is an Escape character. Although some (all?) of that commands do not work in the Windows terminal. For instance, you can change background color ONLY using Windows API.
Mar 28 2021
On Sunday, 28 March 2021 at 17:13:02 UTC, Mark Lagodych wrote:Although some (all?) of that commands do not work in the Windows terminal. For instance, you can change background color ONLY using Windows API.Windows can support them all if you enable the setting. but yeah anything outside the current line needs these sequences and/or the right api calls.
Mar 28 2021
On Sunday, 28 March 2021 at 17:13:02 UTC, Mark Lagodych wrote:On Sunday, 28 March 2021 at 16:45:29 UTC, dog2002 wrote:Thank you. Seems like \033[<n>A\r does work.I mean, I want to write a string without a new line. For example, some command line applications have progress bars. For a single line string I use \r. But it doesn't work for a multiple line string - the application is just adding new lines.See http://www.climagic.org/mirrors/VT100_Escape_Codes.html Basically, you just need to do this: writeln("\033[" ~ cmd); where cmd is your VT100 command and \033 is an Escape character. Although some (all?) of that commands do not work in the Windows terminal. For instance, you can change background color ONLY using Windows API.
Mar 28 2021
On Sunday, 28 March 2021 at 16:45:29 UTC, dog2002 wrote:I mean, I want to write a string without a new line. For example, some command line applications have progress bars. For a single line string I use \r. But it doesn't work for a multiple line string - the application is just adding new lines.You must use ANSI control codes to repositionate the cursor or use a library like ncurses that handle this kind of stuff. https://code.dlang.org/search?q=ncurses In particular , nice-curses have a class to generate a TUI progress bar
Mar 28 2021
On Sunday, 28 March 2021 at 16:45:29 UTC, dog2002 wrote:I mean, I want to write a string without a new line. For example, some command line applications have progress bars. For a single line string I use \r. But it doesn't work for a multiple line string - the application is just adding new lines.you have to erase the line when you're about to display a new progress percent. On UNIX system, you have to use character terminal escapes[1] on window you have to dig the console API[2] or you can just use ncurse library[3][4] [1]: https://web.archive.org/web/20200415203148/http://ascii-table.com/ansi-escape-sequences-vt-100.php [2]: https://docs.microsoft.com/en-us/windows/console/console-reference [3]: https://invisible-island.net/ncurses/announce.html [4]: https://code.dlang.org/search?q=ncurses
Mar 28 2021