From 56c926fc6aeaf1f1545df71fb0f9d676b42dedae Mon Sep 17 00:00:00 2001 From: theblacksquid Date: Thu, 5 Nov 2020 03:10:57 +0800 Subject: [PATCH] Begin re-write of basic display functions in scheme --- .gitignore | 1 + display.scm | 39 +++++++++++++++++++++++++++++++++++++++ guile_wrap.c | 3 ++- main.c | 3 ++- 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 display.scm diff --git a/.gitignore b/.gitignore index 7b418d4..322ba46 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ /texed /display.c~ /display.h~ +/display.scm~ diff --git a/display.scm b/display.scm new file mode 100644 index 0000000..798dd67 --- /dev/null +++ b/display.scm @@ -0,0 +1,39 @@ +#!/usr/bin/guile --listen +!# + +(use-modules (ncurses curses) + (srfi srfi-9) + (system repl server)) + +(define app (make-tcp-server-socket #:port 37146)) + +(spawn-server app) + +(define-record-type + (make-subeditor main-display modeline contents) + subeditor? + (main-display subeditor-main set-subeditor-main!) + (modeline subeditor-modeline set-subeditor-modeline!) + (contents sub-editor-contents set-subeditor-contents!)) + +(define stdscr (initscr)) + +(define (__display-init) + (begin + (cbreak!) + (noecho!) + (nonl!) + (intrflush! #f) + (keypad! stdscr #t))) + +(__display-init) + +(addstr stdscr "Hello world") + +(refresh stdscr) + +(getch stdscr) + +(endwin) + +(stop-server-and-clients!) diff --git a/guile_wrap.c b/guile_wrap.c index 721dcfd..689d5ad 100644 --- a/guile_wrap.c +++ b/guile_wrap.c @@ -1,5 +1,6 @@ #include "buffer.h" +#include "display.h" #include "guile_wrap.h" SCM buffer_init_wrap () @@ -25,7 +26,7 @@ SCM buffer_inspect_wrap (SCM buffer_obj) SCM buffer_insert_wrap (SCM buffer_obj, SCM ch) { buffer_t* buf = scm_to_pointer(buffer_obj); - char ch_unwrap = scm_to_char(ch); + char ch_unwrap = (char) SCM_CHAR(ch); buffer_insert_char(buf, ch_unwrap); return SCM_UNSPECIFIED; } diff --git a/main.c b/main.c index 39f5e42..61f5d7d 100644 --- a/main.c +++ b/main.c @@ -7,7 +7,8 @@ int main(int argc, char *argv[]) /* int state_flag = NORMAL_STATE; */ scm_with_guile(®ister_functions, NULL); - scm_shell(argc, argv); + /* scm_shell(argc, argv); */ + scm_c_primitive_load("display.scm"); return 0; } -- 2.11.4.GIT