home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
x
/
volume12
/
kterm
/
part18
< prev
next >
Wrap
Internet Message Format
|
1991-05-11
|
21KB
Path: uunet!cs.utexas.edu!sun-barr!newstop!jethro!exodus!NMSU.Edu!mleisher
From: mleisher@NMSU.Edu
Newsgroups: comp.sources.x
Subject: v12i099: kterm - kanji xterm, Part18/18
Message-ID: <13151@exodus.Eng.Sun.COM>
Date: 11 May 91 00:52:28 GMT
References: <csx-12i082:kterm@uunet.UU.NET>
Sender: news@exodus.Eng.Sun.COM
Lines: 719
Approved: argv@sun.com
Submitted-by: mleisher@NMSU.Edu
Posting-number: Volume 12, Issue 99
Archive-name: kterm/part18
#!/bin/sh
# this is kt412.18 (part 18 of kterm-4.1.2)
# do not concatenate these parts, unpack them in order with /bin/sh
# file kterm-4.1.2/util.c continued
#
if test ! -r _shar_seq_.tmp; then
echo 'Please unpack part 1 first!'
exit 1
fi
(read Scheck
if test "$Scheck" != 18; then
echo Please unpack part "$Scheck" next!
exit 1
else
exit 0
fi
) < _shar_seq_.tmp || exit 1
if test ! -f _shar_wnt_.tmp; then
echo 'x - still skipping kterm-4.1.2/util.c'
else
echo 'x - continuing file kterm-4.1.2/util.c'
sed 's/^X//' << 'SHAR_EOF' >> 'kterm-4.1.2/util.c' &&
X if(screen->cursor_state)
X HideCursor();
X screen->do_wrap = 0;
X if (n > (i = screen->bot_marg - screen->cur_row + 1))
X n = i;
X if(screen->jumpscroll) {
X if(screen->scroll_amt >= 0 && screen->cur_row == screen->top_marg) {
X if(screen->refresh_amt + n > screen->max_row + 1)
X FlushScroll(screen);
X screen->scroll_amt += n;
X screen->refresh_amt += n;
X } else if(screen->scroll_amt)
X FlushScroll(screen);
X }
X if(!screen->scroll_amt) {
X
X shift = -screen->topline;
X bot = screen->max_row - shift;
X scrollheight = i - n;
X refreshheight = n;
X if((refreshtop = screen->bot_marg - refreshheight + 1 + shift) >
X (i = screen->max_row - refreshheight + 1))
X refreshtop = i;
X if(screen->scrollWidget && !screen->alternate && screen->cur_row == 0) {
X scrolltop = 0;
X if((scrollheight += shift) > i)
X scrollheight = i;
X if((i = screen->savedlines) < screen->savelines) {
X if((i += n) > screen->savelines)
X i = screen->savelines;
X screen->savedlines = i;
X ScrollBarDrawThumb(screen->scrollWidget);
X }
X } else {
X scrolltop = screen->cur_row + shift;
X if((i = screen->bot_marg - bot) > 0) {
X scrollheight -= i;
X if((i = screen->cur_row + n - 1 - bot) >= 0) {
X refreshheight -= i;
X }
X }
X }
X if(scrollheight > 0) {
X if (screen->incopy)
X CopyWait(screen);
X screen->incopy = -1;
X
X XCopyArea (
X screen->display,
X TextWindow(screen),
X TextWindow(screen),
X screen->normalGC,
X (int) screen->border + screen->scrollbar,
X (int) (scrolltop + n) * FontHeight(screen) + screen->border,
X (unsigned) Width(screen),
X (unsigned) scrollheight * FontHeight(screen),
X (int) screen->border + screen->scrollbar,
X (int) scrolltop * FontHeight(screen) + screen->border);
X }
X if(refreshheight > 0)
X XClearArea (
X screen->display,
X TextWindow(screen),
X (int) screen->border + screen->scrollbar,
X (int) refreshtop * FontHeight(screen) + screen->border,
X (unsigned) Width(screen),
X (unsigned) refreshheight * FontHeight(screen),
X FALSE);
X }
X /* adjust screen->buf */
X if(screen->scrollWidget && !screen->alternate && screen->cur_row == 0)
X ScrnDeleteLine(screen->allbuf, screen->bot_marg +
X screen->savelines, 0, n, screen->max_col + 1);
X else
X ScrnDeleteLine(screen->buf, screen->bot_marg, screen->cur_row,
X n, screen->max_col + 1);
}
X
/*
X * Insert n blanks at the cursor's position, no wraparound
X */
InsertChar (screen, n)
register TScreen *screen;
register int n;
{
X register int width = n * FontWidth(screen), cx, cy;
X
X if(screen->cursor_state)
X HideCursor();
X screen->do_wrap = 0;
#ifdef STATUSLINE
X if(screen->cur_row - screen->topline <= screen->max_row ||
X screen->instatus) {
#else /* !STATUSLINE */
X if(screen->cur_row - screen->topline <= screen->max_row) {
#endif /* !STATUSLINE */
X if(!AddToRefresh(screen)) {
X if(screen->scroll_amt)
X FlushScroll(screen);
#ifdef KTERM_KANJI
X BreakMBchar(screen);
#endif /* KTERM_KANJI */
X
X if (screen->incopy)
X CopyWait (screen);
X screen->incopy = -1;
X
X cx = CursorX (screen, screen->cur_col);
X cy = CursorY (screen, screen->cur_row);
X XCopyArea(
X screen->display,
X TextWindow(screen), TextWindow(screen),
X screen->normalGC,
X cx, cy,
X (unsigned) Width(screen)
X - (screen->cur_col + n) * FontWidth(screen),
X (unsigned) FontHeight(screen),
X cx + width, cy);
X XFillRectangle(
X screen->display,
X TextWindow(screen),
#ifdef STATUSLINE
X screen->instatus ? screen->normalGC :
#endif /* STATUSLINE */
X screen->reverseGC,
X cx, cy,
X (unsigned) width, (unsigned) FontHeight(screen));
X }
X }
X /* adjust screen->buf */
X ScrnInsertChar(screen->buf, screen->cur_row, screen->cur_col, n,
X screen->max_col + 1);
}
X
/*
X * Deletes n chars at the cursor's position, no wraparound.
X */
DeleteChar (screen, n)
register TScreen *screen;
register int n;
{
X register int width, cx, cy;
X
X if(screen->cursor_state)
X HideCursor();
X screen->do_wrap = 0;
X if (n > (width = screen->max_col + 1 - screen->cur_col))
X n = width;
X
#ifdef STATUSLINE
X if(screen->cur_row - screen->topline <= screen->max_row ||
X screen->instatus) {
#else /* !STATUSLINE */
X if(screen->cur_row - screen->topline <= screen->max_row) {
#endif /* !STATUSLINE */
X if(!AddToRefresh(screen)) {
X if(screen->scroll_amt)
X FlushScroll(screen);
X
X width = n * FontWidth(screen);
#ifdef KTERM_KANJI
X BreakMBchar(screen);
X screen->cur_col += n;
X BreakMBchar(screen);
X screen->cur_col -= n;
#endif /* KTERM_KANJI */
X
X if (screen->incopy)
X CopyWait (screen);
X screen->incopy = -1;
X
X cx = CursorX (screen, screen->cur_col);
X cy = CursorY (screen, screen->cur_row);
X XCopyArea(screen->display,
X TextWindow(screen), TextWindow(screen),
X screen->normalGC,
X cx + width, cy,
X Width(screen) - (screen->cur_col + n) * FontWidth(screen),
X FontHeight(screen),
X cx, cy);
X XFillRectangle (screen->display, TextWindow(screen),
#ifdef STATUSLINE
X screen->instatus ? screen->normalGC :
#endif /* STATUSLINE */
X screen->reverseGC,
X screen->border + screen->scrollbar + Width(screen) - width,
X cy, width, FontHeight(screen));
X }
X }
X /* adjust screen->buf */
X ScrnDeleteChar (screen->buf, screen->cur_row, screen->cur_col, n,
X screen->max_col + 1);
X
}
X
/*
X * Clear from cursor position to beginning of display, inclusive.
X */
ClearAbove (screen)
register TScreen *screen;
{
X register top, height;
X
X if(screen->cursor_state)
X HideCursor();
X if((top = -screen->topline) <= screen->max_row) {
X if(screen->scroll_amt)
X FlushScroll(screen);
X if((height = screen->cur_row + top) > screen->max_row)
X height = screen->max_row;
X if((height -= top) > 0)
X XClearArea(screen->display, TextWindow(screen),
X screen->border + screen->scrollbar, top *
X FontHeight(screen) + screen->border,
X Width(screen), height * FontHeight(screen), FALSE);
X
X if(screen->cur_row - screen->topline <= screen->max_row)
X ClearLeft(screen);
X }
X ClearBufRows(screen, 0, screen->cur_row - 1);
}
X
/*
X * Clear from cursor position to end of display, inclusive.
X */
ClearBelow (screen)
register TScreen *screen;
{
X register top;
X
X ClearRight(screen);
X if((top = screen->cur_row - screen->topline) <= screen->max_row) {
X if(screen->scroll_amt)
X FlushScroll(screen);
X if(++top <= screen->max_row)
X XClearArea(screen->display, TextWindow(screen),
X screen->border + screen->scrollbar, top *
X FontHeight(screen) + screen->border,
X Width(screen), (screen->max_row - top + 1) *
X FontHeight(screen), FALSE);
X }
X ClearBufRows(screen, screen->cur_row + 1, screen->max_row);
}
X
/*
X * Clear last part of cursor's line, inclusive.
X */
ClearRight (screen)
register TScreen *screen;
{
X if(screen->cursor_state)
X HideCursor();
X screen->do_wrap = 0;
#ifdef STATUSLINE
X if(screen->cur_row - screen->topline <= screen->max_row ||
X screen->instatus) {
#else /* !STATUSLINE */
X if(screen->cur_row - screen->topline <= screen->max_row) {
#endif /* !STATUSLINE */
X if(!AddToRefresh(screen)) {
X if(screen->scroll_amt)
X FlushScroll(screen);
#ifdef KTERM_KANJI
X BreakMBchar(screen);
#endif /* KTERM_KANJI */
X XFillRectangle(screen->display, TextWindow(screen),
#ifdef STATUSLINE
X screen->instatus ? screen->normalGC :
#endif /* STATUSLINE */
X screen->reverseGC,
X CursorX(screen, screen->cur_col),
X CursorY(screen, screen->cur_row),
X Width(screen) - screen->cur_col * FontWidth(screen),
X FontHeight(screen));
X }
X }
#ifdef KTERM
X bzero(screen->buf[screen->cur_row] + screen->cur_col,
X (screen->max_col - screen->cur_col + 1) * sizeof(Bchr));
#else /* !KTERM */
X bzero(screen->buf [2 * screen->cur_row] + screen->cur_col,
X (screen->max_col - screen->cur_col + 1));
X bzero(screen->buf [2 * screen->cur_row + 1] + screen->cur_col,
X (screen->max_col - screen->cur_col + 1));
#endif /* !KTERM */
}
X
/*
X * Clear first part of cursor's line, inclusive.
X */
ClearLeft (screen)
register TScreen *screen;
{
X if(screen->cursor_state)
X HideCursor();
X screen->do_wrap = 0;
#ifdef STATUSLINE
X if(screen->cur_row - screen->topline <= screen->max_row ||
X screen->instatus) {
#else /* !STATUSLINE */
X if(screen->cur_row - screen->topline <= screen->max_row) {
#endif /* !STATUSLINE */
X if(!AddToRefresh(screen)) {
X if(screen->scroll_amt)
X FlushScroll(screen);
#ifdef KTERM_KANJI
X BreakMBchar(screen);
#endif /* KTERM_KANJI */
X XFillRectangle (screen->display, TextWindow(screen),
#ifdef STATUSLINE
X screen->instatus ? screen->normalGC :
#endif /* STATUSLINE */
X screen->reverseGC,
X screen->border + screen->scrollbar,
X CursorY (screen, screen->cur_row),
X (screen->cur_col + 1) * FontWidth(screen),
X FontHeight(screen));
X }
X }
#ifdef KTERM
X bzero (screen->buf[screen->cur_row], (screen->cur_col + 1) * sizeof(Bchr));
#else /* !KTERM */
X bzero (screen->buf [2 * screen->cur_row], (screen->cur_col + 1));
X bzero (screen->buf [2 * screen->cur_row + 1], (screen->cur_col + 1));
#endif /* !KTERM */
}
X
/*
X * Erase the cursor's line.
X */
ClearLine(screen)
register TScreen *screen;
{
X if(screen->cursor_state)
X HideCursor();
X screen->do_wrap = 0;
#ifdef STATUSLINE
X if(screen->cur_row - screen->topline <= screen->max_row ||
X screen->instatus) {
#else /* !STATUSLINE */
X if(screen->cur_row - screen->topline <= screen->max_row) {
#endif /* !STATUSLINE */
X if(!AddToRefresh(screen)) {
X if(screen->scroll_amt)
X FlushScroll(screen);
X XFillRectangle (screen->display, TextWindow(screen),
#ifdef STATUSLINE
X screen->instatus && screen->reversestatus ?
X screen->normalGC :
#endif /* STATUSLINE */
X screen->reverseGC,
X screen->border + screen->scrollbar,
X CursorY (screen, screen->cur_row),
X Width(screen), FontHeight(screen));
X }
X }
#ifdef KTERM
X bzero (screen->buf[screen->cur_row], (screen->max_col + 1) * sizeof(Bchr));
#else /* !KTERM */
X bzero (screen->buf [2 * screen->cur_row], (screen->max_col + 1));
X bzero (screen->buf [2 * screen->cur_row + 1], (screen->max_col + 1));
#endif /* !KTERM */
}
X
ClearScreen(screen)
register TScreen *screen;
{
X register int top;
X
X if(screen->cursor_state)
X HideCursor();
X screen->do_wrap = 0;
X if((top = -screen->topline) <= screen->max_row) {
X if(screen->scroll_amt)
X FlushScroll(screen);
#ifdef STATUSLINE
X if(top == 0 && !screen->statusline)
#else /* !STATUSLINE */
X if(top == 0)
#endif /* !STATUSLINE */
X XClearWindow(screen->display, TextWindow(screen));
X else
X XClearArea(screen->display, TextWindow(screen),
X screen->border + screen->scrollbar,
X top * FontHeight(screen) + screen->border,
X Width(screen), (screen->max_row - top + 1) *
X FontHeight(screen), FALSE);
X }
X ClearBufRows (screen, 0, screen->max_row);
}
X
CopyWait(screen)
register TScreen *screen;
{
X XEvent reply;
X XEvent *rep = &reply;
X
X while (1) {
X XWindowEvent (screen->display, VWindow(screen),
X ExposureMask, &reply);
X switch (reply.type) {
X case Expose:
X HandleExposure (screen, (XExposeEvent *) &reply);
X break;
X case NoExpose:
X case GraphicsExpose:
X if (screen->incopy <= 0) {
X screen->incopy = 1;
X if (screen->scrolls > 0)
X screen->scrolls--;
X }
X if (reply.type == GraphicsExpose)
X HandleExposure (screen, (XExposeEvent *) &reply);
X
X if ((reply.type == NoExpose) ||
X ((XExposeEvent *)rep)->count == 0) {
X if (screen->incopy <= 0 && screen->scrolls > 0)
X screen->scrolls--;
X if (screen->scrolls == 0) {
X screen->incopy = 0;
X return;
X }
X screen->incopy = -1;
X }
X break;
X }
X }
}
/*
X * This routine handles exposure events
X */
HandleExposure (screen, reply)
register TScreen *screen;
register XExposeEvent *reply;
{
X register int toprow, leftcol, nrows, ncols;
X extern Bool waiting_for_initial_map;
X
X if((toprow = (reply->y - screen->border) /
X FontHeight(screen)) < 0)
X toprow = 0;
X if((leftcol = (reply->x - screen->border - screen->scrollbar)
X / FontWidth(screen)) < 0)
X leftcol = 0;
X nrows = (reply->y + reply->height - 1 - screen->border) /
X FontHeight(screen) - toprow + 1;
X ncols =
X (reply->x + reply->width - 1 - screen->border - screen->scrollbar) /
X FontWidth(screen) - leftcol + 1;
X toprow -= screen->scrolls;
X if (toprow < 0) {
X nrows += toprow;
X toprow = 0;
X }
X if (toprow + nrows - 1 > screen->max_row)
#ifdef STATUSLINE
X nrows = screen->max_row - toprow + 1 + screen->statusline;
#else /* !STATUSLINE */
X nrows = screen->max_row - toprow + 1;
#endif /* !STATUSLINE */
X if (leftcol + ncols - 1 > screen->max_col)
X ncols = screen->max_col - leftcol + 1;
X
X if (nrows > 0 && ncols > 0) {
X ScrnRefresh (screen, toprow, leftcol, nrows, ncols, False);
X if (waiting_for_initial_map) {
X first_map_occurred ();
X }
X if (screen->cur_row >= toprow &&
X screen->cur_row < toprow + nrows &&
X screen->cur_col >= leftcol &&
X screen->cur_col < leftcol + ncols)
X return (1);
X
X }
X return (0);
}
X
ReverseVideo (term)
X XtermWidget term;
{
X register TScreen *screen = &term->screen;
X GC tmpGC;
X Window tek = TWindow(screen);
X unsigned long tmp;
#ifdef KTERM
X int fnum;
#ifdef COLOR_TEXT /* mukawa */
X XGCValues xgcv;
#endif /* COLOR_TEXT */
#endif /* KTERM */
X
X tmp = term->core.background_pixel;
X if(screen->cursorcolor == screen->foreground)
X screen->cursorcolor = tmp;
X term->core.background_pixel = screen->foreground;
X screen->foreground = tmp;
X
X tmp = screen->mousecolorback;
X screen->mousecolorback = screen->mousecolor;
X screen->mousecolor = tmp;
X
#ifdef KTERM
#ifdef COLOR_TEXT /* mukawa */
X xgcv.foreground = screen->foreground;
X xgcv.background = term->core.background_pixel;
#endif /* COLOR_TEXT */
X for (fnum=F_ISO8859_1; fnum<FCNT; fnum++) {
#ifdef COLOR_TEXT /* mukawa */
X /* reset color attribute */
X xgcv.foreground = screen->foreground;
X xgcv.background = term->core.background_pixel;
X if(screen->reverseGC)
X XChangeGC(screen->display, screen->reverseGC,
X GCForeground|GCBackground, &xgcv);
X if(screen->reverseboldGC)
X XChangeGC(screen->display, screen->reverseboldGC,
X GCForeground|GCBackground, &xgcv);
/* if(screen->reversecursorGC)
X XChangeGC(screen->display, screen->reversecursorGC,
X GCForeground|GCBackground, &xgcv);
*/
X xgcv.foreground = term->core.background_pixel;
X xgcv.background = screen->foreground;
X if(screen->normalGC)
X XChangeGC(screen->display, screen->normalGC,
X GCForeground|GCBackground, &xgcv);
X if(screen->normalboldGC)
X XChangeGC(screen->display, screen->normalboldGC,
X GCForeground|GCBackground, &xgcv);
/* if(screen->cursorGC)
X XChangeGC(screen->display, screen->cursorGC,
X GCForeground|GCBackground, &xgcv);
*/
#endif /* COLOR_TEXT */
X tmpGC = screen->normalGC;
X screen->normalGC = screen->reverseGC;
X screen->reverseGC = tmpGC;
X
X tmpGC = screen->normalboldGC;
X screen->normalboldGC = screen->reverseboldGC;
X screen->reverseboldGC = tmpGC;
X
X tmpGC = screen->cursorGC;
X screen->cursorGC = screen->reversecursorGC;
X screen->reversecursorGC = tmpGC;
X }
#else /* !KTERM */
X tmpGC = screen->normalGC;
X screen->normalGC = screen->reverseGC;
X screen->reverseGC = tmpGC;
X
X tmpGC = screen->normalboldGC;
X screen->normalboldGC = screen->reverseboldGC;
X screen->reverseboldGC = tmpGC;
/*
X * Bug fix by michael
X * 3 non null lines are inserted.
X */
X tmpGC = screen->cursorGC;
X screen->cursorGC = screen->reversecursorGC;
X screen->reversecursorGC = tmpGC;
#endif /* !KTERM */
X
X recolor_cursor (screen->pointer_cursor,
X screen->mousecolor, screen->mousecolorback);
X recolor_cursor (screen->arrow,
X screen->mousecolor, screen->mousecolorback);
X
X term->misc.re_verse = !term->misc.re_verse;
X
X XDefineCursor(screen->display, TextWindow(screen), screen->pointer_cursor);
X if(tek)
X XDefineCursor(screen->display, tek, screen->arrow);
X
X
X if(screen->scrollWidget)
X ScrollBarReverseVideo(screen->scrollWidget);
X
X XSetWindowBackground(screen->display, TextWindow(screen), term->core.background_pixel);
X if(tek) {
X TekReverseVideo(screen);
X }
X XClearWindow(screen->display, TextWindow(screen));
#ifdef STATUSLINE
X ScrnRefresh (screen, 0, 0, screen->max_row + 1 + screen->statusline,
#else /* !STATUSLINE */
X ScrnRefresh (screen, 0, 0, screen->max_row + 1,
#endif /* !STATUSLINE */
X screen->max_col + 1, False);
X if(screen->Tshow) {
X XClearWindow(screen->display, tek);
X TekExpose((XExposeEvent *) NULL);
X }
X update_reversevideo();
}
X
X
recolor_cursor (cursor, fg, bg)
X Cursor cursor; /* X cursor ID to set */
X unsigned long fg, bg; /* pixel indexes to look up */
{
X register TScreen *screen = &term->screen;
X register Display *dpy = screen->display;
X XColor colordefs[2]; /* 0 is foreground, 1 is background */
X
X colordefs[0].pixel = fg;
X colordefs[1].pixel = bg;
X XQueryColors (dpy, DefaultColormap (dpy, DefaultScreen (dpy)),
X colordefs, 2);
X XRecolorCursor (dpy, cursor, colordefs, colordefs+1);
X return;
}
X
#ifdef KTERM_KANJI
/*
X * If the cursor points second byte of multi byte character,
X * replace this character into two blanks.
X */
BreakMBchar(screen)
register TScreen *screen;
{
X register Bchr *ptr;
X if (screen->cur_col >= 1 && screen->cur_col <= screen->max_col
X && screen->buf[screen->cur_row][screen->cur_col].gset == MBC2) {
X XFillRectangle(screen->display, TextWindow(screen),
#ifdef STATUSLINE
X screen->instatus ? screen->normalGC :
#endif /* STATUSLINE */
X screen->reverseGC,
X CursorX(screen, screen->cur_col - 1),
X CursorY(screen, screen->cur_row),
X 2 * FontWidth(screen), FontHeight(screen));
X ptr = screen->buf[screen->cur_row] + screen->cur_col - 1;
X bzero((char*)ptr, 2 * sizeof(Bchr));
X }
}
X
#endif /* KTERM_KANJI */
#ifdef KTERM
X
Char
MapOnFont(gset, code)
register Char gset;
register Char code;
{
X if (code & NEEDMAP) {
X switch (gset) {
X case GSET_UK:
X return '\243'; /* UK pound sign on iso8859-1 */
X break;
X case GSET_GRAPH:
X code &= ~NEEDMAP;
X return (code == 0x5f) ? 0x7f : (code - 0x5f);
X break;
X case GSET_KANA:
X return code & ~NEEDMAP | 0x80; /* kana on jisx0201 */
X break;
X }
X } else if (code == 0) {
X return ' ';
X } else {
X return code;
X }
}
X
#endif /* KTERM */
SHAR_EOF
echo 'File kterm-4.1.2/util.c is complete' &&
chmod 0664 kterm-4.1.2/util.c ||
echo 'restore of kterm-4.1.2/util.c failed'
Wc_c="`wc -c < 'kterm-4.1.2/util.c'`"
test 32241 -eq "$Wc_c" ||
echo 'kterm-4.1.2/util.c: original size 32241, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
rm -f _shar_seq_.tmp
echo You have unpacked the last part
exit 0
-----------------------------------------------------------------------------
mleisher@nmsu.edu "I laughed.
Mark Leisher I cried.
Computing Research Lab I fell down.
New Mexico State University It changed my life."
Las Cruces, NM - Rich [Cowboy Feng's Space Bar and Grille]
--
Dan Heller
O'Reilly && Associates Z-Code Software Comp-sources-x:
Senior Writer President comp-sources.x@uunet.uu.net
argv@ora.com argv@zipcode.com