commit 3223bbd5d8697e4ef74db82580e4675acf14666f
Author:     Jan Klemkow <[email protected]>
AuthorDate: Thu Apr 2 21:52:18 2020 +0200
Commit:     Jan Klemkow <[email protected]>
CommitDate: Thu Apr 2 21:52:18 2020 +0200

    make event strings editable in config.h

diff --git a/Makefile b/Makefile
index c7c87e9..125edc9 100644
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,11 @@ all: scroll
 clean:
        rm -f scroll ptty
 
+config.h:
+       cp config.def.h config.h
+
+scroll: scroll.c config.h
+
 install: scroll
        cp scroll ${BINDIR}
        cp scroll.1 ${MAN1DIR}
diff --git a/config.def.h b/config.def.h
new file mode 100644
index 0000000..0b61bed
--- /dev/null
+++ b/config.def.h
@@ -0,0 +1,2 @@
+#define SCROLL_UP      "\033[5;2~"
+#define SCROLL_DOWN    "\033[6;2~"
diff --git a/scroll.c b/scroll.c
index 4d3aede..1b864a0 100644
--- a/scroll.c
+++ b/scroll.c
@@ -43,6 +43,8 @@
  #include <libutil.h>
 #endif
 
+#include "config.h"
+
 TAILQ_HEAD(tailhead, line) head;
 
 struct line {
@@ -388,9 +390,9 @@ main(int argc, char *argv[])
                        if (n <= 0 && errno != EINTR)
                                die("read:");
 
-                       if (strncmp("\033[5;2~", input, n) == 0)
+                       if (strncmp(SCROLL_UP, input, n) == 0)
                                scrollup();
-                       else if (strncmp("\033[6;2~", input, n) == 0)
+                       else if (strncmp(SCROLL_DOWN, input, n) == 0)
                                scrolldown(buf, pos);
                        else if (write(mfd, input, n) == -1)
                                die("write:");

Reply via email to