]> code.citadel.org Git - citadel.git/blobdiff - citadel/textclient/commands.c
wtf is gl_string? unused variable, removed it
[citadel.git] / citadel / textclient / commands.c
index 525e3ce62db1a25ad2997a22fc5e8996619e7bb9..bb9da5d7d07d8f76e52acbc0062268645874c3ad 100644 (file)
@@ -92,7 +92,6 @@ char rc_url_cmd[SIZ];
 char rc_open_cmd[SIZ];
 char rc_gotmail_cmd[SIZ];
 
-char *gl_string;
 int next_lazy_cmd = 5;
 
 extern int screenwidth, screenheight;
@@ -487,24 +486,24 @@ int yesno_d(int d)
 
 
 
-/* Gets a line from the terminal */
-/* string == Pointer to string buffer */
-/* lim == Maximum length - if negative, no-show */
-void ctdl_getline(char *string, int lim) 
+/*
+ * Function to read a line of text from the terminal.
+ *
+ * string              Pointer to string buffer
+ * lim                 Maximum length
+ * noshow              Echo asterisks instead of keystrokes?
+ * bs                  Allow backspacing out of the prompt?
+ *
+ * returns: string length
+ */
+int ctdl_getline(char *string, int lim, int noshow, int bs)
 {
        int a, b;
-       char flag = 0;
 
-       if (lim < 0) {
-               lim = (0 - lim);
-               flag = 1;
-       }
        strcpy(string, "");
-       gl_string = string;
        async_ka_start();
 
 GLA:   a = inkey();
-       /* a = (a & 127); ** commented out because it isn't just an ASCII world anymore */
        if ((a == 8 || a == 23) && (IsEmptyStr(string)))
                goto GLA;
        if ((a != 10) && (a != 8) && (strlen(string) == lim))
@@ -524,24 +523,28 @@ GLA:      a = inkey();
        if ((a == 10)) {
                scr_putc(10);
                async_ka_end();
-               return;
+               return(strlen(string));
        }
-       if (a < 32)
+       if (a < 32) {
                a = '.';
+       }
        b = strlen(string);
        string[b] = a;
        string[b + 1] = 0;
-       if (flag == 0)
-               scr_putc(a);
-       if (flag == 1)
+       if (noshow) {
                scr_putc('*');
+       }
+       else {
+               scr_putc(a);
+       }
        goto GLA;
 }
 
 
-/*
- * strprompt()  -  prompt for a string, print the existing value and
- *                 allow the user to press return to keep it...
+/* 
+ * newprompt()         prompt for a string, print the existing value, and
+ *                     allow the user to press return to keep it...
+ *                     If len is negative, pass the "noshow" flag to ctdl_getline()
  */
 void strprompt(char *prompt, char *str, int len)
 {
@@ -569,9 +572,10 @@ void strprompt(char *prompt, char *str, int len)
        color(DIM_WHITE);
        scr_printf(": ");
        color(BRIGHT_CYAN);
-       ctdl_getline(buf, len);
-       if (buf[0] != 0)
+       ctdl_getline(buf, abs(len), (len<0), 0);
+       if (buf[0] != 0) {
                strcpy(str, buf);
+       }
        color(DIM_WHITE);
 }
 
@@ -626,15 +630,17 @@ int intprompt(char *prompt, int ival, int imin, int imax)
 }
 
 /* 
- * newprompt()  -  prompt for a string with no existing value
- *                 (clears out string buffer first)
+ * newprompt()         prompt for a string with no existing value
+ *                     (clears out string buffer first)
+ *                     If len is negative, pass the "noshow" flag to ctdl_getline()
  */
 void newprompt(char *prompt, char *str, int len)
 {
+       str[0] = 0;
        color(BRIGHT_MAGENTA);
        scr_printf("%s", prompt);
        color(DIM_MAGENTA);
-       ctdl_getline(str, len);
+       ctdl_getline(str, abs(len), (len<0), 0);
        color(DIM_WHITE);
 }
 
@@ -773,6 +779,10 @@ void load_command_set(void)
                        if (!strncasecmp(&buf[11], "user", 4))
                                rc_ansi_color = 3;      /* user config */
                }
+               if (!strncasecmp(buf, "status_line=", 12)) {
+                       if (!strncasecmp(&buf[12], "on", 2))
+                               enable_status_line = 1;
+               }
                if (!strncasecmp(buf, "use_background=", 15)) {
                        if (!strncasecmp(&buf[15], "on", 2))
                                rc_color_use_bg = 9;
@@ -1045,7 +1055,8 @@ int getcmd(CtdlIPC *ipc, char *argbuf)
                        if (cmdmatch(cmdbuf, cptr, 5)) {
                                /* We've found our command. */
                                if (requires_string(cptr, cmdpos)) {
-                                       ctdl_getline(argbuf, 64);
+                                       argbuf[0] = 0;
+                                       ctdl_getline(argbuf, 64, 0, 0);
                                } else {
                                        scr_printf("\n");
                                }