chared.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /* $NetBSD: chared.h,v 1.8 2002/03/18 16:00:51 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. * @(#)chared.h 8.1 (Berkeley) 6/4/93
  38. */
  39. /*
  40. * el.chared.h: Character editor interface
  41. */
  42. #ifndef _h_el_chared
  43. #define _h_el_chared
  44. #include <ctype.h>
  45. #include <string.h>
  46. #include "histedit.h"
  47. #define EL_MAXMACRO 10
  48. /*
  49. * This is a issue of basic "vi" look-and-feel. Defining VI_MOVE works
  50. * like real vi: i.e. the transition from command<->insert modes moves
  51. * the cursor.
  52. *
  53. * On the other hand we really don't want to move the cursor, because
  54. * all the editing commands don't include the character under the cursor.
  55. * Probably the best fix is to make all the editing commands aware of
  56. * this fact.
  57. */
  58. #define VI_MOVE
  59. typedef struct c_macro_t {
  60. int level;
  61. char **macro;
  62. char *nline;
  63. } c_macro_t;
  64. /*
  65. * Undo information for both vi and emacs
  66. */
  67. typedef struct c_undo_t {
  68. int action;
  69. size_t isize;
  70. size_t dsize;
  71. char *ptr;
  72. char *buf;
  73. } c_undo_t;
  74. /*
  75. * Current action information for vi
  76. */
  77. typedef struct c_vcmd_t {
  78. int action;
  79. char *pos;
  80. char *ins;
  81. } c_vcmd_t;
  82. /*
  83. * Kill buffer for emacs
  84. */
  85. typedef struct c_kill_t {
  86. char *buf;
  87. char *last;
  88. char *mark;
  89. } c_kill_t;
  90. /*
  91. * Note that we use both data structures because the user can bind
  92. * commands from both editors!
  93. */
  94. typedef struct el_chared_t {
  95. c_undo_t c_undo;
  96. c_kill_t c_kill;
  97. c_vcmd_t c_vcmd;
  98. c_macro_t c_macro;
  99. } el_chared_t;
  100. #define STReof "^D\b\b"
  101. #define STRQQ "\"\""
  102. #define isglob(a) (strchr("*[]?", (a)) != NULL)
  103. #define isword(a) (isprint(a))
  104. #define NOP 0x00
  105. #define DELETE 0x01
  106. #define INSERT 0x02
  107. #define CHANGE 0x04
  108. #define CHAR_FWD 0
  109. #define CHAR_BACK 1
  110. #define MODE_INSERT 0
  111. #define MODE_REPLACE 1
  112. #define MODE_REPLACE_1 2
  113. #include "common.h"
  114. #include "vi.h"
  115. #include "emacs.h"
  116. #include "search.h"
  117. #include "fcns.h"
  118. protected int cv__isword(int);
  119. protected void cv_delfini(EditLine *);
  120. protected char *cv__endword(char *, char *, int);
  121. protected int ce__isword(int);
  122. protected void cv_undo(EditLine *, int, size_t, char *);
  123. protected char *cv_next_word(EditLine*, char *, char *, int, int (*)(int));
  124. protected char *cv_prev_word(EditLine*, char *, char *, int, int (*)(int));
  125. protected char *c__next_word(char *, char *, int, int (*)(int));
  126. protected char *c__prev_word(char *, char *, int, int (*)(int));
  127. protected void c_insert(EditLine *, int);
  128. protected void c_delbefore(EditLine *, int);
  129. protected void c_delafter(EditLine *, int);
  130. protected int c_gets(EditLine *, char *);
  131. protected int c_hpos(EditLine *);
  132. protected int ch_init(EditLine *);
  133. protected void ch_reset(EditLine *);
  134. protected int ch_enlargebufs(EditLine *, size_t);
  135. protected void ch_end(EditLine *);
  136. #endif /* _h_el_chared */