summaryrefslogtreecommitdiff
path: root/vchat-ui.c
diff options
context:
space:
mode:
authorerdgeist <>2006-01-26 18:40:30 +0000
committererdgeist <>2006-01-26 18:40:30 +0000
commit57689e698230030803c872072a03329fdd4fecc6 (patch)
treeb4f8671dbe04741be93091e99eb3c6aa81b9bebd /vchat-ui.c
parent4413fb15bec35744c06ac3cfce2ae2bfa6953ae1 (diff)
unsigned char tidy up, query mode
Diffstat (limited to 'vchat-ui.c')
-rwxr-xr-xvchat-ui.c284
1 files changed, 120 insertions, 164 deletions
diff --git a/vchat-ui.c b/vchat-ui.c
index 9378e0d..bd1cbe0 100755
--- a/vchat-ui.c
+++ b/vchat-ui.c
@@ -30,13 +30,13 @@
30#include "vchat.h" 30#include "vchat.h"
31 31
32/* version of this module */ 32/* version of this module */
33unsigned char *vchat_ui_version = "$Id$"; 33char *vchat_ui_version = "$Id$";
34 34
35/* externally used variables */ 35/* externally used variables */
36/* current string in topic window */ 36/* current string in topic window */
37unsigned char topicstr[TOPICSTRSIZE] = "[] VChat 0.16"; 37char topicstr[TOPICSTRSIZE] = "[] VChat 0.16";
38/* current string in console window */ 38/* current string in console window */
39unsigned char consolestr[CONSOLESTRSIZE] = "[ Get help: .h for server /h for client commands"; 39char consolestr[CONSOLESTRSIZE] = "[ Get help: .h for server /h for client commands";
40 40
41static unsigned int ui_init = 0; 41static unsigned int ui_init = 0;
42 42
@@ -48,8 +48,6 @@ static WINDOW *channel = NULL;
48static WINDOW *private = NULL; 48static WINDOW *private = NULL;
49static WINDOW *output = NULL; 49static WINDOW *output = NULL;
50 50
51static FILE *vchat_logfile = NULL;
52
53/* our screen dimensions */ 51/* our screen dimensions */
54static int screensx = 0; 52static int screensx = 0;
55static int screensy = 0; 53static int screensy = 0;
@@ -68,12 +66,13 @@ static int privheight_desired = 0;
68static int privwinhidden = 0; 66static int privwinhidden = 0;
69int usetime = 1; 67int usetime = 1;
70int outputcountdown = 0; 68int outputcountdown = 0;
69char *querypartner = NULL;
71 70
72struct sb_entry { 71struct sb_entry {
73 int id; 72 int id;
74 time_t when; 73 time_t when;
75 int stamp; 74 int stamp;
76 unsigned char *what; 75 char *what;
77 struct sb_entry *link; 76 struct sb_entry *link;
78}; 77};
79 78
@@ -93,9 +92,9 @@ static int sb_win = 0; /* 0 for pub, 1 for priv */
93 92
94/* struct to keep filter list */ 93/* struct to keep filter list */
95struct filt { 94struct filt {
96 unsigned char colour; 95 char colour;
97 unsigned int id; 96 unsigned int id;
98 unsigned char *text; 97 char *text;
99 regex_t regex; 98 regex_t regex;
100 struct filt *next; 99 struct filt *next;
101}; 100};
@@ -119,7 +118,7 @@ static void resize_output (void);
119static int getsbeheight (struct sb_entry *entry, const int xwidth, int needstime ); 118static int getsbeheight (struct sb_entry *entry, const int xwidth, int needstime );
120static int getsbdataheight (struct sb_data *data, const int xwidth, int needstime ); 119static int getsbdataheight (struct sb_data *data, const int xwidth, int needstime );
121/* CURRENTLY UNUSED 120/* CURRENTLY UNUSED
122static void writecolorized (WINDOW *win, unsigned char *string); 121static void writecolorized (WINDOW *win, char *string);
123*/ 122*/
124 123
125enum { 124enum {
@@ -129,10 +128,20 @@ enum {
129 RMFILTER_KEEPANDSTOP 128 RMFILTER_KEEPANDSTOP
130}; 129};
131 130
131/* */
132static void
133togglequery() {
134 if( querypartner && private ) {
135 { struct sb_data *tmp = sb_pub; sb_pub = sb_priv; sb_priv = tmp; }
136 { WINDOW *tmp= private; private = channel; channel = tmp; }
137 }
138}
139
132/* readlines callback when a line is completed */ 140/* readlines callback when a line is completed */
133static void 141static void
134linecomplete (unsigned char *line) 142linecomplete (char *line)
135{ 143{
144 char *c;
136 int i; 145 int i;
137 146
138 /* send linefeed, return pointer, reset cursors */ 147 /* send linefeed, return pointer, reset cursors */
@@ -157,6 +166,10 @@ linecomplete (unsigned char *line)
157 handleline (line); 166 handleline (line);
158 free (line); 167 free (line);
159 168
169 /* If in query mode, feed query prefix */
170 if (( c = querypartner ))
171 while( *c ) rl_stuff_char( *c++ );
172
160 /* wipe input line and reset cursor */ 173 /* wipe input line and reset cursor */
161 wmove (input, 0, 0); 174 wmove (input, 0, 0);
162 for (i = 0; i < input->_maxx; i++) 175 for (i = 0; i < input->_maxx; i++)
@@ -212,8 +225,8 @@ userinput (void)
212} 225}
213 226
214static int 227static int
215calcdrawcus (unsigned char * const str) { 228calcdrawcus (char * const str) {
216 unsigned char *tmp = str; 229 char *tmp = str;
217 int zero = 0; 230 int zero = 0;
218 while( *tmp && (*tmp!=' ') && (*tmp!='\n')) { if(*tmp==1) zero+=2; tmp++; } 231 while( *tmp && (*tmp!=' ') && (*tmp!='\n')) { if(*tmp==1) zero+=2; tmp++; }
219 return (tmp - str) - zero; 232 return (tmp - str) - zero;
@@ -240,7 +253,7 @@ sb_clear ( struct sb_data **sb ) {
240}*/ 253}*/
241 254
242static struct sb_entry* 255static struct sb_entry*
243sb_add (struct sb_data *sb, unsigned char *line, time_t when) { 256sb_add (struct sb_data *sb, char *line, time_t when) {
244 struct sb_entry *newone = malloc (sizeof(struct sb_entry)); 257 struct sb_entry *newone = malloc (sizeof(struct sb_entry));
245 if( newone ) { 258 if( newone ) {
246 if( sb->count == sb->scroll ) sb->scroll++; 259 if( sb->count == sb->scroll ) sb->scroll++;
@@ -282,7 +295,7 @@ void showout (void)
282 resize(0); 295 resize(0);
283} 296}
284 297
285void writeout (unsigned char *str) 298void writeout (char *str)
286{ 299{
287 int i; 300 int i;
288 sb_add(sb_out,str,time(NULL)); 301 sb_add(sb_out,str,time(NULL));
@@ -290,43 +303,47 @@ void writeout (unsigned char *str)
290 if( i > outputwidth_desired ) outputwidth_desired = i; 303 if( i > outputwidth_desired ) outputwidth_desired = i;
291} 304}
292 305
293int writechan (unsigned char *str) { 306int writechan (char *str) {
294 struct sb_entry *tmp; 307 struct sb_entry *tmp;
295 int i = 0; 308 int i = 0;
296 time_t now = time(NULL); 309 time_t now = time(NULL);
297 tmp = sb_add(sb_pub,str,now); 310 tmp = sb_add(sb_pub,str,now);
298 311
299 if( getintoption( CF_KEEPLOG ) && vchat_logfile )
300 fprintf( vchat_logfile, "%016llX0%s\n", (signed long long)now, str);
301
302 if ( (sb_pub->scroll == sb_pub->count) && ((filtertype == 0) || ( testfilter(tmp)))) { 312 if ( (sb_pub->scroll == sb_pub->count) && ((filtertype == 0) || ( testfilter(tmp)))) {
303 i = writescr(channel, tmp); 313 i = writescr(channel, tmp);
304 wnoutrefresh(channel); 314 wnoutrefresh(channel);
305 } 315 }
306 consoleline(NULL); 316
317 if( querypartner && private )
318 topicline(NULL);
319 else
320 consoleline(NULL);
321
307 return i; 322 return i;
308} 323}
309 324
310int writecf (formtstr id,unsigned char *str) { 325int writecf (formtstr id, char *str) {
311 struct sb_entry *tmp; 326 struct sb_entry *tmp;
312 int i = 0; 327 int i = 0;
313 time_t now = time(NULL); 328 time_t now = time(NULL);
314 snprintf(tmpstr,TMPSTRSIZE,getformatstr(id),str); 329 snprintf(tmpstr,TMPSTRSIZE,getformatstr(id),str);
315 tmp = sb_add(sb_pub,tmpstr,now); 330 tmp = sb_add(sb_pub,tmpstr,now);
316 331
317 if( getintoption( CF_KEEPLOG ) && vchat_logfile )
318 fprintf( vchat_logfile, "%016llX0%s\n", (unsigned long long)now, tmpstr);
319
320 if ( (sb_pub->scroll == sb_pub->count) && 332 if ( (sb_pub->scroll == sb_pub->count) &&
321 ((filtertype == 0) || ( testfilter(tmp)))) { 333 ((filtertype == 0) || ( testfilter(tmp)))) {
322 i = writescr(channel, tmp); 334 i = writescr(channel, tmp);
323 wnoutrefresh(channel); 335 wnoutrefresh(channel);
324 } 336 }
325 consoleline(NULL); 337
338 if( querypartner && private )
339 topicline(NULL);
340 else
341 consoleline(NULL);
342
326 return i; 343 return i;
327} 344}
328 345
329int writepriv (unsigned char *str, int maybeep) { 346int writepriv (char *str, int maybeep) {
330 int i = 0; 347 int i = 0;
331 if (private) { 348 if (private) {
332 349
@@ -334,10 +351,6 @@ int writepriv (unsigned char *str, int maybeep) {
334 struct sb_entry *tmp; 351 struct sb_entry *tmp;
335 tmp = sb_add(sb_priv,str,now); 352 tmp = sb_add(sb_priv,str,now);
336 353
337 if( getintoption( CF_KEEPLOG ) && vchat_logfile ) {
338 fprintf( vchat_logfile, "%016llX1%s\n", (unsigned long long)now, str);
339 }
340
341 if ( !privwinhidden && (sb_priv->scroll == sb_priv->count) && 354 if ( !privwinhidden && (sb_priv->scroll == sb_priv->count) &&
342 ((filtertype == 0) || ( testfilter(tmp)))) { 355 ((filtertype == 0) || ( testfilter(tmp)))) {
343 i = writescr(private, tmp); 356 i = writescr(private, tmp);
@@ -350,7 +363,12 @@ int writepriv (unsigned char *str, int maybeep) {
350 resize(0); 363 resize(0);
351 } 364 }
352 wnoutrefresh(private); 365 wnoutrefresh(private);
353 topicline(NULL); 366
367 if( querypartner && private )
368 consoleline(NULL);
369 else
370 topicline(NULL);
371
354 } else 372 } else
355 i = writechan( str ); 373 i = writechan( str );
356 374
@@ -388,13 +406,13 @@ static int attributes[] = { A_ALTCHARSET, A_BOLD, 0, A_DIM, 0, 0, 0, 0, A_INVIS,
388 0, 0, 1, 0, 0 }; 406 0, 0, 1, 0, 0 };
389 407
390static void 408static void
391docolorize (unsigned char colour, ncurs_attr *attr, ncurs_attr orgattr) { 409docolorize (char colour, ncurs_attr *attr, ncurs_attr orgattr) {
392 if( colour== '0') { 410 if( colour== '0') {
393 *attr = orgattr; 411 *attr = orgattr;
394 } else if( ( colour > '0') && ( colour <= '9')) { 412 } else if( ( colour > '0') && ( colour <= '9')) {
395 BCOLR_SET( attr, colour - '0' ); 413 BCOLR_SET( attr, colour - '0' );
396 } else { 414 } else {
397 unsigned char upc = colour & ( 0x20 ^ 0xff ); /* colour AND NOT 0x20 */ 415 char upc = colour & ( 0x20 ^ 0xff ); /* colour AND NOT 0x20 */
398 attr_t newattr; 416 attr_t newattr;
399 if( ( upc >= 'A') && ( upc<='Z' ) && ( newattr = attributes[upc - 'A']) ) 417 if( ( upc >= 'A') && ( upc<='Z' ) && ( newattr = attributes[upc - 'A']) )
400 attr->attr = ( colour & 0x20 ) ? attr->attr | newattr : attr->attr & ~newattr; 418 attr->attr = ( colour & 0x20 ) ? attr->attr | newattr : attr->attr & ~newattr;
@@ -404,13 +422,13 @@ docolorize (unsigned char colour, ncurs_attr *attr, ncurs_attr orgattr) {
404/* draw arbitrary strings */ 422/* draw arbitrary strings */
405static int 423static int
406writescr ( WINDOW *win, struct sb_entry *entry ) { 424writescr ( WINDOW *win, struct sb_entry *entry ) {
407 unsigned char tmp [64]; 425 char tmp [64];
408 int charcount = 0; 426 int charcount = 0;
409 int i; 427 int i;
410 int textlen = strlen( entry->what ); 428 int textlen = strlen( entry->what );
411 int timelen = ((win == channel)||(win == private)) && usetime ? 429 int timelen = ((win == channel)||(win == private)) && usetime ?
412 (int)strftime(tmp,64,getformatstr(FS_TIME),localtime(&entry->when)) : 0; 430 (int)strftime(tmp,64,getformatstr(FS_TIME),localtime(&entry->when)) : 0;
413 unsigned char textbuffer[ textlen+timelen+1 ]; 431 char textbuffer[ textlen+timelen+1 ];
414 ncurs_attr attrbuffer[ textlen+timelen+1 ]; 432 ncurs_attr attrbuffer[ textlen+timelen+1 ];
415 ncurs_attr orgattr; 433 ncurs_attr orgattr;
416 434
@@ -446,9 +464,9 @@ writescr ( WINDOW *win, struct sb_entry *entry ) {
446 464
447 /* hilite */ 465 /* hilite */
448 if((win == channel)||(win == private)) { /* do not higlight bars */ 466 if((win == channel)||(win == private)) { /* do not higlight bars */
449 filt *flt = filterlist; 467 filt *flt = filterlist;
450 unsigned char *instr = textbuffer; 468 char *instr = textbuffer;
451 regmatch_t match; 469 regmatch_t match;
452 int j; 470 int j;
453 471
454 while( flt ) { 472 while( flt ) {
@@ -494,87 +512,6 @@ writescr ( WINDOW *win, struct sb_entry *entry ) {
494} 512}
495 513
496static void 514static void
497writelog_processentry ( FILE *file, struct sb_entry* entry )
498{
499 char *outtmp;
500 int outoff = 0;
501 if( usetime ) {
502 outtmp = tmpstr+64;
503 strftime(outtmp,64,getformatstr(FS_TIME),localtime(&entry->when));
504 while(*outtmp)
505 if( *outtmp > 1 )
506 tmpstr[outoff++] = *(outtmp++);
507 else
508 if( *(++outtmp))
509 outtmp++;
510 }
511
512 outtmp = entry->what;
513 while(*outtmp)
514 while(*outtmp && ( outoff < TMPSTRSIZE-1) ) {
515 if( *outtmp > 1 )
516 tmpstr[outoff++] = *(outtmp++);
517 else
518 if( *(++outtmp))
519 outtmp++;
520 tmpstr[outoff]=0; outoff = 0;
521 fputs( tmpstr, file );
522 }
523
524 fputc( '\n', file);
525}
526
527void
528writelog_i ( FILE *file)
529{
530 if( !private ) {
531 writelog( file);
532 } else {
533 struct sb_entry *now1= sb_pub->last, *prev1 = NULL, *tmp;
534 struct sb_entry *now2= sb_priv->last, *prev2 = NULL;
535 fputs( "Interleaved messages:\n\n", file);
536 while( now1 || now2 ) {
537 int process;
538 if( now1 && now2 ) {
539 process = ( now1->when < now2->when ) ? 1 : 2;
540 } else {
541 process = now1 ? 1 : 2;
542 }
543
544 if( process == 1 ) {
545 writelog_processentry( file, now1 );
546 tmp = now1; now1 = (struct sb_entry*)((unsigned long)now1->link ^ (unsigned long)prev1); prev1 = tmp;
547 } else {
548 writelog_processentry( file, now2 );
549 tmp = now2; now2 = (struct sb_entry*)((unsigned long)now2->link ^ (unsigned long)prev2); prev2 = tmp;
550 }
551 }
552 }
553}
554
555void
556writelog ( FILE *file )
557{
558 if( sb_pub->last ) {
559 struct sb_entry *now = sb_pub->last, *prev = NULL, *tmp;
560 fputs( "Public messages:\n\n", file);
561 while( now ) {
562 writelog_processentry( file, now );
563 tmp = now; now = (struct sb_entry*)((unsigned long)now->link ^ (unsigned long)prev); prev = tmp;
564 }
565 putc( '\n', file );
566 }
567 if( private && sb_priv->last ) {
568 struct sb_entry *now = sb_priv->last, *prev = NULL, *tmp;
569 fputs( "Private messages:\n\n", file);
570 while( now ) {
571 writelog_processentry( file, now );
572 tmp = now; now = (struct sb_entry*)((unsigned long)now->link ^ (unsigned long)prev); prev = tmp;
573 }
574 }
575}
576
577static void
578resize_output ( ) 515resize_output ( )
579{ 516{
580 int outputwidth = (outputwidth_desired + 7 > screensx) ? screensx - 7 : outputwidth_desired; 517 int outputwidth = (outputwidth_desired + 7 > screensx) ? screensx - 7 : outputwidth_desired;
@@ -587,7 +524,9 @@ resize_output ( )
587} 524}
588 525
589static void 526static void
590doscroll( int up ) { 527doscroll ( int up ) {
528 togglequery();
529 {
591 WINDOW *destwin = (sb_win && private) ? private : channel; 530 WINDOW *destwin = (sb_win && private) ? private : channel;
592 struct sb_data *sb = (sb_win && private) ? sb_priv : sb_pub; 531 struct sb_data *sb = (sb_win && private) ? sb_priv : sb_pub;
593 struct sb_entry *now = sb->entries, *prev = NULL, *tmp; 532 struct sb_entry *now = sb->entries, *prev = NULL, *tmp;
@@ -617,7 +556,14 @@ doscroll( int up ) {
617 556
618 drawwin(destwin, sb); 557 drawwin(destwin, sb);
619 wnoutrefresh(destwin); 558 wnoutrefresh(destwin);
620 if( sb_win && private ) topicline(NULL); else consoleline(NULL); 559
560 togglequery();
561
562 if( private && (destwin == channel) )
563 topicline( NULL);
564 else
565 consoleline( NULL);
566 }
621} 567}
622 568
623 569
@@ -634,7 +580,7 @@ scrolldown (void)
634} 580}
635 581
636void 582void
637scrollwin (vod) 583scrollwin (void)
638{ 584{
639 if (!sb_win && private && !privwinhidden) sb_win = 1; 585 if (!sb_win && private && !privwinhidden) sb_win = 1;
640 else sb_win = 0; 586 else sb_win = 0;
@@ -643,7 +589,7 @@ scrollwin (vod)
643} 589}
644 590
645void 591void
646growprivwin (vod) { 592growprivwin (void) {
647 if( private ) { 593 if( private ) {
648 if( privwinhidden) 594 if( privwinhidden)
649 privwinhidden = 0; 595 privwinhidden = 0;
@@ -653,7 +599,7 @@ growprivwin (vod) {
653 } 599 }
654} 600}
655 601
656void toggleprivwin (vod) { 602void toggleprivwin (void) {
657 if( outputshown ) { 603 if( outputshown ) {
658 outputshown = 0; 604 outputshown = 0;
659 resize(0); 605 resize(0);
@@ -674,7 +620,7 @@ void toggleprivwin (vod) {
674} 620}
675 621
676void 622void
677shrinkprivwin (vod) { 623shrinkprivwin (void) {
678 if( private && !privwinhidden ) { 624 if( private && !privwinhidden ) {
679 if( --privheight_desired < 1) privheight_desired = 1; 625 if( --privheight_desired < 1) privheight_desired = 1;
680 if( privheight_desired > screensy - 5) privheight_desired = screensy - 5; 626 if( privheight_desired > screensy - 5) privheight_desired = screensy - 5;
@@ -778,7 +724,7 @@ forceredraw (void)
778 if(console) wclear(console); 724 if(console) wclear(console);
779 if(topic) wclear(topic); 725 if(topic) wclear(topic);
780 if(private) wclear(private); 726 if(private) wclear(private);
781 if(channel) wclear( channel ); 727 if(channel) wclear(channel );
782 if(output) wclear(output); 728 if(output) wclear(output);
783 if(input) wclear(input); 729 if(input) wclear(input);
784 resize(0); 730 resize(0);
@@ -828,6 +774,8 @@ resize (int signal)
828 * Arrange windows on screen 774 * Arrange windows on screen
829 *****/ 775 *****/
830 776
777 togglequery();
778
831 /* console and input are always there and always 1 line tall */ 779 /* console and input are always there and always 1 line tall */
832 wresize(console,1,screensx); 780 wresize(console,1,screensx);
833 wresize(input,1,screensx); 781 wresize(input,1,screensx);
@@ -882,6 +830,8 @@ resize (int signal)
882 if(private && !privwinhidden ) 830 if(private && !privwinhidden )
883 wnoutrefresh(private); 831 wnoutrefresh(private);
884 832
833 togglequery();
834
885 /* Resize and draw our message window, render topic and 835 /* Resize and draw our message window, render topic and
886 console line */ 836 console line */
887 if(outputshown) resize_output(); 837 if(outputshown) resize_output();
@@ -1277,34 +1227,6 @@ initui (void)
1277 showout( ); 1227 showout( );
1278*/ 1228*/
1279 1229
1280 if( getintoption( CF_KEEPLOG ) ) {
1281 unsigned char *logfile = getstroption( CF_LOGFILE );
1282 if( logfile && *logfile ) {
1283 if( *logfile == '~' )
1284 logfile = tilde_expand( logfile );
1285 vchat_logfile = fopen( logfile, "r+" );
1286 if( vchat_logfile ) {
1287 time_t now;
1288 long long now_;
1289 char dst;
1290 int lenstr;
1291 while( !feof( vchat_logfile)) {
1292 if( (fscanf( vchat_logfile, "%016llX%c", (unsigned long long*)&now_, &dst)) &&
1293 ((dst == '0') || (dst == '1')))
1294 {
1295 now = (time_t)now_;
1296 if(fgets(tmpstr, TMPSTRSIZE, vchat_logfile)) {
1297 lenstr = strlen( tmpstr );
1298 tmpstr[lenstr-1] = '\0';
1299 sb_add( dst == '0' ? sb_pub : sb_priv, tmpstr, now);
1300 }
1301 } else
1302 while( !feof( vchat_logfile) && ( fgetc( vchat_logfile ) != '\n'));
1303 }
1304 }
1305 }
1306 }
1307
1308 resize(0); 1230 resize(0);
1309} 1231}
1310 1232
@@ -1314,7 +1236,7 @@ initui (void)
1314 Enable, when needed 1236 Enable, when needed
1315 1237
1316static void 1238static void
1317writecolorized( WINDOW *win, unsigned char *string) { 1239writecolorized( WINDOW *win, char *string) {
1318 ncurs_attr old_att, new_att; 1240 ncurs_attr old_att, new_att;
1319 int i; 1241 int i;
1320 1242
@@ -1333,12 +1255,14 @@ writecolorized( WINDOW *win, unsigned char *string) {
1333 1255
1334/* render consoleline to screen */ 1256/* render consoleline to screen */
1335void 1257void
1336consoleline (unsigned char *message) 1258consoleline (char *message)
1337{ 1259{
1338 /* clear console, set string (or default), redraw display */ 1260 /* clear console, set string (or default), redraw display */
1339 int i; 1261 int i;
1340 ncurs_attr old_att, new_att; 1262 ncurs_attr old_att, new_att;
1341 1263
1264 togglequery();
1265
1342 memset( &new_att, 0, sizeof(new_att)); 1266 memset( &new_att, 0, sizeof(new_att));
1343 BCOLR_SET( (&new_att), 8 ); 1267 BCOLR_SET( (&new_att), 8 );
1344 wmove (console, 0, 0); 1268 wmove (console, 0, 0);
@@ -1370,13 +1294,15 @@ consoleline (unsigned char *message)
1370 redrawwin(output); 1294 redrawwin(output);
1371 wnoutrefresh(output); 1295 wnoutrefresh(output);
1372 } 1296 }
1297
1298 togglequery();
1373 wnoutrefresh(input); 1299 wnoutrefresh(input);
1374 doupdate(); 1300 doupdate();
1375} 1301}
1376 1302
1377/* render topicline to screen */ 1303/* render topicline to screen */
1378void 1304void
1379topicline (unsigned char *message) 1305topicline (char *message)
1380{ 1306{
1381 int i; 1307 int i;
1382 ncurs_attr old_att, new_att; 1308 ncurs_attr old_att, new_att;
@@ -1384,6 +1310,8 @@ topicline (unsigned char *message)
1384 if( !topic ) 1310 if( !topic )
1385 return; 1311 return;
1386 1312
1313 togglequery();
1314
1387 memset( &new_att, 0, sizeof(new_att)); 1315 memset( &new_att, 0, sizeof(new_att));
1388 BCOLR_SET( (&new_att), 8 ); 1316 BCOLR_SET( (&new_att), 8 );
1389 1317
@@ -1409,6 +1337,8 @@ topicline (unsigned char *message)
1409 redrawwin(output); 1337 redrawwin(output);
1410 wnoutrefresh(output); 1338 wnoutrefresh(output);
1411 } 1339 }
1340
1341 togglequery();
1412 wnoutrefresh(input); 1342 wnoutrefresh(input);
1413 doupdate(); 1343 doupdate();
1414} 1344}
@@ -1421,8 +1351,6 @@ exitui (void)
1421 rl_callback_handler_remove (); 1351 rl_callback_handler_remove ();
1422 endwin (); 1352 endwin ();
1423 ui_init = 0; 1353 ui_init = 0;
1424 if( vchat_logfile )
1425 fclose( vchat_logfile );
1426 } 1354 }
1427} 1355}
1428 1356
@@ -1465,7 +1393,7 @@ static void
1465vcnredraw (void) 1393vcnredraw (void)
1466{ 1394{
1467 int i; 1395 int i;
1468 unsigned char *passbof="-*-*-*-*-*-*-"; 1396 char *passbof="-*-*-*-*-*-*-";
1469 1397
1470 /* wipe input line and reset cursor */ 1398 /* wipe input line and reset cursor */
1471 wmove(input, 0, 0); 1399 wmove(input, 0, 0);
@@ -1486,7 +1414,7 @@ int
1486passprompt (char *buf, int size, int rwflag, void *userdata) 1414passprompt (char *buf, int size, int rwflag, void *userdata)
1487{ 1415{
1488 int i; 1416 int i;
1489 unsigned char *passphrase = NULL; 1417 char *passphrase = NULL;
1490 1418
1491 /* use special non-revealing redraw function */ 1419 /* use special non-revealing redraw function */
1492 /* FIXME: passphrase isn't protected against e.g. swapping */ 1420 /* FIXME: passphrase isn't protected against e.g. swapping */
@@ -1619,7 +1547,7 @@ clearfilters( char colour ) {
1619 1547
1620/* removes filter pattern */ 1548/* removes filter pattern */
1621void 1549void
1622removefilter( unsigned char *tail ) { 1550removefilter( char *tail ) {
1623 int rmv = 0, val; 1551 int rmv = 0, val;
1624 char* end; 1552 char* end;
1625 1553
@@ -1627,8 +1555,8 @@ removefilter( unsigned char *tail ) {
1627 1555
1628 rmv = removefromfilterlist( test_simplerm, (void *)tail, 0 ); 1556 rmv = removefromfilterlist( test_simplerm, (void *)tail, 0 );
1629 if(!rmv) { 1557 if(!rmv) {
1630 val = strtol((char*)tail, &end, 10); 1558 val = strtol(tail, &end, 10);
1631 if( (tail != (unsigned char*)end) && (!*end) ) 1559 if( (tail != end) && (!*end) )
1632 rmv = removefromfilterlist( test_numericrm, (void *)val, 0); 1560 rmv = removefromfilterlist( test_numericrm, (void *)val, 0);
1633 } 1561 }
1634 1562
@@ -1646,7 +1574,7 @@ static unsigned int uniqueidpool = 1;
1646 1574
1647/* returns unique id for filter pattern or 0 for failure */ 1575/* returns unique id for filter pattern or 0 for failure */
1648unsigned int 1576unsigned int
1649addfilter( char colour, unsigned char *regex ) { 1577addfilter( char colour, char *regex ) {
1650 filt *newflt = malloc( sizeof(filt)), **flt = &filterlist; 1578 filt *newflt = malloc( sizeof(filt)), **flt = &filterlist;
1651 1579
1652 if( !newflt ) return 0; 1580 if( !newflt ) return 0;
@@ -1753,3 +1681,31 @@ listfilters( void ) {
1753 } 1681 }
1754 showout(); 1682 showout();
1755} 1683}
1684
1685void
1686handlequery( char *tail ) {
1687 if( *tail ) {
1688 // ".m %s " -> string + 4
1689 if( querypartner && private ) {
1690 WINDOW *tmp= private; private = channel; channel = tmp;
1691 }
1692 querypartner = (char *)realloc( querypartner, 5 + strlen( tail ));
1693 if( querypartner ) {
1694 snprintf( querypartner, 5 + strlen( tail ), ".m %s ", tail );
1695 if( private ) {
1696 WINDOW *tmp= private; private = channel; channel = tmp;
1697 }
1698 }
1699 resize( 0 );
1700 } else {
1701 // QUERY ends
1702 if( querypartner ) {
1703 free( querypartner );
1704 querypartner = NULL;
1705 if( private ) {
1706 WINDOW *tmp= private; private = channel; channel = tmp;
1707 }
1708 resize( 0 );
1709 }
1710 }
1711}