summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2019-07-24 12:34:29 +0100
committerKatolaZ <katolaz@freaknet.org>2019-07-24 12:34:29 +0100
commit1be4c30c5e1526484665c382d784e0de9fe9d8de (patch)
tree551df692508b64c3ebf54435704e948f5fdc0875
parent3a8eeffc5b3ef3d23984913d841e3a0aa5f68e16 (diff)
add config.h
-rw-r--r--Makefile3
-rw-r--r--TODO4
-rw-r--r--config.h16
-rw-r--r--gramscii.c20
4 files changed, 28 insertions, 15 deletions
diff --git a/Makefile b/Makefile
index 9ce0381..da97e66 100644
--- a/Makefile
+++ b/Makefile
@@ -3,6 +3,7 @@
include config.mk
SRC = gramscii.c
+INCLUDES = config.h
all: options gramscii
@@ -14,6 +15,6 @@ options:
@echo "-+-+-+-+-+-+-+-+-+-+-"
-gramscii:
+gramscii: $(SRC) $(INCLUDES)
$(CC) $(CFLAGS) -o $@ $(SRC)
diff --git a/TODO b/TODO
index da7de02..32af33c 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,4 @@
-+ optimize redraws (i.e., avoid to redraw if possible)
-- move configs in config.h
++ optimize redraws (redraw only the modified rectangle)
- change screen management (i.e., dynamic array of lines)
- add action multiplier (e.g., "7h" moves left by 7 cols)
- add scripting mode option ("-s"?)
@@ -25,6 +24,7 @@
- catch SIGWINCH and react appropriately (after scroll is
enabled)
- auto-arrow 'A' (automatic end-char)
+* move configs in config.h
* get screen geometry
* allow the use of [ENTER] to confirm arrow, boxes (useful
for scripting)
diff --git a/config.h b/config.h
new file mode 100644
index 0000000..d38488b
--- /dev/null
+++ b/config.h
@@ -0,0 +1,16 @@
+/* Config options */
+
+/** MARKERS -- the first character is the default one **/
+/* markers for horizontal lines */
+char hlines[] = {"-~=#*@._ "};
+/* markers for vertical lines */
+char vlines[] = {"|H#*@:;i "};
+/* markers for corners */
+char corners[] = {"+'H#*@.\"`"};
+/* markers for arrow start points */
+char st_marks[] = {"+o-|<>^v*"};
+/* markers for arrow endpoints */
+char end_marks[] = {">+o-|<^v*"};
+
+/** LONG_STEP (movements through uppercase HJKL) **/
+#define LONG_STEP 5
diff --git a/gramscii.c b/gramscii.c
index f7f2ed4..2d8b593 100644
--- a/gramscii.c
+++ b/gramscii.c
@@ -12,6 +12,8 @@
#include <string.h>
#include <sys/ioctl.h>
+#include "config.h"
+
#define MOVE 0x00
#define BOX 0x01
#define ARROW 0x02
@@ -40,7 +42,6 @@
#define ARR_U '^'
#define ARR_D 'v'
-
#define HOME 0x01
#define END 0x02
#define MIDDLE 0x04
@@ -51,7 +52,7 @@
#define MIN(x,y) (x) < (y) ? (x) : (y)
#define MAX(x,y) (x) > (y) ? (x) : (y)
-#define DEBUG 1
+/** #define DEBUG 1 **/
char **screen;
int WIDTH, HEIGHT;
@@ -64,11 +65,6 @@ int step;
int force_new;
char cursor;
char corner;
-char hlines[] = {"-~=#@._ "};
-char vlines[] = {"|H#@:;i "};
-char corners[] = {"+'H#@.\""};
-char st_marks[] = {"+o-|<>^v"};
-char end_marks[] = {">+o-|<^v"};
int hlines_sz= sizeof(hlines) -1;
int vlines_sz= sizeof(vlines) -1;
@@ -308,22 +304,22 @@ void handle_goto(){
int move_around(char c){
switch(c){
- case 'H': step = 5;/** FALLTHROUGH **/
+ case 'H': step = LONG_STEP;/** FALLTHROUGH **/
case 'h':
dir = DIR_L;
x -= step;
break;
- case 'J': step = 5;/** FALLTHROUGH **/
+ case 'J': step = LONG_STEP;/** FALLTHROUGH **/
case 'j':
dir = DIR_D;
y += step;
break;
- case 'K': step = 5;/** FALLTHROUGH **/
+ case 'K': step = LONG_STEP;/** FALLTHROUGH **/
case 'k':
dir = DIR_U;
y -= step;
break;
- case 'L': step = 5;/** FALLTHROUGH **/
+ case 'L': step = LONG_STEP;/** FALLTHROUGH **/
case 'l':
dir = DIR_R;
x += step;
@@ -687,7 +683,7 @@ void load_file(){
void new_file(){
check_modified();
erase_screen();
- go_to(MIDDLE);
+ go_to(HOME);
redraw();
fname[0] = '\0';
modified=0;