1 /* Open in new window handling */
12 #include "intl/gettext/libintl.h"
13 #include "osdep/newwin.h"
14 #include "osdep/osdep.h"
15 #include "terminal/terminal.h"
16 #include "util/memory.h"
17 #include "util/string.h"
20 #define XTERM_CMD XTERM
22 #define XTERM_CMD DEFAULT_XTERM_CMD
25 const struct open_in_new open_in_new
[] = {
26 /* [gettext_accelerator_context(open_in_new.os2, open_in_new.win32, open_in_new.beos)] */
27 { ENV_XWIN
, XTERM_CMD
, N_("~Xterm") },
28 { ENV_TWIN
, DEFAULT_TWTERM_CMD
, N_("T~wterm") },
29 { ENV_SCREEN
, DEFAULT_SCREEN_CMD
, N_("~Screen") },
30 /* [gettext_accelerator_context()] */
32 /* [gettext_accelerator_context(open_in_new.os2)] */
33 { ENV_OS2VIO
, DEFAULT_OS2_WINDOW_CMD
, N_("~Window") },
34 { ENV_OS2VIO
, DEFAULT_OS2_FULLSCREEN_CMD
, N_("~Full screen") },
35 /* [gettext_accelerator_context()] */
37 #ifdef CONFIG_OS_WIN32
38 /* [gettext_accelerator_context(open_in_new.win32)] */
39 { ENV_WIN32
, "", N_("~Window") },
40 /* [gettext_accelerator_context()] */
43 /* [gettext_accelerator_context(open_in_new.beos)] */
44 { ENV_BE
, DEFAULT_BEOS_TERM_CMD
, N_("~BeOS terminal") },
45 /* [gettext_accelerator_context()] */
51 can_open_in_new(struct terminal
*term
)
53 int i
, possibilities
= 0;
55 foreach_open_in_new (i
, term
->environment
) {
63 open_new_window(struct terminal
*term
, unsigned char *exe_name
,
64 enum term_env_type environment
, unsigned char *param
)
66 unsigned char *command
= NULL
;
69 foreach_open_in_new (i
, environment
) {
70 command
= open_in_new
[i
].command
;
76 if (environment
& ENV_XWIN
) {
77 unsigned char *xterm
= getenv("ELINKS_XTERM");
79 if (!xterm
) xterm
= getenv("LINKS_XTERM");
80 if (xterm
) command
= xterm
;
82 } else if (environment
& ENV_TWIN
) {
83 unsigned char *twterm
= getenv("ELINKS_TWTERM");
85 if (!twterm
) twterm
= getenv("LINKS_TWTERM");
86 if (twterm
) command
= twterm
;
89 command
= straconcat(command
, " ", exe_name
, " ", param
,
90 (unsigned char *) NULL
);
93 exec_on_terminal(term
, command
, "", TERM_EXEC_NEWWIN
);