diff options
author | Boris Faure <billiob@gmail.com> | 2015-01-18 21:18:39 +0100 |
---|---|---|
committer | Boris Faure <billiob@gmail.com> | 2015-02-06 20:48:03 +0100 |
commit | da474a4c68e3dbad2a6bf9a84741618ad610cad5 (patch) | |
tree | 18c151efe567fa648b1e5532febdb67d2c0efe1f /src | |
parent | b966fdae1f26f34cd08f4a33202bbf765ac5f354 (diff) |
cleanup _sel_set() api
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/termio.c | 58 |
1 files changed, 24 insertions, 34 deletions
diff --git a/src/bin/termio.c b/src/bin/termio.c index 35cc726..5622396 100644 --- a/src/bin/termio.c +++ b/src/bin/termio.c | |||
@@ -105,7 +105,7 @@ static Evas_Smart_Class _parent_sc = EVAS_SMART_CLASS_INIT_NULL; | |||
105 | 105 | ||
106 | static Eina_List *terms = NULL; | 106 | static Eina_List *terms = NULL; |
107 | 107 | ||
108 | static void _sel_set(Evas_Object *obj, Eina_Bool enable); | 108 | static void _sel_set(Termio *sd, Eina_Bool enable); |
109 | static void _remove_links(Termio *sd, Evas_Object *obj); | 109 | static void _remove_links(Termio *sd, Evas_Object *obj); |
110 | static void _smart_update_queue(Evas_Object *obj, Termio *sd); | 110 | static void _smart_update_queue(Evas_Object *obj, Termio *sd); |
111 | static void _smart_apply(Evas_Object *obj); | 111 | static void _smart_apply(Evas_Object *obj); |
@@ -144,12 +144,12 @@ termio_scroll(Evas_Object *obj, int direction, int start_y, int end_y) | |||
144 | ty->selection.end.y += direction; | 144 | ty->selection.end.y += direction; |
145 | if (!(start_y <= ty->selection.start.y && | 145 | if (!(start_y <= ty->selection.start.y && |
146 | end_y >= ty->selection.end.y)) | 146 | end_y >= ty->selection.end.y)) |
147 | _sel_set(obj, EINA_FALSE); | 147 | _sel_set(sd, EINA_FALSE); |
148 | } | 148 | } |
149 | else | 149 | else |
150 | if (!((start_y > ty->selection.end.y) || | 150 | if (!((start_y > ty->selection.end.y) || |
151 | (end_y < ty->selection.start.y))) | 151 | (end_y < ty->selection.start.y))) |
152 | _sel_set(obj, EINA_FALSE); | 152 | _sel_set(sd, EINA_FALSE); |
153 | else | 153 | else |
154 | { | 154 | { |
155 | ty->selection.start.y += direction; | 155 | ty->selection.start.y += direction; |
@@ -218,7 +218,7 @@ termio_content_change(Evas_Object *obj, Evas_Coord x, Evas_Coord y, | |||
218 | int d = MIN(n, ty->w - x); | 218 | int d = MIN(n, ty->w - x); |
219 | if (!((x > end_x) || (x + d < start_x))) | 219 | if (!((x > end_x) || (x + d < start_x))) |
220 | { | 220 | { |
221 | _sel_set(obj, EINA_FALSE); | 221 | _sel_set(sd, EINA_FALSE); |
222 | break; | 222 | break; |
223 | } | 223 | } |
224 | n -= d; | 224 | n -= d; |
@@ -244,7 +244,7 @@ termio_content_change(Evas_Object *obj, Evas_Coord x, Evas_Coord y, | |||
244 | 244 | ||
245 | if (!((cells_changed > (cells_selection + sel_len)) || | 245 | if (!((cells_changed > (cells_selection + sel_len)) || |
246 | (cells_selection > (cells_changed + n)))) | 246 | (cells_selection > (cells_changed + n)))) |
247 | _sel_set(obj, EINA_FALSE); | 247 | _sel_set(sd, EINA_FALSE); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | 250 | ||
@@ -2082,11 +2082,8 @@ termio_selection_get(Evas_Object *obj, int c1x, int c1y, int c2x, int c2y, | |||
2082 | 2082 | ||
2083 | 2083 | ||
2084 | static void | 2084 | static void |
2085 | _sel_set(Evas_Object *obj, Eina_Bool enable) | 2085 | _sel_set(Termio *sd, Eina_Bool enable) |
2086 | { | 2086 | { |
2087 | Termio *sd = evas_object_smart_data_get(obj); | ||
2088 | EINA_SAFETY_ON_NULL_RETURN(sd); | ||
2089 | |||
2090 | if (sd->pty->selection.is_active == enable) return; | 2087 | if (sd->pty->selection.is_active == enable) return; |
2091 | sd->pty->selection.is_active = enable; | 2088 | sd->pty->selection.is_active = enable; |
2092 | if (enable) | 2089 | if (enable) |
@@ -2139,7 +2136,7 @@ _lost_selection(void *data, Elm_Sel_Type selection) | |||
2139 | eina_stringshare_del(sd->sel_str); | 2136 | eina_stringshare_del(sd->sel_str); |
2140 | sd->sel_str = NULL; | 2137 | sd->sel_str = NULL; |
2141 | } | 2138 | } |
2142 | _sel_set(obj, EINA_FALSE); | 2139 | _sel_set(sd, EINA_FALSE); |
2143 | elm_object_cnp_selection_clear(sd->win, selection); | 2140 | elm_object_cnp_selection_clear(sd->win, selection); |
2144 | _smart_update_queue(obj, sd); | 2141 | _smart_update_queue(obj, sd); |
2145 | sd->have_sel = EINA_FALSE; | 2142 | sd->have_sel = EINA_FALSE; |
@@ -2310,17 +2307,14 @@ termio_paste_selection(Evas_Object *obj, Elm_Sel_Type type) | |||
2310 | } | 2307 | } |
2311 | 2308 | ||
2312 | static void | 2309 | static void |
2313 | _sel_line(Evas_Object *obj, int cx EINA_UNUSED, int cy) | 2310 | _sel_line(Termio *sd, int cy) |
2314 | { | 2311 | { |
2315 | int y, w = 0; | 2312 | int y, w = 0; |
2316 | Termio *sd = evas_object_smart_data_get(obj); | ||
2317 | Termcell *cells; | 2313 | Termcell *cells; |
2318 | 2314 | ||
2319 | EINA_SAFETY_ON_NULL_RETURN(sd); | ||
2320 | |||
2321 | termpty_cellcomp_freeze(sd->pty); | 2315 | termpty_cellcomp_freeze(sd->pty); |
2322 | 2316 | ||
2323 | _sel_set(obj, EINA_TRUE); | 2317 | _sel_set(sd, EINA_TRUE); |
2324 | sd->pty->selection.makesel = EINA_FALSE; | 2318 | sd->pty->selection.makesel = EINA_FALSE; |
2325 | sd->pty->selection.start.x = 0; | 2319 | sd->pty->selection.start.x = 0; |
2326 | sd->pty->selection.start.y = cy; | 2320 | sd->pty->selection.start.y = cy; |
@@ -2540,18 +2534,15 @@ _codepoint_is_wordsep(const Eina_Unicode g) | |||
2540 | } | 2534 | } |
2541 | 2535 | ||
2542 | static void | 2536 | static void |
2543 | _sel_word(Evas_Object *obj, int cx, int cy) | 2537 | _sel_word(Termio *sd, int cx, int cy) |
2544 | { | 2538 | { |
2545 | Termio *sd = evas_object_smart_data_get(obj); | ||
2546 | Termcell *cells; | 2539 | Termcell *cells; |
2547 | int x, y, w = 0; | 2540 | int x, y, w = 0; |
2548 | Eina_Bool done = EINA_FALSE; | 2541 | Eina_Bool done = EINA_FALSE; |
2549 | 2542 | ||
2550 | EINA_SAFETY_ON_NULL_RETURN(sd); | ||
2551 | |||
2552 | termpty_cellcomp_freeze(sd->pty); | 2543 | termpty_cellcomp_freeze(sd->pty); |
2553 | 2544 | ||
2554 | _sel_set(obj, EINA_TRUE); | 2545 | _sel_set(sd, EINA_TRUE); |
2555 | sd->pty->selection.makesel = EINA_FALSE; | 2546 | sd->pty->selection.makesel = EINA_FALSE; |
2556 | sd->pty->selection.start.x = cx; | 2547 | sd->pty->selection.start.x = cx; |
2557 | sd->pty->selection.start.y = cy; | 2548 | sd->pty->selection.start.y = cy; |
@@ -2645,9 +2636,8 @@ _sel_word(Evas_Object *obj, int cx, int cy) | |||
2645 | } | 2636 | } |
2646 | 2637 | ||
2647 | static void | 2638 | static void |
2648 | _sel_word_to(Evas_Object *obj, int cx, int cy) | 2639 | _sel_word_to(Termio *sd, int cx, int cy) |
2649 | { | 2640 | { |
2650 | Termio *sd = evas_object_smart_data_get(obj); | ||
2651 | int start_x, start_y, end_x, end_y; | 2641 | int start_x, start_y, end_x, end_y; |
2652 | 2642 | ||
2653 | EINA_SAFETY_ON_NULL_RETURN(sd); | 2643 | EINA_SAFETY_ON_NULL_RETURN(sd); |
@@ -2666,7 +2656,7 @@ _sel_word_to(Evas_Object *obj, int cx, int cy) | |||
2666 | if ((cy >= start_y && cy <= end_y) && | 2656 | if ((cy >= start_y && cy <= end_y) && |
2667 | (cx >= start_x && cx <= end_x)) | 2657 | (cx >= start_x && cx <= end_x)) |
2668 | { | 2658 | { |
2669 | _sel_set(obj, EINA_FALSE); | 2659 | _sel_set(sd, EINA_FALSE); |
2670 | return; | 2660 | return; |
2671 | } | 2661 | } |
2672 | } | 2662 | } |
@@ -2681,12 +2671,12 @@ _sel_word_to(Evas_Object *obj, int cx, int cy) | |||
2681 | if ((cy > start_y || (cy == start_y && cx >= start_x)) && | 2671 | if ((cy > start_y || (cy == start_y && cx >= start_x)) && |
2682 | (cy < end_y || (cy == end_y && cx <= end_x))) | 2672 | (cy < end_y || (cy == end_y && cx <= end_x))) |
2683 | { | 2673 | { |
2684 | _sel_set(obj, EINA_FALSE); | 2674 | _sel_set(sd, EINA_FALSE); |
2685 | return; | 2675 | return; |
2686 | } | 2676 | } |
2687 | } | 2677 | } |
2688 | 2678 | ||
2689 | _sel_word(obj, cx, cy); | 2679 | _sel_word(sd, cx, cy); |
2690 | 2680 | ||
2691 | if (sd->pty->selection.is_box) | 2681 | if (sd->pty->selection.is_box) |
2692 | { | 2682 | { |
@@ -3333,7 +3323,7 @@ _smart_cb_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUS | |||
3333 | { | 3323 | { |
3334 | if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK) | 3324 | if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK) |
3335 | { | 3325 | { |
3336 | _sel_line(data, cx, cy - sd->scroll); | 3326 | _sel_line(sd, cy - sd->scroll); |
3337 | if (sd->pty->selection.is_active) | 3327 | if (sd->pty->selection.is_active) |
3338 | termio_take_selection(data, ELM_SEL_TYPE_PRIMARY); | 3328 | termio_take_selection(data, ELM_SEL_TYPE_PRIMARY); |
3339 | sd->didclick = EINA_TRUE; | 3329 | sd->didclick = EINA_TRUE; |
@@ -3343,9 +3333,9 @@ _smart_cb_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUS | |||
3343 | if (!sd->pty->selection.is_active && sd->didclick) | 3333 | if (!sd->pty->selection.is_active && sd->didclick) |
3344 | sd->pty->selection.is_active = EINA_TRUE; | 3334 | sd->pty->selection.is_active = EINA_TRUE; |
3345 | if (shift && sd->pty->selection.is_active) | 3335 | if (shift && sd->pty->selection.is_active) |
3346 | _sel_word_to(data, cx, cy - sd->scroll); | 3336 | _sel_word_to(sd, cx, cy - sd->scroll); |
3347 | else | 3337 | else |
3348 | _sel_word(data, cx, cy - sd->scroll); | 3338 | _sel_word(sd, cx, cy - sd->scroll); |
3349 | if (sd->pty->selection.is_active) | 3339 | if (sd->pty->selection.is_active) |
3350 | termio_take_selection(data, ELM_SEL_TYPE_PRIMARY); | 3340 | termio_take_selection(data, ELM_SEL_TYPE_PRIMARY); |
3351 | sd->didclick = EINA_TRUE; | 3341 | sd->didclick = EINA_TRUE; |
@@ -3413,7 +3403,7 @@ _smart_cb_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUS | |||
3413 | { | 3403 | { |
3414 | /* New selection */ | 3404 | /* New selection */ |
3415 | sd->moved = EINA_FALSE; | 3405 | sd->moved = EINA_FALSE; |
3416 | _sel_set(data, EINA_FALSE); | 3406 | _sel_set(sd, EINA_FALSE); |
3417 | sd->pty->selection.is_box = | 3407 | sd->pty->selection.is_box = |
3418 | (ctrl || | 3408 | (ctrl || |
3419 | evas_key_modifier_is_set(ev->modifiers, "Alt")); | 3409 | evas_key_modifier_is_set(ev->modifiers, "Alt")); |
@@ -3475,7 +3465,7 @@ _smart_cb_mouse_up(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED | |||
3475 | (sd->pty->selection.start.y == sd->pty->selection.end.y)) || | 3465 | (sd->pty->selection.start.y == sd->pty->selection.end.y)) || |
3476 | (!sd->moved)) | 3466 | (!sd->moved)) |
3477 | { | 3467 | { |
3478 | _sel_set(data, EINA_FALSE); | 3468 | _sel_set(sd, EINA_FALSE); |
3479 | sd->didclick = EINA_FALSE; | 3469 | sd->didclick = EINA_FALSE; |
3480 | _smart_update_queue(data, sd); | 3470 | _smart_update_queue(data, sd); |
3481 | return; | 3471 | return; |
@@ -3593,7 +3583,7 @@ _smart_cb_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUS | |||
3593 | if (sd->link.down.dnd) | 3583 | if (sd->link.down.dnd) |
3594 | { | 3584 | { |
3595 | sd->pty->selection.makesel = EINA_FALSE; | 3585 | sd->pty->selection.makesel = EINA_FALSE; |
3596 | _sel_set(data, EINA_FALSE); | 3586 | _sel_set(sd, EINA_FALSE); |
3597 | _smart_update_queue(data, sd); | 3587 | _smart_update_queue(data, sd); |
3598 | return; | 3588 | return; |
3599 | } | 3589 | } |
@@ -3605,7 +3595,7 @@ _smart_cb_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUS | |||
3605 | { | 3595 | { |
3606 | if ((cx != sd->pty->selection.start.x) || | 3596 | if ((cx != sd->pty->selection.start.x) || |
3607 | ((cy - sd->scroll) != sd->pty->selection.start.y)) | 3597 | ((cy - sd->scroll) != sd->pty->selection.start.y)) |
3608 | _sel_set(data, EINA_TRUE); | 3598 | _sel_set(sd, EINA_TRUE); |
3609 | } | 3599 | } |
3610 | start_x = sd->pty->selection.start.x; | 3600 | start_x = sd->pty->selection.start.x; |
3611 | start_y = sd->pty->selection.start.y; | 3601 | start_y = sd->pty->selection.start.y; |
@@ -4270,7 +4260,7 @@ _smart_size(Evas_Object *obj, int w, int h, Eina_Bool force) | |||
4270 | evas_object_size_hint_request_set(obj, | 4260 | evas_object_size_hint_request_set(obj, |
4271 | sd->font.chw * sd->grid.w, | 4261 | sd->font.chw * sd->grid.w, |
4272 | sd->font.chh * sd->grid.h); | 4262 | sd->font.chh * sd->grid.h); |
4273 | _sel_set(obj, EINA_FALSE); | 4263 | _sel_set(sd, EINA_FALSE); |
4274 | termpty_resize(sd->pty, w, h); | 4264 | termpty_resize(sd->pty, w, h); |
4275 | 4265 | ||
4276 | _smart_calculate(obj); | 4266 | _smart_calculate(obj); |
@@ -4679,7 +4669,7 @@ _smart_pty_cancel_sel(void *data) | |||
4679 | EINA_SAFETY_ON_NULL_RETURN(sd); | 4669 | EINA_SAFETY_ON_NULL_RETURN(sd); |
4680 | if (sd->pty->selection.is_active) | 4670 | if (sd->pty->selection.is_active) |
4681 | { | 4671 | { |
4682 | _sel_set(obj, EINA_FALSE); | 4672 | _sel_set(sd, EINA_FALSE); |
4683 | sd->pty->selection.makesel = EINA_FALSE; | 4673 | sd->pty->selection.makesel = EINA_FALSE; |
4684 | _smart_update_queue(data, sd); | 4674 | _smart_update_queue(data, sd); |
4685 | } | 4675 | } |