lines it has written, issuing the paginator prompt when it knows it needs to. scr_getc() resets the
line count to zero. This completely eliminates the need for individual functions to keep track of
their line count, simplifying a lot of code throughout the system. Why didn't I do it this way 20
years ago? TODO: use the server issued paginator prompt instead of a hardcoded string.
void strprompt(char *prompt, char *str, int len);
int boolprompt(char *prompt, int prev_val);
int intprompt(char *prompt, int ival, int imin, int imax);
-int fmout(int width, FILE *fpin, char *text, FILE *fpout, char pagin,
- int height, int starting_lp, int subst);
+int fmout(int width, FILE *fpin, char *text, FILE *fpout, int subst);
int getcmd(CtdlIPC *ipc, char *argbuf);
void display_help(CtdlIPC *ipc, char *name);
void color(int colornum);
/*
* now clean up various things
*/
- screen_delete();
-
unlink(temp);
unlink(temp2);
nukedir(tempdir);
return;
}
if (text) {
- fmout(screenwidth, NULL, text, NULL,
- ((userflags & US_PAGINATOR) ? 1 : 0),
- screenheight, 1, 1);
+ fmout(screenwidth, NULL, text, NULL, 1);
free(text);
}
}
r = CtdlIPCUserListing(ipc, patn, &listing, buf);
if (r / 100 != 1) {
- pprintf("%s\n", buf);
+ scr_printf("%s\n", buf);
return;
}
- pprintf(" User Name Num L Last Visit Logins Messages\n");
- pprintf("------------------------- ----- - ---------- ------ --------\n");
+ scr_printf(" User Name Num L Last Visit Logins Messages\n");
+ scr_printf("------------------------- ----- - ---------- ------ --------\n");
if (listing != NULL) while (!IsEmptyStr(listing)) {
extract_token(buf, listing, 0, '\n', sizeof buf);
remove_token(listing, 0, '\n');
if (sigcaught == 0) {
extract_token(fl, buf, 0, '|', sizeof fl);
if (pattern(fl, patn) >= 0) {
- pprintf("%-25s ", fl);
- pprintf("%5ld %d ", extract_long(buf, 2),
+ scr_printf("%-25s ", fl);
+ scr_printf("%5ld %d ", extract_long(buf, 2),
extract_int(buf, 1));
lc = extract_long(buf, 3);
localtime_r(&lc, &tmbuf);
- pprintf("%02d/%02d/%04d ",
+ scr_printf("%02d/%02d/%04d ",
(tmbuf.tm_mon + 1),
tmbuf.tm_mday,
(tmbuf.tm_year + 1900));
- pprintf("%6ld %8ld\n", extract_long(buf, 4), extract_long(buf, 5));
+ scr_printf("%6ld %8ld\n", extract_long(buf, 4), extract_long(buf, 5));
}
}
}
free(listing);
- pprintf("\n");
+ scr_printf("\n");
}
/* get misc user info */
r = CtdlIPCGetBio(ipc, fullname, &resp, buf);
if (r / 100 != 1) {
- pprintf("%s\n", buf);
+ scr_printf("%s\n", buf);
return;
}
extract_token(_fullname, buf, 1, '|', sizeof fullname);
if (!longlist) {
color(BRIGHT_WHITE);
- pprintf(" User Name Room ");
- if (screenwidth >= 80) pprintf(" Idle From host");
- pprintf("\n");
+ scr_printf(" User Name Room ");
+ if (screenwidth >= 80) scr_printf(" Idle From host");
+ scr_printf("\n");
color(DIM_WHITE);
- pprintf(" ------------------------- --------------------");
- if (screenwidth >= 80) pprintf(" ---- ------------------------");
- pprintf("\n");
+ scr_printf(" ------------------------- --------------------");
+ if (screenwidth >= 80) scr_printf(" ---- ------------------------");
+ scr_printf("\n");
}
r = CtdlIPCOnlineUsers(ipc, &listing, &timenow, buf);
listing = SortOnlineUsers(listing);
extract_token(actual_room, buf, 9, '|', sizeof actual_room);
extract_token(actual_host, buf, 10, '|', sizeof actual_host);
- pprintf(" Flags: %s\n", flags);
- pprintf("Session: %d\n", extract_int(buf, 0));
- pprintf(" Name: %s\n", username);
- pprintf("In room: %s\n", roomname);
- pprintf(" Host: %s\n", fromhost);
- pprintf(" Client: %s\n", clientsoft);
- pprintf(" Idle: %ld:%02ld:%02ld\n",
+ scr_printf(" Flags: %s\n", flags);
+ scr_printf("Session: %d\n", extract_int(buf, 0));
+ scr_printf(" Name: %s\n", username);
+ scr_printf("In room: %s\n", roomname);
+ scr_printf(" Host: %s\n", fromhost);
+ scr_printf(" Client: %s\n", clientsoft);
+ scr_printf(" Idle: %ld:%02ld:%02ld\n",
(long) idlehours,
(long) idlemins,
(long) idlesecs);
if ( (!IsEmptyStr(actual_user)&&
!IsEmptyStr(actual_room)&&
!IsEmptyStr(actual_host))) {
- pprintf("(really ");
- if (!IsEmptyStr(actual_user)) pprintf("<%s> ", actual_user);
- if (!IsEmptyStr(actual_room)) pprintf("in <%s> ", actual_room);
- if (!IsEmptyStr(actual_host)) pprintf("from <%s> ", actual_host);
- pprintf(")\n");
+ scr_printf("(really ");
+ if (!IsEmptyStr(actual_user)) scr_printf("<%s> ", actual_user);
+ if (!IsEmptyStr(actual_room)) scr_printf("in <%s> ", actual_room);
+ if (!IsEmptyStr(actual_host)) scr_printf("from <%s> ", actual_host);
+ scr_printf(")\n");
}
- pprintf("\n");
+ scr_printf("\n");
} else {
if (isidle == 0) {
if (extract_int(buf, 0) == last_session) {
- pprintf(" ");
+ scr_printf(" ");
}
else {
color(BRIGHT_MAGENTA);
- pprintf("%-3s", flags);
+ scr_printf("%-3s", flags);
}
last_session = extract_int(buf, 0);
color(BRIGHT_CYAN);
- pprintf("%-25s ", username);
+ scr_printf("%-25s ", username);
color(BRIGHT_MAGENTA);
roomname[20] = 0;
- pprintf("%-20s", roomname);
+ scr_printf("%-20s", roomname);
if (screenwidth >= 80) {
- pprintf(" ");
+ scr_printf(" ");
if (idletime > rc_idle_threshold) {
/* over 1000d, must be gone fishing */
if (idlehours > 23999) {
- pprintf("fish");
+ scr_printf("fish");
/* over 10 days */
} else if (idlehours > 239) {
- pprintf("%3ldd", idlehours / 24);
+ scr_printf("%3ldd", idlehours / 24);
/* over 10 hours */
} else if (idlehours > 9) {
- pprintf("%1ldd%02ld",
+ scr_printf("%1ldd%02ld",
idlehours / 24,
idlehours % 24);
/* less than 10 hours */
}
else {
- pprintf("%1ld:%02ld", idlehours, idlemins);
+ scr_printf("%1ld:%02ld", idlehours, idlemins);
}
}
else {
- pprintf(" ");
+ scr_printf(" ");
}
- pprintf(" ");
+ scr_printf(" ");
color(BRIGHT_CYAN);
fromhost[24] = '\0';
- pprintf("%-24s", fromhost);
+ scr_printf("%-24s", fromhost);
}
- pprintf("\n");
+ scr_printf("\n");
color(DIM_WHITE);
}
}
eCrash_Init(¶ms);
#endif
- setIPCDeathHook(screen_delete);
setIPCErrorPrintf(scr_printf);
setCryptoStatusHook(statusHook);
scr_printf("Attaching to server...\n");
ipc = CtdlIPC_new(argc, argv, hostbuf, portbuf);
if (!ipc) {
- screen_delete();
error_printf("Can't connect: %s\n", strerror(errno));
logoff(NULL, 3);
}
}
CtdlIPCLogout(ipc);
if ((mcmd == 29) || (mcmd == 15)) {
- screen_delete();
stty_ctdl(SB_RESTORE);
formout(ipc, "goodbye");
logoff(ipc, 0);
* This file contains functions which implement parts of the
* text-mode user interface.
*
- * Copyright (c) 1987-2009 by the citadel.org team
+ * Copyright (c) 1987-2010 by the citadel.org team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "sysdep.h"
char *gl_string;
int next_lazy_cmd = 5;
-int lines_printed = 0; /* line count for paginator */
extern int screenwidth, screenheight;
extern int termn8;
extern CtdlIPC *ipc_for_signal_handlers; /* KLUDGE cover your eyes */
-/*
- * Check to see if we need to pause at the end of a screen.
- * If we do, we have to switch to half 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, unsigned int pagin, unsigned int height)
-{
- int thekey;
-
- if (sigcaught) return(lp);
- thekey = was_a_key_pressed();
- if (thekey == 'q' || thekey == 'Q' || thekey == 's' || thekey == 'S')
- thekey = STOP_KEY;
- if (thekey == 'n' || thekey == 'N')
- thekey = NEXT_KEY;
- if ( (thekey == NEXT_KEY) || (thekey == STOP_KEY)) sigcaught = thekey;
- if (sigcaught) return(lp);
-
- if (!pagin) return(0);
- if (lp>=(height-1)) {
- set_keepalives(KA_HALF);
- hit_any_key(ipc_for_signal_handlers); /* Cheating -IO */
- set_keepalives(KA_YES);
- return(0);
- }
- return(lp);
-}
-
-
-
-
-/*
- * pprintf() ... paginated version of printf()
- */
-void pprintf(const char *format, ...) {
- va_list arg_ptr;
- static char buf[4096]; /* static for performance, change if needed */
- int i;
-
- /* If sigcaught is nonzero, a keypress has interrupted this and we
- * should just drain output.
- */
- if (sigcaught) return;
-
- /* Otherwise, start spewing... */
- va_start(arg_ptr, format);
- vsnprintf(buf, sizeof(buf), format, arg_ptr);
- va_end(arg_ptr);
-
- for (i=0; !IsEmptyStr(&buf[i]); ++i) {
- scr_putc(buf[i]);
- if (buf[i]==10) {
- ++lines_printed;
- lines_printed = checkpagin(lines_printed,
- (userflags & US_PAGINATOR),
- screenheight);
- }
- }
-}
-
-
-
/*
* print_instant() - print instant messages if there are any
*/
}
/* fall back to built-in instant message display */
scr_printf("\n");
- lines_printed++;
/* Header derived from flags */
if (flags & 2)
scr_printf(" @%s", node);
scr_printf(":\n");
- lines_printed++;
- fmout(screenwidth, NULL, listing, NULL, 1, screenheight, -1, 0);
+ fmout(screenwidth, NULL, listing, NULL, 0);
free(listing);
- lines_printed = 0;
}
scr_printf("\n---\n");
color(BRIGHT_WHITE);
time_t start_time;
scr_flush();
- lines_printed = 0;
time(&start_time);
do {
* necessary and then waits again.
*/
do {
- scr_set_windowsize(ipc_for_signal_handlers);
do_keepalive();
- scr_set_windowsize(ipc_for_signal_handlers);
FD_ZERO(&rfds);
FD_SET(0, &rfds);
if (a == 13) {
a = 10;
}
-/* not so fast there dude, we have to handle UTF-8 and ISO-8859-1...
- if (a > 126) {
- a = 0;
- }
- if (((a != 23) && (a != 4) && (a != 10) && (a != 8) && (a != NEXT_KEY) && (a != STOP_KEY))
- && ((a < 32) || (a > 126))) {
- a = 0;
- }
- */
} while (a == 0);
return (a);
}
}
if (ch == '?') {
- pprintf("\rOne of ... \n");
+ scr_printf("\rOne of ... \n");
for (cptr = cmdlist; cptr != NULL; cptr = cptr->next) {
if (cmdmatch(cmdbuf, cptr, cmdpos)) {
for (a = 0; a < 5; ++a) {
keyopt(cmd_expand(cptr->c_keys[a], 1));
- pprintf(" ");
+ scr_printf(" ");
}
- pprintf("\n");
+ scr_printf("\n");
}
}
sigcaught = 0;
- pprintf("\n%s%c ", room_name, room_prompt(room_flags));
+ scr_printf("\n%s%c ", room_name, room_prompt(room_flags));
got = 0;
for (cptr = cmdlist; cptr != NULL; cptr = cptr->next) {
if ((got == 0) && (cmdmatch(cmdbuf, cptr, cmdpos))) {
for (a = 0; a < cmdpos; ++a) {
- pprintf("%s ",
+ scr_printf("%s ",
cmd_expand(cptr->c_keys[a], 0));
}
got = 1;
FILE *fpin, /* file to read from, or NULL to format given text */
char *text, /* text to be formatted (when fpin is NULL */
FILE *fpout, /* file to write to, or NULL to write to screen */
- char pagin, /* nonzero if we should use the paginator */
- int height, /* screen height to use */
- int starting_lp,/* starting value for lines_printed, -1 for global */
int subst) /* nonzero if we should use hypertext mode */
{
char *buffer = NULL; /* The current message */
}
e = buffer;
- if (starting_lp >= 0)
- lines_printed = starting_lp;
-
/* Run the message body */
while (*e) {
/* Catch characters that shouldn't be there at all */
fprintf(fpout, "\n");
} else {
scr_printf("\n");
- ++lines_printed;
- lines_printed = checkpagin(lines_printed, pagin, height);
}
column = 0;
} else if (old != ' ') {/* Don't print two spaces */
fprintf(fpout, "\n");
} else {
scr_printf("\n");
- ++lines_printed;
- lines_printed = checkpagin(lines_printed, pagin, height);
}
column = 0;
} else if (!(column == 0 && old == ' ')) {
fprintf(fpout, "\n");
} else {
scr_printf("\n");
- ++lines_printed;
- lines_printed = checkpagin(lines_printed, pagin, height);
}
column = 0;
}
fprintf(fpout, "\n");
} else {
scr_printf("\n");
- ++lines_printed;
- lines_printed = checkpagin(lines_printed, pagin, height);
}
return sigcaught;
color(DIM_WHITE);
for (i=0; !IsEmptyStr(&buf[i]); ++i) {
if (buf[i]=='<') {
- pprintf("%c", buf[i]);
+ scr_printf("%c", buf[i]);
color(BRIGHT_MAGENTA);
} else {
if (buf[i]=='>'&& buf[i+1] != '>') {
color(DIM_WHITE);
}
- pprintf("%c", buf[i]);
+ scr_printf("%c", buf[i]);
}
}
color(DIM_WHITE);
r = CtdlIPCGetSingleMessage(ipc, num, (pagin == READ_HEADER ? 1 : 0), 4, &message, buf);
if (r / 100 != 1) {
scr_printf("*** msg #%ld: %d %s\n", num, r, buf);
- ++lines_printed;
- lines_printed = checkpagin(lines_printed, pagin, screenheight);
stty_ctdl(0);
free(message->text);
free_parts(message->attachments);
fprintf(dest, "\n ");
} else {
scr_printf("\n");
- ++lines_printed;
- lines_printed = checkpagin(lines_printed, pagin, screenheight);
if (pagin != 2)
scr_printf(" ");
}
/* View headers only */
if (pagin == 2) {
- pprintf("nhdr=%s\nfrom=%s\ntype=%d\nmsgn=%s\n",
+ scr_printf("nhdr=%s\nfrom=%s\ntype=%d\nmsgn=%s\n",
message->nhdr ? "yes" : "no",
message->author, message->type,
message->msgid);
if (!IsEmptyStr(message->subject)) {
- pprintf("subj=%s\n", message->subject);
+ scr_printf("subj=%s\n", message->subject);
}
if (!IsEmptyStr(message->email)) {
- pprintf("rfca=%s\n", message->email);
+ scr_printf("rfca=%s\n", message->email);
}
- pprintf("hnod=%s\nroom=%s\nnode=%s\ntime=%s",
+ scr_printf("hnod=%s\nroom=%s\nnode=%s\ntime=%s",
message->hnod, message->room,
message->node,
asctime(localtime(&message->time)));
if (!IsEmptyStr(message->recipient)) {
- pprintf("rcpt=%s\n", message->recipient);
+ scr_printf("rcpt=%s\n", message->recipient);
}
if (message->attachments) {
struct parts *ptr;
for (ptr = message->attachments; ptr; ptr = ptr->next) {
- pprintf("part=%s|%s|%s|%s|%s|%ld\n",
+ scr_printf("part=%s|%s|%s|%s|%s|%ld\n",
ptr->name, ptr->filename, ptr->number,
ptr->disposition, ptr->mimetype,
ptr->length);
}
}
- pprintf("\n");
+ scr_printf("\n");
stty_ctdl(0);
free(message->text);
free_parts(message->attachments);
message->author, message->node);
}
- if (!dest) {
- ++lines_printed;
- lines_printed = checkpagin(lines_printed, pagin, screenheight);
- }
-
-
if (message->msgid != NULL) {
safestrncpy(reply_inreplyto, message->msgid, sizeof reply_inreplyto);
}
scr_printf("Subject: ");
color(BRIGHT_CYAN);
scr_printf("%s\n", message->subject);
- ++lines_printed;
- lines_printed = checkpagin(lines_printed,
- pagin, screenheight);
}
}
}
* Here we go
*/
if (format_type == 0) {
- fr = fmout(screenwidth, NULL, message->text, dest,
- ((pagin == 1) ? 1 : 0), screenheight, (-1), 1);
+ fr = fmout(screenwidth, NULL, message->text, dest, 1);
} else {
/* renderer for text/plain */
fprintf(dest, "%s\n", lineptr);
} else {
scr_printf("%s\n", lineptr);
- lines_printed = lines_printed + 1 +
- (linelen / screenwidth);
- lines_printed =
- checkpagin(lines_printed, pagin,
- screenheight);
}
}
if (lineptr[0] == 0) final_line_is_blank = 1;
}
else {
scr_printf("\n");
- ++lines_printed;
- lines_printed = checkpagin(lines_printed, pagin, screenheight);
fr = sigcaught;
}
}
&& (!IsEmptyStr(ptr->mimetype))
) {
color(DIM_WHITE);
- pprintf("Part ");
+ scr_printf("Part ");
color(BRIGHT_MAGENTA);
- pprintf("%s", ptr->number);
+ scr_printf("%s", ptr->number);
color(DIM_WHITE);
- pprintf(": ");
+ scr_printf(": ");
color(BRIGHT_CYAN);
- pprintf("%s", ptr->filename);
+ scr_printf("%s", ptr->filename);
color(DIM_WHITE);
- pprintf(" (%s, %ld bytes)\n", ptr->mimetype, ptr->length);
+ scr_printf(" (%s, %ld bytes)\n", ptr->mimetype, ptr->length);
if (!strncmp(ptr->mimetype, "image/", 6)) {
has_images++;
}
if (mode == 0) {
fp = fopen(filename, "r");
if (fp != NULL) {
- fmout(screenwidth, fp, NULL, NULL, 0,
- screenheight, 0, 0);
+ fmout(screenwidth, fp, NULL, NULL, 0);
beg = ftell(fp);
fclose(fp);
} else {
case 2:
default: /* allow 2+ modes */
e_ex_code = 1; /* start with a failed exit code */
- screen_reset();
stty_ctdl(SB_RESTORE);
editor_pid = fork();
cksum = file_checksum(filename);
} while ((b != editor_pid) && (b >= 0));
editor_pid = (-1);
stty_ctdl(0);
- screen_set();
break;
}
}
fp = fopen(filename, "r");
if (fp != NULL) {
- fmout(screenwidth, fp, NULL, NULL,
- ((userflags & US_PAGINATOR) ? 1 : 0),
- screenheight, 0, 0);
+ fmout(screenwidth, fp, NULL, NULL, 0);
beg = ftell(fp);
fclose(fp);
}
return;
}
- lines_printed = 0;
-
/* this loop cycles through each message... */
start = ((rdir == 1) ? 0 : (num_msgs - 1));
for (a = start; ((a < num_msgs) && (a >= 0)); a = a + rdir) {
if (freopen(prtfile, "r", stdin) == NULL) {
/* we probably should handle the error condition here */
}
- screen_reset();
stty_ctdl(SB_RESTORE);
ka_system(printcmd);
stty_ctdl(SB_NO_INTR);
- screen_set();
unlink(prtfile);
exit(0);
}
keyopt("<?>help -> ");
do {
- lines_printed = 2;
e = (inkey() & 127);
e = tolower(e);
/* return key same as <N> */ if (e == 10)
}
while (transcript && !IsEmptyStr(transcript)) {
- lines_printed = 1;
extract_token(buf, transcript, 0, '\n', sizeof buf);
remove_token(transcript, 0, '\n');
- pprintf("%s\n", buf);
+ scr_printf("%s\n", buf);
}
if (transcript) free(transcript);
return;
if ((c + strlen(rmname) + 4) > screenwidth) {
/* line break, check the paginator */
- pprintf("\n");
+ scr_printf("\n");
c = 1;
}
if (f & QR_MAILBOX) {
} else {
color(DIM_WHITE);
}
- pprintf("%s", rmname);
+ scr_printf("%s", rmname);
if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
- pprintf("} ");
+ scr_printf("} ");
else if (f & QR_DIRECTORY)
- pprintf("] ");
+ scr_printf("] ");
else if (f & QR_NETWORK)
- pprintf(") ");
+ scr_printf(") ");
else
- pprintf("> ");
+ scr_printf("> ");
c = c + strlen(rmname) + 3;
}
for (a = 0; a < 128; ++a) {
if ((strlen(floorlist[a]) > 0) && (a != curr_floor)) {
if ((c + strlen(floorlist[a]) + 4) > screenwidth) {
- pprintf("\n");
+ scr_printf("\n");
c = 1;
}
- pprintf("%s: ", floorlist[a]);
+ scr_printf("%s: ", floorlist[a]);
c = c + strlen(floorlist[a]) + 3;
}
}
if (kn_floor_mode == 0) {
color(BRIGHT_CYAN);
- pprintf("\n Rooms with unread messages:\n");
+ scr_printf("\n Rooms with unread messages:\n");
listrms(listing, LISTRMS_NEW_ONLY, -1, 0, NULL);
color(BRIGHT_CYAN);
- pprintf("\n\n No unseen messages in:\n");
+ scr_printf("\n\n No unseen messages in:\n");
listrms(listing, LISTRMS_OLD_ONLY, -1, 0, NULL);
- pprintf("\n");
+ scr_printf("\n");
}
if (kn_floor_mode == 1) {
color(BRIGHT_CYAN);
- pprintf("\n Rooms with unread messages on %s:\n",
+ scr_printf("\n Rooms with unread messages on %s:\n",
floorlist[(int) curr_floor]);
listrms(listing, LISTRMS_NEW_ONLY, curr_floor, 0, NULL);
color(BRIGHT_CYAN);
- pprintf("\n\n Rooms with no new messages on %s:\n",
+ scr_printf("\n\n Rooms with no new messages on %s:\n",
floorlist[(int) curr_floor]);
listrms(listing, LISTRMS_OLD_ONLY, curr_floor, 0, NULL);
color(BRIGHT_CYAN);
- pprintf("\n\n Other floors:\n");
+ scr_printf("\n\n Other floors:\n");
list_other_floors();
- pprintf("\n");
+ scr_printf("\n");
}
if (kn_floor_mode == 2) {
for (a = 0; a < 128; ++a) {
if (floorlist[a][0] != 0) {
color(BRIGHT_CYAN);
- pprintf("\n Rooms on %s:\n",
+ scr_printf("\n Rooms on %s:\n",
floorlist[a]);
listrms(listing, LISTRMS_ALL, a, 0, NULL);
- pprintf("\n");
+ scr_printf("\n");
}
}
}
};
color(DIM_WHITE);
- IFNEXPERT hit_any_key(ipc);
}
}
color(BRIGHT_CYAN);
- pprintf("\n Forgotten public rooms:\n");
+ scr_printf("\n Forgotten public rooms:\n");
listrms(listing, LISTRMS_ALL, -1, 0, NULL);
- pprintf("\n");
+ scr_printf("\n");
/* Free the room list */
while (listing) {
};
color(DIM_WHITE);
- IFNEXPERT hit_any_key(ipc);
}
void dotknown(CtdlIPC *ipc, int what, char *match)
switch (what) {
case 0:
- pprintf("\n Anonymous rooms:\n");
+ scr_printf("\n Anonymous rooms:\n");
listrms(listing, LISTRMS_ALL, -1, QR_ANONONLY|QR_ANONOPT, NULL);
- pprintf("\n");
+ scr_printf("\n");
break;
case 1:
- pprintf("\n Directory rooms:\n");
+ scr_printf("\n Directory rooms:\n");
listrms(listing, LISTRMS_ALL, -1, QR_DIRECTORY, NULL);
- pprintf("\n");
+ scr_printf("\n");
break;
case 2:
- pprintf("\n Matching \"%s\" rooms:\n", match);
+ scr_printf("\n Matching \"%s\" rooms:\n", match);
listrms(listing, LISTRMS_ALL, -1, 0, match);
- pprintf("\n");
+ scr_printf("\n");
break;
case 3:
- pprintf("\n Preferred only rooms:\n");
+ scr_printf("\n Preferred only rooms:\n");
listrms(listing, LISTRMS_ALL, -1, QR_PREFONLY, NULL);
- pprintf("\n");
+ scr_printf("\n");
break;
case 4:
- pprintf("\n Private rooms:\n");
+ scr_printf("\n Private rooms:\n");
listrms(listing, LISTRMS_ALL, -1, QR_PRIVATE, NULL);
- pprintf("\n");
+ scr_printf("\n");
break;
case 5:
- pprintf("\n Read only rooms:\n");
+ scr_printf("\n Read only rooms:\n");
listrms(listing, LISTRMS_ALL, -1, QR_READONLY, NULL);
- pprintf("\n");
+ scr_printf("\n");
break;
case 6:
- pprintf("\n Shared rooms:\n");
+ scr_printf("\n Shared rooms:\n");
listrms(listing, LISTRMS_ALL, -1, QR_NETWORK, NULL);
- pprintf("\n");
+ scr_printf("\n");
break;
}
};
color(DIM_WHITE);
- IFNEXPERT hit_any_key(ipc);
}
/* FIXME: display internally instead */
snprintf(transmit_cmd, sizeof transmit_cmd, "exec cat %s", tempname);
- screen_reset();
stty_ctdl(SB_RESTORE);
rv = system(transmit_cmd);
stty_ctdl(SB_NO_INTR);
- screen_set();
/* clean up the temporary directory */
nukedir(tempdir);
r = CtdlIPCReadDirectory(ipc, &listing, buf);
if (r / 100 != 1) {
- pprintf("%s\n", buf);
+ scr_printf("%s\n", buf);
return;
}
extract_token(comment, buf, 0, '|', sizeof comment);
extract_token(flnm, buf, 1, '|', sizeof flnm);
- pprintf("\nDirectory of %s on %s\n", flnm, comment);
- pprintf("-----------------------\n");
+ scr_printf("\nDirectory of %s on %s\n", flnm, comment);
+ scr_printf("-----------------------\n");
while (listing && *listing && !IsEmptyStr(listing)) {
extract_token(buf, listing, 0, '\n', sizeof buf);
remove_token(listing, 0, '\n');
extract_token(mimetype, buf, 2, '|', sizeof mimetype);
extract_token(comment, buf, 3, '|', sizeof comment);
if (strlen(flnm) <= 14)
- pprintf("%-14s %8s %s [%s]\n", flnm, flsz, comment, mimetype);
+ scr_printf("%-14s %8s %s [%s]\n", flnm, flsz, comment, mimetype);
else
- pprintf("%s\n%14s %8s %s [%s]\n", flnm, "", flsz,
+ scr_printf("%s\n%14s %8s %s [%s]\n", flnm, "", flsz,
comment, mimetype);
}
if (listing) free(listing);
return;
if (text) {
- fmout(screenwidth, NULL, text, NULL,
- ((userflags & US_PAGINATOR) ? 1 : 0), screenheight,
- (*raide) ? 2 : 0, 1);
+ fmout(screenwidth, NULL, text, NULL, 1);
free(text);
}
}
r = CtdlIPCWhoKnowsRoom(ipc, &listing, buf);
if (r / 100 != 1) {
- pprintf("%s\n", buf);
+ scr_printf("%s\n", buf);
return;
}
while (!IsEmptyStr(listing)) {
extract_token(buf, listing, 0, '\n', sizeof buf);
remove_token(listing, 0, '\n');
if (sigcaught == 0)
- pprintf("%s\n", buf);
+ scr_printf("%s\n", buf);
}
free(listing);
}
snprintf(tmp, sizeof tmp, "WINDOW_TITLE=%s", desc);
putenv(tmp);
- screen_reset();
stty_ctdl(SB_RESTORE);
editor_pid = fork();
if (editor_pid == 0) {
editor_pid = (-1);
scr_printf("Executed %s\n", editor_paths[0]);
stty_ctdl(0);
- screen_set();
} else {
scr_printf("Entering %s. Press return twice when finished.\n", desc);
fp = fopen(temp, "r+");
void edit_floor(CtdlIPC *ipc);
void kill_floor(CtdlIPC *ipc);
void enter_bio(CtdlIPC *ipc);
-void hit_any_key(CtdlIPC *ipc);
int save_buffer(void *file, size_t filelen, const char *pathname);
void destination_directory(char *dest, const char *supplied_filename);
void do_edit(CtdlIPC *ipc,
}
}
-void hit_any_key(CtdlIPC *ipc) { /* hit any key to continue */
- int a,b;
-
- color(COLOR_PUSH);
- color(DIM_RED);
- scr_printf("%s\r", ipc->ServInfo.moreprompt);
- color(COLOR_POP);
- stty_ctdl(0);
- b=inkey();
- for (a=0; !IsEmptyStr(&ipc->ServInfo.moreprompt[a]); ++a)
- scr_putc(' ');
- scr_putc(13);
- stty_ctdl(1);
- if ( (rc_prompt_control == 1)
- || ((rc_prompt_control == 3) && (userflags & US_PROMPTCTL)) ) {
- if (b == 'q' || b == 'Q' || b == 's' || b == 'S')
- b = STOP_KEY;
- if (b == 'n' || b == 'N')
- b = NEXT_KEY;
- }
- if (b==NEXT_KEY) sigcaught = SIGINT;
- if (b==STOP_KEY) sigcaught = SIGQUIT;
-}
-
/*
* Edit or delete a user (cmd=25 to edit/create, 96 to delete)
*/
fclose(fp);
exit(0);
case 1:
- screen_reset();
stty_ctdl(3);
execlp("rx", "rx", flnm, NULL);
exit(1);
case 2:
- screen_reset();
stty_ctdl(3);
execlp("rb", "rb", NULL);
exit(1);
case 3:
- screen_reset();
stty_ctdl(3);
execlp("rz", "rz", NULL);
exit(1);
b = ka_wait(&a);
} while ((b != xfer_pid) && (b != (-1)));
stty_ctdl(0);
- screen_set();
if (a != 0) {
scr_printf("\r*** Transfer unsuccessful.\n");
{
int a, b;
- screen_reset();
stty_ctdl(SB_RESTORE);
a = fork();
if (a == 0) {
b = ka_wait(NULL);
} while ((a != b) && (a != (-1)));
stty_ctdl(0);
- screen_set();
}
/*
r = CtdlIPCListUsersWithBios(ipc, &resp, buf);
if (r / 100 != 1) {
- pprintf("%s\n", buf);
+ scr_printf("%s\n", buf);
return;
}
while (resp && !IsEmptyStr(resp)) {
extract_token(buf, resp, 0, '\n', sizeof buf);
remove_token(resp, 0, '\n');
if ((pos + strlen(buf) + 5) > screenwidth) {
- pprintf("\n");
+ scr_printf("\n");
pos = 1;
}
- pprintf("%s, ", buf);
+ scr_printf("%s, ", buf);
pos = pos + strlen(buf) + 2;
}
- pprintf("%c%c \n\n", 8, 8);
+ scr_printf("%c%c \n\n", 8, 8);
if (resp) free(resp);
}
do {
newprompt("Read bio for who ('?' for list) : ", who, 25);
- pprintf("\n");
+ scr_printf("\n");
if (!strcmp(who, "?"))
list_bio(ipc);
} while (!strcmp(who, "?"));
r = CtdlIPCGetBio(ipc, who, &resp, buf);
if (r / 100 != 1) {
- pprintf("%s\n", buf);
+ scr_printf("%s\n", buf);
return;
}
while (!IsEmptyStr(resp)) {
extract_token(buf, resp, 0, '\n', sizeof buf);
remove_token(resp, 0, '\n');
- pprintf("%s\n", buf);
+ scr_printf("%s\n", buf);
}
if (resp) free(resp);
}
extern int screenheight;
extern int screenwidth;
+int lines_printed = 0;
+int cols_printed = 0;
+
extern int rc_ansi_color;
extern void check_screen_dims(void);
void do_keepalive(void);
-
/*
* Initialize the screen
*/
}
-/*
- * Kill the screen completely (used at exit). It is safe to call this
- * function more than once.
- */
-void screen_delete(void)
-{
- screen_reset();
-}
-
-
/*
* Beep.
-/*
- * Set screen/IO parameters, e.g. at start of program or return from external
- * program run.
- */
-int screen_set(void)
-{
- return 0;
-}
-
-
-/*
- * Reset screen/IO parameters, e.g. at exit or fork of external program.
- */
-int screen_reset(void)
-{
- return 0;
-}
-
/*
* scr_printf() outputs to the terminal
buf = '\0';
if (!read (0, &buf, 1))
logoff(NULL, 3);
+
+ lines_printed = 0;
return buf;
}
+/*
+ * Issue the paginator prompt (more / hit any key to continue)
+ */
+void hit_any_key(void) {
+ int b;
+
+ color(COLOR_PUSH);
+ color(DIM_RED);
+ /* scr_printf("%s\r", ipc->ServInfo.moreprompt); */
+ scr_printf("<<more>>\r"); // FIXME use the prompt given by the server
+ color(COLOR_POP);
+ stty_ctdl(0);
+ b=inkey();
+ /*
+ for (a=0; !IsEmptyStr(&ipc->ServInfo.moreprompt[a]); ++a)
+ scr_putc(' ');
+ */
+ scr_printf(" ");
+ scr_putc(13);
+ stty_ctdl(1);
+/*
+ if ( (rc_prompt_control == 1)
+ || ((rc_prompt_control == 3) && (userflags & US_PROMPTCTL)) ) {
+ if (b == 'q' || b == 'Q' || b == 's' || b == 'S')
+ b = STOP_KEY;
+ if (b == 'n' || b == 'N')
+ b = NEXT_KEY;
+ }
+*/
+ if (b==NEXT_KEY) sigcaught = SIGINT;
+ if (b==STOP_KEY) sigcaught = SIGQUIT;
+}
+
+
/*
* Output one character to the terminal
*/
int scr_putc(int c)
{
+ /* handle tabs normally */
+ if (c == '\t') {
+ do {
+ scr_putc(' ');
+ } while ((cols_printed % 8) != 0);
+ return(c);
+ }
+
+ /* Output the character... */
if (putc(c, stdout) == EOF) {
logoff(NULL, 3);
}
+
+ if (c == '\n') {
+ ++lines_printed;
+ cols_printed = 0;
+ }
+ else if (c == '\r') {
+ cols_printed = 0;
+ }
+ else if (isprint(c)) {
+ ++cols_printed;
+ if ((screenwidth > 0) && (cols_printed > screenwidth)) {
+ ++lines_printed;
+ cols_printed = 0;
+ }
+ }
+
+ // if we want to do a top status line, this is a reasonable way to do it
+ // printf("\033[s\033[0;70H");
+ // printf("\033[K %d/%d %d/%d", cols_printed, screenwidth, lines_printed, screenheight);
+ // printf("\033[u");
+
+ if ((screenheight > 0) && (lines_printed > (screenheight-2))) {
+ lines_printed = 0;
+ hit_any_key();
+ lines_printed = 0;
+ cols_printed = 0;
+ }
+
return c;
}
static volatile int caught_sigwinch = 0;
-/*
- * this is not supposed to be called from a signal handler.
- */
-int scr_set_windowsize(CtdlIPC* ipc)
-{
- return 0;
-}
/*
* scr_winch() handles window size changes from SIGWINCH
/* client code may need the ERR define: */
void screen_new(void);
-void screen_delete(void);
-int screen_set(void);
-int screen_reset(void);
int scr_printf(char *fmt, ...);
-int scr_set_windowsize(CtdlIPC* ipc);
#define SCR_NOBLOCK 0
#define SCR_BLOCK -1
fclose(tempfp);
e_ex_code = 1; /* start with a failed exit code */
- screen_reset();
stty_ctdl(SB_RESTORE);
editor_pid = fork();
cksum = file_checksum(filename);
} while ((b != editor_pid) && (b >= 0));
editor_pid = (-1);
stty_ctdl(0);
- screen_set();
}
if (file_checksum(filename) == cksum) {