source: tester.c @ 2c8d62e

barnowl_perlaimdebianowlrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 2c8d62e was e1c4636, checked in by Erik Nygren <nygren@mit.edu>, 22 years ago
* Added owl::send_zwrite(command, message) to the perl glue to allow for the direct sending of multi-line messages. For example: owl::send_zwrite("-c foo -i bar", "hello"); * Reverted attempted fix for the pagedown problem which just made things worse. * Changed owl_fmtext_print_plain to return an alloc'd string to avoid buffer overrun risks. * Added owl::ztext_stylestrip("...") function to perlglue which returns the ztext with formatting stripped out. * Added colorztext variable which can be used to disable @color() strings arriving in messages after it is set. (Currently, changing its value won't reformat messages). * Outgoing zephyr logging now obeys the logpath variable. * The '~' character in logpath and classlogpath now gets replaced with the user's home directory.
  • Property mode set to 100644
File size: 3.0 KB
Line 
1#include "owl.h"
2#include <unistd.h>
3#include <stdlib.h>
4
5static const char fileIdent[] = "$Id$";
6
7void screeninit() {
8  char buff[1024];
9 
10  sprintf(buff, "TERMINFO=%s", TERMINFO);
11  putenv(buff);
12
13  initscr();
14  start_color();
15  /* cbreak(); */
16  raw();
17  noecho();
18  intrflush(stdscr,FALSE);
19  keypad(stdscr,TRUE);
20  nodelay(stdscr,1);
21  clear();
22  refresh();
23  meta(stdscr, TRUE);
24}
25
26void test1() {
27  int j;
28  owl_editwin e;
29
30  screeninit();
31
32  owl_editwin_init(&e, stdscr, LINES, COLS, OWL_EDITWIN_STYLE_MULTILINE, NULL);
33  /* owl_editwin_set_locktext(&e, "Here is some locktext:\n");*/
34  doupdate();
35  while (1) {
36    usleep(50);
37
38    j=getch();
39
40    if (j==ERR) continue;
41
42    if (j==3) break;
43
44    if (j==27) {
45      j=getch();
46      if (j==ERR) continue;
47      owl_editwin_process_char(&e, j);
48      doupdate();
49    } else {
50      owl_editwin_process_char(&e, j);
51      doupdate();
52    }
53  }
54  endwin();
55  printf("Had:\n%s", owl_editwin_get_text(&e));
56}
57
58void test2(char *in) {
59  owl_fmtext t;
60
61  screeninit();
62
63  owl_fmtext_init_null(&t);
64  owl_fmtext_append_ztext(&t, in);
65  owl_fmtext_curs_waddstr(&t, stdscr);
66  wrefresh(stdscr);
67  sleep(5000);
68  endwin();
69}
70
71void test3() {
72  ZNotice_t *n;
73
74  printf("%i\n", sizeof(n->z_uid.zuid_addr));
75  /* gethostbyaddr((char *) &(n->z_uid.zuid_addr), sizeof(n->z_uid.zuid_addr), AF_INET); */
76}
77
78void colorinfo() {
79  char buff[1024];
80 
81  screeninit();
82  sprintf(buff, "Have %i COLOR_PAIRS\n", COLOR_PAIRS);
83  addstr(buff);
84  refresh();
85  sleep(10);
86  endwin(); 
87}
88
89void test4() {
90  int j;
91  char buff[1024];
92
93  screeninit();
94 
95  while (1) {
96    usleep(100);
97
98    j=getch();
99
100    if (j==ERR) continue;
101
102    if (j==3) break;
103    sprintf(buff, "%o\n", j);
104    addstr(buff);
105  }
106  endwin();
107}
108
109void test_keypress() {
110  int j, rev;
111  char buff[1024], buff2[64];
112
113  screeninit();
114 
115  while (1) {
116    usleep(100);
117
118    j=wgetch(stdscr);
119
120    if (j==ERR) continue;
121
122    if (j==3) break;
123    if (0 == owl_keypress_tostring(j, 0, buff2, 1000)) {
124      rev = owl_keypress_fromstring(buff2);
125      sprintf(buff, "%s : 0x%x 0%o %d %d %s\n", buff2, j, j, j, rev,
126              (j==rev?"matches":"*** WARNING: Does Not Reverse"));
127    } else {
128      sprintf(buff, "UNKNOWN : 0x%x 0%o %d\n", j, j, j);
129    }
130      addstr(buff);
131  }
132  endwin();
133}
134
135
136int main(int argc, char **argv, char **env) {
137  int numfailures=0;
138  if (argc==2 && 0==strcmp(argv[1],"reg")) {
139    numfailures += owl_util_regtest();
140    numfailures += owl_dict_regtest();
141    numfailures += owl_variable_regtest();
142    if (numfailures) {
143      fprintf(stderr, "*** WARNING: %d failures total\n", numfailures);
144    }
145    return(numfailures);
146  } else if (argc==2 && 0==strcmp(argv[1],"test1")) {
147    test1();
148  } else if (argc==2 && 0==strcmp(argv[1],"colorinfo")) {
149    colorinfo();
150  } else if (argc==2 && 0==strcmp(argv[1],"test4")) {
151    test4();
152  } else if (argc==2 && 0==strcmp(argv[1],"keypress")) {
153    test_keypress();
154  } else {
155    fprintf(stderr, "No test specified.  Current options are: reg test1\n");
156  }
157  return(0);
158}
159
Note: See TracBrowser for help on using the repository browser.