[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.27 and 1.28

version 1.27, 2005/03/09 16:20:48 version 1.28, 2005/04/03 02:09:28
Line 5 
Line 5 
  * parts of building the keymap has been moved to a better place.   * parts of building the keymap has been moved to a better place.
  */   */
   
 #include        "def.h"  #include "def.h"
 #include        "kbd.h"  #include "kbd.h"
   
 /*  /*
  * initial keymap declarations, deepest first   * initial keymap declarations, deepest first
Line 15 
Line 15 
 #ifndef NO_HELP  #ifndef NO_HELP
 static PF cHcG[] = {  static PF cHcG[] = {
         ctrlg,                  /* ^G */          ctrlg,                  /* ^G */
         help_help,              /* ^H */          help_help               /* ^H */
 };  };
   
 static PF cHa[] = {  static PF cHa[] = {
         apropos_command,        /* a */          apropos_command,        /* a */
         wallchart,              /* b */          wallchart,              /* b */
         desckey,                /* c */          desckey                 /* c */
 };  };
   
 static struct KEYMAPE (2 + IMAPEXT) helpmap = {  static struct KEYMAPE (2 + IMAPEXT) helpmap = {
Line 34 
Line 34 
                 },                  },
                 {                  {
                         'a', 'c', cHa, NULL                          'a', 'c', cHa, NULL
                 },                  }
         }          }
 };  };
 #endif /* !NO_HELP */  #endif /* !NO_HELP */
   
 static PF cX4cF[] = {  static PF cX4cF[] = {
         poptofile,              /* ^f */          poptofile,              /* ^f */
         ctrlg,                  /* ^g */          ctrlg                   /* ^g */
 };  };
 static PF cX4b[] = {  static PF cX4b[] = {
         poptobuffer,            /* b */          poptobuffer,            /* b */
         rescan,                 /* c */          rescan,                 /* c */
         rescan,                 /* d */          rescan,                 /* d */
         rescan,                 /* e */          rescan,                 /* e */
         poptofile,              /* f */          poptofile               /* f */
 };  };
 static struct KEYMAPE (2 + IMAPEXT) cX4map = {  static struct KEYMAPE (2 + IMAPEXT) cX4map = {
         2,          2,
Line 60 
Line 60 
                 },                  },
                 {                  {
                         'b', 'f', cX4b, NULL                          'b', 'f', cX4b, NULL
                 },                  }
         }          }
 };  };
   
Line 70 
Line 70 
         rescan,                 /* ^D */          rescan,                 /* ^D */
         rescan,                 /* ^E */          rescan,                 /* ^E */
         filevisit,              /* ^F */          filevisit,              /* ^F */
         ctrlg,                  /* ^G */          ctrlg                   /* ^G */
 };  };
   
 static PF cXcL[] = {  static PF cXcL[] = {
Line 86 
Line 86 
         upperregion,            /* ^U */          upperregion,            /* ^U */
         rescan,                 /* ^V */          rescan,                 /* ^V */
         filewrite,              /* ^W */          filewrite,              /* ^W */
         swapmark,               /* ^X */          swapmark                /* ^X */
 };  };
   
 #ifndef NO_MACRO  #ifndef NO_MACRO
 static PF cXlp[] = {  static PF cXlp[] = {
         definemacro,            /* ( */          definemacro,            /* ( */
         finishmacro,            /* ) */          finishmacro             /* ) */
 };  };
 #endif /* !NO_MACRO */  #endif /* !NO_MACRO */
   
