Compare commits
11 Commits
93c0819900
...
6a7555880f
Author | SHA1 | Date |
---|---|---|
hazen2215 | 6a7555880f | |
hazen2215 | 1ab61fdbbf | |
hazen2215 | 93f8f128ab | |
hazen2215 | 01d220f93e | |
hazen2215 | 83040aff5a | |
hazen2215 | 684cdf009b | |
hazen2215 | 1d67679656 | |
hazen2215 | 2827a6c741 | |
hazen2215 | 0ebac1c15f | |
hazen2215 | 4ee4b40525 | |
txtsd | a6335c0e9f |
|
@ -37,7 +37,11 @@ mudeps=('freetype2' 'gumbo' 'harfbuzz' 'libjpeg' 'libopenjp2' 'x11' 'zlib')
|
||||||
|
|
||||||
mkdir -p $outd/{$wsid,lablGL}
|
mkdir -p $outd/{$wsid,lablGL}
|
||||||
|
|
||||||
isfresh() { test "$(<$1.past)" = "$2"; } 2>/dev/null
|
isfresh() {
|
||||||
|
test -f "$1.past" || return 1
|
||||||
|
test "$(<$1.past)" = "$2"
|
||||||
|
} 2>/dev/null
|
||||||
|
|
||||||
|
|
||||||
mbt=${mbt:-release}
|
mbt=${mbt:-release}
|
||||||
test -n "${gmk:-}" && gmk=false || gmk=true
|
test -n "${gmk:-}" && gmk=false || gmk=true
|
||||||
|
|
101
main.ml
101
main.ml
|
@ -77,6 +77,20 @@ let launchpath () =
|
||||||
adderrfmt "spawn" "failed to execute `%s': %s" cmd @@ exntos exn
|
adderrfmt "spawn" "failed to execute `%s': %s" cmd @@ exntos exn
|
||||||
| _pid -> ()
|
| _pid -> ()
|
||||||
|
|
||||||
|
let launchmenu () =
|
||||||
|
let n =
|
||||||
|
match !S.layout with
|
||||||
|
| l :: _ -> string_of_int l.pageno
|
||||||
|
| _ -> E.s
|
||||||
|
in
|
||||||
|
let cmd = Str.global_replace Re.percents !S.path "llpp-menu '%s' '%p'" in
|
||||||
|
let cmd =
|
||||||
|
if nonemptystr n
|
||||||
|
then Str.global_replace Re.percentp n cmd
|
||||||
|
else cmd
|
||||||
|
in
|
||||||
|
getcmdoutput (adderrfmt cmd "failed to obrain query: %s") cmd
|
||||||
|
|
||||||
let getopaque pageno = Hashtbl.find S.pagemap (pageno, !S.gen)
|
let getopaque pageno = Hashtbl.find S.pagemap (pageno, !S.gen)
|
||||||
|
|
||||||
let pagetranslatepoint l x y =
|
let pagetranslatepoint l x y =
|
||||||
|
@ -552,6 +566,11 @@ let gotoxy x y =
|
||||||
S.x := x;
|
S.x := x;
|
||||||
S.y := y;
|
S.y := y;
|
||||||
S.layout := layout;
|
S.layout := layout;
|
||||||
|
match !S.layout with
|
||||||
|
| [] -> ()
|
||||||
|
| l :: _ ->
|
||||||
|
Wsi.settitle @@ Filename.basename !S.path ^ " - "
|
||||||
|
^ string_of_int (l.pageno+1) ^ "/" ^ string_of_int !S.pagecount;
|
||||||
begin match !S.mode with
|
begin match !S.mode with
|
||||||
| LinkNav ln ->
|
| LinkNav ln ->
|
||||||
begin match ln with
|
begin match ln with
|
||||||
|
@ -1008,6 +1027,12 @@ let getpassword () =
|
||||||
then (adderrmsg "askpass" "ask password program not set"; E.s)
|
then (adderrmsg "askpass" "ask password program not set"; E.s)
|
||||||
else getcmdoutput (adderrfmt passcmd "failed to obrain password: %s") passcmd
|
else getcmdoutput (adderrfmt passcmd "failed to obrain password: %s") passcmd
|
||||||
|
|
||||||
|
let getsearchquery () =
|
||||||
|
let searchcmd = getenvdef "LLPP_SEARCH" "llpp-search" in
|
||||||
|
if emptystr searchcmd
|
||||||
|
then (adderrmsg "search" "search program not set"; E.s)
|
||||||
|
else getcmdoutput (adderrfmt searchcmd "failed to obrain query: %s") searchcmd
|
||||||
|
|
||||||
let pgoto opaque pageno x y =
|
let pgoto opaque pageno x y =
|
||||||
let pdimno = getpdimno pageno in
|
let pdimno = getpdimno pageno in
|
||||||
let x, y = Ffi.project opaque pageno pdimno x y in
|
let x, y = Ffi.project opaque pageno pdimno x y in
|
||||||
|
@ -1096,10 +1121,7 @@ let act cmds =
|
||||||
if n = 0
|
if n = 0
|
||||||
then (
|
then (
|
||||||
let y = (getpagey pageno) + truncate y0 in
|
let y = (getpagey pageno) + truncate y0 in
|
||||||
let x =
|
let x = !S.x
|
||||||
if (!S.x < - truncate x0) || (!S.x > !S.winw - truncate x1)
|
|
||||||
then !S.winw/2 - truncate (x0 /. 2. +. x1 /. 2.)
|
|
||||||
else !S.x
|
|
||||||
in
|
in
|
||||||
addnav ();
|
addnav ();
|
||||||
gotoxy x y;
|
gotoxy x y;
|
||||||
|
@ -2770,11 +2792,11 @@ let gotoremote spec =
|
||||||
S.ranchors := ranchor :: !S.ranchors;
|
S.ranchors := ranchor :: !S.ranchors;
|
||||||
opendoc path E.s E.s;
|
opendoc path E.s E.s;
|
||||||
in
|
in
|
||||||
if substratis spec 0 "page="
|
if substratis dest 0 "page="
|
||||||
then
|
then
|
||||||
match Scanf.sscanf spec "page=%d" (fun n -> n) with
|
match Scanf.sscanf dest "page=%d" (fun n -> n) with
|
||||||
| exception exn ->
|
| exception exn ->
|
||||||
adderrfmt "error parsing remote destination" "%s %s" spec @@ exntos exn
|
adderrfmt "error parsing remote destination" "%s %s" dest @@ exntos exn
|
||||||
| pageno ->
|
| pageno ->
|
||||||
S.anchor := (pageno, 0.0, 0.0);
|
S.anchor := (pageno, 0.0, 0.0);
|
||||||
dospawn @@ lazy (Printf.sprintf "%s -page %d %S"
|
dospawn @@ lazy (Printf.sprintf "%s -page %d %S"
|
||||||
|
@ -3033,7 +3055,7 @@ let setautoscrollspeed step goingdown =
|
||||||
let canpan () =
|
let canpan () =
|
||||||
match conf.columns with
|
match conf.columns with
|
||||||
| Csplit _ -> true
|
| Csplit _ -> true
|
||||||
| Csingle _ | Cmulti _ -> !S.x != 0 || conf.zoom > 1.0
|
| Csingle _ | Cmulti _ -> !S.x != 0 || conf.zoom > 0.0
|
||||||
|
|
||||||
let existsinrow pageno (columns, coverA, coverB) p =
|
let existsinrow pageno (columns, coverA, coverB) p =
|
||||||
let last = ((pageno - coverA) mod columns) + columns in
|
let last = ((pageno - coverA) mod columns) + columns in
|
||||||
|
@ -3237,7 +3259,7 @@ let viewkeyboard key mask =
|
||||||
S.text := E.s;
|
S.text := E.s;
|
||||||
Hashtbl.iter (fun _ opaque -> Ffi.clearmark opaque) S.pagemap;
|
Hashtbl.iter (fun _ opaque -> Ffi.clearmark opaque) S.pagemap;
|
||||||
Glutils.postRedisplay "dehighlight";
|
Glutils.postRedisplay "dehighlight";
|
||||||
| Ascii (('/' | '?') as c) ->
|
| Ascii (('?') as c) ->
|
||||||
let ondone isforw s =
|
let ondone isforw s =
|
||||||
cbput !S.hists.pat s;
|
cbput !S.hists.pat s;
|
||||||
S.searchpattern := s;
|
S.searchpattern := s;
|
||||||
|
@ -3245,6 +3267,14 @@ let viewkeyboard key mask =
|
||||||
in
|
in
|
||||||
enttext (String.make 1 c, E.s, Some (onhist !S.hists.pat),
|
enttext (String.make 1 c, E.s, Some (onhist !S.hists.pat),
|
||||||
textentry, ondone (c = '/'), true)
|
textentry, ondone (c = '/'), true)
|
||||||
|
| Ascii '/' ->
|
||||||
|
let query = getsearchquery() in
|
||||||
|
if nonemptystr query
|
||||||
|
then (
|
||||||
|
cbput !S.hists.pat query;
|
||||||
|
S.searchpattern := query;
|
||||||
|
search query true
|
||||||
|
)
|
||||||
| Ascii '+' | Ascii '=' when ctrl ->
|
| Ascii '+' | Ascii '=' when ctrl ->
|
||||||
let incr = if conf.zoom +. 0.01 > 0.1 then 0.1 else 0.01 in
|
let incr = if conf.zoom +. 0.01 > 0.1 then 0.1 else 0.01 in
|
||||||
pivotzoom (conf.zoom +. incr)
|
pivotzoom (conf.zoom +. incr)
|
||||||
|
@ -3297,6 +3327,13 @@ let viewkeyboard key mask =
|
||||||
| Ascii '4' when ctrl ->
|
| Ascii '4' when ctrl ->
|
||||||
let zoom = Ffi.getmaxw () /. float !S.winw in
|
let zoom = Ffi.getmaxw () /. float !S.winw in
|
||||||
if zoom > 0.0 then setzoom zoom
|
if zoom > 0.0 then setzoom zoom
|
||||||
|
| Ascii ('5'|'6' as c) when ctrl ->
|
||||||
|
let fm = (if c = '5' then FitPage else FitWidth) in
|
||||||
|
S.text := "fit model: " ^ FMTE.to_string fm;
|
||||||
|
reqlayout conf.angle fm
|
||||||
|
| Ascii '7' when ctrl ->
|
||||||
|
let zoom = Ffi.getmaxw () /. 1900. *. 6. in
|
||||||
|
if zoom > 0.0 then setzoom zoom
|
||||||
| Fn 9 -> togglebirdseye ()
|
| Fn 9 -> togglebirdseye ()
|
||||||
| Ascii '9' when ctrl -> togglebirdseye ()
|
| Ascii '9' when ctrl -> togglebirdseye ()
|
||||||
| Ascii ('0'..'9' as c) when not ctrl ->
|
| Ascii ('0'..'9' as c) when not ctrl ->
|
||||||
|
@ -3358,6 +3395,34 @@ let viewkeyboard key mask =
|
||||||
| None -> S.autoscroll := Some conf.autoscrollstep
|
| None -> S.autoscroll := Some conf.autoscrollstep
|
||||||
end
|
end
|
||||||
| Ascii 'p' when ctrl -> launchpath ()
|
| Ascii 'p' when ctrl -> launchpath ()
|
||||||
|
| Ascii 'm' when ctrl ->
|
||||||
|
let cmds = launchmenu () in
|
||||||
|
let cl = splitatchar cmds ' ' in
|
||||||
|
let scan s fmt f =
|
||||||
|
try Scanf.sscanf s fmt f
|
||||||
|
with exn -> adderrfmt "remote exec" "error processing '%S': %s\n"
|
||||||
|
cmds @@ exntos exn
|
||||||
|
in
|
||||||
|
(
|
||||||
|
match cl with
|
||||||
|
| "goto", args ->
|
||||||
|
scan args "%u %f %f"
|
||||||
|
(fun pageno x y ->
|
||||||
|
let cmd, _ = !S.geomcmds in
|
||||||
|
if emptystr cmd
|
||||||
|
then gotopagexy pageno x y
|
||||||
|
else
|
||||||
|
let f prevf () =
|
||||||
|
gotopagexy pageno x y;
|
||||||
|
prevf ()
|
||||||
|
in
|
||||||
|
S.reprf := f !S.reprf
|
||||||
|
)
|
||||||
|
| "gotor", args -> scan args "%S" gotoremote
|
||||||
|
| _ ->
|
||||||
|
adderrfmt "remote command"
|
||||||
|
"error processing remote command: %S\n" cmds
|
||||||
|
)
|
||||||
| Ascii 'P' ->
|
| Ascii 'P' ->
|
||||||
setpresentationmode (not conf.presentation);
|
setpresentationmode (not conf.presentation);
|
||||||
showtext ' ' ("presentation mode " ^ onoffs conf.presentation)
|
showtext ' ' ("presentation mode " ^ onoffs conf.presentation)
|
||||||
|
@ -3374,7 +3439,19 @@ let viewkeyboard key mask =
|
||||||
end
|
end
|
||||||
| Ascii ' ' -> nextpage ()
|
| Ascii ' ' -> nextpage ()
|
||||||
| Delete -> prevpage ()
|
| Delete -> prevpage ()
|
||||||
| Ascii '=' -> showtext ' ' (describe_layout !S.layout);
|
| Ascii '=' ->
|
||||||
|
if conf.zoom = 1.0
|
||||||
|
then gotoxy 0 !S.y
|
||||||
|
else setzoom 1.0;
|
||||||
|
reqlayout conf.angle FitPage
|
||||||
|
| Ascii 'Z' ->
|
||||||
|
if Wsi.withshift mask
|
||||||
|
then (
|
||||||
|
setzoom 1.6;
|
||||||
|
reqlayout conf.angle FitPage;
|
||||||
|
let m = (!S.winw - !S.w) / 2 in
|
||||||
|
gotoxy m !S.y
|
||||||
|
)
|
||||||
| Ascii 'w' ->
|
| Ascii 'w' ->
|
||||||
begin match !S.layout with
|
begin match !S.layout with
|
||||||
| [] -> ()
|
| [] -> ()
|
||||||
|
@ -3405,7 +3482,7 @@ let viewkeyboard key mask =
|
||||||
| Ascii 'c' when !S.mode = View ->
|
| Ascii 'c' when !S.mode = View ->
|
||||||
if Wsi.withalt mask
|
if Wsi.withalt mask
|
||||||
then (
|
then (
|
||||||
if conf.zoom > 1.0
|
if conf.zoom > 0.0
|
||||||
then
|
then
|
||||||
let m = (!S.winw - !S.w) / 2 in
|
let m = (!S.winw - !S.w) / 2 in
|
||||||
gotoxy m !S.y
|
gotoxy m !S.y
|
||||||
|
@ -4586,7 +4663,7 @@ let () =
|
||||||
if !S.confpath == E.s
|
if !S.confpath == E.s
|
||||||
then (
|
then (
|
||||||
let dir =
|
let dir =
|
||||||
let dir = Filename.concat home ".config" in
|
let dir = Filename.concat home ".local/share" in
|
||||||
if try Sys.is_directory dir with _ -> false then dir else home
|
if try Sys.is_directory dir with _ -> false then dir else home
|
||||||
in
|
in
|
||||||
S.confpath := Filename.concat dir "llpp.conf"
|
S.confpath := Filename.concat dir "llpp.conf"
|
||||||
|
|
|
@ -6,7 +6,7 @@ die() {
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
cachedir="$HOME/.cache/llpp"
|
cachedir="${XDG_CACHE_HOME:-$HOME/.cache}/llpp"
|
||||||
test -d "$cachedir" || die "cache directory '$cachedir' does not exist"
|
test -d "$cachedir" || die "cache directory '$cachedir' does not exist"
|
||||||
|
|
||||||
caspsuf=
|
caspsuf=
|
||||||
|
|
11
uiutils.ml
11
uiutils.ml
|
@ -97,17 +97,6 @@ let enttext () =
|
||||||
|
|
||||||
| Birdseye _ | View | LinkNav _ -> !S.text
|
| Birdseye _ | View | LinkNav _ -> !S.text
|
||||||
in
|
in
|
||||||
let s =
|
|
||||||
if !S.newerrmsgs
|
|
||||||
then (
|
|
||||||
if not (istextentry !S.mode) && !S.uioh#eformsgs
|
|
||||||
then
|
|
||||||
let s1 = "(press 'e' to review error messages)" in
|
|
||||||
if nonemptystr s then s ^ " " ^ s1 else s1
|
|
||||||
else s
|
|
||||||
)
|
|
||||||
else s
|
|
||||||
in
|
|
||||||
if nonemptystr s
|
if nonemptystr s
|
||||||
then drawstring s
|
then drawstring s
|
||||||
|
|
||||||
|
|
|
@ -1101,7 +1101,11 @@ let init t w h =
|
||||||
w16 s 8 (String.length adata);
|
w16 s 8 (String.length adata);
|
||||||
sendstr1 s 0 (Bytes.length s) fd;
|
sendstr1 s 0 (Bytes.length s) fd;
|
||||||
S.sock := fd;
|
S.sock := fd;
|
||||||
setup d fd 0 screennum w h;
|
let rootwid =
|
||||||
|
try int_of_string(Sys.getenv "LLPP_WID")
|
||||||
|
with Not_found -> 0
|
||||||
|
in
|
||||||
|
setup d fd rootwid screennum w h;
|
||||||
S.t := t;
|
S.t := t;
|
||||||
fd, !S.w, !S.h
|
fd, !S.w, !S.h
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue