This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository efm2.
View the commit online.
commit 3f363c4ce692e208f3ff760c1d384d794aafcd35
Author: Carsten Haitzler (Rasterman) <[email protected]>
AuthorDate: Wed Jan 21 20:13:35 2026 +0000
typebuf - make tab complete work in non-cmd mode
---
src/efm/efm_typebuf.c | 82 +++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 66 insertions(+), 16 deletions(-)
diff --git a/src/efm/efm_typebuf.c b/src/efm/efm_typebuf.c
index d2e8342..a1f997d 100644
--- a/src/efm/efm_typebuf.c
+++ b/src/efm/efm_typebuf.c
@@ -1,5 +1,6 @@
#include "efm_typebuf.h"
#include "efm_util.h"
+#include "elm_entry_common.h"
static int
_typebuf_command_detect(const char *str)
@@ -7,6 +8,7 @@ _typebuf_command_detect(const char *str)
int i = 0;
Eina_Unicode cp;
+ if (!str) return -1;
for (i = 0; (cp = eina_unicode_utf8_next_get(str, &i));)
{
if (cp == ' ') return i;
@@ -15,17 +17,38 @@ _typebuf_command_detect(const char *str)
}
static void
-_typebuf_command_clear(Smart_Data *sd, int cpos, const char *str)
+_typebuf_command_clear(Smart_Data *sd, const char *str)
{
- elm_entry_entry_set(sd->o_typebuf, str);
+ char *s = elm_entry_utf8_to_markup(str);
+
+ elm_entry_entry_set(sd->o_typebuf, s);
+ free(s);
+}
+
+static char *
+_typebuf_command_get(Smart_Data *sd)
+{
+ const char *str = elm_entry_entry_get(sd->o_typebuf);
+ return elm_entry_markup_to_utf8(str);
}
static void
_typebuf_command_str_build_hilight(Eina_Strbuf *buf, const char *str,
int cmdendpos)
{ // make cmd hilight and appear different
+ char *s, *s2;
+
eina_strbuf_append(buf, "<hilight>");
- eina_strbuf_append_n(buf, str, cmdendpos - 1);
+ s = malloc(cmdendpos);
+ if (s)
+ {
+ strncpy(s, str, cmdendpos - 1);
+ s[cmdendpos - 1] = 0;
+ s2 = elm_entry_utf8_to_markup(s);
+ free(s);
+ eina_strbuf_append(buf, s2);
+ free(s2);
+ }
eina_strbuf_append(buf, "</>");
}
@@ -34,7 +57,12 @@ _typebuf_command_str_build_args(Eina_Strbuf *buf, const char *str,
int cmdendpos)
{ // process arguments after cmd and put them back in the string
// e.g. hilight them as appropriate. here just dumbly appending
- eina_strbuf_append(buf, str + cmdendpos - 1);
+ char *s = strdup(str + cmdendpos - 1);
+ char *s2 = elm_entry_utf8_to_markup(s);
+
+ eina_strbuf_append(buf, s2);
+ free(s);
+ free(s2);
}
static void
@@ -79,10 +107,9 @@ _typebuf_update(Smart_Data *sd, const char *str)
static void
_typebuf_format(Smart_Data *sd)
{
- const char *str = elm_entry_entry_get(sd->o_typebuf);
- char *s = elm_entry_markup_to_utf8(str);
- int cpos = elm_entry_cursor_pos_get(sd->o_typebuf);
- int pos;
+ char *s = _typebuf_command_get(sd);
+ int cpos = elm_entry_cursor_pos_get(sd->o_typebuf);
+ int pos;
printf("XXX: typebuf changed [%s]\n", s);
pos = _typebuf_command_detect(s);
@@ -100,7 +127,7 @@ _typebuf_format(Smart_Data *sd)
}
}
// strip out markup used to hilight stuff
- else if (pos <= 0) _typebuf_command_clear(sd, cpos, s);
+ else if (pos <= 0) _typebuf_command_clear(sd, s);
// pur cursor back where it was
elm_entry_cursor_pos_set(sd->o_typebuf, cpos);
_typebuf_update(sd, s);
@@ -110,7 +137,31 @@ _typebuf_format(Smart_Data *sd)
static void
_typebuf_complete(Smart_Data *sd)
{ // find where cursor is (just after) and complete it if possible
- int cpos = elm_entry_cursor_pos_get(sd->o_typebuf);
+ char *s = _typebuf_command_get(sd);
+ int pos = _typebuf_command_detect(s);
+
+ printf("XXX: complete typebuf\n");
+ if (pos > 0)
+ { // cmd mode - ifferent completion
+ int cpos = elm_entry_cursor_pos_get(sd->o_typebuf);
+ printf("XXX: cmd, cpos=%i\n", cpos);
+ }
+ else
+ {
+ Icon *ic = _efm_sel_first_get(sd);
+
+ printf("XXX: selected %p\n", ic);
+ if (ic)
+ {
+ char *s2 = elm_entry_utf8_to_markup(ic->info.file);
+ _typebuf_command_clear(sd, s2);
+ elm_entry_cursor_end_set(sd->o_typebuf);
+ free(s2);
+ _efm_sel_none(sd);
+ _icon_select(ic);
+ }
+ }
+ free(s);
}
static void
@@ -122,8 +173,7 @@ _typebuf_history(Smart_Data *sd, int dir)
if (sd->typebuf_history_pos == -1)
{
- const char *str = elm_entry_entry_get(sd->o_typebuf);
- char *s = elm_entry_markup_to_utf8(str);
+ char *s = _typebuf_command_get(sd);
eina_stringshare_replace(&sd->typebuf_restore, s);
printf("XXX: restore = [%s]", s);
free(s);
@@ -138,7 +188,7 @@ _typebuf_history(Smart_Data *sd, int dir)
else if (sd->typebuf_history_pos >= len) sd->typebuf_history_pos = len - 1;
if (restore) s = sd->typebuf_restore;
else s = eina_list_nth(sd->typebuf_history, sd->typebuf_history_pos);
- elm_entry_entry_set(sd->o_typebuf, s);
+ _typebuf_command_clear(sd, s);
elm_entry_cursor_end_set(sd->o_typebuf);
_typebuf_format(sd);
}
@@ -158,14 +208,14 @@ _cb_typebuf_activated(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Smart_Data *sd = data;
- const char *str = elm_entry_entry_get(sd->o_typebuf);
- char *s = elm_entry_markup_to_utf8(str);
+ char *s = _typebuf_command_get(sd);
printf("XXX: typebuf activated\n");
// XXX: "run" the cmd (eg run selected files or run detected cmd)
sd->typebuf_history
= eina_list_prepend(sd->typebuf_history, eina_stringshare_add(s));
- while (eina_list_count(sd->typebuf_history) > sd->config.typebuf_history_max)
+ while ((int)eina_list_count(sd->typebuf_history) >
+ sd->config.typebuf_history_max)
{
Eina_List *last = eina_list_last(sd->typebuf_history);
if (last)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.