linenoise.h 2.4 KB

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