Line 101 
Line 101 
         onlywind,               /* 1 */          onlywind,               /* 1 */
         splitwind,              /* 2 */          splitwind,              /* 2 */
         rescan,                 /* 3 */          rescan,                 /* 3 */
         NULL,                   /* 4 */          NULL                    /* 4 */
 };  };
   
 static PF cXeq[] = {  static PF cXeq[] = {
         showcpos,               /* = */          showcpos                /* = */
 };  };
   
 static PF cXcar[] = {  static PF cXcar[] = {
Line 173 
Line 173 
                 },                  },
                 {                  {
                         '^', 'u', cXcar, NULL                          '^', 'u', cXcar, NULL
                 },                  }
         }          }
 };  };
   
 static PF metacG[] = {  static PF metacG[] = {
         ctrlg,                  /* ^G */          ctrlg                   /* ^G */
 };  };
   
 static PF metacV[] = {  static PF metacV[] = {
         pagenext,               /* ^V */          pagenext                /* ^V */
 };  };
   
 static PF metasp[] = {  static PF metasp[] = {
         justone,                /* space */          justone                 /* space */
 };  };
   
 static PF metapct[] = {  static PF metapct[] = {
         queryrepl,              /* % */          queryrepl               /* % */
 };  };
   
 static PF metami[] = {  static PF metami[] = {
Line 211 
Line 211 
         rescan,                 /* ; */          rescan,                 /* ; */
         gotobob,                /* < */          gotobob,                /* < */
         rescan,                 /* = */          rescan,                 /* = */
         gotoeob,                /* > */          gotoeob                 /* > */
 };  };
   
 static PF metalb[] = {  static PF metalb[] = {
Line 226 
Line 226 
         capword,                /* c */          capword,                /* c */
         delfword,               /* d */          delfword,               /* d */
         rescan,                 /* e */          rescan,                 /* e */
         forwword,               /* f */          forwword                /* f */
 };  };
   
 static PF metal[] = {  static PF metal[] = {
Line 242 
Line 242 
         upperword,              /* u */          upperword,              /* u */
         backpage,               /* v */          backpage,               /* v */
         copyregion,             /* w */          copyregion,             /* w */
         extend,                 /* x */          extend                  /* x */
 };  };
   
 static PF metatilde[] = {  static PF metatilde[] = {
         notmodified,            /* ~ */          notmodified,            /* ~ */
         delbword,               /* DEL */          delbword                /* DEL */
 };  };
   
 static struct KEYMAPE (8 + IMAPEXT) metamap = {  static struct KEYMAPE (8 + IMAPEXT) metamap = {
Line 278 
Line 278 
                 },                  },
                 {                  {
                         '~', CCHR('?'), metatilde, NULL                          '~', CCHR('?'), metatilde, NULL
                 },                  }
         }          }
 };  };
   
Line 316 
Line 316 
         killregion,             /* ^W */          killregion,             /* ^W */
         NULL,                   /* ^X */          NULL,                   /* ^X */
         yank,                   /* ^Y */          yank,                   /* ^Y */
         spawncli,               /* ^Z */          spawncli                /* ^Z */
 };  };
   
 static PF fund_esc[] = {  static PF fund_esc[] = {
Line 324 
Line 324 
         rescan,                 /* ^\ selfinsert is default on fundamental */          rescan,                 /* ^\ selfinsert is default on fundamental */
         rescan,                 /* ^] */          rescan,                 /* ^] */
         rescan,                 /* ^^ */          rescan,                 /* ^^ */
         undo,                   /* ^_ */          undo                    /* ^_ */
 };  };
   
 static PF fund_del[] = {  static PF fund_del[] = {
         backdel,                /* DEL */          backdel                 /* DEL */
 };  };
   
 #ifndef FUND_XMAPS  #ifndef FUND_XMAPS
Line 365 
Line 365 
 };  };
   
 static PF fill_sp[] = {  static PF fill_sp[] = {
         fillword,               /* ' ' */          fillword                /* ' ' */
 };  };
   
 static struct KEYMAPE (1 + IMAPEXT) fillmap = {  static struct KEYMAPE (1 + IMAPEXT) fillmap = {
Line 375 
Line 375 
         {          {
                 {                  {
                         ' ', ' ', fill_sp, NULL                          ' ', ' ', fill_sp, NULL
                 },                  }
         }          }
 };  };
   
Line 383 
Line 383 
         newline,                /* ^J */          newline,                /* ^J */
         rescan,                 /* ^K */          rescan,                 /* ^K */
         rescan,                 /* ^L */          rescan,                 /* ^L */
         indent,                 /* ^M */          indent                  /* ^M */
 };  };
   
 static struct KEYMAPE (1 + IMAPEXT) indntmap = {  static struct KEYMAPE (1 + IMAPEXT) indntmap = {
Line 393 
Line 393 
         {          {
                 {                  {
                         CCHR('J'), CCHR('M'), indent_lf, NULL                          CCHR('J'), CCHR('M'), indent_lf, NULL
                 },                  }
         }          }
 };  };
   
 static PF blink_rp[] = {  static PF blink_rp[] = {
         showmatch,              /* ) */          showmatch               /* ) */
 };  };
   
 static struct KEYMAPE (1 + IMAPEXT) blinkmap = {  static struct KEYMAPE (1 + IMAPEXT) blinkmap = {
Line 408 
Line 408 
         {          {
                 {                  {
                         ')', ')', blink_rp, NULL                          ')', ')', blink_rp, NULL
                 },                  }
         }          }
 };  };
   
 #ifdef NOTAB  #ifdef NOTAB
 static PF notab_tab[] = {  static PF notab_tab[] = {
         space_to_tabstop,       /* ^I */          space_to_tabstop        /* ^I */
 };  };
   
 static struct KEYMAPE (1 + IMAPEXT) notabmap = {  static struct KEYMAPE (1 + IMAPEXT) notabmap = {
Line 424 
Line 424 
         {          {
                 {                  {
                         CCHR('I'), CCHR('I'), notab_tab, NULL                          CCHR('I'), CCHR('I'), notab_tab, NULL
                 },                  }
         }          }
 };  };
 #endif /* NOTAB */  #endif /* NOTAB */
