Apply st-newterm-0.8.2.diff

custom
Emil Miler 4 years ago
parent 6c49c63f59
commit 4457379f76

@ -213,6 +213,7 @@ static Shortcut shortcuts[] = {
{ TERMMOD, XK_Y, selpaste, {.i = 0} },
{ ShiftMask, XK_Insert, selpaste, {.i = 0} },
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
{ TERMMOD, XK_Return, newterm, {.i = 0} },
{ ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
{ ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
};

21
st.c

@ -160,6 +160,7 @@ typedef struct {
} STREscape;
static void execsh(char *, char **);
static char *getcwd_by_pid(pid_t pid);
static void stty(char **);
static void sigchld(int);
static void ttywriteraw(const char *, size_t);
@ -1057,6 +1058,20 @@ tnew(int col, int row)
treset();
}
void
newterm(const Arg* a)
{
switch (fork()) {
case -1:
die("fork failed: %s\n", strerror(errno));
break;
case 0:
chdir(getcwd_by_pid(pid));
execlp("st", "./st", NULL);
break;
}
}
void
tswapscreen(void)
{
@ -1101,6 +1116,12 @@ kscrollup(const Arg* a)
}
}
static char *getcwd_by_pid(pid_t pid) {
char buf[32];
snprintf(buf, sizeof buf, "/proc/%d/cwd", pid);
return realpath(buf, NULL);
}
void
tscrolldown(int orig, int n, int copyhist)
{

@ -84,6 +84,7 @@ void draw(void);
void kscrolldown(const Arg *);
void kscrollup(const Arg *);
void newterm(const Arg *);
void printscreen(const Arg *);
void printsel(const Arg *);
void sendbreak(const Arg *);

Loading…
Cancel
Save