summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2012-08-18 01:30:05 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-08-18 01:30:05 +0000
commitda816d1bd64fbfcea1ef43ba0150154aec8ab839 (patch)
treeef97d449a963392f700a281cfd43e86e44615a84 /src
parent0576da08a1af9926cf3d6aac3b61ccbed0ec9abc (diff)
streamline compose code - less cnp
SVN revision: 75397
Diffstat (limited to 'src')
-rw-r--r--src/bin/termio.c52
1 files changed, 23 insertions, 29 deletions
diff --git a/src/bin/termio.c b/src/bin/termio.c
index 23c34d1..52350bf 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -820,13 +820,22 @@ _is_modifier(const char *key)
820 return EINA_FALSE; 820 return EINA_FALSE;
821} 821}
822 822
823static void
824_compose_seq_reset(Termio *sd)
825{
826 char *str;
827
828 EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str);
829 sd->composing = EINA_FALSE;
830}
831
823void 832void
824_smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event) 833_smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event)
825{ 834{
826 Evas_Event_Key_Down *ev = event; 835 Evas_Event_Key_Down *ev = event;
827 Termio *sd; 836 Termio *sd;
828 Ecore_Compose_State state; 837 Ecore_Compose_State state;
829 char *compres = NULL, *str; 838 char *compres = NULL;
830 839
831 sd = evas_object_smart_data_get(data); 840 sd = evas_object_smart_data_get(data);
832 if (!sd) return; 841 if (!sd) return;
@@ -852,6 +861,7 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
852 (!evas_key_modifier_is_set(ev->modifiers, "Control")) && 861 (!evas_key_modifier_is_set(ev->modifiers, "Control")) &&
853 (!strcmp(ev->keyname, "Home"))) 862 (!strcmp(ev->keyname, "Home")))
854 { 863 {
864 _compose_seq_reset(sd);
855 evas_object_smart_callback_call(data, "cmdbox", NULL); 865 evas_object_smart_callback_call(data, "cmdbox", NULL);
856 goto end; 866 goto end;
857 } 867 }
@@ -864,8 +874,7 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
864 if (by < 1) by = 1; 874 if (by < 1) by = 1;
865 if (!strcmp(ev->keyname, "Prior")) 875 if (!strcmp(ev->keyname, "Prior"))
866 { 876 {
867 EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str); 877 _compose_seq_reset(sd);
868 sd->composing = EINA_FALSE;
869 sd->scroll += by; 878 sd->scroll += by;
870 if (sd->scroll > sd->pty->backscroll_num) 879 if (sd->scroll > sd->pty->backscroll_num)
871 sd->scroll = sd->pty->backscroll_num; 880 sd->scroll = sd->pty->backscroll_num;
@@ -874,8 +883,7 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
874 } 883 }
875 else if (!strcmp(ev->keyname, "Next")) 884 else if (!strcmp(ev->keyname, "Next"))
876 { 885 {
877 EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str); 886 _compose_seq_reset(sd);
878 sd->composing = EINA_FALSE;
879 sd->scroll -= by; 887 sd->scroll -= by;
880 if (sd->scroll < 0) sd->scroll = 0; 888 if (sd->scroll < 0) sd->scroll = 0;
881 _smart_update_queue(data, sd); 889 _smart_update_queue(data, sd);
@@ -883,8 +891,7 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
883 } 891 }
884 else if (!strcmp(ev->keyname, "Insert")) 892 else if (!strcmp(ev->keyname, "Insert"))
885 { 893 {
886 EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str); 894 _compose_seq_reset(sd);
887 sd->composing = EINA_FALSE;
888 if (evas_key_modifier_is_set(ev->modifiers, "Control")) 895 if (evas_key_modifier_is_set(ev->modifiers, "Control"))
889 _paste_selection(data, ELM_SEL_TYPE_PRIMARY); 896 _paste_selection(data, ELM_SEL_TYPE_PRIMARY);
890 else 897 else
@@ -895,8 +902,7 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
895 { 902 {
896 Config *config = termio_config_get(data); 903 Config *config = termio_config_get(data);
897 904
898 EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str); 905 _compose_seq_reset(sd);
899 sd->composing = EINA_FALSE;
900 if (config) _font_size_set(data, config->font.size + 1); 906 if (config) _font_size_set(data, config->font.size + 1);
901 goto end; 907 goto end;
902 } 908 }
@@ -904,8 +910,7 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
904 { 910 {
905 Config *config = termio_config_get(data); 911 Config *config = termio_config_get(data);
906 912
907 EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str); 913 _compose_seq_reset(sd);
908 sd->composing = EINA_FALSE;
909 if (config) _font_size_set(data, config->font.size - 1); 914 if (config) _font_size_set(data, config->font.size - 1);
910 goto end; 915 goto end;
911 } 916 }
@@ -913,15 +918,13 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
913 { 918 {
914 Config *config = termio_config_get(data); 919 Config *config = termio_config_get(data);
915 920
916 EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str); 921 _compose_seq_reset(sd);
917 sd->composing = EINA_FALSE;
918 if (config) _font_size_set(data, 10); 922 if (config) _font_size_set(data, 10);
919 goto end; 923 goto end;
920 } 924 }
921 else if (!strcmp(ev->keyname, "KP_Divide")) 925 else if (!strcmp(ev->keyname, "KP_Divide"))
922 { 926 {
923 EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str); 927 _compose_seq_reset(sd);
924 sd->composing = EINA_FALSE;
925 _take_selection(data, ELM_SEL_TYPE_CLIPBOARD); 928 _take_selection(data, ELM_SEL_TYPE_CLIPBOARD);
926 goto end; 929 goto end;
927 } 930 }
@@ -943,15 +946,12 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
943 (ev->timestamp == sd->last_keyup)) return; 946 (ev->timestamp == sd->last_keyup)) return;
944 if (!sd->composing) 947 if (!sd->composing)
945 { 948 {
946 EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str); 949 _compose_seq_reset(sd);
947 sd->seq = eina_list_append(sd->seq, eina_stringshare_add(ev->key)); 950 sd->seq = eina_list_append(sd->seq, eina_stringshare_add(ev->key));
948 state = ecore_compose_get(sd->seq, &compres); 951 state = ecore_compose_get(sd->seq, &compres);
949 if (state == ECORE_COMPOSE_MIDDLE) sd->composing = EINA_TRUE; 952 if (state == ECORE_COMPOSE_MIDDLE) sd->composing = EINA_TRUE;
950 else sd->composing = EINA_FALSE; 953 else sd->composing = EINA_FALSE;
951 if (!sd->composing) 954 if (!sd->composing) _compose_seq_reset(sd);
952 {
953 EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str);
954 }
955 else goto end; 955 else goto end;
956 } 956 }
957 else 957 else
@@ -959,15 +959,10 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
959 if (_is_modifier(ev->key)) goto end; 959 if (_is_modifier(ev->key)) goto end;
960 sd->seq = eina_list_append(sd->seq, eina_stringshare_add(ev->key)); 960 sd->seq = eina_list_append(sd->seq, eina_stringshare_add(ev->key));
961 state = ecore_compose_get(sd->seq, &compres); 961 state = ecore_compose_get(sd->seq, &compres);
962 if (state == ECORE_COMPOSE_NONE) 962 if (state == ECORE_COMPOSE_NONE) _compose_seq_reset(sd);
963 {
964 EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str);
965 sd->composing = EINA_FALSE;
966 }
967 else if (state == ECORE_COMPOSE_DONE) 963 else if (state == ECORE_COMPOSE_DONE)
968 { 964 {
969 EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str); 965 _compose_seq_reset(sd);
970 sd->composing = EINA_FALSE;
971 if (compres) 966 if (compres)
972 { 967 {
973 termpty_write(sd->pty, compres, strlen(compres)); 968 termpty_write(sd->pty, compres, strlen(compres));
@@ -1988,7 +1983,6 @@ imf_done:
1988static void 1983static void
1989_smart_del(Evas_Object *obj) 1984_smart_del(Evas_Object *obj)
1990{ 1985{
1991 char *str;
1992 Evas_Object *o; 1986 Evas_Object *o;
1993 Termio *sd = evas_object_smart_data_get(obj); 1987 Termio *sd = evas_object_smart_data_get(obj);
1994 1988
@@ -2012,7 +2006,7 @@ _smart_del(Evas_Object *obj)
2012 if (sd->pty) termpty_free(sd->pty); 2006 if (sd->pty) termpty_free(sd->pty);
2013 if (sd->link.string) free(sd->link.string); 2007 if (sd->link.string) free(sd->link.string);
2014 EINA_LIST_FREE(sd->link.objs, o) evas_object_del(o); 2008 EINA_LIST_FREE(sd->link.objs, o) evas_object_del(o);
2015 EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str); 2009 _compose_seq_reset(sd);
2016 sd->cur.obj = NULL; 2010 sd->cur.obj = NULL;
2017 sd->event = NULL; 2011 sd->event = NULL;
2018 sd->cur.selo_top = NULL; 2012 sd->cur.selo_top = NULL;