Skip to content

Commit

Permalink
* man/mlterm.1, README.ja, doc/{en,ja}/README.win32: Updated.
Browse files Browse the repository at this point in the history
* configure.in, Makefile.in: Check CreatePseudoConsole() function and
  add -DUSE_CONPTY to @PTY_CFLAGS@ if it exists.
* vt_pty.c: vt_pty_win32 and vt_pty_{ssh|mosh}.c coexist.
* vt_pty_win32.c:
  - Rename from vt_pty_pipewin32.c to vt_pty_win32.c.
  - Support ConPTY whic is enabled if USE_CONPTY macro is defined.
  - Add vt_pty_win32_set_pty_read_trigger().
* uitoolkit/ui_main_config.c, ui_screen_manager.c, vt_term.[ch]:
  --slp/start_with_local_pty option is available in win32.
  • Loading branch information
arakiken committed Oct 15, 2023
1 parent 44bf2da commit 1c82312
Show file tree
Hide file tree
Showing 19 changed files with 260 additions and 57 deletions.
17 changes: 17 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
2023-10-15 Araki Ken <arakiken@users.sf.net>

* man/mlterm.1, README.ja, doc/{en,ja}/README.win32: Updated.

* configure.in, Makefile.in: Check CreatePseudoConsole() function and
add -DUSE_CONPTY to @PTY_CFLAGS@ if it exists.

* vt_pty.c: vt_pty_win32 and vt_pty_{ssh|mosh}.c coexist.

* vt_pty_win32.c:
- Rename from vt_pty_pipewin32.c to vt_pty_win32.c.
- Support ConPTY whic is enabled if USE_CONPTY macro is defined.
- Add vt_pty_win32_set_pty_read_trigger().

* uitoolkit/ui_main_config.c, ui_screen_manager.c, vt_term.[ch]:
--slp/start_with_local_pty option is available in win32.

2023-09-18 Araki Ken <arakiken@users.sf.net>

* ui_screen.c: "exesel:" works in win32.
Expand Down
19 changes: 17 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,7 @@ MOSH_OCB_OBJ
MOSH_DIR
VT_PTY_OBJ
SSH2_LIBS_FOR_PROG
PTY_CFLAGS
PROTOBUF_LIBS
PROTOBUF_CFLAGS
SSH2_LIBS
Expand Down Expand Up @@ -19697,9 +19698,20 @@ if test "$ml_cv_is_posix" = "no" ; then
SSH2_LIBS_FOR_PROG="$SSH2_LIBS -lwsock32 -lws2_32"
SSH2_LIBS=
fi
else
VT_PTY_OBJ="vt_pty_pipewin32.o"
fi

ac_fn_c_check_func "$LINENO" "CreatePseudoConsole" "ac_cv_func_CreatePseudoConsole"
if test "x$ac_cv_func_CreatePseudoConsole" = xyes; then :

PTY_CFLAGS="-DUSE_CONPTY"
win32pty=conpty

else
win32pty=pipe
fi


VT_PTY_OBJ="$VT_PTY_OBJ vt_pty_win32.o"
else
VT_PTY_OBJ="vt_pty_unix.o"

Expand Down Expand Up @@ -28342,6 +28354,9 @@ echo "Input Methods :$input_methods_result"
fi
echo "Scrollbars : simple${scrollbars_result}"
echo "libssh2 : $ssh2"
if test "$ml_cv_is_posix" = "no"; then
echo "pty type : $win32pty"
fi
echo "mosh directory : $MOSH_DIR"
if test "$have_gtk" = "yes"; then
if test "$have_gtk4" = "yes"; then
Expand Down
14 changes: 12 additions & 2 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -990,9 +990,16 @@ if test "$ml_cv_is_posix" = "no" ; then
SSH2_LIBS_FOR_PROG="$SSH2_LIBS -lwsock32 -lws2_32"
SSH2_LIBS=
fi
else
VT_PTY_OBJ="vt_pty_pipewin32.o"
fi

AC_CHECK_FUNC(CreatePseudoConsole,
[
PTY_CFLAGS="-DUSE_CONPTY"
win32pty=conpty
],
[win32pty=pipe])
AC_SUBST(PTY_CFLAGS)
VT_PTY_OBJ="$VT_PTY_OBJ vt_pty_win32.o"
else
VT_PTY_OBJ="vt_pty_unix.o"

