Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write full-screen Linux console app/script?

I'm having a hard time even googling this, because I don't know the right keywords. Some command-line apps (such as vi and less) take over the whole console screen and present an interactive interface to the user. Upon exiting such an app, the screen is returned to the state it was in before the app was launched. I want to write a program that behaves in this fashion, but again, I don't even know what this is called, so I can't find any documentation for how it's accomplished.

So, my question is threefold:

  1. What keywords can I use to find documentation on this?
  2. If you are so inclined, links to such documentation would be helpful.
  3. Lastly, can I accomplish this in a scripting language like Ruby, or even bash? I have no problem with C, but the environment I work in is more amenable to interpreted languages.
like image 549
Ryan Ballantyne Avatar asked Jan 08 '13 18:01

Ryan Ballantyne


People also ask

How do I make Linux terminal full screen?

Press the menu button in the top-right corner of the window and select Full Screen, or press F11 .

How do I open a new screen in Linux?

Switching Between Screen Terminal Windows To create a new screen window, just press “Ctrl-A” and “c“.

How do I exit full screen in Ubuntu terminal?

To turn off fullscreen mode and return to the standard gedit window, press F11 . You can also move your mouse cursor to the top of the screen, and wait for the menu bar to appear. When the menu bar appears, select the Leave Fullscreen button.


2 Answers

As said in some comments, you are looking for ncurses. The Linux Documentation Project have a very good HOWTO on ncurses for C that I used myself to start on it

https://tldp.org/HOWTO/NCURSES-Programming-HOWTO/

like image 97
beder Avatar answered Oct 13 '22 13:10

beder


The feature you are describing is the alternate screen buffer. I think that [N]Curses will enable this by default. There are certainly curses bindings for Ruby, Python, and other scripting languages.

like image 43
larsks Avatar answered Oct 13 '22 12:10

larsks