(root)/
texinfo-7.1/
info/
infomap.h
       1  /* infomap.h -- description of a keymap in Info and related functions.
       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     Originaly written by Brian Fox. */
      19  
      20  #ifndef INFOMAP_H
      21  #define INFOMAP_H
      22  
      23  #include "info.h"
      24  
      25  #define ESC '\033'
      26  #define DEL '\177'
      27  #define TAB '\011'      
      28  #define RET '\r'
      29  #define LFD '\n'
      30  #define SPC ' '
      31  
      32  #define meta_character_threshold (DEL + 1)
      33  #define control_character_threshold (SPC)
      34  
      35  #define meta_character_bit 0x80
      36  #define control_character_bit 0x40
      37  
      38  #define Meta_p(c) (((c) > meta_character_threshold))
      39  #define Control_p(c) ((c) < control_character_threshold)
      40  
      41  #define Meta(c) ((c) | (meta_character_bit))
      42  #define UnMeta(c) ((c) & (~meta_character_bit))
      43  #define Control(c) ((toupper (c)) & (~control_character_bit))
      44  #define UnControl(c) (tolower ((c) | control_character_bit))
      45  
      46  /* Structure used to map sequences of bytes to recognized keys. */
      47  typedef struct bytemap_entry
      48  {
      49    char type;
      50    int key;
      51    struct bytemap_entry *next;
      52  } BYTEMAP_ENTRY;
      53  
      54  #define BYTEMAP_NONE 0
      55  #define BYTEMAP_KEY 1
      56  #define BYTEMAP_MAP 2
      57  #define BYTEMAP_ESC 3
      58  
      59  extern BYTEMAP_ENTRY *byte_seq_to_key;
      60  
      61  typedef struct keymap_entry
      62  {
      63    char type;
      64    union
      65    {
      66      InfoCommand *function;         /* The address of a function. */
      67      struct keymap_entry *keymap;   /* The address of another Keymap */
      68    } value;
      69  } KEYMAP_ENTRY;
      70  
      71  /* The values that TYPE can have in a keymap entry. */
      72  #define ISFUNC 0
      73  #define ISKMAP 1
      74  
      75  /* We use Keymap for a pointer to a block of KEYMAP_SIZE KEYMAP_ENTRY's. */
      76  typedef KEYMAP_ENTRY *Keymap;
      77  
      78  extern Keymap info_keymap;
      79  extern Keymap echo_area_keymap;
      80  
      81  #define KEY_RIGHT_ARROW		256
      82  #define KEY_LEFT_ARROW		257
      83  #define KEY_UP_ARROW		258
      84  #define KEY_DOWN_ARROW		259
      85  #define KEY_PAGE_UP		260
      86  #define KEY_PAGE_DOWN		261
      87  #define KEY_HOME		262
      88  #define KEY_END			263
      89  #define KEY_DELETE		264
      90  #define KEY_INSERT		265
      91  #define KEY_CTL_LEFT_ARROW	266
      92  #define KEY_CTL_RIGHT_ARROW	267
      93  #define KEY_CTL_DELETE		268
      94  #define KEY_BACK_TAB		269
      95  #define KEY_MOUSE               270
      96  
      97  /* Add this to get the offset of the key binding with the meta key. */
      98  #define KEYMAP_META_BASE 271
      99  
     100  /* Number of entries in a Keymap: 256 entries for plain byte values plus
     101     mappings for special keys.  The bindings for the key chords with meta
     102     follow. */
     103  #define KEYMAP_SIZE (KEYMAP_META_BASE * 2)
     104  
     105  #define KEYMAP_META(k) ((k) < KEYMAP_META_BASE ? (k) + KEYMAP_META_BASE : (k))
     106  
     107  /* Default "infokey file", where user defs are kept and read by
     108     Info.  MS-DOS doesn't allow leading dots in file names.  */
     109  #ifdef __MSDOS__
     110  #define INFOKEY_FILE		"_infokey"
     111  #else
     112  #define INFOKEY_FILE		".infokey"
     113  #endif
     114  
     115  #define	A_MAX_COMMAND		120
     116  #define	A_INVALID		121
     117  
     118  #define	CONTROL(c)		((c) & 0x1f)
     119  
     120  /* Return a new keymap which has all the uppercase letters mapped to run
     121     the function info_do_lowercase_version (). */
     122  extern Keymap keymap_make_keymap (void);
     123  
     124  /* Read init file and initialize the info keymaps. */
     125  extern void read_init_file (char *init_file);
     126  
     127  #endif /* not INFOMAP_H */