static void term_report_winsize(term_T *term, int rows, int cols);
static void term_free_vterm(term_T *term);
-/* The characters that we know (or assume) that the terminal expects for the
- * backspace and enter keys. */
+/* The character that we know (or assume) that the terminal expects for the
+ * backspace key. */
static int term_backspace_char = BS;
-static int term_enter_char = CAR;
-static int term_nl_does_cr = FALSE;
/**************************************
term_write_job_output(term_T *term, char_u *msg, size_t len)
{
VTerm *vterm = term->tl_vterm;
- char_u *p;
- size_t done;
- size_t len_now;
- if (term_nl_does_cr)
- vterm_input_write(vterm, (char *)msg, len);
- else
- /* need to convert NL to CR-NL */
- for (done = 0; done < len; done += len_now)
- {
- for (p = msg + done; p < msg + len; )
- {
- if (*p == NL)
- break;
- p += utf_ptr2len_len(p, (int)(len - (p - msg)));
- }
- len_now = p - msg - done;
- vterm_input_write(vterm, (char *)msg + done, len_now);
- if (p < msg + len && *p == NL)
- {
- vterm_input_write(vterm, "\r\n", 2);
- ++len_now;
- }
- }
+ vterm_input_write(vterm, (char *)msg, len);
/* this invokes the damage callbacks */
vterm_screen_flush_damage(vterm_obtain_screen(vterm));
switch (c)
{
- case CAR: c = term_enter_char; break;
+ /* don't use VTERM_KEY_ENTER, it may do an unwanted conversion */
+
/* don't use VTERM_KEY_BACKSPACE, it always
* becomes 0x7f DEL */
case K_BS: c = term_backspace_char; break;
int termkey = 0;
int ret;
#ifdef UNIX
- int tty_fd = curbuf->b_term->tl_job->jv_channel->ch_part[get_tty_part(curbuf->b_term)].ch_fd;
+ int tty_fd = curbuf->b_term->tl_job->jv_channel
+ ->ch_part[get_tty_part(curbuf->b_term)].ch_fd;
#endif
/* Remember the terminal we are sending keys to. However, the terminal
break;
update_cursor(curbuf->b_term, FALSE);
+ c = term_vgetc();
+ if (!term_use_loop())
+ {
+ /* Job finished while waiting for a character. Push back the
+ * received character. */
+ if (c != K_IGNORE)
+ vungetc(c);
+ break;
+ }
+ if (c == K_IGNORE)
+ continue;
+
#ifdef UNIX
/*
* The shell or another program may change the tty settings. Getting
* them for every typed character is a bit of overhead, but it's needed
- * for the first CR typed, e.g. when Vim starts in a shell.
+ * for the first character typed, e.g. when Vim starts in a shell.
*/
if (isatty(tty_fd))
{
ttyinfo_T info;
- /* Get the current backspace and enter characters of the pty. */
+ /* Get the current backspace character of the pty. */
if (get_tty_info(tty_fd, &info) == OK)
- {
term_backspace_char = info.backspace;
- term_enter_char = info.enter;
- term_nl_does_cr = info.nl_does_cr;
- }
}
#endif
- c = term_vgetc();
- if (!term_use_loop())
- {
- /* job finished while waiting for a character */
- if (c != K_IGNORE)
- vungetc(c);
- break;
- }
- if (c == K_IGNORE)
- continue;
-
#ifdef WIN3264
/* On Windows winpty handles CTRL-C, don't send a CTRL_C_EVENT.
* Use CTRL-BREAK to kill the job. */