From 308631a56da33767290bd750628b829a131277a9 Mon Sep 17 00:00:00 2001 From: arrow_zhang Date: Tue, 8 Jan 2008 21:16:29 +0800 Subject: [PATCH] add printw test --- ncurses/.gitignore | 7 +++++++ ncurses/Makefile | 5 ++++- ncurses/printw.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 ncurses/.gitignore create mode 100644 ncurses/printw.c diff --git a/ncurses/.gitignore b/ncurses/.gitignore new file mode 100644 index 0000000..0956b7a --- /dev/null +++ b/ncurses/.gitignore @@ -0,0 +1,7 @@ + +tags +.*.swp +.*.swo + +*.o +.*.d diff --git a/ncurses/Makefile b/ncurses/Makefile index 0e21cf9..b9a6fec 100644 --- a/ncurses/Makefile +++ b/ncurses/Makefile @@ -1,6 +1,6 @@ # Makefile include Rules.make -BIN:= ncurses keypad +BIN:= ncurses keypad printw ifdef DEBUG CFLAGS+= -D_DEBUG_ endif @@ -16,6 +16,9 @@ ncurses: ncurses.c keypad: keypad.c $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< +printw: printw.c + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< + .%.d: %.c @$(CC) $(CFLAGS) -M $< >$@ @sed -i "1s/^$*.o:/$*.o $*.d: Makefile Rules.make/g;" $@ diff --git a/ncurses/printw.c b/ncurses/printw.c new file mode 100644 index 0000000..48c49c8 --- /dev/null +++ b/ncurses/printw.c @@ -0,0 +1,36 @@ +/* copyleft (C) GPL3 {{{2 + * Filename: printw.c + * + * Author: arrow + * Created at: Tue Jan 8 21:12:02 2008 + * }}}*/ +/*header files {{{1*/ +#include +#include +#include "debug.h" +/*}}}*/ + +/*declaration {{{1*/ +/*}}}*/ + +/*functions {{{1*/ +int main(int argc, char *argv[]) +{ + char mesg[] = "Just a string"; + int row, col; + + initscr(); + getmaxyx(stdscr, row, col); + mvprintw(row/2, (col - strlen(mesg))/2, "%s", mesg); + mvprintw(row - 2, 0, "This screen has %d rows and %d columns\n", row, col); + printw("Try resizing your window(if possible) and then run this program again"); + refresh(); + getch(); + endwin(); + + return 0; +} + +/* vim:fdm=marker:ts=8:ft=c:norl:fdl=1: + * }}}*/ + -- 2.11.4.GIT