Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe1527d
commit 7f04ee9
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
CC=clang | ||
CFLAGS=-Wall -Werror -g | ||
|
||
all: hellocurses hellocurses2 | ||
|
||
hellocurses: hellocurses.o | ||
$(CC) -l ncurses $< -o $@ | ||
|
||
hellocurses2: hellocurses2.o | ||
$(CC) -l ncurses $< -o $@ | ||
|
||
clean: | ||
$(RM) -f hellocurses hellocurses.o | ||
$(RM) -f hellocurses hellocurses.o hellocurses2 hellocurses2.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include <ncurses.h> | ||
|
||
int main() | ||
{ int ch; | ||
|
||
initscr(); /* Start curses mode */ | ||
raw(); /* Line buffering disabled */ | ||
keypad(stdscr, TRUE); /* We get F1, F2 etc.. */ | ||
noecho(); /* Don't echo() while we do getch */ | ||
|
||
printw("Type any character to see it in bold. Q to quit.\n"); | ||
|
||
do { | ||
ch = getch(); /* If raw() hadn't been called | ||
* we have to press enter before it | ||
* gets to the program */ | ||
clear(); | ||
if(ch == KEY_F(1)) /* Without keypad enabled this will */ | ||
printw("F1 Key pressed");/* not get to us either */ | ||
/* Without noecho() some ugly escape | ||
* charachters might have been printed | ||
* on screen */ | ||
else | ||
{ printw("The pressed key is "); | ||
attron(A_BOLD); | ||
printw("%c", ch); | ||
attroff(A_BOLD); | ||
} | ||
refresh(); /* Print it on to the real screen */ | ||
} while (ch != 'Q'); | ||
|
||
endwin(); /* End curses mode */ | ||
|
||
return 0; | ||
} | ||
|