el.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /* $NetBSD: el.h,v 1.11 2002/03/18 16:00:52 christos Exp $ */
  2. /*-
  3. * Copyright (c) 1992, 1993
  4. * The Regents of the University of California. All rights reserved.
  5. *
  6. * This code is derived from software contributed to Berkeley by
  7. * Christos Zoulas of Cornell University.
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions
  11. * are met:
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in the
  16. * documentation and/or other materials provided with the distribution.
  17. * 3. All advertising materials mentioning features or use of this software
  18. * must display the following acknowledgement:
  19. * This product includes software developed by the University of
  20. * California, Berkeley and its contributors.
  21. * 4. Neither the name of the University nor the names of its contributors
  22. * may be used to endorse or promote products derived from this software
  23. * without specific prior written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  26. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  28. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  29. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  30. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  31. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  32. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  33. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  34. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  35. * SUCH DAMAGE.
  36. *
  37. * @(#)el.h 8.1 (Berkeley) 6/4/93
  38. */
  39. /*
  40. * el.h: Internal structures.
  41. */
  42. #ifndef _h_el
  43. #define _h_el
  44. /*
  45. * Local defaults
  46. */
  47. #define KSHVI
  48. #define VIDEFAULT
  49. #define ANCHOR
  50. #include <stdio.h>
  51. #include <sys/types.h>
  52. #define EL_BUFSIZ 1024 /* Maximum line size */
  53. #define HANDLE_SIGNALS 1<<0
  54. #define NO_TTY 1<<1
  55. #define EDIT_DISABLED 1<<2
  56. typedef int bool_t; /* True or not */
  57. typedef unsigned char el_action_t; /* Index to command array */
  58. typedef struct coord_t { /* Position on the screen */
  59. int h;
  60. int v;
  61. } coord_t;
  62. typedef struct el_line_t {
  63. char *buffer; /* Input line */
  64. char *cursor; /* Cursor position */
  65. char *lastchar; /* Last character */
  66. const char *limit; /* Max position */
  67. } el_line_t;
  68. /*
  69. * Editor state
  70. */
  71. typedef struct el_state_t {
  72. int inputmode; /* What mode are we in? */
  73. int doingarg; /* Are we getting an argument? */
  74. int argument; /* Numeric argument */
  75. int metanext; /* Is the next char a meta char */
  76. el_action_t lastcmd; /* Previous command */
  77. } el_state_t;
  78. /*
  79. * Until we come up with something better...
  80. */
  81. #define el_malloc(a) malloc(a)
  82. #define el_realloc(a,b) realloc(a, b)
  83. #define el_free(a) free(a)
  84. #include "tty.h"
  85. #include "prompt.h"
  86. #include "key.h"
  87. #include "term.h"
  88. #include "refresh.h"
  89. #include "chared.h"
  90. #include "common.h"
  91. #include "search.h"
  92. #include "hist.h"
  93. #include "map.h"
  94. #include "parse.h"
  95. #include "sig.h"
  96. #include "help.h"
  97. #include "read.h"
  98. struct editline {
  99. char *el_prog; /* the program name */
  100. FILE *el_outfile; /* Stdio stuff */
  101. FILE *el_errfile; /* Stdio stuff */
  102. int el_infd; /* Input file descriptor */
  103. int el_flags; /* Various flags. */
  104. coord_t el_cursor; /* Cursor location */
  105. char **el_display; /* Real screen image = what is there */
  106. char **el_vdisplay; /* Virtual screen image = what we see */
  107. void *el_data; /* Client data */
  108. el_line_t el_line; /* The current line information */
  109. el_state_t el_state; /* Current editor state */
  110. el_term_t el_term; /* Terminal dependent stuff */
  111. el_tty_t el_tty; /* Tty dependent stuff */
  112. el_refresh_t el_refresh; /* Refresh stuff */
  113. el_prompt_t el_prompt; /* Prompt stuff */
  114. el_prompt_t el_rprompt; /* Prompt stuff */
  115. el_chared_t el_chared; /* Characted editor stuff */
  116. el_map_t el_map; /* Key mapping stuff */
  117. el_key_t el_key; /* Key binding stuff */
  118. el_history_t el_history; /* History stuff */
  119. el_search_t el_search; /* Search stuff */
  120. el_signal_t el_signal; /* Signal handling stuff */
  121. el_read_t el_read; /* Character reading stuff */
  122. };
  123. protected int el_editmode(EditLine *, int, const char **);
  124. #ifdef DEBUG
  125. #define EL_ABORT(a) (void) (fprintf(el->el_errfile, "%s, %d: ", \
  126. __FILE__, __LINE__), fprintf a, abort())
  127. #else
  128. #define EL_ABORT(a) abort()
  129. #endif
  130. #endif /* _h_el */