package oxbow

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file with.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
open! Oxbow_core

let log_of_out = function
  | Some `Debug -> Log.debug
  | Some `Error -> Log.err
  | Some `Warn -> Log.warn
  | Some `Info -> Log.info
  | None -> Log.debug
;;

let logged ?out r = r |> Result.iter_error @@ fun e -> log_of_out out @@ fun m -> m "%s" e

let focused_output (seat : Types.Seat.t) f =
  match seat.output with
  | None -> Error Messages.seat_missing_output
  | Some o -> f o
;;

let named_output ~name (wm : Types.Wm.t) f =
  match Output.resolve_output_name name wm.outputs with
  | Some o -> f o
  | None -> Error (Printf.sprintf "no output named %s" name)
;;

let named_output_log ?out ~name (wm : Types.Wm.t) f =
  logged ?out
  @@ named_output ~name wm
  @@ fun o ->
  f o;
  Ok None
;;

let focused_output_log ?out seat f =
  logged ?out
  @@ focused_output seat
  @@ fun o ->
  f o;
  Ok None
;;

let focused_window seat f =
  focused_output seat
  @@ fun o ->
  match Output.focused_window o with
  | None -> Error Messages.no_focused_window
  | Some w -> f o w
;;

let focused_window_log ?out seat f =
  logged ?out
  @@ focused_window seat
  @@ fun o w ->
  f o w;
  Ok None
;;

let output (window : Types.Window.t) f =
  match window.output with
  | None -> Error Messages.window_missing_output
  | Some o -> f o
;;

let output_log ?out window f =
  logged ?out
  @@ output window
  @@ fun o ->
  f o;
  Ok None
;;