Skip to content

Commit

Permalink
settings -P/--pcon/ConPTY to enable/disable ConPTY support (mintty/ws…
Browse files Browse the repository at this point in the history
  • Loading branch information
mintty committed Feb 10, 2021
1 parent d787232 commit 6999ae7
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
10 changes: 10 additions & 0 deletions docs/mintty.1
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ options AppName and AppLaunchCmd.
\fB--nopin\fP
Prevent pinning of the mintty window to the Windows taskbar.

.TP
\fB-P\fP, \fB--pcon\fP [\fBon\fP|\fBoff\fP]
Enforce enabling or disabling of ConPTY support.

.TP
\fB--wsl\fP (preferred option: \fB--WSL\fP, see below)
Adjust to WSL (the Windows Subsystem for Linux, or Bash/Ubuntu on Windows):
Expand Down Expand Up @@ -2459,6 +2463,12 @@ a specific AppID cannot be removed or even modified again with normal means.
For this reason, it is advisable to use temporary AppIDs for testing
(like MyMintty.1).

.TP
\fBControl ConPTY support\fP (ConPTY=)
Setting this on or off enforces enabled or disabled support of pseudo console
for native Windows programs. The default is to leave it up to the default
of the system environment (cygwin or MSYS2).

.TP
\fBWord selection characters\fP (WordChars=)
By default, this string setting is empty, in which case double-click word
Expand Down
2 changes: 2 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ const config default_cfg = {
.user_commands_path = W("/bin:%s"),
.session_commands = W(""),
.task_commands = W(""),
.conpty_support = -1,
.menu_mouse = "b",
.menu_ctrlmouse = "e|ls",
.menu_altmouse = "ls",
Expand Down Expand Up @@ -494,6 +495,7 @@ options[] = {
{"UserCommandsPath", OPT_WSTRING, offcfg(user_commands_path)},
{"SessionCommands", OPT_WSTRING | OPT_KEEPCR, offcfg(session_commands)},
{"TaskCommands", OPT_WSTRING | OPT_KEEPCR, offcfg(task_commands)},
{"ConPTY", OPT_BOOL, offcfg(conpty_support)},
{"MenuMouse", OPT_STRING, offcfg(menu_mouse)},
{"MenuCtrlMouse", OPT_STRING, offcfg(menu_ctrlmouse)},
{"MenuMouse5", OPT_STRING, offcfg(menu_altmouse)},
Expand Down
1 change: 1 addition & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ typedef struct {
wstring user_commands_path;
wstring session_commands;
wstring task_commands;
int conpty_support;
string menu_mouse;
string menu_ctrlmouse;
string menu_altmouse;
Expand Down
23 changes: 22 additions & 1 deletion src/winmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -4487,7 +4487,7 @@ static char help[] =
"See manual page for further command line options and configuration.\n"
);

static const char short_opts[] = "+:c:C:eh:i:l:o:p:s:t:T:B:R:uw:HVdD~";
static const char short_opts[] = "+:c:C:eh:i:l:o:p:s:t:T:B:R:uw:HVdD~P:";

enum {
OPT_FG = 0x80,
Expand Down Expand Up @@ -4533,6 +4533,7 @@ opts[] = {
{"WSL", optional_argument, 0, ''}, // short option not enabled
{"WSLmode", optional_argument, 0, ''}, // short option not enabled
#endif
{"pcon", required_argument, 0, 'P'},
{"rootfs", required_argument, 0, ''}, // short option not enabled
{"dir~", no_argument, 0, '~'},
{"help", no_argument, 0, 'H'},
Expand Down Expand Up @@ -4970,6 +4971,8 @@ main(int argc, char *argv[])
dup(tfd);
close(tfd);
}
when 'P':
set_arg_option("ConPTY", optarg);
}
}

Expand Down Expand Up @@ -5704,6 +5707,24 @@ static int dynfonts = 0;
if (*cfg.background == '%')
scale_to_image_ratio();

// Adjust ConPTY support if requested
if (cfg.conpty_support != (uchar)-1) {
char * env = 0;
#ifdef __MSYS__
env = "MSYS";
#else
#ifdef __CYGWIN__
env = "CYGWIN";
#endif
#endif
if (env) {
char * val = cfg.conpty_support ? "enable_pcon" : "disable_pcon";
val = asform("%s %s", getenv(env) ?: "", val);
//printf("%d %s=%s\n", cfg.conpty_support, env, val);
setenv(env, val, true);
}
}

// Create child process.
child_create(
argv,
Expand Down
1 change: 1 addition & 0 deletions wiki/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Keyboard handling
* Applying modifyOtherKeys mode 2 more consistently to special keys (~~#1082).

Configuration
* New settings -P/--pcon/ConPTY to enable/disable ConPTY support (mintty/wsltty#271).
* Support for theme file conversion on filename drag-and-drop (#1079).
* Support for theme file conversion on "file:" URL drag-and-drop (~#1079).
* Support for ".json" theme file conversion (~~#1079).
Expand Down

0 comments on commit 6999ae7

Please sign in to comment.