- (add-fd-handler (gdk:display-connection-number) :input #'main-iterate-all)
- (setq *periodic-polling-function* #'main-iterate-all)
- (setq *max-event-to-sec* 0)
- (setq *max-event-to-usec* 1000))))
+ #+(or cmu sbcl)
+ (progn
+ (add-fd-handler (gdk:display-connection-number) :input #'main-iterate-all)
+ (setq *periodic-polling-function* #'main-iterate-all)
+ (setq *max-event-to-sec* 0)
+ (setq *max-event-to-usec* *event-poll-interval*))
+ #+(and clisp readline)
+ ;; Readline will call the event hook at most ten times per second
+ (setf readline:event-hook #'main-iterate-all)
+ #+clisp
+ ;; When running in Slime we need to hook into the Swank server
+ ;; to handle events asynchronously
+ (if (find-symbol "WAIT-UNTIL-READABLE" "SWANK")
+ (setf (symbol-function 'swank::wait-until-readable)
+ #'(lambda (stream)
+ (loop
+ (case (socket:socket-status (cons stream :input) 0 *event-poll-interval*)
+ (:input (return t))
+ (:eof (read-char stream))
+ (otherwise (main-iterate-all))))))
+ #-readline(warn "Not running in Slime and Readline support is missing, so the Gtk main loop has to be invoked explicit.")))))