package b0
Software construction and deployment kit
Install
dune-project
Dependency
Authors
Maintainers
Sources
b0-0.0.6.tbz
sha512=e9aa779e66c08fc763019f16d4706f465d16c05d6400b58fbd0313317ef33ddea51952e2b058db28e65f7ddb7012f328c8bf02d8f1da17bb543348541a2587f0
doc/src/b0.std/b0_pdf_viewer.ml.html
Source file b0_pdf_viewer.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
(*--------------------------------------------------------------------------- Copyright (c) 2018 The b0 programmers. All rights reserved. SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) open B0_std open Result.Syntax (* Show PDFs *) (* XXX support background reloads *) module Env = struct let pdfviewer = "PDFVIEWER" end type t = Cmd.t let env_fallback cmd = match cmd with | Some _ as v -> Ok v | None -> Os.Env.var' ~empty_is_none:true Cmd.of_string Env.pdfviewer let find ?search ?cmd () = let* cmd = env_fallback cmd in match cmd with | Some cmd -> Os.Cmd.get ?search cmd | None -> let cmds = [Cmd.tool "xdg-open"; Cmd.tool "open"] in match Os.Cmd.find_first ?search cmds with | Some v -> Ok v | None -> if Sys.win32 then Ok Cmd.(arg "start" % "") (* XXX really ? *) else Fmt.error "No PDF viewer found. Set the %a environment variable." Fmt.code Env.pdfviewer let show pdf_viewer file = Os.Cmd.run Cmd.(pdf_viewer %% path file) (* Cli interface *) let pdf_viewer ?docs ?(opts = ["pdf-viewer"]) () = let open Cmdliner in let env = Cmd.Env.info Env.pdfviewer in let doc = "The PDF viewer command $(docv) to use. If absent either one \ of $(b,xdg-open(1)) or $(b,open(1)) is used. If not found and \ on Windows $(b,start) is used." in let absent = "OS dependent fallback" in let cmd = Arg.conv' ~docv:"CMD" (B0_std.Cmd.of_string, B0_std.Cmd.pp_dump) in Arg.(value & opt (Arg.some cmd) None & info opts ~env ~absent ~doc ?docs ~docv:"CMD")
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>