diff options
author | Uoti Urpala <uau@symbol.nonexistent.invalid> | 2008-06-23 03:58:44 +0300 |
---|---|---|
committer | Uoti Urpala <uau@symbol.nonexistent.invalid> | 2008-06-23 03:58:44 +0300 |
commit | de560e8167c21a8fd9ea34f5f42f377102d65232 (patch) | |
tree | d5ef49221ccbb17308b0d14a96e6bd8cfba5916f /libmenu | |
parent | 68e70b3ec34af2e1002d17d0dc81b3408a399ade (diff) | |
parent | 5eee4632d3e2bcf17a29483467d247c71c202e0d (diff) | |
download | mpv-de560e8167c21a8fd9ea34f5f42f377102d65232.tar.bz2 mpv-de560e8167c21a8fd9ea34f5f42f377102d65232.tar.xz |
Merge svn changes up to r27123
Conflicts:
libmenu/menu_filesel.c
libmenu/menu_pt.c
Diffstat (limited to 'libmenu')
-rw-r--r-- | libmenu/menu_filesel.c | 25 | ||||
-rw-r--r-- | libmenu/menu_pt.c | 12 |
2 files changed, 27 insertions, 10 deletions
diff --git a/libmenu/menu_filesel.c b/libmenu/menu_filesel.c index b0643deaf5..187413832d 100644 --- a/libmenu/menu_filesel.c +++ b/libmenu/menu_filesel.c @@ -81,7 +81,7 @@ static void free_entry(list_entry_t* entry) { free(entry); } -static char* replace_path(char* title , char* dir) { +static char* replace_path(char* title , char* dir , int escape) { char *p = strstr(title,"%p"); if(p) { int tl = strlen(title); @@ -89,18 +89,29 @@ static char* replace_path(char* title , char* dir) { int t1l = p-title; int l = tl - 2 + dl; char *r, *n, *d = dir; - char term = *(p-1); + if (escape) { do { - if (*d == '\\' || *d == term) + if (*d == '\\') l++; + else if (*d == '\'') /* ' -> \'\\\'\' */ + l+=7; } while (*d++); + } r = malloc(l + 1); n = r + t1l; memcpy(r,title,t1l); do { - if (*dir == '\\' || *dir == term) + if (escape) { + if (*dir == '\\') + *n++ = '\\'; + else if (*dir == '\'') { /* ' -> \'\\\'\' */ + *n++ = '\\'; *n++ = '\''; + *n++ = '\\'; *n++ = '\\'; + *n++ = '\\'; *n++ = '\''; *n++ = '\\'; + } + } } while ((*n++ = *dir++)); if(tl - t1l - 2 > 0) strcpy(n-1,p+2); @@ -218,7 +229,7 @@ static int open_dir(menu_t* menu,char* args) { free(mpriv->p.title); p = strstr(mpriv->title,"%p"); - mpriv->p.title = replace_path(mpriv->title,mpriv->dir); + mpriv->p.title = replace_path(mpriv->title,mpriv->dir,0); if ((dirp = opendir (mpriv->dir)) == NULL){ mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_OpendirError, strerror(errno)); @@ -350,7 +361,7 @@ static void read_cmd(menu_t* menu,int cmd) { char *str; char *action = mpriv->p.current->d ? mpriv->dir_action:mpriv->file_action; sprintf(filename,"%s%s",mpriv->dir,mpriv->p.current->p.txt); - str = replace_path(action, filename); + str = replace_path(action, filename,1); mp_input_parse_and_queue_cmds(menu->input_ctx, str); if (str != action) free(str); @@ -361,7 +372,7 @@ static void read_cmd(menu_t* menu,int cmd) { char filename[fname_len]; char *str; sprintf(filename,"%s%s",mpriv->dir,mpriv->p.current->p.txt); - str = replace_path(action, filename); + str = replace_path(action, filename,1); mp_input_parse_and_queue_cmds(menu->input_ctx, str); if(str != action) free(str); diff --git a/libmenu/menu_pt.c b/libmenu/menu_pt.c index 1728c251a9..8540410a70 100644 --- a/libmenu/menu_pt.c +++ b/libmenu/menu_pt.c @@ -32,11 +32,13 @@ struct list_entry_s { struct menu_priv_s { menu_list_priv_t p; char* title; + int auto_close; }; static struct menu_priv_s cfg_dflt = { MENU_LIST_PRIV_DFLT, - "Jump to" + "Jump to", + 0 }; #define ST_OFF(m) M_ST_OFF(struct menu_priv_s,m) @@ -44,6 +46,7 @@ static struct menu_priv_s cfg_dflt = { static m_option_t cfg_fields[] = { MENU_LIST_PRIV_FIELDS, { "title", ST_OFF(title), CONF_TYPE_STRING, 0, 0, 0, NULL }, + { "auto-close", ST_OFF(auto_close), CONF_TYPE_FLAG, 0, 0, 1, NULL }, { NULL, NULL, NULL, 0,0,0,NULL } }; @@ -85,8 +88,11 @@ static void read_cmd(menu_t* menu,int cmd) { snprintf(str,15,"pt_step %d",d); } c = mp_input_parse_cmd(str); - if(c) - mp_input_queue_cmd(menu->input_ctx, c); + if(c) { + if(mpriv->auto_close) + mp_input_queue_cmd(menu->input_ctx, mp_input_parse_cmd("menu hide")); + mp_input_queue_cmd(menu->input_ctx, c); + } else mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_FailedToBuildCommand,str); } break; |