Skip to content

Commit 9470a90

Browse files
committed
Merge branch 'combined-sdl2-ncurses-build' of https://github.com/frejanordsiek/lem into frejanordsiek-combined-sdl2-ncurses-build
2 parents ea725bc + 3966e8c commit 9470a90

4 files changed

Lines changed: 55 additions & 12 deletions

File tree

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ rpc:
1212
qlot install
1313
$(LISP) --noinform --no-sysinit --no-userinit --load .qlot/setup.lisp --load scripts/build-rpc.lisp
1414

15+
sdl2-ncurses:
16+
qlot install
17+
$(LISP) --noinform --no-sysinit --no-userinit --load .qlot/setup.lisp --load scripts/build-sdl2-ncurses.lisp
18+
1519
test:
1620
qlot install
1721
.qlot/bin/rove lem-tests.asd

scripts/build-sdl2-ncurses.lisp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
(ql:quickload :lem-sdl2)
2+
(ql:quickload :lem-ncurses)
3+
4+
(lem:init-at-build-time)
5+
6+
(sb-ext:save-lisp-and-die "lem"
7+
:toplevel #'lem:main
8+
:executable t)

src/interface.lisp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
:initarg :window-left-margin
2121
:reader window-left-margin)))
2222

23-
(defun get-default-implementation (&key (errorp t))
23+
(defun get-default-implementation (&key (errorp t) (implementation :ncurses))
2424
(let* ((classes (c2mop:class-direct-subclasses (find-class 'implementation)))
2525
(class (case (length classes)
2626
(0
@@ -31,7 +31,7 @@
3131
(first classes))
3232
(otherwise
3333
(dolist (class classes (first classes))
34-
(when (string= :ncurses (class-name class))
34+
(when (string= implementation (class-name class))
3535
(return class)))))))
3636
(when class
3737
(make-instance class))))

src/lem.lisp

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,20 @@
1010
(defvar *syntax-scan-window-recursive-p* nil)
1111
(defvar *help* "Usage: lem [ OPTION-OR-FILENAME ] ...
1212
Options:
13-
-q, --no-init-file do not load ~/.lem/init.lisp
14-
--slime PORT start slime on PORT
15-
--eval EXPR evaluate lisp expression EXPR
16-
--debug enable debugger
17-
--log-filename FILENAME file name of the log file
18-
--kill immediately exit
19-
-v, --version print the version number and exit
20-
-h, --help display this help and exit"
13+
-q, --no-init-file do not load ~/.lem/init.lisp
14+
--slime PORT start slime on PORT
15+
--eval EXPR evaluate lisp expression EXPR
16+
--debug enable debugger
17+
--log-filename FILENAME file name of the log file
18+
--kill immediately exit
19+
--gui to use any available GUI interface
20+
--nogui to use any available terminal interface
21+
--ncurses to use ncurses terminal interface
22+
--sdl2 to use SDL2 GUI interface
23+
--sdl to use any available SDL GUI interface
24+
-i, --interface INTERFACE interface to use, either sdl2 or ncurses
25+
-v, --version print the version number and exit
26+
-h, --help display this help and exit"
2127
"Help output for cli")
2228

2329
(defun syntax-scan-window (window)
@@ -89,7 +95,8 @@ Options:
8995
args
9096
(debug nil)
9197
(log-filename nil)
92-
(no-init-file nil))
98+
(no-init-file nil)
99+
(interface nil))
93100

94101
(defun parse-args (args)
95102
(let ((parsed-args
@@ -122,6 +129,23 @@ Options:
122129
(error "Please, specify a filename to log to."))
123130
(setf (command-line-arguments-log-filename parsed-args)
124131
filename)))
132+
((equal arg "--ncurses")
133+
(setf (command-line-arguments-interface parsed-args) :ncurses))
134+
((equal arg "--sdl2")
135+
(setf (command-line-arguments-interface parsed-args) :sdl2))
136+
((equal arg "--sdl")
137+
(setf (command-line-arguments-interface parsed-args) :sdl2))
138+
((equal arg "--gui")
139+
(setf (command-line-arguments-interface parsed-args) :sdl2))
140+
((equal arg "--nogui")
141+
(setf (command-line-arguments-interface parsed-args) :ncurses))
142+
((member arg '("-i" "--interface") :test #'equal)
143+
(let ((interface (pop args)))
144+
(if (and interface (plusp (length interface)))
145+
(setf (command-line-arguments-interface parsed-args)
146+
(alexandria:make-keyword (string-upcase interface)))
147+
(write-line "Please specify an interface to use."
148+
*error-output*))))
125149
((equal arg "--kill")
126150
`(uiop:quit))
127151
((member arg '("-v" "--version") :test #'equal)
@@ -258,7 +282,14 @@ See scripts/build-ncurses.lisp or scripts/build-sdl2.lisp"
258282
(cond (*in-the-editor*
259283
(apply-args args))
260284
(t
261-
(let ((implementation (get-default-implementation :errorp nil)))
285+
(let ((implementation
286+
(get-default-implementation
287+
:errorp nil
288+
:implementation
289+
(or (command-line-arguments-interface args)
290+
(if (interactive-stream-p *standard-input*)
291+
:ncurses
292+
:sdl2)))))
262293
(unless implementation
263294
(maybe-load-systems :lem-ncurses)
264295
(setf implementation (get-default-implementation)))

0 commit comments

Comments
 (0)