diff options
author | Carsten Haitzler <raster@rasterman.com> | 2012-08-14 12:30:55 +0000 |
---|---|---|
committer | Carsten Haitzler <raster@rasterman.com> | 2012-08-14 12:30:55 +0000 |
commit | a684b21b577c4f7e8e638fdd5ad99e8d647c86d7 (patch) | |
tree | 3211acb23ae3bb88ea5d0ea909b3e014bd3afbfc | |
parent | d99c9a920ab2c2c56e52e398c87ff7b0a9f181bb (diff) |
add some infra for cmd-mode for terminology. only 1 working cmd atm
"f" (font changes)
SVN revision: 75254
-rw-r--r-- | README | 1 | ||||
-rw-r--r-- | TODO | 4 | ||||
-rw-r--r-- | data/themes/default.edc | 68 | ||||
-rw-r--r-- | src/bin/Makefile.am | 1 | ||||
-rw-r--r-- | src/bin/config.c | 13 | ||||
-rw-r--r-- | src/bin/config.h | 5 | ||||
-rw-r--r-- | src/bin/main.c | 99 | ||||
-rw-r--r-- | src/bin/termcmd.c | 88 | ||||
-rw-r--r-- | src/bin/termcmd.h | 9 | ||||
-rw-r--r-- | src/bin/termio.c | 14 | ||||
-rw-r--r-- | src/bin/termio.h | 1 |
11 files changed, 293 insertions, 10 deletions
@@ -52,6 +52,7 @@ Shift+Keypad-Plus = Font size up 1 | |||
52 | Shift+Keypad-Minus = Font size down 1 | 52 | Shift+Keypad-Minus = Font size down 1 |
53 | Shift+Keypad-Multiply = Reset font size to 10 | 53 | Shift+Keypad-Multiply = Reset font size to 10 |
54 | Shift+Keypad-Divide = Copy highlight to Clipboard (same as ctrl+c in gui apps) | 54 | Shift+Keypad-Divide = Copy highlight to Clipboard (same as ctrl+c in gui apps) |
55 | Alt+backtick(grave) = Enter command mode | ||
55 | 56 | ||
56 | Mouse controls: | 57 | Mouse controls: |
57 | 58 | ||
@@ -1,10 +1,9 @@ | |||
1 | here's a short list of things i think we can do in the short to medium term to | 1 | here's a short list of things i think we can do in the short to medium term to |
2 | make it a first-class terminal: | 2 | make it a first-class terminal: |
3 | 3 | ||
4 | [ ] finish off remote http fetch code for media | ||
5 | [ ] filenames is `xxx' quotes not recognized (as ` different to ') | ||
6 | [ ] blink and blink2 attributes need to be supported | 4 | [ ] blink and blink2 attributes need to be supported |
7 | [ ] dnd text (to/from terminal) | 5 | [ ] dnd text (to/from terminal) |
6 | [ ] dnd file uri's too as text etc. | ||
8 | [ ] general input mode handling improvements (keypad, other key | 7 | [ ] general input mode handling improvements (keypad, other key |
9 | input, etc.) | 8 | input, etc.) |
10 | [ ] selection of themes | 9 | [ ] selection of themes |
@@ -18,7 +17,6 @@ make it a first-class terminal: | |||
18 | on_hold flags, etc.) | 17 | on_hold flags, etc.) |
19 | [ ] selection off edge scrolls in that direction (as per selection | 18 | [ ] selection off edge scrolls in that direction (as per selection |
20 | mode too if it gets NEAR an edge) | 19 | mode too if it gets NEAR an edge) |
21 | [ ] selection should become single edje object so it can be styled nicely | ||
22 | [ ] selection should have handles on the start/end so u can drag and | 20 | [ ] selection should have handles on the start/end so u can drag and |
23 | change its size once there | 21 | change its size once there |
24 | [ ] improve selection text extraction logic so its reliable | 22 | [ ] improve selection text extraction logic so its reliable |
diff --git a/data/themes/default.edc b/data/themes/default.edc index 54a6e53..7da3959 100644 --- a/data/themes/default.edc +++ b/data/themes/default.edc | |||
@@ -183,6 +183,74 @@ collections { | |||
183 | } | 183 | } |
184 | 184 | ||
185 | //////////////////////////////////////////////////////////////////// | 185 | //////////////////////////////////////////////////////////////////// |
186 | // a place terminology will place an entry box for internal commands | ||
187 | part { name: "cmdclip"; type: RECT; | ||
188 | description { state: "default" 0.0; | ||
189 | color: 255 255 255 255; | ||
190 | rel1.to: "terminology.cmdbox"; | ||
191 | rel1.offset: -100 -100; | ||
192 | rel2.to: "terminology.cmdbox"; | ||
193 | rel2.offset: 99 99; | ||
194 | color: 255 255 255 0; | ||
195 | visible: 0; | ||
196 | } | ||
197 | description { state: "visible" 0.0; | ||
198 | inherit: "default" 0.0; | ||
199 | color: 255 255 255 255; | ||
200 | visible: 1; | ||
201 | } | ||
202 | } | ||
203 | part { name: "cmdback"; type: RECT; | ||
204 | clip_to: "cmdclip"; | ||
205 | description { state: "default" 0.0; | ||
206 | color: 255 255 255 255; | ||
207 | rel1.to: "terminology.cmdbox"; | ||
208 | rel1.offset: -2 -2; | ||
209 | rel2.to: "terminology.cmdbox"; | ||
210 | rel2.offset: 1 1; | ||
211 | } | ||
212 | } | ||
213 | part { name: "terminology.cmdbox"; type: SWALLOW; | ||
214 | clip_to: "cmdclip"; | ||
215 | description { state: "default" 0.0; | ||
216 | fixed: 1 1; | ||
217 | min: 8 8; | ||
218 | rel1.relative: 0.0 1.0; | ||
219 | rel1.offset: 8 9; | ||
220 | rel2.offset: -9 9; | ||
221 | align: 0.5 0.0; | ||
222 | } | ||
223 | description { state: "visible" 0.0; | ||
224 | inherit: "default" 0.0; | ||
225 | rel1.offset: 8 -9; | ||
226 | rel2.offset: -9 -9; | ||
227 | align: 0.5 1.0; | ||
228 | } | ||
229 | } | ||
230 | program { name: "cmdshow0"; | ||
231 | signal: "cmdbox,show"; | ||
232 | source: "terminology"; | ||
233 | action: STATE_SET "visible" 0.0; | ||
234 | transition: DECELERATE 0.4; | ||
235 | target: "cmdclip"; | ||
236 | } | ||
237 | program { name: "cmdshow"; | ||
238 | signal: "cmdbox,show"; | ||
239 | source: "terminology"; | ||
240 | action: STATE_SET "visible" 0.0; | ||
241 | transition: SPRING 0.4 0.5 4; | ||
242 | target: "terminology.cmdbox"; | ||
243 | } | ||
244 | program { name: "cmdhide"; | ||
245 | signal: "cmdbox,hide"; | ||
246 | source: "terminology"; | ||
247 | action: STATE_SET "default" 0.0; | ||
248 | transition: ACCELERATE 0.5; | ||
249 | target: "terminology.cmdbox"; | ||
250 | target: "cmdclip"; | ||
251 | } | ||
252 | |||
253 | //////////////////////////////////////////////////////////////////// | ||
186 | // visual bell - spinning red siren light | 254 | // visual bell - spinning red siren light |
187 | part { name: "bell_glow"; | 255 | part { name: "bell_glow"; |
188 | mouse_events: 0; | 256 | mouse_events: 0; |
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index f2dec31..416647c 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am | |||
@@ -25,6 +25,7 @@ options_video.c options_video.h \ | |||
25 | options_theme.c options_theme.h \ | 25 | options_theme.c options_theme.h \ |
26 | options_wallpaper.c options_wallpaper.h \ | 26 | options_wallpaper.c options_wallpaper.h \ |
27 | termio.c termio.h \ | 27 | termio.c termio.h \ |
28 | termcmd.c termcmd.h \ | ||
28 | termiolink.c termiolink.h \ | 29 | termiolink.c termiolink.h \ |
29 | termpty.c termpty.h \ | 30 | termpty.c termpty.h \ |
30 | termptydbl.c termptydbl.h \ | 31 | termptydbl.c termptydbl.h \ |
diff --git a/src/bin/config.c b/src/bin/config.c index 0f40732..faa29ca 100644 --- a/src/bin/config.c +++ b/src/bin/config.c | |||
@@ -107,7 +107,7 @@ config_shutdown(void) | |||
107 | } | 107 | } |
108 | 108 | ||
109 | void | 109 | void |
110 | config_save(const Config *config, const char *key) | 110 | config_save(Config *config, const char *key) |
111 | { | 111 | { |
112 | Eet_File *ef; | 112 | Eet_File *ef; |
113 | char buf[PATH_MAX], buf2[PATH_MAX]; | 113 | char buf[PATH_MAX], buf2[PATH_MAX]; |
@@ -118,7 +118,12 @@ config_save(const Config *config, const char *key) | |||
118 | 118 | ||
119 | if (config->temporary) return; | 119 | if (config->temporary) return; |
120 | if (!key) key = config->config_key; | 120 | if (!key) key = config->config_key; |
121 | 121 | config->font.orig_size = config->font.size; | |
122 | eina_stringshare_del(config->font.orig_name); | ||
123 | config->font.orig_name = NULL; | ||
124 | if (config->font.name) config->font.orig_name = eina_stringshare_add(config->font.name); | ||
125 | config->font.orig_bitmap = config->font.bitmap; | ||
126 | |||
122 | cfgdir = _config_home_get(); | 127 | cfgdir = _config_home_get(); |
123 | snprintf(buf, sizeof(buf), "%s/terminology/config/standard", cfgdir); | 128 | snprintf(buf, sizeof(buf), "%s/terminology/config/standard", cfgdir); |
124 | ecore_file_mkpath(buf); | 129 | ecore_file_mkpath(buf); |
@@ -152,6 +157,9 @@ config_load(const char *key) | |||
152 | eet_close(ef); | 157 | eet_close(ef); |
153 | if (config) | 158 | if (config) |
154 | { | 159 | { |
160 | config->font.orig_size = config->font.size; | ||
161 | if (config->font.name) config->font.orig_name = eina_stringshare_add(config->font.name); | ||
162 | config->font.orig_bitmap = config->font.bitmap; | ||
155 | if (config->version < CONF_VER) | 163 | if (config->version < CONF_VER) |
156 | { | 164 | { |
157 | // currently no upgrade path so reset config. | 165 | // currently no upgrade path so reset config. |
@@ -389,6 +397,7 @@ config_del(Config *config) | |||
389 | if (!config) return; | 397 | if (!config) return; |
390 | 398 | ||
391 | eina_stringshare_del(config->font.name); | 399 | eina_stringshare_del(config->font.name); |
400 | eina_stringshare_del(config->font.orig_name); | ||
392 | eina_stringshare_del(config->theme); | 401 | eina_stringshare_del(config->theme); |
393 | eina_stringshare_del(config->background); | 402 | eina_stringshare_del(config->background); |
394 | eina_stringshare_del(config->wordsep); | 403 | eina_stringshare_del(config->wordsep); |
diff --git a/src/bin/config.h b/src/bin/config.h index 231c5dc..c612c49 100644 --- a/src/bin/config.h +++ b/src/bin/config.h | |||
@@ -10,8 +10,11 @@ struct _Config | |||
10 | int version; | 10 | int version; |
11 | struct { | 11 | struct { |
12 | const char *name; | 12 | const char *name; |
13 | const char *orig_name; | ||
13 | int size; | 14 | int size; |
15 | int orig_size; | ||
14 | unsigned char bitmap; | 16 | unsigned char bitmap; |
17 | unsigned char orig_bitmap; | ||
15 | } font; | 18 | } font; |
16 | struct { | 19 | struct { |
17 | const char *email; | 20 | const char *email; |
@@ -42,7 +45,7 @@ struct _Config | |||
42 | 45 | ||
43 | void config_init(void); | 46 | void config_init(void); |
44 | void config_shutdown(void); | 47 | void config_shutdown(void); |
45 | void config_save(const Config *config, const char *key); | 48 | void config_save(Config *config, const char *key); |
46 | Config *config_load(const char *key); | 49 | Config *config_load(const char *key); |
47 | void config_del(Config *config); | 50 | void config_del(Config *config); |
48 | 51 | ||
diff --git a/src/bin/main.c b/src/bin/main.c index f77a437..40ebd48 100644 --- a/src/bin/main.c +++ b/src/bin/main.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include "main.h" | 5 | #include "main.h" |
6 | #include "win.h" | 6 | #include "win.h" |
7 | #include "termio.h" | 7 | #include "termio.h" |
8 | #include "termcmd.h" | ||
8 | #include "config.h" | 9 | #include "config.h" |
9 | #include "controls.h" | 10 | #include "controls.h" |
10 | #include "media.h" | 11 | #include "media.h" |
@@ -13,11 +14,13 @@ | |||
13 | int _log_domain = -1; | 14 | int _log_domain = -1; |
14 | 15 | ||
15 | static Evas_Object *win = NULL, *bg = NULL, *term = NULL, *media = NULL; | 16 | static Evas_Object *win = NULL, *bg = NULL, *term = NULL, *media = NULL; |
17 | static Evas_Object *cmdbox = NULL; | ||
16 | static Evas_Object *popmedia = NULL; | 18 | static Evas_Object *popmedia = NULL; |
17 | static Evas_Object *conform = NULL; | 19 | static Evas_Object *conform = NULL; |
18 | static Ecore_Timer *flush_timer = NULL; | 20 | static Ecore_Timer *flush_timer = NULL; |
19 | static Eina_Bool focused = EINA_FALSE; | 21 | static Eina_Bool focused = EINA_FALSE; |
20 | static Eina_Bool hold = EINA_FALSE; | 22 | static Eina_Bool hold = EINA_FALSE; |
23 | static Eina_Bool cmdbox_up = EINA_FALSE; | ||
21 | 24 | ||
22 | static void | 25 | static void |
23 | _cb_del(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__) | 26 | _cb_del(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__) |
@@ -31,7 +34,10 @@ _cb_focus_in(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__) | |||
31 | if (!focused) elm_win_urgent_set(win, EINA_FALSE); | 34 | if (!focused) elm_win_urgent_set(win, EINA_FALSE); |
32 | focused = EINA_TRUE; | 35 | focused = EINA_TRUE; |
33 | edje_object_signal_emit(bg, "focus,in", "terminology"); | 36 | edje_object_signal_emit(bg, "focus,in", "terminology"); |
34 | elm_object_focus_set(data, EINA_TRUE); | 37 | if (cmdbox_up) |
38 | elm_object_focus_set(cmdbox, EINA_TRUE); | ||
39 | else | ||
40 | elm_object_focus_set(data, EINA_TRUE); | ||
35 | } | 41 | } |
36 | 42 | ||
37 | static void | 43 | static void |
@@ -39,7 +45,10 @@ _cb_focus_out(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__) | |||
39 | { | 45 | { |
40 | focused = EINA_FALSE; | 46 | focused = EINA_FALSE; |
41 | edje_object_signal_emit(bg, "focus,out", "terminology"); | 47 | edje_object_signal_emit(bg, "focus,out", "terminology"); |
42 | elm_object_focus_set(data, EINA_FALSE); | 48 | if (cmdbox_up) |
49 | elm_object_focus_set(cmdbox, EINA_FALSE); | ||
50 | else | ||
51 | elm_object_focus_set(data, EINA_FALSE); | ||
43 | elm_cache_all_flush(); | 52 | elm_cache_all_flush(); |
44 | } | 53 | } |
45 | 54 | ||
@@ -86,7 +95,6 @@ _cb_change(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNU | |||
86 | static void | 95 | static void |
87 | _cb_exited(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__) | 96 | _cb_exited(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__) |
88 | { | 97 | { |
89 | printf("hold = %i\n", hold); | ||
90 | if (!hold) elm_exit(); | 98 | if (!hold) elm_exit(); |
91 | } | 99 | } |
92 | 100 | ||
@@ -141,6 +149,71 @@ _cb_popup(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUS | |||
141 | edje_object_signal_emit(bg, "popmedia,movie", "terminology"); | 149 | edje_object_signal_emit(bg, "popmedia,movie", "terminology"); |
142 | } | 150 | } |
143 | 151 | ||
152 | static void | ||
153 | _cb_cmdbox(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__) | ||
154 | { | ||
155 | cmdbox_up = EINA_TRUE; | ||
156 | elm_object_focus_set(term, EINA_FALSE); | ||
157 | edje_object_signal_emit(bg, "cmdbox,show", "terminology"); | ||
158 | elm_entry_entry_set(cmdbox, ""); | ||
159 | evas_object_show(cmdbox); | ||
160 | elm_object_focus_set(cmdbox, EINA_TRUE); | ||
161 | } | ||
162 | |||
163 | static void | ||
164 | _cb_cmd_activated(void *data __UNUSED__, Evas_Object *obj, void *event __UNUSED__) | ||
165 | { | ||
166 | char *cmd; | ||
167 | |||
168 | elm_object_focus_set(obj, EINA_FALSE); | ||
169 | edje_object_signal_emit(bg, "cmdbox,hide", "terminology"); | ||
170 | elm_object_focus_set(term, EINA_TRUE); | ||
171 | cmd = (char *)elm_entry_entry_get(obj); | ||
172 | if (cmd) | ||
173 | { | ||
174 | cmd = elm_entry_markup_to_utf8(cmd); | ||
175 | if (cmd) | ||
176 | { | ||
177 | termcmd_do(term, win, bg, cmd); | ||
178 | free(cmd); | ||
179 | } | ||
180 | } | ||
181 | cmdbox_up = EINA_FALSE; | ||
182 | } | ||
183 | |||
184 | static void | ||
185 | _cb_cmd_aborted(void *data __UNUSED__, Evas_Object *obj, void *event __UNUSED__) | ||
186 | { | ||
187 | elm_object_focus_set(obj, EINA_FALSE); | ||
188 | edje_object_signal_emit(bg, "cmdbox,hide", "terminology"); | ||
189 | elm_object_focus_set(term, EINA_TRUE); | ||
190 | cmdbox_up = EINA_FALSE; | ||
191 | } | ||
192 | |||
193 | static void | ||
194 | _cb_cmd_changed(void *data __UNUSED__, Evas_Object *obj, void *event __UNUSED__) | ||
195 | { | ||
196 | char *cmd; | ||
197 | |||
198 | cmd = (char *)elm_entry_entry_get(obj); | ||
199 | if (cmd) | ||
200 | { | ||
201 | cmd = elm_entry_markup_to_utf8(cmd); | ||
202 | if (cmd) | ||
203 | { | ||
204 | termcmd_watch(term, win, bg, cmd); | ||
205 | free(cmd); | ||
206 | } | ||
207 | } | ||
208 | } | ||
209 | |||
210 | static void | ||
211 | _cb_cmd_hints_changed(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) | ||
212 | { | ||
213 | evas_object_show(obj); | ||
214 | edje_object_part_swallow(data, "terminology.cmdbox", obj); | ||
215 | } | ||
216 | |||
144 | void | 217 | void |
145 | main_trans_update(const Config *config) | 218 | main_trans_update(const Config *config) |
146 | { | 219 | { |
@@ -554,7 +627,24 @@ elm_main(int argc, char **argv) | |||
554 | if (pos_y < 0) pos_y = screen_h + pos_y; | 627 | if (pos_y < 0) pos_y = screen_h + pos_y; |
555 | evas_object_move(win, pos_x, pos_y); | 628 | evas_object_move(win, pos_x, pos_y); |
556 | } | 629 | } |
557 | 630 | ||
631 | cmdbox = o = elm_entry_add(win); | ||
632 | elm_entry_single_line_set(o, EINA_TRUE); | ||
633 | elm_entry_scrollable_set(o, EINA_FALSE); | ||
634 | elm_entry_scrollbar_policy_set(o, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); | ||
635 | elm_entry_input_panel_layout_set(o, ELM_INPUT_PANEL_LAYOUT_TERMINAL); | ||
636 | elm_entry_autocapital_type_set(o, ELM_AUTOCAPITAL_TYPE_NONE); | ||
637 | elm_entry_input_panel_enabled_set(o, EINA_TRUE); | ||
638 | elm_entry_input_panel_language_set(o, ELM_INPUT_PANEL_LANG_ALPHABET); | ||
639 | elm_entry_input_panel_return_key_type_set(o, ELM_INPUT_PANEL_RETURN_KEY_TYPE_GO); | ||
640 | elm_entry_prediction_allow_set(o, EINA_FALSE); | ||
641 | evas_object_show(o); | ||
642 | evas_object_smart_callback_add(o, "activated", _cb_cmd_activated, bg); | ||
643 | evas_object_smart_callback_add(o, "aborted", _cb_cmd_aborted, bg); | ||
644 | evas_object_smart_callback_add(o, "changed,user", _cb_cmd_changed, bg); | ||
645 | evas_object_event_callback_add(o, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _cb_cmd_hints_changed, bg); | ||
646 | edje_object_part_swallow(bg, "terminology.cmdbox", o); | ||
647 | |||
558 | term = o = termio_add(win, config, cmd, cd, size_w, size_h); | 648 | term = o = termio_add(win, config, cmd, cd, size_w, size_h); |
559 | termio_win_set(o, win); | 649 | termio_win_set(o, win); |
560 | evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | 650 | evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); |
@@ -567,6 +657,7 @@ elm_main(int argc, char **argv) | |||
567 | evas_object_smart_callback_add(o, "exited", _cb_exited, NULL); | 657 | evas_object_smart_callback_add(o, "exited", _cb_exited, NULL); |
568 | evas_object_smart_callback_add(o, "bell", _cb_bell, NULL); | 658 | evas_object_smart_callback_add(o, "bell", _cb_bell, NULL); |
569 | evas_object_smart_callback_add(o, "popup", _cb_popup, NULL); | 659 | evas_object_smart_callback_add(o, "popup", _cb_popup, NULL); |
660 | evas_object_smart_callback_add(o, "cmdbox", _cb_cmdbox, NULL); | ||
570 | evas_object_show(o); | 661 | evas_object_show(o); |
571 | 662 | ||
572 | main_trans_update(config); | 663 | main_trans_update(config); |
diff --git a/src/bin/termcmd.c b/src/bin/termcmd.c new file mode 100644 index 0000000..a5dbf55 --- /dev/null +++ b/src/bin/termcmd.c | |||
@@ -0,0 +1,88 @@ | |||
1 | #include "private.h" | ||
2 | |||
3 | #include <Elementary.h> | ||
4 | #include "main.h" | ||
5 | #include "win.h" | ||
6 | #include "termio.h" | ||
7 | #include "config.h" | ||
8 | #include "controls.h" | ||
9 | #include "media.h" | ||
10 | #include "utils.h" | ||
11 | #include "termcmd.h" | ||
12 | |||
13 | // called as u type | ||
14 | Eina_Bool | ||
15 | termcmd_watch(Evas_Object *obj, Evas_Object *win, Evas_Object *bg, const char *cmd) | ||
16 | { | ||
17 | if (!cmd) return EINA_FALSE; | ||
18 | if ((cmd[0] == '/') || (cmd[0] == 's')) // search | ||
19 | { | ||
20 | if (cmd[1] == 0) // clear search | ||
21 | { | ||
22 | printf("search clear\n"); | ||
23 | return EINA_TRUE; | ||
24 | } | ||
25 | printf("search '%s'\n", cmd + 1); | ||
26 | return EINA_TRUE; | ||
27 | } | ||
28 | return EINA_FALSE; | ||
29 | obj = win = bg = NULL; | ||
30 | } | ||
31 | |||
32 | // called when you hit enter | ||
33 | Eina_Bool | ||
34 | termcmd_do(Evas_Object *obj, Evas_Object *win, Evas_Object *bg, const char *cmd) | ||
35 | { | ||
36 | if (!cmd) return EINA_FALSE; | ||
37 | if ((cmd[0] == '/') || (cmd[0] == 's')) // search | ||
38 | { | ||
39 | if (cmd[1] == 0) // clear search | ||
40 | { | ||
41 | printf("search clear\n"); | ||
42 | return EINA_TRUE; | ||
43 | } | ||
44 | printf("search '%s'\n", cmd + 1); | ||
45 | return EINA_TRUE; | ||
46 | } | ||
47 | if ((cmd[0] == 'f') || (cmd[0] == 'F')) // font size | ||
48 | { | ||
49 | Config *config = termio_config_get(obj); | ||
50 | |||
51 | if (config) | ||
52 | { | ||
53 | if (cmd[1] == 0) // back to default | ||
54 | { | ||
55 | config->font.bitmap = config->font.orig_bitmap; | ||
56 | if (config->font.orig_name) | ||
57 | { | ||
58 | eina_stringshare_del(config->font.name); | ||
59 | config->font.name = eina_stringshare_add(config->font.orig_name); | ||
60 | } | ||
61 | termio_font_size_set(obj, config->font.orig_size); | ||
62 | return EINA_TRUE; | ||
63 | } | ||
64 | else if (cmd[1] == 'b') // big font size | ||
65 | { | ||
66 | if (config->font.orig_bitmap) | ||
67 | { | ||
68 | config->font.bitmap = 1; | ||
69 | eina_stringshare_del(config->font.name); | ||
70 | config->font.name = eina_stringshare_add("10x20.pcf"); | ||
71 | termio_font_size_set(obj, 20); | ||
72 | } | ||
73 | } | ||
74 | else if (cmd[1] == '+') // size up | ||
75 | { | ||
76 | termio_font_size_set(obj, config->font.size + 1); | ||
77 | } | ||
78 | else if (cmd[1] == '-') // size down | ||
79 | { | ||
80 | termio_font_size_set(obj, config->font.size - 1); | ||
81 | } | ||
82 | } | ||
83 | return EINA_TRUE; | ||
84 | } | ||
85 | return EINA_FALSE; | ||
86 | obj = win = bg = NULL; | ||
87 | } | ||
88 | |||
diff --git a/src/bin/termcmd.h b/src/bin/termcmd.h new file mode 100644 index 0000000..51b0ed2 --- /dev/null +++ b/src/bin/termcmd.h | |||
@@ -0,0 +1,9 @@ | |||
1 | #ifndef _TERMCMD_H__ | ||
2 | #define _TERMCMD_H__ 1 | ||
3 | |||
4 | #include "config.h" | ||
5 | |||
6 | Eina_Bool termcmd_watch(Evas_Object *obj, Evas_Object *win, Evas_Object *bg, const char *cmd); | ||
7 | Eina_Bool termcmd_do(Evas_Object *obj, Evas_Object *win, Evas_Object *bg, const char *cmd); | ||
8 | |||
9 | #endif | ||
diff --git a/src/bin/termio.c b/src/bin/termio.c index b26735a..77281f0 100644 --- a/src/bin/termio.c +++ b/src/bin/termio.c | |||
@@ -779,6 +779,12 @@ _font_size_set(Evas_Object *obj, int size) | |||
779 | } | 779 | } |
780 | } | 780 | } |
781 | 781 | ||
782 | void | ||
783 | termio_font_size_set(Evas_Object *obj, int size) | ||
784 | { | ||
785 | _font_size_set(obj, size); | ||
786 | } | ||
787 | |||
782 | static void | 788 | static void |
783 | _smart_cb_key_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event) | 789 | _smart_cb_key_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event) |
784 | { | 790 | { |
@@ -841,6 +847,14 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, | |||
841 | } | 847 | } |
842 | } | 848 | } |
843 | } | 849 | } |
850 | if ((evas_key_modifier_is_set(ev->modifiers, "Alt")) && | ||
851 | (!evas_key_modifier_is_set(ev->modifiers, "Shift")) && | ||
852 | (!evas_key_modifier_is_set(ev->modifiers, "Control")) && | ||
853 | (!strcmp(ev->keyname, "grave"))) | ||
854 | { | ||
855 | evas_object_smart_callback_call(data, "cmdbox", NULL); | ||
856 | goto end; | ||
857 | } | ||
844 | if (evas_key_modifier_is_set(ev->modifiers, "Shift")) | 858 | if (evas_key_modifier_is_set(ev->modifiers, "Shift")) |
845 | { | 859 | { |
846 | if (ev->keyname) | 860 | if (ev->keyname) |
diff --git a/src/bin/termio.h b/src/bin/termio.h index 5fa3f0b..d1a39aa 100644 --- a/src/bin/termio.h +++ b/src/bin/termio.h | |||
@@ -14,5 +14,6 @@ const char *termio_link_get(const Evas_Object *obj); | |||
14 | void termio_mouseover_suspend_pushpop(Evas_Object *obj, int dir); | 14 | void termio_mouseover_suspend_pushpop(Evas_Object *obj, int dir); |
15 | void termio_size_get(Evas_Object *obj, int *w, int *h); | 15 | void termio_size_get(Evas_Object *obj, int *w, int *h); |
16 | int termio_scroll_get(Evas_Object *obj); | 16 | int termio_scroll_get(Evas_Object *obj); |
17 | void termio_font_size_set(Evas_Object *obj, int size); | ||
17 | 18 | ||
18 | #endif | 19 | #endif |