ctdl_getline() is a mess. started cleaning it up
authorArt Cancro <ajc@uncensored.citadel.org>
Thu, 19 Apr 2012 15:10:41 +0000 (11:10 -0400)
committerArt Cancro <ajc@uncensored.citadel.org>
Thu, 19 Apr 2012 15:10:41 +0000 (11:10 -0400)
citadel/textclient/client_chat.c
citadel/textclient/commands.c
citadel/textclient/messages.c
citadel/textclient/screen.h

index 5b9faeb3a47ed682e37472bf649c85f989c72ca5..760ce5934abb7880c36d45c38dff2e0c537b3943 100644 (file)
@@ -55,9 +55,6 @@
 #define MIN(a, b) ((a) < (b) ? (a) : (b))
 
 extern char temp[];
-void ctdl_getline(char *, int);
-
-
 char last_paged[SIZ] = "";
 
 void chatmode(CtdlIPC *ipc)
index 732080658cf5b108794f6e0a4d781b97842549a2..98be7a698ac17e9e9a281c34bd9183cd15c0490d 100644 (file)
@@ -487,24 +487,26 @@ int yesno_d(int d)
 
 
 
-/* Gets a line from the terminal */
-/* string == Pointer to string buffer */
-/* lim == Maximum length - if negative, no-show */
+/*
+ * Function to read a line of text from the terminal.
+ *
+ * string              Pointer to string buffer
+ * lim                 Maximum length - if negative, echo asterisks instead of characters
+ */
 void ctdl_getline(char *string, int lim) 
 {
        int a, b;
-       char flag = 0;
+       char noshow = 0;
 
        if (lim < 0) {
                lim = (0 - lim);
-               flag = 1;
+               noshow = 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))
@@ -526,15 +528,18 @@ GLA:      a = inkey();
                async_ka_end();
                return;
        }
-       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;
 }
 
index 5f29bf0addcded03f2bcc8e8d9ae121540539033..d86647c185cb6bd06862dd7eb0e1fd7f8d5574a1 100644 (file)
@@ -70,7 +70,6 @@ struct cittext {
 
 void stty_ctdl(int cmd);
 int haschar(const char *st, int ch);
-void ctdl_getline(char *string, int lim);
 int file_checksum(char *filename);
 void progress(CtdlIPC* ipc, unsigned long curr, unsigned long cmax);
 
index 8e057964617e9097164efab34bdb2358ff833008..5107f1098fcb152516b25f50df5bb6bbe0785897 100644 (file)
@@ -14,6 +14,7 @@
 
 void screen_new(void);
 int scr_printf(char *fmt, ...);
+void ctdl_getline(char *string, int lim);
 #define SCR_NOBLOCK 0
 #define SCR_BLOCK -1
 int scr_getc(int delay);