I am writing a console application in Linux, so there are two questions.

First, how to programmatically deploy a terminal emulator to full screen? Yes, in Windows this is done using the Win API, but what to do, for example, in Ubuntu?

Secondly, how can I change the background in the terminal during the execution of the program? So that I didn’t have a user theme, but a one I envisaged?

Thank you in advance.

  • ncurses to help - Andrej Levkovitch
  • @AndrejLevkovitch, and there are no escape sequences for this purpose? - Daniel Chizhevsky
  • for this you need to turn on the keypad - Andrej Levkovitch
  • Here is a good page for ncurses: linuxlib.ru/manpages/CURSES.3.shtml - Andrej Levkovitch

1 answer 1

In Linux, there is no concept of a console application in the Windows sense.

An application can have a controlling terminal with which it has associated standard input, output and error output descriptors, and from which signals can come. The terminal may be physical or virtual, in the latter case it may or may not support changing the number of lines and controlling the position of its window in the graphical environment (if it exists at all). And it depends on the terminal emulator program, of which there are a great many in Linux and each of its capabilities, however, those that run from the X-Window, such as xterm, usually support the VT102 command set, which provides some window control via escape sequences (look for dtterm) , but usually it is reduced or disabled by default or not implemented at all. You can enable it in xterm via X-resources, for example, when launching a terminal emulator:

xterm -xrm 'xterm*allowWindowOps: true' 

Next in the window that opens, try:

 $ printf '\033[3;0;0t' # переместить окно в верхний левый угол $ printf '\033[9;1t' # во весь экран 

If the environment variable DISPLAY defined, then the program is launched from the X-Window, and you can run your terminal emulator, specifying the required configuration and your program in the arguments. For arguments, see man xterm , man gnome-terminal , man konsole , etc.