Skip to content

Instantly share code, notes, and snippets.

@moratori
Created July 12, 2014 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moratori/12787650a460ad6a3ce9 to your computer and use it in GitHub Desktop.
Save moratori/12787650a460ad6a3ce9 to your computer and use it in GitHub Desktop.
clim app4
(in-package :cl-user)
(ql:quickload :clx)
(ql:quickload :mcclim)
(defpackage app
(:use :clim
:clim-lisp))
(in-package :app)
(define-application-frame superapp ()
((numbers
:initform (loop repeat 20 collect (list (random 100000000)))
:accessor numbers)
(cursor
:initform 0
:accessor cursor))
(:panes
(app
:application
:height 400
:width 600
:incremental-redisplay t
:display-function 'display-app)
(int
:interactor
:height 200
:width 600))
(:layouts
(default (vertically () app int))))
(defun display-app (frame pane)
(loop for elm in (numbers frame)
for line from 0 do
(progn
(princ
(if (= line (cursor frame)) "*" " ")
pane)
(updating-output
(pane
:unique-id elm
:id-test #'eq
:cache-value (car elm)
:cache-test #'eql
)
(format pane "~A~%" (car elm))))))
(defun app-main ()
(run-frame-top-level
(make-application-frame 'superapp)))
(define-superapp-command (com-quit :name t) ()
(frame-exit *application-frame*))
(define-superapp-command (com-add :name t) ((number 'integer))
(incf
(car (elt (numbers *application-frame*)
(cursor *application-frame*)))
number))
(define-superapp-command (com-next :name t) ()
(incf (cursor *application-frame*))
(when (= (cursor *application-frame*)
(length (numbers *application-frame*)))
(setf (cursor *application-frame*) 0)))
(define-superapp-command (com-prev :name t) ()
(decf (cursor *application-frame*))
(when (minusp (cursor *application-frame*))
(setf (cursor *application-frame*)
(1- (length (numbers *application-frame*))))))
(app-main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment