[BACK]Return to keymap.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mg

Diff for /src/usr.bin/mg/keymap.c between version 1.12 and 1.13

version 1.12, 2001/05/24 09:47:34 version 1.13, 2001/05/24 10:43:18
Line 575 
Line 575 
 };  };
 #endif /* !NO_DIRED */  #endif /* !NO_DIRED */
   
   MAPS    fundamental_mode = { (KEYMAP *)&fundmap, "fundamental", };
   
 /*  /*
  * give names to the maps, for use by help etc. If the map is to be bindable,   * give names to the maps, for use by help etc. If the map is to be bindable,
  * it must also be listed in the function name table below with the same   * it must also be listed in the function name table below with the same
Line 584 
Line 586 
  * modes.c also.   * modes.c also.
  */   */
   
 MAPS map_table[] = {  static MAPS map_table[] = {
         /* fundamental map MUST be first entry */          {(KEYMAP *) &fillmap, "fill",},
         {(KEYMAP *) & fundmap, "fundamental"},          {(KEYMAP *) &indntmap, "indent",},
         {(KEYMAP *) & fillmap, "fill"},          {(KEYMAP *) &blinkmap, "blink",},
         {(KEYMAP *) & indntmap, "indent"},  
         {(KEYMAP *) & blinkmap, "blink"},  
 #ifdef NOTAB  #ifdef NOTAB
         {(KEYMAP *) & notabmap, "notab"},          {(KEYMAP *) &notabmap, "notab",},
 #endif /* NOTAB */  #endif /* NOTAB */
         {(KEYMAP *) & overwmap, "overwrite"},          {(KEYMAP *) &overwmap, "overwrite",},
         {(KEYMAP *) & metamap, "esc prefix"},          {(KEYMAP *) &metamap, "esc prefix",},
         {(KEYMAP *) & cXmap, "c-x prefix"},          {(KEYMAP *) &cXmap, "c-x prefix",},
         {(KEYMAP *) & cX4map, "c-x 4 prefix"},          {(KEYMAP *) &cX4map, "c-x 4 prefix",},
         {(KEYMAP *) & extramap1, "extra prefix 1"},          {(KEYMAP *) &extramap1, "extra prefix 1",},
         {(KEYMAP *) & extramap2, "extra prefix 2"},          {(KEYMAP *) &extramap2, "extra prefix 2",},
         {(KEYMAP *) & extramap3, "extra prefix 3"},          {(KEYMAP *) &extramap3, "extra prefix 3",},
         {(KEYMAP *) & extramap4, "extra prefix 4"},          {(KEYMAP *) &extramap4, "extra prefix 4",},
         {(KEYMAP *) & extramap5, "extra prefix 5"},          {(KEYMAP *) &extramap5, "extra prefix 5",},
 #ifndef NO_HELP  #ifndef NO_HELP
         {(KEYMAP *) & helpmap, "help"},          {(KEYMAP *) &helpmap, "help",},
 #endif  #endif
 #ifndef NO_DIRED  #ifndef NO_DIRED
         {(KEYMAP *) & diredmap, "dired"},          {(KEYMAP *) &diredmap, "dired",},
 #endif  #endif
           {NULL, NULL},
 };  };
   
 #define NMAPS   (sizeof map_table/sizeof(MAPS))  MAPS *maps;
 int      nmaps = NMAPS;         /* for use by rebind in extend.c */  
   
 KEYMAP *fundamental_map = (KEYMAP *)&fundmap;  void
   maps_init(void)
   {
           int i;
           MAPS *mp;
   
           maps = &fundamental_mode;
           for (i = 0; map_table[i].p_name != NULL; i++) {
                   mp = &map_table[i];
                   mp->p_next = maps;
                   maps = mp;
           }
   }
   
   int
   maps_add(KEYMAP *map, char *name)
   {
           MAPS *mp;
   
           if ((mp = malloc(sizeof(*mp))) == NULL)
                   return FALSE;
   
           mp->p_name = name;
           mp->p_map = map;
           mp->p_next = maps;
           maps = mp;
   
           return TRUE;
   }
   
 char *  char *
 map_name(map)  map_name(KEYMAP *map)
         KEYMAP *map;  
 {  {
         MAPS    *mp = &map_table[0];          MAPS *mp;
   
         do {          for (mp = maps; mp != NULL; mp = mp->p_next)
                 if (mp->p_map == map)                  if (mp->p_map == map)
                         return mp->p_name;                          return mp->p_name;
         } while (++mp < &map_table[NMAPS]);  
         return NULL;          return NULL;
 }  }
   
 MAPS *  MAPS *
 name_mode(name)  name_mode(char *name)
         char *name;  
 {  {
         MAPS    *mp = &map_table[0];          MAPS *mp;
   
         do {          for (mp = maps; mp != NULL; mp = mp->p_next)
                 if (strcmp(mp->p_name, name) == 0)                  if (strcmp(mp->p_name, name) == 0)
                         return mp;                          return mp;
         } while (++mp < &map_table[NMAPS]);  
         return NULL;          return NULL;
 }  }
   
 KEYMAP *  KEYMAP *
 name_map(name)  name_map(char *name)
         char *name;  
 {  {
         MAPS    *mp;          MAPS    *mp;
         return (mp = name_mode(name)) == NULL ? NULL : mp->p_map;          return (mp = name_mode(name)) == NULL ? NULL : mp->p_map;

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13