forked from enlightenment/enlightenment
- more work on typebuffer
- you can do things like '*a*' or 'A*' and they will get selected. - todo: * replace TEXT part with something better (size limitations) * add more logic to typebuffer SVN revision: 18366
This commit is contained in:
parent
d3ebda92b0
commit
ea2d0482c7
|
@ -189,8 +189,12 @@ group {
|
|||
state: "default" 0.0;
|
||||
min: 96 64;
|
||||
max: 384 64;
|
||||
visible: 0;
|
||||
/* if we enable this, then we will zoom in / out */
|
||||
//min: 24 16;
|
||||
//max: 24 16;
|
||||
visible: 1;
|
||||
align: 0.5 0.5;
|
||||
color: 255 255 255 0;
|
||||
image {
|
||||
normal: "e17_fileman_typebuf.png";
|
||||
border: 17 17 17 17;
|
||||
|
@ -199,11 +203,38 @@ group {
|
|||
description {
|
||||
state: "shown" 0.0;
|
||||
inherit: "default" 0.0;
|
||||
min: 96 64;
|
||||
max: 384 64;
|
||||
visible: 1;
|
||||
color: 255 255 255 255;
|
||||
}
|
||||
}
|
||||
part {
|
||||
name: "text";
|
||||
type: TEXT;
|
||||
effect: SHADOW;
|
||||
description {
|
||||
state: "default" 0.0;
|
||||
fixed: 1 1;
|
||||
align: 0.5 0.5;
|
||||
color: 0 0 0 0;
|
||||
color3: 255 255 255 0;
|
||||
text {
|
||||
text: "No Title";
|
||||
size: 12;
|
||||
font: "Edje-Vera";
|
||||
align: 0.5 0.5;
|
||||
elipsis: 0.0;
|
||||
min: 1 1;
|
||||
}
|
||||
}
|
||||
description {
|
||||
state: "shown" 0.0;
|
||||
inherit: "default" 0.0;
|
||||
color: 0 0 0 255;
|
||||
color3: 255 255 255 128;
|
||||
}
|
||||
}
|
||||
|
||||
programs {
|
||||
program {
|
||||
name: "typebuf_show";
|
||||
|
@ -212,6 +243,7 @@ group {
|
|||
action: STATE_SET "shown" 0.0;
|
||||
transition: LINEAR 0.2;
|
||||
target: "typebuffer";
|
||||
target: "text";
|
||||
}
|
||||
program {
|
||||
name: "typebuf_hide";
|
||||
|
@ -220,11 +252,12 @@ group {
|
|||
action: STATE_SET "default" 0.0;
|
||||
transition: LINEAR 0.2;
|
||||
target: "typebuffer";
|
||||
target: "text";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
group {
|
||||
name: "fileman/main";
|
||||
parts {
|
||||
|
|
|
@ -332,6 +332,7 @@ e17_fileman_bg.png \
|
|||
e17_fileman_bg_shadow.png \
|
||||
e17_fileman_rubberband.png \
|
||||
e17_fileman_thumb_bg.png \
|
||||
e17_fileman_typebuf.png \
|
||||
e17_icon_fileman_c.png \
|
||||
e17_icon_fileman_file.png \
|
||||
e17_icon_fileman_file_clicked.png \
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <dirent.h>
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#include <regex.h>
|
||||
|
||||
/* TODO:
|
||||
*
|
||||
|
@ -238,7 +239,7 @@ static void _e_fm_icon_mouse_out_cb (void *data, Evas *e, Evas_O
|
|||
static void _e_fm_icon_mouse_move_cb (void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static int _e_fm_win_mouse_up_cb (void *data, int type, void *event);
|
||||
|
||||
static void _e_fm_icon_goto_key(E_Fm_Smart_Data *sd, char *c);
|
||||
static void _e_fm_icon_select_regex(E_Fm_Smart_Data *sd, char *glob);
|
||||
static void _e_fm_icon_select_up(E_Fm_Smart_Data *sd);
|
||||
static void _e_fm_icon_select_down(E_Fm_Smart_Data *sd);
|
||||
static void _e_fm_icon_select_left(E_Fm_Smart_Data *sd);
|
||||
|
@ -1468,9 +1469,9 @@ _e_fm_dir_files_get(void *data)
|
|||
sd->files = evas_list_sort(sd->files,
|
||||
evas_list_count(sd->files),
|
||||
_e_fm_files_sort_name_cb);
|
||||
e_icon_layout_sort(sd->layout, _e_fm_files_sort_layout_name_cb);
|
||||
// e_icon_layout_sort(sd->layout, _e_fm_files_sort_layout_name_cb);
|
||||
|
||||
|
||||
/*
|
||||
e_icon_layout_freeze(sd->layout);
|
||||
e_icon_layout_reset(sd->layout);
|
||||
|
||||
|
@ -1480,7 +1481,7 @@ _e_fm_dir_files_get(void *data)
|
|||
e_icon_layout_pack(sd->layout, icon->icon_object);
|
||||
}
|
||||
e_icon_layout_thaw(sd->layout);
|
||||
*/
|
||||
|
||||
sd->timer = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
@ -2259,10 +2260,103 @@ _e_fm_win_mouse_up_cb(void *data, int type, void *event)
|
|||
}
|
||||
|
||||
static void
|
||||
_e_fm_icon_goto_key(E_Fm_Smart_Data *sd, char *c)
|
||||
_e_fm_string_replace(const char *src, const char *key, const char *replacement, char *result, size_t resultsize)
|
||||
{
|
||||
size_t resultlen;
|
||||
size_t keylen;
|
||||
|
||||
if(resultsize < 0) return;
|
||||
|
||||
/* special case to prevent infinite loop if key==replacement=="" */
|
||||
if(strcmp(key, replacement) == 0)
|
||||
{
|
||||
snprintf(result, resultsize, "%s", src);
|
||||
return;
|
||||
}
|
||||
|
||||
keylen = strlen(key);
|
||||
|
||||
resultlen = 0;
|
||||
while(*src != '\0' && resultlen+1 < resultsize)
|
||||
{
|
||||
if(strncmp(src, key, keylen) == 0)
|
||||
{
|
||||
snprintf(result+resultlen, resultsize-resultlen, "%s", replacement);
|
||||
resultlen += strlen(result+resultlen);
|
||||
src += keylen;
|
||||
}
|
||||
else
|
||||
{
|
||||
result[resultlen++] = *src++;
|
||||
}
|
||||
}
|
||||
result[resultlen] = '\0';
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_e_fm_icon_select_regex(E_Fm_Smart_Data *sd, char *glob)
|
||||
{
|
||||
E_Fm_Icon *icon;
|
||||
Evas_List *l;
|
||||
char *regex, *tregex;
|
||||
regex_t reg, *creg;
|
||||
int stars, i;
|
||||
|
||||
stars = 0;
|
||||
for(i = 0; i < strlen(glob); i++)
|
||||
if(glob[i] == '*')
|
||||
stars++;
|
||||
|
||||
tregex = calloc(strlen(glob) + stars + 1, sizeof(char));
|
||||
_e_fm_string_replace(glob, "*", ".*", tregex, (strlen(glob) + stars + 1)*sizeof(char));
|
||||
regex = calloc(strlen(tregex) + 3, sizeof(char));
|
||||
snprintf(regex, (strlen(tregex) + 3)*sizeof(char), "^%s$", tregex);
|
||||
regcomp(®, regex, REG_NOSUB | REG_EXTENDED);
|
||||
_e_fm_selections_clear(sd);
|
||||
for (l = sd->files; l; l = l->next)
|
||||
{
|
||||
icon = l->data;
|
||||
creg = ®
|
||||
if(!regexec(creg, icon->file->name, 0, NULL, 0))
|
||||
{
|
||||
_e_fm_selections_add(l->data, l);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
#if 0
|
||||
position:
|
||||
{
|
||||
Evas_Coord x, y, w, h;
|
||||
icon = l->data;
|
||||
evas_object_geometry_get(icon->icon_object, &x, &y, &w, &h);
|
||||
if(!E_CONTAINS(sd->x, sd->y, sd->w, sd->h, x, y, w, h))
|
||||
{
|
||||
E_Event_Fm_Reconfigure *ev;
|
||||
|
||||
ev = E_NEW(E_Event_Fm_Reconfigure, 1);
|
||||
if (ev)
|
||||
{
|
||||
ev->object = sd->object;
|
||||
ev->x = sd->x;
|
||||
ev->y = sd->child.y - (sd->y - (y - sd->icon_info.y_space));
|
||||
ev->w = sd->w;
|
||||
ev->h = sd->h;
|
||||
ecore_event_add(E_EVENT_FM_RECONFIGURE, ev, NULL, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
__e_fm_icon_goto_key(E_Fm_Smart_Data *sd, char *c)
|
||||
{
|
||||
E_Fm_Icon *icon;
|
||||
Evas_List *l;
|
||||
|
||||
return;
|
||||
|
||||
if(sd->selection.current.ptr)
|
||||
{
|
||||
|
@ -2625,8 +2719,6 @@ _e_fm_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|||
ev = event_info;
|
||||
sd = data;
|
||||
|
||||
edje_object_signal_emit(sd->object, "typebuf_show", "");
|
||||
|
||||
if (!strcmp(ev->keyname, "Up"))
|
||||
_e_fm_icon_select_up(sd);
|
||||
else if (!strcmp(ev->keyname, "Down"))
|
||||
|
@ -2635,9 +2727,47 @@ _e_fm_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|||
_e_fm_icon_select_left(sd);
|
||||
else if (!strcmp(ev->keyname, "Right"))
|
||||
_e_fm_icon_select_right(sd);
|
||||
else if (!strcmp(ev->keyname, "Escape"))
|
||||
{
|
||||
if(!strcmp(edje_object_part_state_get(sd->edje_obj, "typebuffer", NULL), "shown"))
|
||||
{
|
||||
edje_object_signal_emit(sd->edje_obj, "typebuf_hide", "");
|
||||
edje_object_part_text_set(sd->edje_obj, "text", "");
|
||||
}
|
||||
}
|
||||
else if (!strcmp(ev->keyname, "Return"))
|
||||
{
|
||||
if(!strcmp(edje_object_part_state_get(sd->edje_obj, "typebuffer", NULL), "shown"))
|
||||
{
|
||||
char *buf;
|
||||
|
||||
edje_object_signal_emit(sd->edje_obj, "typebuf_hide", "");
|
||||
buf = strdup(edje_object_part_text_get(sd->edje_obj, "text"));
|
||||
edje_object_part_text_set(sd->edje_obj, "text", "");
|
||||
if(strcmp(buf, ""))
|
||||
_e_fm_icon_select_regex(sd, buf);
|
||||
}
|
||||
else
|
||||
_e_fm_icon_run(sd);
|
||||
}
|
||||
else if (!strcmp(ev->keyname, "BackSpace"))
|
||||
{
|
||||
if(!strcmp(edje_object_part_state_get(sd->edje_obj, "typebuffer", NULL), "shown"))
|
||||
{
|
||||
char *str;
|
||||
str = NULL;
|
||||
str = edje_object_part_text_get(sd->edje_obj, "text");
|
||||
if(str)
|
||||
{
|
||||
char *buf;
|
||||
int size;
|
||||
size = strlen(str);
|
||||
buf = calloc(size , sizeof(char));
|
||||
snprintf(buf, size, "%s", str);
|
||||
edje_object_part_text_set(sd->edje_obj, "text", buf);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char *fullname;
|
||||
|
||||
|
@ -2650,8 +2780,28 @@ _e_fm_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|||
free(fullname);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(strlen(ev->keyname) == 1)
|
||||
_e_fm_icon_goto_key(sd, ev->string);
|
||||
{
|
||||
char *str;
|
||||
str = NULL;
|
||||
str = edje_object_part_text_get(sd->edje_obj, "text");
|
||||
if(str)
|
||||
{
|
||||
char *buf;
|
||||
int size;
|
||||
size = strlen(str) + strlen(ev->string) + 2;
|
||||
buf = calloc(size, sizeof(char));
|
||||
snprintf(buf, size, "%s%s", str, ev->string);
|
||||
edje_object_part_text_set(sd->edje_obj, "text", buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
edje_object_part_text_set(sd->edje_obj, "text", ev->key);
|
||||
}
|
||||
if(strcmp(edje_object_part_state_get(sd->edje_obj, "typebuffer", NULL), "shown"))
|
||||
edje_object_signal_emit(sd->edje_obj, "typebuf_show", "");
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
Loading…
Reference in New Issue