X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=textclient%2Fcommands.c;h=bdd2dc4e55041b96317734b3bf477ba720732b4c;hb=HEAD;hp=197fe1a9d58dca65c9759838b33bac880fbdb766;hpb=fdef03022a466ce3dbaedf8ceef8d1683ae2dd73;p=citadel.git diff --git a/textclient/commands.c b/textclient/commands.c index 197fe1a9d..dfc3f0601 100644 --- a/textclient/commands.c +++ b/textclient/commands.c @@ -1,19 +1,11 @@ -// This file contains functions which implement parts of the -// text-mode user interface. +// This file contains functions which implement parts of the text-mode user interface. // -// Copyright (c) 1987-2022 by the citadel.org team +// Copyright (c) 1987-2024 by the citadel.org team // -// This program is open source software. Use, duplication, and/or -// disclosure are subject to the GNU General Purpose License version 3. -// -// 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 open source software. Use, duplication, or disclosure is subject to the GNU General Public License version 3. #include "textclient.h" - // The help "files" are now just an embedded set of Very Long Strings. helpnames[] is // an array of "file names" and helptexts[] is the "content". @@ -42,11 +34,14 @@ char *helptexts[] = { " G Goto next room which has UNREAD messages.\n" " H Help. Same as '?'\n" " I Reads the Information file for this room.\n" + " J Jump to any named room (same as <.G>oto)\n" " K List of Known rooms.\n" " L Reads the last five messages in the room.\n" + " M Go to your private Mail room\n" " N Reads all new messages in the room.\n" " O Reads all old messages, backwards.\n" " P Page another user (send an instant message)\n" + " Q Quiet mode on/off (disables receiving instant messages)\n" " R Reads all messages in the room, in reverse order.\n" " S Skips current room without making its messages old.\n" " T Terminate (logout)\n" @@ -342,9 +337,6 @@ char *helptexts[] = { " you can specify a partial match\n" "\n" " <.> ead extfile formatted File 'download' commands.\n" - " <.> ead file using modem \n" - " <.> ead file using modem \n" - " <.> ead file using modem \n" " <.> ead ile unformatted \n" " <.> ead irectory \n" "\n" @@ -431,6 +423,7 @@ int rc_display_message_numbers; int rc_force_mail_prompts; int rc_remember_passwords; int rc_ansi_color; +int rc_sixel; int rc_color_use_bg; int rc_prompt_control = 0; time_t rc_idle_threshold = (time_t) 900; @@ -447,10 +440,10 @@ struct citcmd *cmdlist = NULL; // these variables are local to this module -char keepalives_enabled = KA_YES; // send NOOPs to server when idle -int ok_to_interrupt = 0; // print instant msgs asynchronously -time_t AnsiDetect; // when did we send the detect code? -int enable_color = 0; // nonzero for ANSI color +char keepalives_enabled = KA_YES; // send NOOPs to server when idle +int ok_to_interrupt = 0; // print instant msgs asynchronously +time_t AnsiDetect; // when did we send the detect code? +int enable_color = 0; // nonzero for ANSI color // If an interesting key has been pressed, return its value, otherwise 0 @@ -491,7 +484,7 @@ void display_instant_messages(void) { char sender[64]; char node[64]; char *listing = NULL; - int r; // IPC result code + int r; // IPC result code if (instant_msgs == 0) { return; @@ -753,7 +746,7 @@ int ctdl_getline(char *string, int lim, int noshow, int bs) { while (1) { ch = inkey(); - if ((ch == 8) && (pos > 0)) { // backspace + if ((ch == 8) && (pos > 0)) { // backspace --pos; scr_putc(8); scr_putc(32); @@ -764,7 +757,7 @@ int ctdl_getline(char *string, int lim, int noshow, int bs) { return (-1); } - else if ((ch == 23) && (pos > 0)) { // Ctrl-W deletes a word + else if ((ch == 23) && (pos > 0)) { // Ctrl-W deletes a word while ((pos > 0) && !isspace(string[pos])) { --pos; scr_putc(8); @@ -785,7 +778,7 @@ int ctdl_getline(char *string, int lim, int noshow, int bs) { return (pos); } - else if (isprint(ch)) { // payload characters + else if (isprint(ch)) { // payload characters scr_putc((noshow ? '*' : ch)); string[pos] = ch; ++pos; @@ -868,8 +861,9 @@ void newprompt(char *prompt, char *str, int len) { int lkey(void) { int a; a = inkey(); - if (isupper(a)) + if (isupper(a)) { a = tolower(a); + } return (a); } @@ -897,6 +891,7 @@ void load_command_set(void) { rc_display_message_numbers = 0; rc_force_mail_prompts = 0; rc_ansi_color = 0; + rc_sixel = 0; rc_color_use_bg = 0; strcpy(rc_url_cmd, ""); strcpy(rc_open_cmd, ""); @@ -1005,6 +1000,10 @@ void load_command_set(void) { if (!strncasecmp(&buf[12], "on", 2)) enable_status_line = 1; } + if (!strncasecmp(buf, "use_sixel=", 10)) { + if (!strncasecmp(&buf[10], "on", 2)) + rc_sixel = 1; + } if (!strncasecmp(buf, "use_background=", 15)) { if (!strncasecmp(&buf[15], "on", 2)) rc_color_use_bg = 9; @@ -1185,10 +1184,12 @@ int getcmd(CtdlIPC * ipc, char *argbuf) { // Switch color support on or off if we're in user mode if (rc_ansi_color == 3) { - if (userflags & US_COLOR) + if (userflags & US_COLOR) { enable_color = 1; - else + } + else { enable_color = 0; + } } // if we're running in idiot mode, display a cute little menu @@ -1278,13 +1279,13 @@ int getcmd(CtdlIPC * ipc, char *argbuf) { // If this command is one that changes rooms, then the next lazy-command // (space bar) should be "read new" instead of "goto" - if ((cptr->c_cmdnum == 5) - || (cptr->c_cmdnum == 6) - || (cptr->c_cmdnum == 47) - || (cptr->c_cmdnum == 52) - || (cptr->c_cmdnum == 16) - || (cptr->c_cmdnum == 20) - ) { + if ( (cptr->c_cmdnum == 5) + || (cptr->c_cmdnum == 6) + || (cptr->c_cmdnum == 47) + || (cptr->c_cmdnum == 52) + || (cptr->c_cmdnum == 16) + || (cptr->c_cmdnum == 20) + ) { next_lazy_cmd = 13; } @@ -1294,7 +1295,6 @@ int getcmd(CtdlIPC * ipc, char *argbuf) { } return (cptr->c_cmdnum); - } } @@ -1330,7 +1330,7 @@ int getcmd(CtdlIPC * ipc, char *argbuf) { // set tty modes. commands are: // // 01- set to Citadel mode -// 2 - save current settings for later restoral +// 2 - save current settings for later restore // 3 - restore saved settings void stty_ctdl(int cmd) { struct termios live; @@ -1396,10 +1396,11 @@ void display_help(CtdlIPC * ipc, char *name) { // fmout() - Citadel text formatter and paginator int fmout(int width, // screen width to use - 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 - int subst) { // nonzero if we should use hypertext mode + 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 + int subst // nonzero if we should use hypertext mode +) { char *buffer = NULL; // The current message char *word = NULL; // What we are about to actually print char *e; // Pointer to position in text @@ -1437,9 +1438,9 @@ int fmout(int width, // screen width to use continue; } - if ( (in_quote) && (*e == '\n') && (enable_color) ) { + if ((in_quote) && (*e == '\n') && (enable_color)) { in_quote = 0; - scr_printf("\033[22m\033[23m"); + scr_printf("\033[22m\033[22m"); } if (*e == '\n') { // newline? @@ -1466,9 +1467,9 @@ int fmout(int width, // screen width to use continue; } - if ( (*e == '>') && (column <= 1) && (!fpout) && (enable_color) ) { + if ((*e == '>') && (column <= 1) && (!fpout) && (enable_color)) { in_quote = 1; - scr_printf("\033[2m\033[3m"); + scr_printf("\033[2m\033[2m"); } // Or are we looking at a space? @@ -1582,11 +1583,12 @@ void color(int colornum) { // terminals. - Changed to ORIGINAL_PAIR as this actually // wound up looking horrible on black-on-white terminals, not // to mention transparent terminals. - if (colornum == ORIGINAL_PAIR) + if (colornum == ORIGINAL_PAIR) { printf("\033[0;39;49m"); - else + } + else { printf("\033[%d;3%d;4%dm", (colornum & 8) ? 1 : 0, (colornum & 7), rc_color_use_bg); - + } } } @@ -1609,6 +1611,7 @@ void send_ansi_detect(void) { } +// Turn ANSI color (etc.) support on, or off, or auto-detect support, depending on the configuration void look_for_ansi(void) { fd_set rfds; struct timeval tv; @@ -1616,21 +1619,19 @@ void look_for_ansi(void) { time_t now; int a, rv; - if (rc_ansi_color == 0) { + if (rc_ansi_color == 0) { // Configured to never use color enable_color = 0; } - else if (rc_ansi_color == 1) { + else if (rc_ansi_color == 1) { // Configured to always use color enable_color = 1; } - else if (rc_ansi_color == 2) { - - /* otherwise, do the auto-detect */ + else if (rc_ansi_color == 2) { // Configured to auto-detect ANSI color support strcpy(abuf, ""); - time(&now); - if ((now - AnsiDetect) < 2) + if ((now - AnsiDetect) < 2) { sleep(1); + } do { FD_ZERO(&rfds); @@ -1650,8 +1651,10 @@ void look_for_ansi(void) { } while (FD_ISSET(0, &rfds)); for (a = 0; !IsEmptyStr(&abuf[a]); ++a) { - if ((abuf[a] == 27) && (abuf[a + 1] == '[') - && (abuf[a + 2] == '?')) { + if ( (abuf[a] == 27) + && (abuf[a + 1] == '[') + && (abuf[a + 2] == '?') + ) { // ANSI support was detected! enable_color = 1; } }