terminal: Disable some options in terminal-mode.

In terminal-mode these options are nonsense because cursor is placed at
end of buffer to "follow" output.

Closes #2259
This commit is contained in:
Justin M. Keyes 2017-02-27 10:49:48 +01:00
parent 937e54f865
commit 857113ca8c
2 changed files with 21 additions and 6 deletions

View File

@ -322,7 +322,7 @@ static void parse_msgpack(Stream *stream, RBuffer *rbuf, size_t c, void *data,
if (eof) { if (eof) {
close_channel(channel); close_channel(channel);
char buf[256]; char buf[256];
snprintf(buf, sizeof(buf), "channel %" PRIu64 " was closed by the client", snprintf(buf, sizeof(buf), "ch %" PRIu64 " was closed by the client",
channel->id); channel->id);
call_set_error(channel, buf); call_set_error(channel, buf);
goto end; goto end;
@ -352,8 +352,8 @@ static void parse_msgpack(Stream *stream, RBuffer *rbuf, size_t c, void *data,
} else { } else {
char buf[256]; char buf[256];
snprintf(buf, sizeof(buf), snprintf(buf, sizeof(buf),
"channel %" PRIu64 " sent a response without a matching " "ch %" PRIu64 " returned a response with an unknown request "
"request id. Ensure the client is properly synchronized", "id. Ensure the client is properly synchronized",
channel->id); channel->id);
call_set_error(channel, buf); call_set_error(channel, buf);
} }
@ -405,7 +405,7 @@ static void handle_request(Channel *channel, msgpack_object *request)
&out_buffer))) { &out_buffer))) {
char buf[256]; char buf[256];
snprintf(buf, sizeof(buf), snprintf(buf, sizeof(buf),
"channel %" PRIu64 " sent an invalid message, closed.", "ch %" PRIu64 " sent an invalid message, closed.",
channel->id); channel->id);
call_set_error(channel, buf); call_set_error(channel, buf);
} }
@ -497,7 +497,7 @@ static bool channel_write(Channel *channel, WBuffer *buffer)
char buf[256]; char buf[256];
snprintf(buf, snprintf(buf,
sizeof(buf), sizeof(buf),
"Before returning from a RPC call, channel %" PRIu64 " was " "Before returning from a RPC call, ch %" PRIu64 " was "
"closed due to a failed write", "closed due to a failed write",
channel->id); channel->id);
call_set_error(channel, buf); call_set_error(channel, buf);

View File

@ -232,8 +232,9 @@ Terminal *terminal_open(TerminalOptions opts)
// Default settings for terminal buffers // Default settings for terminal buffers
curbuf->b_p_ma = false; // 'nomodifiable' curbuf->b_p_ma = false; // 'nomodifiable'
curbuf->b_p_ul = -1; // disable undo curbuf->b_p_ul = -1; // 'undolevels'
curbuf->b_p_scbk = 1000; // 'scrollback' curbuf->b_p_scbk = 1000; // 'scrollback'
curbuf->b_p_tw = 0; // 'textwidth'
set_option_value((uint8_t *)"wrap", false, NULL, OPT_LOCAL); set_option_value((uint8_t *)"wrap", false, NULL, OPT_LOCAL);
set_option_value((uint8_t *)"number", false, NULL, OPT_LOCAL); set_option_value((uint8_t *)"number", false, NULL, OPT_LOCAL);
set_option_value((uint8_t *)"relativenumber", false, NULL, OPT_LOCAL); set_option_value((uint8_t *)"relativenumber", false, NULL, OPT_LOCAL);
@ -370,6 +371,16 @@ void terminal_enter(void)
State = TERM_FOCUS; State = TERM_FOCUS;
mapped_ctrl_c |= TERM_FOCUS; // Always map CTRL-C to avoid interrupt. mapped_ctrl_c |= TERM_FOCUS; // Always map CTRL-C to avoid interrupt.
RedrawingDisabled = false; RedrawingDisabled = false;
// Disable these options in terminal-mode. They are nonsense because cursor is
// placed at end of buffer to "follow" output.
int save_w_p_cul = curwin->w_p_cul;
int save_w_p_cuc = curwin->w_p_cuc;
int save_w_p_rnu = curwin->w_p_rnu;
curwin->w_p_cul = false;
curwin->w_p_cuc = false;
curwin->w_p_rnu = false;
adjust_topline(s->term, buf, 0); // scroll to end adjust_topline(s->term, buf, 0); // scroll to end
// erase the unfocused cursor // erase the unfocused cursor
invalidate_terminal(s->term, s->term->cursor.row, s->term->cursor.row + 1); invalidate_terminal(s->term, s->term->cursor.row, s->term->cursor.row + 1);
@ -383,6 +394,10 @@ void terminal_enter(void)
restart_edit = 0; restart_edit = 0;
State = save_state; State = save_state;
RedrawingDisabled = s->save_rd; RedrawingDisabled = s->save_rd;
curwin->w_p_cul = save_w_p_cul;
curwin->w_p_cuc = save_w_p_cuc;
curwin->w_p_rnu = save_w_p_rnu;
// draw the unfocused cursor // draw the unfocused cursor
invalidate_terminal(s->term, s->term->cursor.row, s->term->cursor.row + 1); invalidate_terminal(s->term, s->term->cursor.row, s->term->cursor.row + 1);
unshowmode(true); unshowmode(true);