I'm writing a program that needs to modify the terminal screen buffer without using printf or stdout. On win32 I did that by using CreateConsoleScreenBuffer()
and SetConsoleActiveScreenBuffer()
then writing to the console screen buffer using WriteConsoleOutputCharacter()
. I want to do this on linux as well (kind of like how vim prints things out) but I can't find any way. It would also be great if there was a way to do this using the standard library!
Asked
Active
Viewed 96 times
0

Thomas Dickey
- 51,086
- 7
- 70
- 105

Phillip
- 135
- 6
-
5The [ncurses](https://invisible-island.net/ncurses/) library. – molbdnilo Mar 04 '23 at 10:53
-
1Alternatively you can manipulate the screen by printing [escape sequences](https://man7.org/linux/man-pages/man4/console_codes.4.html). – teapot418 Mar 04 '23 at 13:55
1 Answers
0
OP says
without using
printf
or stdout
you could use stderr (which usually points to the same terminal), e.g.,
echo '\033[H\033[J' >&2
to clear the screen while writing to stderr. Or you could use tput
, e.g.,
tput clear >&2

Thomas Dickey
- 51,086
- 7
- 70
- 105