From 0ab5dd5794f6e28092053af7c97d62cbd3ea0f50 Mon Sep 17 00:00:00 2001 From: "Taylor R. Campbell" Date: Sun, 25 Dec 2005 17:04:39 +0000 Subject: [PATCH] Implement SIGWINCH handler so that Edwin console screens can resize themselves if their enclosing terminals are resized. This is accomplished by: - allocating a new interrupt, INT_Global_3, to mean that the console was resized; - installing a SIGWINCH handler to request an INT_Global_3 interrupt; - introducing a new event distributor, EVENT:CONSOLE-RESIZE, which the run-time system's INT_Global_3 handler invokes; and - adding edwin/tterm.scm's RESIZE-SCREEN as an event receiver to EVENT:CONSOLE-RESIZE whenever an Edwin console screen is entered, and removing it whenever a console screen is exited. --- v7/src/edwin/tterm.scm | 4 +++- v7/src/microcode/osscheme.c | 8 +++++++- v7/src/microcode/osscheme.h | 3 ++- v7/src/microcode/uxsig.c | 12 +++++++++++- v7/src/runtime/intrpt.scm | 17 +++++++++++++++-- v7/src/runtime/runtime.pkg | 4 +++- 6 files changed, 41 insertions(+), 7 deletions(-) diff --git a/v7/src/edwin/tterm.scm b/v7/src/edwin/tterm.scm index c846dc192..f89e01bfc 100644 --- a/v7/src/edwin/tterm.scm +++ b/v7/src/edwin/tterm.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: tterm.scm,v 1.41 2005/10/23 21:07:19 cph Exp $ +$Id: tterm.scm,v 1.42 2005/12/25 17:04:39 riastradh Exp $ Copyright 1990,1991,1993,1994,1998,1999 Massachusetts Institute of Technology Copyright 2001,2002,2003,2004,2005 Massachusetts Institute of Technology @@ -491,11 +491,13 @@ USA. unspecific) (define (console-enter! screen) + (add-event-receiver! event:console-resize resize-screen) (maybe-output screen (ts-enter-termcap-mode (screen-description screen))) (set-screen-cursor-x! screen false) (set-screen-cursor-y! screen false)) (define (console-exit! screen) + (remove-event-receiver! event:console-resize resize-screen) (let ((description (screen-description screen))) (move-cursor screen 0 (fix:-1+ (screen-y-size screen))) (exit-standout-mode screen) diff --git a/v7/src/microcode/osscheme.c b/v7/src/microcode/osscheme.c index ca45812a1..5091aec43 100644 --- a/v7/src/microcode/osscheme.c +++ b/v7/src/microcode/osscheme.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: osscheme.c,v 1.14 2003/02/14 18:28:22 cph Exp $ +$Id: osscheme.c,v 1.15 2005/12/25 17:04:39 riastradh Exp $ Copyright (c) 1990-2000, 2002 Massachusetts Institute of Technology @@ -81,6 +81,12 @@ DEFUN_VOID (test_and_clear_attention_interrupt) #endif /* __OS2__ */ +void +DEFUN_VOID (request_console_resize_interrupt) +{ + REQUEST_INTERRUPT (INT_Global_3); +} + void DEFUN_VOID (request_character_interrupt) { diff --git a/v7/src/microcode/osscheme.h b/v7/src/microcode/osscheme.h index e6c20b607..6e12a891c 100644 --- a/v7/src/microcode/osscheme.h +++ b/v7/src/microcode/osscheme.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: osscheme.h,v 1.13 2003/02/14 18:28:22 cph Exp $ +$Id: osscheme.h,v 1.14 2005/12/25 17:04:39 riastradh Exp $ Copyright (c) 1990-2000 Massachusetts Institute of Technology @@ -56,6 +56,7 @@ extern void EXFUN (request_attention_interrupt, (void)); extern int EXFUN (test_and_clear_attention_interrupt, (void)); #endif /* __OS2__ */ +extern void EXFUN (request_console_resize_interrupt, (void)); extern void EXFUN (request_character_interrupt, (void)); extern void EXFUN (request_timer_interrupt, (void)); extern void EXFUN (request_suspend_interrupt, (void)); diff --git a/v7/src/microcode/uxsig.c b/v7/src/microcode/uxsig.c index dbbfb0e93..a8871a0f1 100644 --- a/v7/src/microcode/uxsig.c +++ b/v7/src/microcode/uxsig.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: uxsig.c,v 1.42 2005/07/04 13:51:19 cph Exp $ +$Id: uxsig.c,v 1.43 2005/12/25 17:04:39 riastradh Exp $ Copyright 1990,1991,1992,1993,1994,1996 Massachusetts Institute of Technology Copyright 2000,2001,2005 Massachusetts Institute of Technology @@ -494,6 +494,15 @@ DEFUN_VOID (OS_restartable_exit) stop_signal_default (SIGTSTP); } +static +DEFUN_STD_HANDLER (sighnd_console_resize, +{ + extern void EXFUN (UX_initialize_tty, (void)); + UX_initialize_tty (); + request_console_resize_interrupt (); +}) + + /* The following conditionalization would more naturally be expressed by conditionalizing the code inside the handler, but the Sun compiler won't accept this conditionalization. */ @@ -706,6 +715,7 @@ DEFUN_VOID (UX_initialize_signals) bind_handler (SIGSYS, sighnd_software_trap); bind_handler (SIGABRT, sighnd_software_trap); bind_handler (SIGPROF, sighnd_software_trap); + bind_handler (SIGWINCH, sighnd_console_resize); } { struct signal_descriptor * scan = signal_descriptors; diff --git a/v7/src/runtime/intrpt.scm b/v7/src/runtime/intrpt.scm index 225b91bf7..30dbdd10e 100644 --- a/v7/src/runtime/intrpt.scm +++ b/v7/src/runtime/intrpt.scm @@ -1,9 +1,9 @@ #| -*-Scheme-*- -$Id: intrpt.scm,v 14.25 2004/10/01 03:39:02 cph Exp $ +$Id: intrpt.scm,v 14.26 2005/12/25 17:04:39 riastradh Exp $ Copyright 1986,1987,1988,1990,1991,1992 Massachusetts Institute of Technology -Copyright 1993,1994,2004 Massachusetts Institute of Technology +Copyright 1993,1994,2004,2005 Massachusetts Institute of Technology This file is part of MIT/GNU Scheme. @@ -36,6 +36,7 @@ USA. (fixed-objects-vector-slot 'INTERRUPT-MASK-VECTOR)) (set! index:termination-vector (fixed-objects-vector-slot 'MICROCODE-TERMINATIONS-PROCEDURES)) + (set! event:console-resize (make-event-distributor)) (set! hook/clean-input/flush-typeahead false) (set! hook/clean-input/keep-typeahead false) (set! hook/^B-interrupt false) @@ -71,6 +72,7 @@ USA. (define-integrable character-slot 4) (define-integrable after-gc-slot 5) (define-integrable timer-slot 6) +(define-integrable console-resize-slot 7) (define-integrable suspend-slot 8) ;; Room for Descartes profiler interrupt handlers (define-integrable illegal-interrupt-slot 15) @@ -121,6 +123,12 @@ USA. ;; prevent us from getting into a loop just running the daemons. (clear-interrupts! interrupt-bit/after-gc)) +(define event:console-resize) +(define (console-resize-handler interrupt-code interrupt-enables) + interrupt-code interrupt-enables + (clear-interrupts! interrupt-bit/global-3) + (event-distributor/invoke! event:console-resize)) + (define ((illegal-interrupt-handler interrupt-bit) interrupt-code interrupt-enables) (clear-interrupts! interrupt-bit) @@ -241,6 +249,11 @@ USA. (vector-set! interrupt-mask-vector suspend-slot interrupt-mask/timer-ok) + (vector-set! system-interrupt-vector console-resize-slot + console-resize-handler) + (vector-set! interrupt-mask-vector console-resize-slot + interrupt-mask/all) + (vector-set! termination-vector (microcode-termination 'GC-OUT-OF-SPACE) gc-out-of-space-handler) diff --git a/v7/src/runtime/runtime.pkg b/v7/src/runtime/runtime.pkg index b1a743cfb..5874bf535 100644 --- a/v7/src/runtime/runtime.pkg +++ b/v7/src/runtime/runtime.pkg @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: runtime.pkg,v 14.570 2005/12/23 04:15:45 cph Exp $ +$Id: runtime.pkg,v 14.571 2005/12/25 17:04:39 riastradh Exp $ Copyright 1988,1989,1990,1991,1992,1993 Massachusetts Institute of Technology Copyright 1994,1995,1996,1997,1998,1999 Massachusetts Institute of Technology @@ -2044,6 +2044,8 @@ USA. (define-package (runtime interrupt-handler) (files "intrpt") (parent (runtime)) + (export () + event:console-resize) (export (runtime emacs-interface) hook/^G-interrupt hook/clean-input/flush-typeahead) -- 2.25.1