🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.epoch.misc
Article #290

Re: Type to window under cursor??

#290
From: Jerry
Date: Thu, 01 Oct 1992 00:26
323 lines
12390 bytes
-> How can I get epoch to type into the buffer window that my
-> mouse pointer is on, instead of having to first click to get the
-> pointer in the current window?  If I move the mouse, it still types
-> in the previously "selected" window.

Wow, I sure wouldn't want this behavior.  Maybe this tip will help:
most new users of Epoch still think in terms of windows instead of
screens.  I find it more convenient to jump from screen to screen
(with only one buffer visible in each) than from window to window, and
buffer to buffer.  Following are some utilities you may find helpful.

C-h u		   run hyper manual browser (from contrib/hyper)
C-h i		   run hyper info browser (from contrib/hyper)

M-+		   highlight-region
M-_		   unhighlight-region

Alt-Copy	   duplicate-screen
Alt-Home	   map-all-screens
Alt-End		   iconify-all-screens
Alt-PgUp	   raise-screen (effectively)  I STILL DON'T UNDERSTAND
Alt-PgDn	   lower-screen (effectively)  WHY THESE ARE NOT INTERACTIVE
Alt-KeyPad 5	   redraw-display (without moving point relative to window)
Alt-KeyPad +	   go to previous screen 
Alt-KeyPad -	   go to next screen
Alt-KeyPad INS	   create-screen
Alt-KeyPad DEL	   remove-screen (effectively) SEE COMPLAINT ABOVE
Alt-KeyPad Enter   find-buffer-other-screen

    and finally!

KeyPad 5	   other-window-or-screen

    so if you have two (or more) windows, it switches windows,
    but if you have only one, it switches screens (cycling through
    however many are not iconified).

Note that the default behavior when auto-raise-screen is nil is dumb:
It assumes that when you do C-z o to switch-screen, you don't want to
see where the cursor just went.  This is fixed by the redefinition of
cursor-to-screen below.  The reason for auto-raise-screen to be not t is
that there is no way (in OpenWindows 2.0) to prevent Epoch jumping to
the top of the workspace whenever the mouse (even briefly) brushes
past it.

This is in $OPENWINHOME/lib/openwin-sys to give me the extra Meta keys
Alt and Alt_Graph

#install Meta keys, XView function keys, AltGraph and Num_Lock as modifiers
xmodmap -e 'add mod1 = Meta_L Meta_R' \
	-e 'add mod2 = F13 F16 F18 F19 F20' \
	-e 'add mod3 = Mode_switch Alt_L' \
	-e 'add mod4 = Num_Lock'  \
	-e 'add mod5 = Multi_key' \
	-e 'keycode 57 = KP_Decimal'

In OpenWindows on a Sun4 keyboard, I use the following bindings:
;; ---------------- epoch special keys ----------------

;; Mask list  
;; normal    = 0
;; shift     = 1
;; caps lock = 2  (lock)
;; control   = 4
;; meta      = 8  (mod1)
;; alt       = 32 (mod3)
;; num lock  = 64 (mod4)

