Skip to content

Commit

Permalink
patch 8.0.0718: output of job in terminal is not displayed
Browse files Browse the repository at this point in the history
Problem:    Output of job in terminal is not displayed.
Solution:   Connect the job output to the terminal.
  • Loading branch information
brammool committed Jul 16, 2017
1 parent 26e8558 commit cb8bbe9
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 38 deletions.
24 changes: 17 additions & 7 deletions src/channel.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ ch_log(channel_T *ch, char *msg)
} }
} }


static void void
ch_logn(channel_T *ch, char *msg, int nr) ch_logn(channel_T *ch, char *msg, int nr)
{ {
if (log_fd != NULL) if (log_fd != NULL)
Expand Down Expand Up @@ -2656,7 +2656,12 @@ may_invoke_callback(channel_T *channel, ch_part_T part)
/* JSON or JS mode: re-encode the message. */ /* JSON or JS mode: re-encode the message. */
msg = json_encode(listtv, ch_mode); msg = json_encode(listtv, ch_mode);
if (msg != NULL) if (msg != NULL)
append_to_buffer(buffer, msg, channel, part); {
if (buffer->b_term != NULL)
write_to_term(buffer, msg, channel);
else
append_to_buffer(buffer, msg, channel, part);
}
} }


if (callback != NULL) if (callback != NULL)
Expand Down Expand Up @@ -4889,7 +4894,7 @@ job_check_ended(void)
* "job_start()" function * "job_start()" function
*/ */
job_T * job_T *
job_start(typval_T *argvars) job_start(typval_T *argvars, jobopt_T *opt_arg)
{ {
job_T *job; job_T *job;
char_u *cmd = NULL; char_u *cmd = NULL;
Expand All @@ -4912,13 +4917,18 @@ job_start(typval_T *argvars)
ga_init2(&ga, (int)sizeof(char*), 20); ga_init2(&ga, (int)sizeof(char*), 20);
#endif #endif


/* Default mode is NL. */ if (opt_arg != NULL)
clear_job_options(&opt); opt = *opt_arg;
opt.jo_mode = MODE_NL; else
if (get_job_options(&argvars[1], &opt, {
/* Default mode is NL. */
clear_job_options(&opt);
opt.jo_mode = MODE_NL;
if (get_job_options(&argvars[1], &opt,
JO_MODE_ALL + JO_CB_ALL + JO_TIMEOUT_ALL + JO_STOPONEXIT JO_MODE_ALL + JO_CB_ALL + JO_TIMEOUT_ALL + JO_STOPONEXIT
+ JO_EXIT_CB + JO_OUT_IO + JO_BLOCK_WRITE) == FAIL) + JO_EXIT_CB + JO_OUT_IO + JO_BLOCK_WRITE) == FAIL)
goto theend; goto theend;
}


/* Check that when io is "file" that there is a file name. */ /* Check that when io is "file" that there is a file name. */
for (part = PART_OUT; part < PART_COUNT; ++part) for (part = PART_OUT; part < PART_COUNT; ++part)
Expand Down
2 changes: 1 addition & 1 deletion src/evalfunc.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6745,7 +6745,7 @@ f_job_start(typval_T *argvars, typval_T *rettv)
rettv->v_type = VAR_JOB; rettv->v_type = VAR_JOB;
if (check_restricted() || check_secure()) if (check_restricted() || check_secure())
return; return;
rettv->vval.v_job = job_start(argvars); rettv->vval.v_job = job_start(argvars, NULL);
} }


