diff --git a/libmenu/menu.c b/libmenu/menu.c index eb7ec2c57d..e45e16ec28 100644 --- a/libmenu/menu.c +++ b/libmenu/menu.c @@ -185,10 +185,14 @@ void menu_dflt_read_key(menu_t* menu,int cmd) { menu->read_cmd(menu,MENU_CMD_DOWN); break; case KEY_LEFT: + menu->read_cmd(menu,MENU_CMD_LEFT); + break; case KEY_ESC: menu->read_cmd(menu,MENU_CMD_CANCEL); break; case KEY_RIGHT: + menu->read_cmd(menu,MENU_CMD_RIGHT); + break; case KEY_ENTER: menu->read_cmd(menu,MENU_CMD_OK); break; diff --git a/libmenu/menu.h b/libmenu/menu.h index 225326a40b..7e2ad4f912 100644 --- a/libmenu/menu.h +++ b/libmenu/menu.h @@ -31,6 +31,8 @@ typedef struct menu_info_s { #define MENU_CMD_DOWN 1 #define MENU_CMD_OK 2 #define MENU_CMD_CANCEL 3 +#define MENU_CMD_LEFT 4 +#define MENU_CMD_RIGHT 5 /// Global init/uninit int menu_init(char* cfg_file); diff --git a/libmenu/menu_cmdlist.c b/libmenu/menu_cmdlist.c index 0e4730f61a..cd0c8ff763 100644 --- a/libmenu/menu_cmdlist.c +++ b/libmenu/menu_cmdlist.c @@ -27,6 +27,8 @@ struct list_entry_s { char* ok; char* cancel; + char* left; + char* right; }; struct menu_priv_s { @@ -47,6 +49,12 @@ static m_option_t cfg_fields[] = { static void read_cmd(menu_t* menu,int cmd) { switch(cmd) { + case MENU_CMD_RIGHT: + if(mpriv->p.current->right) { + mp_cmd_t* c = mp_input_parse_cmd(mpriv->p.current->right); + if(c) mp_input_queue_cmd(c); + break; + } // fallback on ok if right is not defined case MENU_CMD_OK: { if(mpriv->p.current->ok) { mp_cmd_t* c = mp_input_parse_cmd(mpriv->p.current->ok); @@ -54,6 +62,12 @@ static void read_cmd(menu_t* menu,int cmd) { mp_input_queue_cmd(c); } } break; + case MENU_CMD_LEFT: + if(mpriv->p.current->left) { + mp_cmd_t* c = mp_input_parse_cmd(mpriv->p.current->left); + if(c) mp_input_queue_cmd(c); + break; + } // fallback on cancel if left is not defined case MENU_CMD_CANCEL: if(mpriv->p.current->cancel) { mp_cmd_t* c = mp_input_parse_cmd(mpriv->p.current->cancel); @@ -84,7 +98,7 @@ static void close(menu_t* menu) { } static int parse_args(menu_t* menu,char* args) { - char *element,*body, **attribs, *name, *ok, *cancel; + char *element,*body, **attribs, *name; list_entry_t* m = NULL; int r; ASX_Parser_t* parser = asx_parser_new(); @@ -110,12 +124,12 @@ static int parse_args(menu_t* menu,char* args) { asx_free_attribs(attribs); continue; } - ok = asx_get_attrib("ok",attribs); - cancel = asx_get_attrib("cancel",attribs); m = calloc(1,sizeof(struct list_entry_s)); m->p.txt = name; - m->ok = ok; - m->cancel = cancel; + m->ok = asx_get_attrib("ok",attribs); + m->cancel = asx_get_attrib("cancel",attribs); + m->left = asx_get_attrib("left",attribs); + m->right = asx_get_attrib("right",attribs); menu_list_add_entry(menu,m); free(element); diff --git a/libmenu/menu_dvbin.c b/libmenu/menu_dvbin.c index 7da0397aa6..6450a8d3b4 100644 --- a/libmenu/menu_dvbin.c +++ b/libmenu/menu_dvbin.c @@ -191,6 +191,7 @@ static void read_cmd(menu_t* menu, int cmd) char *cmd_name; switch(cmd) { + case MENU_CMD_RIGHT: case MENU_CMD_OK: { elem = mpriv->p.current; @@ -222,6 +223,7 @@ static void read_cmd(menu_t* menu, int cmd) } break; + case MENU_CMD_LEFT: case MENU_CMD_CANCEL: { elem = mpriv->p.current; diff --git a/libmenu/menu_filesel.c b/libmenu/menu_filesel.c index 7d40047cc9..9148dc2c8d 100644 --- a/libmenu/menu_filesel.c +++ b/libmenu/menu_filesel.c @@ -206,6 +206,9 @@ bailout: static void read_cmd(menu_t* menu,int cmd) { mp_cmd_t* c = NULL; switch(cmd) { + case MENU_CMD_LEFT: + mpriv->p.current = mpriv->p.menu; // Hack : we consider that the first entry is ../ + case MENU_CMD_RIGHT: case MENU_CMD_OK: { // Directory if(mpriv->p.current->d) { @@ -261,10 +264,9 @@ static void read_cmd(menu_t* menu,int cmd) { } static void read_key(menu_t* menu,int c){ - if(c == KEY_BS) { - mpriv->p.current = mpriv->p.menu; // Hack : we consider that the first entry is ../ - read_cmd(menu,MENU_CMD_OK); - } else + if(c == KEY_BS) + read_cmd(menu,MENU_CMD_LEFT); + else menu_list_read_key(menu,c,1); } diff --git a/libmenu/menu_list.c b/libmenu/menu_list.c index 8a2717751b..af74ed3eff 100644 --- a/libmenu/menu_list.c +++ b/libmenu/menu_list.c @@ -129,6 +129,7 @@ void menu_list_read_cmd(menu_t* menu,int cmd) { } else { mpriv->current = mpriv->menu; } break; + case MENU_CMD_LEFT: case MENU_CMD_CANCEL: menu->show = 0; menu->cl = 1; @@ -224,3 +225,4 @@ void menu_list_uninit(menu_t* menu,free_entry_t free_func) { mpriv->menu = mpriv->current = NULL; } + diff --git a/libmenu/menu_pt.c b/libmenu/menu_pt.c index 5ccd2f13fa..c5dc3673ea 100644 --- a/libmenu/menu_pt.c +++ b/libmenu/menu_pt.c @@ -50,6 +50,7 @@ static m_option_t cfg_fields[] = { static void read_cmd(menu_t* menu,int cmd) { switch(cmd) { + case MENU_CMD_RIGHT: case MENU_CMD_OK: { int d = 1; char str[15]; diff --git a/libmenu/vf_menu.c b/libmenu/vf_menu.c index 75203fcfdd..3903d954c1 100644 --- a/libmenu/vf_menu.c +++ b/libmenu/vf_menu.c @@ -105,6 +105,10 @@ static int cmd_filter(mp_cmd_t* cmd, int paused, struct vf_priv_s * priv) { menu_read_cmd(priv->current,MENU_CMD_UP); else if(strcmp(arg,"down") == 0) menu_read_cmd(priv->current,MENU_CMD_DOWN); + else if(strcmp(arg,"left") == 0) + menu_read_cmd(priv->current,MENU_CMD_LEFT); + else if(strcmp(arg,"right") == 0) + menu_read_cmd(priv->current,MENU_CMD_RIGHT); else if(strcmp(arg,"ok") == 0) menu_read_cmd(priv->current,MENU_CMD_OK); else if(strcmp(arg,"cancel") == 0)