Verified Commit 66f4344c authored by Merlin Göttlinger's avatar Merlin Göttlinger 💧
Browse files

Removed unused ncurses code and dependencies

parent ebfda5e7
Pipeline #11281 passed with stages
in 6 minutes and 52 seconds
......@@ -39,12 +39,10 @@ Install ocaml include files, minisat include files. Place them in the include
directory (e.g. `/usr/include`, `/usr/lib/ocaml`, or `.`).
Runtime dependencies:
- readline
- minisat (at least minisat 2)
- pgsolver
- m4
- zlib
- ncurses (for the debugger and the repl-example)
On Debian, Ubuntu or other `apt` based Linux distrubutions you can use [the setup script](./ci/apt-setup.sh) and [the OCaml setup script](./ci/ocaml-setup.sh) to install the required dependencies.
......
#!/bin/sh
sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get install -y build-essential minisat libreadline-dev m4 zlib1g-dev libncurses5-dev
sudo apt-get install -y build-essential minisat m4 zlib1g-dev
......@@ -16,15 +16,10 @@ with nixpkgs; rec {
inherit versions ocamline;
minisat = pkgs.minisat;
};
cool-static = let
nc = ncurses5.override { enableStatic = true; };
in
cool.override (o: {
cool-static = cool.override (o: {
doCheck = false;
profile = "static";
glibc = glibc.static;
ncurses5 = nc;
readline = withStatic (readline.override { ncurses = nc; }) ;
});
cool-docker = callPackage ./nix/cool-docker.nix { inherit versions cool; };
cool-tests = ocamlPackages.callPackage ./nix/cool-tests.nix {
......
{ lib, buildDunePackage, ounit, ocamlgraph, fetchgit, pgsolver, glibc, readline, zlib, ncurses5, minisat, ocamline, profile ? null, versions, doCheck ? true }:
{ lib, buildDunePackage, ounit, ocamlgraph, fetchgit, pgsolver, glibc, zlib, minisat, ocamline, profile ? null, versions, doCheck ? true }:
buildDunePackage (rec {
pname = "cool";
......@@ -7,7 +7,7 @@ buildDunePackage (rec {
src = ../.;
buildInputs = [ readline zlib.dev ncurses5 minisat ocamlgraph glibc pgsolver ocamline ];
buildInputs = [ zlib.dev minisat ocamlgraph glibc pgsolver ocamline ];
buildPhase = ''
runHook preBuild
......@@ -25,10 +25,10 @@ buildDunePackage (rec {
OUNIT_CI = "true";
meta = {
meta = with lib; {
homepage = https://www8.cs.fau.de/research/cool-the-coalgebraic-ontology-logic-reasoner/;
description = "Generic reasoner for modal, hybrid and fixpoint logics";
license = lib.licenses.gpl3;
maintainers = with lib.maintainers; [ mgttlinger ];
license = licenses.gpl3;
maintainers = with maintainers; [ mgttlinger ];
};
} // versions)
......@@ -2,4 +2,4 @@
(public_name debugger)
(name debugger)
(modes native)
(libraries cool interfacencurses))
(libraries cool repl))
(* example borrowed from
http://caml.inria.fr/pub/docs/manual-ocaml-400/manual033.html
*)
type window (* The type "window" remains abstract *)
external initscr: unit -> window = "curses_initscr"
external endwin: unit -> unit = "curses_endwin"
external refresh: unit -> unit = "curses_refresh"
external wrefresh : window -> unit = "curses_wrefresh"
external newwin: int -> int -> int -> int -> window = "curses_newwin"
external addch: char -> unit = "curses_addch"
external mvwaddch: window -> int -> int -> char -> unit = "curses_mvwaddch"
external addstr: string -> unit = "curses_addstr"
external mvwaddstr: window -> int -> int -> string -> unit = "curses_mvwaddstr"
external getmaxyx: window -> int * int = "curses_getmaxyx"
external getch : unit -> int = "curses_getch"
(* vim: set et sw=2 sts=2 ts=8 : *)
(* example borrowed from
http://caml.inria.fr/pub/docs/manual-ocaml-400/manual033.html
*)
type window (* The type "window" remains abstract *)
val initscr: unit -> window
val endwin: unit -> unit
val refresh: unit -> unit
val wrefresh : window -> unit
val newwin: int -> int -> int -> int -> window
val addch: char -> unit
val mvwaddch: window -> int -> int -> char -> unit
val addstr: string -> unit
val mvwaddstr: window -> int -> int -> string -> unit
val getmaxyx: window -> int * int
val getch : unit -> int
(* vim: set et sw=2 sts=2 ts=8 : *)
#define __STDC_LIMIT_MACROS
#define __STDC_FORMAT_MACROS
extern "C" {
#include <caml/mlvalues.h>
#include <caml/alloc.h>
#include <caml/memory.h>
#include <caml/custom.h>
}
// Code borrowed from:
// http://caml.inria.fr/pub/docs/manual-ocaml-400/manual033.html#toc147
#include <curses.h>
extern "C" {
/* Encapsulation of opaque window handles (of type WINDOW *)
as OCaml custom blocks. */
char bla[] = "fr.inria.caml.curses_windows";
static struct custom_operations curses_window_ops = {
bla,
custom_finalize_default,
custom_compare_default,
custom_hash_default,
custom_serialize_default,
custom_deserialize_default
};
/* Accessing the WINDOW * part of an OCaml custom block */
#define Window_val(v) (*((WINDOW **) Data_custom_val(v)))
/* Allocating an OCaml custom block to hold the given WINDOW * */
static value alloc_window(WINDOW * w)
{
value v = alloc_custom(&curses_window_ops, sizeof(WINDOW *), 0, 1);
Window_val(v) = w;
return v;
}
value curses_initscr(value unit)
{
CAMLparam1 (unit);
CAMLreturn (alloc_window(initscr()));
}
value curses_endwin(value unit)
{
CAMLparam1 (unit);
endwin();
CAMLreturn (Val_unit);
}
value curses_refresh(value unit)
{
CAMLparam1 (unit);
refresh();
CAMLreturn (Val_unit);
}
value curses_wrefresh(value win)
{
CAMLparam1 (win);
wrefresh(Window_val(win));
CAMLreturn (Val_unit);
}
value curses_newwin(value nlines, value ncols, value x0, value y0)
{
CAMLparam4 (nlines, ncols, x0, y0);
CAMLreturn (alloc_window(newwin(Int_val(nlines), Int_val(ncols),
Int_val(x0), Int_val(y0))));
}
value curses_addch(value c)
{
CAMLparam1 (c);
addch(Int_val(c)); /* Characters are encoded like integers */
CAMLreturn (Val_unit);
}
value curses_mvwaddch(value win, value x, value y, value c)
{
CAMLparam4 (win, x, y, c);
mvwaddch(Window_val(win), Int_val(x), Int_val(y), Int_val(c));
CAMLreturn (Val_unit);
}
value curses_addstr(value s)
{
CAMLparam1 (s);
addstr(String_val(s));
CAMLreturn (Val_unit);
}
value curses_mvwaddstr(value win, value x, value y, value s)
{
CAMLparam4 (win, x, y, s);
mvwaddstr(Window_val(win), Int_val(x), Int_val(y), String_val(s));
CAMLreturn (Val_unit);
}
value curses_getmaxyx(value win)
{
CAMLparam1 (win);
int h, w;
CAMLlocal1( hw );
hw = caml_alloc(2, 0);
getmaxyx(Window_val(win), h, w);
Store_field( hw, 0, Val_int(h) );
Store_field( hw, 1, Val_int(w) );
CAMLreturn ( hw );
}
value curses_getch(value unit) {
CAMLparam1( unit );
CAMLreturn (Val_int(getch()));
}
}
(* a simple NCurses UI Library *)
open Curses
type point = int * int (* x and y *)
type buffer = string list
exception ScreenNotOpen
exception NoRootWidget
type 'a member = {
set : 'a -> unit;
get : unit -> 'a
}
type widget = {
minSize: point member;
paint: point -> buffer;
}
let member_init (v: 'a): 'a member =
let pointer = ref (v) in
{
set = (fun _n -> pointer := v);
get = (fun () -> !pointer);
}
let label str = {
minSize = member_init (0,0);
paint = (fun (_w,_h) -> [ str ]);
}
let root_widget : widget option ref = ref (None)
let get_root_widget () : widget =
match (!root_widget) with
| None -> raise NoRootWidget
| Some x -> x
let stdscr : window option ref = ref (None)
let screen_open () =
stdscr := Some (initscr ())
let get_stdscr () =
match (!stdscr) with
| None -> raise ScreenNotOpen
| Some x -> x
let screen_close () =
stdscr := None;
endwin ()
let paint_widget (wid:widget) ((x,y):point) (size: point) =
let stdscr = get_stdscr () in
let lines = wid.paint size in
let paint i str =
mvwaddstr stdscr (y+i) x str
in
List.iteri paint lines
let update () =
let h, w = getmaxyx (get_stdscr ()) in
paint_widget (get_root_widget()) (0,0) (w,h);
refresh()
let set_root_widget widget =
root_widget := Some widget;
update()
(* vim: set et sw=2 sts=2 ts=8 : *)
(* a simple NCurses UI Library *)
type point = int * int (* x and y *)
type buffer = string list
exception ScreenNotOpen
exception NoRootWidget
type 'a member = {
set : 'a -> unit;
get : unit -> 'a
}
type widget = {
minSize: point member;
paint: point -> buffer;
}
val member_init : 'a -> 'a member
val label: string -> widget
val update : unit -> unit
val set_root_widget : widget -> unit
val screen_open : unit -> unit
val screen_close : unit -> unit
(* vim: set et sw=2 sts=2 ts=8 : *)
(library
;; FIXME switch to 'transition' or 'true'
(wrapped false)
(modes native)
(name interfacencurses)
(cxx_names Curses_stub)
(cxx_flags :standard -std=c++98)
(c_library_flags :standard -lstdc++ -lm -lncurses -ltinfo)
(libraries str ocamline))
......@@ -2,4 +2,4 @@
(public_name repl-example)
(name repl-example)
(modes native)
(libraries interfacencurses unix))
(libraries repl unix))
(library
(modes native)
(name repl)
(libraries str ocamline))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment