Skip to content

Commit a7088e4

Browse files
committed
Start incorporating ncurses with logs
Logs are still not all going where they should, and it interferes with ncurses interface (namely, the debug messages and the output from the listener thread)
1 parent dbf1345 commit a7088e4

3 files changed

Lines changed: 34 additions & 7 deletions

File tree

hello_xi.scm

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
;; (ice-9 getopt-long) ;; for CLI options
77
(ice-9 suspendable-ports)
88
(ice-9 rdelim)
9-
(json))
9+
(json)
10+
(ncurses curses))
1011

1112

1213
(install-suspendable-ports!)
@@ -46,24 +47,49 @@
4647
(setvbuf (cdr xi-pipes) 'line)
4748
;; Tried with-output-to-port but it didn't work for some reason
4849
;; and sent the output of xi-core process to stdout instead
49-
(parameterize ((current-output-port (cdr xi-pipes)))
50+
(parameterize ((current-output-port (cdr xi-pipes))
51+
(current-error-port (open "logs/xi-core.log" (logior O_CREAT O_WRONLY))))
5052
(let ((from-xi (car xi-pipes))
5153
(to-xi (open-output-pipe path)))
5254
(cons from-xi to-xi)))))
5355

54-
;; Main
55-
(define (main args)
56+
(define (xile-setup)
5657
(let* ((xi-proc (xile--open "xi-editor/rust/target/release/xi-core"))
5758
(port-from-xi (car xi-proc))
5859
(port-to-xi (cdr xi-proc))
5960
(init-client (xile--msg-init '()))
6061
(listener (make-thread xile--msg-handler port-from-xi)))
62+
(cons listener (cons port-from-xi port-to-xi))))
63+
64+
;; Main
65+
(define (main args)
66+
(let* ((xi-setup (xile-setup))
67+
(port-from-xi (cadr xi-setup))
68+
(port-to-xi (cddr xi-setup))
69+
(listener (car xi-setup)))
70+
71+
(set-current-error-port (open "logs/xile-err.log" (logior O_CREAT O_WRONLY)))
72+
(set-current-output-port (open "logs/xile-out.log" (logior O_CREAT O_WRONLY)))
73+
74+
;; (define stdscr (initscr))
75+
;; (raw!)
76+
;; (keypad! stdscr #t)
77+
;; (noecho!)
6178

6279
;; Xi init code
63-
(xile--msg-send port-to-xi init-client)
80+
(xile--msg-send port-to-xi (xile--msg-init '()))
6481

65-
;; TODO : event loop thread instead of joining
66-
(join-thread listener (+ 2 (current-time)))
82+
;; (addstr stdscr "Type any character to see it in bold\n")
83+
;; (let ((ch (getch stdscr)))
84+
;; (addstr stdscr "The pressed key is ")
85+
;; (if (char? ch)
86+
;; (addch stdscr (bold ch))
87+
;; (addchstr stdscr (bold (keyname ch))))
6788

89+
;; (refresh stdscr)
90+
;; (getch stdscr)
91+
;; (endwin))
92+
;; TODO : event loop thread instead of joining
93+
(join-thread listener (+ 1 (current-time)))
6894
(close-port port-to-xi)
6995
(close-port port-from-xi)))

logs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.log

logs/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)