4242 * redirection. Probably in call to channel_set_pipes().
4343 * - Win32: Redirecting output does not work, Test_terminal_redir_file()
4444 * is disabled.
45- * - Copy text in the vterm to the Vim buffer once in a while, so that
46- * completion works.
4745 * - When starting terminal window with shell in terminal, then using :gui to
4846 * switch to GUI, shell stops working. Scrollback seems wrong, command
4947 * running in shell is still running.
50- * - in GUI vertical split causes problems. Cursor is flickering. (Hirohito
51- * Higashi, 2017 Sep 19)
52- * - after resizing windows overlap. (Boris Staletic, #2164)
53- * - cursor blinks in terminal on widows with a timer. (xtal8, #2142)
54- * - Termdebug does not work when Vim build with mzscheme. gdb hangs.
55- * - After executing a shell command the status line isn't redraw.
56- * - add test for giving error for invalid 'termsize' value.
57- * - support minimal size when 'termsize' is "rows*cols".
58- * - support minimal size when 'termsize' is empty?
5948 * - GUI: when using tabs, focus in terminal, click on tab does not work.
49+ * - Copy text in the vterm to the Vim buffer once in a while, so that
50+ * completion works.
6051 * - Redrawing is slow with Athena and Motif. Also other GUI? (Ramel Eshed)
6152 * - For the GUI fill termios with default values, perhaps like pangoterm:
6253 * http://bazaar.launchpad.net/~leonerd/pangoterm/trunk/view/head:/main.c#L134
6354 * - When 'encoding' is not utf-8, or the job is using another encoding, setup
6455 * conversions.
56+ * - Termdebug does not work when Vim build with mzscheme: gdb hangs just after
57+ * "run". Everything else works, including communication channel. Not
58+ * initializing mzscheme avoid the problem, thus it's not some #ifdef.
6559 */
6660
6761#include "vim.h"
@@ -133,9 +127,6 @@ struct terminal_S {
133127 /* last known vterm size */
134128 int tl_rows ;
135129 int tl_cols ;
136- /* vterm size does not follow window size */
137- int tl_rows_fixed ;
138- int tl_cols_fixed ;
139130
140131 char_u * tl_title ; /* NULL or allocated */
141132 char_u * tl_status_text ; /* NULL or allocated */
@@ -207,9 +198,38 @@ static int desired_cursor_blink = -1;
207198 * 1. Generic code for all systems.
208199 */
209200
201+ /*
202+ * Parse 'termsize' and set "rows" and "cols" for the terminal size in the
203+ * current window.
204+ * Sets "rows" and/or "cols" to zero when it should follow the window size.
205+ * Return TRUE if the size is the minimum size: "24*80".
206+ */
207+ static int
208+ parse_termsize (win_T * wp , int * rows , int * cols )
209+ {
210+ int minsize = FALSE;
211+
212+ * rows = 0 ;
213+ * cols = 0 ;
214+
215+ if (* wp -> w_p_tms != NUL )
216+ {
217+ char_u * p = vim_strchr (wp -> w_p_tms , 'x' );
218+
219+ /* Syntax of value was already checked when it's set. */
220+ if (p == NULL )
221+ {
222+ minsize = TRUE;
223+ p = vim_strchr (wp -> w_p_tms , '*' );
224+ }
225+ * rows = atoi ((char * )wp -> w_p_tms );
226+ * cols = atoi ((char * )p + 1 );
227+ }
228+ return minsize ;
229+ }
230+
210231/*
211232 * Determine the terminal size from 'termsize' and the current window.
212- * Assumes term->tl_rows and term->tl_cols are zero.
213233 */
214234 static void
215235set_term_and_win_size (term_T * term )
@@ -224,27 +244,21 @@ set_term_and_win_size(term_T *term)
224244 return ;
225245 }
226246#endif
227- if (* curwin -> w_p_tms != NUL )
247+ if (parse_termsize ( curwin , & term -> tl_rows , & term -> tl_cols ) )
228248 {
229- char_u * p = vim_strchr ( curwin -> w_p_tms , 'x' ) + 1 ;
230-
231- term -> tl_rows = atoi (( char * ) curwin -> w_p_tms );
232- term -> tl_cols = atoi (( char * ) p );
249+ if ( term -> tl_rows != 0 )
250+ term -> tl_rows = MAX ( term -> tl_rows , curwin -> w_height );
251+ if ( term -> tl_cols != 0 )
252+ term -> tl_cols = MAX ( term -> tl_cols , curwin -> w_width );
233253 }
234254 if (term -> tl_rows == 0 )
235255 term -> tl_rows = curwin -> w_height ;
236256 else
237- {
238257 win_setheight_win (term -> tl_rows , curwin );
239- term -> tl_rows_fixed = TRUE;
240- }
241258 if (term -> tl_cols == 0 )
242259 term -> tl_cols = curwin -> w_width ;
243260 else
244- {
245261 win_setwidth_win (term -> tl_cols , curwin );
246- term -> tl_cols_fixed = TRUE;
247- }
248262}
249263
250264/*
@@ -2853,6 +2867,10 @@ term_update_window(win_T *wp)
28532867 VTermScreen * screen ;
28542868 VTermState * state ;
28552869 VTermPos pos ;
2870+ int rows , cols ;
2871+ int newrows , newcols ;
2872+ int minsize ;
2873+ win_T * twp ;
28562874
28572875 if (term == NULL || term -> tl_vterm == NULL || term -> tl_normal_mode )
28582876 return FAIL ;
@@ -2871,31 +2889,32 @@ term_update_window(win_T *wp)
28712889 * If the window was resized a redraw will be triggered and we get here.
28722890 * Adjust the size of the vterm unless 'termsize' specifies a fixed size.
28732891 */
2874- if ((!term -> tl_rows_fixed && term -> tl_rows != wp -> w_height )
2875- || (!term -> tl_cols_fixed && term -> tl_cols != wp -> w_width ))
2876- {
2877- int rows = term -> tl_rows_fixed ? term -> tl_rows : wp -> w_height ;
2878- int cols = term -> tl_cols_fixed ? term -> tl_cols : wp -> w_width ;
2879- win_T * twp ;
2892+ minsize = parse_termsize (wp , & rows , & cols );
28802893
2881- FOR_ALL_WINDOWS (twp )
2894+ newrows = 99999 ;
2895+ newcols = 99999 ;
2896+ FOR_ALL_WINDOWS (twp )
2897+ {
2898+ /* When more than one window shows the same terminal, use the
2899+ * smallest size. */
2900+ if (twp -> w_buffer == term -> tl_buffer )
28822901 {
2883- /* When more than one window shows the same terminal, use the
2884- * smallest size. */
2885- if (twp -> w_buffer == term -> tl_buffer )
2886- {
2887- if (!term -> tl_rows_fixed && rows > twp -> w_height )
2888- rows = twp -> w_height ;
2889- if (!term -> tl_cols_fixed && cols > twp -> w_width )
2890- cols = twp -> w_width ;
2891- }
2902+ newrows = MIN (newrows , twp -> w_height );
2903+ newcols = MIN (newcols , twp -> w_width );
28922904 }
2905+ }
2906+ newrows = rows == 0 ? newrows : minsize ? MAX (rows , newrows ) : rows ;
2907+ newcols = cols == 0 ? newcols : minsize ? MAX (cols , newcols ) : cols ;
2908+
2909+ if (term -> tl_rows != newrows || term -> tl_cols != newcols )
2910+ {
2911+
28932912
28942913 term -> tl_vterm_size_changed = TRUE;
2895- vterm_set_size (vterm , rows , cols );
2914+ vterm_set_size (vterm , newrows , newcols );
28962915 ch_log (term -> tl_job -> jv_channel , "Resizing terminal to %d lines" ,
2897- rows );
2898- term_report_winsize (term , rows , cols );
2916+ newrows );
2917+ term_report_winsize (term , newrows , newcols );
28992918 }
29002919
29012920 /* The cursor may have been moved when resizing. */
0 commit comments