commit de4b647005d500d15e520648d9e10317c185f1be
parent b46cf194802d6e9ba831764178631daaeeb8dc72
Author: Rafael Garcia <rafael.garcia.gallego@gmail.com>
Date: Tue, 31 May 2011 01:25:24 +0200
Control-Z handling, kudos to pancake!
Diffstat:
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/config.def.h b/config.def.h
@@ -155,8 +155,8 @@ static const Key stdkeys[] = {
{ CONTROL('Y'), { t_rw, 0, 0, 0 }, f_pipe, FROMCLIP },
{ CONTROL('C'), { t_sel, 0, 0, 0 }, f_pipero, TOCLIP },
-/* Windows-like crap TO REMOVE */
-{ CONTROL('Z'), { t_undo,0, 0, 0 }, f_undo, { .i = 1 } },
+/* This is really fine */
+{ CONTROL('Z'), { 0, 0, 0, 0 }, f_suspend, { 0 } },
/* Others */
{ CONTROL('L'), { 0, 0, 0, 0 }, f_center, { 0 } },
diff --git a/sandy.c b/sandy.c
@@ -180,6 +180,7 @@ static void f_pipero(const Arg*);
static void f_save(const Arg*);
static void f_select(const Arg*);
static void f_spawn(const Arg*);
+static void f_suspend(const Arg*);
static void f_syntax(const Arg *arg);
static void f_title(const Arg *arg);
static void f_toggle(const Arg *arg);
@@ -209,6 +210,7 @@ static Filepos i_scrtofpos(int, int);
static bool i_setfindterm(char*);
static void i_setup(void);
static void i_sigwinch(int);
+static void i_sigcont(int);
static void i_sortpos(Filepos*, Filepos*);
static char *i_strdup(const char*);
static void i_termwininit(void);
@@ -431,6 +433,12 @@ f_spawn(const Arg *arg) {
redrawwin(textwin);
}
+void
+f_suspend(const Arg *arg) {
+ signal (SIGCONT, i_sigcont);
+ kill(getpid(), SIGSTOP);
+}
+
void /* Set syntax with name arg->v */
f_syntax(const Arg *arg) {
int i, j;
@@ -1146,6 +1154,12 @@ i_sigwinch(int unused) {
statusflags|=S_NeedResize;
}
+void /* Process SIGCONT to return after STOP */
+i_sigcont(int unused) {
+ cols = 0;
+ i_resize();
+}
+
void /* Exchange pos0 and pos1 if not in order */
i_sortpos(Filepos *pos0, Filepos *pos1) {
Filepos p;