1 //===-- editlinewin.h -------------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #pragma once 10 11 #include <stdio.h> 12 13 // EditLine editor function return codes. 14 // For user-defined function interface 15 #define CC_NORM 0 16 #define CC_NEWLINE 1 17 #define CC_EOF 2 18 #define CC_ARGHACK 3 19 #define CC_REFRESH 4 20 #define CC_CURSOR 5 21 #define CC_ERROR 6 22 #define CC_FATAL 7 23 #define CC_REDISPLAY 8 24 #define CC_REFRESH_BEEP 9 25 26 // el_set/el_get parameters 27 #define EL_PROMPT 0 // , el_pfunc_t 28 #define EL_TERMINAL 1 // , const char * 29 #define EL_EDITOR 2 // , const char * 30 #define EL_SIGNAL 3 // , int); 31 #define EL_BIND 4 // , const char *, ..., NULL 32 #define EL_TELLTC 5 // , const char *, ..., NULL 33 #define EL_SETTC 6 // , const char *, ..., NULL 34 #define EL_ECHOTC 7 // , const char *, ..., NULL 35 #define EL_SETTY 8 // , const char *, ..., NULL 36 #define EL_ADDFN 9 // , const char *, const char *, el_func_t 37 #define EL_HIST 10 // , hist_fun_t, const char * 38 #define EL_EDITMODE 11 // , int 39 #define EL_RPROMPT 12 // , el_pfunc_t 40 #define EL_GETCFN 13 // , el_rfunc_t 41 #define EL_CLIENTDATA 14 // , void * 42 #define EL_UNBUFFERED 15 // , int 43 #define EL_PREP_TERM 16 // , int 44 #define EL_GETTC 17 // , const char *, ..., NULL 45 #define EL_GETFP 18 // , int, FILE ** 46 #define EL_SETFP 19 // , int, FILE * 47 #define EL_REFRESH 20 // , void 48 #define EL_PROMPT_ESC 21 // , prompt_func, Char); set/get 49 50 #define EL_BUILTIN_GETCFN (NULL) 51 52 // history defines 53 #define H_FUNC 0 // , UTSL 54 #define H_SETSIZE 1 // , const int 55 #define H_GETSIZE 2 // , void 56 #define H_FIRST 3 // , void 57 #define H_LAST 4 // , void 58 #define H_PREV 5 // , void 59 #define H_NEXT 6 // , void 60 #define H_CURR 8 // , const int 61 #define H_SET 7 // , int 62 #define H_ADD 9 // , const char * 63 #define H_ENTER 10 // , const char * 64 #define H_APPEND 11 // , const char * 65 #define H_END 12 // , void 66 #define H_NEXT_STR 13 // , const char * 67 #define H_PREV_STR 14 // , const char * 68 #define H_NEXT_EVENT 15 // , const int 69 #define H_PREV_EVENT 16 // , const int 70 #define H_LOAD 17 // , const char * 71 #define H_SAVE 18 // , const char * 72 #define H_CLEAR 19 // , void 73 #define H_SETUNIQUE 20 // , int 74 #define H_GETUNIQUE 21 // , void 75 #define H_DEL 22 // , int 76 77 struct EditLine {}; 78 79 struct LineInfo { 80 const char *buffer; 81 const char *cursor; 82 const char *lastchar; 83 }; 84 85 struct History {}; 86 87 struct HistEvent { 88 int num; 89 const char *str; 90 }; 91 92 extern "C" { 93 // edit line API 94 EditLine *el_init(const char *, FILE *, FILE *, FILE *); 95 const char *el_gets(EditLine *, int *); 96 int el_set(EditLine *, int, ...); 97 98 void el_end(EditLine *); 99 void el_reset(EditLine *); 100 int el_getc(EditLine *, char *); 101 void el_push(EditLine *, const char *); 102 void el_beep(EditLine *); 103 int el_parse(EditLine *, int, const char **); 104 int el_get(EditLine *, int, ...); 105 int el_source(EditLine *, const char *); 106 void el_resize(EditLine *); 107 const LineInfo *el_line(EditLine *); 108 int el_insertstr(EditLine *, const char *); 109 void el_deletestr(EditLine *, int); 110 111 // history API 112 History *history_init(void); 113 void history_end(History *); 114 int history(History *, HistEvent *, int, ...); 115 }; 116