3 * Rob Zimmermann. All rights reserved.
5 * Keith Bostic. All rights reserved.
7 * See the LICENSE file for redistribution information.
13 static const char sccsid
[] = "$Id: m_func.c,v 8.16 1996/12/14 09:04:11 bostic Exp $ (Berkeley) $Date: 1996/12/14 09:04:11 $";
16 #include <sys/types.h>
17 #include <sys/queue.h>
19 #include "Xm/PanedW.h"
21 #include <bitstring.h>
26 #include "../common/common.h"
30 #include "ipc_extern.h"
38 trace("addstr() {%.*s}\n", ipbp
->len
, ipbp
->str
);
40 /* Add to backing store. */
41 memcpy(CharAt(__vi_screen
, __vi_screen
->cury
, __vi_screen
->curx
),
42 ipbp
->str
, ipbp
->len
);
43 memset(FlagAt(__vi_screen
, __vi_screen
->cury
, __vi_screen
->curx
),
44 __vi_screen
->color
, ipbp
->len
);
46 /* Draw from backing store. */
47 __vi_draw_text(__vi_screen
,
48 __vi_screen
->cury
, __vi_screen
->curx
, ipbp
->len
);
50 /* Advance the caret. */
51 __vi_move_caret(__vi_screen
,
52 __vi_screen
->cury
, __vi_screen
->curx
+ ipbp
->len
);
65 __vi_screen
->color
= ipbp
->val2
;
77 * Future... implement visible bell.
79 XBell(XtDisplay(__vi_screen
->area
), 0);
87 __vi_set_cursor(__vi_screen
, 1);
95 __vi_set_cursor(__vi_screen
, 0);
106 len
= __vi_screen
->cols
- __vi_screen
->curx
;
107 ptr
= CharAt(__vi_screen
, __vi_screen
->cury
, __vi_screen
->curx
);
109 /* Clear backing store. */
110 memset(ptr
, ' ', len
);
111 memset(FlagAt(__vi_screen
, __vi_screen
->cury
, __vi_screen
->curx
),
112 COLOR_STANDARD
, len
);
114 /* Draw from backing store. */
115 __vi_draw_text(__vi_screen
, __vi_screen
->cury
, __vi_screen
->curx
, len
);
124 int y
, rows
, len
, height
, width
;
126 y
= __vi_screen
->cury
;
127 rows
= __vi_screen
->rows
- (y
+1);
128 len
= __vi_screen
->cols
* rows
;
130 /* Don't want to copy the caret! */
131 __vi_erase_caret(__vi_screen
);
133 /* Adjust backing store and the flags. */
134 memmove(CharAt(__vi_screen
, y
, 0), CharAt(__vi_screen
, y
+1, 0), len
);
135 memmove(FlagAt(__vi_screen
, y
, 0), FlagAt(__vi_screen
, y
+1, 0), len
);
137 /* Move the bits on the screen. */
138 width
= __vi_screen
->ch_width
* __vi_screen
->cols
;
139 height
= __vi_screen
->ch_height
* rows
;
140 XCopyArea(XtDisplay(__vi_screen
->area
), /* display */
141 XtWindow(__vi_screen
->area
), /* src */
142 XtWindow(__vi_screen
->area
), /* dest */
143 __vi_copy_gc
, /* context */
144 0, YTOP(__vi_screen
, y
+1), /* srcx, srcy */
146 0, YTOP(__vi_screen
, y
) /* dstx, dsty */
148 /* Need to let X take over. */
149 XmUpdateDisplay(__vi_screen
->area
);
166 int y
, rows
, height
, width
;
169 y
= __vi_screen
->cury
;
170 rows
= __vi_screen
->rows
- (1+y
);
171 from
= CharAt(__vi_screen
, y
, 0),
172 to
= CharAt(__vi_screen
, y
+1, 0);
174 /* Don't want to copy the caret! */
175 __vi_erase_caret(__vi_screen
);
177 /* Adjust backing store. */
178 memmove(to
, from
, __vi_screen
->cols
* rows
);
179 memset(from
, ' ', __vi_screen
->cols
);
181 /* And the backing store. */
182 from
= FlagAt(__vi_screen
, y
, 0),
183 to
= FlagAt(__vi_screen
, y
+1, 0);
184 memmove(to
, from
, __vi_screen
->cols
* rows
);
185 memset(from
, COLOR_STANDARD
, __vi_screen
->cols
);
187 /* Move the bits on the screen. */
188 width
= __vi_screen
->ch_width
* __vi_screen
->cols
;
189 height
= __vi_screen
->ch_height
* rows
;
191 XCopyArea(XtDisplay(__vi_screen
->area
), /* display */
192 XtWindow(__vi_screen
->area
), /* src */
193 XtWindow(__vi_screen
->area
), /* dest */
194 __vi_copy_gc
, /* context */
195 0, YTOP(__vi_screen
, y
), /* srcx, srcy */
197 0, YTOP(__vi_screen
, y
+1) /* dstx, dsty */
200 /* clear out the new space */
201 XClearArea(XtDisplay(__vi_screen
->area
), /* display */
202 XtWindow(__vi_screen
->area
), /* window */
203 0, YTOP(__vi_screen
, y
), /* srcx, srcy */
204 0, __vi_screen
->ch_height
, /* w=full, height */
205 True
/* no exposures */
208 /* Need to let X take over. */
209 XmUpdateDisplay(__vi_screen
->area
);
218 __vi_move_caret(__vi_screen
, ipbp
->val1
, ipbp
->val2
);
226 __vi_expose_func(0, __vi_screen
, 0);
234 /* probably ok to scroll again */
235 __vi_clear_scroll_block();
237 /* if the tag stack widget is active, set the text field there
238 * to agree with the current caret position.
239 * Note that this really ought to be done by core due to wrapping issues
241 __vi_set_word_at_caret( __vi_screen
);
243 /* similarly, the text ruler... */
244 __vi_set_text_ruler( __vi_screen
->cury
, __vi_screen
->curx
);
253 if (__vi_exitp
!= NULL
)
266 /* For the icon, use the tail. */
267 if ((tail
= strrchr(ipbp
->str
, '/')) == NULL
|| *(tail
+ 1) == '\0')
274 * Future: Attach a title to each screen. For now, we change
275 * the title of the shell.
277 shell
= __vi_screen
->area
;
278 while ( ! XtIsShell(shell
) ) shell
= XtParent(shell
);
300 int top
, size
, maximum
, old_max
;
303 * val1 contains the top visible line number
304 * val2 contains the number of visible lines
305 * val3 contains the number of lines in the file
309 maximum
= ipbp
->val3
;
312 fprintf( stderr
, "Setting scrollbar\n" );
313 fprintf( stderr
, "\tvalue\t\t%d\n", top
);
314 fprintf( stderr
, "\tsize\t\t%d\n", size
);
315 fprintf( stderr
, "\tmaximum\t\t%d\n", maximum
);
318 /* armor plating. core thinks there are no lines in an
319 * empty file, but says we are on line 1
321 if ( top
> maximum
) {
323 fprintf( stderr
, "Correcting for top > maximum\n" );
329 /* armor plating. core may think there are more
330 * lines visible than remain in the file
332 if ( top
+size
>= maximum
) {
334 fprintf( stderr
, "Correcting for top+size >= maximum\n" );
336 size
= maximum
- top
;
339 /* need to increase the maximum before changing the values */
340 XtVaGetValues( __vi_screen
->scroll
, XmNmaximum
, &old_max
, 0 );
341 if ( maximum
> old_max
)
342 XtVaSetValues( __vi_screen
->scroll
, XmNmaximum
, maximum
, 0 );
344 /* change the rest of the values without generating a callback */
345 XmScrollBarSetValues( __vi_screen
->scroll
,
349 size
, /* page_increment */
350 False
/* do not notify me */
353 /* need to decrease the maximum after changing the values */
354 if ( maximum
< old_max
)
355 XtVaSetValues( __vi_screen
->scroll
, XmNmaximum
, maximum
, 0 );
369 int (*__vi_iplist
[SI_EVENT_MAX
]) __P((IP_BUF
*)) = {