aports/testing/jackline/latest-notty-compat.patch
2022-05-21 15:28:27 +00:00

212 lines
8.1 KiB
Diff

--- a/cli/cli_client.ml
+++ b/cli/cli_client.ml
@@ -116,14 +116,14 @@
let a = A.(a ++ buddy_to_color (Contact.color contact resource)) in
let first =
match has_notifications state jid, Contact.expanded contact with
- | true, true -> I.char a '*' 1 1
- | false, false -> I.char a (if potentially_visible_resource state contact then '+' else ' ') 1 1
+ | true, true -> I.char ~attr:a '*' 1 1
+ | false, false -> I.char ~attr:a (if potentially_visible_resource state contact then '+' else ' ') 1 1
| true, false -> Chars.star a 1
- | false, true -> I.char a ' ' 1 1
+ | false, true -> I.char ~attr:a ' ' 1 1
and data = if s then Contact.oneline contact None else Contact.oneline contact resource
in
- let buddy = I.(first <|> string a data) in
- v_space (I.char a ' ' 1 1) width buddy I.empty
+ let buddy = I.(first <|> string ~attr:a data) in
+ v_space (I.char ~attr:a ' ' 1 1) width buddy I.empty
let format_buddies state w buddies =
(* where buddies is (contact * resource list) list *)
@@ -162,16 +162,16 @@
I.vsnap ~align:`Top h formatted
let horizontal_line buddy resource a scrollback filter width =
- let pre = I.(Chars.hdash a 2 <|> I.char a ' ' 1 1)
- and scroll = if scrollback = 0 then I.empty else I.string a ("*scrolling " ^ string_of_int scrollback ^ "* ")
- and filter = match filter with None -> I.empty | Some x -> I.string a ("*filter: " ^ x ^ "* ")
+ let pre = I.(Chars.hdash a 2 <|> I.char ~attr:a ' ' 1 1)
+ and scroll = if scrollback = 0 then I.empty else I.string ~attr:a ("*scrolling " ^ string_of_int scrollback ^ "* ")
+ and filter = match filter with None -> I.empty | Some x -> I.string ~attr:a ("*filter: " ^ x ^ "* ")
and jid =
let p = match buddy with
| `User _ -> "buddy: "
| `Room _ -> "room: "
in
let id = Contact.jid buddy resource in
- I.string a (p ^ Xjid.jid_to_string id ^ " ")
+ I.string ~attr:a (p ^ Xjid.jid_to_string id ^ " ")
and otr =
match buddy, resource with
| `User user, Some (`Session s) ->
@@ -183,7 +183,7 @@
(User.verification_status_to_color vs, User.verification_status_to_string vs))
(User.otr_fingerprint s.User.otr)
in
- I.(string a " " <|> string A.(a ++ buddy_to_color col) (data ^ " ") <|> Chars.hdash a 1)
+ I.(string ~attr:a " " <|> string ~attr:A.(a ++ buddy_to_color col) (data ^ " ") <|> Chars.hdash a 1)
| _ -> I.empty
and presence_status =
let tr p s =
@@ -193,10 +193,10 @@
(fun x ->
match split_on_nl a x with
| [] -> I.empty
- | x::_ -> I.(x <|> string a " "))
+ | x::_ -> I.(x <|> string ~attr:a " "))
s
in
- I.(string a (" " ^ User.presence_to_string p ^ " ") <|> status <|> Chars.hdash a 1)
+ I.(string ~attr:a (" " ^ User.presence_to_string p ^ " ") <|> status <|> Chars.hdash a 1)
in
Utils.option
I.empty
@@ -209,17 +209,17 @@
let status_line self mysession notify log a width =
let a = A.(a ++ st bold) in
- let notify = if notify then I.string A.(a ++ st blink ++ Cli_colour.kind `Warning) "##" else Chars.hdash a 2
+ let notify = if notify then I.string ~attr:A.(a ++ st blink ++ Cli_colour.kind `Warning) "##" else Chars.hdash a 2
and jid =
let data = User.userid self mysession
and a' = if log then A.(st reverse) else a
in
- I.(string a "< " <|> string a' data <|> string a " >")
+ I.(string ~attr:a "< " <|> string ~attr:a' data <|> string ~attr:a " >")
and status =
let data = User.presence_to_string mysession.User.presence
and color = if mysession.User.presence = `Offline then `Bad else `Good
in
- I.(string a "[ " <|> string A.(buddy_to_color color ++ a) data <|> string a " ]" <|> Chars.hdash a 1)
+ I.(string ~attr:a "[ " <|> string ~attr:A.(buddy_to_color color ++ a) data <|> string ~attr:a " ]" <|> Chars.hdash a 1)
in
v_space (Chars.hdash a 1) width I.(notify <|> jid) status
@@ -256,7 +256,7 @@
in
if main_height <= 4 || chat_width <= 20 then
- (I.string A.empty "need more space", 1)
+ (I.string ~attr:A.empty "need more space", 1)
else
let active = active state
and resource = resource state
@@ -275,18 +275,18 @@
let iinp =
let inp = Array.of_list pre in
- I.uchars A.empty inp
+ I.uchars ~attr:A.empty inp
and iinp2 =
let inp2 = Array.of_list post in
- I.uchars A.empty inp2
+ I.uchars ~attr:A.empty inp2
in
let r = match post with
| [] ->
let input = char_list_to_str pre in
( match Cli_commands.completion state input with
| [] -> I.empty
- | [x] -> I.string (Cli_colour.kind `Info) x
- | xs -> I.string (Cli_colour.kind `Info) (String.concat "|" xs) )
+ | [x] -> I.string ~attr:(Cli_colour.kind `Info) x
+ | xs -> I.string ~attr:(Cli_colour.kind `Info) (String.concat "|" xs) )
| _ -> iinp2
in
v_center iinp r width
--- a/cli/cli_config.ml
+++ b/cli/cli_config.ml
@@ -16,7 +16,7 @@
let input = I.(inp <|> inp2) in
let above = wrap above in
let below = wrap below in
- let input = if I.width input = 0 then I.string A.empty " " else input in
+ let input = if I.width input = 0 then I.string ~attr:A.empty " " else input in
let image = I.(above <-> content <-> input <-> below) in
Notty_lwt.Term.image term image >>= fun () ->
let col, row =
@@ -31,10 +31,10 @@
let rec go (pre, post) =
let iinp =
let inp = Array.of_list pre in
- I.uchars A.(st reverse) inp
+ I.uchars ~attr:A.(st reverse) inp
and iinp2 =
let inp2 = Array.of_list post in
- I.uchars A.(st reverse) inp2
+ I.uchars ~attr:A.(st reverse) inp2
in
rewrap term above below (prefix, iinp, iinp2) (Notty_lwt.Term.size term) >>= fun () ->
Lwt_stream.next (Notty_lwt.Term.events term) >>= fun e ->
@@ -55,7 +55,7 @@
let read_password ?(above = []) ?(prefix = "") ?(below = []) term =
let rec go pre =
- let w = I.(width (uchars A.empty (Array.of_list pre))) in
+ let w = I.(width (uchars ~attr:A.empty (Array.of_list pre))) in
let input = Chars.star A.(st reverse) w in
rewrap term above below (prefix, input, I.empty) (Notty_lwt.Term.size term) >>= fun () ->
Lwt_stream.next (Notty_lwt.Term.events term) >>= function
--- a/cli/cli_support.ml
+++ b/cli/cli_support.ml
@@ -4,19 +4,19 @@
module Chars = struct
let hdash a w =
if !Utils.unicode then
- I.uchar a (Uchar.of_int 0x2500) w 1
+ I.uchar ~attr:a (Uchar.of_int 0x2500) w 1
else
- I.char a '-' w 1
+ I.char ~attr:a '-' w 1
and vdash a h =
if !Utils.unicode then
- I.uchar a (Uchar.of_int 0x2502) 1 h
+ I.uchar ~attr:a (Uchar.of_int 0x2502) 1 h
else
- I.char a '|' 1 h
+ I.char ~attr:a '|' 1 h
and star a w =
if !Utils.unicode then
- I.uchar a (Uchar.of_int 0x2605) w 1
+ I.uchar ~attr:a (Uchar.of_int 0x2605) w 1
else
- I.char a '*' w 1
+ I.char ~attr:a '*' w 1
end
(* line wrapping is a bit tricky, since we prefer to wrap at word boundaries.
@@ -123,11 +123,11 @@
| `End -> if line = [] then lines else List.rev line::lines
in
let lines = go 0 [] [] [] `Await in
- List.map (fun l -> I.uchars a (Array.of_list l)) (List.rev lines)
+ List.map (fun l -> I.uchars ~attr:a (Array.of_list l)) (List.rev lines)
let split_unicode strip len a str =
(* first try to fit str in len *)
- let whole = I.string a str in
+ let whole = I.string ~attr:a str in
if I.width whole <= len then
[ whole ]
else
@@ -158,7 +158,7 @@
let els =
if Astring.String.Ascii.is_valid l then
let lines = split_ascii strip_ws width l [] in
- List.map (I.string a) lines
+ List.map (I.string ~attr:a) lines
else
split_unicode strip_ws width a l
in
@@ -171,7 +171,7 @@
I.vcat lines
let split_on_nl a m =
- List.map (I.string a) (Astring.String.cuts ~sep:"\n" ~empty:false m)
+ List.map (I.string ~attr:a) (Astring.String.cuts ~sep:"\n" ~empty:false m)
let v_space f width left right =
let len = width - I.(width left + width right) in