aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2018-01-12 08:32:28 +0100
committerBjörn Linse <bjorn.linse@gmail.com>2018-02-05 22:57:43 +0100
commit2d99b81ab5b7481e20c03376f0f40924daff491f (patch)
treeb681908c6317807f75ee701e704b221b0eda71b0
parent0851057a8deaa1197bd0af22babb62c1146d836c (diff)
downloadrneovim-2d99b81ab5b7481e20c03376f0f40924daff491f.tar.gz
rneovim-2d99b81ab5b7481e20c03376f0f40924daff491f.tar.bz2
rneovim-2d99b81ab5b7481e20c03376f0f40924daff491f.zip
shell: use msg_outtrans_len_attr for :!cmd
fixes #7830 and #7788
-rw-r--r--src/nvim/eval.c10
-rw-r--r--src/nvim/ex_cmds.c2
-rw-r--r--src/nvim/os/shell.c65
-rw-r--r--src/nvim/quickfix.c5
4 files changed, 32 insertions, 50 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 1d483eee18..923b4527c2 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -19372,14 +19372,10 @@ void ex_echo(exarg_T *eap)
}
msg_putchar_attr((uint8_t)(*p), echo_attr);
} else {
- if (has_mbyte) {
- int i = (*mb_ptr2len)((const char_u *)p);
+ int i = (*mb_ptr2len)((const char_u *)p);
- (void)msg_outtrans_len_attr((char_u *)p, i, echo_attr);
- p += i - 1;
- } else {
- (void)msg_outtrans_len_attr((char_u *)p, 1, echo_attr);
- }
+ (void)msg_outtrans_len_attr((char_u *)p, i, echo_attr);
+ p += i - 1;
}
}
}
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 6ffd255dc7..9cfcecf8ad 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -1175,7 +1175,7 @@ static void do_filter(
// to read the error messages. Otherwise errors are ignored, so you can see
// the error messages from the command that appear on stdout; use 'u' to fix
// the text.
- // Pass on the kShellDoOut flag when the output is being redirected.
+ // Pass on the kShellOptDoOut flag when the output is being redirected.
if (call_shell(
cmd_buf,
kShellOptFilter | shell_flags,
diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c
index c205e4b3af..11e6a76939 100644
--- a/src/nvim/os/shell.c
+++ b/src/nvim/os/shell.c
@@ -123,6 +123,9 @@ int os_call_shell(char_u *cmd, ShellOpts opts, char_u *extra_args)
if (opts & kShellOptRead) {
output_ptr = &output;
forward_output = false;
+ } else if (opts & kShellOptDoOut) {
+ // Caller has already redirected output
+ forward_output = false;
}
}
@@ -257,11 +260,25 @@ static int do_os_system(char **argv,
// busy state.
ui_busy_start();
ui_flush();
+ if (forward_output) {
+ msg_sb_eol();
+ msg_start();
+ msg_no_more = true;
+ lines_left = -1;
+ }
int exitcode = process_wait(proc, -1, NULL);
if (!got_int && out_data_decide_throttle(0)) {
// Last chunk of output was skipped; display it now.
out_data_ring(NULL, SIZE_MAX);
}
+ if (forward_output) {
+ // caller should decide if wait_return is invoked
+ no_wait_return++;
+ msg_end();
+ no_wait_return--;
+ msg_no_more = false;
+ }
+
ui_busy_stop();
// prepare the out parameters if requested
@@ -436,47 +453,17 @@ static void out_data_ring(char *output, size_t size)
static void out_data_append_to_screen(char *output, size_t remaining,
bool new_line)
{
- static colnr_T last_col = 0; // Column of last row to append to.
-
- size_t off = 0;
- int last_row = (int)Rows - 1;
-
- while (output != NULL && off < remaining) {
- // Found end of line?
- if (output[off] == NL) {
- // Can we start a new line or do we need to continue the last one?
- if (last_col == 0) {
- screen_del_lines(0, 0, 1, (int)Rows, NULL);
- }
- screen_puts_len((char_u *)output, (int)off, last_row, last_col, 0);
- last_col = 0;
-
- size_t skip = off + 1;
- output += skip;
- remaining -= skip;
- off = 0;
- continue;
- }
-
- // TODO(bfredl): using msg_puts would be better until
- // terminal emulation is implemented.
- if (output[off] < 0x20) {
- output[off] = ' ';
- }
-
- off++;
- }
+ char *p = output, *end = output + remaining;
+ while (p < end) {
+ if (*p == '\n' || *p == '\r' || *p == TAB) {
+ msg_putchar_attr((uint8_t)(*p), 0);
+ p++;
+ } else {
+ int i = *p ? mb_ptr2len_len((char_u *)p, (int)(end-p)) : 1;
- if (output != NULL && remaining) {
- if (last_col == 0) {
- screen_del_lines(0, 0, 1, (int)Rows, NULL);
+ (void)msg_outtrans_len_attr((char_u *)p, i, 0);
+ p += i;
}
- screen_puts_len((char_u *)output, (int)remaining, last_row, last_col, 0);
- last_col += (colnr_T)remaining;
- }
-
- if (new_line) {
- last_col = 0;
}
ui_flush();
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 63252df3dc..ea2d13761c 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -3148,10 +3148,9 @@ void ex_make(exarg_T *eap)
}
msg_start();
MSG_PUTS(":!");
- msg_outtrans((char_u *) cmd); // show what we are doing
+ msg_outtrans((char_u *)cmd); // show what we are doing
- // let the shell know if we are redirecting output or not
- do_shell((char_u *) cmd, *p_sp != NUL ? kShellOptDoOut : 0);
+ do_shell((char_u *)cmd, 0);
res = qf_init(wp, fname, (eap->cmdidx != CMD_make