aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2018-04-22 17:27:14 +0200
committerBoris Faure <billiob@gmail.com>2018-04-26 23:23:17 +0200
commit3569f18cc83a054e3dda7491080f54a66bfb887a (patch)
tree55a13bca934efc7512de86256cbbf5daadb2bd58 /src
parenttabs: clicking on New uses current dir for new term according to config (diff)
downloadterminology-3569f18cc83a054e3dda7491080f54a66bfb887a.tar.gz
Bring back the user title per tab
Summary: https://phab.enlightenment.org/T6719 Reviewers: billiob Reviewed By: billiob Differential Revision: https://phab.enlightenment.org/D5852
Diffstat (limited to 'src')
-rw-r--r--src/bin/termio.c25
-rw-r--r--src/bin/termio.h3
-rw-r--r--src/bin/termpty.c1
-rw-r--r--src/bin/termpty.h8
-rw-r--r--src/bin/win.c10
5 files changed, 38 insertions, 9 deletions
diff --git a/src/bin/termio.c b/src/bin/termio.c
index 65f6907..7c87a94 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -369,25 +369,38 @@ termio_title_get(const Evas_Object *obj)
{
Termio *sd = evas_object_smart_data_get(obj);
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL);
+ if (sd->pty->prop.user_title)
+ return sd->pty->prop.user_title;
return sd->pty->prop.title;
}
+const char *
+termio_user_title_get(const Evas_Object *obj)
+{
+ Termio *sd = evas_object_smart_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL);
+ return sd->pty->prop.user_title;
+}
+
void
-termio_title_set(Evas_Object *obj, const char *title)
+termio_user_title_set(Evas_Object *obj, const char *title)
{
Termio *sd = evas_object_smart_data_get(obj);
size_t len = 0;
EINA_SAFETY_ON_NULL_RETURN(sd);
- if (sd->pty->prop.title)
- eina_stringshare_del(sd->pty->prop.title);
+ if (sd->pty->prop.user_title)
+ {
+ eina_stringshare_del(sd->pty->prop.user_title);
+ sd->pty->prop.user_title = NULL;
+ }
if (title)
- len = strlen(title);
- if (len)
{
- sd->pty->prop.title = eina_stringshare_add_length(title, len);
+ len = strlen(title);
}
+ if (len)
+ sd->pty->prop.user_title = eina_stringshare_add_length(title, len);
if (sd->pty->cb.set_title.func)
sd->pty->cb.set_title.func(sd->pty->cb.set_title.data);
}
diff --git a/src/bin/termio.h b/src/bin/termio.h
index 0400b9c..0615595 100644
--- a/src/bin/termio.h
+++ b/src/bin/termio.h
@@ -39,7 +39,8 @@ Eina_Bool termio_cwd_get(const Evas_Object *obj, char *buf, size_t size);
Evas_Object *termio_textgrid_get(const Evas_Object *obj);
Evas_Object *termio_win_get(const Evas_Object *obj);
const char *termio_title_get(const Evas_Object *obj);
-void termio_title_set(Evas_Object *obj, const char *title);
+const char *termio_user_title_get(const Evas_Object *obj);
+void termio_user_title_set(Evas_Object *obj, const char *title);
const char *termio_icon_name_get(const Evas_Object *obj);
void termio_media_mute_set(Evas_Object *obj, Eina_Bool mute);
void termio_media_visualize_set(Evas_Object *obj, Eina_Bool visualize);
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 4645d0f..9098327 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -800,6 +800,7 @@ termpty_free(Termpty *ty)
if (ty->hand_exe_exit) ecore_event_handler_del(ty->hand_exe_exit);
if (ty->hand_fd) ecore_main_fd_handler_del(ty->hand_fd);
if (ty->prop.title) eina_stringshare_del(ty->prop.title);
+ if (ty->prop.user_title) eina_stringshare_del(ty->prop.user_title);
if (ty->prop.icon) eina_stringshare_del(ty->prop.icon);
if (ty->back)
{
diff --git a/src/bin/termpty.h b/src/bin/termpty.h
index 5cac261..0d78ca5 100644
--- a/src/bin/termpty.h
+++ b/src/bin/termpty.h
@@ -87,7 +87,13 @@ struct _Termpty
} change, set_title, set_icon, cancel_sel, exited, bell, command;
} cb;
struct {
- const char *title, *icon;
+ const char *icon;
+ /* dynamic title set by xterm, keep it in case user don't want a
+ * title any more by setting a empty title
+ */
+ const char *title;
+ /* set by user */
+ const char *user_title;
} prop;
const char *cur_cmd;
Termcell *screen, *screen2;
diff --git a/src/bin/win.c b/src/bin/win.c
index c09680b..912981a 100644
--- a/src/bin/win.c
+++ b/src/bin/win.c
@@ -4278,7 +4278,7 @@ _set_title_ok_cb(void *data,
if (!title || !strlen(title))
title = NULL;
- termio_title_set(term->termio, title);
+ termio_user_title_set(term->termio, title);
elm_object_focus_set(entry, EINA_FALSE);
elm_popup_dismiss(popup);
}
@@ -4315,6 +4315,7 @@ term_set_title(Term *term)
Evas_Object *o;
Evas_Object *popup;
Term_Container *tc = term->container;
+ const char *prev_title;
EINA_SAFETY_ON_NULL_RETURN(term);
term->wn->on_popover++;
@@ -4341,6 +4342,13 @@ term_set_title(Term *term)
o = elm_entry_add(popup);
elm_entry_single_line_set(o, EINA_TRUE);
+ elm_entry_editable_set(o, EINA_TRUE);
+ prev_title = termio_user_title_get(term->termio);
+ if (prev_title)
+ {
+ elm_entry_entry_set(o, prev_title);
+ elm_entry_cursor_pos_set(o, strlen(prev_title));
+ }
evas_object_smart_callback_add(o, "activated", _set_title_ok_cb, popup);
evas_object_smart_callback_add(o, "aborted", _set_title_cancel_cb, popup);
elm_object_content_set(popup, o);