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

Diff for /src/usr.bin/tmux/status.c between version 1.153 and 1.154

version 1.153, 2016/10/11 07:23:34 version 1.154, 2016/10/12 13:03:27
Line 855 
Line 855 
 }  }
   
 /* Handle keys in prompt. */  /* Handle keys in prompt. */
 void  int
 status_prompt_key(struct client *c, key_code key)  status_prompt_key(struct client *c, key_code key)
 {  {
         struct options          *oo = c->session->options;          struct options          *oo = c->session->options;
Line 867 
Line 867 
         struct utf8_data         tmp, *first, *last, *ud;          struct utf8_data         tmp, *first, *last, *ud;
   
         size = utf8_strlen(c->prompt_buffer);          size = utf8_strlen(c->prompt_buffer);
   
           if (c->prompt_flags & PROMPT_NUMERIC) {
                   if (key >= '0' && key <= '9')
                           goto append_key;
                   s = utf8_tocstr(c->prompt_buffer);
                   c->prompt_callbackfn(c->prompt_data, s);
                   status_prompt_clear(c);
                   free(s);
                   return (1);
           }
   
         switch (mode_key_lookup(&c->prompt_mdata, key)) {          switch (mode_key_lookup(&c->prompt_mdata, key)) {
         case MODEKEYEDIT_CURSORLEFT:          case MODEKEYEDIT_CURSORLEFT:
                 if (c->prompt_index > 0) {                  if (c->prompt_index > 0) {
Line 1185 
Line 1196 
                         status_prompt_clear(c);                          status_prompt_clear(c);
                 break;                  break;
         case MODEKEY_OTHER:          case MODEKEY_OTHER:
                 if (key <= 0x1f || key >= KEYC_BASE)                  break;
                         break;          default:
                 if (utf8_split(key, &tmp) != UTF8_DONE)                  return (0);
                         break;          }
   
                 c->prompt_buffer = xreallocarray(c->prompt_buffer, size + 2,  append_key:
                     sizeof *c->prompt_buffer);          if (key <= 0x1f || key >= KEYC_BASE)
                   return (0);
           if (utf8_split(key, &tmp) != UTF8_DONE)
                   return (0);
   
                 if (c->prompt_index == size) {          c->prompt_buffer = xreallocarray(c->prompt_buffer, size + 2,
                         utf8_copy(&c->prompt_buffer[c->prompt_index], &tmp);              sizeof *c->prompt_buffer);
                         c->prompt_index++;  
                         c->prompt_buffer[c->prompt_index].size = 0;  
                 } else {  
                         memmove(c->prompt_buffer + c->prompt_index + 1,  
                             c->prompt_buffer + c->prompt_index,  
                             (size + 1 - c->prompt_index) *  
                             sizeof *c->prompt_buffer);  
                         utf8_copy(&c->prompt_buffer[c->prompt_index], &tmp);  
                         c->prompt_index++;  
                 }  
   
                 if (c->prompt_flags & PROMPT_SINGLE) {          if (c->prompt_index == size) {
                         s = utf8_tocstr(c->prompt_buffer);                  utf8_copy(&c->prompt_buffer[c->prompt_index], &tmp);
                         if (strlen(s) != 1)                  c->prompt_index++;
                                 status_prompt_clear(c);                  c->prompt_buffer[c->prompt_index].size = 0;
                         else if (c->prompt_callbackfn(c->prompt_data, s) == 0)          } else {
                                 status_prompt_clear(c);                  memmove(c->prompt_buffer + c->prompt_index + 1,
                         free(s);                      c->prompt_buffer + c->prompt_index,
                 }                      (size + 1 - c->prompt_index) *
                       sizeof *c->prompt_buffer);
                   utf8_copy(&c->prompt_buffer[c->prompt_index], &tmp);
                   c->prompt_index++;
           }
   
                 c->flags |= CLIENT_STATUS;          if (c->prompt_flags & PROMPT_SINGLE) {
                 break;                  s = utf8_tocstr(c->prompt_buffer);
         default:                  if (strlen(s) != 1)
                 break;                          status_prompt_clear(c);
                   else if (c->prompt_callbackfn(c->prompt_data, s) == 0)
                           status_prompt_clear(c);
                   free(s);
         }          }
   
           c->flags |= CLIENT_STATUS;
           return (0);
 }  }
   
 /* Get previous line from the history. */  /* Get previous line from the history. */

Legend:
Removed from v.1.153  
changed lines
  Added in v.1.154