1 /*- 2 * Copyright (c) 1992 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Christos Zoulas of Cornell University. 7 * 8 * %sccs.include.redist.c% 9 * 10 * @(#)histedit.h 5.2 (Berkeley) 06/22/92 11 */ 12 13 /* 14 * histedit.h: Line editor and history interface. 15 */ 16 #ifndef _h_editline 17 #define _h_editline 18 19 #include <sys/types.h> 20 #include <stdio.h> 21 22 /* 23 * ==== Editing ==== 24 */ 25 typedef struct editline EditLine; 26 27 /* 28 * For user-defined function interface 29 */ 30 typedef struct lineinfo { 31 const char *buffer; 32 const char *cursor; 33 const char *lastchar; 34 } LineInfo; 35 36 /* 37 * el_set/el_get parameters 38 */ 39 #define EL_PROMPT 0 40 #define EL_FILE 1 41 #define EL_TERMINAL 2 42 #define EL_EDITOR 3 43 #define EL_SIGNAL 4 44 #define EL_BIND 5 45 #define EL_TELLTC 6 46 #define EL_SETTC 7 47 #define EL_ECHOTC 8 48 #define EL_SETTY 9 49 #define EL_ADDFN 10 50 #define EL_HIST 11 51 52 /* 53 * EditLine editor function return codes. 54 * For user-defined function interface 55 */ 56 #define CC_NORM 0 57 #define CC_NEWLINE 1 58 #define CC_EOF 2 59 #define CC_ARGHACK 3 60 #define CC_REFRESH 4 61 #define CC_CURSOR 5 62 #define CC_ERROR 6 63 #define CC_FATAL 7 64 65 /* 66 * Initialization, cleanup, and resetting 67 */ 68 EditLine *el_init __P((const char *, FILE *, FILE *)); 69 void el_reset __P((EditLine *)); 70 void el_end __P((EditLine *)); 71 72 73 /* 74 * Get a line, a character or push a string back in the input queue 75 */ 76 const char *el_gets __P((EditLine *, int *)); 77 int el_getc __P((EditLine *, char *)); 78 void el_push __P((EditLine *, const char *)); 79 80 /* 81 * High level function internals control 82 * Parses argc, argv array and executes builtin editline commands 83 */ 84 int el_parse __P((EditLine *, int, char **)); 85 86 /* 87 * Low level editline access function 88 */ 89 int el_set __P((EditLine *, int, ...)); 90 91 /* 92 * Must be called when the terminal changes size; If EL_SIGNAL 93 * is set this is done automatically otherwise it is the responsibility 94 * of the application 95 */ 96 void el_resize __P((EditLine *)); 97 98 99 /* 100 * User-defined function interface. 101 */ 102 const LineInfo *el_line __P((EditLine *)); 103 int el_insertstr __P((EditLine *, char *)); 104 void el_deletestr __P((EditLine *, int)); 105 106 /* 107 * ==== History ==== 108 */ 109 110 typedef struct history History; 111 112 typedef struct HistEvent { 113 int num; 114 const char* str; 115 } HistEvent; 116 117 /* 118 * History access functions. 119 */ 120 History * history_init __P((void)); 121 void history_end __P((History *)); 122 123 const HistEvent * history __P((History *, int, ...)); 124 125 #define H_FUNC 0 /* , UTSL */ 126 #define H_EVENT 1 /* , const int); */ 127 #define H_FIRST 2 /* , void); */ 128 #define H_LAST 3 /* , void); */ 129 #define H_PREV 4 /* , void); */ 130 #define H_NEXT 5 /* , void); */ 131 #define H_CURR 6 /* , void); */ 132 #define H_ADD 7 /* , const char*); */ 133 #define H_ENTER 8 /* , const char*); */ 134 #define H_END 9 /* , void); */ 135 #define H_NEXT_STR 10 /* , const char*); */ 136 #define H_PREV_STR 11 /* , const char*); */ 137 #define H_NEXT_EVENT 12 /* , const int); */ 138 #define H_PREV_EVENT 13 /* , const int); */ 139 140 #endif /* _h_editline */ 141