From f4117575c853c20d7312cbb8153d9a77340f8849 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 22 Oct 2012 15:39:49 +1300 Subject: [PATCH] More work. --- Makefile | 6 +++--- keyhandler.c | 4 ++-- pd_readline.c | 4 ++-- pd_readline.h | 40 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 pd_readline.h diff --git a/Makefile b/Makefile index be2e21a..514bca2 100644 --- a/Makefile +++ b/Makefile @@ -17,9 +17,9 @@ LIBS = -l$(SYSLIBS) $(MYLIBS) RM = rm -f -#HEADERS= foo.h bar.h baz.h +HEADERS= pd_readline.h -OBJECTS = pd_readline.o keyhandler.o funcs.o history.o +OBJECTS = keyhandler.o funcs.o history.o pd_readline.o %.o: %.c $(CC) $(CFLAGS) $< -o $@ @@ -27,7 +27,7 @@ OBJECTS = pd_readline.o keyhandler.o funcs.o history.o pd_readline: $(OBJECTS) $(CC) $(LDFLAGS) $(OBJECTS) -o $@ $(LIBS) -#pd_readline.o: $(HEADERS) +pd_readline.o: $(HEADERS) #keyhandler.o: $(HEADERS) #funcs.o: $(HEADERS) #history.o: $(HEADERS) diff --git a/keyhandler.c b/keyhandler.c index 0130e9b..6cbe358 100644 --- a/keyhandler.c +++ b/keyhandler.c @@ -62,12 +62,12 @@ int keyhandler(void) { int i = getch(); - switch(i); + switch(i) { case (27): escape() ; case (33): dosomething(); case (42): something(); - default: stuff(): + default: stuff(); } } diff --git a/pd_readline.c b/pd_readline.c index 5f000bd..033dfc1 100644 --- a/pd_readline.c +++ b/pd_readline.c @@ -23,14 +23,14 @@ /* Ctrl-C and Ctrl-V. */ - +#include "pd_readline.h" int main(void) { /* Read in the command history file. */ - readhistory(); + readhistory("test.txt"); while(1) diff --git a/pd_readline.h b/pd_readline.h new file mode 100644 index 0000000..021933e --- /dev/null +++ b/pd_readline.h @@ -0,0 +1,40 @@ + + +/* pd_readline.h */ +/* Header file for pd_readline. */ +/* This code is released to the public domain. */ +/* "Share and enjoy...." ;) */ +/* See the UNLICENSE file for details. */ + + +/* Buffer typedef. */ +typedef struct { + int index; + char array[80] ; +} buf; + + + +/* Cursor movement funcs. */ +int up(int i); +int down(int i); +buf left(buf b); +buf right(buf b); +buf delch(buf b); +buf insch(buf b); + +/* Escape-key handling. */ +int esc(int i); + +/* Other funcs. */ +void readhistory(char *fname); +int keyhandler(void); + + + + + + + + + -- 2.40.0