summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2015-02-06 22:26:08 +0100
committerBoris Faure <billiob@gmail.com>2015-02-06 22:31:51 +0100
commitcc6b11a6f52c12b19e2542fd55c17fb4af42ba72 (patch)
tree271e171ca74192f22b3a98f9ebea2ac057ac076d /src
parentf0151cecf2b1c1417c9833ad361876f4ea18dc79 (diff)
make selection scroll when at the edge of the terminal. Closes T1944
Diffstat (limited to 'src')
-rw-r--r--src/bin/termio.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/bin/termio.c b/src/bin/termio.c
index d5479a4..9897e49 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -3937,22 +3937,28 @@ _mouse_selection_scroll(void *data)
3937 Termio *sd = evas_object_smart_data_get(obj); 3937 Termio *sd = evas_object_smart_data_get(obj);
3938 Evas_Coord oy, my; 3938 Evas_Coord oy, my;
3939 int cy; 3939 int cy;
3940 float fcy;
3940 3941
3941 if (!sd->pty->selection.makesel) return EINA_FALSE; 3942 if (!sd->pty->selection.makesel) return EINA_FALSE;
3942 3943
3943 evas_pointer_canvas_xy_get(evas_object_evas_get(obj), NULL, &my); 3944 evas_pointer_canvas_xy_get(evas_object_evas_get(obj), NULL, &my);
3944 evas_object_geometry_get(data, NULL, &oy, NULL, NULL); 3945 evas_object_geometry_get(data, NULL, &oy, NULL, NULL);
3945 cy = (my - oy) / sd->font.chh; 3946 fcy = (my - oy) / (float)sd->font.chh;
3946 if (cy < 0) 3947 cy = fcy;
3948 if (fcy < 0.3)
3947 { 3949 {
3950 if (cy == 0)
3951 cy = -1;
3948 sd->scroll -= cy; 3952 sd->scroll -= cy;
3949 if (sd->scroll > sd->pty->backscroll_num) 3953 if (sd->scroll > sd->pty->backscroll_num)
3950 sd->scroll = sd->pty->backscroll_num; 3954 sd->scroll = sd->pty->backscroll_num;
3951 sd->pty->selection.end.y = -sd->scroll; 3955 sd->pty->selection.end.y = -sd->scroll;
3952 _smart_update_queue(data, sd); 3956 _smart_update_queue(data, sd);
3953 } 3957 }
3954 else if (cy >= sd->grid.h) 3958 else if (fcy >= (sd->grid.h - 0.3))
3955 { 3959 {
3960 if (cy <= sd->grid.h)
3961 cy = sd->grid.h + 1;
3956 sd->scroll -= cy - sd->grid.h; 3962 sd->scroll -= cy - sd->grid.h;
3957 if (sd->scroll < 0) sd->scroll = 0; 3963 if (sd->scroll < 0) sd->scroll = 0;
3958 sd->pty->selection.end.y = sd->scroll + sd->grid.h - 1; 3964 sd->pty->selection.end.y = sd->scroll + sd->grid.h - 1;
@@ -3968,6 +3974,7 @@ _smart_cb_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUS
3968 Evas_Event_Mouse_Move *ev = event; 3974 Evas_Event_Mouse_Move *ev = event;
3969 Termio *sd = evas_object_smart_data_get(data); 3975 Termio *sd = evas_object_smart_data_get(data);
3970 int cx, cy; 3976 int cx, cy;
3977 float fcy;
3971 Evas_Coord ox, oy; 3978 Evas_Coord ox, oy;
3972 Eina_Bool scroll = EINA_FALSE; 3979 Eina_Bool scroll = EINA_FALSE;
3973 int shift, ctrl; 3980 int shift, ctrl;
@@ -3979,16 +3986,17 @@ _smart_cb_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUS
3979 3986
3980 evas_object_geometry_get(data, &ox, &oy, NULL, NULL); 3987 evas_object_geometry_get(data, &ox, &oy, NULL, NULL);
3981 cx = (ev->cur.canvas.x - ox) / sd->font.chw; 3988 cx = (ev->cur.canvas.x - ox) / sd->font.chw;
3982 cy = (ev->cur.canvas.y - oy) / sd->font.chh; 3989 fcy = (ev->cur.canvas.y - oy) / (float)sd->font.chh;
3990 cy = fcy;
3983 if (cx < 0) cx = 0; 3991 if (cx < 0) cx = 0;
3984 else if (cx >= sd->grid.w) cx = sd->grid.w - 1; 3992 else if (cx >= sd->grid.w) cx = sd->grid.w - 1;
3985 if (cy < 0) 3993 if (fcy < 0.3)
3986 { 3994 {
3987 cy = 0; 3995 cy = 0;
3988 if (sd->pty->selection.makesel) 3996 if (sd->pty->selection.makesel)
3989 scroll = EINA_TRUE; 3997 scroll = EINA_TRUE;
3990 } 3998 }
3991 else if (cy >= sd->grid.h) 3999 else if (fcy >= (sd->grid.h - 0.3))
3992 { 4000 {
3993 cy = sd->grid.h - 1; 4001 cy = sd->grid.h - 1;
3994 if (sd->pty->selection.makesel) 4002 if (sd->pty->selection.makesel)