Back to index

tetex-bin  3.0
window.h
Go to the documentation of this file.
00001 /* window.h -- Structure and flags used in manipulating Info windows.
00002    $Id: window.h,v 1.3 2004/04/11 17:56:46 karl Exp $
00003 
00004    This file is part of GNU Info, a program for reading online documentation
00005    stored in Info format.
00006 
00007    Copyright (C) 1993, 1997, 2004 Free Software Foundation, Inc.
00008 
00009    This program is free software; you can redistribute it and/or modify
00010    it under the terms of the GNU General Public License as published by
00011    the Free Software Foundation; either version 2, or (at your option)
00012    any later version.
00013 
00014    This program is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017    GNU General Public License for more details.
00018 
00019    You should have received a copy of the GNU General Public License
00020    along with this program; if not, write to the Free Software
00021    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00022 
00023    Written by Brian Fox (bfox@ai.mit.edu). */
00024 
00025 #ifndef INFO_WINDOW_H
00026 #define INFO_WINDOW_H
00027 
00028 #include "infomap.h"
00029 #include "nodes.h"
00030 
00031 /* Smallest number of visible lines in a window.  The actual height is
00032    always one more than this number because each window has a modeline. */
00033 #define WINDOW_MIN_HEIGHT 2
00034 
00035 /* Smallest number of screen lines that can be used to fully present a
00036    window.  This number includes the modeline of the window. */
00037 #define WINDOW_MIN_SIZE (WINDOW_MIN_HEIGHT + 1)
00038 
00039 /* The exact same elements are used within the WINDOW_STATE structure and a
00040    subsection of the WINDOW structure.  We could define a structure which
00041    contains this elements, and include that structure in each of WINDOW_STATE
00042    and WINDOW.  But that would lead references in the code such as
00043    window->state->node which we would like to avoid.  Instead, we #define the
00044    elements here, and simply include the define in both data structures. Thus,
00045    if you need to change window state information, here is where you would
00046    do it.  NB> The last element does NOT end with a semi-colon. */
00047 #define WINDOW_STATE_DECL \
00048    NODE *node;          /* The node displayed in this window. */ \
00049    int pagetop;         /* LINE_STARTS[PAGETOP] is first line in WINDOW. */ \
00050    long point           /* Offset within NODE of the cursor position. */
00051 
00052 /* Structure which defines a window.  Windows are doubly linked, next
00053    and prev. The list of windows is kept on WINDOWS.  The structure member
00054    window->height is the total height of the window.  The position location
00055    (0, window->height + window->first_row) is the first character of this
00056    windows modeline.  The number of lines that can be displayed in a window
00057    is equal to window->height - 1. */
00058 typedef struct window_struct
00059 {
00060   struct window_struct *next;      /* Next window in this chain. */
00061   struct window_struct *prev;      /* Previous window in this chain. */
00062   int width;            /* Width of this window. */
00063   int height;           /* Height of this window. */
00064   int first_row;        /* Offset of the first line in the_screen. */
00065   int goal_column;      /* The column we would like the cursor to appear in. */
00066   Keymap keymap;        /* Keymap used to read commands in this window. */
00067   WINDOW_STATE_DECL;    /* Node, pagetop and point. */
00068   char *modeline;       /* Calculated text of the modeline for this window. */
00069   char **line_starts;   /* Array of printed line starts for this node. */
00070   int line_count;       /* Number of lines appearing in LINE_STARTS. */
00071   int flags;            /* See below for details. */
00072 } WINDOW;
00073 
00074 typedef struct {
00075   WINDOW_STATE_DECL;            /* What gets saved. */
00076 } WINDOW_STATE;
00077 
00078 /* Structure defining the current state of an incremental search. */
00079 typedef struct {
00080   WINDOW_STATE_DECL;    /* The node, pagetop and point. */
00081   int search_index;     /* Offset of the last char in the search string. */
00082   int direction;        /* The direction that this search is heading in. */
00083   int failing;          /* Whether or not this search failed. */
00084 } SEARCH_STATE;
00085 
00086 #define W_UpdateWindow  0x01    /* WINDOW needs updating. */
00087 #define W_WindowIsPerm  0x02    /* This WINDOW is a permanent object. */
00088 #define W_WindowVisible 0x04    /* This WINDOW is currently visible. */
00089 #define W_InhibitMode   0x08    /* This WINDOW has no modeline. */
00090 #define W_NoWrap        0x10    /* Lines do not wrap in this window. */
00091 #define W_InputWindow   0x20    /* Window accepts input. */
00092 #define W_TempWindow    0x40    /* Window is less important. */
00093 
00094 extern WINDOW *windows;         /* List of visible Info windows. */
00095 extern WINDOW *active_window;   /* The currently active window. */
00096 extern WINDOW *the_screen;      /* The Info screen is just another window. */
00097 extern WINDOW *the_echo_area;   /* THE_ECHO_AREA is a window in THE_SCREEN. */
00098 
00099 /* Global variable control redisplay of scrolled windows.  If non-zero, it
00100    is the desired number of lines to scroll the window in order to make
00101    point visible.  A user might set this to 1 for smooth scrolling.  If
00102    set to zero, the line containing point is centered within the window. */
00103 extern int window_scroll_step;
00104 
00105  /* Make the modeline member for WINDOW. */
00106 extern void window_make_modeline (WINDOW *window);
00107 
00108 /* Initalize the window system by creating THE_SCREEN and THE_ECHO_AREA.
00109    Create the first window ever, and make it permanent.
00110    You pass WIDTH and HEIGHT; the dimensions of the total screen size. */
00111 extern void window_initialize_windows (int width, int height);
00112 
00113 /* Make a new window showing NODE, and return that window structure.
00114    The new window is made to be the active window.  If NODE is passed
00115    as NULL, then show the node showing in the active window.  If the
00116    window could not be made return a NULL pointer.  The active window
00117    is not changed.*/
00118 extern WINDOW *window_make_window (NODE *node);
00119 
00120 /* Delete WINDOW from the list of known windows.  If this window was the
00121    active window, make the next window in the chain be the active window,
00122    or the previous window in the chain if there is no next window. */
00123 extern void window_delete_window (WINDOW *window);
00124 
00125 /* A function to call when the screen changes size, and some windows have
00126    to get deleted.  The function is called with the window to be deleted
00127    as an argument, and it can't do anything about the window getting deleted;
00128    it can only clean up dangling references to that window. */
00129 extern VFunction *window_deletion_notifier;
00130 
00131 /* Set WINDOW to display NODE. */
00132 extern void window_set_node_of_window (WINDOW *window, NODE *node);
00133 
00134 /* Tell the window system that the size of the screen has changed.  This
00135    causes lots of interesting things to happen.  The permanent windows
00136    are resized, as well as every visible window.  You pass WIDTH and HEIGHT;
00137    the dimensions of the total screen size. */
00138 extern void window_new_screen_size (int width, int height);
00139 
00140 /* Change the height of WINDOW by AMOUNT.  This also automagically adjusts
00141    the previous and next windows in the chain.  If there is only one user
00142    window, then no change takes place. */
00143 extern void window_change_window_height (WINDOW *window, int amount);
00144 
00145 /* Adjust the pagetop of WINDOW such that the cursor point will be visible. */
00146 extern void window_adjust_pagetop (WINDOW *window);
00147 
00148 /* Tile all of the windows currently displayed in the global variable
00149    WINDOWS.  If argument DO_INTERNALS is non-zero, tile windows displaying
00150    internal nodes as well. */
00151 #define DONT_TILE_INTERNALS 0
00152 #define TILE_INTERNALS      1
00153 extern void window_tile_windows (int style);
00154 
00155 /* Toggle the state of line wrapping in WINDOW.  This can do a bit of fancy
00156    redisplay. */
00157 extern void window_toggle_wrap (WINDOW *window);
00158 
00159 /* For every window in CHAIN, set the flags member to have FLAG set. */
00160 extern void window_mark_chain (WINDOW *chain, int flag);
00161 
00162 /* For every window in CHAIN, clear the flags member of FLAG. */
00163 extern void window_unmark_chain (WINDOW *chain, int flag);
00164 
00165 /* Make WINDOW start displaying at PERCENT percentage of its node. */
00166 extern void window_goto_percentage (WINDOW *window, int percent);
00167 
00168 /* Build a new node which has FORMAT printed with ARG1 and ARG2 as the
00169    contents. */
00170 extern NODE *build_message_node (char *format, void *arg1, void *arg2);
00171 
00172 /* Useful functions can be called from outside of window.c. */
00173 extern void initialize_message_buffer (void);
00174 
00175 /* Print FORMAT with ARG1,2 to the end of the current message buffer. */
00176 extern void printf_to_message_buffer (char *format, void *arg1, void *arg2,
00177     void *arg3);
00178 
00179 /* Convert the contents of the message buffer to a node. */
00180 extern NODE *message_buffer_to_node (void);
00181 
00182 /* Return the length of the most recently printed line in message buffer. */
00183 extern int message_buffer_length_this_line (void);
00184 
00185 /* Pad STRING to COUNT characters by inserting blanks. */
00186 extern int pad_to (int count, char *string);
00187 
00188 /* Make a message appear in the echo area, built from FORMAT, ARG1 and ARG2.
00189    The arguments are treated similar to printf () arguments, but not all of
00190    printf () hair is present.  The message appears immediately.  If there was
00191    already a message appearing in the echo area, it is removed. */
00192 extern void window_message_in_echo_area (char *format, void *arg1, void *arg2);
00193 
00194 /* Place a temporary message in the echo area built from FORMAT, ARG1
00195    and ARG2.  The message appears immediately, but does not destroy
00196    any existing message.  A future call to unmessage_in_echo_area ()
00197    restores the old contents. */
00198 extern void message_in_echo_area (char *format, void *arg1, void *arg2);
00199 extern void unmessage_in_echo_area (void);
00200 
00201 /* Clear the echo area, removing any message that is already present.
00202    The echo area is cleared immediately. */
00203 extern void window_clear_echo_area (void);
00204 
00205 /* Quickly guess the approximate number of lines to that NODE would
00206    take to display.  This really only counts carriage returns. */
00207 extern int window_physical_lines (NODE *node);
00208 
00209 /* Calculate a list of line starts for the node belonging to WINDOW.  The line
00210    starts are pointers to the actual text within WINDOW->NODE. */
00211 extern void calculate_line_starts (WINDOW *window);
00212 
00213 /* Given WINDOW, recalculate the line starts for the node it displays. */
00214 extern void recalculate_line_starts (WINDOW *window);
00215 
00216 /* Return the number of characters it takes to display CHARACTER on the
00217    screen at HPOS. */
00218 extern int character_width (int character, int hpos);
00219 
00220 /* Return the number of characters it takes to display STRING on the
00221    screen at HPOS. */
00222 extern int string_width (char *string, int hpos);
00223 
00224 /* Return the index of the line containing point. */
00225 extern int window_line_of_point (WINDOW *window);
00226 
00227 /* Get and return the goal column for this window. */
00228 extern int window_get_goal_column (WINDOW *window);
00229 
00230 /* Get and return the printed column offset of the cursor in this window. */
00231 extern int window_get_cursor_column (WINDOW *window);
00232 
00233 /* Get and Set the node, pagetop, and point of WINDOW. */
00234 extern void window_get_state (WINDOW *window, SEARCH_STATE *state);
00235 extern void window_set_state (WINDOW *window, SEARCH_STATE *state);
00236 
00237 /* Count the number of characters in LINE that precede the printed column
00238    offset of GOAL. */
00239 extern int window_chars_to_goal (char *line, int goal);
00240 
00241 #endif /* not INFO_WINDOW_H */