Exemple #1
0
void menu_list_read_key(menu_t* menu,int c,int jump_to) {
  list_entry_t* m;
  int i;
  switch(c) {
  case KEY_HOME:
    mpriv->current = mpriv->menu;
    break;
  case KEY_END:
    for(m = mpriv->current ; m && m->next ; m = m->next)
      /**/;
    if(m)
      mpriv->current = m;
    break;
  case KEY_PAGE_UP:
    for(i = 0, m = mpriv->current ; m && m->prev && i < mpriv->disp_lines ; m = m->prev, i++)
      /**/;
    if(m)
      mpriv->current = m;
    break;
  case KEY_PAGE_DOWN:
    for(i = 0, m = mpriv->current ; m && m->next && i < mpriv->disp_lines ; m = m->next, i++)
      /**/;
    if(m)
      mpriv->current = m;
    break;
  default:
    if(jump_to)
      menu_list_jump_to_key(menu,c);
    else
      menu_dflt_read_key(menu,c);
  }    
}
static int read_key(menu_t* menu,int c) {
  if(mpriv->child && mpriv->raw_child) {
    write(mpriv->child_fd[0],&c,sizeof(int));
    return 1;
  }

  if (c == KEY_DELETE || c == KEY_BS) {
    unsigned int i = strlen(mpriv->cur_history->buffer);
    if(i > 0)
      mpriv->cur_history->buffer[i-1] = '\0';
    return 1;
  }
  if (menu_dflt_read_key(menu, c))
    return 1;

  if(isascii(c)) {
    int l = strlen(mpriv->cur_history->buffer);
    if(l >= mpriv->cur_history->size) {
      mpriv->cur_history->size += 255;
      mpriv->cur_history->buffer = realloc(mpriv->cur_history,mpriv->cur_history->size);
    }
    mpriv->cur_history->buffer[l] = (char)c;
    mpriv->cur_history->buffer[l+1] = '\0';
    return 1;
  }
  return 0;
}
Exemple #3
0
static int read_key(menu_t* menu,int c){
    char **str;
    for (str=mpriv->actions; str && *str; str++)
      if (c == (*str)[0]) {
        action = &(*str)[2];
        read_cmd(menu,MENU_CMD_ACTION);
        return 1;
      }
  if (menu_dflt_read_key(menu, c))
    return 1;
  return menu_list_jump_to_key(menu, c);
}
Exemple #4
0
static void read_key(menu_t* menu,int c) {
  switch (c) {
  case KEY_HOME:
    mpriv->cur_line = 0;
    break;
  case KEY_END:
    mpriv->cur_line = mpriv->num_lines - 1;
    break;
  case KEY_PAGE_UP:
    mpriv->cur_line =  mpriv->cur_line > mpriv->disp_lines ?
      mpriv->cur_line - mpriv->disp_lines : 0;
    break;
  case KEY_PAGE_DOWN:
    mpriv->cur_line = mpriv->cur_line + mpriv->disp_lines > mpriv->num_lines - 1 ? mpriv->num_lines - 1 : mpriv->cur_line + mpriv->disp_lines;
    break;
  default:
    menu_dflt_read_key(menu,c);
  }
}
Exemple #5
0
void menu_list_jump_to_key(menu_t* menu,int c) {
  if(c < 256 && isalnum(c)) {
    list_entry_t* e = mpriv->current;
    if(e->txt[0] == c) e = e->next;
    for(  ; e ; e = e->next) {
	if(e->txt[0] == c) {
	  mpriv->current = e;
	  return;
	}
    }
    for(e = mpriv->menu ; e ;  e = e->next) {
	if(e->txt[0] == c) {
	  mpriv->current = e;
	  return;
	}
    }
  } else
    menu_dflt_read_key(menu,c);
}
Exemple #6
0
static int read_key(menu_t* menu,int c){
  if (menu_dflt_read_key(menu, c))
    return 1;
  return menu_list_jump_to_key(menu, c);
}