Skip to content

Instantly share code, notes, and snippets.

@moratori
Created Jul 12, 2014
Embed
What would you like to do?
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