-// 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 is 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".
" 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"
" you can specify a partial match\n"
"\n"
" <.> <R>ead <T>extfile formatted File 'download' commands.\n"
- " <.> <R>ead file using <X>modem \n"
- " <.> <R>ead file using <Y>modem \n"
- " <.> <R>ead file using <Z>modem \n"
" <.> <R>ead <F>ile unformatted \n"
" <.> <R>ead <D>irectory \n"
"\n"
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;
// 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
char sender[64];
char node[64];
char *listing = NULL;
- int r; // IPC result code
+ int r; // IPC result code
if (instant_msgs == 0) {
return;
while (1) {
ch = inkey();
- if ((ch == 8) && (pos > 0)) { // backspace
+ if ((ch == 8) && (pos > 0)) { // backspace
--pos;
scr_putc(8);
scr_putc(32);
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);
return (pos);
}
- else if (isprint(ch)) { // payload characters
+ else if (isprint(ch)) { // payload characters
scr_putc((noshow ? '*' : ch));
string[pos] = ch;
++pos;
int lkey(void) {
int a;
a = inkey();
- if (isupper(a))
+ if (isupper(a)) {
a = tolower(a);
+ }
return (a);
}
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, "");
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;
// 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
// 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;
}
}
return (cptr->c_cmdnum);
-
}
}
// 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;
// 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
// 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);
-
+ }
}
}
}
+// 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;
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);
} 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;
}
}