Created
July 12, 2014 14:43
-
-
Save moratori/12787650a460ad6a3ce9 to your computer and use it in GitHub Desktop.
clim app4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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