1 /* 2 * vim: filetype=c:tabstop=4:ai:expandtab 3 * SPDX-License-Identifier: BSD-2-Clause 4 * scspell-id: 736ea385-f62a-11ec-9ef9-80ee73e9b8e7 5 * 6 * ------------------------------------------------------------------------- 7 * 8 * linehistory.h 9 * 10 * linehistory is forked from linenoise; the original version 11 * is available from https://github.com/antirez/linenoise 12 * 13 * ------------------------------------------------------------------------ 14 * 15 * Copyright (c) 2010-2014 Salvatore Sanfilippo <antirez@gmail.com> 16 * Copyright (c) 2010-2013 Pieter Noordhuis <pcnoordhuis@gmail.com> 17 * Copyright (c) 2020-2021 Jeffrey H. Johnson <trnsz@pobox.com> 18 * Copyright (c) 2021-2022 The DPS8M Development Team 19 * 20 * All rights reserved. 21 * 22 * Redistribution and use in source and binary forms, with or without 23 * modification, are permitted provided that the following conditions are 24 * met: 25 * 26 * * Redistributions of source code must retain the above copyright 27 * notice, this list of conditions and the following disclaimer. 28 * 29 * * Redistributions in binary form must reproduce the above copyright 30 * notice, this list of conditions and the following disclaimer in the 31 * documentation and/or other materials provided with the distribution. 32 * 33 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 34 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 35 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 36 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 37 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 38 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 39 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 40 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 41 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 42 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 43 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 44 * 45 * ------------------------------------------------------------------------- 46 */ 47 48 #ifndef _POSIX_C_SOURCE 49 # define _POSIX_C_SOURCE 200809L 50 #endif /* ifndef _POSIX_C_SOURCE */ 51 52 #ifndef __LINENOISE_H 53 # define __LINENOISE_H 54 55 # if !defined ( __MINGW32__ ) \ 56 && !defined ( CROSS_MINGW32 ) \ 57 && !defined ( CROSS_MINGW64 ) \ 58 && !defined ( __MINGW64__ ) \ 59 && !defined ( _MSC_VER ) \ 60 && !defined ( _MSC_BUILD ) 61 62 # ifndef HAVE_LINEHISTORY 63 # define HAVE_LINEHISTORY 64 # endif /* ifndef HAVE_LINEHISTORY */ 65 66 # include <stddef.h> 67 # include <signal.h> /* raise */ 68 69 # ifdef LH_COMPLETION 70 typedef struct linenoiseCompletions 71 { 72 size_t len; 73 char **cvec; 74 } linenoiseCompletions; 75 76 typedef void (linenoiseCompletionCallback) (const char *, 77 linenoiseCompletions *); 78 void linenoiseSetCompletionCallback(linenoiseCompletionCallback *); 79 void linenoiseAddCompletion(linenoiseCompletions *, const char *); 80 # endif /* ifdef LH_COMPLETION */ 81 82 # ifdef LH_HINTS 83 typedef void (linenoiseFreeHintsCallback) (void *); 84 typedef char *(linenoiseHintsCallback)(const char *, int *color, int *bold); 85 void linenoiseSetHintsCallback(linenoiseHintsCallback *); 86 void linenoiseSetFreeHintsCallback(linenoiseFreeHintsCallback *); 87 # endif /* ifdef LH_HINTS */ 88 89 char *linenoise(const char *prompt); 90 void linenoiseFree(void *ptr); 91 int linenoiseHistoryAdd(const char *line); 92 int linenoiseHistorySetMaxLen(int len); 93 int linenoiseHistorySave(const char *filename); 94 int linenoiseHistoryLoad(const char *filename); 95 void linenoiseClearScreen(void); 96 void linenoiseSetMultiLine(int ml); 97 void linenoisePrintKeyCodes(void); 98 # ifdef LH_MASKMODE 99 void linenoiseMaskModeEnable(void); 100 void linenoiseMaskModeDisable(void); 101 # endif /* ifdef LH_MASKMODE */ 102 103 # endif /* if !defined (__MINGW32__) \ 104 && !defined (__MINGW64__) \ 105 && !defined (CROSS_MINGW32) \ 106 && !defined (CROSS_MINGW64) \ 107 && !defined (_MSC_VER) \ 108 && !defined (_MSC_BUILD) */ 109 110 #endif /* if __LINENOISE_H */