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