Skip to content

Commit 651d9e7

Browse files
committed
Idle example, put some generated by org-mode notice for great sanity
1 parent 2e0617d commit 651d9e7

File tree

16 files changed

+122
-2
lines changed

16 files changed

+122
-2
lines changed

README.org

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ bindings, e.g. ~--dynamic-space-size 2048~
5858
* Hello, World!
5959

6060
#+begin_src lisp :results silent :export none :tangle examples/hello.lisp
61+
;;; Generated from org-mode, do not edit
62+
6163
(eval-when (:compile-toplevel :load-toplevel :execute)
6264
(ql:quickload "iup"))
6365

@@ -96,6 +98,8 @@ bindings, e.g. ~--dynamic-space-size 2048~
9698
** Simple Example
9799

98100
#+begin_src lisp :results silent :export none :tangle examples/callback.lisp
101+
;;; Generated from org-mode, do not edit
102+
99103
(eval-when (:compile-toplevel :load-toplevel :execute)
100104
(ql:quickload "iup"))
101105

@@ -169,12 +173,14 @@ bindings, e.g. ~--dynamic-space-size 2048~
169173

170174
[[./docs/screenshots/callback-3.png]] [[./docs/screenshots/callback-4.png]]
171175

172-
** Close Over Handle Variables
176+
** Color Mixer
173177

174178
Consider capturing state by creating a closure over the controls that
175179
make up state:
176180

177181
#+begin_src lisp :results silent :export none :tangle examples/mixer.lisp
182+
;;; Generated from org-mode, do not edit
183+
178184
(eval-when (:compile-toplevel :load-toplevel :execute)
179185
(ql:quickload "iup"))
180186

@@ -235,6 +241,77 @@ make up state:
235241

236242
[[./docs/screenshots/mixer-02.png]]
237243

