From 886dd6c0cf25ee9affb41c4c6393e685b9560f08 Mon Sep 17 00:00:00 2001 From: malc Date: Mon, 13 Feb 2017 11:25:53 +0300 Subject: [PATCH] Slide-show mode When in slide-show mode is activated auto scrolling changes it's behaviour. Absolute value of auto-scroll-step becomes a transition timeout in seconds, negative values make the slide show go backwards. --- config.ml | 2 ++ main.ml | 37 +++++++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/config.ml b/config.ml index f1466c1..2780fe1 100644 --- a/config.ml +++ b/config.ml @@ -441,6 +441,7 @@ type state = ; mutable traw : [`float] Raw.t ; mutable vraw : [`float] Raw.t ; mutable lnava : (pageno * linkno) option + ; mutable slideshow : int } and hists = { pat : string circbuf @@ -718,6 +719,7 @@ let state = ; traw = Raw.create_static `float ~len:8 ; vraw = Raw.create_static `float ~len:8 ; lnava = None + ; slideshow = 0 } ;; diff --git a/main.ml b/main.ml index 53faee4..0f5fdef 100644 --- a/main.ml +++ b/main.ml @@ -4680,6 +4680,8 @@ let viewkeyboard key mask = let ctrl = Wsi.withctrl mask in let open Keys in match Wsi.kc2kt key with + | Ascii 'S' -> state.slideshow <- state.slideshow lxor 1 + | Ascii 'Q' -> exit 0 | Ascii 'W' -> @@ -4897,9 +4899,8 @@ let viewkeyboard key mask = conf.autoscrollstep <- step; state.autoscroll <- None | None -> - if conf.autoscrollstep = 0 - then state.autoscroll <- Some 1 - else state.autoscroll <- Some conf.autoscrollstep + state.autoscroll <- Some conf.autoscrollstep; + state.slideshow <- state.slideshow land lnot 2 end | Ascii 'p' when ctrl -> @@ -6536,17 +6537,25 @@ let () = then match state.autoscroll with | Some step when step != 0 -> - let y = state.y + step in - let fy = if conf.maxhfit then state.winh else 0 in - let y = - if y < 0 - then state.maxy - fy - else if y >= state.maxy - fy then 0 else y - in - if state.mode = View - then gotoxy_and_clear_text state.x y - else gotoxy state.x y; - deadline +. 0.01 + if state.slideshow land 1 = 1 + then ( + if state.slideshow land 2 = 0 + then state.slideshow <- state.slideshow lor 2 + else if step < 0 then prevpage () else nextpage (); + deadline +. (float (abs step)) + ) + else + let y = state.y + step in + let fy = if conf.maxhfit then state.winh else 0 in + let y = + if y < 0 + then state.maxy - fy + else if y >= state.maxy - fy then 0 else y + in + if state.mode = View + then gotoxy_and_clear_text state.x y + else gotoxy state.x y; + deadline +. 0.01 | _ -> infinity else deadline +. 0.01 in -- 2.11.4.GIT