os/shell: remove dead calls to screen functions

This commit is contained in:
Björn Linse 2018-04-09 10:10:06 +02:00
parent fa6415f13f
commit c28dbede27

View File

@ -136,7 +136,7 @@ int os_call_shell(char_u *cmd, ShellOpts opts, char_u *extra_args)
xfree(input.data); xfree(input.data);
if (output) { if (output) {
(void)write_output(output, nread, true, true); (void)write_output(output, nread, true);
xfree(output); xfree(output);
} }
@ -609,28 +609,20 @@ static void read_input(DynamicBuffer *buf)
} }
} }
static size_t write_output(char *output, size_t remaining, bool to_buffer, static size_t write_output(char *output, size_t remaining, bool eof)
bool eof)
{ {
if (!output) { if (!output) {
return 0; return 0;
} }
char replacement_NUL = to_buffer ? NL : 1;
char *start = output; char *start = output;
size_t off = 0; size_t off = 0;
int lastrow = (int)Rows - 1;
while (off < remaining) { while (off < remaining) {
if (output[off] == NL) { if (output[off] == NL) {
// Insert the line // Insert the line
if (to_buffer) { output[off] = NUL;
output[off] = NUL; ml_append(curwin->w_cursor.lnum++, (char_u *)output, (int)off + 1,
ml_append(curwin->w_cursor.lnum++, (char_u *)output, (int)off + 1, false);
false);
} else {
screen_del_lines(0, 0, 1, (int)Rows, NULL);
screen_puts_len((char_u *)output, (int)off, lastrow, 0, 0);
}
size_t skip = off + 1; size_t skip = off + 1;
output += skip; output += skip;
remaining -= skip; remaining -= skip;
@ -640,24 +632,19 @@ static size_t write_output(char *output, size_t remaining, bool to_buffer,
if (output[off] == NUL) { if (output[off] == NUL) {
// Translate NUL to NL // Translate NUL to NL
output[off] = replacement_NUL; output[off] = NL;
} }
off++; off++;
} }
if (eof) { if (eof) {
if (remaining) { if (remaining) {
if (to_buffer) { // append unfinished line
// append unfinished line ml_append(curwin->w_cursor.lnum++, (char_u *)output, 0, false);
ml_append(curwin->w_cursor.lnum++, (char_u *)output, 0, false); // remember that the NL was missing
// remember that the NL was missing curbuf->b_no_eol_lnum = curwin->w_cursor.lnum;
curbuf->b_no_eol_lnum = curwin->w_cursor.lnum;
} else {
screen_del_lines(0, 0, 1, (int)Rows, NULL);
screen_puts_len((char_u *)output, (int)remaining, lastrow, 0, 0);
}
output += remaining; output += remaining;
} else if (to_buffer) { } else {
curbuf->b_no_eol_lnum = 0; curbuf->b_no_eol_lnum = 0;
} }
} }