103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
* Sequence: ESC [ 2 J
* Effect: clear the whole screen
*
*/
#include <termios.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include "linenoise.h"
#define LINENOISE_DEFAULT_HISTORY_MAX_LEN 100
#define LINENOISE_MAX_LINE 4096
static const char *unsupported_term[] = {"dumb","cons25","emacs",NULL};
static linenoiseCompletionCallback *completionCallback = NULL;
static struct termios orig_termios; /* In order to restore at exit.*/
|
>
>
|
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
* Sequence: ESC [ 2 J
* Effect: clear the whole screen
*
*/
#include <termios.h>
#include <unistd.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include "linenoise.h"
#include "sqlite3.h"
#define LINENOISE_DEFAULT_HISTORY_MAX_LEN 100
#define LINENOISE_MAX_LINE 4096
static const char *unsupported_term[] = {"dumb","cons25","emacs",NULL};
static linenoiseCompletionCallback *completionCallback = NULL;
static struct termios orig_termios; /* In order to restore at exit.*/
|
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
} \
fprintf(lndebug_fp, ", " fmt, arg1); \
fflush(lndebug_fp); \
} while (0)
#else
#define lndebug(fmt, arg1)
#endif
/* ======================= Low level terminal handling ====================== */
/* Set if to use or not the multi line mode. */
void linenoiseSetMultiLine(int ml) {
mlmode = ml;
}
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
} \
fprintf(lndebug_fp, ", " fmt, arg1); \
fflush(lndebug_fp); \
} while (0)
#else
#define lndebug(fmt, arg1)
#endif
/* =========================== C89 compatibility ============================ */
/* snprintf() is not C89, but sqlite3_vsnprintf() can be adapted. */
static int linenoiseSnprintf(char *str, size_t size, const char *format, ...) {
va_list ap;
int result;
va_start(ap,format);
result = strlen(sqlite3_vsnprintf((int)size,str,format,ap));
va_end(ap);
return result;
}
#undef snprintf
#define snprintf linenoiseSnprintf
/* strdup() is technically not standard C89 despite being in POSIX. */
static char *linenoiseStrdup(const char *s) {
int size = strlen(s)+1;
char *result = malloc(size);
if (result) memcpy(result,s,size);
return result;
}
#undef strdup
#define strdup linenoiseStrdup
/* strcasecmp() is not standard C89. SQLite offers a direct replacement. */
#undef strcasecmp
#define strcasecmp sqlite3_stricmp
/* ======================= Low level terminal handling ====================== */
/* Set if to use or not the multi line mode. */
void linenoiseSetMultiLine(int ml) {
mlmode = ml;
}
|