package irc-client
IRC client library - core functionality
Install
Dune Dependency
Authors
Maintainers
Sources
irc-client.0.7.1.tar.gz
sha256=ed339aaa57ffd628958b09e33605c7c90a8072cc0827dca34ef0b2344a576538
doc/src/irc-client/irc_helpers.ml.html
Source file irc_helpers.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
let split ~str ~c = (* [i]: current index in [str] [acc]: list of strings split so far *) let rec rev_split' ~str ~i ~c ~acc = try let index = String.index_from str i c in let before = String.sub str i (index-i) in rev_split' ~str ~c ~i:(index+1) ~acc:(before :: acc) with Not_found -> String.sub str i (String.length str - i) :: acc in List.rev (rev_split' ~str ~i:0 ~c ~acc:[]) let split1_exn ~str ~c = let index = String.index str c in let before = String.sub str 0 index in let after = String.sub str (index + 1) (String.length str - index - 1) in before, after let get_whole_lines ~str = let rec find i acc = try let j = String.index_from str i '\n' in if i=j then find (j+1) acc else let line = String.sub str i (j-i-1) in find (j+1) (line :: acc) with Not_found -> if i=String.length str then List.rev acc, `NoRest else List.rev acc, `Rest (String.sub str i (String.length str - i)) in find 0 [] let handle_input ~buffer ~input = (* Append the new input to the buffer. *) Buffer.add_string buffer input; let whole_lines, rest = get_whole_lines ~str:(Buffer.contents buffer) in (* Replace the buffer contents with the last, partial, line. *) Buffer.clear buffer; begin match rest with | `NoRest -> () | `Rest s -> Buffer.add_string buffer s; end; (* Return the whole lines extracted from the buffer. *) whole_lines module Log = (val Logs.src_log (Logs.Src.create ~doc:"irc-client low level logging" "irc-client"))
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>