]> pd.if.org Git - pd_readline/blob - pd_readline.c
More work
[pd_readline] / pd_readline.c
1
2
3 /*  pd_readline.c                                      */  
4 /*  Some code to allow the editing of a command-line.  */ 
5 /*  You can also move around with the left and right   */ 
6 /*  arrow keys, and recall previous commands with the  */ 
7 /*  up-arrow key.                                      */ 
8 /*  This code is released to the public domain.        */ 
9 /*  "Share and enjoy...."  ;)                          */  
10 /*  See the UNLICENSE file for details.                */ 
11
12 /*  TO DO -                                            */ 
13 /*  a) Add support for Home and End (of line) keys.    */ 
14 /*  b) Add support for function keys.                  */ 
15 /*  c) Add support for Insert key so that text can be  */ 
16 /*     inserted.                                       */   
17 /*  d) Put much of the code into a header file.        */    
18 /*  e) Change so that pressing Enter adds the current  */  
19 /*     line of commands to the command-history.        */ 
20 /*     ( May look at using Ctrl-D to exit, as Python   */ 
21 /*     does with its command-line. )                   */           
22 /*  f) Add support for copying and pasting text via    */ 
23 /*     Ctrl-C and Ctrl-V.                              */  
24
25
26 #include "pd_readline.h"    
27
28
29 int main(void) 
30
31   
32   /* Create a buffer for entered text.  */ 
33   buf mybuf;  
34   mybuf.index = 0;
35    
36   
37   /* Read in the command history file. */ 
38   hist myhist = readhistory("test.txt");  
39     
40   
41   while(1) 
42   {  
43        
44     keyhandler(mybuf, myhist);  
45          
46   }         
47                                       
48   return 0;
49         
50 }  
51
52
53
54
55
56