/* /*
Expand Down
3 changes: 2 additions & 1 deletion src/proto/channel.pro
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
void ch_logfile(char_u *fname, char_u *opt); void ch_logfile(char_u *fname, char_u *opt);
int ch_log_active(void); int ch_log_active(void);
void ch_log(channel_T *ch, char *msg); void ch_log(channel_T *ch, char *msg);
void ch_logn(channel_T *ch, char *msg, int nr);
void ch_logs(channel_T *ch, char *msg, char *name); void ch_logs(channel_T *ch, char *msg, char *name);
channel_T *add_channel(void); channel_T *add_channel(void);
int has_any_channel(void); int has_any_channel(void);
Expand Down Expand Up @@ -63,7 +64,7 @@ void job_set_options(job_T *job, jobopt_T *opt);
void job_stop_on_exit(void); void job_stop_on_exit(void);
int has_pending_job(void); int has_pending_job(void);
void job_check_ended(void); void job_check_ended(void);
job_T *job_start(typval_T *argvars); job_T *job_start(typval_T *argvars, jobopt_T *opt_arg);
char *job_status(job_T *job); char *job_status(job_T *job);
void job_info(job_T *job, dict_T *dict); void job_info(job_T *job, dict_T *dict);
int job_stop(job_T *job, typval_T *argvars); int job_stop(job_T *job, typval_T *argvars);
Expand Down
2 changes: 2 additions & 0 deletions src/proto/screen.pro
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ void conceal_check_cursur_line(void);
void update_single_line(win_T *wp, linenr_T lnum); void update_single_line(win_T *wp, linenr_T lnum);
void update_debug_sign(buf_T *buf, linenr_T lnum); void update_debug_sign(buf_T *buf, linenr_T lnum);
void updateWindow(win_T *wp); void updateWindow(win_T *wp);
int screen_get_current_line_off(void);
void screen_line(int row, int coloff, int endcol, int clear_width, int rlflag);
void rl_mirror(char_u *str); void rl_mirror(char_u *str);
void status_redraw_all(void); void status_redraw_all(void);
void status_redraw_curbuf(void); void status_redraw_curbuf(void);
Expand Down
2 changes: 2 additions & 0 deletions src/proto/terminal.pro
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,5 @@
/* terminal.c */ /* terminal.c */
void ex_terminal(exarg_T *eap); void ex_terminal(exarg_T *eap);
void write_to_term(buf_T *buffer, char_u *msg, channel_T *channel);
void term_update_window(win_T *wp);
/* vim: set ft=c : */ /* vim: set ft=c : */
50 changes: 31 additions & 19 deletions src/screen.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -126,13 +126,6 @@ static void copy_text_attr(int off, char_u *buf, int len, int attr);
#endif #endif
static int win_line(win_T *, linenr_T, int, int, int nochange, proftime_T *syntax_tm); static int win_line(win_T *, linenr_T, int, int, int nochange, proftime_T *syntax_tm);
static int char_needs_redraw(int off_from, int off_to, int cols); static int char_needs_redraw(int off_from, int off_to, int cols);
#ifdef FEAT_RIGHTLEFT
static void screen_line(int row, int coloff, int endcol, int clear_width, int rlflag);
# define SCREEN_LINE(r, o, e, c, rl) screen_line((r), (o), (e), (c), (rl))
#else
static void screen_line(int row, int coloff, int endcol, int clear_width);
# define SCREEN_LINE(r, o, e, c, rl) screen_line((r), (o), (e), (c))
#endif
#ifdef FEAT_WINDOWS #ifdef FEAT_WINDOWS
static void draw_vsep_win(win_T *wp, int row); static void draw_vsep_win(win_T *wp, int row);
#endif #endif
Expand Down Expand Up @@ -411,7 +404,7 @@ redraw_asap(int type)
screenline2 + r * cols, screenline2 + r * cols,
(size_t)cols * sizeof(schar_T)); (size_t)cols * sizeof(schar_T));
#endif #endif
SCREEN_LINE(cmdline_row + r, 0, cols, cols, FALSE); screen_line(cmdline_row + r, 0, cols, cols, FALSE);
} }
ret = 4; ret = 4;
} }
Expand Down Expand Up @@ -1192,6 +1185,17 @@ win_update(win_T *wp)
} }
#endif #endif


#ifdef FEAT_TERMINAL
if (wp->w_buffer->b_term != NULL)
{
/* This window contains a terminal, redraw works completely
* differently. */
term_update_window(wp);
wp->w_redr_type = 0;
return;
}
#endif

