(define (buffer-window/redraw! window)
(if (%window-debug-trace window)
((%window-debug-trace window) 'window window 'force-redraw!))
- (if (tty-screen? (%window-saved-screen window))
- (tty-screen/buffer-window/redraw! window)))
-
-(define (tty-screen/buffer-window/redraw! window)
(let ((mask (set-interrupt-enables! interrupt-mask/gc-ok)))
(%set-window-force-redraw?! window #t)
(%recache-window-buffer-local-variables! window)
(%clear-window-incremental-redisplay-state! window))
(define (%clear-window-incremental-redisplay-state! window)
+ (if (tty-screen? (%window-saved-screen window))
+ (%%clear-window-incremental-redisplay-state! window)))
+
+(define (%%clear-window-incremental-redisplay-state! window)
(if (%window-start-outline window)
(begin
(deallocate-outlines! window
(if (not inferior-thread-changes?)
(begin
(set! inferior-thread-changes? #t)
- (signal-thread-event editor-thread #f))))
+ (hook/signal-inferior-thread-output!))))
+
+(define (signal-inferior-thread-output!)
+ (signal-thread-event editor-thread #f))
+
+(define hook/signal-inferior-thread-output! signal-inferior-thread-output!)
(define (accept-thread-output)
(with-interrupt-mask interrupt-mask/gc-ok
(parent (edwin screen))
(export (edwin)
resize-screen)
+ (import (edwin keyboard)
+ keyboard-peek-busy-no-hang)
(import (runtime primitive-io)
channel-type=terminal?
have-select?
screen-xterm
xterm-screen/set-icon-name
xterm-screen/set-name)
+ (import (edwin keyboard)
+ keyboard-peek-busy-no-hang)
(initialization (initialize-package!)))
(define-package (edwin x-keys)
screen-char-height
screen-pel-width
screen-pel-height)
+ (import (edwin keyboard)
+ keyboard-peek-busy-no-hang)
(import (runtime os2-window-primitives)
button-event-type:down
button-event/flags
(begin
(string-set! image image-index (string-ref picture i))
(loop (fix:+ i 1) (fix:+ image-index 1))))))))))
+\f
+(define (group-line-image! group start end
+ image image-start image-end
+ tab-width column-offset char-image-strings
+ receiver)
+ ;; Like GROUP-IMAGE!, but stops at a line ending. RECEIVER will be
+ ;; called with the index of the next newline character, or END.
+ (let ((text (group-text group))
+ (gap-start (group-gap-start group))
+ (gap-end (group-gap-end group))
+ (gap-length (group-gap-length group)))
+ (cond ((fix:<= end gap-start)
+ (substring-line-image! text start end
+ image image-start image-end
+ tab-width column-offset char-image-strings
+ receiver))
+ ((fix:<= gap-start start)
+ (substring-line-image! text
+ (fix:+ start gap-length)
+ (fix:+ end gap-length)
+ image image-start image-end
+ tab-width column-offset char-image-strings
+ (lambda (text-index image-index)
+ (receiver (fix:- text-index gap-length) image-index))))
+ (else
+ (substring-line-image!
+ text start gap-start
+ image image-start image-end
+ tab-width column-offset char-image-strings
+ (lambda (text-index image-index)
+ (cond ((fix:< text-index gap-start)
+ (receiver text-index image-index))
+ ((and (fix:< start text-index)
+ (char=? #\newline
+ (xstring-ref text (fix:-1+ text-index))))
+ (receiver text-index image-index))
+ ((fix:= image-index image-end)
+ (receiver text-index image-index))
+ (else
+ (substring-line-image!
+ text gap-end (fix:+ end gap-length)
+ image image-index image-end
+ tab-width column-offset char-image-strings
+ (lambda (text-index image-index)
+ (receiver (fix:- text-index gap-length)
+ image-index)))))))))))
+(define (substring-line-image! string string-start string-end
+ image image-start image-end
+ tab-width column-offset char-image-strings
+ receiver)
+ (let loop ((string-index string-start) (image-index image-start))
+ (if (or (fix:= image-index image-end)
+ (fix:= string-index string-end))
+ (receiver string-index image-index)
+ (let ((char (xstring-ref string string-index)))
+ (cond ((char=? char #\newline)
+ (receiver (fix:1+ string-index) image-index))
+ ((and (char=? char #\tab) tab-width)
+ (let* ((n (fix:- tab-width
+ (fix:remainder (fix:+ column-offset
+ image-index)
+ tab-width)))
+ (end (fix:+ image-index n))
+ (min-end (if (fix:< end image-end) end image-end)))
+ (do ((image-index image-index (fix:+ image-index 1)))
+ ((fix:= image-index min-end)
+ (if (fix:<= end image-end)
+ (loop (fix:1+ string-index) end)
+ (receiver string-index image-end)))
+ (string-set! image image-index #\space))))
+ (else
+ (let* ((image-string (vector-ref char-image-strings
+ (char->integer char)))
+ (image-len (string-length image-string))
+ (end (fix:+ image-index image-len))
+ (min-end (if (fix:< end image-end) end image-end)))
+ (do ((image-index image-index (fix:1+ image-index))
+ (i 0 (fix:1+ i)))
+ ((fix:= image-index min-end)
+ (if (fix:<= end image-end)
+ (loop (fix:1+ string-index) end)
+ (receiver string-index image-index)))
+ (string-set! image image-index
+ (string-ref image-string i))))))))))
(loop))))))
(define (keyboard-peek-no-hang)
- (handle-simple-events (editor-peek-no-hang current-editor) #t))
+ (handle-simple-events (lambda () ((editor-peek-no-hang current-editor) 0))
+ #t))
(define (handle-simple-events thunk discard?)
(let loop ()
(define read-key-timeout/fast 500)
(define read-key-timeout/slow 2000)
+(define (keyboard-peek-busy-no-hang peek timeout)
+ ;; For screens that can only PEEK-no-hang for 0 seconds.
+ (let* ((start (real-time-clock))
+ (end (+ start timeout)))
+ (let loop ()
+ (or (peek)
+ (let ((now (real-time-clock)))
+ (if (< now end)
+ (loop)
+ #f))))))
+
(define (keyboard-read-1 reader discard?)
(remap-alias-key
(handle-simple-events
(lambda ()
(let ((peek-no-hang (editor-peek-no-hang current-editor)))
- (if (not (peek-no-hang))
+ (if (not (peek-no-hang 0))
(begin
(if (let ((interval (ref-variable auto-save-interval))
(count auto-save-keystroke-count))
(do-auto-save)
(set! auto-save-keystroke-count 0)))
(update-screens! #f)))
- (let ((wait
- (lambda (timeout)
- (let ((t (+ (real-time-clock) timeout)))
- (let loop ()
- (cond ((peek-no-hang) #f)
- ((>= (real-time-clock) t) #t)
- (else (loop))))))))
- ;; Perform the appropriate juggling of the minibuffer message.
- (cond ((within-typein-edit?)
- (if message-string
- (begin
- (wait read-key-timeout/slow)
- (set! message-string #f)
- (set! message-should-be-erased? #f)
- (clear-current-message!))))
- ((and (or message-should-be-erased?
- (and command-prompt-string
- (not command-prompt-displayed?)))
- (wait read-key-timeout/fast))
- (set! message-string #f)
- (set! message-should-be-erased? #f)
- (if command-prompt-string
- (begin
- (set! command-prompt-displayed? #t)
- (set-current-message! command-prompt-string))
- (clear-current-message!)))))
+ ;; Perform the appropriate juggling of the minibuffer message.
+ (cond ((within-typein-edit?)
+ (if message-string
+ (begin
+ (peek-no-hang read-key-timeout/slow)
+ (set! message-string #f)
+ (set! message-should-be-erased? #f)
+ (clear-current-message!))))
+ ((and (or message-should-be-erased?
+ (and command-prompt-string
+ (not command-prompt-displayed?)))
+ (not (peek-no-hang read-key-timeout/fast)))
+ (set! message-string #f)
+ (set! message-should-be-erased? #f)
+ (if command-prompt-string
+ (begin
+ (set! command-prompt-displayed? #t)
+ (set-current-message! command-prompt-string))
+ (clear-current-message!))))
(reader)))
discard?)))
\ No newline at end of file
(setup-pending 'IN-UPDATE)
pending)
- (define (peek-no-hang)
- (setup-pending #f)
- pending)
+ (define (peek-no-hang timeout)
+ (keyboard-peek-busy-no-hang
+ (lambda ()
+ (setup-pending #f)
+ pending)
+ timeout))
(define (peek)
(setup-pending #t)
(if (null? (cdr queue))
(set-car! queue tail)
(set-cdr! (cdr queue) tail))
- (set-cdr! queue tail))))))))
+ (set-cdr! queue tail))))
+ (if hook/inferior-process-output (hook/inferior-process-output))))))
+
+(define hook/inferior-process-output #f)
(define (process-output-available?)
(not (null? (car process-input-queue))))
(lambda () ;halt-update?
(or (fix:< start end)
(read-char #f)))
- (lambda () ;peek-no-hang
- (or (parse-key)
- (let ((event (read-event #f)))
- (if (fix:fixnum? event)
- (begin
- (process-change-event event)
- #f)
- event))))
+ (lambda (timeout) ;peek-no-hang
+ (keyboard-peek-busy-no-hang
+ (lambda ()
+ (or (parse-key)
+ (let ((event (read-event #f)))
+ (if (fix:fixnum? event)
+ (begin
+ (process-change-event event)
+ #f)
+ event))))
+ timeout))
(lambda () ;peek
(or (parse-key)
(guarantee-result)))
(values (lambda () ;halt-update?
(or pending-result
(probe 'IN-UPDATE)))
- (lambda () ;peek-no-hang
- (or pending-result
- (probe #f)))
+ (lambda (timeout) ;peek-no-hang
+ (keyboard-peek-busy-no-hang
+ (lambda ()
+ (or pending-result
+ (probe #f)))
+ timeout))
(lambda () ;peek
(or pending-result
(let ((result (get-next-event #t)))
(or pending-result
(fix:< start end)
(probe 'IN-UPDATE)))
- (lambda () ;peek-no-hang
- (or pending-result
- (fix:< start end)
- (probe #f)))
+ (lambda (timeout) ;peek-no-hang
+ (keyboard-peek-busy-no-hang
+ (lambda ()
+ (or pending-result
+ (and (fix:< start end)
+ (string-ref string start))
+ (probe #f)))
+ timeout))
(lambda () ;peek
(or pending-result
(if (fix:< start end)