Commit Vladimir's latest cmdedit. I modified it slightly to ensure
authorEric Andersen <andersen@codepoet.org>
Fri, 16 Feb 2001 20:09:17 +0000 (20:09 -0000)
committerEric Andersen <andersen@codepoet.org>
Fri, 16 Feb 2001 20:09:17 +0000 (20:09 -0000)
parse_prompt() would be called before cmdedit_init(), since cmdedit_init()
calls cmdedit_setwidth() which uses cmdedit_prmt_len, which is set by
parse_prompt().  Also, added a mod, so very narrow terminals should now wrap
properly...  This is working very nicely for me -- Vladimir has done some
very good work.

cmdedit.c
lash.c
sh.c
shell/cmdedit.c
shell/lash.c

index 6a53c12f648ce20b9049a41983ebdc42cde2a18d..6fd80fd219d7dfb6820f290eab727ad3d2b48c0b 100644 (file)
--- a/cmdedit.c
+++ b/cmdedit.c
@@ -30,7 +30,7 @@
  */
 
 
-#define TEST
+//#define TEST
 
 
 #ifndef TEST
@@ -555,6 +555,9 @@ static void clean_up_and_die(int sig)
 static void cmdedit_setwidth(int w, int redraw_flg)
 {
        cmdedit_termw = cmdedit_prmt_len + 2;
+       if (w <= cmdedit_termw) {
+               cmdedit_termw = cmdedit_termw % w;
+       }
        if (w > cmdedit_termw) {
 
                cmdedit_termw = w;
@@ -567,10 +570,7 @@ static void cmdedit_setwidth(int w, int redraw_flg)
                        redraw((new_y >= cmdedit_y ? new_y : cmdedit_y), len - cursor);
                        fflush(stdout);
                }
-       } else {
-               error_msg("\n*** Error: minimum screen width is %d",
-                                 cmdedit_termw);
-       }
+       } 
 }
 
 extern void cmdedit_init(void)
@@ -1234,9 +1234,10 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ])
        setTermSettings(inputFd, (void *) &new_settings);
        handlers_sets |= SET_RESET_TERM;
 
-       cmdedit_init();
        /* Print out the command prompt */
        parse_prompt(prompt);
+       /* Now initialize things */
+       cmdedit_init();
 
        while (1) {
 
diff --git a/lash.c b/lash.c
index 9519538dcf708cefc68c49deecd33ba276fa86bd..76ef16a55f09749970c0b828b4afbda651914b8e 100644 (file)
--- a/lash.c
+++ b/lash.c
@@ -854,10 +854,9 @@ static int get_command(FILE * source, char *command)
                ** atexit() handlers and other unwanted stuff to our
                ** child processes (rob@sysgo.de)
                */
-               cmdedit_init();
                cmdedit_read_input(prompt_str, command);
-               free(prompt_str);
                cmdedit_terminate();
+               free(prompt_str);
                return 0;
 #else
                fputs(prompt_str, stdout);
diff --git a/sh.c b/sh.c
index 9519538dcf708cefc68c49deecd33ba276fa86bd..76ef16a55f09749970c0b828b4afbda651914b8e 100644 (file)
--- a/sh.c
+++ b/sh.c
@@ -854,10 +854,9 @@ static int get_command(FILE * source, char *command)
                ** atexit() handlers and other unwanted stuff to our
                ** child processes (rob@sysgo.de)
                */
-               cmdedit_init();
                cmdedit_read_input(prompt_str, command);
-               free(prompt_str);
                cmdedit_terminate();
+               free(prompt_str);
                return 0;
 #else
                fputs(prompt_str, stdout);
index 6a53c12f648ce20b9049a41983ebdc42cde2a18d..6fd80fd219d7dfb6820f290eab727ad3d2b48c0b 100644 (file)
@@ -30,7 +30,7 @@
  */
 
 
-#define TEST
+//#define TEST
 
 
 #ifndef TEST
@@ -555,6 +555,9 @@ static void clean_up_and_die(int sig)
 static void cmdedit_setwidth(int w, int redraw_flg)
 {
        cmdedit_termw = cmdedit_prmt_len + 2;
+       if (w <= cmdedit_termw) {
+               cmdedit_termw = cmdedit_termw % w;
+       }
        if (w > cmdedit_termw) {
 
                cmdedit_termw = w;
@@ -567,10 +570,7 @@ static void cmdedit_setwidth(int w, int redraw_flg)
                        redraw((new_y >= cmdedit_y ? new_y : cmdedit_y), len - cursor);
                        fflush(stdout);
                }
-       } else {
-               error_msg("\n*** Error: minimum screen width is %d",
-                                 cmdedit_termw);
-       }
+       } 
 }
 
 extern void cmdedit_init(void)
@@ -1234,9 +1234,10 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ])
        setTermSettings(inputFd, (void *) &new_settings);
        handlers_sets |= SET_RESET_TERM;
 
-       cmdedit_init();
        /* Print out the command prompt */
        parse_prompt(prompt);
+       /* Now initialize things */
+       cmdedit_init();
 
        while (1) {
 
index 9519538dcf708cefc68c49deecd33ba276fa86bd..76ef16a55f09749970c0b828b4afbda651914b8e 100644 (file)
@@ -854,10 +854,9 @@ static int get_command(FILE * source, char *command)
                ** atexit() handlers and other unwanted stuff to our
                ** child processes (rob@sysgo.de)
                */
-               cmdedit_init();
                cmdedit_read_input(prompt_str, command);
-               free(prompt_str);
                cmdedit_terminate();
+               free(prompt_str);
                return 0;
 #else
                fputs(prompt_str, stdout);