Go to the documentation of this file.00001 #ifndef _GORP_EDLINE_EDLINE_H_
00002 #define _GORP_EDLINE_EDLINE_H_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include <compiler.h>
00039 #include <stdint.h>
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00054
00063 #define EDIT_MODE_ECHO 0x0001
00064
00065 #define EDIT_MODE_BINARY 0x0002
00066
00067 #define EDIT_MODE_HISTORY 0x0004
00068
00076 #ifndef EDIT_KEY_IGNORE
00077
00078 #define EDIT_KEY_IGNORE 0x00
00079 #endif
00080 #ifndef EDIT_KEY_HOME
00081
00082 #define EDIT_KEY_HOME 0x01
00083 #endif
00084 #ifndef EDIT_KEY_LEFT
00085
00086 #define EDIT_KEY_LEFT 0x02
00087 #endif
00088 #ifndef EDIT_KEY_END
00089
00090 #define EDIT_KEY_END 0x05
00091 #endif
00092 #ifndef EDIT_KEY_RIGHT
00093
00094 #define EDIT_KEY_RIGHT 0x06
00095 #endif
00096 #ifndef EDIT_KEY_REMOVE
00097
00098 #define EDIT_KEY_REMOVE 0x08
00099 #endif
00100 #ifndef EDIT_KEY_ENTER
00101
00102 #define EDIT_KEY_ENTER 0x0a
00103 #endif
00104 #ifndef EDIT_DISABLE_HISTORY
00105 #ifndef EDIT_KEY_UP
00106
00107 #define EDIT_KEY_UP 0x12
00108 #endif
00109 #ifndef EDIT_KEY_DOWN
00110
00111 #define EDIT_KEY_DOWN 0x16
00112 #endif
00113 #ifndef EDIT_KEY_RESTORE
00114
00115 #define EDIT_KEY_RESTORE 0x1b
00116 #endif
00117 #endif
00118
00126 #ifndef EDIT_CHAR_SPACE
00127
00128 #define EDIT_CHAR_SPACE ' '
00129 #endif
00130 #ifndef EDIT_CHAR_BACKSPACE
00131
00132 #define EDIT_CHAR_BACKSPACE '\b'
00133 #endif
00134 #ifndef EDIT_CHAR_ALARM
00135
00136 #define EDIT_CHAR_ALARM '\a'
00137 #endif
00138 #ifndef EDIT_STR_EOL
00139
00140 #define EDIT_STR_EOL "\r\n"
00141 #endif
00142
00144 #ifndef EDIT_DISABLE_HISTORY
00145
00146 typedef struct _EDITHISTORY {
00148 int hist_siz;
00150 char **hist_tab;
00151 } EDITHISTORY;
00152 #endif
00153
00155 typedef int (*EDLINEGET) (void *);
00157 typedef int (*EDLINEPUT) (void *, int);
00159 typedef int (*EDLINEMAP) (int, int *);
00160
00162 typedef struct _EDLINE {
00164 EDLINEGET el_get;
00166 void *el_iparm;
00168 EDLINEPUT el_put;
00170 void *el_oparm;
00172 EDLINEMAP el_map;
00174 uint_fast16_t el_mode;
00176 int el_seq;
00177 #ifndef EDIT_DISABLE_HISTORY
00178
00179 EDITHISTORY *el_hist;
00180 #endif
00181 } EDLINE;
00182
00185 __BEGIN_DECLS
00186
00187 extern EDLINE *EdLineOpen(uint16_t mode);
00188 extern void EdLineClose(EDLINE *el);
00189 extern int EdLineRead(EDLINE *el, char *buf, int siz);
00190
00191 #ifndef EDIT_DISABLE_HISTORY
00192 extern EDITHISTORY *EditHistoryCreate(int siz);
00193 extern void EditHistoryDestroy(EDITHISTORY *hist);
00194 extern void EditHistorySet(EDITHISTORY *hist, int idx, char *buf);
00195 extern int EditHistoryGet(EDITHISTORY *hist, int idx, char *buf, int siz);
00196 extern void EditHistoryInsert(EDITHISTORY *hist, int idx, char *buf);
00197 #endif
00198
00199 extern void EdLineRegisterKeymap(EDLINE *el, EDLINEMAP map);
00200 extern int EdLineKeyMap(int key, int *seq);
00201 extern int EdLineKeyMapVt100(int key, int *seq);
00202
00203 extern void EdLineRegisterInput(EDLINE *el, EDLINEGET get, void *iparm);
00204 extern void EdLineRegisterOutput(EDLINE *el, EDLINEPUT put, void *oparm);
00205
00206 __END_DECLS
00207
00208 #endif