Introduced a new layer of "panels" that produce panes

This commit is contained in:
cqc
2021-09-01 04:40:43 -05:00
parent df39308b7a
commit 3004a87571
5 changed files with 589 additions and 315 deletions

22
dune
View File

@ -19,14 +19,28 @@
ocaml-compiler-libs.bytecomp ocaml-compiler-libs.bytecomp
ocaml-compiler-libs.toplevel)) ocaml-compiler-libs.toplevel))
(executable
(name irc)
(modes byte)
(modules irc)
(libraries
fmt
topinf
irc-client
irc-client-lwt
irc-client-unix
irc-client-tls
))
(executable (executable
(name boot) (name boot)
(modes byte) (modes byte)
(modules boot) (modules boot)
(link_flags (-linkall)) (link_flags (-linkall))
(libraries (libraries
lambda-term lambda-term
topinf)) topinf))
(library (library
(name topinf) (name topinf)
@ -40,6 +54,10 @@
zed zed
lambda-term lambda-term
irmin-unix irmin-unix
irc-client
irc-client-lwt
irc-client-unix
irc-client-tls
ocaml-compiler-libs.common ocaml-compiler-libs.common
ocaml-compiler-libs.bytecomp ocaml-compiler-libs.bytecomp
ocaml-compiler-libs.toplevel)) ocaml-compiler-libs.toplevel))

103
irc.ml Normal file
View File

@ -0,0 +1,103 @@
(*
when all you can do is type, making things more complicated than a list is hard?
we need to design this somehow before implementing it
really the graphical drawing / window management funcitons i think at this point.
*)
open Lwt
module C = Irc_client_tls
module M = Irc_message
let host = ref "irc.hackint.org"
let port = ref 6697
let nick = ref "cqcaml"
let channel = ref "#freeside"
let message = "Hello, world! This is a test from ocaml-irc-client"
let output_channel_of_ppf ppf =
Lwt_io.make ~mode:Output (fun b o l ->
let s = String.sub (Lwt_bytes.to_string b) o l in
Fmt.pf ppf "%s" s ;
Lwt.return (String.length s) )
let callback connection result =
match result with
| Result.Ok ({M.command= M.Other _; _} as msg) ->
Lwt_io.printf "Got unknown message: %s\n" (M.to_string msg)
>>= fun () -> Lwt_io.flush Lwt_io.stdout
| Result.Ok ({M.command= M.PRIVMSG (_target, data); _} as msg) ->
Lwt_io.printf "Got message: %s\n" (M.to_string msg)
>>= fun () ->
Lwt_io.flush Lwt_io.stdout
>>= fun () ->
C.send_privmsg ~connection ~target:"cqc" ~message:("ack: " ^ data)
| Result.Ok msg ->
Lwt_io.printf "Got message: %s\n" (M.to_string msg)
>>= fun () -> Lwt_io.flush Lwt_io.stdout
| Result.Error e -> Lwt_io.printl e
let lwt_main () =
C.reconnect_loop ~after:30
~connect:(fun () ->
Lwt_io.printl "Connecting..."
>>= fun () -> C.connect_by_name ~server:!host ~port:!port ~nick:!nick ()
)
~f:(fun connection ->
Lwt_io.printl "Connected"
>>= fun () ->
Lwt_io.printl "send join msg"
>>= fun () ->
C.send_join ~connection ~channel:!channel
>>= fun () -> C.send_privmsg ~connection ~target:!channel ~message )
~callback ()
let _ =
Lwt_main.run
(Lwt.catch lwt_main (fun e ->
Printf.printf "exception: %s\n" (Printexc.to_string e) ;
exit 1 ) )
(* ocamlfind ocamlopt -package irc-client.lwt -linkpkg code.ml *)
(*open Lwt
module C = Irc_client_lwt
let host = "irc.hackint.org"
let port = 6697
let realname = "Demo IRC bot"
let nick = "cqcqcqcqc"
let username = nick
let channel = "#freeside"
let message = "Hello, world! This is a test from ocaml-irc-client"
let callback oc _connection result =
let open Irc_message in
match result with
| Result.Ok msg ->
Fmt.epr "irc msg: msg" ;
Lwt_io.fprintf oc "Got message: %s\n" (to_string msg)
| Result.Error e -> Lwt_io.fprintl oc e
let lwt_main =
let oc = output_channel_of_ppf !Topinf.ppf in
Lwt_unix.gethostbyname host
>>= fun he ->
C.connect
~addr:he.Lwt_unix.h_addr_list.(0)
~port ~username ~mode:0 ~realname ~nick ()
>>= fun connection ->
Lwt_io.fprintl oc "Connected"
>>= fun () ->
C.send_join ~connection ~channel
>>= fun () ->
C.send_privmsg ~connection ~target:channel ~message
>>= fun () ->
C.listen ~connection ~callback:(callback oc) ()
>>= fun () -> C.send_quit ~connection ()
let _ = Lwt_main.run lwt_main
*)

772
main.ml

File diff suppressed because it is too large Load Diff

View File

@ -1327,7 +1327,6 @@ let use_output ppf command =
let use_file ppf ~wrap_in_module name = let use_file ppf ~wrap_in_module name =
match name with match name with
| "" -> use_channel ppf ~wrap_in_module stdin name "(stdin)"
| _ -> ( | _ -> (
match Load_path.find name with match Load_path.find name with
| filename -> | filename ->

View File

@ -6,7 +6,6 @@ val setvalue : string -> Obj.t -> unit
(* End of: accessors for table of toplevel value bindings that must be first in the module signature *) (* End of: accessors for table of toplevel value bindings that must be first in the module signature *)
val print_toplevel_value_bindings : Format.formatter -> unit val print_toplevel_value_bindings : Format.formatter -> unit
val toplevel_env : Env.t ref val toplevel_env : Env.t ref
type evalenv = Format.formatter -> string -> unit type evalenv = Format.formatter -> string -> unit
@ -20,12 +19,9 @@ type directive_fun =
| Directive_ident of (Longident.t -> unit) | Directive_ident of (Longident.t -> unit)
| Directive_bool of (bool -> unit) | Directive_bool of (bool -> unit)
type directive_info = { section : string; doc : string } type directive_info = {section: string; doc: string}
val add_directive : Misc.filepath -> directive_fun -> directive_info -> unit val add_directive : Misc.filepath -> directive_fun -> directive_info -> unit
val directive_info_table : (string, directive_info) Hashtbl.t val directive_info_table : (string, directive_info) Hashtbl.t
val ppf : Format.formatter ref val ppf : Format.formatter ref
val eval : evalenv option ref val eval : evalenv option ref