Initial check-in. Mostly sort of works. Ish.
2 * $Id: message.c,v 1.5 2004/12/30 09:07:47 ali Exp $
3 * Copyright (C) 2007 J. Ali Harlow
4 * Min Hack may be freely redistributed. See license for details.
12 char minhack_yn_function(const char *ques, const char *choices, char def,
16 waddstr(windows[message_win].win,ques);
19 waddstr(windows[message_win].win," [");
20 for(i=0;choices[i] && choices[i]!='\033';i++)
21 waddch(windows[message_win].win,choices[i]);
22 waddstr(windows[message_win].win,"] ");
26 sprintf(buf,"(%c) ",def);
27 waddstr(windows[message_win].win,buf);
29 wclrtoeol(windows[message_win].win);
30 getyx(windows[message_win].win,i,x);
33 ch=wgetch(windows[message_win].win);
37 if (strchr(choices,'q'))
39 else if (strchr(choices,'n'))
50 if (strchr(choices,'#') && strchr("0123456789",ch))
52 waddch(windows[message_win].win,ch);
57 else if (strchr(choices,ch))
63 else if (cnt && (ch=='\b' || ch==127))
66 wmove(windows[message_win].win,0,n+x);
67 wclrtoeol(windows[message_win].win);
75 return wgetch(windows[message_win].win);
78 char *minhack_getlin(const char *query)
82 nhproxy_cb_flush_screen();
83 minhack_putstr(message_win,0,query);
84 wclrtoeol(windows[message_win].win);
85 getyx(windows[message_win].win,i,x);
88 ch=wgetch(windows[message_win].win);
89 if (ch>=' ' && ch<='~' && n<sizeof(line)-1)
91 waddch(windows[message_win].win,ch);
94 else if (n && (ch=='\b' || ch==127))
97 wmove(windows[message_win].win,0,n+x);
98 wclrtoeol(windows[message_win].win);
100 else if (ch=='\n' || ch=='\r')
114 int minhack_get_ext_cmd(void)
118 struct nhproxy_cb_get_extended_commands_res *commands;
119 commands=nhproxy_cb_get_extended_commands();
120 line=minhack_getlin("# ");
121 for(i=0;i<commands->n_commands;i++)
122 if (!strcmp(commands->commands[i],line))
127 nhproxy_cb_free_extended_commands(commands);