diff options
author | Ron Yorston <rmy@pobox.com> | 2012-03-22 15:21:20 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2012-03-22 15:21:20 +0000 |
commit | 0d8b2c4a929ea9d3ac37499319fe0d8e7941a0c2 (patch) | |
tree | 6709ddd6071a9c238ba69233540bbcfe560c6a44 /libbb/lineedit.c | |
parent | 67758035a4fe040c6ac69b39d61bcd6bddd7b827 (diff) | |
parent | 56a3b82e9692a25ef9c9269e88feac0d579ce8e8 (diff) | |
download | busybox-w32-0d8b2c4a929ea9d3ac37499319fe0d8e7941a0c2.tar.gz busybox-w32-0d8b2c4a929ea9d3ac37499319fe0d8e7941a0c2.tar.bz2 busybox-w32-0d8b2c4a929ea9d3ac37499319fe0d8e7941a0c2.zip |
Merge commit '56a3b82e9692a25ef9c9269e88feac0d579ce8e8' into merge
Conflicts:
coreutils/ls.c
include/platform.h
libbb/bb_basename.c
Diffstat (limited to 'libbb/lineedit.c')
-rw-r--r-- | libbb/lineedit.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 67c5e0baa..e443c7a3e 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -41,6 +41,10 @@ | |||
41 | */ | 41 | */ |
42 | #include "libbb.h" | 42 | #include "libbb.h" |
43 | #include "unicode.h" | 43 | #include "unicode.h" |
44 | #ifndef _POSIX_VDISABLE | ||
45 | # define _POSIX_VDISABLE '\0' | ||
46 | #endif | ||
47 | |||
44 | 48 | ||
45 | #ifdef TEST | 49 | #ifdef TEST |
46 | # define ENABLE_FEATURE_EDITING 0 | 50 | # define ENABLE_FEATURE_EDITING 0 |
@@ -184,6 +188,7 @@ extern struct lineedit_statics *const lineedit_ptr_to_statics; | |||
184 | IF_FEATURE_EDITING_FANCY_PROMPT(num_ok_lines = 1;) \ | 188 | IF_FEATURE_EDITING_FANCY_PROMPT(num_ok_lines = 1;) \ |
185 | IF_USERNAME_OR_HOMEDIR(home_pwd_buf = (char*)null_str;) \ | 189 | IF_USERNAME_OR_HOMEDIR(home_pwd_buf = (char*)null_str;) \ |
186 | } while (0) | 190 | } while (0) |
191 | |||
187 | static void deinit_S(void) | 192 | static void deinit_S(void) |
188 | { | 193 | { |
189 | #if ENABLE_FEATURE_EDITING_FANCY_PROMPT | 194 | #if ENABLE_FEATURE_EDITING_FANCY_PROMPT |
@@ -1684,7 +1689,7 @@ static void ask_terminal(void) | |||
1684 | * write(1, "~/srcdevel/bbox/fix/busybox.t4 # ", 33) = 33 | 1689 | * write(1, "~/srcdevel/bbox/fix/busybox.t4 # ", 33) = 33 |
1685 | * poll([{fd=0, events=POLLIN}], 1, 0) = 0 (Timeout) <-- no input exists | 1690 | * poll([{fd=0, events=POLLIN}], 1, 0) = 0 (Timeout) <-- no input exists |
1686 | * write(1, "\33[6n", 4) = 4 <-- send the ESC sequence, quick! | 1691 | * write(1, "\33[6n", 4) = 4 <-- send the ESC sequence, quick! |
1687 | * poll([{fd=0, events=POLLIN}], 1, 4294967295) = 1 ([{fd=0, revents=POLLIN}]) | 1692 | * poll([{fd=0, events=POLLIN}], 1, -1) = 1 ([{fd=0, revents=POLLIN}]) |
1688 | * read(0, "\n", 1) = 1 <-- oh crap, user's input got in first | 1693 | * read(0, "\n", 1) = 1 <-- oh crap, user's input got in first |
1689 | */ | 1694 | */ |
1690 | struct pollfd pfd; | 1695 | struct pollfd pfd; |
@@ -1842,10 +1847,11 @@ static void win_changed(int nsig) | |||
1842 | { | 1847 | { |
1843 | int sv_errno = errno; | 1848 | int sv_errno = errno; |
1844 | unsigned width; | 1849 | unsigned width; |
1850 | |||
1845 | get_terminal_width_height(0, &width, NULL); | 1851 | get_terminal_width_height(0, &width, NULL); |
1846 | cmdedit_setwidth(width, nsig /* - just a yes/no flag */); | 1852 | //FIXME: cmdedit_setwidth() -> redraw() -> printf() -> KABOOM! (we are in signal handler!) |
1847 | if (nsig == SIGWINCH) | 1853 | cmdedit_setwidth(width, /*redraw_flg:*/ nsig); |
1848 | signal(SIGWINCH, win_changed); /* rearm ourself */ | 1854 | |
1849 | errno = sv_errno; | 1855 | errno = sv_errno; |
1850 | } | 1856 | } |
1851 | 1857 | ||
@@ -2031,14 +2037,9 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman | |||
2031 | new_settings.c_cc[VMIN] = 1; | 2037 | new_settings.c_cc[VMIN] = 1; |
2032 | new_settings.c_cc[VTIME] = 0; | 2038 | new_settings.c_cc[VTIME] = 0; |
2033 | /* Turn off CTRL-C, so we can trap it */ | 2039 | /* Turn off CTRL-C, so we can trap it */ |
2034 | #ifndef _POSIX_VDISABLE | ||
2035 | # define _POSIX_VDISABLE '\0' | ||
2036 | #endif | ||
2037 | new_settings.c_cc[VINTR] = _POSIX_VDISABLE; | 2040 | new_settings.c_cc[VINTR] = _POSIX_VDISABLE; |
2038 | tcsetattr_stdin_TCSANOW(&new_settings); | 2041 | tcsetattr_stdin_TCSANOW(&new_settings); |
2039 | 2042 | ||
2040 | previous_SIGWINCH_handler = signal(SIGWINCH, win_changed); | ||
2041 | win_changed(0); /* do initial resizing */ | ||
2042 | #if ENABLE_USERNAME_OR_HOMEDIR | 2043 | #if ENABLE_USERNAME_OR_HOMEDIR |
2043 | { | 2044 | { |
2044 | struct passwd *entry; | 2045 | struct passwd *entry; |
@@ -2061,6 +2062,11 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman | |||
2061 | parse_and_put_prompt(prompt); | 2062 | parse_and_put_prompt(prompt); |
2062 | ask_terminal(); | 2063 | ask_terminal(); |
2063 | 2064 | ||
2065 | /* Install window resize handler (NB: after *all* init is complete) */ | ||
2066 | //FIXME: save entire sigaction! | ||
2067 | previous_SIGWINCH_handler = signal(SIGWINCH, win_changed); | ||
2068 | win_changed(0); /* get initial window size */ | ||
2069 | |||
2064 | read_key_buffer[0] = 0; | 2070 | read_key_buffer[0] = 0; |
2065 | while (1) { | 2071 | while (1) { |
2066 | /* | 2072 | /* |