mleisher@NMSU.Edu (05/11/91)
Submitted-by: mleisher@NMSU.Edu Posting-number: Volume 12, Issue 98 Archive-name: kterm/part17 #!/bin/sh # this is kt412.17 (part 17 of kterm-4.1.2) # do not concatenate these parts, unpack them in order with /bin/sh # file kterm-4.1.2/screen.c continued # if test ! -r _shar_seq_.tmp; then echo 'Please unpack part 1 first!' exit 1 fi (read Scheck if test "$Scheck" != 17; 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/screen.c' else echo 'x - continuing file kterm-4.1.2/screen.c' sed 's/^X//' << 'SHAR_EOF' >> 'kterm-4.1.2/screen.c' && #endif /* STATUSLINE */ X (hilite != 0) ^ ((flags & INVERSE) != 0), X flags & UNDERLINE, X False); X n = 0; #else /* !KTERM */ #ifdef STATUSLINE X if (((!hilite && (flags & INVERSE) != 0) || X (hilite && (flags & INVERSE) == 0)) X ^ (dostatus < 0 && screen->reversestatus)) #else /* !STATUSLINE */ X if ( (!hilite && (flags & INVERSE) != 0) || X (hilite && (flags & INVERSE) == 0) ) #endif /* !STATUSLINE */ X if (flags & BOLD) gc = screen->reverseboldGC; X else gc = screen->reverseGC; X else X if (flags & BOLD) gc = screen->normalboldGC; X else gc = screen->normalGC; X XDrawImageString(screen->display, TextWindow(screen), gc, X x, y, (char *) &chars[lastind], n = col - lastind); X if((flags & BOLD) && screen->enbolden) X XDrawString(screen->display, TextWindow(screen), gc, X x + 1, y, (char *) &chars[lastind], n); X if(flags & UNDERLINE) X XDrawLine(screen->display, TextWindow(screen), gc, X x, y+1, x + n * FontWidth(screen), y+1); #endif /* !KTERM */ X } #ifdef STATUSLINE X if (dostatus <= 0) X break; X dostatus = -1; X topline = 0; X scrollamt = 0; X toprow = maxrow = max = screen->max_row + 1; X left = CursorX(screen, leftcol); X width = ncols * FontWidth(screen); X if (leftcol == 0) { X left--; X width++; X } X if (leftcol + ncols - 1 >= screen->max_col) X width++; X XFillRectangle(screen->display, TextWindow(screen), X screen->reversestatus ? screen->normalGC : screen->reverseGC, #ifdef KTERM X left, y, #else /* !KTERM */ X left, y - screen->fnt_norm->max_bounds.ascent, #endif /* !KTERM */ X width, screen->statusheight); X if (!screen->reversestatus) X StatusBox(screen); X y++; X } /* end of for(;;) */ #endif /* STATUSLINE */ #ifdef KTERM X if (dbuf != drawbuf) XtFree(dbuf); #endif /* KTERM */ } X ClearBufRows (screen, first, last) /* X Sets the rows first though last of the buffer of screen to spaces. X Requires first <= last; first, last are rows of screen->buf. X */ register TScreen *screen; register int first, last; { #ifdef KTERM X while (first <= last) X bzero (screen->buf [first++], (screen->max_col + 1) * sizeof(Bchr)); #else /* !KTERM */ X first *= 2; X last = 2 * last + 1; X while (first <= last) X bzero (screen->buf [first++], (screen->max_col + 1)); #endif /* !KTERM */ } X ScreenResize (screen, width, height, flags) /* X Resizes screen: X 1. If new window would have fractional characters, sets window size so as to X discard fractional characters and returns -1. X Minimum screen size is 1 X 1. X Note that this causes another ExposeWindow event. X 2. Enlarges screen->buf if necessary. New space is appended to the bottom X and to the right X 3. Reduces screen->buf if necessary. Old space is removed from the bottom X and from the right X 4. Cursor is positioned as closely to its former position as possible X 5. Sets screen->max_row and screen->max_col to reflect new size X 6. Maintains the inner border (and clears the border on the screen). X 7. Clears origin mode and sets scrolling region to be entire screen. X 8. Returns 0 X */ register TScreen *screen; int width, height; unsigned *flags; { X int rows, cols; X int border = 2 * screen->border; #ifdef sun #ifdef TIOCSSIZE X struct ttysize ts; #endif /* TIOCSSIZE */ #else /* sun */ #ifdef TIOCSWINSZ X struct winsize ws; #endif /* TIOCSWINSZ */ #endif /* sun */ X Window tw = TextWindow (screen); #ifdef STATUSLINE X int oldmaxrow = screen->max_row; #endif /* STATUSLINE */ X X /* clear the right and bottom internal border because of NorthWest X gravity might have left junk on the right and bottom edges */ X XClearArea (screen->display, tw, X width - screen->border, 0, /* right edge */ X screen->border, height, /* from top to bottom */ X False); X XClearArea (screen->display, tw, X 0, height - screen->border, /* bottom */ X width, screen->border, /* all across the bottom */ X False); X X /* round so that it is unlikely the screen will change size on */ X /* small mouse movements. */ #ifdef STATUSLINE X rows = (height + FontHeight(screen) / 2 - border - screen->statusheight) / #else /* !STATUSLINE */ X rows = (height + FontHeight(screen) / 2 - border) / #endif /* !STATUSLINE */ X FontHeight(screen); X cols = (width + FontWidth(screen) / 2 - border - screen->scrollbar) / X FontWidth(screen); X if (rows < 1) rows = 1; X if (cols < 1) cols = 1; X X /* change buffers if the screen has changed size */ X if (screen->max_row != rows - 1 || screen->max_col != cols - 1) { X register int savelines = screen->scrollWidget ? X screen->savelines : 0; X X if(screen->cursor_state) X HideCursor(); X if (screen->altbuf) X Reallocate(&screen->altbuf, (Char **)&screen->abuf_address, X rows, cols, screen->max_row + 1, screen->max_col + 1); X Reallocate(&screen->allbuf, (Char **)&screen->sbuf_address, X rows + savelines, cols, X screen->max_row + 1 + savelines, screen->max_col + 1); #ifdef KTERM X screen->buf = &screen->allbuf[savelines]; #else /* !KTERM */ X screen->buf = &screen->allbuf[2 * savelines]; #endif /* !KTERM */ X X screen->max_row = rows - 1; X screen->max_col = cols - 1; X X /* adjust scrolling region */ X screen->top_marg = 0; X screen->bot_marg = screen->max_row; X *flags &= ~ORIGIN; X #ifdef STATUSLINE X if (screen->statusline) { X if (oldmaxrow > rows - 1) X ScrnRefresh(screen, rows, 0, 1, cols, True); X else if (oldmaxrow < rows - 1) X XClearArea (screen->display, tw, X 0, (oldmaxrow+1) * FontHeight(screen) + screen->border, X width, screen->statusheight, X False); X } X if (screen->instatus) X screen->cur_row = screen->max_row + 1; X else #endif /* STATUSLINE */ X if (screen->cur_row > screen->max_row) X screen->cur_row = screen->max_row; X if (screen->cur_col > screen->max_col) X screen->cur_col = screen->max_col; X X screen->fullVwin.height = height - border; #ifdef STATUSLINE X screen->fullVwin.height -= screen->statusheight; #endif /* STATUSLINE */ X screen->fullVwin.width = width - border - screen->scrollbar; X X } else if(FullHeight(screen) == height && FullWidth(screen) == width) X return(0); /* nothing has changed at all */ X X if(screen->scrollWidget) X ResizeScrollBar(screen->scrollWidget, -1, -1, height); X X screen->fullVwin.fullheight = height; X screen->fullVwin.fullwidth = width; X ResizeSelection (screen, rows, cols); #ifdef sun #ifdef TIOCSSIZE X /* Set tty's idea of window size */ X ts.ts_lines = rows; X ts.ts_cols = cols; X ioctl (screen->respond, TIOCSSIZE, &ts); #ifdef SIGWINCH X if(screen->pid > 1) { X int pgrp; X X if (ioctl (screen->respond, TIOCGPGRP, &pgrp) != -1) X killpg(pgrp, SIGWINCH); X } #endif /* SIGWINCH */ #endif /* TIOCSSIZE */ #else /* sun */ #ifdef TIOCSWINSZ X /* Set tty's idea of window size */ X ws.ws_row = rows; X ws.ws_col = cols; X ws.ws_xpixel = width; X ws.ws_ypixel = height; X ioctl (screen->respond, TIOCSWINSZ, (char *)&ws); #ifdef notdef /* change to SIGWINCH if this doesn't work for you */ X if(screen->pid > 1) { X int pgrp; X X if (ioctl (screen->respond, TIOCGPGRP, &pgrp) != -1) X killpg(pgrp, SIGWINCH); X } #endif /* SIGWINCH */ #endif /* TIOCSWINSZ */ #endif /* sun */ X return (0); } X #ifdef KTERM static void AdjustMbcsText(screen, fnum, text, length) TScreen *screen; int fnum; XXChar2b *text; int length; { X int i; X int fntype = FontType(screen, fnum, 0); X X if (fntype != LOW && fntype != HIGH) X return; X for (i = 0; i < length; i++) { X if (fntype == LOW) { X text[i].byte1 &= ~NEEDMAP; X text[i].byte2 &= ~NEEDMAP; X } else if (fntype == HIGH) { X text[i].byte1 |= NEEDMAP; X text[i].byte2 |= NEEDMAP; X } X } } #endif /* KTERM */ X #ifdef KTERM #ifdef COLOR_TEXT /* mukawa */ ScreenDraw(screen, x, y, dbuf, n, gset, color, bold, rev, under, cursor) #else /* COLOR_TEXT */ ScreenDraw(screen, x, y, dbuf, n, gset, bold, rev, under, cursor) #endif /* COLOR_TEXT */ register TScreen *screen; int x, y; /* upper-left bound */ XXChar2b *dbuf; int n; Char gset; #ifdef COLOR_TEXT /* mukawa */ int color; #endif /* COLOR_TEXT */ int bold, rev, under, cursor; /* Boolean */ { X GC gc, backgc; X int fnum, cols; X Boolean cursorstate; X X fnum = FNUM(gset); X cols = gset & MBCS ? n * 2 : n; X X /* X * This check is to make sure that mbcs text has the high bit X * cleared or set depending on which type of font is being used. X * This is to catch situations like switching between a JIS and X * EUC Kanji font, or vice versa. X */ X if (gset & MBCS) X AdjustMbcsText(screen, fnum, dbuf, n); X X cursorstate = cursor && (screen->select || screen->always_highlight); X if (rev) { X if (cursorstate && screen->reversecursorGC) X gc = screen->reversecursorGC; X else if (bold) X gc = screen->reverseboldGC; X else X gc = screen->reverseGC; X backgc = screen->normalGC; X } else { X if (cursorstate && screen->cursorGC) X gc = screen->cursorGC; X else if (bold) X gc = screen->normalboldGC; X else X gc = screen->normalGC; X backgc = screen->reverseGC; X } X #ifdef COLOR_TEXT /* mukawa */ X if(!cursorstate) { X if (color & COLOR_TEXT_MASK) { X extern XtermWidget term; X XGCValues xgcv; X int cn; X X cn = ((color>>COLOR_TEXT_SHIFT)&COLOR_TEXT_MASK2) - X COLOR_TEXT_ADJUST; X cn = (cn < 0) ? 0 : cn; X if (rev) { X xgcv.background = screen->textcolor[cn]; X XChangeGC(screen->display, gc, GCBackground, X &xgcv); X } X else { X xgcv.foreground = screen->textcolor[cn]; X XChangeGC(screen->display, gc, GCForeground, X &xgcv); X } X } X else { X extern XtermWidget term; X XGCValues xgcv; X X if (rev) { X xgcv.background = screen->foreground; X XChangeGC(screen->display, gc, GCBackground, X &xgcv); X } X else { X xgcv.foreground = screen->foreground; X XChangeGC(screen->display, gc, GCForeground, X &xgcv); X } X } X } #endif /* COLOR_TEXT */ X X if (gset == GSET_GRAPH) { X XSegment segbuf[256 * 2], *segp; X int col, X, nsegs; X segp = (n > 256) X ? (XSegment *)XtMalloc(2 * n * sizeof(XSegment)) X : segbuf; X for (col = nsegs = 0, X = x; col < n; X col ++, X += FontWidth(screen)) { X switch (dbuf[col].byte2) { X case 'j': X case 'k': X case 'u': X segp[nsegs].x1 = X; X segp[nsegs].y1 = y + FontHeight(screen) / 2; X segp[nsegs].x2 = X + FontWidth(screen) / 2; X segp[nsegs].y2 = y + FontHeight(screen) / 2; X nsegs ++; X break; X case 'l': X case 'm': X case 't': X segp[nsegs].x1 = X + FontWidth(screen) / 2; X segp[nsegs].y1 = y + FontHeight(screen) / 2; X segp[nsegs].x2 = X + FontWidth(screen); X segp[nsegs].y2 = y + FontHeight(screen) / 2; X nsegs ++; X break; X case 'n': X case 'q': X case 'v': X case 'w': X segp[nsegs].x1 = X; X segp[nsegs].y1 = y + FontHeight(screen) / 2; X segp[nsegs].x2 = X + FontWidth(screen); X segp[nsegs].y2 = y + FontHeight(screen) / 2; X nsegs ++; X break; X } X switch (dbuf[col].byte2) { X case 'j': X case 'm': X case 'v': X segp[nsegs].x1 = X + FontWidth(screen) / 2; X segp[nsegs].y1 = y; X segp[nsegs].x2 = X + FontWidth(screen) / 2; X segp[nsegs].y2 = y + FontHeight(screen) / 2; X nsegs ++; X break; X case 'k': X case 'l': X case 'w': X segp[nsegs].x1 = X + FontWidth(screen) / 2; X segp[nsegs].y1 = y + FontHeight(screen) / 2; X segp[nsegs].x2 = X + FontWidth(screen) / 2; X segp[nsegs].y2 = y + FontHeight(screen); X nsegs ++; X break; X case 'n': X case 't': X case 'u': X case 'x': X segp[nsegs].x1 = X + FontWidth(screen) / 2; X segp[nsegs].y1 = y; X segp[nsegs].x2 = X + FontWidth(screen) / 2; X segp[nsegs].y2 = y + FontHeight(screen); X nsegs ++; X break; X } X } X XFillRectangle(screen->display, TextWindow(screen), X backgc, x, y, n*FontWidth(screen), FontHeight(screen)); X XDrawSegments(screen->display, TextWindow(screen), X gc, segp, nsegs); X if (segp != segbuf) XtFree(segp); X } else { X int Y = y + screen->linespace / 2 + screen->max_ascent; X X XDrawImageString16(screen->display, TextWindow(screen), X gc, x, Y, dbuf, n); X if (bold && screen->enbolden) X XDrawString16(screen->display, TextWindow(screen), X gc, x + 1, Y, dbuf, n); X if (under) X XDrawLine(screen->display, TextWindow(screen), X gc, x, Y+1, x+cols*FontWidth(screen), Y+1); X } X if (cursor && !cursorstate) { X screen->box->x = x; X screen->box->y = y + screen->linespace / 2; X XDrawLines (screen->display, TextWindow(screen), X screen->cursoroutlineGC ? screen->cursoroutlineGC X : gc, X screen->box, NBOX, CoordModePrevious); X } } #endif /* KTERM */ SHAR_EOF echo 'File kterm-4.1.2/screen.c is complete' && chmod 0664 kterm-4.1.2/screen.c || echo 'restore of kterm-4.1.2/screen.c failed' Wc_c="`wc -c < 'kterm-4.1.2/screen.c'`" test 30881 -eq "$Wc_c" || echo 'kterm-4.1.2/screen.c: original size 30881, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= kterm-4.1.2/scrollbar.c ============== if test -f 'kterm-4.1.2/scrollbar.c' -a X"$1" != X"-c"; then echo 'x - skipping kterm-4.1.2/scrollbar.c (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting kterm-4.1.2/scrollbar.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'kterm-4.1.2/scrollbar.c' && /* X * $XConsortium: scrollbar.c,v 1.32 89/12/15 11:45:51 kit Exp $ X * $Header: /usr/src.yoshi/X/KTerm/4.1.0/RCS/scrollbar.c,v 1.1 90/06/27 09:39:53 kagotani Rel $ X */ X #include <X11/copyright.h> X /* X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. X * X * All Rights Reserved X * X * Permission to use, copy, modify, and distribute this software and its X * documentation for any purpose and without fee is hereby granted, X * provided that the above copyright notice appear in all copies and that X * both that copyright notice and this permission notice appear in X * supporting documentation, and that the name of Digital Equipment X * Corporation not be used in advertising or publicity pertaining to X * distribution of the software without specific, written prior permission. X * X * X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS X * SOFTWARE. X */ X #include <stdio.h> #include <ctype.h> #include <setjmp.h> #include <X11/Xatom.h> X #include "ptyx.h" /* X headers included here. */ X #include <X11/StringDefs.h> #include <X11/Shell.h> X #include <X11/Xaw/Scrollbar.h> X #include "data.h" #include "error.h" #include "menu.h" X extern void bcopy(); X #ifndef lint static char rcs_id[] = "$XConsortium: scrollbar.c,v 1.32 89/12/15 11:45:51 kit Exp $"; #endif /* lint */ X /* Event handlers */ X static void ScrollTextTo(); static void ScrollTextUpDownBy(); X static Bool IsEventType( display, event, type ) X Display *display; X XEvent *event; X int type; { X return (event->type == type); } X X /* resize the text window for a terminal screen, modifying the X * appropriate WM_SIZE_HINTS and taking advantage of bit gravity. X */ X #ifdef STATUSLINE void ResizeScreen(xw, min_width, min_height ) #else /* !STATUSLINE */ static void ResizeScreen(xw, min_width, min_height ) #endif /* !STATUSLINE */ X register XtermWidget xw; X int min_width, min_height; { X register TScreen *screen = &xw->screen; X XSizeHints sizehints; X XSetWindowAttributes newAttributes; X XWindowAttributes oldAttributes; X XEvent event; X XtGeometryResult geomreqresult; X Dimension oldWidth, oldHeight; X Dimension reqWidth, reqHeight, repWidth, repHeight; X static Arg argList[] = { X {XtNminWidth, 0}, X {XtNminHeight, 0}, X /* %%% the next two should move to VTInitialize, VTSetValues */ X {XtNwidthInc, 0}, X {XtNheightInc, 0} X }; X #ifndef nothack X long supp; X X /* %%% gross hack caused by our late processing of geometry X (in VTRealize) and setting of size hints there, leaving X Shell with insufficient information to do the job properly here. X Instead of doing it properly, we save and restore the X size hints around Shell.SetValues and Shell.GeometryManager X */ X if (!XGetWMNormalHints (screen->display, XtWindow(XtParent(xw)), X &sizehints, &supp)) X sizehints.flags = 0; X sizehints.base_width = min_width; X sizehints.base_height = min_height; X sizehints.width_inc = FontWidth(screen); X sizehints.height_inc = FontHeight(screen); X sizehints.min_width = sizehints.base_width + sizehints.width_inc; X sizehints.min_height = sizehints.base_height + sizehints.height_inc; X sizehints.width = (screen->max_col + 1) * FontWidth(screen) X + min_width; X sizehints.height = FontHeight(screen) * (screen->max_row + 1) X + min_height; #ifdef STATUSLINE X sizehints.base_height += screen->statusheight; X sizehints.min_height += screen->statusheight; X sizehints.height += screen->statusheight; #endif /* STATUSLINE */ X sizehints.flags |= (PBaseSize|PMinSize|PResizeInc); #endif X X argList[0].value = (XtArgVal)min_width; X argList[1].value = (XtArgVal)min_height; X argList[2].value = (XtArgVal)FontWidth(screen); X argList[3].value = (XtArgVal)FontHeight(screen); X XtSetValues( XtParent(xw), argList, XtNumber(argList) ); X X XGetWindowAttributes( screen->display, TextWindow(screen), X &oldAttributes ); X X newAttributes.event_mask = X oldAttributes.your_event_mask | StructureNotifyMask; #ifdef STATUSLINE X newAttributes.bit_gravity = ForgetGravity; #else /* !STATUSLINE */ X newAttributes.bit_gravity = EastGravity; #endif /* !STATUSLINE */ X X /* The following statement assumes scrollbar is on Left! X If we ever have scrollbars on the right, then the X bit-gravity should be left alone, NOT changed to EastGravity. */ X XChangeWindowAttributes( screen->display, TextWindow(screen), X CWEventMask|CWBitGravity, &newAttributes ); X X oldWidth = xw->core.width; X oldHeight = xw->core.height; X reqWidth = (screen->max_col + 1) * FontWidth(screen) + min_width; #ifdef STATUSLINE X reqHeight = FontHeight(screen) * (screen->max_row + 1) X + screen->statusheight + min_height; #else /* !STATUSLINE */ X reqHeight = FontHeight(screen) * (screen->max_row + 1) + min_height; #endif /* !STATUSLINE */ X geomreqresult = XtMakeResizeRequest ((Widget)xw, reqWidth, reqHeight, X &repWidth, &repHeight); X #ifndef nothack X XSetWMNormalHints(screen->display, XtWindow(XtParent(xw)), &sizehints); #endif X X if (oldWidth != reqWidth || oldHeight != reqHeight) { X /* wait for a window manager to actually do it */ X XIfEvent (screen->display, &event, IsEventType, (char *)ConfigureNotify); X } X X newAttributes.event_mask = oldAttributes.your_event_mask; X newAttributes.bit_gravity = NorthWestGravity; X XChangeWindowAttributes( screen->display, TextWindow(screen), X CWEventMask|CWBitGravity, X &newAttributes ); } X void DoResizeScreen (xw) X register XtermWidget xw; { X int border = 2 * xw->screen.border; X int sb = (xw->screen.scrollbar ? xw->screen.scrollWidget->core.width : 0); X X ResizeScreen (xw, border + sb, border); } X X static Widget CreateScrollBar(xw, x, y, height) X XtermWidget xw; X int x, y, height; { X Widget scrollWidget; X X static Arg argList[] = { X {XtNx, (XtArgVal) 0}, X {XtNy, (XtArgVal) 0}, X {XtNheight, (XtArgVal) 0}, X {XtNreverseVideo, (XtArgVal) 0}, X {XtNorientation, (XtArgVal) XtorientVertical}, X {XtNborderWidth, (XtArgVal) 1}, X }; X X argList[0].value = (XtArgVal) x; X argList[1].value = (XtArgVal) y; X argList[2].value = (XtArgVal) height; X argList[3].value = (XtArgVal) xw->misc.re_verse; X X scrollWidget = XtCreateWidget("scrollbar", scrollbarWidgetClass, X xw, argList, XtNumber(argList)); X XtAddCallback (scrollWidget, XtNscrollProc, ScrollTextUpDownBy, 0); X XtAddCallback (scrollWidget, XtNjumpProc, ScrollTextTo, 0); X return (scrollWidget); } X static void RealizeScrollBar (sbw, screen) X Widget sbw; X TScreen *screen; { X XtRealizeWidget (sbw); } X X ScrollBarReverseVideo(scrollWidget) X register Widget scrollWidget; { X Arg args[4]; X int nargs = XtNumber(args); X unsigned long bg, fg, bdr; X Pixmap bdpix; X X XtSetArg(args[0], XtNbackground, &bg); X XtSetArg(args[1], XtNforeground, &fg); X XtSetArg(args[2], XtNborderColor, &bdr); X XtSetArg(args[3], XtNborderPixmap, &bdpix); X XtGetValues (scrollWidget, args, nargs); X args[0].value = (XtArgVal) fg; X args[1].value = (XtArgVal) bg; X nargs--; /* don't set border_pixmap */ X if (bdpix == XtUnspecifiedPixmap) { /* if not pixmap then pixel */ X args[2].value = args[1].value; /* set border to new fg */ X } else { /* ignore since pixmap */ X nargs--; /* don't set border pixel */ X } X XtSetValues (scrollWidget, args, nargs); } X X X ScrollBarDrawThumb(scrollWidget) X register Widget scrollWidget; { X register TScreen *screen = &term->screen; X register int thumbTop, thumbHeight, totalHeight; X X thumbTop = screen->topline + screen->savedlines; X thumbHeight = screen->max_row + 1; X totalHeight = thumbHeight + screen->savedlines; X X XawScrollbarSetThumb(scrollWidget, X ((float)thumbTop) / totalHeight, X ((float)thumbHeight) / totalHeight); X } X ResizeScrollBar(scrollWidget, x, y, height) X register Widget scrollWidget; X int x, y; X unsigned height; { X XtConfigureWidget(scrollWidget, x, y, scrollWidget->core.width, X height, scrollWidget->core.border_width); X ScrollBarDrawThumb(scrollWidget); } X WindowScroll(screen, top) X register TScreen *screen; X int top; { X register int i, lines; X register int scrolltop, scrollheight, refreshtop; X register int x = 0; #ifdef KTERM X int fnum = F_ISO8859_1; /* refered by normalGC */ #endif /* KTERM */ X X if (top < -screen->savedlines) X top = -screen->savedlines; X else if (top > 0) X top = 0; X if((i = screen->topline - top) == 0) { X ScrollBarDrawThumb(screen->scrollWidget); X return; X } X X ScrollSelection(screen, i); X X if(screen->cursor_state) X HideCursor(); X lines = i > 0 ? i : -i; X if(lines > screen->max_row + 1) X lines = screen->max_row + 1; X scrollheight = screen->max_row - lines + 1; X if(i > 0) X refreshtop = scrolltop = 0; X else { X scrolltop = lines; X refreshtop = scrollheight; X } X x = screen->scrollbar + screen->border; X if(scrollheight > 0) { X if (screen->multiscroll && scrollheight == 1 && X screen->topline == 0 && screen->top_marg == 0 && X screen->bot_marg == screen->max_row) { X if (screen->incopy < 0 && screen->scrolls == 0) X CopyWait (screen); X screen->scrolls++; X } else { X if (screen->incopy) X CopyWait (screen); X screen->incopy = -1; X } X XCopyArea( X screen->display, X TextWindow(screen), TextWindow(screen), X screen->normalGC, X (int) x, X (int) scrolltop * FontHeight(screen) + screen->border, X (unsigned) Width(screen), X (unsigned) scrollheight * FontHeight(screen), X (int) x, X (int) (scrolltop + i) * FontHeight(screen) X + screen->border); X } X screen->topline = top; X XClearArea( X screen->display, X TextWindow(screen), X (int) x, X (int) refreshtop * FontHeight(screen) + screen->border, X (unsigned) Width(screen), X (unsigned) lines * FontHeight(screen), X FALSE); X ScrnRefresh(screen, refreshtop, 0, lines, screen->max_col + 1, False); X X ScrollBarDrawThumb(screen->scrollWidget); } X X ScrollBarOn (xw, init, doalloc) X XtermWidget xw; X int init, doalloc; { X register TScreen *screen = &xw->screen; X register int border = 2 * screen->border; X register int i; X Char *realloc(), *calloc(); X X if(screen->scrollbar) X return; X X if (init) { /* then create it only */ X if (screen->scrollWidget) return; X X /* make it a dummy size and resize later */ X if ((screen->scrollWidget = CreateScrollBar (xw, -1, - 1, 5)) X == NULL) { X Bell(); X return; X } X X return; X X } X X if (!screen->scrollWidget) { X Bell (); X Bell (); X return; X } X X if (doalloc && screen->allbuf) { #ifdef KTERM X if((screen->allbuf = X (ScrnBuf) realloc((char *) screen->buf, X (unsigned) (screen->max_row + 2 + X screen->savelines) * X sizeof(Bchr *))) X == NULL) X Error (ERROR_SBRALLOC); X screen->buf = &screen->allbuf[screen->savelines]; X bcopy ((char *)screen->allbuf, (char *)screen->buf, X (screen->max_row + 2) * sizeof (Bchr *)); X for(i = screen->savelines - 1 ; i >= 0 ; i--) { X if((screen->allbuf[i] = X (Bchr *)calloc((unsigned) screen->max_col + 1, sizeof(Bchr))) == NULL) X Error (ERROR_SBRALLOC2); X } #else /* !KTERM */ X if((screen->allbuf = X (ScrnBuf) realloc((char *) screen->buf, X (unsigned) 2*(screen->max_row + 2 + X screen->savelines) * X sizeof(char *))) X == NULL) X Error (ERROR_SBRALLOC); X screen->buf = &screen->allbuf[2 * screen->savelines]; X bcopy ((char *)screen->allbuf, (char *)screen->buf, X 2 * (screen->max_row + 2) * sizeof (char *)); X for(i = 2 * screen->savelines - 1 ; i >= 0 ; i--) X if((screen->allbuf[i] = X calloc((unsigned) screen->max_col + 1, sizeof(char))) == X NULL) X Error (ERROR_SBRALLOC2); #endif /* !KTERM */ X } X X ResizeScrollBar (screen->scrollWidget, -1, -1, #ifdef STATUSLINE X Height (screen) + border + screen->statusheight); #else /* !STATUSLINE */ X Height (screen) + border); #endif /* !STATUSLINE */ X RealizeScrollBar (screen->scrollWidget, screen); X screen->scrollbar = screen->scrollWidget->core.width; #ifdef STATUSLINE X status_box[0].x += screen->scrollbar; #endif /* STATUSLINE */ X X ScrollBarDrawThumb(screen->scrollWidget); X DoResizeScreen (xw); X /* map afterwards so BitGravity can be used profitably */ X XMapWindow(screen->display, XtWindow(screen->scrollWidget)); X update_scrollbar (); } X ScrollBarOff(screen) X register TScreen *screen; { X if(!screen->scrollbar) X return; #ifdef STATUSLINE X status_box[0].x -= screen->scrollbar; #endif /* STATUSLINE */ X screen->scrollbar = 0; X XUnmapWindow(screen->display, XtWindow(screen->scrollWidget)); X DoResizeScreen (term); X update_scrollbar (); } X /*ARGSUSED*/ static void ScrollTextTo(scrollbarWidget, closure, topPercent) X Widget scrollbarWidget; X caddr_t closure; X float *topPercent; { X register TScreen *screen = &term->screen; X int thumbTop; /* relative to first saved line */ X int newTopLine; X /* X screen->savedlines : Number of offscreen text lines, X screen->maxrow + 1 : Number of onscreen text lines, X screen->topline : -Number of lines above the last screen->max_row+1 lines */ X X thumbTop = *topPercent * (screen->savedlines + screen->max_row+1); X newTopLine = thumbTop - screen->savedlines; X WindowScroll(screen, newTopLine); } X /*ARGSUSED*/ static void ScrollTextUpDownBy(scrollbarWidget, closure, pixels) X Widget scrollbarWidget; X Opaque closure; X int pixels; { X register TScreen *screen = &term->screen; X register int rowOnScreen, newTopLine; X X rowOnScreen = pixels / FontHeight(screen); X if (rowOnScreen == 0) { X if (pixels < 0) X rowOnScreen = -1; X else if (pixels > 0) X rowOnScreen = 1; X } X newTopLine = screen->topline + rowOnScreen; X WindowScroll(screen, newTopLine); } X X /* X * assume that b is lower case and allow plural X */ static int specialcmplowerwiths (a, b) X char *a, *b; { X register char ca, cb; X X if (!a || !b) return 0; X X while (1) { X ca = *a; X cb = *b; X if (isascii(ca) && isupper(ca)) { /* lowercasify */ #ifdef _tolower X ca = _tolower (ca); #else X ca = tolower (ca); #endif X } X if (ca != cb || ca == '\0') break; /* if not eq else both nul */ X a++, b++; X } X if (cb == '\0' && (ca == '\0' || (ca == 's' && a[1] == '\0'))) X return 1; X X return 0; } X static int params_to_pixels (screen, params, n) X TScreen *screen; X String *params; X int n; { X register mult = 1; X register char *s; X X switch (n > 2 ? 2 : n) { X case 2: X s = params[1]; X if (specialcmplowerwiths (s, "page")) { X mult = (screen->max_row + 1) * FontHeight(screen); X } else if (specialcmplowerwiths (s, "halfpage")) { X mult = ((screen->max_row + 1) * FontHeight(screen)) >> 1; X } else if (specialcmplowerwiths (s, "pixel")) { X mult = 1; X } /* else assume that it is Line */ X mult *= atoi (params[0]); X break; X case 1: X mult = atoi (params[0]) * FontHeight(screen); /* lines */ X break; X default: X mult = screen->scrolllines * FontHeight(screen); X break; X } X X return mult; } X X /*ARGSUSED*/ void HandleScrollForward (gw, event, params, nparams) X Widget gw; X XEvent *event; X String *params; X Cardinal *nparams; { X XtermWidget w = (XtermWidget) gw; X register TScreen *screen = &w->screen; X X ScrollTextUpDownBy (gw, (Opaque) NULL, X params_to_pixels (screen, params, (int) *nparams)); X return; } X X /*ARGSUSED*/ void HandleScrollBack (gw, event, params, nparams) X Widget gw; X XEvent *event; X String *params; X Cardinal *nparams; { X XtermWidget w = (XtermWidget) gw; X register TScreen *screen = &w->screen; X X ScrollTextUpDownBy (gw, (Opaque) NULL, X -params_to_pixels (screen, params, (int) *nparams)); X return; } X X SHAR_EOF chmod 0664 kterm-4.1.2/scrollbar.c || echo 'restore of kterm-4.1.2/scrollbar.c failed' Wc_c="`wc -c < 'kterm-4.1.2/scrollbar.c'`" test 15832 -eq "$Wc_c" || echo 'kterm-4.1.2/scrollbar.c: original size 15832, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= kterm-4.1.2/tabs.c ============== if test -f 'kterm-4.1.2/tabs.c' -a X"$1" != X"-c"; then echo 'x - skipping kterm-4.1.2/tabs.c (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting kterm-4.1.2/tabs.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'kterm-4.1.2/tabs.c' && /* X * $XConsortium: tabs.c,v 1.2 88/09/06 17:08:36 jim Exp $ X */ X #ifndef lint static char *rcsid_tabs_c = "$XConsortium: tabs.c,v 1.2 88/09/06 17:08:36 jim Exp $"; #endif /* lint */ X #include <X11/copyright.h> X /* X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. X * X * All Rights Reserved X * X * Permission to use, copy, modify, and distribute this software and its X * documentation for any purpose and without fee is hereby granted, X * provided that the above copyright notice appear in all copies and that X * both that copyright notice and this permission notice appear in X * supporting documentation, and that the name of Digital Equipment X * Corporation not be used in advertising or publicity pertaining to X * distribution of the software without specific, written prior permission. X * X * X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS X * SOFTWARE. X */ X /* tabs.c */ X #ifndef lint static char rcs_id[] = "$XConsortium: tabs.c,v 1.2 88/09/06 17:08:36 jim Exp $"; #endif /* lint */ X #include <X11/Xlib.h> #include "ptyx.h" /* X * This file presumes 32bits/word. This is somewhat of a crock, and should X * be fixed sometime. X */ X /* X * places tabstops at only every 8 columns X */ TabReset(tabs) Tabs tabs; { X register int i; X X for (i=0; i<TAB_ARRAY_SIZE; ++i) X tabs[i] = 0; X X for (i=0; i<MAX_TABS; i+=8) X TabSet(tabs, i); } X X /* X * places a tabstop at col X */ TabSet(tabs, col) Tabs tabs; { X tabs[col >> 5] |= (1 << (col & 31)); } X /* X * clears a tabstop at col X */ TabClear(tabs, col) Tabs tabs; { X tabs[col >> 5] &= ~(1 << (col & 31)); } X /* X * returns the column of the next tabstop X * (or MAX_TABS - 1 if there are no more). X * A tabstop at col is ignored. X */ TabNext (tabs, col) Tabs tabs; { X extern XtermWidget term; X register TScreen *screen = &term->screen; X X if(screen->curses && screen->do_wrap && (term->flags & WRAPAROUND)) { X Index(screen, 1); X col = screen->cur_col = screen->do_wrap = 0; X } X for (++col; col<MAX_TABS; ++col) X if (tabs[col >> 5] & (1 << (col & 31))) X return (col); X X return (MAX_TABS - 1); } X /* X * clears all tabs X */ TabZonk (tabs) Tabs tabs; { X register int i; X X for (i=0; i<TAB_ARRAY_SIZE; ++i) X tabs[i] = 0; } SHAR_EOF chmod 0664 kterm-4.1.2/tabs.c || echo 'restore of kterm-4.1.2/tabs.c failed' Wc_c="`wc -c < 'kterm-4.1.2/tabs.c'`" test 2605 -eq "$Wc_c" || echo 'kterm-4.1.2/tabs.c: original size 2605, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= kterm-4.1.2/termcap.kt ============== if test -f 'kterm-4.1.2/termcap.kt' -a X"$1" != X"-c"; then echo 'x - skipping kterm-4.1.2/termcap.kt (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting kterm-4.1.2/termcap.kt (Text)' sed 's/^X//' << 'SHAR_EOF' > 'kterm-4.1.2/termcap.kt' && vk|kterm|kterm hangul hanzi kanji terminal emulator (X window system):\ X :hs:es:ts=\E[?%i%dT:fs=\E[?F:ds=\E[?H:\ X :KJ:sc=\E7:rc=\E8:cs=\E[%i%d;%dr:TY=ascii:tc=xterm: SHAR_EOF chmod 0664 kterm-4.1.2/termcap.kt || echo 'restore of kterm-4.1.2/termcap.kt failed' Wc_c="`wc -c < 'kterm-4.1.2/termcap.kt'`" test 166 -eq "$Wc_c" || echo 'kterm-4.1.2/termcap.kt: original size 166, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= kterm-4.1.2/terminfo.kt ============== if test -f 'kterm-4.1.2/terminfo.kt' -a X"$1" != X"-c"; then echo 'x - skipping kterm-4.1.2/terminfo.kt (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting kterm-4.1.2/terminfo.kt (Text)' sed 's/^X//' << 'SHAR_EOF' > 'kterm-4.1.2/terminfo.kt' && kterm|kterm hangul hanzi kanji terminal emulator (X window system), X hs, eslok, tsl=\E[?%i%dT, fs=\E[?F, ds=\E[?H, X sc=\E7, rc=\E8, csr=\E[%i%p1%d;%p2%dr, X use=xterm, SHAR_EOF chmod 0664 kterm-4.1.2/terminfo.kt || echo 'restore of kterm-4.1.2/terminfo.kt failed' Wc_c="`wc -c < 'kterm-4.1.2/terminfo.kt'`" test 167 -eq "$Wc_c" || echo 'kterm-4.1.2/terminfo.kt: original size 167, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= kterm-4.1.2/util.c ============== if test -f 'kterm-4.1.2/util.c' -a X"$1" != X"-c"; then echo 'x - skipping kterm-4.1.2/util.c (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting kterm-4.1.2/util.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'kterm-4.1.2/util.c' && /* X * $XConsortium: util.c,v 1.19 89/12/10 20:44:15 jim Exp $ X * $Kagotani: /usr/src.yoshi/X/KTerm/4.1.0/RCS/util.c,v 1.1 90/06/27 09:39:57 kagotani Rel $ X * X * $Id: util.c,v 1.2 1991/03/17 23:57:47 mleisher Exp $ X */ X #include <X11/copyright.h> X /* X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. X * X * All Rights Reserved X * X * Permission to use, copy, modify, and distribute this software and its X * documentation for any purpose and without fee is hereby granted, X * provided that the above copyright notice appear in all copies and that X * both that copyright notice and this permission notice appear in X * supporting documentation, and that the name of Digital Equipment X * Corporation not be used in advertising or publicity pertaining to X * distribution of the software without specific, written prior permission. X * X * X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS X * SOFTWARE. X */ X /* util.c */ X #ifndef lint static char rcs_id[] = "$XConsortium: util.c,v 1.19 89/12/10 20:44:15 jim Exp $"; #endif /* lint */ X #include <stdio.h> #include <X11/Intrinsic.h> #include <setjmp.h> typedef int *jmp_ptr; X #include "ptyx.h" #include "data.h" #include "error.h" #include "menu.h" X #ifdef KTERM static int fnum = F_ISO8859_1; /* refered by GC's in many functions */ #endif /* KTERM */ X /* X * These routines are used for the jump scroll feature X */ FlushScroll(screen) register TScreen *screen; { X register int i; X register int shift = -screen->topline; X register int bot = screen->max_row - shift; X register int refreshtop; X register int refreshheight; X register int scrolltop; X register int scrollheight; X X if(screen->cursor_state) X HideCursor(); X if(screen->scroll_amt > 0) { X refreshheight = screen->refresh_amt; X scrollheight = screen->bot_marg - screen->top_marg - X refreshheight + 1; X if((refreshtop = screen->bot_marg - refreshheight + 1 + shift) > X (i = screen->max_row - screen->scroll_amt + 1)) X refreshtop = i; X if(screen->scrollWidget && !screen->alternate X && screen->top_marg == 0) { X scrolltop = 0; X if((scrollheight += shift) > i) X scrollheight = i; X if((i = screen->bot_marg - bot) > 0 && X (refreshheight -= i) < screen->scroll_amt) X refreshheight = screen->scroll_amt; X if((i = screen->savedlines) < screen->savelines) { X if((i += screen->scroll_amt) > X screen->savelines) X i = screen->savelines; X screen->savedlines = i; X ScrollBarDrawThumb(screen->scrollWidget); X } X } else { X scrolltop = screen->top_marg + shift; X if((i = bot - (screen->bot_marg - screen->refresh_amt + X screen->scroll_amt)) > 0) { X if(bot < screen->bot_marg) X refreshheight = screen->scroll_amt + i; X } else { X scrollheight += i; X refreshheight = screen->scroll_amt; X if((i = screen->top_marg + screen->scroll_amt - X 1 - bot) > 0) { X refreshtop += i; X refreshheight -= i; X } X } X } X } else { X refreshheight = -screen->refresh_amt; X scrollheight = screen->bot_marg - screen->top_marg - X refreshheight + 1; X refreshtop = screen->top_marg + shift; X scrolltop = refreshtop + refreshheight; X if((i = screen->bot_marg - bot) > 0) X scrollheight -= i; X if((i = screen->top_marg + refreshheight - 1 - bot) > 0) X refreshheight -= i; X } X if(scrollheight > 0) { X if (screen->multiscroll && scrollheight == 1 && X screen->topline == 0 && screen->top_marg == 0 && X screen->bot_marg == screen->max_row) { X if (screen->incopy < 0 && screen->scrolls == 0) X CopyWait (screen); X screen->scrolls++; X } else { X if (screen->incopy) X CopyWait (screen); X screen->incopy = -1; X } X X XCopyArea ( X screen->display, X TextWindow(screen), X TextWindow(screen), X screen->normalGC, X (int) screen->border + screen->scrollbar, X (int) (scrolltop + screen->scroll_amt) * FontHeight(screen) X + 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 ScrollSelection(screen, -(screen->scroll_amt)); X screen->scroll_amt = 0; X screen->refresh_amt = 0; 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 ScrnRefresh(screen, refreshtop, 0, refreshheight, X screen->max_col + 1, False); X } } X AddToRefresh(screen) register TScreen *screen; { X register int amount = screen->refresh_amt; X register int row = screen->cur_row; X #ifdef STATUSLINE X if(screen->instatus) X return(0); #endif /* STATUSLINE */ X if(amount == 0) X return(0); X if(amount > 0) { X register int bottom; X X if(row == (bottom = screen->bot_marg) - amount) { X screen->refresh_amt++; X return(1); X } X return(row >= bottom - amount + 1 && row <= bottom); X } else { X register int top; X X amount = -amount; X if(row == (top = screen->top_marg) + amount) { X screen->refresh_amt--; X return(1); X } X return(row <= top + amount - 1 && row >= top); X } } X /* X * scrolls the screen by amount lines, erases bottom, doesn't alter X * cursor position (i.e. cursor moves down amount relative to text). X * All done within the scrolling region, of course. X * requires: amount > 0 X */ Scroll(screen, amount) register TScreen *screen; register int amount; { X register int i = screen->bot_marg - screen->top_marg + 1; X register int shift; X register int bot; X register int refreshtop = 0; X register int refreshheight; X register int scrolltop; X register int scrollheight; X X if(screen->cursor_state) X HideCursor(); X if (amount > i) X amount = i; X if(screen->jumpscroll) { X if(screen->scroll_amt > 0) { X if(screen->refresh_amt + amount > i) X FlushScroll(screen); X screen->scroll_amt += amount; X screen->refresh_amt += amount; X } else { X if(screen->scroll_amt < 0) X FlushScroll(screen); X screen->scroll_amt = amount; X screen->refresh_amt = amount; X } X refreshheight = 0; X } else { X ScrollSelection(screen, -(amount)); X if (amount == i) { X ClearScreen(screen); X return; X } X shift = -screen->topline; X bot = screen->max_row - shift; X scrollheight = i - amount; X refreshheight = amount; 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 X && screen->top_marg == 0) { X scrolltop = 0; X if((scrollheight += shift) > i) X scrollheight = i; X if((i = screen->savedlines) < screen->savelines) { X if((i += amount) > screen->savelines) X i = screen->savelines; X screen->savedlines = i; X ScrollBarDrawThumb(screen->scrollWidget); X } X } else { X scrolltop = screen->top_marg + shift; X if((i = screen->bot_marg - bot) > 0) { X scrollheight -= i; X if((i = screen->top_marg + amount - 1 - bot) >= 0) { X refreshtop += i; X refreshheight -= i; X } X } X } X if(scrollheight > 0) { X if (screen->multiscroll X && amount==1 && screen->topline == 0 X && screen->top_marg==0 X && screen->bot_marg==screen->max_row) { X if (screen->incopy<0 && screen->scrolls==0) X CopyWait(screen); X screen->scrolls++; X } else { X if (screen->incopy) X CopyWait(screen); X screen->incopy = -1; X } X X XCopyArea( X screen->display, X TextWindow(screen), X TextWindow(screen), X screen->normalGC, X (int) screen->border + screen->scrollbar, X (int) (scrolltop+amount) * 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 if(refreshheight > shift) X refreshheight = shift; X } X } X if(screen->scrollWidget && !screen->alternate && screen->top_marg == 0) X ScrnDeleteLine(screen->allbuf, screen->bot_marg + X screen->savelines, 0, amount, screen->max_col + 1); X else X ScrnDeleteLine(screen->buf, screen->bot_marg, screen->top_marg, X amount, screen->max_col + 1); X if(refreshheight > 0) X ScrnRefresh(screen, refreshtop, 0, refreshheight, X screen->max_col + 1, False); } X X /* X * Reverse scrolls the screen by amount lines, erases top, doesn't alter X * cursor position (i.e. cursor moves up amount relative to text). X * All done within the scrolling region, of course. X * Requires: amount > 0 X */ RevScroll(screen, amount) register TScreen *screen; register int amount; { X register int i = screen->bot_marg - screen->top_marg + 1; X register int shift; X register int bot; X register int refreshtop; X register int refreshheight; X register int scrolltop; X register int scrollheight; X X if(screen->cursor_state) X HideCursor(); X if (amount > i) X amount = i; X if(screen->jumpscroll) { X if(screen->scroll_amt < 0) { X if(-screen->refresh_amt + amount > i) X FlushScroll(screen); X screen->scroll_amt -= amount; X screen->refresh_amt -= amount; X } else { X if(screen->scroll_amt > 0) X FlushScroll(screen); X screen->scroll_amt = -amount; X screen->refresh_amt = -amount; X } X } else { X shift = -screen->topline; X bot = screen->max_row - shift; X refreshheight = amount; X scrollheight = screen->bot_marg - screen->top_marg - X refreshheight + 1; X refreshtop = screen->top_marg + shift; X scrolltop = refreshtop + refreshheight; X if((i = screen->bot_marg - bot) > 0) X scrollheight -= i; X if((i = screen->top_marg + refreshheight - 1 - bot) > 0) X refreshheight -= i; X if(scrollheight > 0) { X if (screen->multiscroll X && amount==1 && screen->topline == 0 X && screen->top_marg==0 X && screen->bot_marg==screen->max_row) { X if (screen->incopy<0 && screen->scrolls==0) X CopyWait(screen); X screen->scrolls++; X } else { X if (screen->incopy) X CopyWait(screen); X screen->incopy = -1; X } X X XCopyArea ( X screen->display, X TextWindow(screen), X TextWindow(screen), X screen->normalGC, X (int) screen->border + screen->scrollbar, X (int) (scrolltop-amount) * 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 ScrnInsertLine (screen->buf, screen->bot_marg, screen->top_marg, X amount, screen->max_col + 1); } X /* X * If cursor not in scrolling region, returns. Else, X * inserts n blank lines at the cursor's position. Lines above the X * bottom margin are lost. X */ InsertLine (screen, n) register TScreen *screen; register int n; { X register int i; X register int shift; X register int bot; X register int refreshtop; X register int refreshheight; X register int scrolltop; X register int scrollheight; X X if (screen->cur_row < screen->top_marg || X screen->cur_row > screen->bot_marg) X return; 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 && X screen->cur_row <= -screen->refresh_amt) { 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 shift = -screen->topline; X bot = screen->max_row - shift; X refreshheight = n; X scrollheight = screen->bot_marg - screen->cur_row - refreshheight + 1; X refreshtop = screen->cur_row + shift; X scrolltop = refreshtop + refreshheight; X if((i = screen->bot_marg - bot) > 0) X scrollheight -= i; X if((i = screen->cur_row + refreshheight - 1 - bot) > 0) X refreshheight -= i; X if(scrollheight > 0) { X if (screen->incopy) X CopyWait (screen); X screen->incopy = -1; 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 ScrnInsertLine(screen->buf, screen->bot_marg, screen->cur_row, n, X screen->max_col + 1); } X /* X * If cursor not in scrolling region, returns. Else, deletes n lines X * at the cursor's position, lines added at bottom margin are blank. X */ DeleteLine(screen, n) register TScreen *screen; register int n; { X register int i; X register int shift; X register int bot; X register int refreshtop; X register int refreshheight; X register int scrolltop; X register int scrollheight; X X if (screen->cur_row < screen->top_marg || X screen->cur_row > screen->bot_marg) X return; SHAR_EOF true || echo 'restore of kterm-4.1.2/util.c failed' fi echo 'End of kterm-4.1.2 part 17' echo 'File kterm-4.1.2/util.c is continued in part 18' echo 18 > _shar_seq_.tmp 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