From 30d47c0f9de40e4e78dd481b58387fbf2fb66e91 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 10 Apr 2000 01:47:23 +0000 Subject: [PATCH] * More paginator changes. Shuffled code around, added pagination to a bunch of other functions, and replaced the old, cumbersome pagination with the new, easy, API-based one in everything except message output. --- citadel/ChangeLog | 6 +++++ citadel/commands.c | 21 +++++++++++++++ citadel/commands.h | 2 ++ citadel/rooms.c | 62 ++++++++++++++++----------------------------- citadel/routines.c | 19 -------------- citadel/routines.h | 1 - citadel/routines2.c | 14 +++++----- 7 files changed, 58 insertions(+), 67 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 9fee335d8..99e4d7842 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,9 @@ $Log$ + Revision 570.18 2000/04/10 01:47:22 ajc + * More paginator changes. Shuffled code around, added pagination to a bunch + of other functions, and replaced the old, cumbersome pagination with the + new, easy, API-based one in everything except message output. + Revision 570.17 2000/04/09 17:51:18 ajc * Added pprintf() (paginated version of printf) to the client-side API. Now any client side function can be paginated simply by changing all of the @@ -1841,3 +1846,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/commands.c b/citadel/commands.c index 9e6719544..844a2e9b2 100644 --- a/citadel/commands.c +++ b/citadel/commands.c @@ -83,6 +83,27 @@ int enable_color = 0; /* nonzero for ANSI color */ +/* + * Check to see if we need to pause at the end of a screen. + * If we do, we have to disable server keepalives during the pause because + * we are probably in the middle of a server operation and the NOOP command + * would confuse everything. + */ +int checkpagin(int lp, int pagin, int height) +{ + if (!pagin) return(0); + if (lp>=(height-1)) { + set_keepalives(KA_NO); + hit_any_key(); + set_keepalives(KA_YES); + return(0); + } + return(lp); + } + + + + /* * pprintf() ... paginated version of printf() */ diff --git a/citadel/commands.h b/citadel/commands.h index 6ade37ce7..968e1980b 100644 --- a/citadel/commands.h +++ b/citadel/commands.h @@ -50,9 +50,11 @@ void keyopt(char *); char keymenu(char *menuprompt, char *menustring); void async_ka_start(void); void async_ka_end(void); +int checkpagin(int lp, int pagin, int height); void pprintf(const char *format, ...); + extern int num_urls; extern char urls[MAXURLS][256]; extern char rc_url_cmd[256]; diff --git a/citadel/rooms.c b/citadel/rooms.c index dd1749689..fcc65c3ef 100644 --- a/citadel/rooms.c +++ b/citadel/rooms.c @@ -41,7 +41,6 @@ void progress(long int curr, long int cmax); int pattern(char *search, char *patn); int file_checksum(char *filename); int nukedir(char *dirname); -int checkpagin(int lp, int pagin, int height); extern unsigned room_flags; extern char room_name[]; @@ -64,8 +63,6 @@ extern char ugname[]; extern char floorlist[128][256]; -int knlinecount; - void load_floorlist(void) { int a; @@ -105,12 +102,7 @@ void room_tree_list(struct roomlisting *rp) { if ((c + strlen(rmname) + 4) > screenwidth) { /* line break, check the paginator */ - printf("\n"); - knlinecount = knlinecount + 1; - knlinecount = checkpagin(knlinecount, - ((userflags & US_PAGINATOR) ? 1 : 0), - screenheight); - + pprintf("\n"); c = 1; } if (f & QR_MAILBOX) { @@ -122,11 +114,11 @@ void room_tree_list(struct roomlisting *rp) { else { color(DIM_WHITE); } - printf("%s",rmname); - if ((f & QR_DIRECTORY) && (f & QR_NETWORK)) printf("} "); - else if (f & QR_DIRECTORY) printf("] "); - else if (f & QR_NETWORK) printf(") "); - else printf("> "); + pprintf("%s",rmname); + if ((f & QR_DIRECTORY) && (f & QR_NETWORK)) pprintf("} "); + else if (f & QR_DIRECTORY) pprintf("] "); + else if (f & QR_NETWORK) pprintf(") "); + else pprintf("> "); c = c + strlen(rmname) + 3; } @@ -220,10 +212,10 @@ void list_other_floors(void) { c = 1; for (a=0; a<128; ++a) if ((strlen(floorlist[a])>0)&&(a!=curr_floor)) { if ((c + strlen(floorlist[a]) + 4) > screenwidth) { - printf("\n"); + pprintf("\n"); c = 1; } - printf("%s: ",floorlist[a]); + pprintf("%s: ",floorlist[a]); c = c + strlen(floorlist[a]) + 3; } } @@ -239,51 +231,41 @@ void knrooms(int kn_floor_mode) int a; load_floorlist(); - knlinecount = 0; if (kn_floor_mode == 0) { color(BRIGHT_CYAN); - printf("\n Rooms with unread messages:\n"); - knlinecount = knlinecount + 2; + pprintf("\n Rooms with unread messages:\n"); listrms("LKRN"); color(BRIGHT_CYAN); - printf("\n\n No unseen messages in:\n"); - knlinecount = knlinecount + 3; + pprintf("\n\n No unseen messages in:\n"); listrms("LKRO"); - printf("\n"); - knlinecount = knlinecount + 1; + pprintf("\n"); } if (kn_floor_mode == 1) { color(BRIGHT_CYAN); - printf("\n Rooms with unread messages on %s:\n", + pprintf("\n Rooms with unread messages on %s:\n", floorlist[(int)curr_floor]); - knlinecount = knlinecount + 2; - sprintf(buf,"LKRN %d",curr_floor); + sprintf(buf,"LKRN %d", curr_floor); listrms(buf); color(BRIGHT_CYAN); - printf("\n\n Rooms with no new messages on %s:\n", + pprintf("\n\n Rooms with no new messages on %s:\n", floorlist[(int)curr_floor]); - knlinecount = knlinecount + 3; sprintf(buf,"LKRO %d",curr_floor); listrms(buf); color(BRIGHT_CYAN); - printf("\n\n Other floors:\n"); - knlinecount = knlinecount + 3; + pprintf("\n\n Other floors:\n"); list_other_floors(); - printf("\n"); - knlinecount = knlinecount + 1; + pprintf("\n"); } if (kn_floor_mode == 2) { for (a=0; a<128; ++a) if (floorlist[a][0]!=0) { color(BRIGHT_CYAN); - printf("\n Rooms on %s:\n",floorlist[a]); - knlinecount = knlinecount + 2; + pprintf("\n Rooms on %s:\n",floorlist[a]); sprintf(buf,"LKRA %d",a); listrms(buf); - printf("\n"); - knlinecount = knlinecount + 1; + pprintf("\n"); } } @@ -294,9 +276,9 @@ void knrooms(int kn_floor_mode) void listzrooms(void) { /* list public forgotten rooms */ color(BRIGHT_CYAN); - printf("\n Forgotten public rooms:\n"); + pprintf("\n Forgotten public rooms:\n"); listrms("LZRM"); - printf("\n"); + pprintf("\n"); color(DIM_WHITE); IFNEXPERT hit_any_key(); } @@ -912,13 +894,13 @@ void whoknows(void) { serv_puts("WHOK"); serv_gets(buf); if (buf[0]!='1') { - printf("%s\n",&buf[5]); + pprintf("%s\n",&buf[5]); return; } sigcaught = 0; sttybbs(SB_YES_INTR); while (serv_gets(buf), strncmp(buf,"000",3)) { - if (sigcaught==0) printf("%s\n",buf); + if (sigcaught==0) pprintf("%s\n",buf); } sttybbs(SB_NO_INTR); } diff --git a/citadel/routines.c b/citadel/routines.c index d93fc04a7..e7c08a9a0 100644 --- a/citadel/routines.c +++ b/citadel/routines.c @@ -295,25 +295,6 @@ void interr(int errnum) /* display internal error as defined in errmsgs */ -/* - * Check to see if we need to pause at the end of a screen. - * If we do, we have to disable server keepalives during the pause because - * we are probably in the middle of a server operation and the NOOP command - * would confuse everything. - */ -int checkpagin(int lp, int pagin, int height) -{ - if (!pagin) return(0); - if (lp>=(height-1)) { - set_keepalives(KA_NO); - hit_any_key(); - set_keepalives(KA_YES); - return(0); - } - return(lp); - } - - void strproc(char *string) { int a; diff --git a/citadel/routines.h b/citadel/routines.h index d176a232f..8e37f8976 100644 --- a/citadel/routines.h +++ b/citadel/routines.h @@ -2,7 +2,6 @@ void edituser(void); void interr(int errnum); int struncmp(char *lstr, char *rstr, int len); -int checkpagin(int lp, int pagin, int height); int pattern(char *search, char *patn); void enter_config(int mode); void locate_host(char *hbuf); diff --git a/citadel/routines2.c b/citadel/routines2.c index d4e07c929..5af1700f5 100644 --- a/citadel/routines2.c +++ b/citadel/routines2.c @@ -575,18 +575,18 @@ void list_bio(void) serv_puts("LBIO"); serv_gets(buf); if (buf[0] != '1') { - printf("%s\n", &buf[4]); + pprintf("%s\n", &buf[4]); return; } while (serv_gets(buf), strcmp(buf, "000")) { if ((pos + strlen(buf) + 5) > screenwidth) { - printf("\n"); + pprintf("\n"); pos = 1; } - printf("%s, ", buf); + pprintf("%s, ", buf); pos = pos + strlen(buf) + 2; } - printf("%c%c \n\n", 8, 8); + pprintf("%c%c \n\n", 8, 8); } @@ -600,7 +600,7 @@ void read_bio(void) do { newprompt("Read bio for who ('?' for list) : ", who, 25); - printf("\n"); + pprintf("\n"); if (!strcmp(who, "?")) list_bio(); } while (!strcmp(who, "?")); @@ -608,11 +608,11 @@ void read_bio(void) serv_puts(buf); serv_gets(buf); if (buf[0] != '1') { - printf("%s\n", &buf[4]); + pprintf("%s\n", &buf[4]); return; } while (serv_gets(buf), strcmp(buf, "000")) { - printf("%s\n", buf); + pprintf("%s\n", buf); } } -- 2.39.2