#include <stdlib.h>
#include "pd_readline.h"
+/* Note - make the up and down funcs return a buffer. */
+/* A line from the history file can be put into the */
+/* array member of the buffer. */
+/* Also test for the top and bottom of the history file. */
+
/* Move up in history list. */
-int up(int i)
+buf up(int i)
{
/* Move down in history list. */
-int down(int i)
+buf down(int i)
{
}
+void enter(void)
+{
+ printf("Enter ");
+}
+
+
-/* Function to handle escape sequences. */
-int esc(int i)
+/* Function for special key combinations */
+/* (Ctrl, Alt, function keys. */
+int spec(int i)
{
-
-
-}
-
+}
-/* Read the file into the array of strings. */
+/* Read the file into the array of strings. */
+/* TO DO - look at reading file into a series of structs. */
+
void readhistory(char *fname)
{
int retval = fexists(fname);
}
+/* TO DO - a function that reads in the 2d history array, and */
+/* returns a struct with one line from the array, and the index */
+/* of the line. */
+
+
+
-void keyhandler(void)
+/* Arrow keys are esc [ A to esc [ D */
+/* Alt keys are just esc then key (e.g. Alt-g is esc g ). */
+/* Ctrl (then letter) keys are just Dec 1 to Dec 26 */
+
+void keyhandler(buf b)
{
+
int i = getch();
switch(i)
{
- case (27): puts("1"); /* escape() ; */
- case (33): puts("2"); /* dosomething(); */
- case (42): puts("3"); /* something(); */
- default: puts("4"); /* stuff(); */
+ case (1): break; /* Ctrl a */
+ case (2): break; /* Ctrl b */
+ case (3): break; /* Ctrl c */
+
+ case (10): enter(); /* Enter */
+
+ case (27): spec(i); break; /* esc */
+
+ case (32): printf("%c", i); break; /* Printable chars. */
+ case (33): printf("%c", i); break; /* Printable chars. */
+ case (34): printf("%c", i); break; /* Printable chars. */
+
+ case (65): printf("%c", i); break; /* "A" */
+ case (66): printf("%c", i); break; /* "B" */
+ case (67): printf("%c", i); break; /* "C" */
+ case (68): printf("%c", i); break; /* "D" */
+ case (69): printf("%c", i); break; /* "E" */
+ case (70): printf("%c", i); break; /* "F" */
+
+ case (97): printf("%c", i); break; /* "a" */
+ case (98): printf("%c", i); break; /* "b" */
+ case (99): printf("%c", i); break; /* "c" */
+ case (100): printf("%c", i); break; /* "d" */
+ case (101): printf("%c", i); break; /* "e" */
+ case (102): printf("%c", i); break; /* "f" */
+
+ case (126): printf("%c", i); break; /* "~" */
+
+ case (127): delch(b); break;
+
+ default: break; /* stuff(); */
}
}