summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLeandro Pereira <leandro@profusion.mobi>2012-08-23 09:44:31 +0000
committerLeandro Pereira <leandro@profusion.mobi>2012-08-23 09:44:31 +0000
commita258b46431c5ebe052c4a492930a7e08812b1dce (patch)
tree14e3174756c1e36c21537a259e23918750e94db3 /src
parent6e04128e7df88deccf22395db1caa2d9ee66d8ee (diff)
terminology: Cleanup _smart_cb_key_down()
SVN revision: 75610
Diffstat (limited to 'src')
-rw-r--r--src/bin/termio.c156
1 files changed, 77 insertions, 79 deletions
diff --git a/src/bin/termio.c b/src/bin/termio.c
index 97cb7f6..84c12ac 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -843,6 +843,72 @@ _compose_seq_reset(Termio *sd)
843 sd->composing = EINA_FALSE; 843 sd->composing = EINA_FALSE;
844} 844}
845 845
846static Eina_Bool
847_handle_alt_ctrl(const char *keyname, Evas_Object *term)
848{
849 if (!strcmp(keyname, "equal"))
850 termcmd_do(term, NULL, NULL, "f+");
851 else if (!strcmp(keyname, "minus"))
852 termcmd_do(term, NULL, NULL, "f-");
853 else if (!strcmp(keyname, "0"))
854 termcmd_do(term, NULL, NULL, "f");
855 else if (!strcmp(keyname, "9"))
856 termcmd_do(term, NULL, NULL, "fb");
857 else
858 return EINA_FALSE;
859
860 return EINA_TRUE;
861}
862
863static Eina_Bool
864_handle_shift(Evas_Event_Key_Down *ev, int by, Evas_Object *term, Termio *sd)
865{
866 if (!strcmp(ev->keyname, "Prior"))
867 {
868 sd->scroll += by;
869 if (sd->scroll > sd->pty->backscroll_num)
870 sd->scroll = sd->pty->backscroll_num;
871 _smart_update_queue(term, sd);
872 }
873 else if (!strcmp(ev->keyname, "Next"))
874 {
875 sd->scroll -= by;
876 if (sd->scroll < 0) sd->scroll = 0;
877 _smart_update_queue(term, sd);
878 }
879 else if (!strcmp(ev->keyname, "Insert"))
880 {
881 if (evas_key_modifier_is_set(ev->modifiers, "Control"))
882 _paste_selection(term, ELM_SEL_TYPE_PRIMARY);
883 else
884 _paste_selection(term, ELM_SEL_TYPE_CLIPBOARD);
885 }
886 else if (!strcmp(ev->keyname, "KP_Add"))
887 {
888 Config *config = termio_config_get(term);
889
890 if (config) _font_size_set(term, config->font.size + 1);
891 }
892 else if (!strcmp(ev->keyname, "KP_Subtract"))
893 {
894 Config *config = termio_config_get(term);
895
896 if (config) _font_size_set(term, config->font.size - 1);
897 }
898 else if (!strcmp(ev->keyname, "KP_Multiply"))
899 {
900 Config *config = termio_config_get(term);
901
902 if (config) _font_size_set(term, 10);
903 }
904 else if (!strcmp(ev->keyname, "KP_Divide"))
905 _take_selection(term, ELM_SEL_TYPE_CLIPBOARD);
906 else
907 return EINA_FALSE;
908
909 return EINA_TRUE;
910}
911
846void 912void
847_smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event) 913_smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event)
848{ 914{
@@ -884,91 +950,23 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
884 (evas_key_modifier_is_set(ev->modifiers, "Control")) && 950 (evas_key_modifier_is_set(ev->modifiers, "Control")) &&
885 (!evas_key_modifier_is_set(ev->modifiers, "Shift"))) 951 (!evas_key_modifier_is_set(ev->modifiers, "Shift")))
886 { 952 {
887 _compose_seq_reset(sd); 953 if (_handle_alt_ctrl(ev->keyname, data))
888 if (!strcmp(ev->keyname, "equal"))
889 { 954 {
890 termcmd_do(data, NULL, NULL, "f+"); 955 _compose_seq_reset(sd);
891 goto end;
892 }
893 else if (!strcmp(ev->keyname, "minus"))
894 {
895 termcmd_do(data, NULL, NULL, "f-");
896 goto end;
897 }
898 else if (!strcmp(ev->keyname, "0"))
899 {
900 termcmd_do(data, NULL, NULL, "f");
901 goto end;
902 }
903 else if (!strcmp(ev->keyname, "9"))
904 {
905 termcmd_do(data, NULL, NULL, "fb");
906 goto end; 956 goto end;
907 } 957 }
908 } 958 }
909 if (evas_key_modifier_is_set(ev->modifiers, "Shift")) 959 if ((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
960 (ev->keyname))
910 { 961 {
911 if (ev->keyname) 962 int by = sd->grid.h - 2;
912 {
913 int by = sd->grid.h - 2;
914 963
915 if (by < 1) by = 1; 964 if (by < 1) by = 1;
916 if (!strcmp(ev->keyname, "Prior")) 965
917 { 966 if (_handle_shift(ev, by, data, sd))
918 _compose_seq_reset(sd); 967 {
919 sd->scroll += by; 968 _compose_seq_reset(sd);
920 if (sd->scroll > sd->pty->backscroll_num) 969 goto end;
921 sd->scroll = sd->pty->backscroll_num;
922 _smart_update_queue(data, sd);
923 goto end;
924 }
925 else if (!strcmp(ev->keyname, "Next"))
926 {
927 _compose_seq_reset(sd);
928 sd->scroll -= by;
929 if (sd->scroll < 0) sd->scroll = 0;
930 _smart_update_queue(data, sd);
931 goto end;
932 }
933 else if (!strcmp(ev->keyname, "Insert"))
934 {
935 _compose_seq_reset(sd);
936 if (evas_key_modifier_is_set(ev->modifiers, "Control"))
937 _paste_selection(data, ELM_SEL_TYPE_PRIMARY);
938 else
939 _paste_selection(data, ELM_SEL_TYPE_CLIPBOARD);
940 goto end;
941 }
942 else if (!strcmp(ev->keyname, "KP_Add"))
943 {
944 Config *config = termio_config_get(data);
945
946 _compose_seq_reset(sd);
947 if (config) _font_size_set(data, config->font.size + 1);
948 goto end;
949 }
950 else if (!strcmp(ev->keyname, "KP_Subtract"))
951 {
952 Config *config = termio_config_get(data);
953
954 _compose_seq_reset(sd);
955 if (config) _font_size_set(data, config->font.size - 1);
956 goto end;
957 }
958 else if (!strcmp(ev->keyname, "KP_Multiply"))
959 {
960 Config *config = termio_config_get(data);
961
962 _compose_seq_reset(sd);
963 if (config) _font_size_set(data, 10);
964 goto end;
965 }
966 else if (!strcmp(ev->keyname, "KP_Divide"))
967 {
968 _compose_seq_reset(sd);
969 _take_selection(data, ELM_SEL_TYPE_CLIPBOARD);
970 goto end;
971 }
972 } 970 }
973 } 971 }
974 if (sd->jump_on_keypress) 972 if (sd->jump_on_keypress)