home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
x
/
volume12
/
kterm
/
part16
< prev
next >
Wrap
Internet Message Format
|
1991-05-11
|
52KB
Path: uunet!cs.utexas.edu!sun-barr!newstop!jethro!exodus!NMSU.Edu!mleisher
From: mleisher@NMSU.Edu
Newsgroups: comp.sources.x
Subject: v12i097: kterm - kanji xterm, Part16/18
Message-ID: <13149@exodus.Eng.Sun.COM>
Date: 11 May 91 00:52:07 GMT
References: <csx-12i082:kterm@uunet.UU.NET>
Sender: news@exodus.Eng.Sun.COM
Lines: 1612
Approved: argv@sun.com
Submitted-by: mleisher@NMSU.Edu
Posting-number: Volume 12, Issue 97
Archive-name: kterm/part16
#!/bin/sh
# this is kt412.16 (part 16 of kterm-4.1.2)
# do not concatenate these parts, unpack them in order with /bin/sh
# file kterm-4.1.2/n2ks continued
#
if test ! -r _shar_seq_.tmp; then
echo 'Please unpack part 1 first!'
exit 1
fi
(read Scheck
if test "$Scheck" != 16; 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/n2ks'
else
echo 'x - continuing file kterm-4.1.2/n2ks'
sed 's/^X//' << 'SHAR_EOF' >> 'kterm-4.1.2/n2ks' &&
IXBOSNr;.ss]bY`%a]?O2uA@p2cDK<A;;/UHednt!p]@70bDIL0-;/UKfekp<q]@TnhA@pMlD0*>D;
/KpWgehos]A3fkD/m2E;/C9bi)+<3]AZV'B"R&"Cgjs9;/C6ajAB`8]B'AsCh10?FDGp/k]CT=]BOE
QF1^^ZCLt-DFDGL#lu[#5]BorICJDG/FDG<smrW>b]C9oXFM%'bCK.q:FDGF!o5nbm]CZGPDfWJ`FD
l64pN1=c]D-Jd@Cu>WDfNDcFDl95qfHaU]DN"XDe-KYFD5d.Tlb!i]V9L^B"Xm\BjnZMFD5a-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>
cB6A47q.Fhla80Fk<6+lKF_&PjB2EZirb#&>aIrrR:iXRNB4u>,Uh=@^aJEN_B#pi^BL9e<B4t_pW+
Td`aJfMZBQV=qB4thsX(Q*jaK0#IElbCr9681XB1ljXY\-UNaKZ(b94Z,LB1R'aZtDpNaL,YOFNCn'
87]fNB2!?e\S"TWaLV^k9P2AXB2!<d]Oso[aLu4[AB;JtH#q'BB6e+1_.S%5aMJ9sH$%-FB5Vb2`Fj
(0aMqk1B#r#*DF2FcB5V/!a_,L5aN=j&DIgi3B1d6dc"BX\aNeEj@E?c-8n?#iB23KgdUu<raO:K/:
1hSsB23!YeRq3haOb&kF3*!H6>"<lB0p%Jg1N`laP.&76?L<(B0p.Mh.L2;aPUW>F3*9P@V3^?B4>;
jib)_BaQ!V?@V!R@B5M\1k%AOPaQI2Q8BC"-D.UfQB5M8%l=Xs(aQj1GD.1NPB5MY0m:U9XaR3\XAB
=4PD0X.kB2*Hgnn1[/aR]aO9ju-8B2*Beok.!0aS'7_Ele#gCid\nB5D2$qIaVQaSQ<WCiRPoB5D\2
rF]qWaSl/>
xbtoa End N 11862 2e56 E 24 S 193cbe R c50565ec
SHAR_EOF
echo 'File kterm-4.1.2/n2ks is complete' &&
chmod 0664 kterm-4.1.2/n2ks ||
echo 'restore of kterm-4.1.2/n2ks failed'
Wc_c="`wc -c < 'kterm-4.1.2/n2ks'`"
test 15081 -eq "$Wc_c" ||
echo 'kterm-4.1.2/n2ks: original size 15081, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= kterm-4.1.2/patchlevel.h ==============
if test -f 'kterm-4.1.2/patchlevel.h' -a X"$1" != X"-c"; then
echo 'x - skipping kterm-4.1.2/patchlevel.h (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting kterm-4.1.2/patchlevel.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'kterm-4.1.2/patchlevel.h' &&
#define patchlevel 6
SHAR_EOF
chmod 0664 kterm-4.1.2/patchlevel.h ||
echo 'restore of kterm-4.1.2/patchlevel.h failed'
Wc_c="`wc -c < 'kterm-4.1.2/patchlevel.h'`"
test 21 -eq "$Wc_c" ||
echo 'kterm-4.1.2/patchlevel.h: original size 21, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= kterm-4.1.2/ptyx.h ==============
if test -f 'kterm-4.1.2/ptyx.h' -a X"$1" != X"-c"; then
echo 'x - skipping kterm-4.1.2/ptyx.h (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting kterm-4.1.2/ptyx.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'kterm-4.1.2/ptyx.h' &&
/*
X * $XConsortium: ptyx.h,v 1.40 89/12/14 18:49:38 jim Exp $
X * $Kagotani: /usr/src.yoshi/X/KTerm/4.1.0/RCS/ptyx.h,v 1.1 90/06/27 09:39:38 kagotani Rel $
X *
X * $Header: /usr/local/src/X11/contrib/clients/kterm-4.1.2/RCS/ptyx.h,v 1.6 1991/03/17 23:48:41 mleisher Exp $
X */
X
/*
X * Modified for Hanzi support:
X * Mark Leisher mleisher@nmsu.edu Fri Nov 9 09:22:33 1990
X */
X
#include "kterm.h"
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
/* ptyx.h */
/* @(#)ptyx.h X10/6.6 11/10/86 */
X
#include <X11/IntrinsicP.h>
#include <X11/Xmu/Misc.h> /* For Max() and Min(). */
#include <signal.h> /* for SIGTSTP */
X
/* Extra Xlib definitions */
#define AllButtonsUp(detail, ignore) (\
X ((ignore) == Button1) ? \
X (((detail)&(Button2Mask|Button3Mask)) == 0) \
X : \
X (((ignore) == Button2) ? \
X (((detail)&(Button1Mask|Button3Mask)) == 0) \
X : \
X (((detail)&(Button1Mask|Button2Mask)) == 0)) \
X )
X
#define MAX_COLS 200
#define MAX_ROWS 128
X
/*
** System V definitions
*/
X
#ifdef SYSV
X
#define killpg(x,sig) kill(-x,sig)
X
#ifndef CRAY
#define dup2(fd1,fd2) ((fd1 == fd2) ? fd1 : \
X (close(fd2), fcntl(fd1, F_DUPFD, fd2)))
#endif
X
#endif /* !SYSV */
X
/*
** allow for mobility of the pty master/slave directories
*/
#ifndef PTYDEV
#ifdef hpux
#define PTYDEV "/dev/ptym/ptyxx"
#else /* !hpux */
#define PTYDEV "/dev/ptyxx"
#endif /* !hpux */
#endif /* !PTYDEV */
X
#ifndef TTYDEV
#ifdef hpux
#define TTYDEV "/dev/pty/ttyxx"
#else /* !hpux */
#define TTYDEV "/dev/ttyxx"
#endif /* !hpux */
#endif /* !TTYDEV */
X
#ifndef PTYCHAR1
#ifdef hpux
#define PTYCHAR1 "zyxwvutsrqp"
#else /* !hpux */
#define PTYCHAR1 "pqrstuvwxyz"
#endif /* !hpux */
#endif /* !PTYCHAR1 */
X
#ifndef PTYCHAR2
#ifdef hpux
#define PTYCHAR2 "fedcba9876543210"
#else /* !hpux */
#define PTYCHAR2 "0123456789abcdef"
#endif /* !hpux */
#endif /* !PTYCHAR2 */
X
#ifdef KTERM_KANJI
# ifndef WCHAR_T
# define WCHAR_T
typedef unsigned short wchar_t;
# endif /* WCHAR_T */
#endif /* KTERM_KANJI */
X
/* Until the translation manager comes along, I have to do my own translation of
X * mouse events into the proper routines. */
X
typedef enum {NORMAL, LEFTEXTENSION, RIGHTEXTENSION} EventMode;
X
/*
X * The origin of a screen is 0, 0. Therefore, the number of rows
X * on a screen is screen->max_row + 1, and similarly for columns.
X */
X
typedef unsigned char Char; /* to support 8 bit chars */
X
#ifdef KTERM
typedef struct {
X Char gset;
X Char code;
X Char attr;
} Bchr;
typedef Bchr **ScrnBuf;
#else /* !KTERM */
typedef Char **ScrnBuf;
#endif /* !KTERM */
X
/*
X * ANSI emulation.
X */
#define INQ 0x05
#define FF 0x0C /* C0, C1 control names */
#define LS1 0x0E
#define LS0 0x0F
#define CAN 0x18
#define SUB 0x1A
#define ESC 0x1B
#define US 0x1F
#define DEL 0x7F
#define HTS ('H'+0x40)
#define SS2 0x8E
#define SS3 0x8F
#define DCS 0x90
#define OLDID 0x9A /* ESC Z */
#define CSI 0x9B
#define ST 0x9C
#define OSC 0x9D
#define PM 0x9E
#define APC 0x9F
#define RDEL 0xFF
X
#define NMENUFONTS 7 /* entries in fontMenu */
X
#define NBOX 5 /* Number of Points in box */
#define NPARAM 10 /* Max. parameters */
X
#define MINHILITE 32
X
typedef struct {
X unsigned char a_type;
X unsigned char a_pintro;
X unsigned char a_final;
X unsigned char a_inters;
X char a_nparam; /* # of parameters */
X char a_dflt[NPARAM]; /* Default value flags */
X short a_param[NPARAM]; /* Parameters */
X char a_nastyf; /* Error flag */
} ANSI;
X
typedef struct {
X int row;
X int col;
X unsigned flags; /* Vt100 saves graphics rendition. Ugh! */
X char curgl;
X char curgr;
#ifdef KTERM
X Char gsets[4];
#else /* !KTERM */
X char gsets[4];
#endif /* !KTERM */
} SavedCursor;
X
#define TEK_FONT_LARGE 0
#define TEK_FONT_2 1
#define TEK_FONT_3 2
#define TEK_FONT_SMALL 3
#define TEKNUMFONTS 4
X
/* Actually there are 5 types of lines, but four are non-solid lines */
#define TEKNUMLINES 4
X
typedef struct {
X int x;
X int y;
X int fontsize;
X int linetype;
} Tmodes;
X
typedef struct {
X int Twidth;
X int Theight;
} T_fontsize;
X
typedef struct {
X short *bits;
X int x;
X int y;
X int width;
X int height;
} BitmapBits;
X
#define SAVELINES 64 /* default # lines to save */
#define SCROLLLINES 1 /* default # lines to scroll */
X
#ifdef KTERM
# define LINESPACE 0 /* default space between lines */
# define F_ISO8859_1 0
# define F_JISX0201_0 (F_ISO8859_1 + 1)
# ifdef KTERM_KANJI
# define F_JISX0208_0 (F_JISX0201_0 + 1)
# define FCNT (F_JISX0208_0 + 1)
# else
# define FCNT (F_JISX0201_0 + 1)
# endif
X
#ifdef KTERM_HANZI
#define F_GB2312_0 (F_JISX0208_0 + 1)
# ifdef FCNT
# undef FCNT
# endif
#define FCNT (F_GB2312_0 + 1)
#endif /* KTERM_HANZI */
X
#ifdef KTERM_HANGUL
# ifdef KTERM_HANZI
# define F_KSC5601_0 (F_GB2312_0 + 1)
# else
# define F_KSC5601_0 (F_JISX0208 + 1)
# endif
# ifdef FCNT
# undef FCNT
# endif
#define FCNT (F_KSC5601_0 + 1)
#endif /* KTERM_HANGUL */
X
/*
X * Changing FNUM to int fontno() to simplify adding other charsets
X * later. The fontno() function located in charproc.c.
X * M. Leisher
X */
X
int fontno(/* int gs */);
X
#define FNUM(gs) fontno(gs)
X
int FontType(/* TScreen *screen, int fnum, bold */);
X
#endif /* KTERM */
X
typedef struct {
/* These parameters apply to both windows */
X Display *display; /* X display for screen */
X int respond; /* socket for responses
X (position report, etc.) */
X long pid; /* pid of process on far side */
X int uid; /* user id of actual person */
X int gid; /* group id of actual person */
#ifdef KTERM
X GC _normalGC[FCNT];
X GC _reverseGC[FCNT];
X GC _normalboldGC[FCNT];
X GC _reverseboldGC[FCNT];
X GC _cursorGC[FCNT];
X GC _reversecursorGC[FCNT];
# define normalGC _normalGC[fnum]
# define reverseGC _reverseGC[fnum]
# define normalboldGC _normalboldGC[fnum]
# define reverseboldGC _reverseboldGC[fnum]
# define cursorGC _cursorGC[fnum]
# define reversecursorGC _reversecursorGC[fnum]
#else /* !KTERM */
X GC normalGC; /* normal painting */
X GC reverseGC; /* reverse painting */
X GC normalboldGC; /* normal painting, bold font */
X GC reverseboldGC; /* reverse painting, bold font */
X GC cursorGC; /* normal cursor painting */
X GC reversecursorGC;/* reverse cursor painting */
#endif /* !KTERM */
X GC cursoroutlineGC;/* for painting lines around */
X Pixel foreground; /* foreground color */
X Pixel cursorcolor; /* Cursor color */
X Pixel mousecolor; /* Mouse color */
X Pixel mousecolorback; /* Mouse color background */
#ifdef COLOR_TEXT /* mukawa */
X Pixel textcolor[8]; /* text color */
#endif COLOR_TEXT
X int border; /* inner border */
X Cursor arrow; /* arrow cursor */
X unsigned short send_mouse_pos; /* user wants mouse transition */
X /* and position information */
X int select; /* xterm selected */
X Boolean visualbell; /* visual bell mode */
X int logging; /* logging mode */
X Boolean allowSendEvents;/* SendEvent mode */
X Boolean grabbedKbd; /* keyboard is grabbed */
X int logfd; /* file descriptor of log */
X char *logfile; /* log file name */
X unsigned char *logstart; /* current start of log buffer */
X int inhibit; /* flags for inhibiting changes */
X
/* VT window parameters */
X struct {
X Window window; /* X window id */
X int width; /* width of columns */
X int height; /* height of rows */
X int fullwidth; /* full width of window */
X int fullheight; /* full height of window */
X int f_width; /* width of fonts in pixels */
X int f_height; /* height of fonts in pixels */
X } fullVwin;
X Cursor pointer_cursor; /* pointer cursor in window */
X
X /* Terminal fonts must be of the same size and of fixed width */
#ifdef KTERM
X XFontStruct *_fnt_norm[FCNT];
X XFontStruct *_fnt_bold[FCNT];
X int _enbolden[FCNT];
X XPoint *_box[FCNT];
# define fnt_norm _fnt_norm[fnum]
# define fnt_bold _fnt_bold[fnum]
# define enbolden _enbolden[fnum]
# define box _box[fnum]
X int linespace; /* space between lines */
X int max_ascent;
X int max_descent;
#else /* !KTERM */
X XFontStruct *fnt_norm; /* normal font of terminal */
X XFontStruct *fnt_bold; /* bold font of terminal */
X int enbolden; /* overstrike for bold font */
X XPoint *box; /* draw unselected cursor */
#endif /* !KTERM */
X
X int cursor_state; /* ON or OFF */
X int cursor_set; /* requested state */
X int cursor_col; /* previous cursor column */
X int cursor_row; /* previous cursor row */
X int cur_col; /* current cursor column */
X int cur_row; /* current cursor row */
X int max_col; /* rightmost column */
X int max_row; /* bottom row */
X int top_marg; /* top line of scrolling region */
X int bot_marg; /* bottom line of " " */
X Widget scrollWidget; /* pointer to scrollbar struct */
X int scrollbar; /* if > 0, width of scrollbar, and
X scrollbar is showing */
X int topline; /* line number of top, <= 0 */
X int savedlines; /* number of lines that've been saved */
X int savelines; /* number of lines off top to save */
X int scrolllines; /* number of lines to button scroll */
X Boolean scrollttyoutput; /* scroll to bottom on tty output */
X Boolean scrollkey; /* scroll to bottom on key */
X
X ScrnBuf buf; /* screen buffer (main) */
X ScrnBuf allbuf; /* screen buffer (may include
X lines scrolled off top */
X char *sbuf_address; /* main screen memory address */
X ScrnBuf altbuf; /* alternate screen buffer */
X char *abuf_address; /* alternate screen memory address */
X Boolean alternate; /* true if using alternate buf */
X unsigned short do_wrap; /* true if cursor in last column
X and character just output */
X int incopy; /* 0 if no RasterCopy exposure
X event processed since last
X RasterCopy */
X Boolean c132; /* allow change to 132 columns */
X Boolean curses; /* cludge-ups for more and vi */
X Boolean marginbell; /* true if margin bell on */
X int nmarginbell; /* columns from right margin */
X int bellarmed; /* cursor below bell margin */
X Boolean multiscroll; /* true if multi-scroll */
X int scrolls; /* outstanding scroll count */
X SavedCursor sc; /* data for restore cursor */
X int save_modes[19]; /* save dec private modes */
#ifdef STATUSLINE
X Boolean statusline; /* status line showing */
X Boolean reversestatus; /* status line reversed */
X Boolean instatus; /* cursor in status line */
X int statusheight; /* status line height */
X SavedCursor statussc; /* status line restore cursor */
#endif /* STATUSLINE */
X
X /* Improved VT100 emulation stuff. */
#ifdef KTERM
X Char gsets[4]; /* G0 through G3. */
#else /* !KTERM */
X char gsets[4]; /* G0 through G3. */
#endif /* !KTERM */
X char curgl; /* Current GL setting. */
X char curgr; /* Current GR setting. */
X char curss; /* Current single shift. */
X int scroll_amt; /* amount to scroll */
X int refresh_amt; /* amount to refresh */
X Boolean jumpscroll; /* whether we should jumpscroll */
X Boolean always_highlight; /* whether to highlight cursor */
X
/* Tektronix window parameters */
X GC TnormalGC; /* normal painting */
X GC TcursorGC; /* normal cursor painting */
X Pixel Tforeground; /* foreground color */
X Pixel Tbackground; /* Background color */
X Pixel Tcursorcolor; /* Cursor color */
X int Tcolor; /* colors used */
X Boolean Vshow; /* VT window showing */
X Boolean Tshow; /* Tek window showing */
X Boolean waitrefresh; /* postpone refresh */
X struct {
X Window window; /* X window id */
X int width; /* width of columns */
X int height; /* height of rows */
X int fullwidth; /* full width of window */
X int fullheight; /* full height of window */
X double tekscale; /* scale factor Tek -> vs100 */
X } fullTwin;
X XPoint **Tbox; /* draw unselected cursor */
X int xorplane; /* z plane for inverts */
X GC linepat[TEKNUMLINES]; /* line patterns */
X Boolean TekEmu; /* true if Tektronix emulation */
X int cur_X; /* current x */
X int cur_Y; /* current y */
X Tmodes cur; /* current tek modes */
X Tmodes page; /* starting tek modes on page */
X int margin; /* 0 -> margin 1, 1 -> margin 2 */
X int pen; /* current Tektronix pen 0=up, 1=dn */
X char *TekGIN; /* nonzero if Tektronix GIN mode*/
X int multiClickTime; /* time between multiclick selects */
X char *charClass; /* for overriding word selection */
X Boolean cutNewline; /* whether or not line cut has \n */
X Boolean cutToBeginningOfLine; /* line cuts to BOL? */
#ifdef KTERM
X Ichr *selection; /* the current selection */
#else /* !KTERM */
X char *selection; /* the current selection */
#endif /* !KTERM */
X int selection_size; /* size of allocated buffer */
X int selection_length; /* number of significant bytes */
X int selection_time; /* latest event timestamp */
X int startHRow, startHCol, /* highlighted text */
X endHRow, endHCol,
X startHCoord, endHCoord;
X Atom* selection_atoms; /* which selections we own */
X Cardinal sel_atoms_size; /* how many atoms allocated */
X Cardinal selection_count; /* how many atoms in use */
X Boolean eight_bits; /* use 8th bit instead of ESC prefix */
X Pixmap menu_item_bitmap; /* mask for checking items */
X Widget mainMenu, vtMenu, tekMenu, fontMenu;
#ifdef KTERM
X char* menu_font_list[NMENUFONTS];
X char* menu_bfont_list[NMENUFONTS];
X char* _menu_font_names[FCNT][NMENUFONTS];
X char* _menu_bfont_names[FCNT][NMENUFONTS];
# define menu_font_names _menu_font_names[fnum]
# define menu_bfont_names _menu_bfont_names[fnum]
#else /* !KTERM */
X char* menu_font_names[NMENUFONTS];
#endif /* !KTERM */
X int menu_font_number;
} TScreen;
X
typedef struct _TekPart {
X XFontStruct *Tfont[TEKNUMFONTS];
X int tobaseline[TEKNUMFONTS]; /* top to baseline for each font */
X char *initial_font; /* large, 2, 3, small */
} TekPart;
X
X
X
/* meaning of bits in screen.select flag */
#define INWINDOW 01 /* the mouse is in one of the windows */
#define FOCUS 02 /* one of the windows is the focus window */
X
#define MULTICLICKTIME 250 /* milliseconds */
X
typedef struct
{
X unsigned flags;
} TKeyboard;
X
typedef struct _Misc {
X char *geo_metry;
X char *T_geometry;
#ifdef KTERM
X char *fontlist;
X char *bfontlist;
X char *_f_n[FCNT];
X char *_f_b[FCNT];
# define f_n _f_n[fnum]
# define f_b _f_b[fnum]
#ifdef KTERM_KANJI
X char *k_m;
#endif /* KTERM_KANJI */
#ifdef KTERM_HANZI
X char *hz_m;
X char *hz_gb2big_tbl;
X char *hz_big2gb_tbl;
#endif /* KTERM_HANZI */
#ifdef KTERM_HANGUL
X char *hg_m;
X char *hg_n2ks_tbl;
#endif /* KTERM_HANGUL */
X
#ifdef KTERM_KANJI
X char *lang; /* This will be the language being displayed. */
#endif
X
#else /* !KTERM */
X char *f_n;
X char *f_b;
#endif /* !KTERM */
X Boolean log_on;
X Boolean login_shell;
X Boolean re_verse;
X Boolean reverseWrap;
X Boolean logInhibit;
X Boolean signalInhibit;
X Boolean tekInhibit;
X Boolean scrollbar;
X Boolean titeInhibit;
X Boolean tekSmall; /* start tek window in small size */
#ifdef STATUSLINE
X Boolean statusnormal;
#endif /* STATUSLINE */
} Misc;
X
typedef struct {int foo;} XtermClassPart, TekClassPart;
X
typedef struct _XtermClassRec {
X CoreClassPart core_class;
X XtermClassPart xterm_class;
} XtermClassRec;
X
typedef struct _TekClassRec {
X CoreClassPart core_class;
X TekClassPart tek_class;
} TekClassRec;
X
/* define masks for flags */
#define CAPS_LOCK 0x01
#define KYPD_APL 0x02
#define CURSOR_APL 0x04
X
#define N_MARGINBELL 10
#define MAX_TABS 320
#define TAB_ARRAY_SIZE 10 /* number of ints to provide MAX_TABS bits */
X
typedef unsigned Tabs [TAB_ARRAY_SIZE];
X
typedef struct _XtermWidgetRec {
X CorePart core;
X TKeyboard keyboard; /* terminal keyboard */
X TScreen screen; /* terminal screen */
X unsigned flags; /* mode flags */
X unsigned initflags; /* initial mode flags */
X Tabs tabs; /* tabstops of the terminal */
X Misc misc; /* miscelaneous parameters */
} XtermWidgetRec, *XtermWidget;
X
typedef struct _TekWidgetRec {
X CorePart core;
X TekPart tek;
} TekWidgetRec, *TekWidget;
X
#define BUF_SIZE 4096
X
/* masks for terminal flags */
X
#define INVERSE 0x01 /* invert the characters to be output */
#define UNDERLINE 0x02 /* true if underlining */
#define BOLD 0x04
#define NL_TAG 0x08
#define TAB_TAG 0x10
#ifdef COLOR_TEXT /* mukawa */
#define COLOR_TEXT_MASK 0x78 /* text color RGB attribute. */
#define COLOR_TEXT_MASK2 0xf
#define COLOR_TEXT_SHIFT 3
#define COLOR_TEXT_ADJUST 3
#define COLOR_TEXT0 0x18
#define COLOR_TEXT1 0x20
#define COLOR_TEXT2 0x28
#define COLOR_TEXT3 0x30
#define COLOR_TEXT4 0x38
#define COLOR_TEXT5 0x40
#define COLOR_TEXT6 0x48
#define COLOR_TEXT7 0x50
#define WRAPAROUND 0x80
#define REVERSE_VIDEO 0x100 /* true if screen white on black */
#define ORIGIN 0x200 /* true if in origin mode */
#define INSERT 0x400 /* true if in insert mode */
#define SMOOTHSCROLL 0x800 /* true if in smooth scroll mode */
#define IN132COLUMNS 0x1000 /* true if in 132 column mode */
#define LINEFEED 0x2000
#define REVERSEWRAP 0x4000 /* true if reverse wraparound mode */
#ifdef KTERM_KANJI
#define JIS_KANJI 0x8000 /* true if in JIS mode */
#define EUC_KANJI 0x10000 /* true if in EUC mode */
#define SJIS_KANJI 0x20000 /* true if in SJIS mode */
#endif /* KTERM_KANJI */
#ifdef KTERM_HANZI
#define GUOBIAO_HANZI 0x40000 /* true if in GuoBiao mode */
#define SGB_HANZI 0x80000 /* true if in Shift-GuoBiao mode */
#define BIG5_HANZI 0x100000 /* true if in Big5 mode */
#endif /* KTERM_HANZI */
#ifdef KTERM_HANGUL
#define KS_HANGUL 0x200000 /* true if in KS Hangul mode */
#define NBYTE_HANGUL 0x400000 /* true if in N-byte Hangul mode */
#endif /* KTERM_HANGUL */
X
#else /* COLOR_TEXT */
X
#define WRAPAROUND 0x20
#define REVERSE_VIDEO 0x40 /* true if screen white on black */
#define ORIGIN 0x80 /* true if in origin mode */
#define INSERT 0x100 /* true if in insert mode */
#define SMOOTHSCROLL 0x200 /* true if in smooth scroll mode */
#define IN132COLUMNS 0x400 /* true if in 132 column mode */
#define LINEFEED 0x800
#define REVERSEWRAP 0x1000 /* true if reverse wraparound mode */
#ifdef KTERM_KANJI
#define JIS_KANJI 0x2000 /* true if in JIS mode */
#define EUC_KANJI 0x4000 /* true if in EUC mode */
#define SJIS_KANJI 0x8000 /* true if in SJIS mode */
#endif /* KTERM_KANJI */
#ifdef KTERM_HANZI
#define GUOBIAO_HANZI 0x10000 /* true if in GuoBiao mode */
#define SGB_HANZI 0x20000 /* true if in Shift-GuoBiao mode */
#define BIG5_HANZI 0x40000 /* true if in Big5 mode */
#endif /* KTERM_HANZI */
#ifdef KTERM_HANGUL
#define KS_HANGUL 0x80000 /* true if in KS Hangul mode */
#define NBYTE_HANGUL 0x100000 /* true if in N-byte Hangul mode */
#endif /* KTERM_HANGUL */
X
#endif /* COLOR_TEXT */
X
#define ATTRIBUTES 0x07 /* attributes mask */
#define CHAR 0177
X
#define VWindow(screen) (screen->fullVwin.window)
#define VShellWindow term->core.parent->core.window
#define TextWindow(screen) (screen->fullVwin.window)
#define TWindow(screen) (screen->fullTwin.window)
#define TShellWindow tekWidget->core.parent->core.window
#define Width(screen) (screen->fullVwin.width)
#define Height(screen) (screen->fullVwin.height)
#define FullWidth(screen) (screen->fullVwin.fullwidth)
#define FullHeight(screen) (screen->fullVwin.fullheight)
#define FontWidth(screen) (screen->fullVwin.f_width)
#ifdef KTERM
#ifdef KTERM_KANJI
/*
X * These are the three types returned by the FontType() function
X * in charproc.c
X */
#define NONE -1 /* Font doesn't exist. */
#define HIGH 0 /* Font encoded 0xa1a1. */
#define LOW 1 /* Font encoded 0x2121. */
#define MIXED 2 /* Font encoded 0xa140 (Big5 special). */
#endif /* KTERM_KANJI */
X
#define FontHeight(screen) (screen->fullVwin.f_height + screen->linespace)
/*
#define FontHeight(screen) (screen->fullVwin.f_height + term->misc.linespace)
*/
#else /* !KTERM */
#define FontHeight(screen) (screen->fullVwin.f_height)
#endif /* !KTERM */
#define TWidth(screen) (screen->fullTwin.width)
#define THeight(screen) (screen->fullTwin.height)
#define TFullWidth(screen) (screen->fullTwin.fullwidth)
#define TFullHeight(screen) (screen->fullTwin.fullheight)
#define TekScale(screen) (screen->fullTwin.tekscale)
X
#define CursorX(screen,col) ((col) * FontWidth(screen) + screen->border \
X + screen->scrollbar)
#define CursorY(screen,row) ((((row) - screen->topline) * FontHeight(screen)) \
X + screen->border)
X
#define TWINDOWEVENTS (KeyPressMask | ExposureMask | ButtonPressMask |\
X ButtonReleaseMask | StructureNotifyMask |\
X EnterWindowMask | LeaveWindowMask | FocusChangeMask)
X
#define WINDOWEVENTS (TWINDOWEVENTS | PointerMotionMask)
X
X
#define TEK_LINK_BLOCK_SIZE 1024
X
typedef struct Tek_Link
{
X struct Tek_Link *next; /* pointer to next TekLink in list
X NULL <=> this is last TekLink */
X short count;
X char *ptr;
X char data [TEK_LINK_BLOCK_SIZE];
} TekLink;
X
/* flags for cursors */
#define OFF 0
#define ON 1
#define CLEAR 0
#define TOGGLE 1
X
/* flags for inhibit */
#define I_LOG 0x01
#define I_SIGNAL 0x02
#define I_TEK 0x04
X
extern Cursor make_colored_cursor();
SHAR_EOF
chmod 0664 kterm-4.1.2/ptyx.h ||
echo 'restore of kterm-4.1.2/ptyx.h failed'
Wc_c="`wc -c < 'kterm-4.1.2/ptyx.h'`"
test 21948 -eq "$Wc_c" ||
echo 'kterm-4.1.2/ptyx.h: original size 21948, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= kterm-4.1.2/screen.c ==============
if test -f 'kterm-4.1.2/screen.c' -a X"$1" != X"-c"; then
echo 'x - skipping kterm-4.1.2/screen.c (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting kterm-4.1.2/screen.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'kterm-4.1.2/screen.c' &&
/*
X * $XConsortium: screen.c,v 1.16 89/12/10 20:44:52 jim Exp $
X * $Kagotani: /usr/src.yoshi/X/KTerm/4.1.0/RCS/screen.c,v 1.1 90/06/27 09:39:50 kagotani Rel $
X *
X * $Id: screen.c,v 1.2 1991/03/17 23:54:57 mleisher Exp $
X */
X
/*
X * Modified for Hanzi support:
X * Mark Leisher mleisher@nmsu.edu Fri Nov 9 09:22:33 1990
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
/* screen.c */
X
#ifndef lint
static char rcs_id[] = "$XConsortium: screen.c,v 1.16 89/12/10 20:44:52 jim Exp $";
#endif /* lint */
X
#include <X11/Xlib.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include "ptyx.h"
#include "error.h"
X
extern Char *calloc(), *malloc(), *realloc();
extern void bcopy();
extern void free();
X
ScrnBuf Allocate (nrow, ncol, addr)
/*
X allocates memory for a 2-dimensional array of chars and returns a pointer
X thereto
X each line is formed from a pair of char arrays. The first (even) one is
X the actual character array and the second (odd) one is the attributes.
X */
register int nrow, ncol;
#ifdef KTERM
Bchr **addr;
#else /* !KTERM */
Char **addr;
#endif /* !KTERM */
{
X register ScrnBuf base;
#ifdef KTERM
X register Bchr *tmp;
#else /* !KTERM */
X register Char *tmp;
#endif /* !KTERM */
X register int i;
X
#ifdef STATUSLINE
X nrow++;
#endif /* STATUSLINE */
#ifdef KTERM
X if ((base = (ScrnBuf) calloc ((unsigned)nrow, sizeof (Bchr *))) == 0)
#else /* !KTERM */
X if ((base = (ScrnBuf) calloc ((unsigned)(nrow *= 2), sizeof (char *))) == 0)
#endif /* !KTERM */
X SysError (ERROR_SCALLOC);
X
#ifdef KTERM
X if ((tmp = (Bchr *)calloc ((unsigned) (nrow * ncol), sizeof(Bchr))) == 0)
#else /* !KTERM */
X if ((tmp = calloc ((unsigned) (nrow * ncol), sizeof(char))) == 0)
#endif /* !KTERM */
X SysError (ERROR_SCALLOC2);
X
X *addr = tmp;
X for (i = 0; i < nrow; i++, tmp += ncol)
X base[i] = tmp;
X
X return (base);
}
X
/*
X * This is called when the screen is resized. Not complex if you do
X * things in the right order...
X */
static void
Reallocate(sbuf, sbufaddr, nrow, ncol, oldrow, oldcol)
ScrnBuf *sbuf;
#ifdef KTERM
Bchr **sbufaddr;
#else /* !KTERM */
Char **sbufaddr;
#endif /* !KTERM */
int nrow, ncol, oldrow, oldcol;
{
X register ScrnBuf base;
#ifdef KTERM
X register Bchr *tmp;
X register int i, minrows, mincols;
X Bchr *oldbuf;
#else /* !KTERM */
X register Char *tmp;
X register int i, minrows, mincols;
X Char *oldbuf;
#endif /* !KTERM */
#ifdef STATUSLINE
# ifdef KTERM
X Bchr *oldstat;
# else /* !KTERM */
X char *oldstat;
# endif /* !KTERM */
#endif /* STATUSLINE */
X
X if (sbuf == NULL || *sbuf == NULL)
X return;
X
#ifdef STATUSLINE
X nrow++;
X oldrow++;
X /* save pointers for the statusline (the last row) */
X oldstat = (*sbuf)[oldrow-1];
#endif /* STATUSLINE */
#ifndef KTERM
X oldrow *= 2;
#endif /* !KTERM */
X oldbuf = *sbufaddr;
X
X /*
X * Special case if oldcol == ncol - straight forward realloc and
X * update of the additional lines in sbuf
X */
X
X /*
X * realloc sbuf; we don't care about losing the lower lines if the
X * screen shrinks. It might be cleaner to readjust the screen so
X * that the UPPER lines vanish when the screen shrinks but that's
X * more work...
X */
#ifdef KTERM
X *sbuf = (ScrnBuf) realloc((char *) (*sbuf),
X (unsigned) (nrow * sizeof(Bchr *)));
#else /* !KTERM */
X nrow *= 2;
X *sbuf = (ScrnBuf) realloc((char *) (*sbuf),
X (unsigned) (nrow * sizeof(char *)));
#endif /* !KTERM */
X if (*sbuf == 0)
X SysError(ERROR_RESIZE);
X base = *sbuf;
X
X /*
X * create the new buffer space and copy old buffer contents there
X * line by line, updating the pointers in sbuf as we go; then free
X * the old buffer
X */
#ifdef KTERM
X if ((tmp = (Bchr *)calloc((unsigned) (nrow * ncol), sizeof(Bchr))) == 0)
#else /* !KTERM */
X if ((tmp = calloc((unsigned) (nrow * ncol), sizeof(char))) == 0)
#endif /* !KTERM */
X SysError(ERROR_SREALLOC);
#ifdef STATUSLINE
X nrow--;
X oldrow--;
#endif /* STATUSLINE */
X *sbufaddr = tmp;
X minrows = (oldrow < nrow) ? oldrow : nrow;
X mincols = (oldcol < ncol) ? oldcol : ncol;
#ifdef KTERM
X mincols *= sizeof(Bchr);
#endif /* KTERM */
X for(i = 0; i < minrows; i++, tmp += ncol) {
X bcopy(base[i], tmp, mincols);
X base[i] = tmp;
X }
X if (oldrow < nrow) {
X for (i = minrows; i < nrow; i++, tmp += ncol)
X base[i] = tmp;
X }
#ifdef STATUSLINE
X bcopy(oldstat, tmp, mincols);
X base[nrow] = tmp;
#ifndef KTERM
X tmp += ncol;
X oldstat += oldcol;
X bcopy(oldstat, tmp, mincols);
X base[nrow+1] = tmp;
#endif /* !KTERM */
#endif /* STATUSLINE */
X /* Now free the old buffer - simple, see... */
X free(oldbuf);
}
X
#ifdef KTERM
ScreenWrite (screen, str, flags, gset, length)
#else /* !KTERM */
ScreenWrite (screen, str, flags, length)
#endif /* !KTERM */
/*
X Writes str into buf at row row and column col. Characters are set to match
X flags.
X */
TScreen *screen;
char *str;
register unsigned flags;
#ifdef KTERM
register Char gset;
#endif /* KTERM */
register int length; /* length of string */
{
#ifdef KTERM
X register int avail = screen->max_col - screen->cur_col + 1;
X register Bchr *col;
#else /* !KTERM */
X register Char *attrs;
X register int avail = screen->max_col - screen->cur_col + 1;
X register Char *col;
#endif /* !KTERM */
X
X if (length > avail)
X length = avail;
X if (length <= 0)
X return;
X
#ifdef KTERM
X col = screen->buf[avail = screen->cur_row] + screen->cur_col;
X flags &= (ATTRIBUTES|COLOR_TEXT_MASK);
#else /* !KTERM */
X col = screen->buf[avail = 2 * screen->cur_row] + screen->cur_col;
X attrs = screen->buf[avail + 1] + screen->cur_col;
X flags &= ATTRIBUTES;
#endif /* !KTERM */
#ifdef KTERM
X if (gset & MBCS) {
X while(length > 0) {
X col->code = *str++;
X col->gset = gset;
X col->attr = flags;
X col++;
X col->code = *str++;
X col->gset = MBC2;
X col->attr = flags;
X col++;
X length -= 2;
X }
X } else {
X while(length-- > 0) {
X col->code = *str++;
X col->gset = gset;
X col->attr = flags;
X col++;
X }
X }
#else /* KTERM */
X bcopy(str, col, length);
X while(length-- > 0)
X *attrs++ = flags;
#endif /* !KTERM */
}
X
ScrnInsertLine (sb, last, where, n, size)
/*
X Inserts n blank lines at sb + where, treating last as a bottom margin.
X Size is the size of each entry in sb.
X Requires: 0 <= where < where + n <= last
X n <= MAX_ROWS
X */
register ScrnBuf sb;
int last;
register int where, n, size;
{
X register int i;
#ifdef KTERM
X Bchr *save [MAX_ROWS];
#else /* !KTERM */
X char *save [2 * MAX_ROWS];
#endif /* !KTERM */
X
X
X /* save n lines at bottom */
#ifdef KTERM
X bcopy ((char *) &sb [last -= n - 1], (char *) save,
X sizeof (Bchr *) * n);
#else /* !KTERM */
X bcopy ((char *) &sb [2 * (last -= n - 1)], (char *) save,
X 2 * sizeof (char *) * n);
#endif /* !KTERM */
X
X /* clear contents of old rows */
#ifdef KTERM
X for (i = n - 1; i >= 0; i--)
X bzero ((char *) save [i], size *sizeof(Bchr));
#else /* !KTERM */
X for (i = 2 * n - 1; i >= 0; i--)
X bzero ((char *) save [i], size);
#endif /* !KTERM */
X
X /*
X * WARNING, overlapping copy operation. Move down lines (pointers).
X *
X * +----|---------|--------+
X *
X * is copied in the array to:
X *
X * +--------|---------|----+
X */
#ifdef KTERM
X bcopy ((char *) &sb [where], (char *) &sb [where + n],
X sizeof (Bchr *) * (last - where));
#else /* !KTERM */
X bcopy ((char *) &sb [2 * where], (char *) &sb [2 * (where + n)],
X 2 * sizeof (char *) * (last - where));
#endif /* !KTERM */
X
X /* reuse storage for new lines at where */
#ifdef KTERM
X bcopy ((char *)save, (char *) &sb[where], sizeof(Bchr *) * n);
#else /* !KTERM */
X bcopy ((char *)save, (char *) &sb[2 * where], 2 * sizeof(char *) * n);
#endif /* !KTERM */
}
X
X
ScrnDeleteLine (sb, last, where, n, size)
/*
X Deletes n lines at sb + where, treating last as a bottom margin.
X Size is the size of each entry in sb.
X Requires 0 <= where < where + n < = last
X n <= MAX_ROWS
X */
register ScrnBuf sb;
register int n, last, size;
int where;
{
X register int i;
#ifdef KTERM
X Bchr *save [MAX_ROWS];
#else /* !KTERM */
X char *save [2 * MAX_ROWS];
#endif /* !KTERM */
X
X /* save n lines at where */
#ifdef KTERM
X bcopy ((char *) &sb[where], (char *)save, sizeof(Bchr *) * n);
#else /* !KTERM */
X bcopy ((char *) &sb[2 * where], (char *)save, 2 * sizeof(char *) * n);
#endif /* !KTERM */
X
X /* clear contents of old rows */
#ifdef KTERM
X for (i = n - 1 ; i >= 0 ; i--)
X bzero ((char *) save [i], size * sizeof(Bchr));
#else /* !KTERM */
X for (i = 2 * n - 1 ; i >= 0 ; i--)
X bzero ((char *) save [i], size);
#endif /* !KTERM */
X
X /* move up lines */
#ifdef KTERM
X bcopy ((char *) &sb[where + n], (char *) &sb[where],
X sizeof (Bchr *) * ((last -= n - 1) - where));
#else /* !KTERM */
X bcopy ((char *) &sb[2 * (where + n)], (char *) &sb[2 * where],
X 2 * sizeof (char *) * ((last -= n - 1) - where));
#endif /* !KTERM */
X
X /* reuse storage for new bottom lines */
#ifdef KTERM
X bcopy ((char *)save, (char *) &sb[last], sizeof(Bchr *) * n);
#else /* !KTERM */
X bcopy ((char *)save, (char *) &sb[2 * last],
X 2 * sizeof(char *) * n);
#endif /* !KTERM */
}
X
X
ScrnInsertChar (sb, row, col, n, size)
/*
X Inserts n blanks in sb at row, col. Size is the size of each row.
X */
ScrnBuf sb;
int row, size;
register int col, n;
{
X register int i, j;
#ifdef KTERM
X register Bchr *ptr = sb [row];
#else /* !KTERM */
X register Char *ptr = sb [2 * row];
X register Char *attrs = sb [2 * row + 1];
#endif /* !KTERM */
X
X for (i = size - 1; i >= col + n; i--) {
X ptr[i] = ptr[j = i - n];
#ifndef KTERM
X attrs[i] = attrs[j];
#endif /* !KTERM */
X }
X
#ifdef KTERM
X bzero (ptr + col, n * sizeof(Bchr));
#else /* !KTERM */
X bzero (ptr + col, n);
X bzero (attrs + col, n);
#endif /* !KTERM */
}
X
X
ScrnDeleteChar (sb, row, col, n, size)
/*
X Deletes n characters in sb at row, col. Size is the size of each row.
X */
ScrnBuf sb;
register int row, size;
register int n, col;
{
#ifdef KTERM
X register Bchr *ptr = sb[row];
#else /* !KTERM */
X register Char *ptr = sb[2 * row];
X register Char *attrs = sb[2 * row + 1];
#endif /* !KTERM */
X register nbytes = (size - n - col);
X
#ifdef KTERM
X bcopy (ptr + col + n, ptr + col, nbytes * sizeof(Bchr));
X bzero (ptr + size - n, n * sizeof(Bchr));
#else /* !KTERM */
X bcopy (ptr + col + n, ptr + col, nbytes);
X bcopy (attrs + col + n, attrs + col, nbytes);
X bzero (ptr + size - n, n);
X bzero (attrs + size - n, n);
#endif /* !KTERM */
}
X
X
ScrnRefresh (screen, toprow, leftcol, nrows, ncols, force)
/*
X Repaints the area enclosed by the parameters.
X Requires: (toprow, leftcol), (toprow + nrows, leftcol + ncols) are
X coordinates of characters in screen;
X nrows and ncols positive.
X */
register TScreen *screen;
int toprow, leftcol, nrows, ncols;
Boolean force; /* ... leading/trailing spaces */
{
#ifdef KTERM
X XChar2b drawbuf[256], *dbuf;
X int y = toprow * FontHeight(screen) + screen->border;
#else /* !KTERM */
X int y = toprow * FontHeight(screen) + screen->border +
X screen->fnt_norm->ascent;
#endif /* !KTERM */
X register int row;
X register int topline = screen->topline;
X int maxrow = toprow + nrows - 1;
X int scrollamt = screen->scroll_amt;
X int max = screen->max_row;
#ifdef STATUSLINE
X int dostatus = 0, left, width;
X int fnum = F_ISO8859_1;
#endif /* STATUSLINE */
X
#ifdef KTERM
X dbuf = (ncols > 256) ? (XChar2b *)XtMalloc(ncols * sizeof(XChar2b))
X : drawbuf;
#endif /* KTERM */
#ifdef STATUSLINE
X if (screen->statusline && maxrow == screen->max_row + 1) {
X dostatus++;
X maxrow--;
X }
#endif /* STATUSLINE */
X if(screen->cursor_col >= leftcol && screen->cursor_col <=
X (leftcol + ncols - 1) && screen->cursor_row >= toprow + topline &&
X screen->cursor_row <= maxrow + topline)
X screen->cursor_state = OFF;
#ifdef STATUSLINE
X for (;;) {
#endif /* STATUSLINE */
X for (row = toprow; row <= maxrow; y += FontHeight(screen), row++) {
#ifdef KTERM
X register Bchr *chars;
X Char gset;
#else /* !KTERM */
X register Char *chars;
X register Char *attrs;
#endif /* !KTERM */
X register int col = leftcol;
X int maxcol = leftcol + ncols - 1;
X int lastind;
X int flags;
X int x, n;
X GC gc;
X Boolean hilite;
X
X if (row < screen->top_marg || row > screen->bot_marg)
X lastind = row;
X else
X lastind = row - scrollamt;
X
X if (lastind < 0 || lastind > max)
X continue;
X
#ifdef KTERM
X n = 0;
X chars = screen->buf [lastind + topline];
#else /* !KTERM */
X chars = screen->buf [2 * (lastind + topline)];
X attrs = screen->buf [2 * (lastind + topline) + 1];
#endif /* !KTERM */
X
X if (row < screen->startHRow || row > screen->endHRow ||
X (row == screen->startHRow && maxcol < screen->startHCol) ||
X (row == screen->endHRow && col >= screen->endHCol))
X {
X /* row does not intersect selection; don't hilite */
X if (!force) {
#ifdef KTERM
X while (col <= maxcol && (chars[col].attr & ~BOLD) == 0 &&
X !(chars[col].gset & CS96) &&
X (chars[col].code & ~040) == 0)
#else /* !KTERM */
X while (col <= maxcol && (attrs[col] & ~BOLD) == 0 &&
X (chars[col] & ~040) == 0)
#endif /* !KTERM */
X col++;
X
#ifdef KTERM
X while (col <= maxcol && (chars[maxcol].attr & ~BOLD) == 0 &&
X !(chars[maxcol].gset & CS96) &&
X (chars[maxcol].code & ~040) == 0)
#else /* !KTERM */
X while (col <= maxcol && (attrs[maxcol] & ~BOLD) == 0 &&
X (chars[maxcol] & ~040) == 0)
#endif /* !KTERM */
X maxcol--;
X }
X hilite = False;
X }
X else {
X /* row intersects selection; split into pieces of single type */
X if (row == screen->startHRow && col < screen->startHCol) {
X ScrnRefresh(screen, row, col, 1, screen->startHCol - col,
X force);
X col = screen->startHCol;
X }
X if (row == screen->endHRow && maxcol >= screen->endHCol) {
X ScrnRefresh(screen, row, screen->endHCol, 1,
X maxcol - screen->endHCol + 1, force);
X maxcol = screen->endHCol - 1;
X }
X /* remaining piece should be hilited */
X hilite = True;
X }
#ifdef KTERM_KANJI
X if (chars[col].gset == MBC2 && col != 0)
X col--;
X if (chars[maxcol].gset & MBCS && chars[maxcol].gset != MBC2)
X maxcol++;
#endif /* KTERM_KANJI */
X
X if (col > maxcol) continue;
X
#ifdef KTERM
X flags = chars[col].attr;
X gset = chars[col].gset;
#else /* !KTERM */
X flags = attrs[col];
X
#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;
#endif /* !KTERM */
X
X x = CursorX(screen, col);
X lastind = col;
X
X for (; col <= maxcol; col++) {
#ifdef KTERM
X if (chars[col].attr != flags || chars[col].gset != gset) {
#ifdef COLOR_TEXT /* mukawa */
X ScreenDraw(screen, x, y, dbuf, n, gset, flags,
#else /* COLOR_TEXT */
X ScreenDraw(screen, x, y, dbuf, n, gset,
#endif /* COLOR_TEXT */
X flags & BOLD,
#ifdef STATUSLINE
X (dostatus < 0 && screen->reversestatus) ^
#endif /* STATUSLINE */
X (hilite != 0) ^ ((flags & INVERSE) != 0),
X flags & UNDERLINE,
X False);
X n = 0;
#else /* !KTERM */
X if (attrs[col] != flags) {
X XDrawImageString(screen->display, TextWindow(screen),
X gc, x, y, (char *) &chars[lastind], n = col - lastind);
X if((flags & BOLD) && screen->enbolden)
X XDrawString(screen->display, TextWindow(screen),
X gc, x + 1, y, (char *) &chars[lastind], n);
X if(flags & UNDERLINE)
X XDrawLine(screen->display, TextWindow(screen),
X gc, x, y+1, x+n*FontWidth(screen), y+1);
#endif /* !KTERM */
X
X x += (col - lastind) * FontWidth(screen);
X
X lastind = col;
X
#ifdef KTERM
X flags = chars[col].attr;
X gset = chars[col].gset;
X }
#else /* !KTERM */
X flags = attrs[col];
X
#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 }
#endif /* !KTERM */
X
#ifdef KTERM
X /*
X * subeteno moji wo, XChar2b string ni copy suru.
X * konotoki MSB ga tattetara, gset wo shirabete
X * tekitouna code ni henkansuru.
X */
#ifdef KTERM_KANJI
X if (gset & MBCS) {
X dbuf[n].byte1 = chars[col++].code;
X dbuf[n].byte2 = chars[col].code;
X } else
#endif /* KTERM_KANJI */
X {
X dbuf[n].byte1 = 0;
X dbuf[n].byte2 = MapOnFont(gset, chars[col].code);
X }
X n++;
#else /* !KTERM */
X if(chars[col] == 0)
X chars[col] = ' ';
#endif /* !KTERM */
X }
X
X
#ifdef KTERM
#ifdef COLOR_TEXT /* mukawa */
X ScreenDraw(screen, x, y, dbuf, n, gset, flags,
#else /* COLOR_TEXT */
X ScreenDraw(screen, x, y, dbuf, n, gset,
#endif /* COLOR_TEXT */
X flags & BOLD,
#ifdef STATUSLINE
X (dostatus < 0 && screen->reversestatus) ^
SHAR_EOF
true || echo 'restore of kterm-4.1.2/screen.c failed'
fi
echo 'End of kterm-4.1.2 part 16'
echo 'File kterm-4.1.2/screen.c is continued in part 17'
echo 17 > _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