4 /* Functions to handle cursor movement for */
6 /* This code is released to the public domain. */
7 /* "Share and enjoy...." ;) */
8 /* See the UNLICENSE file for details. */
14 #include "pd_readline.h"
16 /* Note - make the up and down funcs return a buffer. */
17 /* A line from the history file can be put into the */
18 /* array member of the buffer. */
19 /* Also test for the top and bottom of the history file. */
22 /* Display a buffer */
25 printf("%s", b.array);
30 /* Enter a char into a buffer and display the buffer array. */
40 memset(b.array[0], 0, sizeof(b.array) );
52 /* Move up in history list. */
61 /* Move down in history list. */
69 /* Move cursor to left. */
77 /* Move cursor to right. */
107 /* Find if a number is in a given range. */
108 int range(int rstart, int rend, int i)
110 if ( (rstart <= i) && (i <= rend) ) return 1;
116 /* Assign a type depending on the range that a */
122 if ( range(0, 9, i) == 1 ) ret = 1;
123 else if ( range(10, 10, i) == 1 ) ret = 2;
124 else if ( range(27, 27, i) == 1 ) ret = 3;
125 else if ( range(32, 126, i) == 1 ) ret = 4;
126 else if ( range(127, 127, i) == 1 ) ret = 5;
134 /* Function for special key combinations */
135 /* (Ctrl, Alt, function keys. */
141 if ( ( j == 65 ) ) printf("Up ");
142 else if ( ( j == 66 ) ) printf("Down ");
143 else if ( ( j == 67 ) ) printf("Right ");
144 else if ( ( j == 68 ) ) printf("Left ");