home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
x
/
volume12
/
kterm
/
part06
< prev
next >
Wrap
Text File
|
1991-05-08
|
52KB
|
1,711 lines
Path: uunet!cs.utexas.edu!convex!central!newstop!male!jethro!exodus!NMSU.Edu!mleisher
From: mleisher@NMSU.Edu
Newsgroups: comp.sources.x
Subject: v12i087: kterm - kanji xterm, Part06/18
Message-ID: <12971@exodus.Eng.Sun.COM>
Date: 8 May 91 02:38:58 GMT
References: <csx-12i082:kterm@uunet.UU.NET>
Sender: news@exodus.Eng.Sun.COM
Lines: 1699
Approved: argv@sun.com
Submitted-by: mleisher@NMSU.Edu
Posting-number: Volume 12, Issue 87
Archive-name: kterm/part06
#!/bin/sh
# this is kt412.06 (part 6 of kterm-4.1.2)
# do not concatenate these parts, unpack them in order with /bin/sh
# file kterm-4.1.2/button.c continued
#
if test ! -r _shar_seq_.tmp; then
echo 'Please unpack part 1 first!'
exit 1
fi
(read Scheck
if test "$Scheck" != 6; 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/button.c'
else
echo 'x - continuing file kterm-4.1.2/button.c'
sed 's/^X//' << 'SHAR_EOF' >> 'kterm-4.1.2/button.c' &&
/* h i j k l m n o */
X 48, 48, 48, 48, 48, 48, 48, 48,
/* p q r s t u v w */
X 48, 48, 48, 48, 48, 48, 48, 48,
/* x y z { | } ~ DEL */
X 48, 48, 48, 123, 124, 125, 126, 1};
X
X
int SetCharacterClassRange (low, high, value)
X register int low, high; /* in range of [0..127] */
X register int value; /* arbitrary */
{
X
X if (low < 0 || high > 127 || high < low) return (-1);
X
X for (; low <= high; low++) charClass[low] = value;
X
X return (0);
}
X
X
ComputeSelect(startRow, startCol, endRow, endCol, extend)
int startRow, startCol, endRow, endCol;
Bool extend;
{
X register TScreen *screen = &term->screen;
#ifdef KTERM
X register Bchr *ptr;
X Char gset;
#else /* !KTERM */
X register Char *ptr;
#endif /* !KTERM */
X register int length;
X register int class;
X int osc = startSCol;
X
X if (Coordinate(startRow, startCol) <= Coordinate(endRow, endCol)) {
X startSRow = startRRow = startRow;
X startSCol = startRCol = startCol;
X endSRow = endRRow = endRow;
X endSCol = endRCol = endCol;
X } else { /* Swap them */
X startSRow = startRRow = endRow;
X startSCol = startRCol = endCol;
X endSRow = endRRow = startRow;
X endSCol = endRCol = startCol;
X }
X
X switch (selectUnit) {
X case SELECTCHAR :
X if (startSCol > (LastTextCol(startSRow) + 1)) {
X startSCol = 0;
X startSRow++;
X }
X if (endSCol > (LastTextCol(endSRow) + 1)) {
X endSCol = 0;
X endSRow++;
X }
X break;
X case SELECTWORD :
X if (startSCol > (LastTextCol(startSRow) + 1)) {
X startSCol = 0;
X startSRow++;
X } else {
#ifdef KTERM
X ptr = screen->buf[startSRow+screen->topline]
X + startSCol;
#ifdef MB_WSEL
X if (ptr->gset == MBC2)
X { /* 2nd byte of a mbcs character */
X startSCol--;
X ptr--;
X }
X if (ptr->gset != MBC2 && (ptr->gset & MBCS) != 0)
X { /* 1st byte of a mbcs character */
X class = mbcsCharClass (ptr);
X do
X {
X startSCol -= 2;
X ptr -= 2;
X } while (startSCol >= 0
X && ptr->gset != MBC2 && (ptr->gset & MBCS) != 0
X && class == mbcsCharClass (ptr));
X startSCol++;
X ptr++;
X }
X else if (ptr->gset == GSET_KANA)
X do
X {
X --startSCol;
X --ptr;
X } while (startSCol >= 0
X && ptr->gset == GSET_KANA);
X else
X {
X gset = ptr->gset;
X class = charClass[ptr->code];
X do {
X --startSCol;
X --ptr;
X } while (startSCol >= 0
X && ptr->gset == gset
X && charClass[ptr->code] == class);
X }
#else /* !MB_WSEL */
X class = charClass[ptr->code];
X do {
X --startSCol;
X --ptr;
X } while (startSCol >= 0
X && charClass[ptr->code] == class);
#endif /* !MB_WSEL */
#else /* !KTERM */
X ptr = screen->buf[2*(startSRow+screen->topline)]
X + startSCol;
X class = charClass[*ptr];
X do {
X --startSCol;
X --ptr;
X } while (startSCol >= 0
X && charClass[*ptr] == class);
#endif /* !KTERM */
X ++startSCol;
X }
X if (endSCol > (LastTextCol(endSRow) + 1)) {
X endSCol = 0;
X endSRow++;
X } else {
X length = LastTextCol(endSRow);
#ifdef KTERM
X ptr = screen->buf[endSRow+screen->topline]
X + endSCol;
#ifdef MB_WSEL
X if (ptr->gset == MBC2)
X { /* 2nd byte of a mbcs character */
X endSCol--;
X ptr--;
X }
X if (ptr->gset != MBC2 && (ptr->gset & MBCS) != 0)
X { /* 1st byte of a mbcs character */
X class = mbcsCharClass (ptr);
X do
X {
X endSCol += 2;
X ptr += 2;
X } while (endSCol < length
X && ptr->gset != MBC2 && (ptr->gset & MBCS) != 0
X && class == mbcsCharClass (ptr));
X }
X else if (ptr->gset == GSET_KANA)
X do
X {
X ++endSCol;
X ++ptr;
X } while (endSCol <= length
X && ptr->gset == GSET_KANA);
X else
X {
X gset = ptr->gset;
X class = charClass[ptr->code];
X do {
X ++endSCol;
X ++ptr;
X } while (endSCol <= length
X && ptr->gset == gset
X && charClass[ptr->code] == class);
X }
#else /* !MB_WSEL */
X class = charClass[ptr->code];
X do {
X ++endSCol;
X ++ptr;
X } while (endSCol <= length
X && charClass[ptr->code] == class);
#endif /* !MB_WSEL */
#else /* !KTERM */
X ptr = screen->buf[2*(endSRow+screen->topline)]
X + endSCol;
X class = charClass[*ptr];
X do {
X ++endSCol;
X ++ptr;
X } while (endSCol <= length
X && charClass[*ptr] == class);
#endif /* !KTERM */
X /* Word select selects if pointing to any char
X in "word", especially in that it includes
X the last character in a word. So no --endSCol
X and do special eol handling */
X if (endSCol > length+1) {
X endSCol = 0;
X ++endSRow;
X }
X }
X break;
X case SELECTLINE :
X if (term->screen.cutToBeginningOfLine) {
X startSCol = 0;
X } else if (!extend) {
X startSCol = osc;
X }
X if (term->screen.cutNewline) {
X endSCol = 0;
X ++endSRow;
X } else {
X endSCol = LastTextCol(endSRow) + 1;
X }
X break;
X }
X
X TrackText(startSRow, startSCol, endSRow, endSCol);
X return;
}
X
#if defined(KTERM) && defined(MB_WSEL)
/*
X * by Kiyoshi KANAZAWA, Nov. 29, 1990.
X *
X * Modified by Mark Leisher Sun Mar 17 00:09:18 1991
X * Added support for Chinese and Korean text.
X *
X * A MBCS is divided into DIGITS, LETTERS, HIRAGANA, KATAKANA, BOPOMOFO,
X * GREEK, RUSSIAN, DRAWING, CHAR, BOPOMOFO, HANGUL, HANJA, HANZI, JAMOS,
X * KANA, and KANJI classes for Chinese, Japanese, and Korean character
X * sets.
X * Many of these distinctions are not currently necessary, but are here
X * for future expansion of selection capabilities for MBCS text.
X *
X * The CHAR class is what most of the Kanji, Hanzi, Hangul, and Hanja fall
X * in.
X *
X * DIGITS and LETTERS are considered to be in the same character class and
X * consist of 0-9, A-Z, and a-z in a MBCS.
X *
X * HIRAGANA and KATAKANA are considered to be in the same class as KANJI.
X * In any other MBCS, they are considered to be of the KANA class.
X *
X * GREEK and RUSSIAN are considered separate character classes in a MBCS.
X *
X * DRAWING is a separate class that consists of the line drawing sections
X * of a MBCS.
X *
X * BOPOMOFO (ZhuYinFuHao) is considered a separate character class in a
X * Chinese MBCS.
X *
X * HANGUL, HANJA, HANZI, JAMOS, and KANJI are considered to have the same
X * character class.
X *
X * All other code points in a MBCS are considered to be individual
X * character classes.
X */
X
#define MBCS_DIGITS 0
#define MBCS_LETTERS MBCS_DIGITS
#define MBCS_GREEK (MBCS_DIGITS + 1)
#define MBCS_RUSSIAN (MBCS_GREEK + 1)
#define MBCS_DRAWING (MBCS_RUSSIAN + 1)
#define MBCS_BOPOMOFO (MBCS_DRAWING + 1)
#define MBCS_KANA (MBCS_BOPOMOFO + 1)
#define MBCS_CHAR (MBCS_KANA + 1)
#define MBCS_HANGUL MBCS_CHAR
#define MBCS_HANJA MBCS_CHAR
#define MBCS_HANZI MBCS_CHAR
#define MBCS_JAMOS MBCS_CHAR
#define MBCS_KANJI MBCS_CHAR
#define MBCS_HIRAGANA MBCS_CHAR
#define MBCS_KATAKANA MBCS_CHAR
X
/*
X * Character classes in a Big5 Chinese character set.
X */
static int
BCMbcsCharClass(c1, c2)
unsigned char c1, c2;
{
X switch (c1) {
X case 0xa2:
X if (0xaf <= c2 && c2 <= 0xb8)
X return(MBCS_DIGITS);
X if (0xcf <= c2 && c2 <= 0xfe)
X return(MBCS_LETTERS);
X break;
X case 0xa3:
X if (0x40 <= c2 && c2 <= 0x43)
X return(MBCS_LETTERS);
X if (0x44 <= c2 && c2 <= 0x73)
X return(MBCS_GREEK);
X if (0xa6 <= c2 && c2 <= 0xba)
X return(MBCS_BOPOMOFO);
X break;
X default:
X if (0xa4 <= c1 && c1 <= 0xf9 && (0x40 <= c2 && c2 <= 0xfe))
X return(MBCS_HANZI);
X break;
X }
X return((c1 << 8) | c2);
}
X
/*
X * Character classes in a GB 2312 character set.
X */
static int
GCMbcsCharClass(c1, c2)
unsigned char c1, c2;
{
X switch (c1) {
X case 0xa3:
X if (0xb0 <= c2 && c2 <= 0xb9)
X return(MBCS_DIGITS);
X if ((0xc1 <= c2 && c2 <= 0xda) || (0xe1 <= c2 && c2 <= 0xfa))
X return(MBCS_LETTERS);
X break;
X case 0xa4:
X if (0xa1 <= c2 && c2 <= 0xf3)
X /* HIRAGANA plane in the GB 2312 set */
X return(MBCS_KANA);
X break;
X case 0xa5:
X if (0xa1 <= c2 && c2 <= 0xf6)
X /* KATAKANA plane in the GB 2312 set */
X return(MBCS_KANA);
X break;
X case 0xa6:
X if ((0xa1 <= c2 && c2 <= 0xb8) || (0xc1 <= c2 && c2 <= 0xd8))
X return(MBCS_GREEK);
X break;
X case 0xa7:
X if ((0xa1 <= c2 && c2 <= 0xc1) || (0xd1 <= c2 && c2 <= 0xf1))
X return(MBCS_RUSSIAN);
X break;
X case 0xa8:
X if (0xc5 <= c2 && c2 <= 0xe9)
X return(MBCS_BOPOMOFO);
X break;
X case 0xa9:
X if (0xa4 <= c2 && c2 <= 0xef)
X return(MBCS_DRAWING);
X break;
X default:
X if (0xb0 <= c1 && c1 <= 0xfe && (0xa1 <= c2 && c2 <= 0xfe))
X return(MBCS_HANZI);
X break;
X }
X return((c1 << 8) | c2);
}
X
/*
X * Character classes in a JIS X0208 character set.
X */
static int
JMbcsCharClass(c1, c2)
unsigned char c1, c2;
{
X switch (c1) {
X case 0x21:
X switch (c2) {
X case 0x38:
X case 0x39:
X case 0x3a:
X return (MBCS_KANJI);
X case 0x3c:
X return (MBCS_KATAKANA);
X }
X break;
X case 0x23:
X if (0x30 <= c2 && c2 <= 0x39)
X return (MBCS_DIGITS);
X if (0x41 <= c2 && c2 <= 0x5a || 0x61 <= c2 && c2 <= 0x7a)
X return (MBCS_LETTERS);
X break;
X case 0x24:
X if (0x21 <= c2 && c2 <= 0x73)
X return (MBCS_HIRAGANA);
X break;
X case 0x25:
X if (0x21 <= c2 && c2 <= 0x76)
X return (MBCS_KATAKANA);
X break;
X case 0x26:
X if (0x21 <= c2 && c2 <= 0x38 || 0x41 <= c2 && c2 <= 0x58)
X return (MBCS_GREEK);
X break;
X case 0x27:
X if (0x21 <= c2 && c2 <= 0x41 || 0x51 <= c2 && c2 <= 0x71)
X return (MBCS_RUSSIAN);
X break;
X case 0x28:
X if (0x21 <= c2 && c2 <= 0x40)
X return (MBCS_DRAWING);
X break;
X default:
X if (0x30 <= c1 && c1 <= 0x4e && 0x21 <= c2 && c2 <= 0x7e
X || c1 == 0x4f && (0x21 <= c2 || c2 <= 0x53)) /* dai_1_suijun */
X return (MBCS_KANJI);
X if (0x50 <= c1 && c1 <= 0x73 && 0x21 <= c2 && c2 <= 0x7e
X || c1 == 0x74 && (0x21 <= c2 || c2 <= 0x24)) /* dai_2_suijun */
X return (MBCS_KANJI);
X break;
X }
X return ((c1 << 8) | c2); /* return mbcs code */
}
X
/*
X * Character classes in a KS C5601 character set.
X */
static int
KMbcsCharClass(c1, c2)
unsigned char c1, c2;
{
X switch (c1) {
X case 0x23:
X if (0x39 <= c2 && c2 <= 0x3f)
X return (MBCS_DIGITS);
X if (0x41 <= c2 && c2 <= 0x5a || 0x61 <= c2 && c2 <= 0x7a)
X return (MBCS_LETTERS);
X break;
X case 0x24:
X if (0x21 <= c2 && c2 <= 0x7e)
X return (MBCS_JAMOS);
X break;
X case 0x25:
X if (0x41 <= c2 && c2 <= 0x58 || 0x61 <= c2 && c2 <= 0x78)
X return (MBCS_GREEK);
X break;
X case 0x26:
X if (0x21 <= c2 && c2 <= 0x64)
X return (MBCS_DRAWING);
X break;
X case 0x2a:
X if (0x21 <= c2 && c2 <= 0x73)
X /* HIRAGANA plane in KS C5601 set */
X return (MBCS_KANA);
X break;
X case 0x2b:
X if (0x21 <= c2 && c2 <= 0x76)
X /* KATAKANA plane in KS C5601 set */
X return (MBCS_KANA);
X break;
X case 0x2c:
X if (0x21 <= c2 && c2 <= 0x41 || 0x51 <= c2 && c2 <= 0x71)
X return (MBCS_RUSSIAN);
X break;
X default:
X if (0x30 <= c1 && c1 <= 0x48 && 0x21 <= c2 && c2 <= 0x7e)
X return (MBCS_HANGUL);
X if (0x4a <= c1 && c1 <= 0x7d && 0x21 <= c2 && c2 <= 0x7e)
X return (MBCS_HANJA);
X break;
X }
X return ((c1 << 8) | c2); /* return mbcs code */
}
X
static int
mbcsCharClass (ptr)
register Bchr *ptr;
{
X register unsigned char c1, c2;
X register int fntype;
X
X c1 = ptr->code;
X c2 = (ptr + 1)->code;
X fntype = FontType(&term->screen, FNUM(ptr->gset), 0);
X
X switch(ptr->gset) {
X case GSET_HANGUL:
X c1 &= ~NEEDMAP;
X c2 &= ~NEEDMAP;
X return(KMbcsCharClass(c1, c2));
X break;
X case GSET_HANZI:
X /*
X * MIXED most likely means Big5 font in use.
X * If this is the case, the screen buffer holds Big5 MB text.
X */
X if (fntype == MIXED)
X return(BCMbcsCharClass(c1, c2));
X c1 |= NEEDMAP;
X c2 |= NEEDMAP;
X return(GCMbcsCharClass(c1, c2));
X break;
X case GSET_KANJI:
X c1 &= ~NEEDMAP;
X c2 &= ~NEEDMAP;
X return(JMbcsCharClass(c1, c2));
X break;
X }
X return((c1 << 8) | c2);
}
X
#endif /* KTERM && MBCS_WSEL */
X
TrackText(frow, fcol, trow, tcol)
register int frow, fcol, trow, tcol;
/* Guaranteed (frow, fcol) <= (trow, tcol) */
{
X register int from, to;
X register TScreen *screen = &term->screen;
X int old_startrow, old_startcol, old_endrow, old_endcol;
X
X /* (frow, fcol) may have been scrolled off top of display */
X if (frow < 0)
X frow = fcol = 0;
X /* (trow, tcol) may have been scrolled off bottom of display */
X if (trow > screen->max_row+1) {
X trow = screen->max_row+1;
X tcol = 0;
X }
X old_startrow = screen->startHRow;
X old_startcol = screen->startHCol;
X old_endrow = screen->endHRow;
X old_endcol = screen->endHCol;
X if (frow == old_startrow && fcol == old_startcol &&
X trow == old_endrow && tcol == old_endcol) return;
X screen->startHRow = frow;
X screen->startHCol = fcol;
X screen->endHRow = trow;
X screen->endHCol = tcol;
X from = Coordinate(frow, fcol);
X to = Coordinate(trow, tcol);
X if (to <= screen->startHCoord || from > screen->endHCoord) {
X /* No overlap whatsoever between old and new hilite */
X ReHiliteText(old_startrow, old_startcol, old_endrow, old_endcol);
X ReHiliteText(frow, fcol, trow, tcol);
X } else {
X if (from < screen->startHCoord) {
X /* Extend left end */
X ReHiliteText(frow, fcol, old_startrow, old_startcol);
X } else if (from > screen->startHCoord) {
X /* Shorten left end */
X ReHiliteText(old_startrow, old_startcol, frow, fcol);
X }
X if (to > screen->endHCoord) {
X /* Extend right end */
X ReHiliteText(old_endrow, old_endcol, trow, tcol);
X } else if (to < screen->endHCoord) {
X /* Shorten right end */
X ReHiliteText(trow, tcol, old_endrow, old_endcol);
X }
X }
X screen->startHCoord = from;
X screen->endHCoord = to;
}
X
ReHiliteText(frow, fcol, trow, tcol)
register int frow, fcol, trow, tcol;
/* Guaranteed that (frow, fcol) <= (trow, tcol) */
{
X register TScreen *screen = &term->screen;
X register int i;
X
X if (frow < 0)
X frow = fcol = 0;
X else if (frow > screen->max_row)
X return; /* nothing to do, since trow >= frow */
X
X if (trow < 0)
X return; /* nothing to do, since frow <= trow */
X else if (trow > screen->max_row) {
X trow = screen->max_row;
X tcol = screen->max_col+1;
X }
X if (frow == trow && fcol == tcol)
X return;
X
X if(frow != trow) { /* do multiple rows */
X if((i = screen->max_col - fcol + 1) > 0) { /* first row */
X ScrnRefresh(screen, frow, fcol, 1, i, True);
X }
X if((i = trow - frow - 1) > 0) { /* middle rows*/
X ScrnRefresh(screen, frow+1, 0,i, screen->max_col+1, True);
X }
X if(tcol > 0 && trow <= screen->max_row) { /* last row */
X ScrnRefresh(screen, trow, 0, 1, tcol, True);
X }
X } else { /* do single row */
X ScrnRefresh(screen, frow, fcol, 1, tcol - fcol, True);
X }
}
X
SaltTextAway(crow, ccol, row, col, params, num_params)
/*register*/ int crow, ccol, row, col;
String *params; /* selections */
Cardinal num_params;
/* Guaranteed that (crow, ccol) <= (row, col), and that both points are valid
X (may have row = screen->max_row+1, col = 0) */
{
X register TScreen *screen = &term->screen;
X register int i, j = 0;
#ifdef KTERM
X Ichr *line, *lp;
X Bchr *ch = screen->buf[row + screen->topline];
#else /* !KTERM */
X char *line, *lp;
#endif /* !KTERM */
X static _OwnSelection();
X
X if (crow == row && ccol > col) {
X int tmp = ccol;
X ccol = col;
X col = tmp;
X }
X
X --col;
X /* first we need to know how long the string is before we can save it*/
X
#ifdef KTERM
X if (ch[ccol].gset == MBC2)
X ccol--;
X if (ch[col].gset & MBCS && ch[col].gset != MBC2) /* MBC1 */
X col++;
#endif /* !KTERM */
X if ( row == crow ) j = Length(screen, crow, ccol, col);
X else { /* two cases, cut is on same line, cut spans multiple lines */
X j += Length(screen, crow, ccol, screen->max_col) + 1;
X for(i = crow + 1; i < row; i++)
X j += Length(screen, i, 0, screen->max_col) + 1;
X if (col >= 0)
X j += Length(screen, row, 0, col);
X }
X
X /* now get some memory to save it in */
X
X if (screen->selection_size <= j) {
#ifdef KTERM
X if((line = (Ichr *)malloc((unsigned)((j + 1) * sizeof(Ichr)))) == (Ichr *)NULL)
#else /* !KTERM */
X if((line = malloc((unsigned) j + 1)) == (char *)NULL)
#endif /* !KTERM */
X SysError(ERROR_BMALLOC2);
X XtFree(screen->selection);
X screen->selection = line;
X screen->selection_size = j + 1;
X } else line = screen->selection;
X if (!line || j < 0) return;
X
#ifdef KTERM
X line[j].code = '\0'; /* make sure it is null terminated */
X line[j].gset = 0;
#else /* !KTERM */
X line[j] = '\0'; /* make sure it is null terminated */
#endif /* !KTERM */
X lp = line; /* lp points to where to save the text */
X if ( row == crow ) lp = SaveText(screen, row, ccol, col, lp);
X else {
X lp = SaveText(screen, crow, ccol, screen->max_col, lp);
X
X for(i = crow +1; i < row; i++)
X /*
X * If any real EOL's occur in the text, SaveText takes care
X * of inserting them into the saved line.
X * TAB's are also preserved in SaveText.
X */
X lp = SaveText(screen, i, 0, screen->max_col, lp);
X
X if (col >= 0)
X lp = SaveText(screen, row, 0, col, lp);
X }
#ifdef KTERM
X lp->code = '\0'; /* make sure we have end marked */
X lp->gset = 0;
#else /* !KTERM */
X *lp = '\0'; /* make sure we have end marked */
#endif /* !KTERM */
X
#ifdef KTERM
X /*
X * (lp - line) should be used to express the length of the converted
X * Kanji string. j is only its original length.
X */
X screen->selection_length = lp - line;
#else /* !KTERM */
X screen->selection_length = j;
#endif /* !KTERM */
X _OwnSelection(term, params, num_params);
}
X
#ifdef KTERM_HANZI
/*
X * Changed function name from convNonStandardHanziToGB to simplify.
X * Version 4.1.1->4.1.2
X */
extern Ichr *convNSHzToGB();
#endif /* KTERM_HANZI */
X
static Boolean ConvertSelection(w, selection, target,
X type, value, length, format)
Widget w;
Atom *selection, *target, *type;
caddr_t *value;
unsigned long *length;
int *format;
{
X Display* d = XtDisplay(w);
X XtermWidget xterm = (XtermWidget)w;
#ifdef KTERM_HANZI
X Ichr *tmp_selection;
#endif /* KTERM_HANZI */
X
X if (xterm->screen.selection == NULL) return False; /* can this happen? */
X
X if (*target == XA_TARGETS(d)) {
X Atom* targetP;
X Atom* std_targets;
X unsigned long std_length;
X XmuConvertStandardSelection(
X w, xterm->screen.selection_time, selection,
X target, type, (caddr_t*)&std_targets, &std_length, format
X );
X *length = std_length + 5;
X *value = (caddr_t)XtMalloc(sizeof(Atom)*(*length));
X targetP = *(Atom**)value;
X *targetP++ = XA_STRING;
X *targetP++ = XA_TEXT(d);
X *targetP++ = XA_COMPOUND_TEXT(d);
X *targetP++ = XA_LENGTH(d);
X *targetP++ = XA_LIST_LENGTH(d);
X bcopy((char*)std_targets, (char*)targetP, sizeof(Atom)*std_length);
X XtFree((char*)std_targets);
X *type = XA_ATOM;
X *format = 32;
X return True;
X }
X
X if (*target == XA_STRING ||
X *target == XA_TEXT(d) ||
X *target == XA_COMPOUND_TEXT(d)) {
#ifdef KTERM
X if (*target == XA_COMPOUND_TEXT(d) || *target == XA_TEXT(d)) {
X *type = XA_COMPOUND_TEXT(d);
#ifdef KTERM_HANZI
X if (xterm->flags & BIG5_HANZI)
X tmp_selection =
X convNSHzToGB(xterm->screen.selection, BIGtoGB);
X if (xterm->flags & BIG5_HANZI)
X *length = convCStoCT(tmp_selection, NULL);
X else
#endif /* KTERM_HANZI */
X *length = convCStoCT(xterm->screen.selection, NULL);
X *value = (caddr_t)XtMalloc(*length + 1);
#ifdef KTERM_HANZI
X if (xterm->flags & BIG5_HANZI)
X (void)convCStoCT(tmp_selection, (Char *)*value);
X else
#endif /* KTERM_HANZI */
X (void)convCStoCT(xterm->screen.selection, (Char *)*value);
X } else {
X *type = XA_STRING;
X *length = convCStoLatin1(xterm->screen.selection, NULL);
X *value = (caddr_t)XtMalloc(*length + 1);
X (void)convCStoLatin1(xterm->screen.selection, (Char *)*value);
X }
#else /* !KTERM */
X if (*target == XA_COMPOUND_TEXT(d))
X *type = *target;
X else
X *type = XA_STRING;
X *value = xterm->screen.selection;
X *length = xterm->screen.selection_length;
#endif /* !KTERM */
X *format = 8;
X return True;
X }
X if (*target == XA_LIST_LENGTH(d)) {
X *value = XtMalloc(4);
X if (sizeof(long) == 4)
X *(long*)*value = 1;
X else {
X long temp = 1;
X bcopy( ((char*)&temp)+sizeof(long)-4, (char*)*value, 4);
X }
X *type = XA_INTEGER;
X *length = 1;
X *format = 32;
X return True;
X }
X if (*target == XA_LENGTH(d)) {
X *value = XtMalloc(4);
X if (sizeof(long) == 4)
#ifdef KTERM
X *(long*)*value = convCStoCT(xterm->screen.selection, NULL);
#else /* !KTERM */
X *(long*)*value = xterm->screen.selection_length;
#endif /* !KTERM */
X else {
#ifdef KTERM
X long temp = convCStoCT(xterm->screen.selection, NULL);
#else /* !KTERM */
X long temp = xterm->screen.selection_length;
#endif /* !KTERM */
X bcopy( ((char*)&temp)+sizeof(long)-4, (char*)*value, 4);
X }
X *type = XA_INTEGER;
X *length = 1;
X *format = 32;
X return True;
X }
X if (XmuConvertStandardSelection(w, xterm->screen.selection_time, selection,
X target, type, value, length, format))
X return True;
X
X /* else */
X return False;
X
}
X
X
static void LoseSelection(w, selection)
X Widget w;
X Atom *selection;
{
X register TScreen* screen = &((XtermWidget)w)->screen;
X register Atom* atomP;
X int i;
X for (i = 0, atomP = screen->selection_atoms;
X i < screen->selection_count; i++, atomP++)
X {
X if (*selection == *atomP) *atomP = (Atom)0;
X switch (*atomP) {
X case XA_CUT_BUFFER0:
X case XA_CUT_BUFFER1:
X case XA_CUT_BUFFER2:
X case XA_CUT_BUFFER3:
X case XA_CUT_BUFFER4:
X case XA_CUT_BUFFER5:
X case XA_CUT_BUFFER6:
X case XA_CUT_BUFFER7: *atomP = (Atom)0;
X }
X }
X
X for (i = screen->selection_count; i; i--) {
X if (screen->selection_atoms[i-1] != 0) break;
X }
X screen->selection_count = i;
X
X for (i = 0, atomP = screen->selection_atoms;
X i < screen->selection_count; i++, atomP++)
X {
X if (*atomP == (Atom)0) {
X *atomP = screen->selection_atoms[--screen->selection_count];
X }
X }
X
X if (screen->selection_count == 0)
X TrackText(0, 0, 0, 0);
}
X
X
#ifndef KTERM
/* ARGSUSED */
static void SelectionDone(w, selection, target)
Widget w;
Atom *selection, *target;
{
X /* empty proc so Intrinsics know we want to keep storage */
}
#endif /* !KTERM */
X
X
static /* void */ _OwnSelection(term, selections, count)
register XtermWidget term;
String *selections;
Cardinal count;
{
X Atom* atoms = term->screen.selection_atoms;
X int i;
X Boolean have_selection = False;
X
X if (term->screen.selection_length < 0) return;
X
X if (count > term->screen.sel_atoms_size) {
X XtFree((char*)atoms);
X atoms = (Atom*)XtMalloc(count*sizeof(Atom));
X term->screen.selection_atoms = atoms;
X term->screen.sel_atoms_size = count;
X }
X XmuInternStrings( XtDisplay((Widget)term), selections, count, atoms );
X for (i = 0; i < count; i++) {
X int buffer;
X switch (atoms[i]) {
X case XA_CUT_BUFFER0: buffer = 0; break;
X case XA_CUT_BUFFER1: buffer = 1; break;
X case XA_CUT_BUFFER2: buffer = 2; break;
X case XA_CUT_BUFFER3: buffer = 3; break;
X case XA_CUT_BUFFER4: buffer = 4; break;
X case XA_CUT_BUFFER5: buffer = 5; break;
X case XA_CUT_BUFFER6: buffer = 6; break;
X case XA_CUT_BUFFER7: buffer = 7; break;
X default: buffer = -1;
X }
X if (buffer >= 0)
#ifdef KTERM
X {
X /* Since type of a CUT_BUFFER is STRING, KANJI and KANA
X * characters can't be stored in a CUT_BUFFER
X */
X int nw;
X int nc = 0;
X Ichr *p;
X char *s, *q;
X p = term->screen.selection;
X for (nw = term->screen.selection_length; nw > 0; nw--, p++) {
X if (p->gset == GSET_ASCII)
X nc++;
X }
X if (nc > 0) {
X char buf[256];
X p = term->screen.selection;
X s = q = (nc > 256) ? XtMalloc(nc) : buf;
X for (nw = term->screen.selection_length; nw > 0; nw--, p++) {
X if (p->gset == GSET_ASCII)
X *q++ = p->code & 0x7f;
X }
X XStoreBuffer( XtDisplay((Widget)term), s, nc, buffer);
X if (s != buf) XtFree(s);
X } else
X XStoreBuffer( XtDisplay((Widget)term), NULL, nc, buffer);
X }
#else /* !KTERM */
X XStoreBuffer( XtDisplay((Widget)term), term->screen.selection,
X term->screen.selection_length, buffer );
#endif /* !KTERM */
X else if (!replyToEmacs) {
X have_selection |=
X XtOwnSelection( (Widget)term, atoms[i],
X term->screen.selection_time,
#ifdef KTERM
X ConvertSelection, LoseSelection, NULL );
#else /* !KTERM */
X ConvertSelection, LoseSelection, SelectionDone );
#endif /* !KTERM */
X }
X }
X if (!replyToEmacs)
X term->screen.selection_count = count;
X if (!have_selection)
X TrackText(0, 0, 0, 0);
}
X
/* void */ DisownSelection(term)
register XtermWidget term;
{
X Atom* atoms = term->screen.selection_atoms;
X Cardinal count = term->screen.selection_count;
X int i;
X
X for (i = 0; i < count; i++) {
X int buffer;
X switch (atoms[i]) {
X case XA_CUT_BUFFER0: buffer = 0; break;
X case XA_CUT_BUFFER1: buffer = 1; break;
X case XA_CUT_BUFFER2: buffer = 2; break;
X case XA_CUT_BUFFER3: buffer = 3; break;
X case XA_CUT_BUFFER4: buffer = 4; break;
X case XA_CUT_BUFFER5: buffer = 5; break;
X case XA_CUT_BUFFER6: buffer = 6; break;
X case XA_CUT_BUFFER7: buffer = 7; break;
X default: buffer = -1;
X }
X if (buffer < 0)
X XtDisownSelection( (Widget)term, atoms[i],
X term->screen.selection_time );
X }
X term->screen.selection_count = 0;
X term->screen.startHRow = term->screen.startHCol = 0;
X term->screen.endHRow = term->screen.endHCol = 0;
}
X
X
/* returns number of chars in line from scol to ecol out */
int Length(screen, row, scol, ecol)
register int row, scol, ecol;
register TScreen *screen;
{
#ifdef KTERM
X register Bchr *ch;
X
X ch = screen->buf[row + screen->topline];
X while (ecol >= scol && (ch[ecol].code == ' ' || ch[ecol].code == 0))
X
#else /* !KTERM */
X register Char *ch;
X
X ch = screen->buf[2 * (row + screen->topline)];
X while (ecol >= scol && (ch[ecol] == ' ' || ch[ecol] == 0))
#endif /* !KTERM */
X ecol--;
X return (ecol - scol + 1);
}
X
/* copies text into line, preallocated */
#ifdef KTERM
Ichr *SaveText(screen, row, scol, ecol, lp)
int row;
int scol, ecol;
TScreen *screen;
register Ichr *lp; /* pointer to where to put the text */
#else /* !KTERM */
char *SaveText(screen, row, scol, ecol, lp)
int row;
int scol, ecol;
TScreen *screen;
register char *lp; /* pointer to where to put the text */
#endif /* !KTERM */
{
X register int i = 0;
#ifdef KTERM
X register Bchr *ch = screen->buf[row + screen->topline];
X register Char g;
# ifdef KTERM_HANZI
X /*
X * Need to check to see if a Big5 font is in use also.
X * Otherwise, no preservation of first Big5 byte is needed.
X */
X register int sp_case = term->flags & BIG5_HANZI;
# endif /* KTERM_HANZI */
#else /* !KTERM */
X register Char *ch = screen->buf[2 * (row + screen->topline)];
#endif /* !KTERM */
X register int c;
X
X if ((i = Length(screen, row, scol, ecol)) == 0) return(lp);
X
X ecol = scol + i;
X /*
X * Just hoping that there will always be enough space allocated for
X * new lines.
X */
X if (ch[ecol].attr & NL_TAG)
X ecol++;
X for (i = scol; i < ecol; i++) {
#ifdef KTERM
X c = ch[i].code & ~NEEDMAP;
X g = ch[i].gset;
X if (ch[i].attr & TAB_TAG) {
X lp->code = '\t';
X lp->gset = GSET_ASCII;
X i++;
X while(i < ecol && ch[i].code == '\0' &&
X !(ch[i].attr & (TAB_TAG|NL_TAG)))
X i++;
X if (i < ecol &&
X (ch[i].code != '\0' || ch[i].attr & (TAB_TAG|NL_TAG)))
X i--;
X } else if (ch[i].attr & NL_TAG) {
X lp->code = '\n';
X lp->gset = GSET_ASCII;
X } else if (c < ' ' || c == 0x7f && !(g & CS96)) {
X lp->code = ' ';
X lp->gset = GSET_ASCII;
X } else {
# ifdef KTERM_HANZI
X /*
X * Big5 text is a special case in which the
X * high order bit on the first byte needs to
X * be preserved when cutting/copying by selection.
X * This is because it is a mixed 7 and 8-bit
X * format.
X * If the first byte is not preserved, then the
X * conversion to Compound Text doesn't work
X * right and junk gets stored to the selection.
X */
X lp->code = (sp_case) ? ch[i].code : c;
# else /* !KTERM_HANZI */
X lp->code = c;
# endif /* !KTERM_HANZI */
X lp->gset = g;
X }
X lp++;
#else /* !KTERM */
X if ((c = ch[i]) == 0)
X c = ' ';
X else if(c < ' ') {
X if(c == '\036')
X c = '#';
X else
X c += 0x5f;
X } else if(c == 0x7f)
X c = 0x5f;
X *lp++ = c;
#endif /* !KTERM */
X }
X return(lp);
}
X
EditorButton(event)
register XButtonEvent *event;
{
X register TScreen *screen = &term->screen;
X int pty = screen->respond;
X char line[6];
X register unsigned row, col;
X int button;
X
X button = event->button - 1;
X
X row = (event->y - screen->border)
X / FontHeight(screen);
X col = (event->x - screen->border - screen->scrollbar)
X / FontWidth(screen);
X (void) strcpy(line, "\033[M");
X if (screen->send_mouse_pos == 1) {
X line[3] = ' ' + button;
X } else {
X line[3] = ' ' + (KeyState(event->state) << 2) +
X ((event->type == ButtonPress)? button:3);
X }
X line[4] = ' ' + col + 1;
X line[5] = ' ' + row + 1;
X v_write(pty, line, 6);
}
X
X
/*ARGSUSED*/
void HandleGINInput (w, event, param_list, nparamsp)
X Widget w;
X XEvent *event;
X String *param_list;
X Cardinal *nparamsp;
{
X if (term->screen.TekGIN && *nparamsp == 1) {
X int c = param_list[0][0];
X switch (c) {
X case 'l': case 'm': case 'r':
X case 'L': case 'M': case 'R':
X break;
X default:
X Bell (); /* let them know they goofed */
X c = 'l'; /* provide a default */
X }
X TekEnqMouse (c | 0x80);
X TekGINoff();
X } else {
X Bell ();
X }
}
X
X
/* ARGSUSED */
void HandleSecure(w, event, params, param_count)
X Widget w;
X XEvent *event; /* unused */
X String *params; /* [0] = volume */
X Cardinal *param_count; /* 0 or 1 */
{
X Time time = CurrentTime;
X
X if ((event->xany.type == KeyPress) ||
X (event->xany.type == KeyRelease))
X time = event->xkey.time;
X else if ((event->xany.type == ButtonPress) ||
X (event->xany.type == ButtonRelease))
X time = event->xbutton.time;
X DoSecureKeyboard (time);
}
SHAR_EOF
echo 'File kterm-4.1.2/button.c is complete' &&
chmod 0664 kterm-4.1.2/button.c ||
echo 'restore of kterm-4.1.2/button.c failed'
Wc_c="`wc -c < 'kterm-4.1.2/button.c'`"
test 55853 -eq "$Wc_c" ||
echo 'kterm-4.1.2/button.c: original size 55853, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= kterm-4.1.2/charproc.c ==============
if test -f 'kterm-4.1.2/charproc.c' -a X"$1" != X"-c"; then
echo 'x - skipping kterm-4.1.2/charproc.c (File already exists)'
rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting kterm-4.1.2/charproc.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'kterm-4.1.2/charproc.c' &&
/*
X * $XConsortium: charproc.c,v 1.123 90/03/12 10:30:21 jim Exp $
X * $Kagotani: /usr/src.yoshi/X/KTerm/4.1.0/RCS/charproc.c,v 1.1 90/06/27 09:38:31 kagotani Rel $
X *
X * $Header: /usr/local/src/X11/contrib/clients/kterm-4.1.2/RCS/charproc.c,v 1.8 1991/03/17 23:46:43 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>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xmu/Atoms.h>
X
/*
X * Copyright 1988 Massachusetts Institute of Technology
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
X
/* charproc.c */
X
#ifdef att
#ifndef STREAMSCONN
#define STREAMSCONN
#endif
#endif
X
#include <stdio.h>
#include <X11/Xos.h>
#ifndef CRAY
#include <sgtty.h>
#endif
#include <ctype.h>
#include <errno.h>
#include <setjmp.h>
#if defined(macII) || defined(CRAY)
#undef FIOCLEX /* redefined from sgtty.h */
#undef FIONCLEX /* redefined from sgtty.h */
#endif
#include "ptyx.h"
#include "VTparse.h"
#include "data.h"
#include <X11/Xutil.h>
#include "error.h"
#include "main.h"
#include <X11/cursorfont.h>
#include <X11/StringDefs.h>
#include "menu.h"
X
#ifdef KTERM_HANZI
#include "hzutil.h"
#endif /* KTERM_HANZI */
X
#ifdef KTERM_HANGUL
#include "hgutil.h"
#endif /* KTERM_HANGUL */
X
#if !defined(EWOULDBLOCK) && defined(EAGAIN)
#define EWOULDBLOCK EAGAIN
#endif
X
extern Widget toplevel;
extern void exit(), bcopy();
static void VTallocbuf();
X
#define DEFAULT -1
#define TEXT_BUF_SIZE 256
#define TRACKTIMESEC 4L
#define TRACKTIMEUSEC 0L
X
#define XtNalwaysHighlight "alwaysHighlight"
#define XtNboldFont "boldFont"
#define XtNc132 "c132"
#define XtNcharClass "charClass"
#define XtNcurses "curses"
#define XtNcursorColor "cursorColor"
#ifdef COLOR_TEXT /* mukawa */
#define XtNcolor0 "color0"
#define XtNcolor1 "color1"
#define XtNcolor2 "color2"
#define XtNcolor3 "color3"
#define XtNcolor4 "color4"
#define XtNcolor5 "color5"
#define XtNcolor6 "color6"
#define XtNcolor7 "color7"
#endif /* COLOR_TEXT */
#define XtNcutNewline "cutNewline"
#define XtNcutToBeginningOfLine "cutToBeginningOfLine"
#define XtNeightBitInput "eightBitInput"
#define XtNgeometry "geometry"
#define XtNtekGeometry "tekGeometry"
#define XtNinternalBorder "internalBorder"
#define XtNjumpScroll "jumpScroll"
#define XtNlogFile "logFile"
#define XtNlogging "logging"
#define XtNlogInhibit "logInhibit"
#define XtNloginShell "loginShell"
#define XtNmarginBell "marginBell"
#define XtNpointerColor "pointerColor"
#define XtNpointerColorBackground "pointerColorBackground"
#define XtNpointerShape "pointerShape"
#define XtNmultiClickTime "multiClickTime"
#define XtNmultiScroll "multiScroll"
#define XtNnMarginBell "nMarginBell"
#define XtNreverseWrap "reverseWrap"
#define XtNsaveLines "saveLines"
#define XtNscrollBar "scrollBar"
#define XtNscrollTtyOutput "scrollTtyOutput"
#define XtNscrollKey "scrollKey"
#define XtNscrollLines "scrollLines"
#define XtNscrollPos "scrollPos"
#define XtNsignalInhibit "signalInhibit"
#ifdef STATUSLINE
#define XtNstatusLine "statusLine"
#define XtNstatusNormal "statusNormal"
#endif /* STATUSLINE */
#define XtNtekInhibit "tekInhibit"
#define XtNtekSmall "tekSmall"
#define XtNtekStartup "tekStartup"
#define XtNtiteInhibit "titeInhibit"
#define XtNvisualBell "visualBell"
#define XtNallowSendEvents "allowSendEvents"
#ifdef KTERM
#define XtNromanKanaFont "romanKanaFont"
#define XtNromanKanaBoldFont "romanKanaBoldFont"
# ifdef KTERM_KANJI
#define XtNkanjiFont "kanjiFont"
#define XtNkanjiBoldFont "kanjiBoldFont"
#define XtNkanjiMode "kanjiMode"
# ifdef KTERM_HANZI
#define XtNhanziFont "hanziFont"
#define XtNhanziBoldFont "hanziBoldFont"
#define XtNhanziMode "hanziMode"
#define XtNhanziGbToBigTable "hanziGbToBigTable"
#define XtNhanziBigToGbTable "hanziBigToGbTable"
# endif /* KTERM_HANZI */
# ifdef KTERM_HANGUL
#define XtNhangulFont "hangulFont"
#define XtNhangulBoldFont "hangulBoldFont"
#define XtNhangulMode "hangulMode"
#define XtNhangulNtoKSTable "hangulNtoKSTable"
# endif /* KTERM_HANGUL */
#define XtNlanguage "language"
# endif /* KTERM_KANJI */
#define XtNfontList "fontList"
#define XtNboldFontList "boldFontList"
#define XtNlineSpace "lineSpace"
#endif /* KTERM */
X
#define XtCAlwaysHighlight "AlwaysHighlight"
#define XtCC132 "C132"
#define XtCCharClass "CharClass"
#define XtCCurses "Curses"
#define XtCCutNewline "CutNewline"
#define XtCCutToBeginningOfLine "CutToBeginningOfLine"
#define XtCEightBitInput "EightBitInput"
#define XtCGeometry "Geometry"
#define XtCJumpScroll "JumpScroll"
#define XtCLogfile "Logfile"
#define XtCLogging "Logging"
#define XtCLogInhibit "LogInhibit"
#define XtCLoginShell "LoginShell"
#define XtCMarginBell "MarginBell"
#define XtCMultiClickTime "MultiClickTime"
#define XtCMultiScroll "MultiScroll"
#define XtCColumn "Column"
#define XtCReverseWrap "ReverseWrap"
#define XtCSaveLines "SaveLines"
#define XtCScrollBar "ScrollBar"
#define XtCScrollLines "ScrollLines"
#define XtCScrollPos "ScrollPos"
#define XtCScrollCond "ScrollCond"
#define XtCSignalInhibit "SignalInhibit"
#ifdef STATUSLINE
#define XtCStatusLine "StatusLine"
#define XtCStatusNormal "StatusNormal"
#endif /* STATUSLINE */
#define XtCTekInhibit "TekInhibit"
#define XtCTekSmall "TekSmall"
#define XtCTekStartup "TekStartup"
#define XtCTiteInhibit "TiteInhibit"
#define XtCVisualBell "VisualBell"
#define XtCAllowSendEvents "AllowSendEvents"
#ifdef KTERM
#define XtCRomanKanaFont "RomanKanaFont"
# ifdef KTERM_KANJI
#define XtCKanjiFont "KanjiFont"
#define XtCKanjiMode "KanjiMode"
# ifdef KTERM_HANZI
#define XtCHanziFont "HanziFont"
#define XtCHanziMode "HanziMode"
#define XtCHanziGbToBigTable "HanziGbToBigTable"
#define XtCHanziBigToGbTable "HanziBigToGbTable"
# endif /* KTERM_HANZI */
# ifdef KTERM_HANGUL
#define XtCHangulFont "HangulFont"
#define XtCHangulMode "HangulMode"
#define XtCHangulNtoKSTable "HangulNtoKSTable"
# endif /* KTERM_HANGUL */
#define XtCLanguage "Language"
# endif /* KTERM_KANJI */
#define XtCFontList "FontList"
#define XtCLineSpace "LineSpace"
#endif /* KTERM */
X
#define doinput() (bcnt-- > 0 ? *bptr++ : in_put())
X
#ifndef lint
static char rcs_id[] = "$XConsortium: charproc.c,v 1.123 90/03/12 10:30:21 jim Exp $";
#endif /* lint */
X
static int nparam;
static ANSI reply;
static int param[NPARAM];
X
static unsigned long ctotal;
static unsigned long ntotal;
static jmp_buf vtjmpbuf;
X
extern int groundtable[];
extern int csitable[];
extern int dectable[];
extern int eigtable[];
extern int esctable[];
extern int iestable[];
extern int igntable[];
extern int scrtable[];
extern int scstable[];
#ifdef KTERM_KANJI
extern int mbcstable[];
static Char pending_byte;
#endif /* KTERM_KANJI */
X
X
/* event handlers */
extern void HandleKeyPressed(), HandleEightBitKeyPressed();
extern void HandleStringEvent();
extern void HandleEnterWindow();
extern void HandleLeaveWindow();
extern void HandleFocusChange();
static void HandleKeymapChange();
extern void HandleInsertSelection();
extern void HandleSelectStart(), HandleKeyboardSelectStart();
extern void HandleSelectExtend(), HandleSelectSet();
extern void HandleSelectEnd(), HandleKeyboardSelectEnd();
extern void HandleStartExtend(), HandleKeyboardStartExtend();
static void HandleBell();
static void HandleIgnore();
extern void HandleSecure();
extern void HandleScrollForward();
extern void HandleScrollBack();
extern void HandleCreateMenu(), HandlePopupMenu();
extern void HandleSetFont();
extern void SetVTFont();
#ifdef KTERM_KCONV
extern void BeginConversion();
#endif /* KTERM_KCONV */
X
/*
X * NOTE: VTInitialize zeros out the entire ".screen" component of the
X * XtermWidget, so make sure to add an assignment statement in VTInitialize()
X * for each new ".screen" field added to this resource list.
X */
X
/* Defaults */
static Boolean defaultFALSE = FALSE;
static Boolean defaultTRUE = TRUE;
static int defaultBorderWidth = DEFBORDERWIDTH;
static int defaultIntBorder = DEFBORDER;
static int defaultSaveLines = SAVELINES;
static int defaultScrollLines = SCROLLLINES;
static int defaultNMarginBell = N_MARGINBELL;
static int defaultMultiClickTime = MULTICLICKTIME;
#ifdef KTERM
static int defaultLineSpace = LINESPACE;
#endif /* KTERM */
static char * _Font_Selected_ = "yes"; /* string is arbitrary */
X
/*
X * Warning, the following must be kept under 1024 bytes or else some
X * compilers (particularly AT&T 6386 SVR3.2) will barf). Workaround is to
X * declare a static buffer and copy in at run time (the the Athena text widget
X * does). Yuck.
X */
#ifdef KTERM_KCONV
static char defaultTranslations[] =
"\
X Ctrl <KeyPress> Kanji: begin-conversion(JAPANESE_CONVERSION) \n\
X Shift <KeyPress> Prior: scroll-back(1,halfpage) \n\
X Shift <KeyPress> Next: scroll-forw(1,halfpage) \n\
X Shift <KeyPress> Select: select-cursor-start() select-cursor-end(PRIMARY, CUT_BUFFER0) \n\
X Shift <KeyPress> Insert: insert-selection(PRIMARY, CUT_BUFFER0) \n\
X ~Meta<KeyPress>: insert-seven-bit() \n\
X Meta<KeyPress>: insert-eight-bit() \n\
X Ctrl ~Meta<Btn1Down>: popup-menu(mainMenu) \n\
X ~Meta <Btn1Down>: select-start() \n\
X ~Meta <Btn1Motion>: select-extend() \n\
X Ctrl ~Meta <Btn2Down>: popup-menu(vtMenu) \n\
~Ctrl ~Meta <Btn2Down>: ignore() \n\
~Ctrl ~Meta <Btn2Up>: insert-selection(PRIMARY, CUT_BUFFER0) \n\
X Ctrl ~Meta <Btn3Down>: popup-menu(fontMenu) \n\
~Ctrl ~Meta <Btn3Down>: start-extend() \n\
X ~Meta <Btn3Motion>: select-extend() \n\
~Ctrl ~Meta <BtnUp>: select-end(PRIMARY, CUT_BUFFER0) \n\
X <BtnDown>: bell(0) \
";
#else /* !KTERM_KCONV */
static char defaultTranslations[] =
"\
X Shift <KeyPress> Prior: scroll-back(1,halfpage) \n\
X Shift <KeyPress> Next: scroll-forw(1,halfpage) \n\
X Shift <KeyPress> Select: select-cursor-start() select-cursor-end(PRIMARY, CUT_BUFFER0) \n\
X Shift <KeyPress> Insert: insert-selection(PRIMARY, CUT_BUFFER0) \n\
X ~Meta<KeyPress>: insert-seven-bit() \n\
X Meta<KeyPress>: insert-eight-bit() \n\
X Ctrl ~Meta<Btn1Down>: popup-menu(mainMenu) \n\
X ~Meta <Btn1Down>: select-start() \n\
X ~Meta <Btn1Motion>: select-extend() \n\
X Ctrl ~Meta <Btn2Down>: popup-menu(vtMenu) \n\
~Ctrl ~Meta <Btn2Down>: ignore() \n\
~Ctrl ~Meta <Btn2Up>: insert-selection(PRIMARY, CUT_BUFFER0) \n\
X Ctrl ~Meta <Btn3Down>: popup-menu(fontMenu) \n\
~Ctrl ~Meta <Btn3Down>: start-extend() \n\
X ~Meta <Btn3Motion>: select-extend() \n\
~Ctrl ~Meta <BtnUp>: select-end(PRIMARY, CUT_BUFFER0) \n\
X <BtnDown>: bell(0) \
";
#endif /* !KTERM_KCONV */
X
static XtActionsRec actionsList[] = {
#ifdef KTERM_KCONV
X { "begin-conversion", BeginConversion },
#endif /* KTERM_KCONV */
X { "bell", HandleBell },
X { "create-menu", HandleCreateMenu },
X { "ignore", HandleIgnore },
X { "insert", HandleKeyPressed }, /* alias for insert-seven-bit */
X { "insert-seven-bit", HandleKeyPressed },
X { "insert-eight-bit", HandleEightBitKeyPressed },
X { "insert-selection", HandleInsertSelection },
X { "keymap", HandleKeymapChange },
X { "popup-menu", HandlePopupMenu },
X { "secure", HandleSecure },
X { "select-start", HandleSelectStart },
X { "select-extend", HandleSelectExtend },
X { "select-end", HandleSelectEnd },
X { "select-set", HandleSelectSet },
X { "select-cursor-start", HandleKeyboardSelectStart },
X { "select-cursor-end", HandleKeyboardSelectEnd },
X { "set-vt-font", HandleSetFont },
X { "start-extend", HandleStartExtend },
X { "start-cursor-extend", HandleKeyboardStartExtend },
X { "string", HandleStringEvent },
X { "scroll-forw", HandleScrollForward },
X { "scroll-back", HandleScrollBack },
X /* menu actions */
X { "allow-send-events", HandleAllowSends },
X { "set-visual-bell", HandleVisualBell },
X { "set-logging", HandleLogging },
X { "redraw", HandleRedraw },
X { "send-signal", HandleSendSignal },
X { "quit", HandleQuit },
X { "set-scrollbar", HandleScrollbar },
X { "set-jumpscroll", HandleJumpscroll },
X { "set-reverse-video", HandleReverseVideo },
X { "set-autowrap", HandleAutoWrap },
X { "set-reversewrap", HandleReverseWrap },
X { "set-autolinefeed", HandleAutoLineFeed },
X { "set-appcursor", HandleAppCursor },
X { "set-appkeypad", HandleAppKeypad },
X { "set-scroll-on-key", HandleScrollKey },
X { "set-scroll-on-tty-output", HandleScrollTtyOutput },
X { "set-allow132", HandleAllow132 },
X { "set-cursesemul", HandleCursesEmul },
X { "set-marginbell", HandleMarginBell },
X { "set-altscreen", HandleAltScreen },
X { "soft-reset", HandleSoftReset },
X { "hard-reset", HandleHardReset },
X { "set-terminal-type", HandleSetTerminalType },
X { "set-visibility", HandleVisibility },
X { "set-tek-text", HandleSetTekText },
X { "tek-page", HandleTekPage },
X { "tek-reset", HandleTekReset },
X { "tek-copy", HandleTekCopy },
#ifdef STATUSLINE
X { "set-statusline", HandleStatusLine },
X { "set-reversestatus", HandleStatusReverse },
#endif /* STATUSLINE */
#ifdef KTERM_KANJI
X { "set-kanji-mode", HandleSetKanjiMode },
#endif /* KTERM_KANJI */
};
X
static XtResource resources[] = {
#ifdef KTERM
{XtNfont, XtCFont, XtRString, sizeof(char *),
X XtOffset(XtermWidget, misc._f_n[F_ISO8859_1]), XtRString,
X (caddr_t) NULL},
{XtNboldFont, XtCFont, XtRString, sizeof(char *),
X XtOffset(XtermWidget, misc._f_b[F_ISO8859_1]), XtRString,
X (caddr_t) NULL},
{XtNromanKanaFont, XtCRomanKanaFont, XtRString, sizeof(char *),
X XtOffset(XtermWidget, misc._f_n[F_JISX0201_0]), XtRString,
X (caddr_t) NULL},
{XtNromanKanaBoldFont, XtCRomanKanaFont, XtRString, sizeof(char *),
X XtOffset(XtermWidget, misc._f_b[F_JISX0201_0]), XtRString,
X (caddr_t) NULL},
# ifdef KTERM_KANJI
{XtNkanjiFont, XtCKanjiFont, XtRString, sizeof(char *),
X XtOffset(XtermWidget, misc._f_n[F_JISX0208_0]), XtRString,
X (caddr_t) NULL},
{XtNkanjiBoldFont, XtCKanjiFont, XtRString, sizeof(char *),
X XtOffset(XtermWidget, misc._f_b[F_JISX0208_0]), XtRString,
X (caddr_t) NULL},
{XtNkanjiMode, XtCKanjiMode, XtRString, sizeof(char *),
X XtOffset(XtermWidget, misc.k_m), XtRString,
X (caddr_t) NULL},
{XtNfontList, XtCFontList, XtRString, sizeof(char *),
X XtOffset(XtermWidget, misc.fontlist), XtRString,
X (caddr_t) NULL},
{XtNboldFontList, XtCFontList, XtRString, sizeof(char *),
X XtOffset(XtermWidget, misc.bfontlist), XtRString,
X (caddr_t) NULL},
{XtNlanguage, XtCLanguage, XtRString, sizeof(char *),
X XtOffset(XtermWidget, misc.lang), XtRString,
X (caddr_t) NULL},
# endif /* KTERM_KANJI */
# ifdef KTERM_HANZI
{XtNhanziFont, XtCHanziFont, XtRString, sizeof(char *),
X XtOffset(XtermWidget, misc._f_n[F_GB2312_0]), XtRString,
X (caddr_t) NULL},
{XtNhanziBoldFont, XtCHanziFont, XtRString, sizeof(char *),
X XtOffset(XtermWidget, misc._f_b[F_GB2312_0]), XtRString,
X (caddr_t) NULL},
{XtNhanziMode, XtCHanziMode, XtRString, sizeof(char *),
X XtOffset(XtermWidget, misc.hz_m), XtRString,
X (caddr_t) NULL},
/*
X * The following two resources need to be set in the default app
X * resources file or the users app resources file. They are
X * directory and filename info on the Big5 <-> GuoBiao conversion
X * tables
X */
{XtNhanziGbToBigTable, XtCHanziGbToBigTable, XtRString, sizeof(char *),
X XtOffset(XtermWidget, misc.hz_gb2big_tbl), XtRString,
X (caddr_t) NULL},
{XtNhanziBigToGbTable, XtCHanziBigToGbTable, XtRString, sizeof(char *),
X XtOffset(XtermWidget, misc.hz_big2gb_tbl), XtRString,
X (caddr_t) NULL},
# endif /* KTERM_HANZI */
# ifdef KTERM_HANGUL
{XtNhangulFont, XtCHangulFont, XtRString, sizeof(char *),
X XtOffset(XtermWidget, misc._f_n[F_KSC5601_0]), XtRString,
X (caddr_t) NULL},
{XtNhangulBoldFont, XtCHangulFont, XtRString, sizeof(char *),
X XtOffset(XtermWidget, misc._f_b[F_KSC5601_0]), XtRString,
X (caddr_t) NULL},
{XtNhangulMode, XtCHangulMode, XtRString, sizeof(char *),
SHAR_EOF
true || echo 'restore of kterm-4.1.2/charproc.c failed'
fi
echo 'End of kterm-4.1.2 part 6'
echo 'File kterm-4.1.2/charproc.c is continued in part 7'
echo 7 > _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