What would be the best, most portable, simplest way to create a GUI-like feeling in the command line?
Basically I'm asking for a library that allows you to change background and text colors, have a text input area on the bottom of the console, and be able to edit a certain area in the command line without having to clear the whole screen. Does such a library exist?
Example from IRSSI
Thank you.
You could use ncurses
ncurses?
Here is a HowTo: http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/index.html
ncurses ?
Though if you need MS Windows support, you may find limitations.
PDCurses or ncurses (if you care only about *nixes). irssi uses the latter.
NCurses always clears the whole screen. Is there any alternative which only changes the colors but not mess with the current console content?
Related
I wanna change the colour/color of my program text. I don't wanna do it on windows.h as I want my program to run on other platforms. I also don't wanna do system("color 0a"); is there any ways that i can fix that? if so please help.
There is a way to change color through #include <conio.h>, but as I can see you want it to be cross-platform and conio.h is pure DOS based, that's probably not what you want.
So with that considered I would recommend using ncurses. It's really flexible and usefull library capable of infinite terminal styling. It has even a Windows alternative pdcurses that has identical syntax.
See more at pdcurses or ncurses.
I am writing a simple program in C++ to be run in a terminal window. I would like the output text to be locked in position on the screen. Instead of each new line appearing at the bottom of the screen and pushing everything up, I would like to be able to change a line of text or some characters in a line of text, while keeping other lines above and below it static. I know I have seen this done in terminal, and I believe it was done with C++, but I can't find any documentation on it. I cannot even think of what this type of display might be called. My google fu has failed me; please help. If you can tell me what commands/library to use, that would be great, but even being able to tell me what commands accomplish this in a programming language other than C++ would give me more to go on than I have now.
You want ncurses, a library for displaying text on a terminal.
If you are programming for Microsoft Windows, try googling for Win32 Console Functions.
I want to partition the output screen into two parts (just like frames do it in HTML). So that one part may remain fixed and display some content which is updated based on input received from the other part.
I do not wish to venture into GUI stuff therefore OpenGL, SDL etc are ruled out (I wish to do it in command line mode). I have Borland C++ with graphics.h support, but it is just too old to carry on.
What alternatives do I have at my disposal (If not C++, a solution in C will also be Ok.)
You may want to take a look at curses-like libraries like PDCurses.
Other than that, you may use ANSI terminal escape sequences to control the cursor on a text window, this may be quicker if what you are doing is simple, otherwise use PDCurses and it will handle the escape sequences for you.
Check out Curses / NCurses.
I am trying to build a console application that takes user input. I was able to use printf to keep the cursor in the same place, I could have used curses as well, but I can't get up-arrow command history to work. Any pointers ?
I think you want readline (www.gnu.org/software/readline/ which seems to now redirect to the maintainer site at http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html)
In addition to the mentions of the readline library, I'll also mention the BSD-licensed editline library and the rlwrap command-line wrapper tool that runs any program with a readline-based history.
As long as the GNU license is not a problem for you, I would strongly consider GNU Readline
Have a look at the GNU Readline library. It can provide input history support.
In Windows the standard console windows provide up-arrow input history -- you don't have to do anything. For other standard Windows console services see the doskey command quickhelp, and simply replace the word "command" with "line of input". It's a bit misleading, yes.
EDIT, added para: Possibly you're doing something that circumvents the standard services. I just noticed that the browser window title says "ncurses", which is not in your current question title. Perhaps that's it, but in that case, ask specifically for help with ncurses.
For *nix see the other answers.
Cheers & hth.
I am trying to write a C++ program where the screen updates every 1 second. However, I want the screen to be similar to htop, where it updates and does not have to scroll with each update. That way, I don't have a step-by-step iteration in my terminal.
Does anyone know what this style is called or how to program it?
Thanks!
The usual way is with something like ncurses. If you're on Windows, it has console functions built in so you can do the same without any extra libraries (though they do take a while to understand). If you only want one line of output, you can use a '\r' to return to the beginning of the current line and/or \b to backspace over previous characters (handy if yoy only want to overwrite a few little bits and pieces).
You'll need a library like curses (on *nix) or pdcurses for Windows (conio functions would probably still work on windows).