annotate lisp/emulators/tpu-extras.el @ 211:78478c60bfcd r20-4b4

Import from CVS: tag r20-4b4
author cvs
date Mon, 13 Aug 2007 10:05:51 +0200
parents 3d6bfa290dbd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; tpu-extras.el --- Scroll margins and free cursor mode for TPU-edt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
3 ;; Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: Rob Riepel <riepel@networking.stanford.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Maintainer: Rob Riepel <riepel@networking.stanford.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Keywords: emulations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 72
diff changeset
10 ;; XEmacs modifications by Kevin Oberman <oberman@es.net>
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 72
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 72
diff changeset
20 ;; GNU General Public License for more details.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 72
diff changeset
23 ;; along with XEmacs; see the file COPYING. If not, write to the
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 72
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 72
diff changeset
25 ;; Boston, MA 02111-1307, USA.
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
26
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 72
diff changeset
27 ;;; Synced up with FSF 19.34 and XEmacs 19.16
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
31 ;; Use the functions defined here to customize TPU-edt to your tastes by
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
32 ;; setting scroll margins and/or turning on free cursor mode. Here's an
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
33 ;; example for your .emacs file.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
34
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
35 ;; (tpu-set-cursor-free) ; Set cursor free.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
36 ;; (tpu-set-scroll-margins "10%" "15%") ; Set scroll margins.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
37
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
38 ;; Scroll margins and cursor binding can be changed from within emacs using
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
39 ;; the following commands:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
40
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
41 ;; tpu-set-scroll-margins or set scroll margins
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
42 ;; tpu-set-cursor-bound or set cursor bound
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
43 ;; tpu-set-cursor-free or set cursor free
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
44
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
45 ;; Additionally, Gold-F toggles between bound and free cursor modes.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
46
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
47 ;; Note that switching out of free cursor mode or exiting TPU-edt while in
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
48 ;; free cursor mode strips trailing whitespace from every line in the file.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
49
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
50
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
51 ;;; Details:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
52
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; The functions contained in this file implement scroll margins and free
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; cursor mode. The following keys and commands are affected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; key/command function scroll cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;; Up-Arrow previous line x x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;; Down-Arrow next line x x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; Right-Arrow next character x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;; Left-Arrow previous character x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; KP0 next or previous line x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; KP7 next or previous page x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;; KP8 next or previous screen x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; KP2 next or previous end-of-line x x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; Control-e current end-of-line x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;; Control-h previous beginning-of-line x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;; Next Scr next screen x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;; Prev Scr previous screen x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;; Search find a string x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; Replace find and replace a string x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; Newline insert a newline x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; Paragraph next or previous paragraph x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;; Auto-Fill break lines on spaces x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;; These functions are not part of the base TPU-edt for the following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;; reasons:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;; Free cursor mode is implemented with the emacs picture-mode functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;; These functions support moving the cursor all over the screen, however,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;; when the cursor is moved past the end of a line, spaces or tabs are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; appended to the line - even if no text is entered in that area. In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;; order for a free cursor mode to work exactly like TPU/edt, this trailing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;; whitespace needs to be dealt with in every function that might encounter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;; it. Such global changes are impractical, however, free cursor mode is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;; too valuable to abandon completely, so it has been implemented in those
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; functions where it serves best.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;; The implementation of scroll margins adds overhead to previously
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;; simple and often used commands. These commands are now responsible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; for their normal operation and part of the display function. There
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;; is a possibility that this display overhead could adversely affect the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;; performance of TPU-edt on slower computers. In order to support the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;; widest range of computers, scroll margin support is optional.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
96 ;; It's actually not known whether the overhead associated with scroll
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
97 ;; margin support is significant. If you find that it is, please send
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;; a note describing the extent of the performance degradation. Be sure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;; to include a description of the platform where you're running TPU-edt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;; Send your note to the address provided by Gold-V.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;; Even with these differences and limitations, these functions implement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;; important aspects of the real TPU/edt. Those who miss free cursor mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;; and/or scroll margins will appreciate these implementations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
109 ;;; Gotta have tpu-edt
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
111 (require 'tpu-edt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;;; Customization variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (defconst tpu-top-scroll-margin 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 "*Scroll margin at the top of the screen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 Interpreted as a percent of the current window size.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (defconst tpu-bottom-scroll-margin 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 "*Scroll margin at the bottom of the screen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 Interpreted as a percent of the current window size.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (defvar tpu-backward-char-like-tpu t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 "*If non-nil, in free cursor mode backward-char (left-arrow) works
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 just like TPU/edt. Otherwise, backward-char will move to the end of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 the previous line when starting from a line beginning.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;;; Global variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (defvar tpu-cursor-free nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 "If non-nil, let the cursor roam free.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;;; Hooks -- Set cursor free in picture mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;;; Clean up when writing a file from cursor free mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
138 (add-hook 'picture-mode-hook 'tpu-set-cursor-free)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (defun tpu-write-file-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 "Eliminate whitespace at ends of lines, if the cursor is free."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (if (and (buffer-modified-p) tpu-cursor-free) (picture-clean)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (or (memq 'tpu-write-file-hook write-file-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (setq write-file-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (cons 'tpu-write-file-hook write-file-hooks)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;;; Utility routines for implementing scroll margins
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (defun tpu-top-check (beg lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 "Enforce scroll margin at the top of screen."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (let ((margin (/ (* (window-height) tpu-top-scroll-margin) 100)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (cond ((< beg margin) (recenter beg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ((< (- beg lines) margin) (recenter margin)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (defun tpu-bottom-check (beg lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 "Enforce scroll margin at the bottom of screen."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (let* ((height (window-height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (margin (+ 1 (/ (* height tpu-bottom-scroll-margin) 100)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;; subtract 1 from height because it includes mode line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (difference (- height margin 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (cond ((> beg difference) (recenter beg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ((> (+ beg lines) difference) (recenter (- margin))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;;; Movement by character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (defun tpu-forward-char (num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 "Move right ARG characters (left if ARG is negative)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (interactive "p")
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 72
diff changeset
172 (setq zmacs-region-stays t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (if tpu-cursor-free (picture-forward-column num) (forward-char num)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (defun tpu-backward-char (num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 "Move left ARG characters (right if ARG is negative)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (interactive "p")
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 72
diff changeset
178 (setq zmacs-region-stays t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (cond ((not tpu-cursor-free)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (backward-char num))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (tpu-backward-char-like-tpu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (picture-backward-column num))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ((bolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (picture-end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (picture-backward-column (1- num)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (picture-backward-column num))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;;; Movement by line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (defun tpu-next-line (num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 "Move to next line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 Prefix argument serves as a repeat count."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (interactive "p")
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 72
diff changeset
197 (setq zmacs-region-stays t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (let ((beg (tpu-current-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (if tpu-cursor-free (or (eobp) (picture-move-down num))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (next-line-internal num))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (tpu-bottom-check beg num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (setq this-command 'next-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (defun tpu-previous-line (num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 "Move to previous line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 Prefix argument serves as a repeat count."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (interactive "p")
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 72
diff changeset
208 (setq zmacs-region-stays t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (let ((beg (tpu-current-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (if tpu-cursor-free (picture-move-up num) (next-line-internal (- num)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (tpu-top-check beg num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (setq this-command 'previous-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (defun tpu-next-beginning-of-line (num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 "Move to beginning of line; if at beginning, move to beginning of next line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 Accepts a prefix argument for the number of lines to move."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (interactive "p")
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 72
diff changeset
218 (setq zmacs-region-stays t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (let ((beg (tpu-current-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (forward-line (- 1 num))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (tpu-top-check beg num)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (defun tpu-next-end-of-line (num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 "Move to end of line; if at end, move to end of next line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 Accepts a prefix argument for the number of lines to move."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (interactive "p")
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 72
diff changeset
228 (setq zmacs-region-stays t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (let ((beg (tpu-current-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (cond (tpu-cursor-free
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (let ((beg (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (if (< 1 num) (forward-line num))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (picture-end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (if (<= (point) beg) (progn (forward-line) (picture-end-of-line)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (forward-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (end-of-line num)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (tpu-bottom-check beg num)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (defun tpu-previous-end-of-line (num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 "Move EOL upward.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 Accepts a prefix argument for the number of lines to move."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (interactive "p")
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 72
diff changeset
244 (setq zmacs-region-stays t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (let ((beg (tpu-current-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (cond (tpu-cursor-free
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (picture-end-of-line (- 1 num)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (end-of-line (- 1 num))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (tpu-top-check beg num)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (defun tpu-current-end-of-line nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 "Move point to end of current line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (interactive)
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 72
diff changeset
255 (setq zmacs-region-stays t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (let ((beg (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (if tpu-cursor-free (picture-end-of-line) (end-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (if (= beg (point)) (message "You are already at the end of a line."))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (defun tpu-forward-line (num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 "Move to beginning of next line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 Prefix argument serves as a repeat count."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (let ((beg (tpu-current-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (next-line-internal num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (tpu-bottom-check beg num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (beginning-of-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (defun tpu-backward-line (num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 "Move to beginning of previous line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 Prefix argument serves as repeat count."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (interactive "p")
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 72
diff changeset
273 (setq zmacs-region-stays t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (let ((beg (tpu-current-line)))
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
275 (or (bolp) (>= 0 num) (setq num (- num 1)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (next-line-internal (- num))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (tpu-top-check beg num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (beginning-of-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 ;;; Movement by paragraph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (defun tpu-paragraph (num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 "Move to the next paragraph in the current direction.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 A repeat count means move that many paragraphs."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (interactive "p")
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 72
diff changeset
287 (setq zmacs-region-stays t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (let* ((left nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (beg (tpu-current-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (height (window-height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (top-percent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (if (= 0 tpu-top-scroll-margin) 10 tpu-top-scroll-margin))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (bottom-percent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (if (= 0 tpu-bottom-scroll-margin) 15 tpu-bottom-scroll-margin))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (top-margin (/ (* height top-percent) 100))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (bottom-up-margin (+ 1 (/ (* height bottom-percent) 100)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (bottom-margin (max beg (- height bottom-up-margin 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (top (save-excursion (move-to-window-line top-margin) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (bottom (save-excursion (move-to-window-line bottom-margin) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (far (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (goto-char bottom) (forward-line (- height 2)) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (cond (tpu-advance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (tpu-next-paragraph num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (cond((> (point) far)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (setq left (save-excursion (forward-line height)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (if (= 0 left) (recenter top-margin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (recenter (- left bottom-up-margin))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (and (> (point) bottom) (recenter bottom-margin)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (tpu-previous-paragraph num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (and (< (point) top) (recenter (min beg top-margin)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 ;;; Movement by page
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (defun tpu-page (num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 "Move to the next page in the current direction.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 A repeat count means move that many pages."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (interactive "p")
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 72
diff changeset
321 (setq zmacs-region-stays t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (let* ((left nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (beg (tpu-current-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (height (window-height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (top-percent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (if (= 0 tpu-top-scroll-margin) 10 tpu-top-scroll-margin))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (bottom-percent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (if (= 0 tpu-bottom-scroll-margin) 15 tpu-bottom-scroll-margin))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (top-margin (/ (* height top-percent) 100))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (bottom-up-margin (+ 1 (/ (* height bottom-percent) 100)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (bottom-margin (max beg (- height bottom-up-margin 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (top (save-excursion (move-to-window-line top-margin) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (bottom (save-excursion (move-to-window-line bottom-margin) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (far (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (goto-char bottom) (forward-line (- height 2)) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (cond (tpu-advance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (forward-page num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (cond((> (point) far)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (setq left (save-excursion (forward-line height)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (if (= 0 left) (recenter top-margin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (recenter (- left bottom-up-margin))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (and (> (point) bottom) (recenter bottom-margin)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (backward-page num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (and (< (point) top) (recenter (min beg top-margin)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 ;;; Scrolling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (defun tpu-scroll-window-down (num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 "Scroll the display down to the next section.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 A repeat count means scroll that many sections."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (interactive "p")
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 72
diff changeset
355 (setq zmacs-region-stays t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (let* ((beg (tpu-current-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (height (1- (window-height)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (lines (* num (/ (* height tpu-percent-scroll) 100))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (next-line-internal (- lines))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (tpu-top-check beg lines)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (defun tpu-scroll-window-up (num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 "Scroll the display up to the next section.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 A repeat count means scroll that many sections."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (interactive "p")
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 72
diff changeset
366 (setq zmacs-region-stays t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (let* ((beg (tpu-current-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (height (1- (window-height)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (lines (* num (/ (* height tpu-percent-scroll) 100))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (next-line-internal lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (tpu-bottom-check beg lines)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 ;;; Replace the TPU-edt internal search function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (defun tpu-search-internal (pat &optional quiet)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 "Search for a string or regular expression."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (let* ((left nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (beg (tpu-current-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (height (window-height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (top-percent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (if (= 0 tpu-top-scroll-margin) 10 tpu-top-scroll-margin))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (bottom-percent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (if (= 0 tpu-bottom-scroll-margin) 15 tpu-bottom-scroll-margin))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (top-margin (/ (* height top-percent) 100))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (bottom-up-margin (+ 1 (/ (* height bottom-percent) 100)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (bottom-margin (max beg (- height bottom-up-margin 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (top (save-excursion (move-to-window-line top-margin) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (bottom (save-excursion (move-to-window-line bottom-margin) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (far (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (goto-char bottom) (forward-line (- height 2)) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (tpu-search-internal-core pat quiet)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (if tpu-searching-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (cond((> (point) far)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (setq left (save-excursion (forward-line height)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (if (= 0 left) (recenter top-margin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (recenter (- left bottom-up-margin))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (and (> (point) bottom) (recenter bottom-margin))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (and (< (point) top) (recenter (min beg top-margin))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 ;;; Replace the newline, newline-and-indent, and do-auto-fill functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (or (fboundp 'tpu-old-newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (fset 'tpu-old-newline (symbol-function 'newline)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (or (fboundp 'tpu-old-do-auto-fill)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (fset 'tpu-old-do-auto-fill (symbol-function 'do-auto-fill)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (or (fboundp 'tpu-old-newline-and-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (fset 'tpu-old-newline-and-indent (symbol-function 'newline-and-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (defun newline (&optional num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 "Insert a newline. With arg, insert that many newlines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 In Auto Fill mode, can break the preceding line if no numeric arg.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 This is the TPU-edt version that respects the bottom scroll margin."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (interactive "p")
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 72
diff changeset
418 (setq zmacs-region-stays t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (let ((beg (tpu-current-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (or num (setq num 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (tpu-old-newline num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (tpu-bottom-check beg num)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (defun newline-and-indent nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 "Insert a newline, then indent according to major mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 Indentation is done using the current indent-line-function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 In programming language modes, this is the same as TAB.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 In some text modes, where TAB inserts a tab, this indents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 to the specified left-margin column. This is the TPU-edt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 version that respects the bottom scroll margin."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (interactive)
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 72
diff changeset
432 (setq zmacs-region-stays t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (let ((beg (tpu-current-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (tpu-old-newline-and-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (tpu-bottom-check beg 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (defun do-auto-fill nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 "TPU-edt version that respects the bottom scroll margin."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (let ((beg (tpu-current-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (tpu-old-do-auto-fill)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (tpu-bottom-check beg 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 ;;; Function to set scroll margins
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
446 ;;;###autoload
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (defun tpu-set-scroll-margins (top bottom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 "Set scroll margins."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 "sEnter top scroll margin (N lines or N%% or RETURN for current value): \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 \nsEnter bottom scroll margin (N lines or N%% or RETURN for current value): ")
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 72
diff changeset
452 (setq zmacs-region-stays t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 ;; set top scroll margin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (or (string= top "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (if (string= "%" (substring top -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (setq tpu-top-scroll-margin (string-to-int top))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (setq tpu-top-scroll-margin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (/ (1- (+ (* (string-to-int top) 100) (window-height)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (window-height)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 ;; set bottom scroll margin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (or (string= bottom "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (if (string= "%" (substring bottom -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (setq tpu-bottom-scroll-margin (string-to-int bottom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (setq tpu-bottom-scroll-margin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (/ (1- (+ (* (string-to-int bottom) 100) (window-height)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (window-height)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 ;; report scroll margin settings if running interactively
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (and (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (message "Scroll margins set. Top = %s%%, Bottom = %s%%"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 tpu-top-scroll-margin tpu-bottom-scroll-margin)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 ;;; Functions to set cursor bound or free
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
475 ;;;###autoload
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (defun tpu-set-cursor-free nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 "Allow the cursor to move freely about the screen."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (interactive)
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 72
diff changeset
479 (setq zmacs-region-stays t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (setq tpu-cursor-free t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (substitute-key-definition 'tpu-set-cursor-free
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 'tpu-set-cursor-bound
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 GOLD-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (message "The cursor will now move freely about the screen."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
486 ;;;###autoload
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (defun tpu-set-cursor-bound nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 "Constrain the cursor to the flow of the text."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (interactive)
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 72
diff changeset
490 (setq zmacs-region-stays t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (picture-clean)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (setq tpu-cursor-free nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (substitute-key-definition 'tpu-set-cursor-bound
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 'tpu-set-cursor-free
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 GOLD-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (message "The cursor is now bound to the flow of your text."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 ;;; tpu-extras.el ends here