244+
* Idle Action
245+
246+
#+begin_src lisp :results silent :export none :tangle examples/idle.lisp
247+
;;; Generated from org-mode, do not edit
248+
249+
(eval-when (:compile-toplevel :load-toplevel :execute)
250+
(ql:quickload "iup"))
251+
252+
(defpackage #:iup-examples.idle
253+
(:use #:common-lisp)
254+
(:export #:idle))
255+
256+
(in-package #:iup-examples.idle)
257+
#+end_src
258+
259+
There is a global callback for running functions when IUP event loop
260+
is idle. See also [[https://webserver2.tecgraf.puc-rio.br/iup/en/call/iup_idle_action.html][IUP: Idle Action]]. In Lisp, it can be set using
261+
~(SETF IUP:IDLE-ACTION)~. Note: Idle actions run a lot more often than
262+
you'd expect. Try the following example application to get an idea for
263+
just how often.
264+
265+
An idle action function should return ~IUP:+DEFAULT+~, ~IUP:+CLOSE+~
266+
or ~IUP:+IGNORE+~. ~IUP:+DEFAULT~ will cause the idle action function
267+
to be called repeatedly. ~IUP:+IGNORE+~ will run idle action
268+
once. ~IUP:+CLOSE+~ will exit the event loop.
269+
270+
#+begin_src lisp :results silent :tangle examples/idle.lisp
271+
(defun idle ()
272+
(iup:with-iup ()
273+
(let* ((counter (iup:label :fontsize 24
274+
:title 0
275+
:expand :yes
276+
:alignment :acenter))
277+
(start-button (iup:button :title "&Start" :expand :horizontal))
278+
(stop-button (iup:button :title "S&top" :expand :horizontal))
279+
(vbox (iup:vbox (list counter
280+
(iup:hbox (list start-button stop-button)
281+
:cgap 5))
282+
:margin "5x5"))
283+
(dialog (iup:dialog vbox
284+
:title (format nil "Idle Example on ~A" (lisp-implementation-type))
285+
:size "QUARTERxQUARTER")))
286+
(setf (iup:callback start-button :action)
287+
(lambda (handle)
288+
(setf (iup:idle-action)
289+
(lambda ()
290+
(setf (iup:attribute counter :title)
291+
(1+ (iup:attribute counter :title 'number)))
292+
iup:+default+))
293+
iup:+default+))
294+
(setf (iup:callback stop-button :action)
295+
(lambda (handle)
296+
(setf (iup:idle-action) nil)
297+
iup:+default+))
298+
(iup:show dialog)
299+
(iup:main-loop))))
300+
#+end_src
301+
302+
#+begin_src lisp :results silent :export none :tangle examples/idle.lisp
303+
#-sbcl (idle)
304+
305+
,#+sbcl
306+
(sb-int:with-float-traps-masked
307+
(:divide-by-zero :invalid)
308+
(idle))
309+
#+end_src
310+
311+
[[./docs/screenshots/idle-01.png]]
312+
313+
[[./docs/screenshots/idle-02.png]]
314+
238315
* Canvas
239316

240317
In this example, we'll port the Sierpinski Carpet fractal that
@@ -249,6 +326,8 @@ IUP:CALLBACK)~. ~*LEVELS*~ will keep track how deep to draw the
249326
fractal.
250327

251328
#+begin_src lisp :results silent :export none :tangle examples/sierpinski.lisp
329+
;;; Generated from org-mode, do not edit
330+
252331
(eval-when (:compile-toplevel :load-toplevel :execute)
253332
(ql:quickload '("iup" "iup-cd" "cd")))
254333

@@ -419,6 +498,8 @@ automatically loaded. The Lisp bindings do the same thing, so to use
419498
it, we need to depend on ~IUP-CONTROLS~.
420499

421500
#+begin_src lisp :results silent :export none :tangle examples/cells.lisp
501+
;;; Generated from org-mode, do not edit
502+
422503
(eval-when (:compile-toplevel :load-toplevel :execute)
423504
(ql:quickload '("iup" "iup-controls" "cd")))
424505

@@ -506,6 +587,8 @@ When out click callback is called:
506587
* Detachable Box
507588

508589
#+begin_src lisp :results silent :export none :tangle examples/detached.lisp
590+
;;; Generated from org-mode, do not edit
591+
509592
(eval-when (:compile-toplevel :load-toplevel :execute)
510593
(ql:quickload "iup"))
511594

@@ -593,6 +676,8 @@ Demonstrates the use of ~(SETF IUP:ATTRIBUTE)~ for setting attributes
593676
not available via control's constructor function.
594677

595678
#+begin_src lisp :results silent :export none :tangle examples/tabs.lisp
679+
;;; Generated from org-mode, do not edit
680+
596681
(eval-when (:compile-toplevel :load-toplevel :execute)
597682
(ql:quickload "iup"))
598683

@@ -660,6 +745,8 @@ the IUP/OpenGL integration points here. It suffices to say, we've got
660745
a function ~CUBE~ which draws OpenGL things to the current buffer.
661746

662747
#+begin_src lisp :export none :results silent :tangle examples/cube.lisp
748+
;;; Generated from org-mode, do not edit
749+
663750
(eval-when (:compile-toplevel :load-toplevel :execute)
664751
(ql:quickload '("iup" "iup-gl" "cl-opengl" "cl-glu")))
665752

@@ -785,6 +872,8 @@ goes one step further by allowing the tree to be expanded recursively
785872
as branches open.
786873

787874
#+begin_src lisp :results silent :export none :tangle examples/tree.lisp
875+
;;; Generated from org-mode, do not edit
876+
788877
(eval-when (:compile-toplevel :load-toplevel :execute)
789878
(ql:quickload '("iup" "iup-controls" "uiop")))
790879

@@ -853,6 +942,8 @@ IUP includes a number of dialogs, including one that embeds the
853942
[[https://www.scintilla.org/][Scintilla]] editor control.
854943

855944
#+begin_src lisp :results silent :tangle examples/dialogs.lisp
945+
;;; Generated from org-mode, do not edit
946+
856947
(eval-when (:compile-toplevel :load-toplevel :execute)
857948
(ql:quickload '("iup" "iup-scintilla")))
858949

@@ -1061,6 +1152,8 @@ system provides support in our IUP bindings for interoperability with
10611152
[[http://webserver2.tecgraf.puc-rio.br/im/][IM]], an imaging toolkit, also by Tecgraf.
10621153

10631154
#+begin_src lisp :results silent :export none :tangle examples/icon.lisp
1155+
;;; Generated from org-mode, do not edit
1156+
10641157
(eval-when (:compile-toplevel :load-toplevel :execute)
10651158
(ql:quickload '("iup" "iup-im")))
10661159

@@ -1109,6 +1202,8 @@ IM supports a large number of formats. Here we use a .ICO file.
11091202
** File Drag and Drop from Applications
11101203

11111204
#+begin_src lisp :results silent :export none :tangle examples/drophash.lisp
1205+
;;; Generated from org-mode, do not edit
1206+
11121207
(eval-when (:compile-toplevel :load-toplevel :execute)
11131208
(ql:quickload '("iup" "ironclad")))
11141209

docs/screenshots/idle-01.png

9.56 KB
Loading

docs/screenshots/mixer-01.png

10.9 KB
Loading

examples/callback.lisp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
;;; Generated from org-mode, do not edit
2+
13
(eval-when (:compile-toplevel :load-toplevel :execute)
24
(ql:quickload "iup"))
35

examples/cells.lisp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
;;; Generated from org-mode, do not edit
2+
13
(eval-when (:compile-toplevel :load-toplevel :execute)
24
(ql:quickload '("iup" "iup-controls" "cd")))
35

examples/cube.lisp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
;;; Generated from org-mode, do not edit
2+
13
(eval-when (:compile-toplevel :load-toplevel :execute)
24
(ql:quickload '("iup" "iup-gl" "cl-opengl" "cl-glu")))
35

examples/detached.lisp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
;;; Generated from org-mode, do not edit
2+
13
(eval-when (:compile-toplevel :load-toplevel :execute)
24
(ql:quickload "iup"))
35

examples/dialogs.lisp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
;;; Generated from org-mode, do not edit
2+
13
(eval-when (:compile-toplevel :load-toplevel :execute)
24
(ql:quickload '("iup" "iup-scintilla")))
35

examples/drophash.lisp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
;;; Generated from org-mode, do not edit
2+
13
(eval-when (:compile-toplevel :load-toplevel :execute)
24
(ql:quickload '("iup" "ironclad")))
35

examples/hello.lisp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
;;; Generated from org-mode, do not edit
2+
13
(eval-when (:compile-toplevel :load-toplevel :execute)
24
(ql:quickload "iup"))
35

0 commit comments

Comments
 (0)