|
6 | 6 | ;; (ice-9 getopt-long) ;; for CLI options |
7 | 7 | (ice-9 suspendable-ports) |
8 | 8 | (ice-9 rdelim) |
9 | | - (json)) |
| 9 | + (json) |
| 10 | + (ncurses curses)) |
10 | 11 |
|
11 | 12 |
|
12 | 13 | (install-suspendable-ports!) |
|
46 | 47 | (setvbuf (cdr xi-pipes) 'line) |
47 | 48 | ;; Tried with-output-to-port but it didn't work for some reason |
48 | 49 | ;; 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)))) |
50 | 52 | (let ((from-xi (car xi-pipes)) |
51 | 53 | (to-xi (open-output-pipe path))) |
52 | 54 | (cons from-xi to-xi))))) |
53 | 55 |
|
54 | | -;; Main |
55 | | -(define (main args) |
| 56 | +(define (xile-setup) |
56 | 57 | (let* ((xi-proc (xile--open "xi-editor/rust/target/release/xi-core")) |
57 | 58 | (port-from-xi (car xi-proc)) |
58 | 59 | (port-to-xi (cdr xi-proc)) |
59 | 60 | (init-client (xile--msg-init '())) |
60 | 61 | (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!) |
61 | 78 |
|
62 | 79 | ;; Xi init code |
63 | | - (xile--msg-send port-to-xi init-client) |
| 80 | + (xile--msg-send port-to-xi (xile--msg-init '())) |
64 | 81 |
|
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)))) |
67 | 88 |
|
| 89 | + ;; (refresh stdscr) |
| 90 | + ;; (getch stdscr) |
| 91 | + ;; (endwin)) |
| 92 | + ;; TODO : event loop thread instead of joining |
| 93 | + (join-thread listener (+ 1 (current-time))) |
68 | 94 | (close-port port-to-xi) |
69 | 95 | (close-port port-from-xi))) |
0 commit comments