(defun install-epoch-keybindings ()
  "Does what it says.  Requires X server and so must be executed at runtime."
  (progn

(rebind-key "R11" 0 "\C-xo")
(rebind-key "R11" 'lock "\C-xo")

(rebind-key "L6" 'mod3 "\C-z2")
(rebind-key "L6" 34 "\C-z2")
(rebind-key "L6" 96 "\C-z2")
(rebind-key "R7" 'control "\C-z4<")
(rebind-key "R7" 6 "\C-z4<")
(rebind-key "R7" 68 "\C-z4<")
(rebind-key "R7" 'mod3 "\C-z\C-m")
(rebind-key "R7" 34 "\C-z\C-m")
(rebind-key "R7" 96 "\C-z\C-m")
(rebind-key "Up" 'mod3 "\C-z+")
(rebind-key "Up" 34 "\C-z+")
(rebind-key "Up" 96 "\C-z+")
(rebind-key "R9" 'control "\C-z4v")
(rebind-key "R9" 6 "\C-z4v")
(rebind-key "R9" 68 "\C-z4v")
(rebind-key "R9" 'mod3 "\C-zr")
(rebind-key "R9" 34 "\C-zr")
(rebind-key "R9" 96 "\C-zr")
(rebind-key "R11" 'mod3 "\C-z\C-l")
(rebind-key "R11" 34 "\C-z\C-l")
(rebind-key "R11" 96 "\C-z\C-l")
(rebind-key "R13" 'control "\C-z4>")
(rebind-key "R13" 6 "\C-z4>")
(rebind-key "R13" 68 "\C-z4>")
(rebind-key "R13" 'mod3 "\C-z\C-z")
(rebind-key "R13" 34 "\C-z\C-z")
(rebind-key "R13" 96 "\C-z\C-z")
(rebind-key "Down" 'mod3 "\C-z-")
(rebind-key "Down" 34 "\C-z-")
(rebind-key "Down" 96 "\C-z-")
(rebind-key "R15" 'control "\C-z4\C-v")
(rebind-key "R15" 6 "\C-z4\C-v")
(rebind-key "R15" 68 "\C-z4\C-v")
(rebind-key "R15" 'mod3 "\C-zl")
(rebind-key "R15" 34 "\C-zl")
(rebind-key "R15" 96 "\C-zl")
(rebind-key "Insert" 'mod3 "\C-z3")
(rebind-key "Insert" 34 "\C-z3")
(rebind-key "Insert" 96 "\C-z3")
(rebind-key "KP_Enter" 'mod3 "\C-z4b")
(rebind-key "KP_Enter" 34 "\C-z4b")
(rebind-key "KP_Enter" 96 "\C-z4b")
(rebind-key "KP_Subtract" 'mod3 "\C-zO")
(rebind-key "KP_Subtract" 34 "\C-zO")
(rebind-key "KP_Subtract" 96 "\C-zO")
(rebind-key "KP_Add" 'mod3 "\C-u\C-zO")
(rebind-key "KP_Add" 34 "\C-u\C-zO")
(rebind-key "KP_Add" 96 "\C-u\C-zO")
(rebind-key "KP_Decimal" 'mod3 "\C-z0")
(rebind-key "KP_Decimal" 34 "\C-z0")
(rebind-key "KP_Decimal" 96 "\C-z0")

))
;;
;; if dumping in epoch, otherwise not needed
;; (epoch-add-setup-hook 'install-epoch-keybindings)


;; ---------------- epoch utilities ----------------

;; EPOCH initialization file

(setq include-system-name nil)
(setq vertical-drag-inc 2)
(setq auto-raise-screen nil)

(setq target-buffer (get-buffer "*scratch*"))
(define-key esc-map "+" 'highlight-region)
(define-key esc-map "_" 'unhighlight-region)
(define-key global-map "\C-z\C-z" 'iconify-all-screens)
(define-key global-map "\C-z\C-m" 'map-all-screens)
(define-key global-map "\C-z\C-l" 'redraw-display)
(define-key global-map "\C-zO" 'other-screen)
(define-key global-map "\C-z3" 'create-screen)
(define-key ctl-x-map "o" 'other-window-or-screen)
(define-key global-map "\C-z4\C-v" 'scroll-up-other-window-or-screen)
(define-key global-map "\C-z4v" 'scroll-down-other-window-or-screen)
(define-key global-map "\C-z4<" 'beginning-of-buffer-other-window-or-screen)
(define-key global-map "\C-z4>" 'end-of-buffer-other-window-or-screen)

;; sure would have liked to use these functions
;; but they cause epoch to die and crash my window manager in the process
;; you gonna fix this Marc ?
;; (define-key global-map "\C-z+" 'set-bigger-font)
;; (define-key global-map "\C-z-" 'set-smaller-font)

(autoload 'pre-info "hyper-man"
	  "Run info in Epoch with multiple screens" t)

(autoload 'hyper-man-begin "hyper-man"
	  "Run hyper manual to browse unix man pages.")

(define-key help-map "i" 'pre-info)
(define-key help-map "u" 'hyper-man-begin)

(defun iconify-all-screens ()
  "Close all epoch screens (X windows become icons)."
  (interactive)
  (mapcar 'iconify-screen (screen-list)))

(defun map-all-screens ()
  "Open all epoch screens (icons become X windows)."
  (interactive)
  (mapcar 'map-screen (reverse (screen-list t))))

(defun scroll-process-output (process data)
  (princ data (process-mark process))
  (let ((win (epoch::get-buffer-window (process-buffer process))) )
    (if (not (eq win (selected-window)))
	(set-window-point win (process-mark process)))))

;; don't be tempted to use this with compile.el
;; or epoch will go down in flames
(defun scroll-this-process-buffer ()
  (interactive)
  (set-process-filter
   (get-buffer-process (current-buffer)) 'scroll-process-output)
  (if (not epoch::global-update) (setq epoch::global-update t))
  (epoch::set-update t))

(setq comint-exec-hook
  '((lambda ()
     (and running-epoch
       (scroll-this-process-buffer))
     )))

(defun other-screen (&optional arg)
  "Switch to the next mapped (not iconified) screen.
Optional Prefix ARG selects previous screen instead."
  (interactive "P")
  (progn
  (switch-screen
   (if arg (prev-screen)(next-screen)))))

;; since we'll be using multiple screens as well as windows
(defun other-window-or-screen (&optional arg)
  "Switch to other window if more than one.
    Otherwise, switch to previous screen and raise.
Optional ARG selects ARG'th window or next screen instead."
  (interactive "p")
  (if (one-window-p)
      (if (eq arg 1) (other-screen t) (other-screen nil))
    (if arg (other-window arg) (other-window))))

(defun scroll-down-other-window-or-screen (&optional arg)
  "Switch to other window (or screen).  Once there, scroll-down by ARG lines."
  (interactive "P")
  (let ((otherscr (one-window-p))
	(old-screen (current-screen)))
    (if otherscr
	(progn (epoch::select-screen (prev-screen))
	       (if arg (scroll-down arg)
		 (forward-line (- (- (window-height) 1))))
	       (epoch::select-screen old-screen))
      (scroll-other-window (if arg (- arg)(quote -))))))

(defun scroll-up-other-window-or-screen (&optional arg)
  "Switch to other window (or screen).  Once there, scroll-up by ARG lines."
  (interactive "P")
  (let ((otherscr (one-window-p))
	(old-screen (current-screen)))
    (if otherscr
	(progn (epoch::select-screen (prev-screen))
	       (if arg (scroll-up arg)
		 (forward-line (- (window-height) 1)))
	       (epoch::select-screen old-screen))
      (scroll-other-window arg))))

(defun end-of-buffer-other-window-or-screen ()
  "Switch to other window (or screen) then goto end of buffer and come back."
  (interactive)
  (let ((otherscr (one-window-p))
	(old-screen (current-screen)))
    (if otherscr
	(epoch::select-screen (prev-screen)) (other-window 1))
    (goto-char (point-max))
    (if otherscr
	(epoch::select-screen old-screen) (other-window -1))))

(defun beginning-of-buffer-other-window-or-screen ()
  "Switch to other window if more than one.
Otherwise, switch screens.  Once there, goto beginning of buffer."
  (interactive)
  (let ((otherscr (one-window-p))
	(old-screen (current-screen)))
    (if otherscr
	(epoch::select-screen (prev-screen)) (other-window 1))
    (goto-char (point-min))
    (if otherscr
	(epoch::select-screen old-screen) (other-window -1))))

;; make sure cursor movement makes the screen visible.
;; this wouldn't be necessary if _real_ support for
;; nil auto-raise-screen had been built in
(defun cursor-to-screen (scr)
  "Warp cursor to SCREEN, raise and select it."
  (interactive)
   (raise-screen scr)
  (if epoch::cursor-warps-to-screen
      (epoch::warp-mouse (/ (epoch::screen-width scr) 2) 0 scr)))

;; mark.el -- Makes all buffers have a mark
;; 
;; PURPOSE
;;   The interactive function barfs on "\nr" if the region is not set
;;   yet.  I consider this to be a defect in emacs because
;;    1. There is not a "safe" alternative to \nr
;;    2. As a user, I always think that I have a region
;;    3. As a developer, I cannot write functions that use the region in
;;    some cases and not in others.
;;    Perhaps I can get around this by adopting a convention that
;;    all functions that use the region must use it all the time and
;;    must be called by functions that check for the region. (Note that
;;    there is no function that can check for the region without also
;;    generating a disturbing message to the user in case of error.)
;;  
;;    The solution is to be sure that there is always a region!
;;    This should go into the filesys stuff, but for now, I shall
;;    do it using a provided hook.  Hopefully the scribe mode stuff is
;;    loaded before the hook is checked.

(defun push-mark-quietly (&optional location message)
  "An arguementless version of push mark that generates no message by default."
  (push-mark location (not message)))

(if (not (memq 'push-mark-quietly find-file-hooks))
    (setq find-file-hooks (cons 'push-mark-quietly find-file-hooks)))

;; highlight-region for epoch

(defun highlight-region (p1 p2)
   "Highlight the current region in reverse video."
   (interactive "r")
   (let ((highlight-style (make-style)))
	 (set-style-foreground highlight-style (background))
	 (set-style-background highlight-style (foreground))
	 (epoch::add-zone p1 p2  highlight-style)))


(defun unhighlight-region (p1 p2)
   "Unhighlight the current region (if in reverse video)."
   (interactive "r")
   (let ((highlight-style (make-style)))
	 (set-style-foreground highlight-style (foreground))
	 (set-style-background highlight-style (background))
	 (epoch::add-zone p1 p2  highlight-style)))

(setq ispell-highlight t)
Technical Details
Message-ID: <9210010026.AA29652@banach>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!math.ep.utexas.EDU!jerry
References: <e7fr024f23UN01@JUTS.ccc.amdahl.com>

Show Full Headers
Complete Article Headers
Newsgroups: gnu.epoch.misc
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!math.ep.utexas.EDU!jerry
From: jerry@math.ep.utexas.EDU (Jerry)
Subject: Re: Type to window under cursor??
Message-ID: <9210010026.AA29652@banach>
Sender: daemon@cis.ohio-state.edu
Organization: Department of Mathematical Sciences--University of Texas at El Paso
References: <e7fr024f23UN01@JUTS.ccc.amdahl.com>
Distribution: gnu
Date: Thu, 1 Oct 1992 00:26:34 GMT
Lines: 324