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