Unified · Split
| @@ -19,10 +19,10 @@ module U = struct · 18 unmodified lines | |||
| 19 | let pgscale h = truncate (float h *. conf.pgscale) | 19 | let pgscale h = truncate (float h *. conf.pgscale) |
| 20 | let nogeomcmds = function | s, [] -> emptystr s | _ -> false | 20 | let nogeomcmds = function | s, [] -> emptystr s | _ -> false |
| 21 | let maxy () = !S.maxy - if conf.maxhfit then !S.winh else 0 | 21 | let maxy () = !S.maxy - if conf.maxhfit then !S.winh else 0 |
| 22 | let clamp incr = bound (!S.y + incr) 0 @@ maxy () | ||
| 23 | let scalecolor c = let c = c *. conf.colorscale in (c, c, c) | 22 | let scalecolor c = let c = c *. conf.colorscale in (c, c, c) |
| 24 | let panbound x = bound x (- !S.w) !S.winw | 23 | let panbound x = bound x (- !S.w) !S.winw |
| 25 | let pagevisible layout n = List.exists (fun l -> l.pageno = n) layout | 24 | let pagevisible layout n = List.exists (fun l -> l.pageno = n) layout |
| 25 | let add_to_y_and_clamp inc = bound (!S.y + inc) 0 @@ maxy () | ||
| 26 | end | 26 | end |
| 27 | 27 | ||
| 28 | let debugrect (x0, y0, x1, y1, x2, y2, x3, y3) = | 28 | let debugrect (x0, y0, x1, y1, x2, y2, x3, y3) = |
| @@ -1550,10 +1550,12 @@ let downbirdseye incr (conf, leftx, pageno, hooverpageno, anchor) = · 1521 unmodified lines | |||
| 1550 | | [] -> | 1550 | | [] -> |
| 1551 | let y, h = getpageyh pageno in | 1551 | let y, h = getpageyh pageno in |
| 1552 | let dy = (y - !S.y) - (!S.winh - h - conf.interpagespace) in | 1552 | let dy = (y - !S.y) - (!S.winh - h - conf.interpagespace) in |
| 1553 | gotoxy !S.x (U.clamp dy) | 1553 | gotoxy !S.x (U.add_to_y_and_clamp dy) |
| 1554 | | l :: _ when l.pageno = pageno -> | 1554 | | l :: _ when l.pageno = pageno -> |
| 1555 | if l.pagevh != l.pageh | 1555 | if l.pagevh != l.pageh |
| 1556 | then gotoxy !S.x (U.clamp (l.pageh - l.pagevh + conf.interpagespace)) | 1556 | then |
| 1557 | let inc = l.pageh - l.pagevh + conf.interpagespace in | ||
| 1558 | gotoxy !S.x (U.add_to_y_and_clamp inc) | ||
| 1557 | else Glutils.postRedisplay "downbirdseye" | 1559 | else Glutils.postRedisplay "downbirdseye" |
| 1558 | | _ :: rest -> loop rest | 1560 | | _ :: rest -> loop rest |
| 1559 | in | 1561 | in |
| @@ -3028,7 +3030,7 @@ let nextpage () = · 1468 unmodified lines | |||
| 3028 | | Csingle _ -> | 3030 | | Csingle _ -> |
| 3029 | if conf.presentation && rest == [] && l.pageh > l.pagey + l.pagevh | 3031 | if conf.presentation && rest == [] && l.pageh > l.pagey + l.pagevh |
| 3030 | then | 3032 | then |
| 3031 | let y = U.clamp (U.pgscale !S.winh) in | 3033 | let y = U.add_to_y_and_clamp (U.pgscale !S.winh) in |
| 3032 | gotoxy !S.x y | 3034 | gotoxy !S.x y |
| 3033 | else | 3035 | else |
| 3034 | let pageno = min (l.pageno+1) (!S.pagecount-1) in | 3036 | let pageno = min (l.pageno+1) (!S.pagecount-1) in |
| @@ -3038,7 +3040,7 @@ let nextpage () = · 3 unmodified lines | |||
| 3038 | && (existsinrow l.pageno cl | 3040 | && (existsinrow l.pageno cl |
| 3039 | (fun l -> l.pageh > l.pagey + l.pagevh)) | 3041 | (fun l -> l.pageh > l.pagey + l.pagevh)) |
| 3040 | then | 3042 | then |
| 3041 | let y = U.clamp (U.pgscale !S.winh) in | 3043 | let y = U.add_to_y_and_clamp (U.pgscale !S.winh) in |
| 3042 | gotoxy !S.x y | 3044 | gotoxy !S.x y |
| 3043 | else | 3045 | else |
| 3044 | let pageno = min (l.pageno+c) (!S.pagecount-1) in | 3046 | let pageno = min (l.pageno+c) (!S.pagecount-1) in |
| @@ -3060,14 +3062,14 @@ let prevpage () = · 15 unmodified lines | |||
| 3060 | match conf.columns with | 3062 | match conf.columns with |
| 3061 | | Csingle _ -> | 3063 | | Csingle _ -> |
| 3062 | if conf.presentation && l.pagey != 0 | 3064 | if conf.presentation && l.pagey != 0 |
| 3063 | then gotoxy !S.x (U.clamp (U.pgscale ~-(!S.winh))) | 3065 | then gotoxy !S.x (U.add_to_y_and_clamp (U.pgscale ~-(!S.winh))) |
| 3064 | else | 3066 | else |
| 3065 | let pageno = max 0 (l.pageno-1) in | 3067 | let pageno = max 0 (l.pageno-1) in |
| 3066 | gotoxy !S.x (getpagey pageno) | 3068 | gotoxy !S.x (getpagey pageno) |
| 3067 | | Cmulti ((c, _, coverB) as cl, _) -> | 3069 | | Cmulti ((c, _, coverB) as cl, _) -> |
| 3068 | if conf.presentation && | 3070 | if conf.presentation && |
| 3069 | (existsinrow l.pageno cl (fun l -> l.pagey != 0)) | 3071 | (existsinrow l.pageno cl (fun l -> l.pagey != 0)) |
| 3070 | then gotoxy !S.x (U.clamp (U.pgscale ~-(!S.winh))) | 3072 | then gotoxy !S.x (U.add_to_y_and_clamp (U.pgscale ~-(!S.winh))) |
| 3071 | else | 3073 | else |
| 3072 | let decr = | 3074 | let decr = |
| 3073 | if l.pageno = !S.pagecount - coverB | 3075 | if l.pageno = !S.pagecount - coverB |
| @@ -3403,11 +3405,11 @@ let viewkeyboard key mask = · 329 unmodified lines | |||
| 3403 | | Birdseye beye -> upbirdseye 1 beye | 3405 | | Birdseye beye -> upbirdseye 1 beye |
| 3404 | | Textentry _ | View | LinkNav _ -> | 3406 | | Textentry _ | View | LinkNav _ -> |
| 3405 | if ctrl | 3407 | if ctrl |
| 3406 | then gotoxy !S.x (U.clamp ~-(!S.winh/2)) | 3408 | then gotoxy !S.x (U.add_to_y_and_clamp ~-(!S.winh/2)) |
| 3407 | else ( | 3409 | else ( |
| 3408 | if not (Wsi.withshift mask) && conf.presentation | 3410 | if not (Wsi.withshift mask) && conf.presentation |
| 3409 | then prevpage () | 3411 | then prevpage () |
| 3410 | else gotoxy !S.x (U.clamp (-conf.scrollstep)) | 3412 | else gotoxy !S.x (U.add_to_y_and_clamp (-conf.scrollstep)) |
| 3411 | ) | 3413 | ) |
| 3412 | end | 3414 | end |
| 3413 | | Some n -> setautoscrollspeed n false | 3415 | | Some n -> setautoscrollspeed n false |
| @@ -3419,11 +3421,11 @@ let viewkeyboard key mask = · 5 unmodified lines | |||
| 3419 | | Birdseye beye -> downbirdseye 1 beye | 3421 | | Birdseye beye -> downbirdseye 1 beye |
| 3420 | | Textentry _ | View | LinkNav _ -> | 3422 | | Textentry _ | View | LinkNav _ -> |
| 3421 | if ctrl | 3423 | if ctrl |
| 3422 | then gotoxy !S.x (U.clamp (!S.winh/2)) | 3424 | then gotoxy !S.x (U.add_to_y_and_clamp (!S.winh/2)) |
| 3423 | else ( | 3425 | else ( |
| 3424 | if not (Wsi.withshift mask) && conf.presentation | 3426 | if not (Wsi.withshift mask) && conf.presentation |
| 3425 | then nextpage () | 3427 | then nextpage () |
| 3426 | else gotoxy !S.x (U.clamp (conf.scrollstep)) | 3428 | else gotoxy !S.x (U.add_to_y_and_clamp (conf.scrollstep)) |
| 3427 | ) | 3429 | ) |
| 3428 | end | 3430 | end |
| 3429 | | Some n -> setautoscrollspeed n true | 3431 | | Some n -> setautoscrollspeed n true |
| @@ -3455,7 +3457,7 @@ let viewkeyboard key mask = · 25 unmodified lines | |||
| 3455 | match !S.layout with | 3457 | match !S.layout with |
| 3456 | | [] -> !S.y | 3458 | | [] -> !S.y |
| 3457 | | l :: _ -> !S.y - l.pagey | 3459 | | l :: _ -> !S.y - l.pagey |
| 3458 | else U.clamp (U.pgscale ~- !S.winh) | 3460 | else U.add_to_y_and_clamp (U.pgscale ~- !S.winh) |
| 3459 | in | 3461 | in |
| 3460 | gotoxy !S.x y | 3462 | gotoxy !S.x y |
| 3461 | | Next -> | 3463 | | Next -> |
| @@ -3465,7 +3467,7 @@ let viewkeyboard key mask = · 3 unmodified lines | |||
| 3465 | match List.rev !S.layout with | 3467 | match List.rev !S.layout with |
| 3466 | | [] -> !S.y | 3468 | | [] -> !S.y |
| 3467 | | l :: _ -> getpagey l.pageno | 3469 | | l :: _ -> getpagey l.pageno |
| 3468 | else U.clamp (U.pgscale !S.winh) | 3470 | else U.add_to_y_and_clamp (U.pgscale !S.winh) |
| 3469 | in | 3471 | in |
| 3470 | gotoxy !S.x y | 3472 | gotoxy !S.x y |
| 3471 | | Ascii 'g' | Home -> | 3473 | | Ascii 'g' | Home -> |
| @@ -3473,7 +3475,7 @@ let viewkeyboard key mask = · 1 unmodified line | |||
| 3473 | gotoxy 0 0 | 3475 | gotoxy 0 0 |
| 3474 | | Ascii 'G' | End -> | 3476 | | Ascii 'G' | End -> |
| 3475 | addnav (); | 3477 | addnav (); |
| 3476 | gotoxy 0 (U.clamp !S.maxy) | 3478 | gotoxy 0 (U.add_to_y_and_clamp !S.maxy) |
| 3477 | | Right when Wsi.withalt mask -> | 3479 | | Right when Wsi.withalt mask -> |
| 3478 | (match !S.nav.future with | 3480 | (match !S.nav.future with |
| 3479 | | [] -> () | 3481 | | [] -> () |
| @@ -3664,13 +3666,13 @@ let birdseyekeyboard key mask · 184 unmodified lines | |||
| 3664 | !S.winw | 3666 | !S.winw |
| 3665 | (pgh !S.layout) in | 3667 | (pgh !S.layout) in |
| 3666 | match layout with | 3668 | match layout with |
| 3667 | | [] -> gotoxy !S.x (U.clamp ~- !S.winh) | 3669 | | [] -> gotoxy !S.x (U.add_to_y_and_clamp ~- !S.winh) |
| 3668 | | l :: _ -> | 3670 | | l :: _ -> |
| 3669 | S.mode := Birdseye (oconf, leftx, l.pageno, hooverpageno, anchor); | 3671 | S.mode := Birdseye (oconf, leftx, l.pageno, hooverpageno, anchor); |
| 3670 | gotopage1 l.pageno 0 | 3672 | gotopage1 l.pageno 0 |
| 3671 | ); | 3673 | ); |
| 3672 | 3674 | ||
| 3673 | | [] -> gotoxy !S.x (U.clamp ~- !S.winh) | 3675 | | [] -> gotoxy !S.x (U.add_to_y_and_clamp ~- !S.winh) |
| 3674 | end; | 3676 | end; |
| 3675 | 3677 | ||
| 3676 | | Next -> | 3678 | | Next -> |
| @@ -3690,14 +3692,14 @@ let birdseyekeyboard key mask · 13 unmodified lines | |||
| 3690 | ); | 3692 | ); |
| 3691 | Glutils.postRedisplay "birdseye pagedown"; | 3693 | Glutils.postRedisplay "birdseye pagedown"; |
| 3692 | ) | 3694 | ) |
| 3693 | else gotoxy !S.x (U.clamp (incr + conf.interpagespace*2)); | 3695 | else gotoxy !S.x (U.add_to_y_and_clamp (incr + conf.interpagespace*2)); |
| 3694 | 3696 | ||
| 3695 | | l :: _ -> | 3697 | | l :: _ -> |
| 3696 | S.mode := Birdseye (oconf, leftx, l.pageno, hooverpageno, anchor); | 3698 | S.mode := Birdseye (oconf, leftx, l.pageno, hooverpageno, anchor); |
| 3697 | gotopage1 l.pageno 0; | 3699 | gotopage1 l.pageno 0; |
| 3698 | end | 3700 | end |
| 3699 | 3701 | ||
| 3700 | | [] -> gotoxy !S.x (U.clamp !S.winh) | 3702 | | [] -> gotoxy !S.x (U.add_to_y_and_clamp !S.winh) |
| 3701 | end; | 3703 | end; |
| 3702 | 3704 | ||
| 3703 | | Home -> | 3705 | | Home -> |
| @@ -4054,7 +4056,7 @@ let viewmouse button down x y mask = · 350 unmodified lines | |||
| 4054 | else | 4056 | else |
| 4055 | let incr = if n = 4 then -conf.scrollstep else conf.scrollstep in | 4057 | let incr = if n = 4 then -conf.scrollstep else conf.scrollstep in |
| 4056 | let incr = incr * 2 in | 4058 | let incr = incr * 2 in |
| 4057 | let y = U.clamp incr in | 4059 | let y = U.add_to_y_and_clamp incr in |
| 4058 | gotoxy !S.x y | 4060 | gotoxy !S.x y |
| 4059 | ) | 4061 | ) |
| 4060 | 4062 | ||
| @@ -4251,7 +4253,7 @@ let uioh = object · 190 unmodified lines | |||
| 4251 | and dy = y0 - y in | 4253 | and dy = y0 - y in |
| 4252 | S.mstate := Mpan (x, y); | 4254 | S.mstate := Mpan (x, y); |
| 4253 | let x = if canpan () then U.panbound (!S.x + dx) else !S.x in | 4255 | let x = if canpan () then U.panbound (!S.x + dx) else !S.x in |
| 4254 | let y = U.clamp dy in | 4256 | let y = U.add_to_y_and_clamp dy in |
| 4255 | gotoxy x y | 4257 | gotoxy x y |
| 4256 | 4258 | ||
| 4257 | | Msel (a, _) -> | 4259 | | Msel (a, _) -> |
| @@ -4351,7 +4353,7 @@ let uioh = object · 93 unmodified lines | |||
| 4351 | method alwaysscrolly = false | 4353 | method alwaysscrolly = false |
| 4352 | method scroll dx dy = | 4354 | method scroll dx dy = |
| 4353 | let x = if canpan () then U.panbound (!S.x + dx) else !S.x in | 4355 | let x = if canpan () then U.panbound (!S.x + dx) else !S.x in |
| 4354 | gotoxy x (U.clamp (2 * dy)); | 4356 | gotoxy x (U.add_to_y_and_clamp (2 * dy)); |
| 4355 | !S.uioh | 4357 | !S.uioh |
| 4356 | method zoom z x y = | 4358 | method zoom z x y = |
| 4357 | pivotzoom ~x ~y (conf.zoom *. exp z); | 4359 | pivotzoom ~x ~y (conf.zoom *. exp z); |