summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2015-08-06 21:26:43 +0200
committerBoris Faure <billiob@gmail.com>2015-08-06 21:53:14 +0200
commit3716c7ec51d25d93b70a5197bfbef4eb2f7b9e68 (patch)
tree55fc928df4423042fdb815a6e5ff8f37731ad688 /src
parentfc79e3857532f314ba8a26453b4582c767eddbdf (diff)
apply zoom level/font size to all terms in a window
Diffstat (limited to 'src')
-rw-r--r--src/bin/termcmd.c27
-rw-r--r--src/bin/termio.c20
-rw-r--r--src/bin/win.c34
-rw-r--r--src/bin/win.h8
4 files changed, 68 insertions, 21 deletions
diff --git a/src/bin/termcmd.c b/src/bin/termcmd.c
index cf5792f..cbe0073 100644
--- a/src/bin/termcmd.c
+++ b/src/bin/termcmd.c
@@ -23,12 +23,17 @@ _termcmd_search(Evas_Object *obj EINA_UNUSED, Evas_Object *win EINA_UNUSED, Evas
23} 23}
24 24
25static Eina_Bool 25static Eina_Bool
26_termcmd_font_size(Evas_Object *obj, Evas_Object *win EINA_UNUSED, Evas_Object *bg EINA_UNUSED, const char *cmd) 26_termcmd_font_size(Evas_Object *obj, Evas_Object *win EINA_UNUSED,
27 Evas_Object *bg EINA_UNUSED, const char *cmd)
27{ 28{
28 Config *config = termio_config_get(obj); 29 Config *config = termio_config_get(obj);
29 30
30 if (config) 31 if (config)
31 { 32 {
33 Term *term = termio_term_get(obj);
34 Win *wn = term_win_get(term);
35 int new_size;
36
32 if (cmd[0] == 0) // back to default 37 if (cmd[0] == 0) // back to default
33 { 38 {
34 config->font.bitmap = config->font.orig_bitmap; 39 config->font.bitmap = config->font.orig_bitmap;
@@ -37,8 +42,7 @@ _termcmd_font_size(Evas_Object *obj, Evas_Object *win EINA_UNUSED, Evas_Object *
37 eina_stringshare_del(config->font.name); 42 eina_stringshare_del(config->font.name);
38 config->font.name = eina_stringshare_add(config->font.orig_name); 43 config->font.name = eina_stringshare_add(config->font.orig_name);
39 } 44 }
40 termio_font_size_set(obj, config->font.orig_size); 45 new_size = config->font.orig_size;
41 return EINA_TRUE;
42 } 46 }
43 else if (cmd[0] == 'b') // big font size 47 else if (cmd[0] == 'b') // big font size
44 { 48 {
@@ -47,23 +51,24 @@ _termcmd_font_size(Evas_Object *obj, Evas_Object *win EINA_UNUSED, Evas_Object *
47 config->font.bitmap = 1; 51 config->font.bitmap = 1;
48 eina_stringshare_del(config->font.name); 52 eina_stringshare_del(config->font.name);
49 config->font.name = eina_stringshare_add("10x20.pcf"); 53 config->font.name = eina_stringshare_add("10x20.pcf");
50 termio_font_size_set(obj, 20);
51 }
52 else
53 {
54 termio_font_size_set(obj, 20);
55 } 54 }
55 new_size = 20;
56 } 56 }
57 else if (cmd[0] == '+') // size up 57 else if (cmd[0] == '+') // size up
58 { 58 {
59 termio_font_size_set(obj, config->font.size + 1); 59 new_size = config->font.size + 1;
60 } 60 }
61 else if (cmd[0] == '-') // size down 61 else if (cmd[0] == '-') // size down
62 { 62 {
63 termio_font_size_set(obj, config->font.size - 1); 63 new_size = config->font.size - 1;
64 } 64 }
65 else 65 else
66 ERR(_("Unknown font command: %s"), cmd); 66 {
67 ERR(_("Unknown font command: %s"), cmd);
68 return EINA_TRUE;
69 }
70
71 win_font_size_set(wn, new_size);
67 } 72 }
68 return EINA_TRUE; 73 return EINA_TRUE;
69} 74}
diff --git a/src/bin/termio.c b/src/bin/termio.c
index 39cec99..d8f319a 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -4422,11 +4422,10 @@ _smart_cb_gest_zoom_start(void *data, void *event)
4422 config = sd->config; 4422 config = sd->config;
4423 if (config) 4423 if (config)
4424 { 4424 {
4425 int sz; 4425 int sz = (double)config->font.size * p->zoom;
4426
4427 sd->zoom_fontsize_start = config->font.size; 4426 sd->zoom_fontsize_start = config->font.size;
4428 sz = (double)sd->zoom_fontsize_start * p->zoom; 4427 if (sz != config->font.size)
4429 if (sz != config->font.size) _font_size_set(data, sz); 4428 win_font_size_set(term_win_get(sd->term), sz);
4430 } 4429 }
4431 sd->didclick = EINA_TRUE; 4430 sd->didclick = EINA_TRUE;
4432 return EVAS_EVENT_FLAG_ON_HOLD; 4431 return EVAS_EVENT_FLAG_ON_HOLD;
@@ -4443,8 +4442,9 @@ _smart_cb_gest_zoom_move(void *data, void *event)
4443 config = sd->config; 4442 config = sd->config;
4444 if (config) 4443 if (config)
4445 { 4444 {
4446 int sz = (double)sd->zoom_fontsize_start * p->zoom; 4445 int sz = (double)config->font.size * p->zoom;
4447 if (sz != config->font.size) _font_size_set(data, sz); 4446 if (sz != config->font.size)
4447 win_font_size_set(term_win_get(sd->term), sz);
4448 } 4448 }
4449 sd->didclick = EINA_TRUE; 4449 sd->didclick = EINA_TRUE;
4450 return EVAS_EVENT_FLAG_ON_HOLD; 4450 return EVAS_EVENT_FLAG_ON_HOLD;
@@ -4461,8 +4461,9 @@ _smart_cb_gest_zoom_end(void *data, void *event)
4461 config = sd->config; 4461 config = sd->config;
4462 if (config) 4462 if (config)
4463 { 4463 {
4464 int sz = (double)sd->zoom_fontsize_start * p->zoom; 4464 int sz = (double)config->font.size * p->zoom;
4465 if (sz != config->font.size) _font_size_set(data, sz); 4465 if (sz != config->font.size)
4466 win_font_size_set(term_win_get(sd->term), sz);
4466 } 4467 }
4467 sd->didclick = EINA_TRUE; 4468 sd->didclick = EINA_TRUE;
4468 return EVAS_EVENT_FLAG_ON_HOLD; 4469 return EVAS_EVENT_FLAG_ON_HOLD;
@@ -4471,7 +4472,6 @@ _smart_cb_gest_zoom_end(void *data, void *event)
4471static Evas_Event_Flags 4472static Evas_Event_Flags
4472_smart_cb_gest_zoom_abort(void *data, void *event EINA_UNUSED) 4473_smart_cb_gest_zoom_abort(void *data, void *event EINA_UNUSED)
4473{ 4474{
4474// Elm_Gesture_Zoom_Info *p = event;
4475 Termio *sd = evas_object_smart_data_get(data); 4475 Termio *sd = evas_object_smart_data_get(data);
4476 Config *config; 4476 Config *config;
4477 4477
@@ -4480,7 +4480,7 @@ _smart_cb_gest_zoom_abort(void *data, void *event EINA_UNUSED)
4480 if (config) 4480 if (config)
4481 { 4481 {
4482 if (sd->zoom_fontsize_start != config->font.size) 4482 if (sd->zoom_fontsize_start != config->font.size)
4483 _font_size_set(data, sd->zoom_fontsize_start); 4483 win_font_size_set(term_win_get(sd->term), sd->zoom_fontsize_start);
4484 } 4484 }
4485 sd->didclick = EINA_TRUE; 4485 sd->didclick = EINA_TRUE;
4486 return EVAS_EVENT_FLAG_ON_HOLD; 4486 return EVAS_EVENT_FLAG_ON_HOLD;
diff --git a/src/bin/win.c b/src/bin/win.c
index 9293f5b..3a91d90 100644
--- a/src/bin/win.c
+++ b/src/bin/win.c
@@ -4117,6 +4117,24 @@ term_new(Win *wn, Config *config, const char *cmd,
4117 4117
4118/* }}} */ 4118/* }}} */
4119 4119
4120
4121
4122static Eina_Bool
4123_font_size_set(Term *term, void *data)
4124{
4125 int fontsize = (intptr_t) data;
4126
4127 termio_font_size_set(term->termio, fontsize);
4128
4129 return ECORE_CALLBACK_PASS_ON;
4130}
4131
4132void
4133win_font_size_set(Win *wn, int new_size)
4134{
4135 for_each_term_do(wn, &_font_size_set, (void*)(intptr_t)new_size);
4136}
4137
4120void 4138void
4121windows_free(void) 4139windows_free(void)
4122{ 4140{
@@ -4146,3 +4164,19 @@ windows_update(void)
4146 tc->update(tc); 4164 tc->update(tc);
4147 } 4165 }
4148} 4166}
4167
4168Eina_Bool
4169for_each_term_do(Win *wn, For_Each_Term cb, void *data)
4170{
4171 Eina_List *l;
4172 Term *term;
4173 Eina_Bool res = ECORE_CALLBACK_DONE;
4174
4175 EINA_LIST_FOREACH(wn->terms, l, term)
4176 {
4177 res = cb(term, data);
4178 if (res == ECORE_CALLBACK_CANCEL)
4179 return res;
4180 }
4181 return res;
4182}
diff --git a/src/bin/win.h b/src/bin/win.h
index 0b414d8..fda7b44 100644
--- a/src/bin/win.h
+++ b/src/bin/win.h
@@ -52,10 +52,18 @@ void term_next(Term *term);
52void term_prev(Term *term); 52void term_prev(Term *term);
53Win * term_win_get(Term *term); 53Win * term_win_get(Term *term);
54 54
55void
56win_font_size_set(Win *wn, int new_size);
55 57
56Eina_Bool 58Eina_Bool
57term_has_popmedia(const Term *term); 59term_has_popmedia(const Term *term);
58void 60void
59term_popmedia_close(Term *term); 61term_popmedia_close(Term *term);
60 62
63typedef Eina_Bool (*For_Each_Term)(Term *term, void *data);
64
65Eina_Bool
66for_each_term_do(Win *wn, For_Each_Term cb, void *data);
67
68
61#endif 69#endif