| | |
Trapping the Tab Key.......
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2007
Posts: 14
Reputation:
Solved Threads: 0
Hi,
I am making a small software. As a part of the Command Line Interface I am supposed to include the "tab help facility" .Incase the user is typing a command and in between he presses the Tab key, the software should display all the avavilable commands.
I am unable to trap the Tab ...
And ofcourse the Coding is in C..
I am making a small software. As a part of the Command Line Interface I am supposed to include the "tab help facility" .Incase the user is typing a command and in between he presses the Tab key, the software should display all the avavilable commands.
I am unable to trap the Tab ...
And ofcourse the Coding is in C..
•
•
Join Date: Dec 2006
Posts: 1,089
Reputation:
Solved Threads: 164
if you are using c++ we can write portable code
C++ Syntax (Toggle Plain Text)
std::cin >> std::noskipws ; char ch ; std::cin >> ch ; if( ch == '\t' ) /* ... */ ;// tab else /* ... */ ; // something else
Last edited by ~s.o.s~; Apr 3rd, 2007 at 1:46 pm. Reason: Fixed code tags.
•
•
•
•
Depends on if you want the user to press the return/enter key first. If not, you'll probably want to code with something like [search]NCurses[/search].
"Incase the user is typing a command and in between he presses the Tab key, the software should display all the avavilable commands."
Kinda like word completion in shells.
•
•
Join Date: Dec 2006
Posts: 1,089
Reputation:
Solved Threads: 164
ncurses (or curses) is installed by default by
most linux distros. try man curses to check.
install ncurses-development package if
it is not already installed.
while writing code,
compiling/linking:
either gcc. -lncurses your_program.c
or gcc your_program.c libncurses.a
link statically to the ncurses library
if u want to run your program on machines
where ncurses is not installed.
most linux distros. try man curses to check.
install ncurses-development package if
it is not already installed.
while writing code,
#include <ncurses.h> // or <curses.h> int main() { initscr() ; // must be called first cbreak() // disable the buffering // required to get a character immediately // without waiting for return key. noecho(); // only if u want to suppress // echo of input keys keypad(stdscr, TRUE); // only if u want // to read special keys (delete,arrow keys etc.) // to read a character, use int getch(void) ; // normally getch waits till a // key is hit. to work in a // nonblocking manner, call // nodelay(stdscr, TRUE) ; // in this case getch will return // ERR if key input is not available. endwin() // must be called before exiting // to restore the terminal settings. return 0 ; }
compiling/linking:
either gcc. -lncurses your_program.c
or gcc your_program.c libncurses.a
link statically to the ncurses library
if u want to run your program on machines
where ncurses is not installed.
Last edited by vijayan121; Apr 4th, 2007 at 12:37 pm. Reason: formatting
![]() |
| Thread Tools | Search this Thread |
api array based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock wordfrequency wxwidgets






