1 /** \file linenoise.h 2 * 3 * \brief guerrilla line editing library against the idea that a 4 * line editing lib needs to be 20,000 lines of C code - header 5 * 6 * See linenoise.c for more information. 7 * 8 * ------------------------------------------------------------------------ 9 * 10 * Copyright (c) 2010, Salvatore Sanfilippo <antirez at gmail dot com> 11 * Copyright (c) 2010, Pieter Noordhuis <pcnoordhuis at gmail dot com> 12 * 13 * All rights reserved. 14 * 15 * Redistribution and use in source and binary forms, with or without 16 * modification, are permitted provided that the following conditions are 17 * met: 18 * 19 * * Redistributions of source code must retain the above copyright 20 * notice, this list of conditions and the following disclaimer. 21 * 22 * * Redistributions in binary form must reproduce the above copyright 23 * notice, this list of conditions and the following disclaimer in the 24 * documentation and/or other materials provided with the distribution. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 */ 38 39 #ifndef __LINENOISE_H 40 #define __LINENOISE_H 41 42 #include "vice.h" 43 44 typedef struct linenoiseCompletions { 45 size_t len; 46 char **cvec; 47 } linenoiseCompletions; 48 49 struct console_private_s; 50 51 typedef void(linenoiseCompletionCallback)(const char *, linenoiseCompletions *); 52 void linenoiseSetCompletionCallback(linenoiseCompletionCallback *); 53 void linenoiseAddCompletion(linenoiseCompletions *, char *); 54 55 char *linenoise(const char *prompt, struct console_private_s *term); 56 int linenoiseHistoryAdd(const char *line); 57 int linenoiseHistorySetMaxLen(int len); 58 int linenoiseHistorySave(char *filename); 59 int linenoiseHistoryLoad(char *filename); 60 void linenoiseClearScreen(struct console_private_s *term); 61 62 #endif /* __LINENOISE_H */ 63