window.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /* window.h -- Structure and flags used in manipulating Info windows.
  2. $Id$
  3. Copyright 1993, 1997, 2004, 2007, 2011 2013, 2014, 2015, 2016, 2017
  4. Free Software Foundation, Inc.
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. Originally written by Brian Fox. */
  16. #ifndef INFO_WINDOW_H
  17. #define INFO_WINDOW_H
  18. #include "doc.h"
  19. #include "nodes.h"
  20. #include <regex.h>
  21. /* Smallest number of visible lines in a window. The actual height is
  22. always one more than this number because each window has a modeline. */
  23. #define WINDOW_MIN_HEIGHT 2
  24. /* Smallest number of screen lines that can be used to fully present a
  25. window. This number includes the modeline of the window. */
  26. #define WINDOW_MIN_SIZE (WINDOW_MIN_HEIGHT + 1)
  27. /* A line map structure keeps a table of point values corresponding to
  28. column offsets within the current line. It is used to convert
  29. point values into columns on screen and vice versa. */
  30. typedef struct line_map_struct
  31. {
  32. NODE *node; /* Node to which this line pertains */
  33. size_t nline; /* Line number for which the map is computed. */
  34. size_t size; /* Number of elements map can accomodate */
  35. size_t used; /* Number of used map slots */
  36. long *map; /* The map itself */
  37. } LINE_MAP;
  38. /* The exact same elements are used within the WINDOW_STATE structure and a
  39. subsection of the WINDOW structure. We could define a structure which
  40. contains this elements, and include that structure in each of WINDOW_STATE
  41. and WINDOW. But that would lead references in the code such as
  42. window->state->node which we would like to avoid. Instead, we #define the
  43. elements here, and simply include the define in both data structures. Thus,
  44. if you need to change window state information, here is where you would
  45. do it. NB> The last element does NOT end with a semi-colon. */
  46. #define WINDOW_STATE_DECL \
  47. NODE *node; /* The node displayed in this window. */ \
  48. long pagetop; /* LINE_STARTS[PAGETOP] is first line in WINDOW. */ \
  49. long point /* Offset within NODE of the cursor position. */
  50. typedef struct {
  51. WINDOW_STATE_DECL; /* What gets saved. */
  52. } WINDOW_STATE;
  53. typedef struct match_struct
  54. {
  55. regmatch_t *matches; /* Array of matches */
  56. size_t match_count;
  57. size_t match_alloc;
  58. int finished; /* Non-zero if all possible matches are stored. */
  59. regex_t regex;
  60. char *buffer;
  61. size_t buflen;
  62. } MATCH_STATE;
  63. /* Structure which defines a window. Windows are doubly linked, next
  64. and prev. The list of windows is kept on WINDOWS. The structure member
  65. window->height is the total height of the window. The position location
  66. (0, window->height + window->first_row) is the first character of this
  67. windows modeline. The number of lines that can be displayed in a window
  68. is equal to window->height - 1. */
  69. typedef struct window_struct
  70. {
  71. struct window_struct *next; /* Next window in this chain. */
  72. struct window_struct *prev; /* Previous window in this chain. */
  73. long width; /* Width of this window. */
  74. long height; /* Height of this window. */
  75. long first_row; /* Offset of the first line in the_screen. */
  76. long goal_column; /* Column to place the cursor in when moving it up and
  77. down. -1 means the column it is currently in. */
  78. WINDOW_STATE_DECL; /* Node, pagetop and point. */
  79. LINE_MAP line_map; /* Current line map */
  80. char *modeline; /* Calculated text of the modeline for this window. */
  81. long *line_starts; /* Offsets of printed line starts in node->contents.*/
  82. long *log_line_no; /* Number of logical line corresponding to each
  83. physical one. */
  84. long line_count; /* Number of printed lines in node. */
  85. size_t line_slots; /* Allocated space in LINE_STARTS and LOG_LINE_NO. */
  86. int flags; /* See below for details. */
  87. /* Used for highlighting search matches. */
  88. char *search_string;
  89. int search_is_case_sensitive;
  90. MATCH_STATE matches;
  91. /* History of nodes visited in this window. */
  92. WINDOW_STATE **hist; /* Nodes visited in this window, including current. */
  93. size_t hist_index; /* Index where to add the next node. */
  94. size_t hist_slots; /* Number of slots allocated to HIST. */
  95. } WINDOW;
  96. #define W_UpdateWindow 0x01 /* WINDOW needs updating. */
  97. #define W_WindowIsPerm 0x02 /* This WINDOW is a permanent object. */
  98. #define W_WindowVisible 0x04 /* This WINDOW is currently visible. */
  99. #define W_InhibitMode 0x08 /* This WINDOW has no modeline. */
  100. #define W_NoWrap 0x10 /* Lines do not wrap in this window. */
  101. #define W_InputWindow 0x20 /* Window accepts input. */
  102. #define W_TempWindow 0x40 /* Window is less important. */
  103. extern WINDOW *windows; /* List of visible Info windows. */
  104. extern WINDOW *active_window; /* The currently active window. */
  105. extern WINDOW *the_screen; /* The Info screen is just another window. */
  106. extern WINDOW *the_echo_area; /* THE_ECHO_AREA is a window in THE_SCREEN. */
  107. extern int show_malformed_multibyte_p; /* Show malformed multibyte sequences */
  108. /* Global variable control redisplay of scrolled windows. If non-zero, it
  109. is the desired number of lines to scroll the window in order to make
  110. point visible. A user might set this to 1 for smooth scrolling. If
  111. set to zero, the line containing point is centered within the window. */
  112. extern int window_scroll_step;
  113. /* Make the modeline member for WINDOW. */
  114. void window_make_modeline (WINDOW *window);
  115. /* Initalize the window system by creating THE_SCREEN and THE_ECHO_AREA.
  116. Create the first window ever, and make it permanent.
  117. You pass WIDTH and HEIGHT; the dimensions of the total screen size. */
  118. void window_initialize_windows (int width, int height);
  119. /* Make a new window by splitting an existing one. If the window could
  120. not be made return a null pointer. The active window is not changed .*/
  121. WINDOW *window_make_window (void);
  122. /* Delete WINDOW from the list of known windows. If this window was the
  123. active window, make the next window in the chain be the active window,
  124. or the previous window in the chain if there is no next window. */
  125. void window_delete_window (WINDOW *window);
  126. /* Set WINDOW to display NODE. */
  127. void window_set_node_of_window (WINDOW *window, NODE *node);
  128. /* Tell the window system that the size of the screen has changed. This
  129. causes lots of interesting things to happen. The permanent windows
  130. are resized, as well as every visible window. You pass WIDTH and HEIGHT;
  131. the dimensions of the total screen size. */
  132. void window_new_screen_size (int width, int height);
  133. /* Change the height of WINDOW by AMOUNT. This also automagically adjusts
  134. the previous and next windows in the chain. If there is only one user
  135. window, then no change takes place. */
  136. void window_change_window_height (WINDOW *window, int amount);
  137. void set_window_pagetop (WINDOW *window, int desired_top);
  138. /* Adjust the pagetop of WINDOW such that the cursor point will be visible. */
  139. void window_adjust_pagetop (WINDOW *window);
  140. /* Tile all of the windows currently displayed in the global variable
  141. WINDOWS. If argument DO_INTERNALS is non-zero, tile windows displaying
  142. internal nodes as well. */
  143. #define DONT_TILE_INTERNALS 0
  144. #define TILE_INTERNALS 1
  145. void window_tile_windows (int style);
  146. /* Toggle the state of line wrapping in WINDOW. This can do a bit of fancy
  147. redisplay. */
  148. void window_toggle_wrap (WINDOW *window);
  149. /* For every window in CHAIN, set the flags member to have FLAG set. */
  150. void window_mark_chain (WINDOW *chain, int flag);
  151. /* For every window in CHAIN, clear the flags member of FLAG. */
  152. void window_unmark_chain (WINDOW *chain, int flag);
  153. /* Make WINDOW start displaying at PERCENT percentage of its node. */
  154. void window_goto_percentage (WINDOW *window, int percent);
  155. /* Build a new node which has AP printed according to FORMAT as the
  156. contents. */
  157. NODE *build_message_node (const char *format, va_list ap);
  158. NODE *format_message_node (const char *format, ...)
  159. TEXINFO_PRINTFLIKE(1,2);
  160. struct text_buffer;
  161. NODE *text_buffer_to_node (struct text_buffer *tb);
  162. /* Make a message appear in the echo area, built from arguments formatted
  163. according to FORMAT.
  164. The message appears immediately. If there was
  165. already a message appearing in the echo area, it is removed. */
  166. void window_message_in_echo_area (const char *format, ...)
  167. TEXINFO_PRINTFLIKE(1,2);
  168. void vwindow_message_in_echo_area (const char *format, va_list ap);
  169. void free_echo_area (void);
  170. /* Place a temporary message in the echo area built from arguments
  171. formatted as per FORMAT.
  172. The message appears immediately, but does not destroy
  173. any existing message. A future call to unmessage_in_echo_area ()
  174. restores the old contents. */
  175. void message_in_echo_area (const char *format, ...)
  176. TEXINFO_PRINTFLIKE(1,2);
  177. void unmessage_in_echo_area (void);
  178. /* Clear the echo area, removing any message that is already present.
  179. The echo area is cleared immediately. */
  180. void window_clear_echo_area (void);
  181. /* Return the index of the line containing point. */
  182. int window_line_of_point (WINDOW *window);
  183. /* Get and return the printed column offset of the cursor in this window. */
  184. int window_get_cursor_column (WINDOW *window);
  185. void window_compute_line_map (WINDOW *win);
  186. int window_point_to_column (WINDOW *win, long point, long *np);
  187. void window_line_map_init (WINDOW *win);
  188. long window_log_to_phys_line (WINDOW *window, long ln);
  189. void calculate_line_starts (WINDOW *window);
  190. #endif /* not INFO_WINDOW_H */