diff options
author | Aurélien Aptel <aurelien.aptel@gmail.com> | 2011-06-08 21:35:58 +0200 |
---|---|---|
committer | Aurélien Aptel <aurelien.aptel@gmail.com> | 2011-06-08 21:35:58 +0200 |
commit | 4259a3ba3a99da4bc551c9cde6868366fb2c01fa (patch) | |
tree | e906e58aa8338ad307f318368fe6d602cc805240 | |
parent | fb32d01a183979b3235740aaea555bfe94759dab (diff) | |
download | st-patched-4259a3ba3a99da4bc551c9cde6868366fb2c01fa.tar.bz2 st-patched-4259a3ba3a99da4bc551c9cde6868366fb2c01fa.tar.xz st-patched-4259a3ba3a99da4bc551c9cde6868366fb2c01fa.zip |
add -w option to embed st. (thx nodus cursorius)
-rw-r--r-- | st.1 | 6 | ||||
-rw-r--r-- | st.c | 10 |
2 files changed, 14 insertions, 2 deletions
@@ -7,6 +7,8 @@ st \- simple terminal | |||
7 | .IR class ] | 7 | .IR class ] |
8 | .RB [ \-t | 8 | .RB [ \-t |
9 | .IR title ] | 9 | .IR title ] |
10 | .RB [ \-w | ||
11 | .IR windowid ] | ||
10 | .RB [ \-v ] | 12 | .RB [ \-v ] |
11 | .RB [ \-e | 13 | .RB [ \-e |
12 | .IR command ...] | 14 | .IR command ...] |
@@ -21,6 +23,10 @@ defines the window title (default 'st'). | |||
21 | .BI \-c " class" | 23 | .BI \-c " class" |
22 | defines the window class (default $TERM). | 24 | defines the window class (default $TERM). |
23 | .TP | 25 | .TP |
26 | .BI \-w " windowid" | ||
27 | embeds st within the window identified by | ||
28 | .I windowid | ||
29 | .TP | ||
24 | .B \-v | 30 | .B \-v |
25 | prints version information to stderr, then exits. | 31 | prints version information to stderr, then exits. |
26 | .TP | 32 | .TP |
@@ -35,7 +35,7 @@ | |||
35 | 35 | ||
36 | #define USAGE \ | 36 | #define USAGE \ |
37 | "st-" VERSION ", (c) 2010-2011 st engineers\n" \ | 37 | "st-" VERSION ", (c) 2010-2011 st engineers\n" \ |
38 | "usage: st [-t title] [-c class] [-v] [-e command...]\n" | 38 | "usage: st [-t title] [-c class] [-w windowid] [-v] [-e command...]\n" |
39 | 39 | ||
40 | /* Arbitrary sizes */ | 40 | /* Arbitrary sizes */ |
41 | #define ESC_TITLE_SIZ 256 | 41 | #define ESC_TITLE_SIZ 256 |
@@ -260,6 +260,7 @@ static pid_t pid; | |||
260 | static Selection sel; | 260 | static Selection sel; |
261 | static char **opt_cmd = NULL; | 261 | static char **opt_cmd = NULL; |
262 | static char *opt_title = NULL; | 262 | static char *opt_title = NULL; |
263 | static char *opt_embed = NULL; | ||
263 | static char *opt_class = NULL; | 264 | static char *opt_class = NULL; |
264 | 265 | ||
265 | int | 266 | int |
@@ -1606,6 +1607,7 @@ void | |||
1606 | xinit(void) { | 1607 | xinit(void) { |
1607 | XSetWindowAttributes attrs; | 1608 | XSetWindowAttributes attrs; |
1608 | Cursor cursor; | 1609 | Cursor cursor; |
1610 | Window parent; | ||
1609 | 1611 | ||
1610 | if(!(xw.dpy = XOpenDisplay(NULL))) | 1612 | if(!(xw.dpy = XOpenDisplay(NULL))) |
1611 | die("Can't open display\n"); | 1613 | die("Can't open display\n"); |
@@ -1636,7 +1638,8 @@ xinit(void) { | |||
1636 | | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask; | 1638 | | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask; |
1637 | attrs.colormap = xw.cmap; | 1639 | attrs.colormap = xw.cmap; |
1638 | 1640 | ||
1639 | xw.win = XCreateWindow(xw.dpy, XRootWindow(xw.dpy, xw.scr), 0, 0, | 1641 | parent = opt_embed ? strtol(opt_embed, NULL, 0) : XRootWindow(xw.dpy, xw.scr); |
1642 | xw.win = XCreateWindow(xw.dpy, parent, 0, 0, | ||
1640 | xw.w, xw.h, 0, XDefaultDepth(xw.dpy, xw.scr), InputOutput, | 1643 | xw.w, xw.h, 0, XDefaultDepth(xw.dpy, xw.scr), InputOutput, |
1641 | XDefaultVisual(xw.dpy, xw.scr), | 1644 | XDefaultVisual(xw.dpy, xw.scr), |
1642 | CWBackPixel | CWBorderPixel | CWBitGravity | CWEventMask | 1645 | CWBackPixel | CWBorderPixel | CWBitGravity | CWEventMask |
@@ -1943,6 +1946,9 @@ main(int argc, char *argv[]) { | |||
1943 | case 'c': | 1946 | case 'c': |
1944 | if(++i < argc) opt_class = argv[i]; | 1947 | if(++i < argc) opt_class = argv[i]; |
1945 | break; | 1948 | break; |
1949 | case 'w': | ||
1950 | if(++i < argc) opt_embed = argv[i]; | ||
1951 | break; | ||
1946 | case 'e': | 1952 | case 'e': |
1947 | /* eat every remaining arguments */ | 1953 | /* eat every remaining arguments */ |
1948 | if(++i < argc) opt_cmd = &argv[i]; | 1954 | if(++i < argc) opt_cmd = &argv[i]; |