Ver código fonte

Create functional hello world example.

Lily Carpenter 9 anos atrás
pai
commit
44eb01195a
6 arquivos alterados com 44 adições e 3 exclusões
  1. 2 1
      README.org
  2. 11 1
      bearlibterminal.asd
  3. 3 0
      bearlibterminal.lisp
  4. 11 0
      examples/hello-world.lisp
  5. 2 0
      library.lisp
  6. 15 1
      package.lisp

+ 2 - 1
README.org

@@ -3,7 +3,8 @@ A simple interface to the easy to use terminal library [[http://foo.wyrd.name/en
3 3
 ** Install
4 4
 *** Install [[https://www.quicklisp.org/beta/][quicklisp]]
5 5
 *** Clone git repo into ~/quicklisp/local-projects/
6
-*** (ql:quickload :cl-bearlibterminal)
6
+*** Install [[http://foo.wyrd.name/en:bearlibterminal][BearLibTerminal]]. (make sure to run ldconfig!)
7
+*** (ql:quickload :bearlibterminal)
7 8
 ** Use
8 9
 *** This is a very very thin wrapper over the [[http://foo.wyrd.name/en:bearlibterminal][BearLibTerminal]] c bindings.
9 10
 *** See: [[http://foo.wyrd.name/en:bearlibterminal:design][BearLibTerminal Design]] and [[http://foo.wyrd.name/en:bearlibterminal:reference][BearLibTerminal Reference]]

+ 11 - 1
bearlibterminal.asd

@@ -5,11 +5,21 @@
5 5
   :author "Lily Carpenter <lily-license@azrazalea.net>"
6 6
   :license "BSD 3-clause"
7 7
   :serial t
8
-  :depends-on ("cl-autowrap")
8
+  :depends-on ("cl-autowrap" "cl-plus-c")
9 9
   :components ((:module :autowrap-spec
10 10
                 :pathname "spec"
11 11
                 :components
12 12
                 ((:static-file "BearLibTerminal.h")))
13 13
                (:file "package")
14 14
                (:file "library")
15
+               (:file "autowrap")
15 16
                (:file "bearlibterminal")))
17
+
18
+(asdf:defsystem #:bearlibeterminal/examples
19
+  :description "simple examples to demonstrate common usage of bearlibterminal."
20
+  :author "Lily Carpenter <lily-license@azrazalea.net>"
21
+  :license "BSD 3-clause"
22
+  :depends-on (:bearlibterminal)
23
+  :pathname "examples"
24
+  :serial t
25
+  :components ((:file "hello-world")))

+ 3 - 0
bearlibterminal.lisp

@@ -3,3 +3,6 @@
3 3
 (in-package #:bearlibterminal)
4 4
 
5 5
 ;;; "bearlibterminal" goes here. Hacks and glory await!
6
+
7
+(defun terminal-print (x y string)
8
+  (terminal-print8 x y string))

+ 11 - 0
examples/hello-world.lisp

@@ -0,0 +1,11 @@
1
+(in-package :bearlibterminal-examples)
2
+
3
+(require :bearlibterminal)
4
+
5
+(defun hello-world ()
6
+  "Simple hello world terminal example"
7
+  (terminal-open)
8
+  (terminal-print 1 1 "Hello, world!")
9
+  (terminal-refresh)
10
+  (loop while (not (equal (terminal-read) bearlibterminal-ffi:+tk-close+)))
11
+  (terminal-close))

+ 2 - 0
library.lisp

@@ -2,3 +2,5 @@
2 2
 
3 3
 (cffi:define-foreign-library bearlibterminal
4 4
   (t (:default "libBearLibTerminal")))
5
+
6
+(cffi:use-foreign-library bearLibTerminal)

+ 15 - 1
package.lisp

@@ -5,4 +5,18 @@
5 5
 (defpackage #:bearlibterminal-ffi.functions)
6 6
 
7 7
 (defpackage #:bearlibterminal
8
-  (:use #:cl))
8
+  (:use #:cl
9
+        #:autowrap.minimal
10
+        #:plus-c
11
+        #:bearlibterminal-ffi.functions
12
+        #:bearlibterminal-ffi.accessors)
13
+  (:export
14
+   #:terminal-open
15
+   #:terminal-read
16
+   #:terminal-print
17
+   #:terminal-close
18
+   #:terminal-refresh))
19
+
20
+(defpackage #:bearlibterminal-examples
21
+  (:use :cl :bearlibterminal)
22
+  (:export #:hello-world))