Expand Down Expand Up @@ -2438,6 +2445,9 @@ echo "Input Methods :$input_methods_result"
fi
echo "Scrollbars : simple${scrollbars_result}"
echo "libssh2 : $ssh2"
if test "$ml_cv_is_posix" = "no"; then
echo "pty type : $win32pty"
fi
echo "mosh directory : $MOSH_DIR"
if test "$have_gtk" = "yes"; then
if test "$have_gtk4" = "yes"; then
Expand Down
2 changes: 0 additions & 2 deletions doc/en/README.win32
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ Memo about WIN32 native GUI.
"\x1b]5379;mlclient <prefix opitions> <options>\x07" sequence (which
mlclient or mlclientx command supports) is avaiable. (see doc/en/PROTOCOL).
o Supported scrollbars are "simple" and "sample" alone.
o Only "mlclient" command is available for "exesel:..." operation in
~/.mlterm/key in MinGW.
o In order to show DEC SPECIAL characters, it is necessary to install
"Tera Special" font (TSPECIAL1.TTF) which is a part of Tera Term
(https://ja.osdn.net/projects/ttssh2/).
Expand Down
2 changes: 2 additions & 0 deletions doc/en/ReleaseNote
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* Pressing '?' in copy mode searches for a string backward.
(https://github.com/arakiken/mlterm/issues/72)
* Support wp-primary-selection protocol in wayland.
* Support "exesel:" operation in ~/.mlterm/key in win32.
* Support ConPTY in win32.
* Add tool/accessories/applycfg.sh and applyfontcfg.sh
(https://github.com/arakiken/mlterm/issues/71)
* Update unicode property table (generated from UnicodeData.txt and
Expand Down
2 changes: 1 addition & 1 deletion doc/ja/README.ja
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ comment -*- mode: text; tab-width:2; indent-tabs-mode:nil; coding:euc-jp -*-
o ssh_x11_forwarding (true/*false*)
ssh ��³�� x11 forwarding ��ͭ��

o start_with_local_pty (true/*false*) (Android ��)
o start_with_local_pty (true/*false*) (Android or win32 ��)
default_server ���ץ���󤬻��ꤵ��Ƥ��ʤ����ˡ���ư���� SSH ��³����
��������ɽ�����ʤ��褦�ˤ��ޤ���

Expand Down
4 changes: 1 addition & 3 deletions doc/ja/README.win32
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
comment -*- mode: text; tab-width:2; indent-tabs-mode:nil -*-
comment -*- mode: text; tab-width:2; indent-tabs-mode:nil; coding:euc-jp -*-

WIN32 native GUI �б��˴ؤ�����

Expand Down Expand Up @@ -118,8 +118,6 @@ WIN32 native GUI
�Ť��Ǥ��ˤ�뵼��Ū�� bold ɽ����Ԥ��ޤ�(Bold �� Normal �ǥե����������
�ʤ��礬���뤿��)
o ����������С��ϡ�"simple" ���� "sample" �Τ߻��ѤǤ��ޤ���
o MinGW �Ǥϡ�~/.mlterm/key �� OPERATION �� "exesel:..." �Ǥϡ�mlclient �ʳ���
�¹Ԥ��뤳�ȤϤǤ��ޤ���
o utmp �Ͼ��̵���Ȥʤ�ޤ���

* ������������
Expand Down
2 changes: 2 additions & 0 deletions etc/key
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
# Shift+Button3="exesel:/cygdrive/c/Program\\ Files/Internet\\ Explorer/iexplore.exe \"%s\""
# (Enclose %s by "" to invalidate special characters of cmd.exe)
# Shift+Button3="exesel:cmd.exe /C \"start microsoft-edge:\\"%s\\"\""
# (for win32 (MinGW))
# Shift+Button3="exesel:cmd.exe /C start microsoft-edge:%s"
# (This doesn't necessarily work because MS-Edge doesn't start if "%s" contains "=")
# Shift+Button3="exesel:explorer.exe microsoft-edge:\"%s\""
# Button4="\x1bOA\x1bOA"
Expand Down
4 changes: 2 additions & 2 deletions man/mlterm.1
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ e.g.) mlterm \-\-serv ssh://user@host:22:eucjp
Whether to allow dynamic change of shortcut keys by OSC 5379 set_shortcut sequence.
The default is \fBfalse\fR.
.TP
\fB\-\-slp\fR(=\fIbool\fR) (Available for Android)
\fB\-\-slp\fR(=\fIbool\fR) (Available for Android or win32)
Whether to start mlterm with local pty instead of ssh connection.
The default is \fBfalse\fR.
.TP
Expand Down Expand Up @@ -1780,7 +1780,7 @@ Specify private key file for ssh connection.
\fBssh_x11_forwarding\fR=\fIbool\fR (\fB\-\-x11\fR)
Enable x11 forwarding for ssh connection.
.TP
\fBstart_with_local_pty\fR (\fB\-\-slp\fR) (Available for Android)
\fBstart_with_local_pty\fR (\fB\-\-slp\fR) (Available for Android or win32)
Start mlterm with local pty instead of ssh connection.
.TP
\fBstep_in_changing_font_size\fR (\fB\-z\fR, \fB\-\-largesmall\fR)
Expand Down
5 changes: 5 additions & 0 deletions uitoolkit/ui_event_source.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,14 @@ static void receive_next_event(void) {

void ui_event_source_init(void) {
#ifdef USE_WIN32API
#ifdef USE_LIBSSH2
vt_pty_ssh_set_pty_read_trigger(ui_display_trigger_pty_read);
#ifdef USE_MOSH
vt_pty_mosh_set_pty_read_trigger(ui_display_trigger_pty_read);
#endif
#endif
vt_pty_win32_set_pty_read_trigger(ui_display_trigger_pty_read);
#endif
}

void ui_event_source_final(void) {
Expand Down
4 changes: 2 additions & 2 deletions uitoolkit/ui_main_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ void ui_prepare_for_main_config(bl_conf_t *conf) {
"the number of sixel colors of console [16]");
bl_conf_add_opt(conf, '\0', "csz", 0, "default_cell_size", "default cell size [8,16]");
#endif
#if defined(__ANDROID__) && defined(USE_LIBSSH2)
#if (defined(__ANDROID__) && defined(USE_LIBSSH2)) || defined(USE_WIN32API)
bl_conf_add_opt(conf, '\0', "slp", 1, "start_with_local_pty",
"start mlterm with local pty instead of ssh connection [false]");
#endif
Expand Down Expand Up @@ -1383,7 +1383,7 @@ void ui_main_config_init(ui_main_config_t *main_config, bl_conf_t *conf, int arg
}
#endif

#if defined(__ANDROID__) && defined(USE_LIBSSH2)
#if (defined(__ANDROID__) && defined(USE_LIBSSH2)) || defined(USE_WIN32API)
if ((value = bl_conf_get_value(conf, "start_with_local_pty"))) {
int flag = true_or_false(value);

Expand Down
13 changes: 6 additions & 7 deletions uitoolkit/ui_screen_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,15 @@ static int open_pty_intern(vt_term_t *term, char *cmd_path, char **cmd_argv,
* SHELL env var -> /etc/passwd -> /bin/sh
*/
if ((cmd_path = getenv("SHELL")) == NULL || *cmd_path == '\0') {
#ifndef USE_WIN32API
#ifdef USE_WIN32API
cmd_path = "c:\\Windows\\System32\\cmd.exe";
#else
struct passwd *pw;

if ((pw = getpwuid(getuid())) == NULL || *(cmd_path = pw->pw_shell) == '\0')
#endif
{
if ((pw = getpwuid(getuid())) == NULL || *(cmd_path = pw->pw_shell) == '\0') {
cmd_path = "/bin/sh";
}
#endif
}
}
}
Expand Down Expand Up @@ -1443,10 +1444,8 @@ u_int ui_screen_manager_startup(void) {

for (count = 0; count < num_startup_screens; count++) {
if (!open_screen_intern(main_config.disp_name, vt_get_detached_term(NULL), NULL, 0, 0,
#if defined(USE_LIBSSH2) && defined(__ANDROID__)
#if (defined(USE_LIBSSH2) && defined(__ANDROID__)) || defined(USE_WIN32API)
!start_with_local_pty
#elif defined(USE_WIN32API)
1 /* show dialog */
#else
0
#endif
Expand Down
2 changes: 1 addition & 1 deletion vtemu/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ VPATH = $(top_srcdir)/vtemu
CFLAGS = $(CFLAGS_LOCAL) @DEB_CFLAGS@ @POBL_CFLAGS@ @MEF_CFLAGS@ @SSH2_CFLAGS@ \
@UTMP_CFLAGS@ @FRIBIDI_CFLAGS@ @IND_CFLAGS@ @CTL_CFLAGS@ @VT52_CFLAGS@ \
@IMAGE_CFLAGS@ @TOOLS_CFLAGS@ @OT_LAYOUT_CFLAGS@ @TRANSFER_CFLAGS@ @CFLAGS@ \
@VT_NORM_CFLAGS@ @TRUECOLOR_CFLAGS@ @CPPFLAGS@ \
@VT_NORM_CFLAGS@ @TRUECOLOR_CFLAGS@ @PTY_CFLAGS@ @CPPFLAGS@ \
-I/usr/local/include -DLIBEXECDIR=\"$(libexecdir)\" -DBINDIR=\"$(bindir)\" \
-DLIBDIR=\"$(libdir)\"

Expand Down
13 changes: 8 additions & 5 deletions vtemu/vt_pty.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ vt_pty_t *vt_pty_new(const char *cmd_path, /* can be NULL */
u_int cols, u_int rows, u_int width_pix, u_int height_pix) {
vt_pty_t *pty;

#ifndef USE_WIN32API

if (!pass) {
#ifdef USE_WIN32API
pty = vt_pty_win32_new(cmd_path, cmd_argv, env, host, pass, cols, rows);
#else
pty =
vt_pty_unix_new(cmd_path, cmd_argv, env, host, work_dir, cols, rows, width_pix, height_pix);
} else
#endif
{
} else {
#if defined(USE_LIBSSH2)
if (strncmp(host, "mosh://", 7) == 0) {
pty = vt_pty_mosh_new(cmd_path, cmd_argv, env, host + 7, pass, pubkey, privkey, cols, rows,
Expand All @@ -52,7 +54,8 @@ vt_pty_t *vt_pty_new(const char *cmd_path, /* can be NULL */
width_pix, height_pix);
}
#elif defined(USE_WIN32API)
pty = vt_pty_pipe_new(cmd_path, cmd_argv, env, host, pass, cols, rows);
/* for pipe and plink */
pty = vt_pty_win32_new(cmd_path, cmd_argv, env, host, pass, cols, rows);
#else
pty = NULL;
#endif
Expand Down Expand Up @@ -81,7 +84,7 @@ vt_pty_t *vt_pty_new_with(int master, int slave, pid_t child_pid, u_int cols, u_
} else
#endif
{
/* XXX vt_pty_ssh_new_with() and vt_pty_pipe_new_with() haven't been implemented yet. */
/* XXX vt_pty_ssh_new_with() and vt_pty_win32_new_with() haven't been implemented yet. */
pty = NULL;
}

Expand Down
6 changes: 5 additions & 1 deletion vtemu/vt_pty.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ typedef enum {
PTY_LOCAL,
PTY_SSH,
PTY_MOSH,
PTY_PIPE,
PTY_WIN32,
} vt_pty_mode_t;

typedef struct vt_pty_event_listener {
Expand Down Expand Up @@ -120,6 +120,10 @@ int vt_start_config_menu(vt_pty_t *pty, char *cmd_path, int x, int y, char *disp

#define vt_pty_is_loopback(pty) ((pty)->stored != NULL)

#ifdef USE_WIN32API
void vt_pty_win32_set_pty_read_trigger(void (*func)(void));
#endif

#ifdef USE_LIBSSH2
#ifndef USE_MOSH
void *vt_search_ssh_session(const char *host, const char *port, const char *user);
Expand Down
4 changes: 2 additions & 2 deletions vtemu/vt_pty_intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ vt_pty_t *vt_pty_ssh_new(const char *cmd_path, char **cmd_argv, char **env, cons
const char *pass, const char *pubkey, const char *privkey, u_int cols,
u_int rows, u_int width_pix, u_int height_pix);

vt_pty_t *vt_pty_pipe_new(const char *cmd_path, char **cmd_argv, char **env, const char *host,
const char *pass, u_int cols, u_int rows);
vt_pty_t *vt_pty_win32_new(const char *cmd_path, char **cmd_argv, char **env, const char *host,
const char *pass, u_int cols, u_int rows);

vt_pty_t *vt_pty_mosh_new(const char *cmd_path, char **cmd_argv, char **env, const char *host,
const char *pass, const char *pubkey, const char *privkey, u_int cols,
Expand Down
Loading

0 comments on commit 1c82312

Please sign in to comment.