linenoise.h 2.5 KB

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