Mercurial > emacs
annotate lisp/compare-w.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 | 213978acbc1e |
| children | eea183a35396 |
| rev | line source |
|---|---|
|
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
1 ;;; compare-w.el --- compare text between windows for Emacs. |
|
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
2 |
| 845 | 3 ;; Copyright (C) 1986, 1989 Free Software Foundation, Inc. |
| 4 | |
|
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
5 ;; Maintainer: FSF |
| 257 | 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 | |
|
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
11 ;; the Free Software Foundation; either version 2, or (at your option) |
| 257 | 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 | |
|
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
23 ;;; Code: |
|
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
24 |
| 257 | 25 (defvar compare-windows-whitespace " \t\n" |
| 26 "*String of characters considered whitespace for \\[compare-windows]. | |
| 27 Changes in whitespace are optionally ignored. | |
| 28 | |
| 29 The value of `compare-windows-whitespace' may instead be a function; this | |
| 30 function is called in each buffer, with point at the current scanning point. | |
| 31 The function's job is to categorize any whitespace around (including before) | |
| 32 point; it should also advance past any whitespace. | |
| 33 | |
| 34 The function is passed one argument, the point where `compare-windows' | |
| 35 was originally called; it should not consider any text before that point. | |
| 36 If the function returns the same value for both buffers, then the | |
| 37 whitespace is considered to match, and is skipped.") | |
| 38 | |
| 39 (defvar compare-ignore-case nil | |
| 40 "*Non-nil means \\[compare-windows] ignores case differences.") | |
| 41 | |
| 42 ;;;###autoload | |
| 43 (defun compare-windows (ignore-whitespace) | |
| 44 "Compare text in current window with text in next window. | |
| 45 Compares the text starting at point in each window, | |
| 46 moving over text in each one as far as they match. | |
| 47 | |
| 48 A prefix arg means ignore changes in whitespace. | |
| 49 The variable `compare-windows-whitespace' controls how whitespace is skipped. | |
| 50 If `compare-ignore-case' is non-nil, changes in case are also ignored." | |
| 51 (interactive "P") | |
| 52 (let* (p1 p2 maxp1 maxp2 b1 b2 w2 | |
| 53 success size | |
| 54 (opoint1 (point)) | |
| 55 opoint2 | |
| 56 (skip-whitespace (if ignore-whitespace | |
| 57 compare-windows-whitespace)) | |
| 58 (skip-whitespace-regexp (concat "[" skip-whitespace "]+"))) | |
| 59 (setq p1 (point) b1 (current-buffer)) | |
| 60 (setq w2 (next-window (selected-window))) | |
| 61 (if (eq w2 (selected-window)) | |
| 62 (error "No other window")) | |
| 63 (setq p2 (window-point w2) | |
| 64 b2 (window-buffer w2)) | |
| 65 (setq opoint2 p2) | |
| 66 (setq maxp1 (point-max)) | |
| 67 (save-excursion | |
| 68 (set-buffer b2) | |
| 69 (setq maxp2 (point-max))) | |
| 70 | |
| 71 (setq success t) | |
| 72 (while success | |
| 73 (setq success nil) | |
| 74 ;; if interrupted, show how far we've gotten | |
| 75 (goto-char p1) | |
| 76 (set-window-point w2 p2) | |
| 77 | |
| 78 ;; If both buffers have whitespace next to point, | |
| 79 ;; optionally skip over it. | |
| 80 | |
| 81 (and skip-whitespace | |
| 82 (save-excursion | |
| 83 (let (p1a p2a w1 w2 result1 result2) | |
| 84 (if (stringp skip-whitespace) | |
| 85 (progn | |
| 86 (if (not (eobp)) | |
| 87 (skip-chars-backward skip-whitespace opoint1)) | |
| 88 (and (looking-at skip-whitespace-regexp) | |
| 89 (setq p1a (match-end 0) result1 t))) | |
| 90 (setq result1 (funcall skip-whitespace opoint1)) | |
| 91 (setq p1a (point))) | |
| 92 (set-buffer b2) | |
| 93 (goto-char p2) | |
| 94 (if (stringp skip-whitespace) | |
| 95 (progn | |
| 96 (if (not (eobp)) | |
| 97 (skip-chars-backward skip-whitespace opoint2)) | |
| 98 (and (looking-at skip-whitespace-regexp) | |
| 99 (setq p2a (match-end 0) result2 t))) | |
| 100 (setq result2 (funcall skip-whitespace opoint2)) | |
| 101 (setq p2a (point))) | |
| 102 (and result1 result2 (eq result1 result2) | |
| 103 (setq p1 p1a | |
| 104 p2 p2a))))) | |
| 105 | |
| 106 ;; Try advancing comparing 1000 chars at a time. | |
| 107 ;; When that fails, go 500 chars at a time, and so on. | |
| 108 (let ((size 1000) | |
| 109 success-1) | |
| 110 (while (> size 0) | |
| 111 (setq success-1 t) | |
| 112 (while success-1 | |
| 113 (setq size (min size (- maxp1 p1) (- maxp2 p2))) | |
| 114 (save-excursion | |
| 115 (set-buffer b2) | |
| 116 (setq s2 (buffer-substring p2 (+ size p2)))) | |
| 117 (setq success-1 | |
| 118 (and (> size 0) | |
| 119 (if compare-ignore-case | |
| 120 (let ((case-fold-search t)) | |
| 121 (save-excursion | |
| 122 (search-forward s2 (+ p1 size) t))) | |
| 123 (equal (buffer-substring p1 (+ size p1)) s2)))) | |
| 124 (if success-1 | |
| 125 (setq p1 (+ p1 size) p2 (+ p2 size) | |
| 126 success t))) | |
| 127 (setq size (/ size 2))))) | |
| 128 | |
| 129 (goto-char p1) | |
| 130 (set-window-point w2 p2) | |
| 131 (if (= (point) opoint1) | |
| 132 (ding)))) | |
| 584 | 133 |
| 134 (provide 'compare-w) | |
| 135 | |
|
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
136 ;;; compare-w.el ends here |
