]> code.citadel.org Git - citadel.git/blobdiff - citadel/textclient/commands.c
Networker: remove unneeded assignment
[citadel.git] / citadel / textclient / commands.c
index a1ac0350187bb9673bce53543c0ba3660df40685..426849a95f3091f61eaaa7c2994163b2819d3287 100644 (file)
@@ -492,7 +492,7 @@ int yesno_d(int d)
  * string              Pointer to string buffer
  * lim                 Maximum length
  * noshow              Echo asterisks instead of keystrokes?
- * bs                  Allow backspacing out of the prompt? (NOT IMPLEMENTED YET)
+ * bs                  Allow backspacing out of the prompt? (returns -1 if this happens)
  *
  * returns: string length
  */
@@ -502,7 +502,15 @@ int ctdl_getline(char *string, int lim, int noshow, int bs)
        int ch;
 
        async_ka_start();
-       scr_printf("%s", string);
+       if (noshow && !IsEmptyStr(string)) {
+               int num_stars = strlen(string);
+               while (num_stars--) {
+                       scr_putc('*');
+               }
+       }
+       else {
+               scr_printf("%s", string);
+       }
 
        while(1) {
                ch = inkey();
@@ -512,6 +520,11 @@ int ctdl_getline(char *string, int lim, int noshow, int bs)
                        scr_putc(8); scr_putc(32); scr_putc(8);
                }
 
+               else if ((ch == 8) && (pos == 0) && (bs)) {             /* backspace out of the prompt */
+                       async_ka_end();
+                       return(-1);
+               }
+
                else if ((ch == 23) && (pos > 0)) {                     /* Ctrl-W deletes a word */
                        while ((pos > 0) && !isspace(string[pos])) {
                                --pos;
@@ -546,34 +559,13 @@ int ctdl_getline(char *string, int lim, int noshow, int bs)
  */
 void strprompt(char *prompt, char *str, int len)
 {
-       int i;
-       char buf[128];
-
        print_instant();
        color(DIM_WHITE);
-       scr_printf("%s ", prompt);
-       color(DIM_MAGENTA);
-       scr_printf("[");
-       color(BRIGHT_MAGENTA);
-
-       if (len >= 0) {
-               scr_printf("%s", str);
-       }
-       else {
-               for (i=0; !IsEmptyStr(&str[i]); ++i) {
-                       scr_printf("*");
-               }
-       }
-
-       color(DIM_MAGENTA);
-       scr_printf("]");
+       scr_printf("%s", prompt);
        color(DIM_WHITE);
        scr_printf(": ");
        color(BRIGHT_CYAN);
-       ctdl_getline(buf, abs(len), (len<0), 0);
-       if (buf[0] != 0) {
-               strcpy(str, buf);
-       }
+       ctdl_getline(str, abs(len), (len<0), 0);
        color(DIM_WHITE);
 }