summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgodfath3r <galatsanosp@gmail.com>2015-08-16 20:36:38 +0200
committerBoris Faure <billiob@gmail.com>2015-08-16 20:36:38 +0200
commit8e8207dae1e2fc9195de5c97041d5d44629b702a (patch)
treeff0b0fbf4fb70103df4fe032c3ecc7f7a37490fa /src
parent8d4b06617fd9a9a71e08a63063d739ee56ef4f36 (diff)
Dont use : as a separator but trim it from selected word. Fixes T2602
Reviewers: billiob Maniphest Tasks: T2602 Differential Revision: https://phab.enlightenment.org/D2931
Diffstat (limited to 'src')
-rw-r--r--src/bin/termio.c95
1 files changed, 92 insertions, 3 deletions
diff --git a/src/bin/termio.c b/src/bin/termio.c
index 9992b22..c92fd6e 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -2600,7 +2600,6 @@ _codepoint_is_wordsep(const Eina_Unicode g)
2600 ')', 2600 ')',
2601 '*', 2601 '*',
2602 ',', 2602 ',',
2603 ':',
2604 ';', 2603 ';',
2605 '=', 2604 '=',
2606 '?', 2605 '?',
@@ -2770,6 +2769,95 @@ _codepoint_is_wordsep(const Eina_Unicode g)
2770 return EINA_FALSE; 2769 return EINA_FALSE;
2771} 2770}
2772 2771
2772Eina_Bool
2773_to_trim(Eina_Unicode codepoint)
2774{
2775 static const Eina_Unicode trim_chars[] =
2776 {
2777 ':',
2778 '<',
2779 '>',
2780 '.'
2781 };
2782 int i = 0;
2783 size_t len;
2784 len = sizeof(trim_chars)/sizeof((trim_chars)[0]);
2785
2786 for (i == 0; i < len; i++)
2787 if (codepoint == trim_chars[i])
2788 return EINA_TRUE;
2789 return EINA_FALSE;
2790}
2791
2792static void
2793_trim_sel_word(Termio *sd, int w)
2794{
2795 Termcell *cells;
2796 int start = 0, end = 0, line = 0, k = 0;
2797 if (sd->pty->selection.start.y != sd->pty->selection.end.y)
2798 {
2799 start = sd->pty->selection.start.x;
2800 end = sd->pty->selection.end.x;
2801 k = sd->pty->selection.end.y - sd->pty->selection.start.y;
2802 for (; k >= 0; k--)
2803 {
2804 line = sd->pty->selection.start.y;
2805 cells = termpty_cellrow_get(sd->pty, line, &w);
2806
2807 while (_to_trim(cells[start].codepoint)) start++;
2808
2809 if (start >= w)
2810 {
2811 start = 0;
2812 sd->pty->selection.start.y += 1;
2813 }
2814
2815 if (sd->pty->selection.start.y == sd->pty->selection.end.y)
2816 {
2817 start = 0;
2818 line = sd->pty->selection.start.y;
2819 cells = termpty_cellrow_get(sd->pty, line, &w);
2820 while (_to_trim(cells[start].codepoint)) start++;
2821 while (_to_trim(cells[end].codepoint)) end--;
2822 break;
2823 }
2824 }
2825 sd->pty->selection.start.x = start;
2826
2827 start = sd->pty->selection.start.x;
2828 end = sd->pty->selection.end.x;
2829 k = sd->pty->selection.end.y;
2830 for (; k >= sd->pty->selection.start.y; k--)
2831 {
2832 line = sd->pty->selection.end.y;
2833 cells = termpty_cellrow_get(sd->pty, line, &w);
2834
2835 while (_to_trim(cells[end].codepoint)) end--;
2836
2837 if (end <= 0)
2838 {
2839 end = w;
2840 sd->pty->selection.end.y -= 1;
2841 }
2842 }
2843 sd->pty->selection.end.x = end;
2844 }
2845 else
2846 {
2847 line = sd->pty->selection.start.y;
2848 start = sd->pty->selection.start.x;
2849 end = sd->pty->selection.end.x;
2850
2851 cells = termpty_cellrow_get(sd->pty, line, &w);
2852
2853 while (_to_trim(cells[start].codepoint)) start++;
2854 while (_to_trim(cells[end].codepoint)) end--;
2855
2856 sd->pty->selection.start.x = start;
2857 sd->pty->selection.end.x = end;
2858 }
2859}
2860
2773static void 2861static void
2774_sel_word(Termio *sd, int cx, int cy) 2862_sel_word(Termio *sd, int cx, int cy)
2775{ 2863{
@@ -2884,6 +2972,7 @@ _sel_word(Termio *sd, int cx, int cy)
2884 2972
2885 end: 2973 end:
2886 2974
2975 _trim_sel_word(sd, w);
2887 sd->pty->selection.by_word = EINA_TRUE; 2976 sd->pty->selection.by_word = EINA_TRUE;
2888 sd->pty->selection.is_top_to_bottom = EINA_TRUE; 2977 sd->pty->selection.is_top_to_bottom = EINA_TRUE;
2889 2978
@@ -3991,9 +4080,9 @@ _smart_cb_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUS
3991 if (!sd->pty->selection.is_active && sd->didclick) 4080 if (!sd->pty->selection.is_active && sd->didclick)
3992 sd->pty->selection.is_active = EINA_TRUE; 4081 sd->pty->selection.is_active = EINA_TRUE;
3993 if (shift && sd->pty->selection.is_active) 4082 if (shift && sd->pty->selection.is_active)
3994 _sel_word_to(sd, cx, cy - sd->scroll, EINA_TRUE); 4083 _sel_word_to(sd, cx, cy - sd->scroll, EINA_TRUE);
3995 else 4084 else
3996 _sel_word(sd, cx, cy - sd->scroll); 4085 _sel_word(sd, cx, cy - sd->scroll);
3997 if (sd->pty->selection.is_active) 4086 if (sd->pty->selection.is_active)
3998 termio_take_selection(data, ELM_SEL_TYPE_PRIMARY); 4087 termio_take_selection(data, ELM_SEL_TYPE_PRIMARY);
3999 sd->didclick = EINA_TRUE; 4088 sd->didclick = EINA_TRUE;