42
42
* redirection. Probably in call to channel_set_pipes().
43
43
* - Win32: Redirecting output does not work, Test_terminal_redir_file()
44
44
* is disabled.
45
- * - Copy text in the vterm to the Vim buffer once in a while, so that
46
- * completion works.
47
45
* - When starting terminal window with shell in terminal, then using :gui to
48
46
* switch to GUI, shell stops working. Scrollback seems wrong, command
49
47
* 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?
59
48
* - 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.
60
51
* - Redrawing is slow with Athena and Motif. Also other GUI? (Ramel Eshed)
61
52
* - For the GUI fill termios with default values, perhaps like pangoterm:
62
53
* http://bazaar.launchpad.net/~leonerd/pangoterm/trunk/view/head:/main.c#L134
63
54
* - When 'encoding' is not utf-8, or the job is using another encoding, setup
64
55
* 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.
65
59
*/
66
60
67
61
#include "vim.h"
@@ -133,9 +127,6 @@ struct terminal_S {
133
127
/* last known vterm size */
134
128
int tl_rows ;
135
129
int tl_cols ;
136
- /* vterm size does not follow window size */
137
- int tl_rows_fixed ;
138
- int tl_cols_fixed ;
139
130
140
131
char_u * tl_title ; /* NULL or allocated */
141
132
char_u * tl_status_text ; /* NULL or allocated */
@@ -207,9 +198,38 @@ static int desired_cursor_blink = -1;
207
198
* 1. Generic code for all systems.
208
199
*/
209
200
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
+
210
231
/*
211
232
* Determine the terminal size from 'termsize' and the current window.
212
- * Assumes term->tl_rows and term->tl_cols are zero.
213
233
*/
214
234
static void
215
235
set_term_and_win_size (term_T * term )
@@ -224,27 +244,21 @@ set_term_and_win_size(term_T *term)
224
244
return ;
225
245
}
226
246
#endif
227
- if (* curwin -> w_p_tms != NUL )
247
+ if (parse_termsize ( curwin , & term -> tl_rows , & term -> tl_cols ) )
228
248
{
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 );
233
253
}
234
254
if (term -> tl_rows == 0 )
235
255
term -> tl_rows = curwin -> w_height ;
236
256
else
237
- {
238
257
win_setheight_win (term -> tl_rows , curwin );
239
- term -> tl_rows_fixed = TRUE;
240
- }
241
258
if (term -> tl_cols == 0 )
242
259
term -> tl_cols = curwin -> w_width ;
243
260
else
244
- {
245
261
win_setwidth_win (term -> tl_cols , curwin );
246
- term -> tl_cols_fixed = TRUE;
247
- }
248
262
}
249
263
250
264
/*
@@ -2853,6 +2867,10 @@ term_update_window(win_T *wp)
2853
2867
VTermScreen * screen ;
2854
2868
VTermState * state ;
2855
2869
VTermPos pos ;
2870
+ int rows , cols ;
2871
+ int newrows , newcols ;
2872
+ int minsize ;
2873
+ win_T * twp ;
2856
2874
2857
2875
if (term == NULL || term -> tl_vterm == NULL || term -> tl_normal_mode )
2858
2876
return FAIL ;
@@ -2871,31 +2889,32 @@ term_update_window(win_T *wp)
2871
2889
* If the window was resized a redraw will be triggered and we get here.
2872
2890
* Adjust the size of the vterm unless 'termsize' specifies a fixed size.
2873
2891
*/
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 );
2880
2893
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 )
2882
2901
{
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 );
2892
2904
}
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
+
2893
2912
2894
2913
term -> tl_vterm_size_changed = TRUE;
2895
- vterm_set_size (vterm , rows , cols );
2914
+ vterm_set_size (vterm , newrows , newcols );
2896
2915
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 );
2899
2918
}
2900
2919
2901
2920
/* The cursor may have been moved when resizing. */
0 commit comments