From 66a23e616670fe19e966c833ac4c0db5edf57c7c Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 18 Jun 2018 16:55:30 +0200 Subject: Use fz_quad type in structured text and selection/highlighting. --- source/tools/murun.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'source/tools/murun.c') diff --git a/source/tools/murun.c b/source/tools/murun.c index c74e4bbc..f7a890b2 100644 --- a/source/tools/murun.c +++ b/source/tools/murun.c @@ -489,6 +489,19 @@ static void ffi_pushrect(js_State *J, fz_rect rect) js_pushnumber(J, rect.y1); js_setindex(J, -2, 3); } +static void ffi_pushquad(js_State *J, fz_quad quad) +{ + js_newarray(J); + js_pushnumber(J, quad.ul.x); js_setindex(J, -2, 0); + js_pushnumber(J, quad.ul.y); js_setindex(J, -2, 1); + js_pushnumber(J, quad.ur.x); js_setindex(J, -2, 0); + js_pushnumber(J, quad.ur.y); js_setindex(J, -2, 1); + js_pushnumber(J, quad.ll.x); js_setindex(J, -2, 0); + js_pushnumber(J, quad.ll.y); js_setindex(J, -2, 1); + js_pushnumber(J, quad.lr.x); js_setindex(J, -2, 0); + js_pushnumber(J, quad.lr.y); js_setindex(J, -2, 1); +} + static fz_irect ffi_toirect(js_State *J, int idx) { fz_irect irect; @@ -1922,7 +1935,7 @@ static void ffi_Page_search(js_State *J) fz_context *ctx = js_getcontext(J); fz_page *page = ffi_topage(J, 0); const char *needle = js_tostring(J, 1); - fz_rect hits[256]; + fz_quad hits[256]; int i, n = 0; fz_try(ctx) @@ -1932,7 +1945,7 @@ static void ffi_Page_search(js_State *J) js_newarray(J); for (i = 0; i < n; ++i) { - ffi_pushrect(J, hits[i]); + ffi_pushquad(J, hits[i]); js_setindex(J, -2, i); } } @@ -2777,7 +2790,7 @@ static void ffi_DisplayList_search(js_State *J) fz_context *ctx = js_getcontext(J); fz_display_list *list = js_touserdata(J, 0, "fz_display_list"); const char *needle = js_tostring(J, 1); - fz_rect hits[256]; + fz_quad hits[256]; int i, n = 0; fz_try(ctx) @@ -2787,7 +2800,7 @@ static void ffi_DisplayList_search(js_State *J) js_newarray(J); for (i = 0; i < n; ++i) { - ffi_pushrect(J, hits[i]); + ffi_pushquad(J, hits[i]); js_setindex(J, -2, i); } } @@ -2797,7 +2810,7 @@ static void ffi_StructuredText_search(js_State *J) fz_context *ctx = js_getcontext(J); fz_stext_page *text = js_touserdata(J, 0, "fz_stext_page"); const char *needle = js_tostring(J, 1); - fz_rect hits[256]; + fz_quad hits[256]; int i, n = 0; fz_try(ctx) @@ -2807,7 +2820,7 @@ static void ffi_StructuredText_search(js_State *J) js_newarray(J); for (i = 0; i < n; ++i) { - ffi_pushrect(J, hits[i]); + ffi_pushquad(J, hits[i]); js_setindex(J, -2, i); } } @@ -2818,7 +2831,7 @@ static void ffi_StructuredText_highlight(js_State *J) fz_stext_page *text = js_touserdata(J, 0, "fz_stext_page"); fz_point a = ffi_topoint(J, 1); fz_point b = ffi_topoint(J, 2); - fz_rect hits[256]; + fz_quad hits[256]; int i, n = 0; fz_try(ctx) @@ -2828,7 +2841,7 @@ static void ffi_StructuredText_highlight(js_State *J) js_newarray(J); for (i = 0; i < n; ++i) { - ffi_pushrect(J, hits[i]); + ffi_pushquad(J, hits[i]); js_setindex(J, -2, i); } } -- cgit v1.2.3