Line 437 
Line 437 
                 /* unused dummy entry for VMS C */                  /* unused dummy entry for VMS C */
                 {                  {
                         (KCHAR)0, (KCHAR)0, NULL, NULL                          (KCHAR)0, (KCHAR)0, NULL, NULL
                 },                  }
         }          }
 };  };
   
Line 469 
Line 469 
         universal_argument,     /* ^U */          universal_argument,     /* ^U */
         forwpage,               /* ^V */          forwpage,               /* ^V */
         rescan,                 /* ^W */          rescan,                 /* ^W */
         NULL,                   /* ^X */          NULL                    /* ^X */
 };  };
   
 static PF diredcz[] = {  static PF diredcz[] = {
Line 479 
Line 479 
         rescan,                 /* ^] */          rescan,                 /* ^] */
         rescan,                 /* ^^ */          rescan,                 /* ^^ */
         rescan,                 /* ^_ */          rescan,                 /* ^_ */
         forwline,               /* SP */          forwline                /* SP */
 };  };
   
 static PF diredc[] = {  static PF diredc[] = {
         d_copy,                 /* c */          d_copy,                 /* c */
         d_del,                  /* d */          d_del,                  /* d */
         d_findfile,             /* e */          d_findfile,             /* e */
         d_findfile,             /* f */          d_findfile              /* f */
 };  };
   
 static PF diredn[] = {  static PF diredn[] = {
Line 500 
Line 500 
         d_undel,                /* u */          d_undel,                /* u */
         rescan,                 /* v */          rescan,                 /* v */
         rescan,                 /* w */          rescan,                 /* w */
         d_expunge,              /* x */          d_expunge               /* x */
 };  };
   
 static PF direddl[] = {  static PF direddl[] = {
         d_undelbak,             /* del */          d_undelbak              /* del */
 };  };
   
 #ifndef DIRED_XMAPS  #ifndef DIRED_XMAPS
Line 547 
Line 547 
 };  };
 #endif /* !NO_DIRED */  #endif /* !NO_DIRED */
   
 MAPS    fundamental_mode = { (KEYMAP *)&fundmap, "fundamental", };  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
  * name. Maps created dynamicly currently don't get added here, thus are   * name. Maps created dynamically currently don't get added here, thus are
  * unnamed. Modes are just named keymaps with functions to add/subtract them   * unnamed. Modes are just named keymaps with functions to add/subtract them
  * from a buffer's list of modes.  If you change a mode name, change it in   * from a buffer's list of modes.  If you change a mode name, change it in
  * modes.c also.   * modes.c also.
Line 575 
Line 575 
 #ifndef NO_DIRED  #ifndef NO_DIRED
         {(KEYMAP *) &diredmap, "dired",},          {(KEYMAP *) &diredmap, "dired",},
 #endif  #endif
         {NULL, NULL},          {NULL, NULL}
 };  };
   
 MAPS *maps;  MAPS *maps;
Line 583 
Line 583 
 void  void
 maps_init(void)  maps_init(void)
 {  {
         int i;          int      i;
         MAPS *mp;          MAPS    *mp;
   
         maps = &fundamental_mode;          maps = &fundamental_mode;
         for (i = 0; map_table[i].p_name != NULL; i++) {          for (i = 0; map_table[i].p_name != NULL; i++) {
Line 597 
Line 597 
 int  int
 maps_add(KEYMAP *map, const char *name)  maps_add(KEYMAP *map, const char *name)
 {  {
         MAPS *mp;          MAPS    *mp;
   
         if ((mp = malloc(sizeof(*mp))) == NULL)          if ((mp = malloc(sizeof(*mp))) == NULL)
                 return FALSE;                  return (FALSE);
   
         mp->p_name = name;          mp->p_name = name;
         mp->p_map = map;          mp->p_map = map;
         mp->p_next = maps;          mp->p_next = maps;
         maps = mp;          maps = mp;
   
         return TRUE;          return (TRUE);
 }  }
   
 const char *  const char *
 map_name(KEYMAP *map)  map_name(KEYMAP *map)
 {  {
         MAPS *mp;          MAPS    *mp;
   
         for (mp = maps; mp != NULL; mp = mp->p_next)          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);
         return NULL;          return (NULL);
 }  }
   
 MAPS *  MAPS *
 name_mode(const char *name)  name_mode(const char *name)
 {  {
         MAPS *mp;          MAPS    *mp;
   
         for (mp = maps; mp != NULL; mp = mp->p_next)          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);
         return NULL;          return (NULL);
 }  }
   
 KEYMAP *  KEYMAP *
 name_map(const char *name)  name_map(const 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.27  
changed lines
  Added in v.1.28