253253# define PV_TWK OPT_WIN(WV_TWK)
254254# define PV_TWS OPT_WIN(WV_TWS)
255255# define PV_TWSL OPT_BUF(BV_TWSL)
256+ # define PV_TMOD OPT_WIN(WV_TMOD)
256257#endif
257258#ifdef FEAT_SIGNS
258259# define PV_SCL OPT_WIN(WV_SCL)
@@ -2698,6 +2699,15 @@ static struct vimoption options[] =
26982699#else
26992700 (char_u * )NULL , PV_NONE ,
27002701 {(char_u * )FALSE, (char_u * )FALSE}
2702+ #endif
2703+ SCTX_INIT },
2704+ {"termmode" , "tmod" , P_STRING |P_ALLOCED |P_VI_DEF ,
2705+ #ifdef FEAT_TERMINAL
2706+ (char_u * )VAR_WIN , PV_TMOD ,
2707+ {(char_u * )"" , (char_u * )NULL }
2708+ #else
2709+ (char_u * )NULL , PV_NONE ,
2710+ {(char_u * )NULL , (char_u * )0L }
27012711#endif
27022712 SCTX_INIT },
27032713 {"termwinkey" , "twk" , P_STRING |P_ALLOCED |P_RWIN |P_VI_DEF ,
@@ -3208,6 +3218,9 @@ static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noins
32083218#ifdef FEAT_SIGNS
32093219static char * (p_scl_values []) = {"yes" , "no" , "auto" , NULL };
32103220#endif
3221+ #ifdef FEAT_TERMINAL
3222+ static char * (p_tmod_values []) = {"winpty" , "conpty" , "" , NULL };
3223+ #endif
32113224
32123225static void set_options_default (int opt_flags );
32133226static void set_string_default_esc (char * name , char_u * val , int escape );
@@ -3661,7 +3674,12 @@ set_init_1(int clean_arg)
36613674 {
36623675 char buf [50 ];
36633676
3664- sprintf (buf , "cp%ld" , (long )GetConsoleCP ());
3677+ /* Win32 console: In ConPTY, GetConsoleCP() returns zero.
3678+ * Use an alternative value. */
3679+ if (GetConsoleCP () == 0 )
3680+ sprintf (buf , "cp%ld" , (long )GetACP ());
3681+ else
3682+ sprintf (buf , "cp%ld" , (long )GetConsoleCP ());
36653683 p_tenc = vim_strsave ((char_u * )buf );
36663684 if (p_tenc != NULL )
36673685 {
@@ -7468,14 +7486,14 @@ did_set_string_option(
74687486#endif
74697487
74707488#ifdef FEAT_TERMINAL
7471- /* 'termwinkey' */
7489+ // 'termwinkey'
74727490 else if (varp == & curwin -> w_p_twk )
74737491 {
74747492 if (* curwin -> w_p_twk != NUL
74757493 && string_to_key (curwin -> w_p_twk , TRUE) == 0 )
74767494 errmsg = e_invarg ;
74777495 }
7478- /* 'termwinsize' */
7496+ // 'termwinsize'
74797497 else if (varp == & curwin -> w_p_tws )
74807498 {
74817499 if (* curwin -> w_p_tws != NUL )
@@ -7487,6 +7505,12 @@ did_set_string_option(
74877505 errmsg = e_invarg ;
74887506 }
74897507 }
7508+ // 'termmode'
7509+ else if (varp == & curwin -> w_p_tmod )
7510+ {
7511+ if (check_opt_strings (* varp , p_tmod_values , FALSE) != OK )
7512+ errmsg = e_invarg ;
7513+ }
74907514#endif
74917515
74927516#ifdef FEAT_VARTABS
@@ -8838,7 +8862,7 @@ set_bool_option(
88388862 if (!has_vtp_working ())
88398863 {
88408864 p_tgc = 0 ;
8841- return ( char_u * ) N_ ("E954: 24-bit colors are not supported on this environment" );
8865+ return N_ ("E954: 24-bit colors are not supported on this environment" );
88428866 }
88438867 if (is_term_win32 ())
88448868 swap_tcap ();
@@ -10928,6 +10952,7 @@ get_varp(struct vimoption *p)
1092810952 case PV_TWK : return (char_u * )& (curwin -> w_p_twk );
1092910953 case PV_TWS : return (char_u * )& (curwin -> w_p_tws );
1093010954 case PV_TWSL : return (char_u * )& (curbuf -> b_p_twsl );
10955+ case PV_TMOD : return (char_u * )& (curwin -> w_p_tmod );
1093110956#endif
1093210957
1093310958 case PV_AI : return (char_u * )& (curbuf -> b_p_ai );
@@ -11128,6 +11153,7 @@ copy_winopt(winopt_T *from, winopt_T *to)
1112811153#ifdef FEAT_TERMINAL
1112911154 to -> wo_twk = vim_strsave (from -> wo_twk );
1113011155 to -> wo_tws = vim_strsave (from -> wo_tws );
11156+ to -> wo_tmod = vim_strsave (from -> wo_tmod );
1113111157#endif
1113211158#ifdef FEAT_FOLDING
1113311159 to -> wo_fdc = from -> wo_fdc ;
@@ -11198,6 +11224,7 @@ check_winopt(winopt_T *wop UNUSED)
1119811224#ifdef FEAT_TERMINAL
1119911225 check_string_option (& wop -> wo_twk );
1120011226 check_string_option (& wop -> wo_tws );
11227+ check_string_option (& wop -> wo_tmod );
1120111228#endif
1120211229#ifdef FEAT_LINEBREAK
1120311230 check_string_option (& wop -> wo_briopt );
@@ -11241,6 +11268,7 @@ clear_winopt(winopt_T *wop UNUSED)
1124111268#ifdef FEAT_TERMINAL
1124211269 clear_string_option (& wop -> wo_twk );
1124311270 clear_string_option (& wop -> wo_tws );
11271+ clear_string_option (& wop -> wo_tmod );
1124411272#endif
1124511273}
1124611274
0 commit comments