[ADD] test code and emacs conf .d
[arrow.git] / ncurses / scrollwin2.c
blobf04fb4735cfc5febc472c25526422af79e443484
1 #include <stdlib.h>
2 #include <ncurses.h>
3 #include <signal.h>
4 #include <stdio.h>
5 #include <unistd.h>
6 static void finish(int sig);
7 WINDOW *scrwin, *boxwin;
8 int main(int argc, char *argv[])
10 FILE *fp;
11 int i, j;
13 fp = fopen("zz.txt", "w+");
14 if (fp == NULL) {
15 printf("open file fail\n");
16 return 0;
18 initscr();
19 cbreak();
20 noecho();
21 nonl();
22 scrwin = newwin(10, 40, LINES / 2 - 6, COLS / 2 - 25);
23 boxwin = newwin(12, 42, LINES / 2 - 7, COLS / 2 - 26);
24 scrollok(scrwin, 1);
25 box(boxwin, '|', '-');
26 refresh();
27 wrefresh(boxwin);
28 signal(SIGINT, finish);
29 signal(SIGQUIT, finish);
30 for (i = 0;; i++) {
31 if (i % 20 == 0)
32 if (getchar() == 'q')
33 return 0;
34 sleep(1);
35 wprintw(scrwin, "the string is %d\n", j = i % 9);
36 fprintf(fp, "the string is %d\n", j);
37 wrefresh(scrwin);
40 fclose(fp);
41 return 0;
43 void finish(int sig)
45 endwin();
46 exit(0);