Mercurial > emacs
annotate src/casetab.c @ 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 | 5fe52748a72c |
| children | 952f2a18f83d |
| rev | line source |
|---|---|
| 118 | 1 /* GNU Emacs routines to deal with case tables. |
| 2 Copyright (C) 1987 Free Software Foundation, Inc. | |
| 3 | |
| 4 This file is part of GNU Emacs. | |
| 5 | |
| 6 GNU Emacs is free software; you can redistribute it and/or modify | |
| 7 it under the terms of the GNU General Public License as published by | |
| 8 the Free Software Foundation; either version 1, or (at your option) | |
| 9 any later version. | |
| 10 | |
| 11 GNU Emacs is distributed in the hope that it will be useful, | |
| 12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 GNU General Public License for more details. | |
| 15 | |
| 16 You should have received a copy of the GNU General Public License | |
| 17 along with GNU Emacs; see the file COPYING. If not, write to | |
| 18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
| 19 | |
| 20 /* Written by Howard Gayle. See chartab.c for details. */ | |
| 21 | |
| 22 #include "config.h" | |
| 23 #include "lisp.h" | |
| 24 #include "buffer.h" | |
| 25 | |
| 26 Lisp_Object Qcase_table_p; | |
| 27 Lisp_Object Vascii_downcase_table, Vascii_upcase_table; | |
| 28 Lisp_Object Vascii_canon_table, Vascii_eqv_table; | |
| 29 | |
| 30 void compute_trt_inverse (); | |
| 31 | |
| 32 DEFUN ("case-table-p", Fcase_table_p, Scase_table_p, 1, 1, 0, | |
| 33 "Return t iff ARG is a case table.\n\ | |
| 34 See `set-case-table' for more information on these data structures.") | |
| 35 (table) | |
| 36 Lisp_Object table; | |
| 37 { | |
| 38 Lisp_Object down, up, canon, eqv; | |
| 39 down = Fcar_safe (table); | |
| 40 up = Fcar_safe (Fcdr_safe (table)); | |
| 41 canon = Fcar_safe (Fcdr_safe (Fcdr_safe (table))); | |
| 42 eqv = Fcar_safe (Fcdr_safe (Fcdr_safe (Fcdr_safe (table)))); | |
| 43 | |
| 44 #define STRING256_P(obj) \ | |
| 45 (XTYPE (obj) == Lisp_String && XSTRING (obj)->size == 256) | |
| 46 | |
| 47 return (STRING256_P (down) | |
| 484 | 48 && (NILP (up) || STRING256_P (up)) |
| 49 && ((NILP (canon) && NILP (eqv)) | |
| 118 | 50 || (STRING256_P (canon) && STRING256_P (eqv))) |
| 51 ? Qt : Qnil); | |
| 52 } | |
| 53 | |
| 54 static Lisp_Object | |
| 55 check_case_table (obj) | |
| 56 Lisp_Object obj; | |
| 57 { | |
| 58 register Lisp_Object tem; | |
| 59 | |
| 484 | 60 while (tem = Fcase_table_p (obj), NILP (tem)) |
| 118 | 61 obj = wrong_type_argument (Qcase_table_p, obj, 0); |
| 62 return (obj); | |
| 63 } | |
| 64 | |
| 65 DEFUN ("current-case-table", Fcurrent_case_table, Scurrent_case_table, 0, 0, 0, | |
| 66 "Return the case table of the current buffer.") | |
| 67 () | |
| 68 { | |
| 69 Lisp_Object down, up, canon, eqv; | |
| 70 | |
| 71 down = current_buffer->downcase_table; | |
| 72 up = current_buffer->upcase_table; | |
| 73 canon = current_buffer->case_canon_table; | |
| 74 eqv = current_buffer->case_eqv_table; | |
| 75 | |
| 76 return Fcons (down, Fcons (up, Fcons (canon, Fcons (eqv, Qnil)))); | |
| 77 } | |
| 78 | |
| 79 DEFUN ("standard-case-table", Fstandard_case_table, | |
| 80 Sstandard_case_table, 0, 0, 0, | |
| 81 "Return the standard case table.\n\ | |
| 82 This is the one used for new buffers.") | |
| 83 () | |
| 84 { | |
| 85 return Fcons (Vascii_downcase_table, | |
| 86 Fcons (Vascii_upcase_table, | |
| 87 Fcons (Vascii_canon_table, | |
| 88 Fcons (Vascii_eqv_table, Qnil)))); | |
| 89 } | |
| 90 | |
|
1506
5fe52748a72c
* casetab.c (set_case_table): Declare this to be static, and
Jim Blandy <jimb@redhat.com>
parents:
484
diff
changeset
|
91 static Lisp_Object set_case_table (); |
|
5fe52748a72c
* casetab.c (set_case_table): Declare this to be static, and
Jim Blandy <jimb@redhat.com>
parents:
484
diff
changeset
|
92 |
| 118 | 93 DEFUN ("set-case-table", Fset_case_table, Sset_case_table, 1, 1, 0, |
| 94 "Select a new case table for the current buffer.\n\ | |
| 95 A case table is a list (DOWNCASE UPCASE CANONICALIZE EQUIVALENCES)\n\ | |
| 96 where each element is either nil or a string of length 256.\n\ | |
| 97 DOWNCASE maps each character to its lower-case equivalent.\n\ | |
| 98 UPCASE maps each character to its upper-case equivalent;\n\ | |
| 99 if lower and upper case characters are in 1-1 correspondence,\n\ | |
| 100 you may use nil and the upcase table will be deduced from DOWNCASE.\n\ | |
| 101 CANONICALIZE maps each character to a canonical equivalent;\n\ | |
| 102 any two characters that are related by case-conversion have the same\n\ | |
| 103 canonical equivalent character.\n\ | |
| 104 EQUIVALENCES is a map that cyclicly permutes each equivalence class\n\ | |
| 105 (of characters with the same canonical equivalent).\n\ | |
| 106 Both CANONICALIZE and EQUIVALENCES may be nil, in which case\n\ | |
| 107 both are deduced from DOWNCASE and UPCASE.") | |
| 108 (table) | |
| 109 Lisp_Object table; | |
| 110 { | |
|
1506
5fe52748a72c
* casetab.c (set_case_table): Declare this to be static, and
Jim Blandy <jimb@redhat.com>
parents:
484
diff
changeset
|
111 return set_case_table (table, 0); |
| 118 | 112 } |
| 113 | |
| 114 DEFUN ("set-standard-case-table", | |
| 115 Fset_standard_case_table, Sset_standard_case_table, 1, 1, 0, | |
| 116 "Select a new standard case table for new buffers.\n\ | |
| 117 See `set-case-table' for more info on case tables.") | |
| 118 (table) | |
| 119 Lisp_Object table; | |
| 120 { | |
|
1506
5fe52748a72c
* casetab.c (set_case_table): Declare this to be static, and
Jim Blandy <jimb@redhat.com>
parents:
484
diff
changeset
|
121 return set_case_table (table, 1); |
| 118 | 122 } |
| 123 | |
|
1506
5fe52748a72c
* casetab.c (set_case_table): Declare this to be static, and
Jim Blandy <jimb@redhat.com>
parents:
484
diff
changeset
|
124 static Lisp_Object |
| 118 | 125 set_case_table (table, standard) |
| 126 Lisp_Object table; | |
| 127 int standard; | |
| 128 { | |
| 129 Lisp_Object down, up, canon, eqv; | |
| 130 | |
| 131 check_case_table (table); | |
| 132 | |
| 133 down = Fcar_safe (table); | |
| 134 up = Fcar_safe (Fcdr_safe (table)); | |
| 135 canon = Fcar_safe (Fcdr_safe (Fcdr_safe (table))); | |
| 136 eqv = Fcar_safe (Fcdr_safe (Fcdr_safe (Fcdr_safe (table)))); | |
| 137 | |
| 484 | 138 if (NILP (up)) |
| 118 | 139 { |
| 140 up = Fmake_string (make_number (256), make_number (0)); | |
| 141 compute_trt_inverse (XSTRING (down)->data, XSTRING (up)->data); | |
| 142 } | |
| 143 | |
| 484 | 144 if (NILP (canon)) |
| 118 | 145 { |
| 146 register int i; | |
| 147 unsigned char *upvec = XSTRING (up)->data; | |
| 148 unsigned char *downvec = XSTRING (down)->data; | |
| 149 | |
| 150 canon = Fmake_string (make_number (256), make_number (0)); | |
| 151 eqv = Fmake_string (make_number (256), make_number (0)); | |
| 152 | |
| 153 /* Set up the CANON vector; for each character, | |
| 154 this sequence of upcasing and downcasing ought to | |
| 155 get the "preferred" lowercase equivalent. */ | |
| 156 for (i = 0; i < 256; i++) | |
| 157 XSTRING (canon)->data[i] = downvec[upvec[downvec[i]]]; | |
| 158 | |
| 159 compute_trt_inverse (XSTRING (canon)->data, XSTRING (eqv)->data); | |
| 160 } | |
| 161 | |
| 162 if (standard) | |
| 163 { | |
| 164 Vascii_downcase_table = down; | |
| 165 Vascii_upcase_table = up; | |
| 166 Vascii_canon_table = canon; | |
| 167 Vascii_eqv_table = eqv; | |
| 168 } | |
| 169 else | |
| 170 { | |
| 171 current_buffer->downcase_table = down; | |
| 172 current_buffer->upcase_table = up; | |
| 173 current_buffer->case_canon_table = canon; | |
| 174 current_buffer->case_eqv_table = eqv; | |
| 175 } | |
| 176 return table; | |
| 177 } | |
| 178 | |
| 179 /* Given a translate table TRT, store the inverse mapping into INVERSE. | |
| 180 Since TRT is not one-to-one, INVERSE is not a simple mapping. | |
| 181 Instead, it divides the space of characters into equivalence classes. | |
| 182 All characters in a given class form one circular list, chained through | |
| 183 the elements of INVERSE. */ | |
| 184 | |
| 185 void | |
| 186 compute_trt_inverse (trt, inverse) | |
| 187 register unsigned char *trt; | |
| 188 register unsigned char *inverse; | |
| 189 { | |
| 190 register int i = 0400; | |
| 191 register unsigned char c, q; | |
| 192 | |
| 193 while (i--) | |
| 194 inverse[i] = i; | |
| 195 i = 0400; | |
| 196 while (i--) | |
| 197 { | |
| 198 if ((q = trt[i]) != (unsigned char) i) | |
| 199 { | |
| 200 c = inverse[q]; | |
| 201 inverse[q] = i; | |
| 202 inverse[i] = c; | |
| 203 } | |
| 204 } | |
| 205 } | |
| 206 | |
| 207 init_casetab_once () | |
| 208 { | |
| 209 register int i; | |
| 210 Lisp_Object tem; | |
| 211 | |
| 212 tem = Fmake_string (make_number (256), make_number (0)); | |
| 213 Vascii_downcase_table = tem; | |
| 214 Vascii_canon_table = tem; | |
| 215 | |
| 216 for (i = 0; i < 256; i++) | |
| 217 XSTRING (tem)->data[i] = (i >= 'A' && i <= 'Z') ? i + 040 : i; | |
| 218 | |
| 219 tem = Fmake_string (make_number (256), make_number (0)); | |
| 220 Vascii_upcase_table = tem; | |
| 221 Vascii_eqv_table = tem; | |
| 222 | |
| 223 for (i = 0; i < 256; i++) | |
| 224 XSTRING (tem)->data[i] | |
| 225 = ((i >= 'A' && i <= 'Z') | |
| 226 ? i + ('a' - 'A') | |
| 227 : ((i >= 'a' && i <= 'z') | |
| 228 ? i + ('A' - 'a') | |
| 229 : i)); | |
| 230 } | |
| 231 | |
| 232 syms_of_casetab () | |
| 233 { | |
| 234 Qcase_table_p = intern ("case-table-p"); | |
| 235 staticpro (&Qcase_table_p); | |
| 236 staticpro (&Vascii_downcase_table); | |
| 237 staticpro (&Vascii_upcase_table); | |
| 238 staticpro (&Vascii_canon_table); | |
| 239 staticpro (&Vascii_eqv_table); | |
| 240 | |
| 241 defsubr (&Scase_table_p); | |
| 242 defsubr (&Scurrent_case_table); | |
| 243 defsubr (&Sstandard_case_table); | |
| 244 defsubr (&Sset_case_table); | |
| 245 defsubr (&Sset_standard_case_table); | |
| 246 | |
| 247 #if 0 | |
| 248 DEFVAR_LISP ("ascii-downcase-table", &Vascii_downcase_table, | |
| 249 "String mapping ASCII characters to lowercase equivalents."); | |
| 250 DEFVAR_LISP ("ascii-upcase-table", &Vascii_upcase_table, | |
| 251 "String mapping ASCII characters to uppercase equivalents."); | |
| 252 #endif | |
| 253 } |
