2
* $XConsortium: util.c,v 1.31 91/06/20 18:34:47 gildea Exp $
3
* $Id: util.c,v 6.3 1996/07/02 05:01:31 kagotani Rel $
7
* Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
11
* Permission to use, copy, modify, and distribute this software and its
12
* documentation for any purpose and without fee is hereby granted,
13
* provided that the above copyright notice appear in all copies and that
14
* both that copyright notice and this permission notice appear in
15
* supporting documentation, and that the name of Digital Equipment
16
* Corporation not be used in advertising or publicity pertaining to
17
* distribution of the software without specific, written prior permission.
20
* DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
21
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
22
* DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
23
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
24
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
25
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
38
static void horizontal_copy_area();
39
static void vertical_copy_area();
42
static int fnum = F_ISO8859_1; /* refered by *GC in many functions */
46
* These routines are used for the jump scroll feature
49
register TScreen *screen;
52
register int shift = -screen->topline;
53
register int bot = screen->max_row - shift;
54
register int refreshtop;
55
register int refreshheight;
56
register int scrolltop;
57
register int scrollheight;
59
if(screen->cursor_state)
61
if(screen->scroll_amt > 0) {
62
refreshheight = screen->refresh_amt;
63
scrollheight = screen->bot_marg - screen->top_marg -
65
if((refreshtop = screen->bot_marg - refreshheight + 1 + shift) >
66
(i = screen->max_row - screen->scroll_amt + 1))
68
if(screen->scrollWidget && !screen->alternate
69
&& screen->top_marg == 0) {
71
if((scrollheight += shift) > i)
73
if((i = screen->bot_marg - bot) > 0 &&
74
(refreshheight -= i) < screen->scroll_amt)
75
refreshheight = screen->scroll_amt;
76
if((i = screen->savedlines) < screen->savelines) {
77
if((i += screen->scroll_amt) >
79
i = screen->savelines;
80
screen->savedlines = i;
81
ScrollBarDrawThumb(screen->scrollWidget);
84
scrolltop = screen->top_marg + shift;
85
if((i = bot - (screen->bot_marg - screen->refresh_amt +
86
screen->scroll_amt)) > 0) {
87
if(bot < screen->bot_marg)
88
refreshheight = screen->scroll_amt + i;
91
refreshheight = screen->scroll_amt;
92
if((i = screen->top_marg + screen->scroll_amt -
100
refreshheight = -screen->refresh_amt;
101
scrollheight = screen->bot_marg - screen->top_marg -
103
refreshtop = screen->top_marg + shift;
104
scrolltop = refreshtop + refreshheight;
105
if((i = screen->bot_marg - bot) > 0)
107
if((i = screen->top_marg + refreshheight - 1 - bot) > 0)
110
scrolling_copy_area(screen, scrolltop+screen->scroll_amt,
111
scrollheight, screen->scroll_amt);
112
ScrollSelection(screen, -(screen->scroll_amt));
113
screen->scroll_amt = 0;
114
screen->refresh_amt = 0;
115
if(refreshheight > 0) {
119
(int) screen->border + screen->scrollbar,
120
(int) refreshtop * FontHeight(screen) + screen->border,
121
(unsigned) Width(screen),
122
(unsigned) refreshheight * FontHeight(screen),
124
ScrnRefresh(screen, refreshtop, 0, refreshheight,
125
screen->max_col + 1, False);
130
register TScreen *screen;
132
register int amount = screen->refresh_amt;
133
register int row = screen->cur_row;
136
if(amount == 0 || screen->instatus)
137
#else /* !STATUSLINE */
139
#endif /* !STATUSLINE */
144
if(row == (bottom = screen->bot_marg) - amount) {
145
screen->refresh_amt++;
148
return(row >= bottom - amount + 1 && row <= bottom);
153
if(row == (top = screen->top_marg) + amount) {
154
screen->refresh_amt--;
157
return(row <= top + amount - 1 && row >= top);
162
* scrolls the screen by amount lines, erases bottom, doesn't alter
163
* cursor position (i.e. cursor moves down amount relative to text).
164
* All done within the scrolling region, of course.
165
* requires: amount > 0
167
Scroll(screen, amount)
168
register TScreen *screen;
171
register int i = screen->bot_marg - screen->top_marg + 1;
174
register int refreshtop = 0;
175
register int refreshheight;
176
register int scrolltop;
177
register int scrollheight;
179
if(screen->cursor_state)
183
if(screen->jumpscroll) {
184
if(screen->scroll_amt > 0) {
185
if(screen->refresh_amt + amount > i)
187
screen->scroll_amt += amount;
188
screen->refresh_amt += amount;
190
if(screen->scroll_amt < 0)
192
screen->scroll_amt = amount;
193
screen->refresh_amt = amount;
197
ScrollSelection(screen, -(amount));
202
shift = -screen->topline;
203
bot = screen->max_row - shift;
204
scrollheight = i - amount;
205
refreshheight = amount;
206
if((refreshtop = screen->bot_marg - refreshheight + 1 + shift) >
207
(i = screen->max_row - refreshheight + 1))
209
if(screen->scrollWidget && !screen->alternate
210
&& screen->top_marg == 0) {
212
if((scrollheight += shift) > i)
214
if((i = screen->savedlines) < screen->savelines) {
215
if((i += amount) > screen->savelines)
216
i = screen->savelines;
217
screen->savedlines = i;
218
ScrollBarDrawThumb(screen->scrollWidget);
221
scrolltop = screen->top_marg + shift;
222
if((i = screen->bot_marg - bot) > 0) {
224
if((i = screen->top_marg + amount - 1 - bot) >= 0) {
231
if (screen->multiscroll && amount == 1 &&
232
screen->topline == 0 && screen->top_marg == 0 &&
233
screen->bot_marg == screen->max_row) {
234
if (screen->incopy < 0 && screen->scrolls == 0)
238
scrolling_copy_area(screen, scrolltop+amount, scrollheight, amount);
239
if(refreshheight > 0) {
243
(int) screen->border + screen->scrollbar,
244
(int) refreshtop * FontHeight(screen) + screen->border,
245
(unsigned) Width(screen),
246
(unsigned) refreshheight * FontHeight(screen),
248
if(refreshheight > shift)
249
refreshheight = shift;
252
if(screen->scrollWidget && !screen->alternate && screen->top_marg == 0)
253
ScrnDeleteLine(screen->allbuf, screen->bot_marg +
254
screen->savelines, 0, amount, screen->max_col + 1);
256
ScrnDeleteLine(screen->buf, screen->bot_marg, screen->top_marg,
257
amount, screen->max_col + 1);
258
if(refreshheight > 0)
259
ScrnRefresh(screen, refreshtop, 0, refreshheight,
260
screen->max_col + 1, False);
265
* Reverse scrolls the screen by amount lines, erases top, doesn't alter
266
* cursor position (i.e. cursor moves up amount relative to text).
267
* All done within the scrolling region, of course.
268
* Requires: amount > 0
270
RevScroll(screen, amount)
271
register TScreen *screen;
274
register int i = screen->bot_marg - screen->top_marg + 1;
277
register int refreshtop;
278
register int refreshheight;
279
register int scrolltop;
280
register int scrollheight;
282
if(screen->cursor_state)
286
if(screen->jumpscroll) {
287
if(screen->scroll_amt < 0) {
288
if(-screen->refresh_amt + amount > i)
290
screen->scroll_amt -= amount;
291
screen->refresh_amt -= amount;
293
if(screen->scroll_amt > 0)
295
screen->scroll_amt = -amount;
296
screen->refresh_amt = -amount;
299
shift = -screen->topline;
300
bot = screen->max_row - shift;
301
refreshheight = amount;
302
scrollheight = screen->bot_marg - screen->top_marg -
304
refreshtop = screen->top_marg + shift;
305
scrolltop = refreshtop + refreshheight;
306
if((i = screen->bot_marg - bot) > 0)
308
if((i = screen->top_marg + refreshheight - 1 - bot) > 0)
311
if (screen->multiscroll && amount == 1 &&
312
screen->topline == 0 && screen->top_marg == 0 &&
313
screen->bot_marg == screen->max_row) {
314
if (screen->incopy < 0 && screen->scrolls == 0)
318
scrolling_copy_area(screen, scrolltop-amount, scrollheight, -amount);
319
if(refreshheight > 0)
323
(int) screen->border + screen->scrollbar,
324
(int) refreshtop * FontHeight(screen) + screen->border,
325
(unsigned) Width(screen),
326
(unsigned) refreshheight * FontHeight(screen),
329
ScrnInsertLine (screen->buf, screen->bot_marg, screen->top_marg,
330
amount, screen->max_col + 1);
334
* If cursor not in scrolling region, returns. Else,
335
* inserts n blank lines at the cursor's position. Lines above the
336
* bottom margin are lost.
338
InsertLine (screen, n)
339
register TScreen *screen;
345
register int refreshtop;
346
register int refreshheight;
347
register int scrolltop;
348
register int scrollheight;
350
if (screen->cur_row < screen->top_marg ||
351
screen->cur_row > screen->bot_marg)
353
if(screen->cursor_state)
356
if (n > (i = screen->bot_marg - screen->cur_row + 1))
358
if(screen->jumpscroll) {
359
if(screen->scroll_amt <= 0 &&
360
screen->cur_row <= -screen->refresh_amt) {
361
if(-screen->refresh_amt + n > screen->max_row + 1)
363
screen->scroll_amt -= n;
364
screen->refresh_amt -= n;
365
} else if(screen->scroll_amt)
368
if(!screen->scroll_amt) {
369
shift = -screen->topline;
370
bot = screen->max_row - shift;
372
scrollheight = screen->bot_marg - screen->cur_row - refreshheight + 1;
373
refreshtop = screen->cur_row + shift;
374
scrolltop = refreshtop + refreshheight;
375
if((i = screen->bot_marg - bot) > 0)
377
if((i = screen->cur_row + refreshheight - 1 - bot) > 0)
379
vertical_copy_area(screen, scrolltop-n, scrollheight, -n);
380
if(refreshheight > 0)
384
(int) screen->border + screen->scrollbar,
385
(int) refreshtop * FontHeight(screen) + screen->border,
386
(unsigned) Width(screen),
387
(unsigned) refreshheight * FontHeight(screen),
390
/* adjust screen->buf */
391
ScrnInsertLine(screen->buf, screen->bot_marg, screen->cur_row, n,
392
screen->max_col + 1);
396
* If cursor not in scrolling region, returns. Else, deletes n lines
397
* at the cursor's position, lines added at bottom margin are blank.
399
DeleteLine(screen, n)
400
register TScreen *screen;
406
register int refreshtop;
407
register int refreshheight;
408
register int scrolltop;
409
register int scrollheight;
411
if (screen->cur_row < screen->top_marg ||
412
screen->cur_row > screen->bot_marg)
414
if(screen->cursor_state)
417
if (n > (i = screen->bot_marg - screen->cur_row + 1))
419
if(screen->jumpscroll) {
420
if(screen->scroll_amt >= 0 && screen->cur_row == screen->top_marg) {
421
if(screen->refresh_amt + n > screen->max_row + 1)
423
screen->scroll_amt += n;
424
screen->refresh_amt += n;
425
} else if(screen->scroll_amt)
428
if(!screen->scroll_amt) {
430
shift = -screen->topline;
431
bot = screen->max_row - shift;
432
scrollheight = i - n;
434
if((refreshtop = screen->bot_marg - refreshheight + 1 + shift) >
435
(i = screen->max_row - refreshheight + 1))
437
if(screen->scrollWidget && !screen->alternate && screen->cur_row == 0) {
439
if((scrollheight += shift) > i)
441
if((i = screen->savedlines) < screen->savelines) {
442
if((i += n) > screen->savelines)
443
i = screen->savelines;
444
screen->savedlines = i;
445
ScrollBarDrawThumb(screen->scrollWidget);
448
scrolltop = screen->cur_row + shift;
449
if((i = screen->bot_marg - bot) > 0) {
451
if((i = screen->cur_row + n - 1 - bot) >= 0) {
456
vertical_copy_area(screen, scrolltop+n, scrollheight, n);
457
if(refreshheight > 0)
461
(int) screen->border + screen->scrollbar,
462
(int) refreshtop * FontHeight(screen) + screen->border,
463
(unsigned) Width(screen),
464
(unsigned) refreshheight * FontHeight(screen),
467
/* adjust screen->buf */
468
if(screen->scrollWidget && !screen->alternate && screen->cur_row == 0)
469
ScrnDeleteLine(screen->allbuf, screen->bot_marg +
470
screen->savelines, 0, n, screen->max_col + 1);
472
ScrnDeleteLine(screen->buf, screen->bot_marg, screen->cur_row,
473
n, screen->max_col + 1);
477
* Insert n blanks at the cursor's position, no wraparound
479
InsertChar (screen, n)
480
register TScreen *screen;
485
if(screen->cursor_state)
490
#endif /* KTERM_MBCS */
492
if(screen->cur_row - screen->topline <= screen->max_row ||
494
#else /* !STATUSLINE */
495
if(screen->cur_row - screen->topline <= screen->max_row) {
496
#endif /* !STATUSLINE */
497
if(!AddToRefresh(screen)) {
498
if(screen->scroll_amt)
502
* prevent InsertChar from shifting the end of a line over
503
* if it is being appended to
505
if (non_blank_line (screen->buf, screen->cur_row,
506
screen->cur_col, screen->max_col + 1))
507
horizontal_copy_area(screen, screen->cur_col,
508
screen->max_col+1 - (screen->cur_col+n),
511
cx = CursorX (screen, screen->cur_col);
512
cy = CursorY (screen, screen->cur_row);
518
screen->instatus && screen->reversestatus ?
520
#endif /* STATUSLINE */
523
(unsigned) n * FontWidth(screen), (unsigned) FontHeight(screen));
526
/* adjust screen->buf */
527
ScrnInsertChar(screen->buf, screen->cur_row, screen->cur_col, n,
528
screen->max_col + 1);
532
* Deletes n chars at the cursor's position, no wraparound.
534
DeleteChar (screen, n)
535
register TScreen *screen;
540
if(screen->cursor_state)
543
if (n > (width = screen->max_col + 1 - screen->cur_col))
548
screen->cur_col += n;
550
screen->cur_col -= n;
551
#endif /* KTERM_MBCS */
553
if(screen->cur_row - screen->topline <= screen->max_row ||
555
#else /* !STATUSLINE */
556
if(screen->cur_row - screen->topline <= screen->max_row) {
557
#endif /* !STATUSLINE */
558
if(!AddToRefresh(screen)) {
559
if(screen->scroll_amt)
562
horizontal_copy_area(screen, screen->cur_col+n,
563
screen->max_col+1 - (screen->cur_col+n),
567
(screen->display, TextWindow(screen),
569
screen->instatus && screen->reversestatus ?
571
#endif /* STATUSLINE */
573
screen->border + screen->scrollbar
574
+ Width(screen) - n*FontWidth(screen),
575
CursorY (screen, screen->cur_row), n * FontWidth(screen),
579
/* adjust screen->buf */
580
ScrnDeleteChar (screen->buf, screen->cur_row, screen->cur_col, n,
581
screen->max_col + 1);
586
* Clear from cursor position to beginning of display, inclusive.
589
register TScreen *screen;
591
register top, height;
593
if(screen->cursor_state)
595
if((top = -screen->topline) <= screen->max_row) {
596
if(screen->scroll_amt)
598
if((height = screen->cur_row + top) > screen->max_row)
599
height = screen->max_row;
600
if((height -= top) > 0)
601
XClearArea(screen->display, TextWindow(screen),
602
screen->border + screen->scrollbar, top *
603
FontHeight(screen) + screen->border,
604
Width(screen), height * FontHeight(screen), FALSE);
606
if(screen->cur_row - screen->topline <= screen->max_row)
609
ClearBufRows(screen, 0, screen->cur_row - 1);
613
* Clear from cursor position to end of display, inclusive.
616
register TScreen *screen;
621
if((top = screen->cur_row - screen->topline) <= screen->max_row) {
622
if(screen->scroll_amt)
624
if(++top <= screen->max_row)
625
XClearArea(screen->display, TextWindow(screen),
626
screen->border + screen->scrollbar, top *
627
FontHeight(screen) + screen->border,
628
Width(screen), (screen->max_row - top + 1) *
629
FontHeight(screen), FALSE);
631
ClearBufRows(screen, screen->cur_row + 1, screen->max_row);
635
* Clear last part of cursor's line, inclusive.
638
register TScreen *screen;
640
if(screen->cursor_state)
645
#endif /* KTERM_MBCS */
647
if(screen->cur_row - screen->topline <= screen->max_row ||
649
#else /* !STATUSLINE */
650
if(screen->cur_row - screen->topline <= screen->max_row) {
651
#endif /* !STATUSLINE */
652
if(!AddToRefresh(screen)) {
653
if(screen->scroll_amt)
655
XFillRectangle(screen->display, TextWindow(screen),
657
screen->instatus && screen->reversestatus ?
659
#endif /* STATUSLINE */
661
CursorX(screen, screen->cur_col),
662
CursorY(screen, screen->cur_row),
663
Width(screen) - screen->cur_col * FontWidth(screen),
668
bzero(screen->buf[screen->cur_row] + screen->cur_col,
669
(screen->max_col - screen->cur_col + 1) * sizeof(Bchr));
670
/* with the right part cleared, we can't be wrapping */
671
screen->buf [screen->cur_row] [0].attr &= ~LINEWRAPPED;
673
bzero(screen->buf [2 * screen->cur_row] + screen->cur_col,
674
(screen->max_col - screen->cur_col + 1));
675
bzero(screen->buf [2 * screen->cur_row + 1] + screen->cur_col,
676
(screen->max_col - screen->cur_col + 1));
677
/* with the right part cleared, we can't be wrapping */
678
screen->buf [2 * screen->cur_row + 1] [0] &= ~LINEWRAPPED;
683
* Clear first part of cursor's line, inclusive.
686
register TScreen *screen;
695
if(screen->cursor_state)
700
#endif /* KTERM_MBCS */
702
if(screen->cur_row - screen->topline <= screen->max_row ||
704
#else /* !STATUSLINE */
705
if(screen->cur_row - screen->topline <= screen->max_row) {
706
#endif /* !STATUSLINE */
707
if(!AddToRefresh(screen)) {
708
if(screen->scroll_amt)
710
XFillRectangle (screen->display, TextWindow(screen),
712
screen->instatus && screen->reversestatus ?
714
#endif /* STATUSLINE */
716
screen->border + screen->scrollbar,
717
CursorY (screen, screen->cur_row),
718
(screen->cur_col + 1) * FontWidth(screen),
724
for ( i=0, cp=screen->buf[screen->cur_row];
725
i < screen->cur_col + 1;
727
cp->gset = GSET_ASCII;
729
cp->attr = CHARDRAWN;
732
for ( i=0, cp=screen->buf[2 * screen->cur_row];
733
i < screen->cur_col + 1;
736
for ( i=0, cp=screen->buf[2 * screen->cur_row + 1];
737
i < screen->cur_col + 1;
744
* Erase the cursor's line.
747
register TScreen *screen;
749
if(screen->cursor_state)
753
if(screen->cur_row - screen->topline <= screen->max_row ||
755
#else /* !STATUSLINE */
756
if(screen->cur_row - screen->topline <= screen->max_row) {
757
#endif /* !STATUSLINE */
758
if(!AddToRefresh(screen)) {
759
if(screen->scroll_amt)
761
XFillRectangle (screen->display, TextWindow(screen),
763
screen->instatus && screen->reversestatus ?
765
#endif /* STATUSLINE */
767
screen->border + screen->scrollbar,
768
CursorY (screen, screen->cur_row),
769
Width(screen), FontHeight(screen));
773
bzero (screen->buf[screen->cur_row], (screen->max_col + 1) * sizeof(Bchr));
775
bzero (screen->buf [2 * screen->cur_row], (screen->max_col + 1));
776
bzero (screen->buf [2 * screen->cur_row + 1], (screen->max_col + 1));
781
register TScreen *screen;
785
if(screen->cursor_state)
788
if((top = -screen->topline) <= screen->max_row) {
789
if(screen->scroll_amt)
792
if(top == 0 && !screen->statusheight)
793
#else /* !STATUSLINE */
795
#endif /* !STATUSLINE */
796
XClearWindow(screen->display, TextWindow(screen));
798
XClearArea(screen->display, TextWindow(screen),
799
screen->border + screen->scrollbar,
800
top * FontHeight(screen) + screen->border,
801
Width(screen), (screen->max_row - top + 1) *
802
FontHeight(screen), FALSE);
804
ClearBufRows (screen, 0, screen->max_row);
808
register TScreen *screen;
811
XEvent *rep = &reply;
814
XWindowEvent (screen->display, VWindow(screen),
815
ExposureMask, &reply);
816
switch (reply.type) {
818
HandleExposure (screen, &reply);
822
if (screen->incopy <= 0) {
824
if (screen->scrolls > 0)
827
if (reply.type == GraphicsExpose)
828
HandleExposure (screen, &reply);
830
if ((reply.type == NoExpose) ||
831
((XExposeEvent *)rep)->count == 0) {
832
if (screen->incopy <= 0 && screen->scrolls > 0)
834
if (screen->scrolls == 0) {
846
* used by vertical_copy_area and and horizontal_copy_area
849
copy_area(screen, src_x, src_y, width, height, dest_x, dest_y)
852
unsigned int width, height;
858
/* wait for previous CopyArea to complete unless
859
multiscroll is enabled and active */
860
if (screen->incopy && screen->scrolls == 0)
864
/* save for translating Expose events */
865
screen->copy_src_x = src_x;
866
screen->copy_src_y = src_y;
867
screen->copy_width = width;
868
screen->copy_height = height;
869
screen->copy_dest_x = dest_x;
870
screen->copy_dest_y = dest_y;
874
copygc = XtGetGC((Widget)term, 0, NULL); /* graphics_exposures = TRUE */
875
XCopyArea(screen->display,
876
TextWindow(screen), TextWindow(screen),
878
src_x, src_y, width, height, dest_x, dest_y);
880
XCopyArea(screen->display,
881
TextWindow(screen), TextWindow(screen),
883
src_x, src_y, width, height, dest_x, dest_y);
888
* use when inserting or deleting characters on the current line
891
horizontal_copy_area(screen, firstchar, nchars, amount)
893
int firstchar; /* char pos on screen to start copying at */
895
int amount; /* number of characters to move right */
897
int src_x = CursorX(screen, firstchar);
898
int src_y = CursorY(screen, screen->cur_row);
900
copy_area(screen, src_x, src_y,
901
(unsigned)nchars*FontWidth(screen), FontHeight(screen),
902
src_x + amount*FontWidth(screen), src_y);
906
* use when inserting or deleting lines from the screen
909
vertical_copy_area(screen, firstline, nlines, amount)
911
int firstline; /* line on screen to start copying at */
913
int amount; /* number of lines to move up (neg=down) */
916
int src_x = screen->border + screen->scrollbar;
917
int src_y = firstline * FontHeight(screen) + screen->border;
919
copy_area(screen, src_x, src_y,
920
(unsigned)Width(screen), nlines*FontHeight(screen),
921
src_x, src_y - amount*FontHeight(screen));
926
* use when scrolling the entire screen
928
scrolling_copy_area(screen, firstline, nlines, amount)
930
int firstline; /* line on screen to start copying at */
932
int amount; /* number of lines to move up (neg=down) */
936
vertical_copy_area(screen, firstline, nlines, amount);
941
* Handler for Expose events on the VT widget.
942
* Returns 1 iff the area where the cursor was got refreshed.
944
HandleExposure (screen, event)
945
register TScreen *screen;
946
register XEvent *event;
948
register XExposeEvent *reply = (XExposeEvent *)event;
950
/* if not doing CopyArea or if this is a GraphicsExpose, don't translate */
951
if(!screen->incopy || event->type != Expose)
952
return handle_translated_exposure (screen, reply->x, reply->y,
953
reply->width, reply->height);
955
/* compute intersection of area being copied with
956
area being exposed. */
957
int both_x1 = Max(screen->copy_src_x, reply->x);
958
int both_y1 = Max(screen->copy_src_y, reply->y);
959
int both_x2 = Min(screen->copy_src_x+screen->copy_width,
960
reply->x+reply->width);
961
int both_y2 = Min(screen->copy_src_y+screen->copy_height,
962
reply->y+reply->height);
965
/* was anything copied affected? */
966
if(both_x2 > both_x1 && both_y2 > both_y1) {
967
/* do the copied area */
968
value = handle_translated_exposure
969
(screen, reply->x + screen->copy_dest_x - screen->copy_src_x,
970
reply->y + screen->copy_dest_y - screen->copy_src_y,
971
reply->width, reply->height);
973
/* was anything not copied affected? */
974
if(reply->x < both_x1 || reply->y < both_y1
975
|| reply->x+reply->width > both_x2
976
|| reply->y+reply->height > both_y2)
977
value = handle_translated_exposure (screen, reply->x, reply->y,
978
reply->width, reply->height);
985
* Called by the ExposeHandler to do the actual repaint after the coordinates
986
* have been translated to allow for any CopyArea in progress.
987
* The rectangle passed in is pixel coordinates.
989
handle_translated_exposure (screen, rect_x, rect_y, rect_width, rect_height)
990
register TScreen *screen;
991
register int rect_x, rect_y;
992
register unsigned int rect_width, rect_height;
994
register int toprow, leftcol, nrows, ncols;
995
extern Bool waiting_for_initial_map;
997
toprow = (rect_y - screen->border) / FontHeight(screen);
1001
if(toprow > screen->max_row + 1)
1002
toprow = screen->max_row + 1;
1003
#endif /* STATUSLINE */
1004
leftcol = (rect_x - screen->border - screen->scrollbar)
1005
/ FontWidth(screen);
1008
nrows = (rect_y + rect_height - 1 - screen->border) /
1009
FontHeight(screen) - toprow + 1;
1011
(rect_x + rect_width - 1 - screen->border - screen->scrollbar) /
1012
FontWidth(screen) - leftcol + 1;
1013
toprow -= screen->scrolls;
1018
if (toprow + nrows - 1 > screen->max_row)
1020
nrows = screen->max_row - toprow + 1 + !!screen->statusheight;
1021
/* !!statusheight == (statusheight ? 1 : 0) */
1022
#else /* !STATUSLINE */
1023
nrows = screen->max_row - toprow + 1;
1024
#endif /* !STATUSLINE */
1025
if (leftcol + ncols - 1 > screen->max_col)
1026
ncols = screen->max_col - leftcol + 1;
1028
if (nrows > 0 && ncols > 0) {
1029
ScrnRefresh (screen, toprow, leftcol, nrows, ncols, False);
1030
if (waiting_for_initial_map) {
1031
first_map_occurred ();
1033
if (screen->cur_row >= toprow &&
1034
screen->cur_row < toprow + nrows &&
1035
screen->cur_col >= leftcol &&
1036
screen->cur_col < leftcol + ncols)
1043
ReverseVideo (termw)
1046
register TScreen *screen = &termw->screen;
1049
Window tek = TWindow(screen);
1050
#endif /* !KTERM_NOTEK */
1056
tmp = termw->core.background_pixel;
1057
if(screen->cursorcolor == screen->foreground)
1058
screen->cursorcolor = tmp;
1059
termw->core.background_pixel = screen->foreground;
1060
screen->foreground = tmp;
1062
tmp = screen->mousecolorback;
1063
screen->mousecolorback = screen->mousecolor;
1064
screen->mousecolor = tmp;
1067
for (fnum=F_ISO8859_1; fnum<FCNT; fnum++) {
1068
tmpGC = screen->normalGC;
1069
screen->normalGC = screen->reverseGC;
1070
screen->reverseGC = tmpGC;
1072
tmpGC = screen->normalboldGC;
1073
screen->normalboldGC = screen->reverseboldGC;
1074
screen->reverseboldGC = tmpGC;
1076
tmpGC = screen->cursorGC;
1077
screen->cursorGC = screen->reversecursorGC;
1078
screen->reversecursorGC = tmpGC;
1081
tmpGC = screen->normalGC;
1082
screen->normalGC = screen->reverseGC;
1083
screen->reverseGC = tmpGC;
1085
tmpGC = screen->normalboldGC;
1086
screen->normalboldGC = screen->reverseboldGC;
1087
screen->reverseboldGC = tmpGC;
1090
* Bug fix by michael
1091
* 3 non null lines are inserted.
1093
tmpGC = screen->cursorGC;
1094
screen->cursorGC = screen->reversecursorGC;
1095
screen->reversecursorGC = tmpGC;
1096
# endif /* !ENBUG */
1099
recolor_cursor (screen->pointer_cursor,
1100
screen->mousecolor, screen->mousecolorback);
1101
recolor_cursor (screen->arrow,
1102
screen->mousecolor, screen->mousecolorback);
1104
termw->misc.re_verse = !termw->misc.re_verse;
1106
XDefineCursor(screen->display, TextWindow(screen), screen->pointer_cursor);
1109
XDefineCursor(screen->display, tek, screen->arrow);
1110
#endif /* !KTERM_NOTEK */
1113
if(screen->scrollWidget)
1114
ScrollBarReverseVideo(screen->scrollWidget);
1116
XSetWindowBackground(screen->display, TextWindow(screen), termw->core.background_pixel);
1119
TekReverseVideo(screen);
1121
#endif /* !KTERM_NOTEK */
1122
XClearWindow(screen->display, TextWindow(screen));
1124
ScrnRefresh (screen, 0, 0, screen->max_row + 1 + !!screen->statusheight,
1125
/* !!statusheight == (statusheight ? 1 : 0) */
1126
#else /* !STATUSLINE */
1127
ScrnRefresh (screen, 0, 0, screen->max_row + 1,
1128
#endif /* !STATUSLINE */
1129
screen->max_col + 1, False);
1132
XClearWindow(screen->display, tek);
1133
TekExpose((Widget)NULL, (XEvent *)NULL, (Region)NULL);
1135
#endif /* !KTERM_NOTEK */
1136
update_reversevideo();
1138
IMSendColor(screen);
1139
#endif /* KTERM_XIM */
1140
#ifdef KTERM_KINPUT2
1142
#endif /* KTERM_KINPUT2 */
1146
recolor_cursor (cursor, fg, bg)
1147
Cursor cursor; /* X cursor ID to set */
1148
unsigned long fg, bg; /* pixel indexes to look up */
1150
register TScreen *screen = &term->screen;
1151
register Display *dpy = screen->display;
1152
XColor colordefs[2]; /* 0 is foreground, 1 is background */
1154
colordefs[0].pixel = fg;
1155
colordefs[1].pixel = bg;
1156
XQueryColors (dpy, DefaultColormap (dpy, DefaultScreen (dpy)),
1158
XRecolorCursor (dpy, cursor, colordefs, colordefs+1);
1164
* If the cursor points the second byte of a multi byte character,
1165
* replace this character with two blanks.
1168
register TScreen *screen;
1171
if (screen->cur_col >= 1 && screen->cur_col <= screen->max_col
1172
&& screen->buf[screen->cur_row][screen->cur_col].gset == MBC2) {
1175
if(screen->cur_row - screen->topline <= screen->max_row ||
1177
#else /* !STATUSLINE */
1178
if(screen->cur_row - screen->topline <= screen->max_row) {
1179
#endif /* !STATUSLINE */
1180
if(!AddToRefresh(screen)) {
1181
if(screen->scroll_amt)
1182
FlushScroll(screen);
1183
XFillRectangle(screen->display, TextWindow(screen),
1185
screen->instatus && screen->reversestatus ?
1187
#endif /* STATUSLINE */
1189
CursorX(screen, screen->cur_col - 1),
1190
CursorY(screen, screen->cur_row),
1191
2 * FontWidth(screen), FontHeight(screen));
1194
ptr = screen->buf[screen->cur_row] + screen->cur_col - 1;
1195
bzero((char*)ptr, 2 * sizeof(Bchr));
1199
#endif /* KTERM_MBCS */