window.h revision 21495
1272343Sngie/* window.h -- Structure and flags used in manipulating Info windows. */ 2272343Sngie 3272343Sngie/* This file is part of GNU Info, a program for reading online documentation 4272343Sngie stored in Info format. 5272343Sngie 6272343Sngie Copyright (C) 1993 Free Software Foundation, Inc. 7272343Sngie 8272343Sngie This program is free software; you can redistribute it and/or modify 9272343Sngie it under the terms of the GNU General Public License as published by 10272343Sngie the Free Software Foundation; either version 2, or (at your option) 11272343Sngie any later version. 12272343Sngie 13272343Sngie This program is distributed in the hope that it will be useful, 14272343Sngie but WITHOUT ANY WARRANTY; without even the implied warranty of 15272343Sngie MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16272343Sngie GNU General Public License for more details. 17272343Sngie 18272343Sngie You should have received a copy of the GNU General Public License 19272343Sngie along with this program; if not, write to the Free Software 20272343Sngie Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21272343Sngie 22 Written by Brian Fox (bfox@ai.mit.edu). */ 23 24#if !defined (_WINDOW_H_) 25#define _WINDOW_H_ 26 27#include "nodes.h" 28#include "infomap.h" 29 30/* Smallest number of visible lines in a window. The actual height is 31 always one more than this number because each window has a modeline. */ 32#define WINDOW_MIN_HEIGHT 2 33 34/* Smallest number of screen lines that can be used to fully present a 35 window. This number includes the modeline of the window. */ 36#define WINDOW_MIN_SIZE (WINDOW_MIN_HEIGHT + 1) 37 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 int pagetop; /* LINE_STARTS[PAGETOP] is first line in WINDOW. */ \ 49 long point /* Offset within NODE of the cursor position. */ 50 51/* Structure which defines a window. Windows are doubly linked, next 52 and prev. The list of windows is kept on WINDOWS. The structure member 53 window->height is the total height of the window. The position location 54 (0, window->height + window->first_row) is the first character of this 55 windows modeline. The number of lines that can be displayed in a window 56 is equal to window->height - 1. */ 57typedef struct __window__ { 58 struct __window__ *next; /* Next window in this chain. */ 59 struct __window__ *prev; /* Previous window in this chain. */ 60 int width; /* Width of this window. */ 61 int height; /* Height of this window. */ 62 int first_row; /* Offset of the first line in the_screen. */ 63 int goal_column; /* The column we would like the cursor to appear in. */ 64 Keymap keymap; /* Keymap used to read commands in this window. */ 65 WINDOW_STATE_DECL; /* Node, pagetop and point. */ 66 char *modeline; /* Calculated text of the modeline for this window. */ 67 char **line_starts; /* Array of printed line starts for this node. */ 68 int line_count; /* Number of lines appearing in LINE_STARTS. */ 69 int flags; /* See below for details. */ 70} WINDOW; 71 72typedef struct { 73 WINDOW_STATE_DECL; /* What gets saved. */ 74} WINDOW_STATE; 75 76#define W_UpdateWindow 0x01 /* WINDOW needs updating. */ 77#define W_WindowIsPerm 0x02 /* This WINDOW is a permanent object. */ 78#define W_WindowVisible 0x04 /* This WINDOW is currently visible. */ 79#define W_InhibitMode 0x08 /* This WINDOW has no modeline. */ 80#define W_NoWrap 0x10 /* Lines do not wrap in this window. */ 81#define W_InputWindow 0x20 /* Window accepts input. */ 82#define W_TempWindow 0x40 /* Window is less important. */ 83 84extern WINDOW *windows; /* List of visible Info windows. */ 85extern WINDOW *active_window; /* The currently active window. */ 86extern WINDOW *the_screen; /* The Info screen is just another window. */ 87extern WINDOW *the_echo_area; /* THE_ECHO_AREA is a window in THE_SCREEN. */ 88 89/* Global variable control redisplay of scrolled windows. If non-zero, it 90 is the desired number of lines to scroll the window in order to make 91 point visible. A user might set this to 1 for smooth scrolling. If 92 set to zero, the line containing point is centered within the window. */ 93extern int window_scroll_step; 94 95 /* Make the modeline member for WINDOW. */ 96extern void window_make_modeline (); 97 98/* Initalize the window system by creating THE_SCREEN and THE_ECHO_AREA. 99 Create the first window ever, and make it permanent. 100 You pass WIDTH and HEIGHT; the dimensions of the total screen size. */ 101extern void window_initialize_windows (); 102 103/* Make a new window showing NODE, and return that window structure. 104 The new window is made to be the active window. If NODE is passed 105 as NULL, then show the node showing in the active window. If the 106 window could not be made return a NULL pointer. The active window 107 is not changed.*/ 108extern WINDOW *window_make_window (); 109 110/* Delete WINDOW from the list of known windows. If this window was the 111 active window, make the next window in the chain be the active window, 112 or the previous window in the chain if there is no next window. */ 113extern void window_delete_window (); 114 115/* A function to call when the screen changes size, and some windows have 116 to get deleted. The function is called with the window to be deleted 117 as an argument, and it can't do anything about the window getting deleted; 118 it can only clean up dangling references to that window. */ 119extern VFunction *window_deletion_notifier; 120 121/* Set WINDOW to display NODE. */ 122extern void window_set_node_of_window (); 123 124/* Tell the window system that the size of the screen has changed. This 125 causes lots of interesting things to happen. The permanent windows 126 are resized, as well as every visible window. You pass WIDTH and HEIGHT; 127 the dimensions of the total screen size. */ 128extern void window_new_screen_size (); 129 130/* Change the height of WINDOW by AMOUNT. This also automagically adjusts 131 the previous and next windows in the chain. If there is only one user 132 window, then no change takes place. */ 133extern void window_change_window_height (); 134 135/* Adjust the pagetop of WINDOW such that the cursor point will be visible. */ 136extern void window_adjust_pagetop (); 137 138/* Tile all of the windows currently displayed in the global variable 139 WINDOWS. If argument DO_INTERNALS is non-zero, tile windows displaying 140 internal nodes as well. */ 141#define DONT_TILE_INTERNALS 0 142#define TILE_INTERNALS 1 143extern void window_tile_windows (); 144 145/* Toggle the state of line wrapping in WINDOW. This can do a bit of fancy 146 redisplay. */ 147extern void window_toggle_wrap (); 148 149/* For every window in CHAIN, set the flags member to have FLAG set. */ 150extern void window_mark_chain (); 151 152/* For every window in CHAIN, clear the flags member of FLAG. */ 153extern void window_unmark_chain (); 154 155/* Make WINDOW start displaying at PERCENT percentage of its node. */ 156extern void window_goto_percentage (); 157 158/* Build a new node which has FORMAT printed with ARG1 and ARG2 as the 159 contents. */ 160extern NODE *build_message_node (); 161 162/* Useful functions can be called from outside of window.c. */ 163extern void initialize_message_buffer (); 164 165/* Print FORMAT with ARG1,2 to the end of the current message buffer. */ 166extern void printf_to_message_buffer (); 167 168/* Convert the contents of the message buffer to a node. */ 169extern NODE *message_buffer_to_node (); 170 171/* Return the length of the most recently printed line in message buffer. */ 172extern int message_buffer_length_this_line (); 173 174/* Pad STRING to COUNT characters by inserting blanks. */ 175extern int pad_to (); 176 177/* Make a message appear in the echo area, built from FORMAT, ARG1 and ARG2. 178 The arguments are treated similar to printf () arguments, but not all of 179 printf () hair is present. The message appears immediately. If there was 180 already a message appearing in the echo area, it is removed. */ 181extern void window_message_in_echo_area (); 182 183/* Place a temporary message in the echo area built from FORMAT, ARG1 184 and ARG2. The message appears immediately, but does not destroy 185 any existing message. A future call to unmessage_in_echo_area () 186 restores the old contents. */ 187extern void message_in_echo_area (); 188extern void unmessage_in_echo_area (); 189 190/* Clear the echo area, removing any message that is already present. 191 The echo area is cleared immediately. */ 192extern void window_clear_echo_area (); 193 194/* Quickly guess the approximate number of lines to that NODE would 195 take to display. This really only counts carriage returns. */ 196extern int window_physical_lines (); 197 198/* Calculate a list of line starts for the node belonging to WINDOW. The line 199 starts are pointers to the actual text within WINDOW->NODE. */ 200extern void calculate_line_starts (); 201 202/* Given WINDOW, recalculate the line starts for the node it displays. */ 203extern void recalculate_line_starts (); 204 205/* Return the number of characters it takes to display CHARACTER on the 206 screen at HPOS. */ 207extern int character_width (); 208 209/* Return the number of characters it takes to display STRING on the 210 screen at HPOS. */ 211extern int string_width (); 212 213/* Return the index of the line containing point. */ 214extern int window_line_of_point (); 215 216/* Get and return the goal column for this window. */ 217extern int window_get_goal_column (); 218 219/* Get and return the printed column offset of the cursor in this window. */ 220extern int window_get_cursor_column (); 221 222/* Get and Set the node, pagetop, and point of WINDOW. */ 223extern void window_get_state (), window_set_state (); 224 225/* Count the number of characters in LINE that precede the printed column 226 offset of GOAL. */ 227extern int window_chars_to_goal (); 228 229#endif /* !_WINDOW_H_ */ 230