]> pd.if.org Git - pd_readline/blobdiff - funcs.c
More work.
[pd_readline] / funcs.c
diff --git a/funcs.c b/funcs.c
index 87e0d505a7a847bec6d66ccca3a2b4e863d2e815..36241e5cb97ddfd6adac38d3e1caca31de25c72b 100644 (file)
--- a/funcs.c
+++ b/funcs.c
 /* Also test for the top and bottom of the history file.  */     
 
 
+/*  Display a buffer  */ 
+void show(buf b)
+{ 
+   printf("%s", b.array);                      
+}      
+
+
+
+/* Enter a char into a buffer and display the buffer array.  */ 
+buf set(buf b, int i)
+{ 
+  if ( (b.index < 80)  )  
+    { 
+          b.array[b.index] = i;        
+          b.index += 1 ;
+    } 
+  else
+    { 
+          memset(b.array[0], 0, sizeof(b.array) ); 
+          b.array[0] = i;
+          b.index += 1 ;               
+    }          
+  
+  show(b); 
+  return b;    
+       
+} 
+
+
+
 /* Move up in history list. */ 
-buf up(int i
+buf up(buf b
 { 
   
 
@@ -29,7 +59,7 @@ buf up(int i)
 
 
 /* Move down in history list. */ 
-buf down(int i
+buf down(buf b
 { 
 
 
@@ -74,14 +104,45 @@ void enter(void)
 }      
 
 
+/* Find if a number is in a given range. */ 
+int range(int rstart, int rend, int i)
+{
+   if ( (rstart <= i) && (i <= rend) ) return 1;
+   else return 0;      
+       
+}      
+
+
+/* Assign a type depending on the range that a  */ 
+/* number is in.                                */ 
+int type(int i)
+{ 
+   int ret; 
+   
+        if ( range(0, 9, i) == 1 )       ret = 1; 
+   else if ( range(10, 10, i) == 1 )     ret = 2; 
+   else if ( range(27, 27, i) == 1 )     ret = 3; 
+   else if ( range(32, 126, i) == 1 )    ret = 4;         
+   else if ( range(127, 127, i) == 1 )   ret = 5;
+   else ret = 6;          
+    
+   return ret; 
+   
+}     
+       
 
 /*  Function for special key combinations  */ 
 /*  (Ctrl, Alt, function keys.             */ 
-int spec(int i)
+void spec(void)
 { 
        
-       
-
+  int j = getch();  
+   
+       if ( ( j == 65 )        )  printf("Up ");  
+  else if ( ( j == 66 )        )  printf("Down "); 
+  else if ( ( j == 67 )        )  printf("Right "); 
+  else if ( ( j == 68 )        )  printf("Left "); 
+               
 }