spiffy new strprompt() allows backspacing over the existing value
authorArt Cancro <ajc@uncensored.citadel.org>
Thu, 19 Apr 2012 16:20:06 +0000 (12:20 -0400)
committerArt Cancro <ajc@uncensored.citadel.org>
Thu, 19 Apr 2012 16:20:06 +0000 (12:20 -0400)
citadel/textclient/commands.c

index 33c0d6927ea7ca3b00e8eceed10f6c08c7fa1b6c..426849a95f3091f61eaaa7c2994163b2819d3287 100644 (file)
@@ -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();
@@ -551,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);
 }