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

Diff for /src/usr.bin/mg/kbd.c between version 1.6 and 1.7

version 1.6, 2001/05/23 16:14:00 version 1.7, 2001/05/23 20:19:44
Line 131 
Line 131 
  * keymap element the keyboard was found in as a side effect.   * keymap element the keyboard was found in as a side effect.
  */   */
 PF  PF
 doscan(map, c)  doscan(map, c, newmap)
         KEYMAP *map;          KEYMAP *map;
         int     c;          int     c;
           KEYMAP **newmap;
 {  {
         MAP_ELEMENT     *elec = &map->map_element[0];          MAP_ELEMENT     *elec = &map->map_element[0];
         MAP_ELEMENT     *last = &map->map_element[map->map_num];          MAP_ELEMENT     *last = &map->map_element[map->map_num];
           PF              ret;
   
         while (elec < last && c > elec->k_num)          while (elec < last && c > elec->k_num)
                 elec++;                  elec++;
Line 144 
Line 146 
         /* used by prefix and binding code */          /* used by prefix and binding code */
         ele = elec;          ele = elec;
         if (elec >= last || c < elec->k_base)          if (elec >= last || c < elec->k_base)
                 return map->map_default;                  ret = map->map_default;
         return elec->k_funcp[c - elec->k_base];          else
                   ret = elec->k_funcp[c - elec->k_base];
           if (ret == NULL && newmap != NULL)
                   *newmap = elec->k_prefmap;
   
           return ret;
 }  }
   
 int  int
Line 160 
Line 167 
         curmap = curbp->b_modes[curbp->b_nmodes]->p_map;          curmap = curbp->b_modes[curbp->b_nmodes]->p_map;
         key.k_count = 0;          key.k_count = 0;
         while ((funct = doscan(curmap, (key.k_chars[key.k_count++] =          while ((funct = doscan(curmap, (key.k_chars[key.k_count++] =
             getkey(TRUE)))) == NULL)              getkey(TRUE)), &curmap)) == NULL)
                 curmap = ele->k_prefmap;                  /*nothing*/;
 #ifndef NO_MACRO  #ifndef NO_MACRO
         if (macrodef && macrocount < MAXMACRO)          if (macrodef && macrocount < MAXMACRO)
                 macro[macrocount++].m_funct = funct;                  macro[macrocount++].m_funct = funct;
Line 184 
Line 191 
                         c = TOLOWER(key.k_chars[key.k_count - 1]);                          c = TOLOWER(key.k_chars[key.k_count - 1]);
                         curmap = curbp->b_modes[mode]->p_map;                          curmap = curbp->b_modes[mode]->p_map;
                         for (i = 0; i < key.k_count - 1; i++) {                          for (i = 0; i < key.k_count - 1; i++) {
                                 if ((fp = doscan(curmap, (key.k_chars[i])))                                  if ((fp = doscan(curmap, (key.k_chars[i]), &curmap))
                                     != NULL)                                      != NULL)
                                         break;                                          break;
                                 curmap = ele->k_prefmap;  
                         }                          }
                         if (fp == NULL) {                          if (fp == NULL) {
                                 if ((fp = doscan(curmap, c)) == NULL)                                  if ((fp = doscan(curmap, c, NULL)) == NULL)
                                         while ((fp = doscan(curmap,                                          while ((fp = doscan(curmap,
                                             key.k_chars[key.k_count++] =                                              key.k_chars[key.k_count++] =
                                             getkey(TRUE))) == NULL)                                              getkey(TRUE), &curmap)) == NULL)
                                                 curmap = ele->k_prefmap;                                                  /*nothing*/;
                                 if (fp != rescan) {                                  if (fp != rescan) {
 #ifndef NO_MACRO  #ifndef NO_MACRO
                                         if (macrodef && macrocount <= MAXMACRO)                                          if (macrodef && macrocount <= MAXMACRO)
Line 210 
Line 216 
                         return ABORT;                          return ABORT;
                 curmap = curbp->b_modes[mode]->p_map;                  curmap = curbp->b_modes[mode]->p_map;
                 for (i = 0; i < key.k_count; i++) {                  for (i = 0; i < key.k_count; i++) {
                         if ((fp = doscan(curmap, (key.k_chars[i]))) != NULL)                          if ((fp = doscan(curmap, (key.k_chars[i]), &curmap)) != NULL)
                                 break;                                  break;
                         curmap = ele->k_prefmap;  
                 }                  }
                 if (fp == NULL) {                  if (fp == NULL) {
                         while ((fp = doscan(curmap, key.k_chars[i++] =                          while ((fp = doscan(curmap, key.k_chars[i++] =
                             getkey(TRUE))) == NULL)                              getkey(TRUE), &curmap)) == NULL)
                                 curmap = ele->k_prefmap;                                  /*nothing*/;
                         key.k_count = i;                          key.k_count = i;
                 }                  }
                 if (fp != rescan && i >= key.k_count - 1) {                  if (fp != rescan && i >= key.k_count - 1) {
Line 249 
Line 254 
                 if (c >= '0' && c <= '9')                  if (c >= '0' && c <= '9')
                         return digit_argument(f, nn);                          return digit_argument(f, nn);
                 curmap = curbp->b_modes[curbp->b_nmodes]->p_map;                  curmap = curbp->b_modes[curbp->b_nmodes]->p_map;
                 while ((funct = doscan(curmap, c)) == NULL) {                  while ((funct = doscan(curmap, c, &curmap)) == NULL) {
                         curmap = ele->k_prefmap;  
                         key.k_chars[key.k_count++] = c = getkey(TRUE);                          key.k_chars[key.k_count++] = c = getkey(TRUE);
                 }                  }
                 if (funct != universal_argument) {                  if (funct != universal_argument) {
Line 288 
Line 292 
         key.k_chars[0] = c;          key.k_chars[0] = c;
         key.k_count = 1;          key.k_count = 1;
         curmap = curbp->b_modes[curbp->b_nmodes]->p_map;          curmap = curbp->b_modes[curbp->b_nmodes]->p_map;
         while ((funct = doscan(curmap, c)) == NULL) {          while ((funct = doscan(curmap, c, &curmap)) == NULL) {
                 curmap = ele->k_prefmap;  
                 key.k_chars[key.k_count++] = c = getkey(TRUE);                  key.k_chars[key.k_count++] = c = getkey(TRUE);
         }          }
 #ifndef NO_MACRO  #ifndef NO_MACRO
Line 328 
Line 331 
         key.k_chars[0] = c;          key.k_chars[0] = c;
         key.k_count = 1;          key.k_count = 1;
         curmap = curbp->b_modes[curbp->b_nmodes]->p_map;          curmap = curbp->b_modes[curbp->b_nmodes]->p_map;
         while ((funct = doscan(curmap, c)) == NULL) {          while ((funct = doscan(curmap, c, &curmap)) == NULL) {
                 curmap = ele->k_prefmap;  
                 key.k_chars[key.k_count++] = c = getkey(TRUE);                  key.k_chars[key.k_count++] = c = getkey(TRUE);
         }          }
 #ifndef NO_MACRO  #ifndef NO_MACRO

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7