#ifdef FEAT_SEARCH_EXTRA #ifdef FEAT_SEARCH_EXTRA
init_search_hl(wp); init_search_hl(wp);
#endif #endif
Expand Down Expand Up @@ -2886,7 +2890,7 @@ fold_line(
} }
#endif #endif


SCREEN_LINE(row + W_WINROW(wp), W_WINCOL(wp), (int)W_WIDTH(wp), screen_line(row + W_WINROW(wp), W_WINCOL(wp), (int)W_WIDTH(wp),
(int)W_WIDTH(wp), FALSE); (int)W_WIDTH(wp), FALSE);


/* /*
Expand Down Expand Up @@ -3996,7 +4000,7 @@ win_line(
#endif #endif
) )
{ {
SCREEN_LINE(screen_row, W_WINCOL(wp), col, -(int)W_WIDTH(wp), screen_line(screen_row, W_WINCOL(wp), col, -(int)W_WIDTH(wp),
wp->w_p_rl); wp->w_p_rl);
/* Pretend we have finished updating the window. Except when /* Pretend we have finished updating the window. Except when
* 'cursorcolumn' is set. */ * 'cursorcolumn' is set. */
Expand Down Expand Up @@ -5443,7 +5447,7 @@ win_line(
} }
#endif #endif


SCREEN_LINE(screen_row, W_WINCOL(wp), col, screen_line(screen_row, W_WINCOL(wp), col,
(int)W_WIDTH(wp), wp->w_p_rl); (int)W_WIDTH(wp), wp->w_p_rl);
row++; row++;


Expand Down Expand Up @@ -5749,11 +5753,11 @@ win_line(
) )
{ {
#ifdef FEAT_CONCEAL #ifdef FEAT_CONCEAL
SCREEN_LINE(screen_row, W_WINCOL(wp), col - boguscols, screen_line(screen_row, W_WINCOL(wp), col - boguscols,
(int)W_WIDTH(wp), wp->w_p_rl); (int)W_WIDTH(wp), wp->w_p_rl);
boguscols = 0; boguscols = 0;
#else #else
SCREEN_LINE(screen_row, W_WINCOL(wp), col, screen_line(screen_row, W_WINCOL(wp), col,
(int)W_WIDTH(wp), wp->w_p_rl); (int)W_WIDTH(wp), wp->w_p_rl);
#endif #endif
++row; ++row;
Expand Down Expand Up @@ -5959,6 +5963,17 @@ char_needs_redraw(int off_from, int off_to, int cols)
return FALSE; return FALSE;
} }


#if defined(FEAT_TERMINAL) || defined(PROTO)
/*
* Return the index in ScreenLines[] for the current screen line.
*/
int
screen_get_current_line_off()
{
return (int)(current_ScreenLine - ScreenLines);
}
#endif

/* /*
* Move one "cooked" screen line to the screen, but only the characters that * Move one "cooked" screen line to the screen, but only the characters that
* have actually changed. Handle insert/delete character. * have actually changed. Handle insert/delete character.
Expand All @@ -5970,16 +5985,13 @@ char_needs_redraw(int off_from, int off_to, int cols)
* When TRUE and "clear_width" > 0, clear columns 0 to "endcol" * When TRUE and "clear_width" > 0, clear columns 0 to "endcol"
* When FALSE and "clear_width" > 0, clear columns "endcol" to "clear_width" * When FALSE and "clear_width" > 0, clear columns "endcol" to "clear_width"
*/ */
static void void
screen_line( screen_line(
int row, int row,
int coloff, int coloff,
int endcol, int endcol,
int clear_width int clear_width,
#ifdef FEAT_RIGHTLEFT int rlflag UNUSED)
, int rlflag
#endif
)
{ {
unsigned off_from; unsigned off_from;
unsigned off_to; unsigned off_to;
Expand Down
Loading

0 comments on commit cb8bbe9

Please sign in to comment.