Mercurial > emacs
annotate lisp/textmodes/text-mode.el @ 1717:aa7d6d57504b
* frame.h (struct frame): New fields `can_have_scrollbars' and
`has_vertical_scrollbars'.
(FRAME_CAN_HAVE_SCROLLBARS, FRAME_HAS_VERTICAL_SCROLLBARS): New
accessors, for both the MULTI_FRAME and non-MULTI_FRAME.
(VERTICAL_SCROLLBAR_WIDTH, WINDOW_VERTICAL_SCROLLBAR,
WINDOW_VERTICAL_SCROLLBAR_COLUMN,
WINDOW_VERTICAL_SCROLLBAR_HEIGHT): New macros.
* window.h (struct window): New field `vertical_scrollbar'.
* xterm.h (struct x_display): vertical_scrollbars,
judge_timestamp, vertical_scrollbar_extra: New fields.
(struct scrollbar): New struct.
(VERTICAL_SCROLLBAR_PIXEL_WIDTH, VERTICAL_SCROLLBAR_PIXEL_HEIGHT,
VERTICAL_SCROLLBAR_LEFT_BORDER, VERTICAL_SCROLLBAR_RIGHT_BORDER,
VERTICAL_SCROLLBAR_TOP_BORDER, VERTICAL_SCROLLBAR_BOTTOM_BORDER,
CHAR_TO_PIXEL_WIDTH, CHAR_TO_PIXEL_HEIGHT, PIXEL_TO_CHAR_WIDTH,
PIXEL_TO_CHAR_HEIGHT): New accessors and macros.
* frame.c (make_frame): Initialize the `can_have_scrollbars' and
`has_vertical_scrollbars' fields of the frame.
* term.c (term_init): Note that TERMCAP terminals don't support
scrollbars.
(mouse_position_hook): Document new args.
(set_vertical_scrollbar_hook, condemn_scrollbars_hook,
redeem_scrollbar_hook, judge_scrollbars_hook): New hooks.
* termhooks.h: Declare and document them.
(enum scrollbar_part): New type.
(struct input_event): Describe the new form of the scrollbar_click
event type. Change `part' from a Lisp_Object to an enum
scrollbar_part. Add a new field `scrollbar'.
* keyboard.c (kbd_buffer_get_event): Pass appropriate new
parameters to *mouse_position_hook, and make_lispy_movement.
* xfns.c (x_set_vertical_scrollbar): New function.
(x_figure_window_size): Use new macros to calculate frame size.
(Fx_create_frame): Note that X Windows frames do support scroll
bars. Default to "yes".
* xterm.c: #include <X11/cursorfont.h> and "window.h".
(x_vertical_scrollbar_cursor): New variable.
(x_term_init): Initialize it.
(last_mouse_bar, last_mouse_bar_frame, last_mouse_part,
last_mouse_scroll_range_start, last_mouse_scroll_range_end): New
variables.
(XTmouse_position): Use them to return scrollbar movement events.
Take new arguments, for that purpose.
(x_window_to_scrollbar, x_scrollbar_create,
x_scrollbar_set_handle, x_scrollbar_remove, x_scrollbar_move,
XTset_scrollbar, XTcondemn_scrollbars, XTredeem_scrollbar,
XTjudge_scrollbars, x_scrollbar_expose,
x_scrollbar_background_expose, x_scrollbar_handle_click,
x_scrollbar_handle_motion): New functions to implement scrollbars.
(x_term_init): Set the termhooks.h hooks to point to them.
(x_set_window_size): Use new macros to calculate frame size. Set
vertical_scrollbar_extra field.
(x_make_frame_visible): Use the frame accessor
FRAME_HAS_VERTICAL_SCROLLBARS to decide if we need to map the
frame's subwindows as well.
(XTread_socket): Use new size-calculation macros from xterm.h when
processing ConfigureNotify events.
(x_wm_set_size_hint): Use PIXEL_TO_CHAR_WIDTH and
PIXEL_TO_CHAR_HEIGHT macros.
* ymakefile (xdisp.o): This now depends on termhooks.h.
(xterm.o): This now depends on window.h.
| author | Jim Blandy <jimb@redhat.com> |
|---|---|
| date | Thu, 24 Dec 1992 06:17:18 +0000 |
| parents | ddfd236e2c0c |
| children | 9e7ec92a4fdf |
| rev | line source |
|---|---|
|
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
283
diff
changeset
|
1 ;;; text-mode.el --- text mode, and its idiosyncratic commands. |
|
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
283
diff
changeset
|
2 |
| 841 | 3 ;; Copyright (C) 1985, 1992 Free Software Foundation, Inc. |
| 4 | |
|
775
1ca26ccad38e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
727
diff
changeset
|
5 ;; Maintainer: FSF |
| 36 | 6 |
| 7 ;; This file is part of GNU Emacs. | |
| 8 | |
| 9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
| 10 ;; it under the terms of the GNU General Public License as published by | |
| 727 | 11 ;; the Free Software Foundation; either version 2, or (at your option) |
| 36 | 12 ;; any later version. |
| 13 | |
| 14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
| 15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 ;; GNU General Public License for more details. | |
| 18 | |
| 19 ;; You should have received a copy of the GNU General Public License | |
| 20 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
| 21 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 22 | |
|
775
1ca26ccad38e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
727
diff
changeset
|
23 ;;; Code: |
| 36 | 24 |
| 25 (defvar text-mode-syntax-table nil | |
| 26 "Syntax table used while in text mode.") | |
| 27 | |
| 28 (defvar text-mode-abbrev-table nil | |
| 29 "Abbrev table used while in text mode.") | |
| 30 (define-abbrev-table 'text-mode-abbrev-table ()) | |
| 31 | |
| 32 (if text-mode-syntax-table | |
| 33 () | |
| 34 (setq text-mode-syntax-table (make-syntax-table)) | |
| 35 (modify-syntax-entry ?\" ". " text-mode-syntax-table) | |
| 36 (modify-syntax-entry ?\\ ". " text-mode-syntax-table) | |
| 37 (modify-syntax-entry ?' "w " text-mode-syntax-table)) | |
| 38 | |
| 39 (defvar text-mode-map nil | |
| 40 "Keymap for Text mode. | |
| 41 Many other modes, such as Mail mode, Outline mode and Indented Text mode, | |
| 42 inherit all the commands defined in this map.") | |
| 43 | |
| 44 (if text-mode-map | |
| 45 () | |
| 46 (setq text-mode-map (make-sparse-keymap)) | |
| 47 (define-key text-mode-map "\t" 'tab-to-tab-stop) | |
| 48 (define-key text-mode-map "\es" 'center-line) | |
| 49 (define-key text-mode-map "\eS" 'center-paragraph)) | |
| 50 | |
| 51 | |
| 52 ;(defun non-saved-text-mode () | |
| 53 ; "Like text-mode, but delete auto save file when file is saved for real." | |
| 54 ; (text-mode) | |
| 55 ; (make-local-variable 'delete-auto-save-files) | |
| 56 ; (setq delete-auto-save-files t)) | |
| 57 | |
| 58 (defun text-mode () | |
| 59 "Major mode for editing text intended for humans to read. Special commands:\\{text-mode-map} | |
| 1576 | 60 Turning on Text mode calls the value of the variable `text-mode-hook', |
| 36 | 61 if that value is non-nil." |
| 62 (interactive) | |
| 63 (kill-all-local-variables) | |
| 64 (use-local-map text-mode-map) | |
| 65 (setq mode-name "Text") | |
| 66 (setq major-mode 'text-mode) | |
| 67 (setq local-abbrev-table text-mode-abbrev-table) | |
| 68 (set-syntax-table text-mode-syntax-table) | |
| 69 (run-hooks 'text-mode-hook)) | |
| 70 | |
| 71 (defvar indented-text-mode-map () | |
| 72 "Keymap for Indented Text mode. | |
| 73 All the commands defined in Text mode are inherited unless overridden.") | |
| 74 | |
| 75 (if indented-text-mode-map | |
| 76 () | |
| 283 | 77 ;; Make different definintion for TAB before the one in text-mode-map, but |
| 78 ;; share the rest. | |
| 79 (let ((newmap (make-sparse-keymap))) | |
| 80 (define-key newmap "\t" 'indent-relative) | |
| 81 (setq indented-text-mode-map (nconc newmap text-mode-map)))) | |
| 36 | 82 |
| 83 (defun indented-text-mode () | |
| 84 "Major mode for editing indented text intended for humans to read.\\{indented-text-mode-map} | |
| 1576 | 85 Turning on `indented-text-mode' calls the value of the variable |
| 86 `text-mode-hook', if that value is non-nil." | |
| 36 | 87 (interactive) |
| 88 (kill-all-local-variables) | |
| 89 (use-local-map text-mode-map) | |
| 90 (define-abbrev-table 'text-mode-abbrev-table ()) | |
| 91 (setq local-abbrev-table text-mode-abbrev-table) | |
| 92 (set-syntax-table text-mode-syntax-table) | |
| 93 (make-local-variable 'indent-line-function) | |
| 94 (setq indent-line-function 'indent-relative-maybe) | |
| 95 (use-local-map indented-text-mode-map) | |
| 96 (setq mode-name "Indented Text") | |
| 97 (setq major-mode 'indented-text-mode) | |
| 98 (run-hooks 'text-mode-hook)) | |
| 99 | |
| 100 (defun center-paragraph () | |
| 101 "Center each nonblank line in the paragraph at or after point. | |
| 1576 | 102 See `center-line' for more info." |
| 36 | 103 (interactive) |
| 104 (save-excursion | |
| 105 (forward-paragraph) | |
| 106 (or (bolp) (newline 1)) | |
| 107 (let ((end (point))) | |
| 108 (backward-paragraph) | |
| 109 (center-region (point) end)))) | |
| 110 | |
| 111 (defun center-region (from to) | |
| 112 "Center each nonblank line starting in the region. | |
| 1576 | 113 See `center-line' for more info." |
| 36 | 114 (interactive "r") |
| 115 (if (> from to) | |
| 116 (let ((tem to)) | |
| 117 (setq to from from tem))) | |
| 118 (save-excursion | |
| 119 (save-restriction | |
| 120 (narrow-to-region from to) | |
| 121 (goto-char from) | |
| 122 (while (not (eobp)) | |
| 123 (or (save-excursion (skip-chars-forward " \t") (eolp)) | |
| 124 (center-line)) | |
| 125 (forward-line 1))))) | |
| 126 | |
| 127 (defun center-line () | |
| 128 "Center the line point is on, within the width specified by `fill-column'. | |
| 129 This means adjusting the indentation so that it equals | |
| 130 the distance between the end of the text and `fill-column'." | |
| 131 (interactive) | |
| 132 (save-excursion | |
| 133 (let (line-length) | |
| 134 (beginning-of-line) | |
| 135 (delete-horizontal-space) | |
| 136 (end-of-line) | |
| 137 (delete-horizontal-space) | |
| 138 (setq line-length (current-column)) | |
| 139 (beginning-of-line) | |
| 140 (indent-to | |
| 141 (+ left-margin | |
| 142 (/ (- fill-column left-margin line-length) 2)))))) | |
|
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
283
diff
changeset
|
143 |
|
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
283
diff
changeset
|
144 ;;; text-mode.el ends here |
