File: cdemo.c

package info (click to toggle)
libcurses-perl 1.08b-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 624 kB
  • ctags: 754
  • sloc: ansic: 8,714; perl: 1,773; makefile: 36; sh: 9
file content (116 lines) | stat: -rw-r--r-- 2,135 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*  cdemo.c
**
**  Copyright (c) 1994-2000  William Setzer
**
**  You may distribute under the terms of either the Artistic License
**  or the GNU General Public License, as specified in the README file.
*/

#include "CursesDef.h"
#include "CursesTyp.h"
#include "c-config.h"
#ifdef VMS
#include <unistd.h>  /* not in perl.h ??? */
#endif

main() {
  WINDOW *b;
  chtype ch;
  char str[250];
  int m, n;

  initscr();
  b = subwin(stdscr, 10, 20, 3, 3);

  noecho();
  cbreak();

  move(0, 0);
  addstr("ref b = <something C won't do>");
  move(1, 1);
  addstr("fooalpha");

#ifdef C_ATTRON
#  ifdef A_BOLD
  attron(A_BOLD);
#  endif
#endif
  move(2, 5);
  addstr("bold  ");
#ifdef C_ATTRON
#  ifdef A_REVERSE
  attron(A_REVERSE);
#  endif
#endif
  addstr("bold+reverse");
#ifdef C_ATTRSET
#  ifdef A_NORMAL
  attrset(A_NORMAL);
#  endif
#endif
  addstr("  normal  (if your curses supports these modes)");

  move(6, 1);
  addstr("do12345678901234567890n't worry be happy");
#ifdef C_BOX
  box(b, '|', '-');
#endif
  wstandout(b);
  move(2, 2);
  waddstr(b, "ping");
  wstandend(b);
  move(4, 4);
  waddstr(b, "pong");

  wmove(b, 3, 3);
  move(6, 3);
  wdeleteln(b);
  insertln();

  move(4, 5);
  wdelch(b);
  move(7, 8);
  insch('a');

#ifdef C_KEYPAD
  keypad(stdscr, 1);
#endif
  move(14, 0);
  addstr("hit a key: ");
  refresh();
  ch = getch();
  move(15, 0);
  printw("you typed: >>%c<<", ch);
  move(17, 0);
  addstr("enter string: ");
  refresh();
  getstr(str);

  move(18, 0);
  printw("you typed: >>%s<<", str);
  getyx(stdscr, m, n);
  move(19, 4);
  printw("y == %d (should be 18), x == %d", m, n);

  ch = mvinch(19, 7);
  move(20, 0);
  printw("The character at (19,7) is an '%c' (should be an '=')", ch);

  move(21, 0);
  addstr("testing KEY_*.  Hit the up arrow on your keyboard: ");
  refresh();
  ch = getch();

#ifdef KEY_UP
  if (ch == KEY_UP) { mvaddstr(22, 0, "KEY_UP was pressed!");         }
  else              { mvaddstr(22, 0, "Something else was pressed."); }
#else
  move(22, 0);
  addstr("You don't seem to have the KEY_UP macro");
#endif

  move(LINES - 1, 0);
  refresh();
  sleep(5);
  endwin();
}