annotate src/indent.c @ 1268:fffe735e63ee

[xemacs-hg @ 2003-02-07 11:50:50 by ben] fixes for menu crashes + better preemption behavior This contains two related changes: (1) Fix problems with reentrant calling of lwlib and associated crashes when selecting menu items. (2) Improve redisplay handling of preemption. Turn on lazy lock and hold down page-down or page-up and you'll see what I mean. They are related because they both touch on the code that retrieves events and handles the internal queues. console-msw.h, event-msw.c, event-stream.c, events.h, menubar-msw.c, menubar-x.c, menubar.h: mswindows_protect_modal_loop() has been generalized to event_stream_protect_modal_loop(), and moved to event-stream.c. mswindows_in_modal_loop ->in_modal_loop likewise. Changes in event-msw.c and menubar-msw.c for the new names and calling format (use structures instead of static variables in menubar-msw.c). Delete former in_menu_callback and use in_modal_loop in its place. Remove emacs_mswindows_quit_check_disallowed_p(), superseded by in_modal_loop. Use event_stream_protect_modal_loop() in pre_activate_callback() so that we get no lwlib reentrancy. Rearrange some of the code in event-msw.c to be grouped better. Make mswindows_drain_windows_queue() respect in_modal_loop and do nothing if so. cmdloop.c, event-stream.c: Don't conditionalize on LWLIB_MENUBARS_LUCID when giving error when in_modal_loop, and give better error. event-Xt.c, event-gtk.c: If in_modal_loop, only retrieve process and timeout events. Don't retrieve any X events because processing them can lead to reentrancy in lwlib -> death. event-stream.c: Remove unused parameter to check_event_stream_ok() and change all callers. lisp.h, event-stream.c: Rearrange some functions for increased clarity -- in particular, group all the input-pending/QUIT-related stuff together, and put right next to next-event stuff, to which it's related. Add the concept of "HOW_MANY" -- when asking whether user input is pending, you can ask if at least HOW_MANY events are pending, not just if any are. Add parameter to detect_input_pending() for this. Change recursive_sit_for from a Lisp_Object (which could only be Qt or Qnil) to an int, like it should be. event-Xt.c, event-gtk.c, event-xlike-inc.c: New file. Abstract out similar code in event_{Xt/gtk}_pending_p() and write only once, using include-file tricks. Rewrite this function to implement HOW_MANY and only process events when not in_modal_loop. event-msw.c: Implement HOW_MANY and only process events when not in_modal_loop. event-tty.c: Implement HOW_MANY. redisplay.c: Add var `max-preempts' to control maximum number of preempts. (#### perhaps not useful) Rewrite preemption check so that, rather than preempting when any user events are available, only preempt when a certain number (currently 4) of them are backed up. This effectively allows redisplay to proceed to completion in the presence of a fast auto-repeat (usually the auto-repeating is generated dynamically as necessary), and you get much better display behavior with lazy-lock active. event-unixoid.c: Comment changes. event-stream.c: Rewrite discard-input much more simply and safely using the drain-queue functions. I think the old version might loop forever if called when in_modal_loop. SEMI-UNRELATED CHANGES: ----------------------- event-stream.c: Turn QUIT-checking back on when running the pre-idle hook so it can be quit out of. indent.c: Document exact functioning of `vertical-motion' better, and its differences from GNU Emacs.
author ben
date Fri, 07 Feb 2003 11:50:54 +0000
parents e22b0213b713
children 8c96bdabcaf9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* Indentation functions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1995 Board of Trustees, University of Illinois.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Copyright (C) 1985, 1986, 1987, 1988, 1992, 1993, 1994, 1995
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 793
diff changeset
4 Free Software Foundation, Inc.
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 665
diff changeset
5 Copyright (C) 2002 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 /* This file has been Mule-ized. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 /* Synched up with: 19.30. Diverges significantly from FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 #include "buffer.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 #include "device.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 #include "extents.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #include "faces.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #include "frame.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 #include "glyphs.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 #include "insdel.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 #ifdef REGION_CACHE_NEEDS_WORK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 #include "region-cache.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 #include "window.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 Lisp_Object Qcoerce;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 /* Indentation can insert tabs if this is non-zero;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 otherwise always uses spaces */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 int indent_tabs_mode;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 /* Avoid recalculation by remembering things in these variables. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 /* Last value returned by current_column.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 Some things set last_known_column_point to -1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 to mark the memoized value as invalid */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 static int last_known_column;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 /* Last buffer searched by current_column */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 static struct buffer *last_known_column_buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 /* Value of point when current_column was called */
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
62 static Charbpos last_known_column_point;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 /* Value of MODIFF when current_column was called */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 static int last_known_column_modified;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
67 static Charbpos
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
68 last_visible_position (Charbpos pos, struct buffer *buf)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 Lisp_Object buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 Lisp_Object value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 665
diff changeset
73 buffer = wrap_buffer (buf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 value = Fprevious_single_property_change (make_int (pos), Qinvisible,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 buffer, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 if (NILP (value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 return 0; /* no visible position found */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 /* #### bug bug bug!!! This will return the position of the beginning
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 of an invisible extent; this extent is very likely to be start-closed,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 and thus the spaces inserted in `indent-to' will go inside the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 invisible extent.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 Not sure what the correct solution is here. Rethink indent-to? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 return XINT (value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 #ifdef REGION_CACHE_NEEDS_WORK
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 /* Allocate or free the width run cache, as requested by the current
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 state of current_buffer's cache_long_line_scans variable. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 width_run_cache_on_off (struct buffer *buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 if (NILP (buf->cache_long_line_scans))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 /* It should be off. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 if (buf->width_run_cache)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 free_region_cache (buf->width_run_cache);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 buf->width_run_cache = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 buf->width_table = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 /* It should be on. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 if (buf->width_run_cache == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 buf->width_run_cache = new_region_cache ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 recompute_width_table (buf, buffer_display_table ());
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 #endif /* REGION_CACHE_NEEDS_WORK */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 /* Cancel any recorded value of the horizontal position. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 invalidate_current_column (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 last_known_column_point = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 int
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
128 column_at_point (struct buffer *buf, Charbpos init_pos, int cur_col)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 int col;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 int tab_seen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 int tab_width = XINT (buf->tab_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 int post_tab;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
134 Charbpos pos = init_pos;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
135 Ichar c;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 col = tab_seen = post_tab = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 if (pos <= BUF_BEGV (buf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 pos--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 c = BUF_FETCH_CHAR (buf, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 if (c == '\t')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 if (tab_seen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 col = ((col + tab_width) / tab_width) * tab_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 post_tab += col;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 col = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 tab_seen = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 else if (c == '\n' ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 (EQ (buf->selective_display, Qt) && c == '\r'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 /* #### This needs updating to handle the new redisplay. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 /* #### FSFmacs looks at ctl_arrow, display tables.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 We need to do similar. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 #if 0
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
165 displayed_glyphs = glyphs_from_charbpos (sel_frame, buf,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 XWINDOW (selected_window),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 pos, dp, 0, col, 0, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 col += (displayed_glyphs->columns
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 - (displayed_glyphs->begin_columns
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 + displayed_glyphs->end_columns));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 #else /* XEmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 #ifdef MULE
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
173 col += XCHARSET_COLUMNS (ichar_charset (c));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 col ++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 #endif /* XEmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 if (tab_seen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 col = ((col + tab_width) / tab_width) * tab_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 col += post_tab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 if (cur_col)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 last_known_column_buffer = buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 last_known_column = col;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 last_known_column_point = init_pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 last_known_column_modified = BUF_MODIFF (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 return col;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 int
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 665
diff changeset
199 string_column_at_point (Lisp_Object s, Charbpos init_pos, int tab_width)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 int col;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 int tab_seen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 int post_tab;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
204 Charbpos pos = init_pos;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
205 Ichar c;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 col = tab_seen = post_tab = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 if (pos <= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 pos--;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
216 c = string_ichar (s, pos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 if (c == '\t')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 if (tab_seen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 col = ((col + tab_width) / tab_width) * tab_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 post_tab += col;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 col = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 tab_seen = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 else if (c == '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 #ifdef MULE
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
230 col += XCHARSET_COLUMNS (ichar_charset (c));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 col ++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 if (tab_seen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 col = ((col + tab_width) / tab_width) * tab_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 col += post_tab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 return col;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 current_column (struct buffer *buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 if (buf == last_known_column_buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 && BUF_PT (buf) == last_known_column_point
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 && BUF_MODIFF (buf) == last_known_column_modified)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 return last_known_column;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 return column_at_point (buf, BUF_PT (buf), 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 DEFUN ("current-column", Fcurrent_column, 0, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 Return the horizontal position of point. Beginning of line is column 0.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 This is calculated by adding together the widths of all the displayed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 representations of the character between the start of the previous line
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 and point. (e.g. control characters will have a width of 2 or 4, tabs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 will have a variable width.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 Ignores finite width of frame, which means that this function may return
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 values greater than (frame-width).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 Whether the line is visible (if `selective-display' is t) has no effect;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 however, ^M is treated as end of line when `selective-display' is t.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 If BUFFER is nil, the current buffer is assumed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 return make_int (current_column (decode_buffer (buffer, 0)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 DEFUN ("indent-to", Findent_to, 1, 3, "NIndent to column: ", /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 Indent from point with tabs and spaces until COLUMN is reached.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
276 Optional second argument MINIMUM says always do at least MINIMUM spaces
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
277 even if that goes past COLUMN; by default, MINIMUM is zero.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 If BUFFER is nil, the current buffer is assumed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
280 (column, minimum, buffer))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 int mincol;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 int fromcol;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 struct buffer *buf = decode_buffer (buffer, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 int tab_width = XINT (buf->tab_width);
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
287 Charbpos opoint = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
289 CHECK_INT (column);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 if (NILP (minimum))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 minimum = Qzero;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 CHECK_INT (minimum);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 665
diff changeset
295 buffer = wrap_buffer (buf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 fromcol = current_column (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 mincol = fromcol + XINT (minimum);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 440
diff changeset
299 if (mincol < XINT (column)) mincol = XINT (column);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 if (fromcol == mincol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 return make_int (mincol);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 if (!NILP (Fextent_at (make_int (BUF_PT (buf)), buffer, Qinvisible,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 Qnil, Qnil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
309 Charbpos last_visible = last_visible_position (BUF_PT (buf), buf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 opoint = BUF_PT (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 if (last_visible >= BUF_BEGV (buf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 BUF_SET_PT (buf, last_visible);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 444
diff changeset
315 invalid_operation ("Visible portion of buffer not modifiable", Qunbound);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 if (indent_tabs_mode)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 int n = mincol / tab_width - fromcol / tab_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 if (n != 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 Finsert_char (make_char ('\t'), make_int (n), Qnil, buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 fromcol = (mincol / tab_width) * tab_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 Finsert_char (make_char (' '), make_int (mincol - fromcol), Qnil, buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 last_known_column_buffer = buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 last_known_column = mincol;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 last_known_column_point = BUF_PT (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 last_known_column_modified = BUF_MODIFF (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 /* Not in FSF: */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 if (opoint > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 BUF_SET_PT (buf, opoint);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 return make_int (mincol);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 int
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 793
diff changeset
344 byte_spaces_at_point (struct buffer *b, Bytebpos byte_pos)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 {
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 793
diff changeset
346 Bytebpos byte_end = BYTE_BUF_ZV (b);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 int col = 0;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
348 Ichar c;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 int tab_width = XINT (b->tab_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 if (tab_width <= 0 || tab_width > 1000)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 tab_width = 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 793
diff changeset
354 while (byte_pos < byte_end &&
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 793
diff changeset
355 (c = BYTE_BUF_FETCH_CHAR (b, byte_pos),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 (c == '\t'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 ? (col += tab_width - col % tab_width)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 : (c == ' ' ? ++col : 0))))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 793
diff changeset
359 INC_BYTEBPOS (b, byte_pos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 return col;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 DEFUN ("current-indentation", Fcurrent_indentation, 0, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 Return the indentation of the current line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 This is the horizontal position of the character
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 following any initial whitespace.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 (buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 struct buffer *buf = decode_buffer (buffer, 0);
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
373 Charbpos pos = find_next_newline (buf, BUF_PT (buf), -1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 665
diff changeset
375 buffer = wrap_buffer (buf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 if (!NILP (Fextent_at (make_int (pos), buffer, Qinvisible, Qnil, Qnil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 return Qzero;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 793
diff changeset
380 return make_int (byte_spaces_at_point (buf, charbpos_to_bytebpos (buf, pos)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 DEFUN ("move-to-column", Fmove_to_column, 1, 3, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 Move point to column COLUMN in the current line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 The column of a character is calculated by adding together the widths
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 as displayed of the previous characters in the line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 This function ignores line-continuation;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 there is no upper limit on the column number a character can have
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 and horizontal scrolling has no effect.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 If specified column is within a character, point goes after that character.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 If it's past end of line, point goes to end of line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 A value of 'coerce for the second (optional) argument FORCE means if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 COLUMN is in the middle of a tab character, change it to spaces.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 Any other non-nil value means the same, plus if the line is too short to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 reach column COLUMN, then add spaces/tabs to get there.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 Returns the actual column that it moved to.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 (column, force, buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 /* This function can GC */
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
405 Charbpos pos;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 struct buffer *buf = decode_buffer (buffer, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 int col = current_column (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 int goal;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
409 Charbpos end;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 int tab_width = XINT (buf->tab_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 int prev_col = 0;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
413 Ichar c = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 665
diff changeset
415 buffer = wrap_buffer (buf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 if (tab_width <= 0 || tab_width > 1000) tab_width = 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 CHECK_NATNUM (column);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 goal = XINT (column);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 retry:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 pos = BUF_PT (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 end = BUF_ZV (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 /* If we're starting past the desired column,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 back up to beginning of line and scan from there. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 if (col > goal)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 pos = find_next_newline (buf, pos, -1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 col = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 while (col < goal && pos < end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 c = BUF_FETCH_CHAR (buf, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 if (c == '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 if (c == '\r' && EQ (buf->selective_display, Qt))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 if (c == '\t')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 prev_col = col;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 col += tab_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 col = col / tab_width * tab_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 /* #### oh for the days of the complete new redisplay */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 /* #### FSFmacs looks at ctl_arrow, display tables.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 We need to do similar. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 #if 0
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
451 displayed_glyphs = glyphs_from_charbpos (selected_frame (),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 buf,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 XWINDOW (Fselected_window (Qnil)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 pos, dp, 0, col, 0, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 col += (displayed_glyphs->columns
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 - (displayed_glyphs->begin_columns
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 + displayed_glyphs->end_columns));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 #else /* XEmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 #ifdef MULE
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
460 col += XCHARSET_COLUMNS (ichar_charset (c));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 col ++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 #endif /* XEmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 BUF_SET_PT (buf, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 /* If a tab char made us overshoot, change it to spaces
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 and scan through it again. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 if (!NILP (force) && col > goal && c == '\t' && prev_col < goal)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 buffer_delete_range (buf, BUF_PT (buf) - 1, BUF_PT (buf), 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 Findent_to (make_int (col - 1), Qzero, buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 buffer_insert_emacs_char (buf, ' ');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 goto retry;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 /* If line ends prematurely, add space to the end. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 if (col < goal && !NILP (force) && !EQ (force, Qcoerce))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 col = goal;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 Findent_to (make_int (col), Qzero, buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 last_known_column_buffer = buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 last_known_column = col;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 last_known_column_point = BUF_PT (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 last_known_column_modified = BUF_MODIFF (buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 return make_int (col);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 #if 0 /* #### OK boys, this function needs to be present, I think.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 It was there before the 19.12 redisplay rewrite. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 793
diff changeset
500 DEFUN ("compute-motion", Fcompute_motion, 7, 7, 0, /*
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 "Scan through the current buffer, calculating screen position.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 Scan the current buffer forward from offset FROM,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 assuming it is at position FROMPOS--a cons of the form (HPOS . VPOS)--
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 to position TO or position TOPOS--another cons of the form (HPOS . VPOS)--
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 and return the ending buffer position and screen location.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 There are three additional arguments:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 WIDTH is the number of columns available to display text;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 this affects handling of continuation lines.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 This is usually the value returned by `window-width', less one (to allow
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 for the continuation glyph).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 OFFSETS is either nil or a cons cell (HSCROLL . TAB-OFFSET).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 HSCROLL is the number of columns not being displayed at the left
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 margin; this is usually taken from a window's hscroll member.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 TAB-OFFSET is the number of columns of the first tab that aren't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 being displayed, perhaps because the line was continued within it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 If OFFSETS is nil, HSCROLL and TAB-OFFSET are assumed to be zero.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 WINDOW is the window to operate on. Currently this is used only to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 find the display table. It does not matter what buffer WINDOW displays;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 `compute-motion' always operates on the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 The value is a list of five elements:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 (POS HPOS VPOS PREVHPOS CONTIN)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 POS is the buffer position where the scan stopped.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 VPOS is the vertical position where the scan stopped.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 HPOS is the horizontal position where the scan stopped.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 PREVHPOS is the horizontal position one character back from POS.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 CONTIN is t if a line was continued after (or within) the previous character.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 For example, to find the buffer position of column COL of line LINE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 of a certain window, pass the window's starting location as FROM
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 and the window's upper-left coordinates as FROMPOS.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 Pass the buffer's (point-max) as TO, to limit the scan to the end of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 visible section of the buffer, and pass LINE and COL as TOPOS.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 (from, frompos, to, topos, width, offsets, window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
542 Lisp_Object charbpos, hpos, vpos, prevhpos, contin;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 struct position *pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 int hscroll, tab_offset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 struct window *w = decode_window (window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 CHECK_INT_COERCE_MARKER (from);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 CHECK_CONS (frompos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 CHECK_INT (XCAR (frompos));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 CHECK_INT (XCDR (frompos));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 CHECK_INT_COERCE_MARKER (to);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 CHECK_CONS (topos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 CHECK_INT (XCAR (topos));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 CHECK_INT (XCDR (topos));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 CHECK_INT (width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 if (!NILP (offsets))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 CHECK_CONS (offsets);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 CHECK_INT (XCAR (offsets));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 CHECK_INT (XCDR (offsets));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 hscroll = XINT (XCAR (offsets));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 tab_offset = XINT (XCDR (offsets));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 hscroll = tab_offset = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 pos = compute_motion (XINT (from), XINT (XCDR (frompos)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 XINT (XCAR (frompos)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 XINT (to), XINT (XCDR (topos)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 XINT (XCAR (topos)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 XINT (width), hscroll, tab_offset, w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 665
diff changeset
573 charbpos = make_int (pos->charbpos);
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 665
diff changeset
574 hpos = make_int (pos->hpos);
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 665
diff changeset
575 vpos = make_int (pos->vpos);
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 665
diff changeset
576 prevhpos = make_int (pos->prevhpos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
578 return list5 (charbpos, hpos, vpos, prevhpos,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 pos->contin ? Qt : Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 #endif /* 0 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 /* Helper for vmotion_1 - compute vertical pixel motion between
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 START and END in the line start cache CACHE. This just sums
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 the line heights, including both the starting and ending lines.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 vpix_motion (line_start_cache_dynarr *cache, int start, int end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 int i, vpix;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 assert (start <= end);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 assert (start >= 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 assert (end < Dynarr_length (cache));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 vpix = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 for (i = start; i <= end; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 vpix += Dynarr_atp (cache, i)->height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 return vpix;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 vmotion_1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 Given a starting position ORIG, move point VTARGET lines in WINDOW.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 Returns the new value for point. If the arg ret_vpos is not nil, it is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 taken to be a pointer to an int and the number of lines actually moved is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 returned in it. If the arg ret_vpix is not nil, it is taken to be a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 pointer to an int and the vertical pixel height of the motion which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 took place is returned in it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 ****************************************************************************/
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
614 static Charbpos
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
615 vmotion_1 (struct window *w, Charbpos orig, int vtarget,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 int *ret_vpos, int *ret_vpix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 struct buffer *b = XBUFFER (w->buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 int elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 elt = point_in_line_start_cache (w, orig, (vtarget < 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 ? -vtarget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 : vtarget));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 /* #### This assertion must be true before the if statements are hit
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 but may possibly be wrong after the call to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 point_in_line_start_cache if orig is outside of the visible
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 region of the buffer. Handle this. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 assert (elt >= 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 /* Moving downward. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 if (vtarget > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 int cur_line = Dynarr_length (w->line_start_cache) - 1 - elt;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
635 Charbpos ret_pt;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 if (cur_line > vtarget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 cur_line = vtarget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 /* The traditional FSF behavior is to return the end of buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 position if we couldn't move far enough because we hit it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 if (cur_line < vtarget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 ret_pt = BUF_ZV (b);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 ret_pt = Dynarr_atp (w->line_start_cache, cur_line + elt)->start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 while (ret_pt > BUF_ZV (b) && cur_line > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 cur_line--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 ret_pt = Dynarr_atp (w->line_start_cache, cur_line + elt)->start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 if (ret_vpos) *ret_vpos = cur_line;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 if (ret_vpix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 *ret_vpix = vpix_motion (w->line_start_cache, elt, cur_line + elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 return ret_pt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 else if (vtarget < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 if (elt < -vtarget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 if (ret_vpos) *ret_vpos = -elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 if (ret_vpix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 *ret_vpix = vpix_motion (w->line_start_cache, 0, elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 /* #### This should be BUF_BEGV (b), right? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 return Dynarr_atp (w->line_start_cache, 0)->start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 if (ret_vpos) *ret_vpos = vtarget;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 if (ret_vpix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 *ret_vpix = vpix_motion (w->line_start_cache, elt + vtarget, elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 return Dynarr_atp (w->line_start_cache, elt + vtarget)->start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 /* No vertical motion requested so we just return the position
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 of the beginning of the current line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 if (ret_vpos) *ret_vpos = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 if (ret_vpix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 *ret_vpix = vpix_motion (w->line_start_cache, elt, elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 return Dynarr_atp (w->line_start_cache, elt)->start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 867
diff changeset
687 RETURN_NOT_REACHED(0); /* shut up compiler */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 /*****************************************************************************
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 vmotion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 Given a starting position ORIG, move point VTARGET lines in WINDOW.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 Returns the new value for point. If the arg ret_vpos is not nil, it is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 taken to be a pointer to an int and the number of lines actually moved is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 returned in it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 ****************************************************************************/
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
698 Charbpos
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
699 vmotion (struct window *w, Charbpos orig, int vtarget, int *ret_vpos)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 return vmotion_1 (w, orig, vtarget, ret_vpos, NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 /* Helper for Fvertical_motion.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 static
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 Lisp_Object vertical_motion_1 (Lisp_Object lines, Lisp_Object window,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 int pixels)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
710 Charbpos charbpos;
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
711 Charbpos orig;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 int selected;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 int *vpos, *vpix;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 int value=0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 struct window *w;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 if (NILP (window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 window = Fselected_window (Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 CHECK_LIVE_WINDOW (window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 CHECK_INT (lines);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 selected = (EQ (window, Fselected_window (Qnil)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 w = XWINDOW (window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 orig = selected ? BUF_PT (XBUFFER (w->buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 : marker_position (w->pointm[CURRENT_DISP]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 vpos = pixels ? NULL : &value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 vpix = pixels ? &value : NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
733 charbpos = vmotion_1 (w, orig, XINT (lines), vpos, vpix);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 /* Note that the buffer's point is set, not the window's point. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 if (selected)
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
737 BUF_SET_PT (XBUFFER (w->buffer), charbpos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 set_marker_restricted (w->pointm[CURRENT_DISP],
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
740 make_int(charbpos),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 w->buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 return make_int (value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 DEFUN ("vertical-motion", Fvertical_motion, 1, 3, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 Move to start of frame line LINES lines down.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 If LINES is negative, this is moving up.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 Optional second argument is WINDOW to move in,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 the default is the selected window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 Sets point to position found; this may be start of line
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 or just the start of a continuation line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 If optional third argument PIXELS is nil, returns number
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 of lines moved; may be closer to zero than LINES if beginning
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 or end of buffer was reached. If PIXELS is non-nil, the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 vertical pixel height of the motion which took place is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 returned instead of the actual number of lines moved. A
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 motion of zero lines returns the height of the current line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760
1268
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1204
diff changeset
761 NOTE NOTE NOTE: GNU Emacs/XEmacs difference.
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1204
diff changeset
762
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1204
diff changeset
763 What `vertical-motion' actually does is set WINDOW's buffer's point
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1204
diff changeset
764 if WINDOW is the selected window; else, it sets WINDOW's point.
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1204
diff changeset
765 This is unfortunately somewhat tricky to work with, and different
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1204
diff changeset
766 from GNU Emacs, which always uses the current buffer, not WINDOW's
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1204
diff changeset
767 buffer, always sets current buffer's point, and, from the
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1204
diff changeset
768 perspective of this function, temporarily makes WINDOW display
fffe735e63ee [xemacs-hg @ 2003-02-07 11:50:50 by ben]
ben
parents: 1204
diff changeset
769 the current buffer if it wasn't already.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 (lines, window, pixels))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 return vertical_motion_1 (lines, window, !NILP (pixels));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 * Like vmotion() but requested and returned movement is in pixels.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 * HOW specifies the stopping condition. Positive means move at least
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 * PIXELS. Negative means at most. Zero means as close as possible.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 */
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
781 Charbpos
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
782 vmotion_pixels (Lisp_Object window, Charbpos start, int pixels, int how,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 int *motion)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 struct window *w;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
786 Charbpos eobuf, bobuf;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 int defheight;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 int needed;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 int line, next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 int remain, abspix, dirn;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 int elt, nelt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 line_start_cache_dynarr *cache;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 int previous = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 int lines;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 if (NILP (window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 window = Fselected_window (Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 CHECK_LIVE_WINDOW (window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 w = XWINDOW (window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 eobuf = BUF_ZV (XBUFFER (w->buffer));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 bobuf = BUF_BEGV (XBUFFER (w->buffer));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 default_face_height_and_width (window, &defheight, NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 /* guess num lines needed in line start cache + a few extra */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 abspix = abs (pixels);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 needed = (abspix + defheight-1)/defheight + 3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 dirn = (pixels >= 0) ? 1 : -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 elt = point_in_line_start_cache (w, start, needed);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 assert (elt >= 0); /* in the cache */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 cache = w->line_start_cache;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 nelt = Dynarr_length (cache);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 *motion = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 if (pixels == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825 /* No vertical motion requested so we just return the position
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 of the beginning of the current display line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 return Dynarr_atp (cache, elt)->start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 if ((dirn < 0 && elt == 0 &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 Dynarr_atp (cache, elt)->start <= bobuf) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 (dirn > 0 && elt == nelt-1 &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 Dynarr_atp (cache, elt)->end >= eobuf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 return Dynarr_atp (cache, elt)->start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 remain = abspix;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 for (i = elt; (dirn > 0) ? (i < nelt) : (i > 0); i += dirn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 /* cache line we're considering moving over */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 int ii = (dirn > 0) ? i : i-1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 if (remain < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 return Dynarr_atp (cache, i)->start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 line = Dynarr_atp (cache, ii)->height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 next = remain - line;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 /* is stopping condition satisfied? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 if ((how > 0 && remain <= 0) || /* at least */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 (how < 0 && next < 0) || /* at most */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 (how == 0 && remain <= abs (next))) /* closest */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 return Dynarr_atp (cache, i)->start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 /* moving down and nowhere left to go? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 if (dirn > 0 && Dynarr_atp (cache, ii)->end >= eobuf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 return Dynarr_atp (cache, ii)->start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 /* take the step */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 remain = next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 *motion += dirn * line;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 /* moving up and nowhere left to go? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 if (dirn < 0 && Dynarr_atp (cache, ii)->start <= bobuf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863 return Dynarr_atp (cache, ii)->start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 /* get here => need more cache lines. try again. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867 assert (abs (*motion) > previous); /* progress? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 previous = abs (*motion);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 lines = (pixels < 0) ? elt : (nelt - elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 needed += (remain*lines + abspix-1)/abspix + 3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873
1204
e22b0213b713 [xemacs-hg @ 2003-01-12 11:07:58 by michaels]
michaels
parents: 867
diff changeset
874 RETURN_NOT_REACHED(0); /* shut up compiler */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 DEFUN ("vertical-motion-pixels", Fvertical_motion_pixels, 1, 3, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 Move to start of frame line PIXELS vertical pixels down.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 If PIXELS is negative, this is moving up.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 The actual vertical motion in pixels is returned.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 Optional second argument is WINDOW to move in,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 the default is the selected window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 Optional third argument HOW specifies when to stop. A value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 less than zero indicates that the motion should be no more
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 than PIXELS. A value greater than zero indicates that the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 motion should be at least PIXELS. Any other value indicates
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 that the motion should be as close as possible to PIXELS.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 (pixels, window, how))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
893 Charbpos charbpos;
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
894 Charbpos orig;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 int selected;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 int motion;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 int howto;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 struct window *w;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 if (NILP (window))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 window = Fselected_window (Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 CHECK_LIVE_WINDOW (window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 CHECK_INT (pixels);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 selected = (EQ (window, Fselected_window (Qnil)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 w = XWINDOW (window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 orig = selected ? BUF_PT (XBUFFER (w->buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 : marker_position (w->pointm[CURRENT_DISP]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 howto = INTP (how) ? XINT (how) : 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
915 charbpos = vmotion_pixels (window, orig, XINT (pixels), howto, &motion);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 if (selected)
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
918 BUF_SET_PT (XBUFFER (w->buffer), charbpos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 set_marker_restricted (w->pointm[CURRENT_DISP],
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
921 make_int(charbpos),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 w->buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 return make_int (motion);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 syms_of_indent (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 DEFSUBR (Fcurrent_indentation);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 DEFSUBR (Findent_to);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933 DEFSUBR (Fcurrent_column);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 DEFSUBR (Fmove_to_column);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 #if 0 /* #### */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 DEFSUBR (Fcompute_motion);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 DEFSUBR (Fvertical_motion);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 DEFSUBR (Fvertical_motion_pixels);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 444
diff changeset
941 DEFSYMBOL (Qcoerce);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945 vars_of_indent (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 DEFVAR_BOOL ("indent-tabs-mode", &indent_tabs_mode /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 *Indentation can insert tabs if this is non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949 Setting this variable automatically makes it local to the current buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 indent_tabs_mode = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 }