Mercurial > vim
comparison src/terminal.c @ 11741:b4d8f956eb18 v8.0.0753
patch 8.0.0753: no size reports to a job running in a terminal
commit https://github.com/vim/vim/commit/b13501f7dada4154fc7633d79989d1dab98ae99d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jul 22 22:32:56 2017 +0200
patch 8.0.0753: no size reports to a job running in a terminal
Problem: A job running in a terminal does not get notified of changes in
the terminal size.
Solution: Use ioctl() and SIGWINCH to report the terminal size.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 22 Jul 2017 22:45:04 +0200 |
parents | 1c8ec1029233 |
children | 6141a21dd232 |
comparison
equal
deleted
inserted
replaced
11740:afbd33dc6853 | 11741:b4d8f956eb18 |
---|---|
10 /* | 10 /* |
11 * Terminal window support, see ":help :terminal". | 11 * Terminal window support, see ":help :terminal". |
12 * | 12 * |
13 * There are three parts: | 13 * There are three parts: |
14 * 1. Generic code for all systems. | 14 * 1. Generic code for all systems. |
15 * Uses libvterm for the terminal emulator. | |
15 * 2. The MS-Windows implementation. | 16 * 2. The MS-Windows implementation. |
16 * Uses a hidden console for the terminal emulator. | 17 * Uses winpty. |
17 * 3. The Unix-like implementation. | 18 * 3. The Unix-like implementation. |
18 * Uses libvterm for the terminal emulator directly. | 19 * Uses pseudo-tty's (pty's). |
19 * | 20 * |
20 * For each terminal one VTerm is constructed. This uses libvterm. A copy of | 21 * For each terminal one VTerm is constructed. This uses libvterm. A copy of |
21 * that library is in the libvterm directory. | 22 * that library is in the libvterm directory. |
22 * | 23 * |
23 * When a terminal window is opened, a job is started that will be connected to | 24 * When a terminal window is opened, a job is started that will be connected to |
30 * terminal emulator invokes callbacks when its screen content changes. The | 31 * terminal emulator invokes callbacks when its screen content changes. The |
31 * line range is stored in tl_dirty_row_start and tl_dirty_row_end. Once in a | 32 * line range is stored in tl_dirty_row_start and tl_dirty_row_end. Once in a |
32 * while, if the terminal window is visible, the screen contents is drawn. | 33 * while, if the terminal window is visible, the screen contents is drawn. |
33 * | 34 * |
34 * TODO: | 35 * TODO: |
35 * - When 'termsize' is set and dragging the separator the terminal gets messed | |
36 * up. | |
37 * - set buffer options to be scratch, hidden, nomodifiable, etc. | 36 * - set buffer options to be scratch, hidden, nomodifiable, etc. |
38 * - set buffer name to command, add (1) to avoid duplicates. | 37 * - set buffer name to command, add (1) to avoid duplicates. |
39 * - Add a scrollback buffer (contains lines to scroll off the top). | 38 * - Add a scrollback buffer (contains lines to scroll off the top). |
40 * Can use the buf_T lines, store attributes somewhere else? | 39 * Can use the buf_T lines, store attributes somewhere else? |
41 * - When the job ends: | 40 * - When the job ends: |
603 * If the window was resized a redraw will be triggered and we get here. | 602 * If the window was resized a redraw will be triggered and we get here. |
604 * Adjust the size of the vterm unless 'termsize' specifies a fixed size. | 603 * Adjust the size of the vterm unless 'termsize' specifies a fixed size. |
605 */ | 604 */ |
606 if ((!term->tl_rows_fixed && term->tl_rows != wp->w_height) | 605 if ((!term->tl_rows_fixed && term->tl_rows != wp->w_height) |
607 || (!term->tl_cols_fixed && term->tl_cols != wp->w_width)) | 606 || (!term->tl_cols_fixed && term->tl_cols != wp->w_width)) |
608 vterm_set_size(vterm, | 607 { |
609 term->tl_rows_fixed ? term->tl_rows : wp->w_height, | 608 int rows = term->tl_rows_fixed ? term->tl_rows : wp->w_height; |
610 term->tl_cols_fixed ? term->tl_cols : wp->w_width); | 609 int cols = term->tl_cols_fixed ? term->tl_cols : wp->w_width; |
610 | |
611 vterm_set_size(vterm, rows, cols); | |
612 ch_logn(term->tl_job->jv_channel, "Resizing terminal to %d lines", | |
613 rows); | |
614 | |
615 #if defined(UNIX) | |
616 /* Use an ioctl() to report the new window size to the job. */ | |
617 if (term->tl_job != NULL && term->tl_job->jv_channel != NULL) | |
618 { | |
619 int fd = -1; | |
620 int part; | |
621 | |
622 for (part = PART_OUT; part < PART_COUNT; ++part) | |
623 { | |
624 fd = term->tl_job->jv_channel->ch_part[part].ch_fd; | |
625 if (isatty(fd)) | |
626 break; | |
627 } | |
628 if (part < PART_COUNT && mch_report_winsize(fd, rows, cols) == OK) | |
629 mch_stop_job(term->tl_job, (char_u *)"winch"); | |
630 } | |
631 #endif | |
632 } | |
611 | 633 |
612 /* The cursor may have been moved when resizing. */ | 634 /* The cursor may have been moved when resizing. */ |
613 vterm_state_get_cursorpos(state, &pos); | 635 vterm_state_get_cursorpos(state, &pos); |
614 position_cursor(wp, &pos); | 636 position_cursor(wp, &pos); |
615 | 637 |