term.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /* $NetBSD: term.h,v 1.13 2002/03/18 16:01:00 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. * @(#)term.h 8.1 (Berkeley) 6/4/93
  38. */
  39. /*
  40. * el.term.h: Termcap header
  41. */
  42. #ifndef _h_el_term
  43. #define _h_el_term
  44. #include "histedit.h"
  45. typedef struct { /* Symbolic function key bindings */
  46. const char *name; /* name of the key */
  47. int key; /* Index in termcap table */
  48. key_value_t fun; /* Function bound to it */
  49. int type; /* Type of function */
  50. } fkey_t;
  51. typedef struct {
  52. coord_t t_size; /* # lines and cols */
  53. int t_flags;
  54. #define TERM_CAN_INSERT 0x001 /* Has insert cap */
  55. #define TERM_CAN_DELETE 0x002 /* Has delete cap */
  56. #define TERM_CAN_CEOL 0x004 /* Has CEOL cap */
  57. #define TERM_CAN_TAB 0x008 /* Can use tabs */
  58. #define TERM_CAN_ME 0x010 /* Can turn all attrs. */
  59. #define TERM_CAN_UP 0x020 /* Can move up */
  60. #define TERM_HAS_META 0x040 /* Has a meta key */
  61. #define TERM_HAS_AUTO_MARGINS 0x080 /* Has auto margins */
  62. #define TERM_HAS_MAGIC_MARGINS 0x100 /* Has magic margins */
  63. char *t_buf; /* Termcap buffer */
  64. int t_loc; /* location used */
  65. char **t_str; /* termcap strings */
  66. int *t_val; /* termcap values */
  67. char *t_cap; /* Termcap buffer */
  68. fkey_t *t_fkey; /* Array of keys */
  69. } el_term_t;
  70. /*
  71. * fKey indexes
  72. */
  73. #define A_K_DN 0
  74. #define A_K_UP 1
  75. #define A_K_LT 2
  76. #define A_K_RT 3
  77. #define A_K_HO 4
  78. #define A_K_EN 5
  79. #define A_K_NKEYS 6
  80. protected void term_move_to_line(EditLine *, int);
  81. protected void term_move_to_char(EditLine *, int);
  82. protected void term_clear_EOL(EditLine *, int);
  83. protected void term_overwrite(EditLine *, const char *, int);
  84. protected void term_insertwrite(EditLine *, char *, int);
  85. protected void term_deletechars(EditLine *, int);
  86. protected void term_clear_screen(EditLine *);
  87. protected void term_beep(EditLine *);
  88. protected int term_change_size(EditLine *, int, int);
  89. protected int term_get_size(EditLine *, int *, int *);
  90. protected int term_init(EditLine *);
  91. protected void term_bind_arrow(EditLine *);
  92. protected void term_print_arrow(EditLine *, const char *);
  93. protected int term_clear_arrow(EditLine *, const char *);
  94. protected int term_set_arrow(EditLine *, const char *, key_value_t *, int);
  95. protected void term_end(EditLine *);
  96. protected int term_set(EditLine *, const char *);
  97. protected int term_settc(EditLine *, int, const char **);
  98. protected int term_telltc(EditLine *, int, const char **);
  99. protected int term_echotc(EditLine *, int, const char **);
  100. protected int term__putc(int);
  101. protected void term__flush(void);
  102. /*
  103. * Easy access macros
  104. */
  105. #define EL_FLAGS (el)->el_term.t_flags
  106. #define EL_CAN_INSERT (EL_FLAGS & TERM_CAN_INSERT)
  107. #define EL_CAN_DELETE (EL_FLAGS & TERM_CAN_DELETE)
  108. #define EL_CAN_CEOL (EL_FLAGS & TERM_CAN_CEOL)
  109. #define EL_CAN_TAB (EL_FLAGS & TERM_CAN_TAB)
  110. #define EL_CAN_ME (EL_FLAGS & TERM_CAN_ME)
  111. #define EL_HAS_META (EL_FLAGS & TERM_HAS_META)
  112. #define EL_HAS_AUTO_MARGINS (EL_FLAGS & TERM_HAS_AUTO_MARGINS)
  113. #define EL_HAS_MAGIC_MARGINS (EL_FLAGS & TERM_HAS_MAGIC_MARGINS)
  114. #endif /* _h_el_term */