History

Rename clamp to add_to_y_and_clamp

malc committed 5 years ago

Commit 9fa0ead1 parent ca34db31 file · +23 −21Browse files

Unified · Split

main.ml+23−21
@@ -19,10 +19,10 @@ module U = struct · 18 unmodified lines
1919 let pgscale h = truncate (float h *. conf.pgscale)
2020 let nogeomcmds = function | s, [] -> emptystr s | _ -> false
2121 let maxy () = !S.maxy - if conf.maxhfit then !S.winh else 0
22− let clamp incr = bound (!S.y + incr) 0 @@ maxy ()
2322 let scalecolor c = let c = c *. conf.colorscale in (c, c, c)
2423 let panbound x = bound x (- !S.w) !S.winw
2524 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 ()
2626 end
2727
2828 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
15501550 | [] ->
15511551 let y, h = getpageyh pageno in
15521552 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)
15541554 | l :: _ when l.pageno = pageno ->
15551555 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)
15571559 else Glutils.postRedisplay "downbirdseye"
15581560 | _ :: rest -> loop rest
15591561 in
@@ -3028,7 +3030,7 @@ let nextpage () = · 1468 unmodified lines
30283030 | Csingle _ ->
30293031 if conf.presentation && rest == [] && l.pageh > l.pagey + l.pagevh
30303032 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
30323034 gotoxy !S.x y
30333035 else
30343036 let pageno = min (l.pageno+1) (!S.pagecount-1) in
@@ -3038,7 +3040,7 @@ let nextpage () = · 3 unmodified lines
30383040 && (existsinrow l.pageno cl
30393041 (fun l -> l.pageh > l.pagey + l.pagevh))
30403042 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
30423044 gotoxy !S.x y
30433045 else
30443046 let pageno = min (l.pageno+c) (!S.pagecount-1) in
@@ -3060,14 +3062,14 @@ let prevpage () = · 15 unmodified lines
30603062 match conf.columns with
30613063 | Csingle _ ->
30623064 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)))
30643066 else
30653067 let pageno = max 0 (l.pageno-1) in
30663068 gotoxy !S.x (getpagey pageno)
30673069 | Cmulti ((c, _, coverB) as cl, _) ->
30683070 if conf.presentation &&
30693071 (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)))
30713073 else
30723074 let decr =
30733075 if l.pageno = !S.pagecount - coverB
@@ -3403,11 +3405,11 @@ let viewkeyboard key mask = · 329 unmodified lines
34033405 | Birdseye beye -> upbirdseye 1 beye
34043406 | Textentry _ | View | LinkNav _ ->
34053407 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))
34073409 else (
34083410 if not (Wsi.withshift mask) && conf.presentation
34093411 then prevpage ()
3410− else gotoxy !S.x (U.clamp (-conf.scrollstep))
3412+ else gotoxy !S.x (U.add_to_y_and_clamp (-conf.scrollstep))
34113413 )
34123414 end
34133415 | Some n -> setautoscrollspeed n false
@@ -3419,11 +3421,11 @@ let viewkeyboard key mask = · 5 unmodified lines
34193421 | Birdseye beye -> downbirdseye 1 beye
34203422 | Textentry _ | View | LinkNav _ ->
34213423 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))
34233425 else (
34243426 if not (Wsi.withshift mask) && conf.presentation
34253427 then nextpage ()
3426− else gotoxy !S.x (U.clamp (conf.scrollstep))
3428+ else gotoxy !S.x (U.add_to_y_and_clamp (conf.scrollstep))
34273429 )
34283430 end
34293431 | Some n -> setautoscrollspeed n true
@@ -3455,7 +3457,7 @@ let viewkeyboard key mask = · 25 unmodified lines
34553457 match !S.layout with
34563458 | [] -> !S.y
34573459 | 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)
34593461 in
34603462 gotoxy !S.x y
34613463 | Next ->
@@ -3465,7 +3467,7 @@ let viewkeyboard key mask = · 3 unmodified lines
34653467 match List.rev !S.layout with
34663468 | [] -> !S.y
34673469 | l :: _ -> getpagey l.pageno
3468− else U.clamp (U.pgscale !S.winh)
3470+ else U.add_to_y_and_clamp (U.pgscale !S.winh)
34693471 in
34703472 gotoxy !S.x y
34713473 | Ascii 'g' | Home ->
@@ -3473,7 +3475,7 @@ let viewkeyboard key mask = · 1 unmodified line
34733475 gotoxy 0 0
34743476 | Ascii 'G' | End ->
34753477 addnav ();
3476− gotoxy 0 (U.clamp !S.maxy)
3478+ gotoxy 0 (U.add_to_y_and_clamp !S.maxy)
34773479 | Right when Wsi.withalt mask ->
34783480 (match !S.nav.future with
34793481 | [] -> ()
@@ -3664,13 +3666,13 @@ let birdseyekeyboard key mask · 184 unmodified lines
36643666 !S.winw
36653667 (pgh !S.layout) in
36663668 match layout with
3667− | [] -> gotoxy !S.x (U.clamp ~- !S.winh)
3669+ | [] -> gotoxy !S.x (U.add_to_y_and_clamp ~- !S.winh)
36683670 | l :: _ ->
36693671 S.mode := Birdseye (oconf, leftx, l.pageno, hooverpageno, anchor);
36703672 gotopage1 l.pageno 0
36713673 );
36723674
3673− | [] -> gotoxy !S.x (U.clamp ~- !S.winh)
3675+ | [] -> gotoxy !S.x (U.add_to_y_and_clamp ~- !S.winh)
36743676 end;
36753677
36763678 | Next ->
@@ -3690,14 +3692,14 @@ let birdseyekeyboard key mask · 13 unmodified lines
36903692 );
36913693 Glutils.postRedisplay "birdseye pagedown";
36923694 )
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));
36943696
36953697 | l :: _ ->
36963698 S.mode := Birdseye (oconf, leftx, l.pageno, hooverpageno, anchor);
36973699 gotopage1 l.pageno 0;
36983700 end
36993701
3700− | [] -> gotoxy !S.x (U.clamp !S.winh)
3702+ | [] -> gotoxy !S.x (U.add_to_y_and_clamp !S.winh)
37013703 end;
37023704
37033705 | Home ->
@@ -4054,7 +4056,7 @@ let viewmouse button down x y mask = · 350 unmodified lines
40544056 else
40554057 let incr = if n = 4 then -conf.scrollstep else conf.scrollstep in
40564058 let incr = incr * 2 in
4057− let y = U.clamp incr in
4059+ let y = U.add_to_y_and_clamp incr in
40584060 gotoxy !S.x y
40594061 )
40604062
@@ -4251,7 +4253,7 @@ let uioh = object · 190 unmodified lines
42514253 and dy = y0 - y in
42524254 S.mstate := Mpan (x, y);
42534255 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
42554257 gotoxy x y
42564258
42574259 | Msel (a, _) ->
@@ -4351,7 +4353,7 @@ let uioh = object · 93 unmodified lines
43514353 method alwaysscrolly = false
43524354 method scroll dx dy =
43534355 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));
43554357 !S.uioh
43564358 method zoom z x y =
43574359 pivotzoom ~x ~y (conf.zoom *. exp z);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t