v09i032: colxterm -- Color xterm, Part02/14
Tom Weinstein
tomw at orac.esd.sgi.com
Sat Sep 15 04:10:32 AEST 1990
Submitted-by: Tom Weinstein <tomw at orac.esd.sgi.com>
Posting-number: Volume 9, Issue 32
Archive-name: colxterm/part02
#! /bin/sh
# This is a shell archive. Remove anything before this line, then feed it
# into a shell via "sh file" or similar. To overwrite existing files,
# type "sh file -c".
# The tool that generated this appeared in the comp.sources.unix newsgroup;
# send mail to comp-sources-unix at uunet.uu.net if you want that tool.
# If this archive is complete, you will see the following message at the end:
# "End of archive 2 (of 14)."
# Contents: xterm/TekPrsTbl.c.ac xterm/VTparse.def xterm/button.c
# Wrapped by argv at turnpike on Thu Sep 13 20:42:17 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'xterm/TekPrsTbl.c.ac' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'xterm/TekPrsTbl.c.ac'\"
else
echo shar: Extracting \"'xterm/TekPrsTbl.c.ac'\" \(12699 characters\)
sed "s/^X//" >'xterm/TekPrsTbl.c.ac' <<'END_OF_FILE'
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* DC4 NAK SYN ETB */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* CAN EM SUB ESC */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_ESC_STATE,
X/* FS GS RS US */
XCASE_PT_STATE,
XCASE_PLT_STATE,
XCASE_IPL_STATE,
XCASE_ALP_STATE,
X/* SP ! " # */
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
X/* $ % & ' */
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
X/* ( ) * + */
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
X/* , - . / */
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
X/* 0 1 2 3 */
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
X/* 4 5 6 7 */
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
X/* 8 9 : ; */
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
X/* < = > ? */
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
X/* @ A B C */
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
X/* D E F G */
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
X/* H I J K */
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
X/* L M N O */
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
X/* P Q R S */
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
X/* T U V W */
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
X/* X Y Z [ */
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
X/* \ ] ^ _ */
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
X/* ` a b c */
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
X/* d e f g */
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
X/* h i j k */
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
X/* l m n o */
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
X/* p q r s */
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
X/* t u v w */
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
X/* x y z { */
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
X/* | } ~ DEL */
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
XCASE_PT_POINT,
X/* 0x80 0x81 0x82 0x83 */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* 0x84 0x85 0x86 0x87 */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* 0x88 0x89 0x8a 0x8b */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* 0x8c 0x8d 0x8e 0x8f */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* 0x90 0x91 0x92 0x93 */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* 0x94 0x95 0x96 0x97 */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* 0x99 0x99 0x9a 0x9b */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* 0x9c 0x9d 0x9e 0x9f */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* nobreakspace exclamdown cent sterling */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* currency yen brokenbar section */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* diaeresis copyright ordfeminine guillemotleft */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* notsign hyphen registered macron */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* degree plusminus twosuperior threesuperior */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* acute mu paragraph periodcentered */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* cedilla onesuperior masculine guillemotright */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* onequarter onehalf threequarters questiondown */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* Agrave Aacute Acircumflex Atilde */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* Adiaeresis Aring AE Ccedilla */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* Egrave Eacute Ecircumflex Ediaeresis */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* Igrave Iacute Icircumflex Idiaeresis */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* Eth Ntilde Ograve Oacute */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* Ocircumflex Otilde Odiaeresis multiply */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* Ooblique Ugrave Uacute Ucircumflex */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* Udiaeresis Yacute Thorn ssharp */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* agrave aacute acircumflex atilde */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* adiaeresis aring ae ccedilla */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* egrave eacute ecircumflex ediaeresis */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* igrave iacute icircumflex idiaeresis */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* eth ntilde ograve oacute */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* ocircumflex otilde odiaeresis division */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* oslash ugrave uacute ucircumflex */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* udiaeresis yacute thorn ydiaeresis */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X};
X
Xint Tspttable[] = {
X/* NUL SOH STX ETX */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* EOT ENQ ACK BEL */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_BEL,
X/* BS HT NL VT */
XCASE_BS,
XCASE_TAB,
XCASE_LF,
XCASE_UP,
X/* NP CR SO SI */
XCASE_IGNORE,
XCASE_CR,
XCASE_IGNORE,
XCASE_IGNORE,
X/* DLE DC1 DC2 DC3 */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* DC4 NAK SYN ETB */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* CAN EM SUB ESC */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_ESC_STATE,
X/* FS GS RS US */
XCASE_PT_STATE,
XCASE_PLT_STATE,
XCASE_IPL_STATE,
XCASE_ALP_STATE,
X/* SP ! " # */
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
X/* $ % & ' */
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
X/* ( ) * + */
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
X/* , - . / */
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
X/* 0 1 2 3 */
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
X/* 4 5 6 7 */
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
X/* 8 9 : ; */
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
X/* < = > ? */
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
X/* @ A B C */
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
X/* D E F G */
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
X/* H I J K */
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
X/* L M N O */
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
X/* P Q R S */
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
X/* T U V W */
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
X/* X Y Z [ */
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
X/* \ ] ^ _ */
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
X/* ` a b c */
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
X/* d e f g */
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
X/* h i j k */
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
X/* l m n o */
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
X/* p q r s */
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
X/* t u v w */
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
X/* x y z { */
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
X/* | } ~ DEL */
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
XCASE_SPT_POINT,
X/* 0x80 0x81 0x82 0x83 */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* 0x84 0x85 0x86 0x87 */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* 0x88 0x89 0x8a 0x8b */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* 0x8c 0x8d 0x8e 0x8f */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* 0x90 0x91 0x92 0x93 */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* 0x94 0x95 0x96 0x97 */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* 0x99 0x99 0x9a 0x9b */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* 0x9c 0x9d 0x9e 0x9f */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* nobreakspace exclamdown cent sterling */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* currency yen brokenbar section */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* diaeresis copyright ordfeminine guillemotleft */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* notsign hyphen registered macron */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* degree plusminus twosuperior threesuperior */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* acute mu paragraph periodcentered */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* cedilla onesuperior masculine guillemotright */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* onequarter onehalf threequarters questiondown */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* Agrave Aacute Acircumflex Atilde */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* Adiaeresis Aring AE Ccedilla */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* Egrave Eacute Ecircumflex Ediaeresis */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* Igrave Iacute Icircumflex Idiaeresis */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* Eth Ntilde Ograve Oacute */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* Ocircumflex Otilde Odiaeresis multiply */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* Ooblique Ugrave Uacute Ucircumflex */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* Udiaeresis Yacute Thorn ssharp */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* agrave aacute acircumflex atilde */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* adiaeresis aring ae ccedilla */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* egrave eacute ecircumflex ediaeresis */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* igrave iacute icircumflex idiaeresis */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* eth ntilde ograve oacute */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* ocircumflex otilde odiaeresis division */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* oslash ugrave uacute ucircumflex */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X/* udiaeresis yacute thorn ydiaeresis */
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
XCASE_IGNORE,
X};
END_OF_FILE
if test 12699 -ne `wc -c <'xterm/TekPrsTbl.c.ac'`; then
echo shar: \"'xterm/TekPrsTbl.c.ac'\" unpacked with wrong size!
fi
# end of 'xterm/TekPrsTbl.c.ac'
fi
if test -f 'xterm/VTparse.def' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'xterm/VTparse.def'\"
else
echo shar: Extracting \"'xterm/VTparse.def'\" \(1014 characters\)
sed "s/^X//" >'xterm/VTparse.def' <<'END_OF_FILE'
X#
X# $XConsortium: VTparse.def,v 1.3 89/01/04 13:37:48 jim Exp $
X#
X# List of symbols that need to be defined for VTparse.h. If you need to
X# change any of the CASE_ macros, make the change here and rerun the command
X# shown in VTparse.h.
X#
X
XCASE_GROUND_STATE
XCASE_IGNORE_STATE
XCASE_IGNORE_ESC
XCASE_IGNORE
XCASE_BELL
XCASE_BS
XCASE_CR
XCASE_ESC
XCASE_VMOT
XCASE_TAB
XCASE_SI
XCASE_SO
XCASE_SCR_STATE
XCASE_SCS0_STATE
XCASE_SCS1_STATE
XCASE_SCS2_STATE
XCASE_SCS3_STATE
XCASE_ESC_IGNORE
XCASE_ESC_DIGIT
XCASE_ESC_SEMI
XCASE_DEC_STATE
XCASE_ICH
XCASE_CUU
XCASE_CUD
XCASE_CUF
XCASE_CUB
XCASE_CUP
XCASE_ED
XCASE_EL
XCASE_IL
XCASE_DL
XCASE_DCH
XCASE_DA1
XCASE_TRACK_MOUSE
XCASE_TBC
XCASE_SET
XCASE_RST
XCASE_SGR
XCASE_CPR
XCASE_DECSTBM
XCASE_DECREQTPARM
XCASE_DECSET
XCASE_DECRST
XCASE_DECALN
XCASE_GSETS
XCASE_DECSC
XCASE_DECRC
XCASE_DECKPAM
XCASE_DECKPNM
XCASE_IND
XCASE_NEL
XCASE_HTS
XCASE_RI
XCASE_SS2
XCASE_SS3
XCASE_CSI_STATE
XCASE_OSC
XCASE_RIS
XCASE_LS2
XCASE_LS3
XCASE_LS3R
XCASE_LS2R
XCASE_LS1R
XCASE_PRINT
XCASE_XTERM_SAVE
XCASE_XTERM_RESTORE
XCASE_XTERM_TITLE
XCASE_DECID
END_OF_FILE
if test 1014 -ne `wc -c <'xterm/VTparse.def'`; then
echo shar: \"'xterm/VTparse.def'\" unpacked with wrong size!
fi
# end of 'xterm/VTparse.def'
fi
if test -f 'xterm/button.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'xterm/button.c'\"
else
echo shar: Extracting \"'xterm/button.c'\" \(38111 characters\)
sed "s/^X//" >'xterm/button.c' <<'END_OF_FILE'
X/*
X * $XConsortium: button.c,v 1.52 90/06/08 14:28:51 jim Exp $
X */
X
X
X#include <X11/copyright.h>
X
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
X/*
Xbutton.c Handles button events in the terminal emulator.
X does cut/paste operations, change modes via menu,
X passes button events through to some applications.
X J. Gettys.
X*/
X#ifndef lint
Xstatic char rcs_id[] = "$XConsortium: button.c,v 1.52 90/06/08 14:28:51 jim Exp $";
X#endif /* lint */
X
X#include "ptyx.h" /* Xlib headers included here. */
X#include <X11/Xatom.h>
X#include <stdio.h>
X#include <setjmp.h>
X#include <ctype.h>
X
X#include <X11/Xmu/Atoms.h>
X#include <X11/Xmu/StdSel.h>
X
X#include "data.h"
X#include "error.h"
X#include "menu.h"
X
Xextern char *malloc();
X
X#define KeyState(x) (((x) & (ShiftMask|ControlMask)) + (((x) & Mod1Mask) ? 2 : 0))
X /* adds together the bits:
X shift key -> 1
X meta key -> 2
X control key -> 4 */
X
X#define TEXTMODES 4
X#define NBUTS 3
X#define DIRS 2
X#define UP 1
X#define DOWN 0
X#define SHIFTS 8 /* three keys, so eight combinations */
X#define Coordinate(r,c) ((r) * (term->screen.max_col+1) + (c))
X
Xchar *SaveText();
Xextern EditorButton();
X
Xextern char *xterm_name;
Xextern Bogus();
X
Xstatic PointToRowCol();
X
Xextern XtermWidget term;
X
X/* Selection/extension variables */
X
X/* Raw char position where the selection started */
Xstatic int rawRow, rawCol;
X
X/* Selected area before CHAR, WORD, LINE selectUnit processing */
Xstatic int startRRow, startRCol, endRRow, endRCol = 0;
X
X/* Selected area after CHAR, WORD, LINE selectUnit processing */
Xstatic int startSRow, startSCol, endSRow, endSCol = 0;
X
X/* Valid rows for selection clipping */
Xstatic int firstValidRow, lastValidRow;
X
X/* Start, end of extension */
Xstatic int startERow, startECol, endERow, endECol;
X
X/* Saved values of raw selection for extend to restore to */
Xstatic int saveStartRRow, saveStartRCol, saveEndRRow, saveEndRCol;
X
X/* Multi-click handling */
Xstatic int numberOfClicks = 0;
Xstatic long int lastButtonUpTime = 0;
Xtypedef int SelectUnit;
X#define SELECTCHAR 0
X#define SELECTWORD 1
X#define SELECTLINE 2
X#define NSELECTUNITS 3
Xstatic SelectUnit selectUnit;
X
X/* Send emacs escape code when done selecting or extending? */
Xstatic int replyToEmacs;
X
X
XBoolean SendMousePosition(w, event)
XWidget w;
XXEvent* event;
X{
X register TScreen *screen = &((XtermWidget)w)->screen;
X static TrackDown();
X
X if (screen->send_mouse_pos == 0) return False;
X
X if (event->type != ButtonPress && event->type != ButtonRelease)
X return False;
X
X#define KeyModifiers \
X (event->xbutton.state & (ShiftMask | LockMask | ControlMask | Mod1Mask | \
X Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask ))
X
X#define ButtonModifiers \
X (event->xbutton.state & (ShiftMask | LockMask | ControlMask | Mod1Mask | \
X Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask ))
X
X switch (screen->send_mouse_pos) {
X case 1: /* X10 compatibility sequences */
X
X if (KeyModifiers == 0) {
X if (event->type == ButtonPress)
X EditorButton(event);
X return True;
X }
X return False;
X
X case 2: /* DEC vt200 compatible */
X
X if (KeyModifiers == 0 || KeyModifiers == ControlMask) {
X EditorButton(event);
X return True;
X }
X return False;
X
X case 3: /* DEC vt200 hilite tracking */
X if ( event->type == ButtonPress &&
X KeyModifiers == 0 &&
X event->xbutton.button == Button1 ) {
X TrackDown(event);
X return True;
X }
X if (KeyModifiers == 0 || KeyModifiers == ControlMask) {
X EditorButton(event);
X return True;
X }
X /* fall through */
X
X default:
X return False;
X }
X#undef KeyModifiers
X}
X
X
X/*ARGSUSED*/
Xvoid HandleSelectExtend(w, event, params, num_params)
XWidget w;
XXEvent *event; /* must be XMotionEvent */
XString *params; /* unused */
XCardinal *num_params; /* unused */
X{
X register TScreen *screen = &((XtermWidget)w)->screen;
X int row, col;
X
X screen->selection_time = event->xmotion.time;
X switch (eventMode) {
X case LEFTEXTENSION :
X case RIGHTEXTENSION :
X PointToRowCol (event->xmotion.y, event->xmotion.x,
X &row, &col);
X ExtendExtend (row, col);
X break;
X case NORMAL :
X /* will get here if send_mouse_pos != 0 */
X break;
X }
X}
X
X
X/*ARGSUSED*/
Xstatic void do_select_end (w, event, params, num_params, use_cursor_loc)
XWidget w;
XXEvent *event; /* must be XButtonEvent */
XString *params; /* selections */
XCardinal *num_params;
XBool use_cursor_loc;
X{
X ((XtermWidget)w)->screen.selection_time = event->xbutton.time;
X switch (eventMode) {
X case NORMAL :
X (void) SendMousePosition(w, event);
X break;
X case LEFTEXTENSION :
X case RIGHTEXTENSION :
X EndExtend(event, params, *num_params, use_cursor_loc);
X break;
X }
X}
X
X
Xvoid HandleSelectEnd(w, event, params, num_params)
XWidget w;
XXEvent *event; /* must be XButtonEvent */
XString *params; /* selections */
XCardinal *num_params;
X{
X do_select_end (w, event, params, num_params, False);
X}
X
X
Xvoid HandleKeyboardSelectEnd(w, event, params, num_params)
XWidget w;
XXEvent *event; /* must be XButtonEvent */
XString *params; /* selections */
XCardinal *num_params;
X{
X do_select_end (w, event, params, num_params, True);
X}
X
X
X
X
Xstruct _SelectionList {
X String *params;
X Cardinal count;
X Time time;
X};
X
X
Xstatic void _GetSelection(w, time, params, num_params)
XWidget w;
XTime time;
XString *params; /* selections in precedence order */
XCardinal num_params;
X{
X static void SelectionReceived();
X Atom selection;
X int buffer;
X
X XmuInternStrings(XtDisplay(w), params, (Cardinal)1, &selection);
X switch (selection) {
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 register TScreen *screen = &((XtermWidget)w)->screen;
X int inbytes;
X unsigned long nbytes;
X int fmt8 = 8;
X Atom type = XA_STRING;
X char *line = XFetchBuffer(screen->display, &inbytes, buffer);
X nbytes = (unsigned long) inbytes;
X if (nbytes > 0)
X SelectionReceived(w, NULL, &selection, &type, (caddr_t)line,
X &nbytes, &fmt8);
X else if (num_params > 1)
X _GetSelection(w, time, params+1, num_params-1);
X } else {
X struct _SelectionList* list;
X if (--num_params) {
X list = XtNew(struct _SelectionList);
X list->params = params + 1;
X list->count = num_params;
X list->time = time;
X } else list = NULL;
X XtGetSelectionValue(w, selection, XA_STRING, SelectionReceived,
X (caddr_t)list, time);
X }
X}
X
X
X/* ARGSUSED */
Xstatic void SelectionReceived(w, client_data, selection, type,
X value, length, format)
XWidget w;
Xcaddr_t client_data;
XAtom *selection, *type;
Xcaddr_t value;
Xunsigned long *length;
Xint *format;
X{
X int pty = ((XtermWidget)w)->screen.respond; /* file descriptor of pty */
X register char *lag, *cp, *end;
X char *line = (char*)value;
X
X if (*type == 0 /*XT_CONVERT_FAIL*/ || *length == 0) {
X struct _SelectionList* list = (struct _SelectionList*)client_data;
X if (list != NULL) {
X _GetSelection(w, list->time, list->params, list->count);
X XtFree(client_data);
X }
X return;
X }
X
X end = &line[*length];
X lag = line;
X for (cp = line; cp != end; cp++)
X {
X if (*cp != '\n') continue;
X *cp = '\r';
X v_write(pty, lag, cp - lag + 1);
X lag = cp + 1;
X }
X if (lag != end)
X v_write(pty, lag, end - lag);
X
X XtFree(client_data);
X XtFree(value);
X}
X
X
XHandleInsertSelection(w, event, params, num_params)
XWidget w;
XXEvent *event; /* assumed to be XButtonEvent* */
XString *params; /* selections in precedence order */
XCardinal *num_params;
X{
X if (SendMousePosition(w, event)) return;
X _GetSelection(w, event->xbutton.time, params, *num_params);
X}
X
X
XSetSelectUnit(buttonDownTime, defaultUnit)
Xunsigned long buttonDownTime;
XSelectUnit defaultUnit;
X{
X/* Do arithmetic as integers, but compare as unsigned solves clock wraparound */
X if ((long unsigned)((long int)buttonDownTime - lastButtonUpTime)
X > term->screen.multiClickTime) {
X numberOfClicks = 1;
X selectUnit = defaultUnit;
X } else {
X ++numberOfClicks;
X selectUnit = ((selectUnit + 1) % NSELECTUNITS);
X }
X}
X
Xstatic void do_select_start (w, event, startrow, startcol)
XWidget w;
XXEvent *event; /* must be XButtonEvent* */
Xint startrow, startcol;
X{
X if (SendMousePosition(w, event)) return;
X SetSelectUnit(event->xbutton.time, SELECTCHAR);
X replyToEmacs = FALSE;
X StartSelect(startrow, startcol);
X}
X
X/* ARGSUSED */
XHandleSelectStart(w, event, params, num_params)
XWidget w;
XXEvent *event; /* must be XButtonEvent* */
XString *params; /* unused */
XCardinal *num_params; /* unused */
X{
X register TScreen *screen = &((XtermWidget)w)->screen;
X int startrow, startcol;
X
X firstValidRow = 0;
X lastValidRow = screen->max_row;
X PointToRowCol(event->xbutton.y, event->xbutton.x, &startrow, &startcol);
X do_select_start (w, event, startrow, startcol);
X}
X
X
X/* ARGSUSED */
XHandleKeyboardSelectStart(w, event, params, num_params)
XWidget w;
XXEvent *event; /* must be XButtonEvent* */
XString *params; /* unused */
XCardinal *num_params; /* unused */
X{
X register TScreen *screen = &((XtermWidget)w)->screen;
X
X do_select_start (w, event, screen->cursor_row, screen->cursor_col);
X}
X
X
Xstatic TrackDown(event)
Xregister XButtonEvent *event;
X{
X int startrow, startcol;
X
X SetSelectUnit(event->time, SELECTCHAR);
X if (numberOfClicks > 1 ) {
X PointToRowCol(event->y, event->x, &startrow, &startcol);
X replyToEmacs = TRUE;
X StartSelect(startrow, startcol);
X } else {
X waitingForTrackInfo = 1;
X EditorButton(event);
X }
X}
X
X
X#define boundsCheck(x) if (x < 0) \
X x = 0; \
X else if (x >= screen->max_row) \
X x = screen->max_row;
X
XTrackMouse(func, startrow, startcol, firstrow, lastrow)
Xint func, startrow, startcol, firstrow, lastrow;
X{
X TScreen *screen = &term->screen;
X
X if (!waitingForTrackInfo) { /* Timed out, so ignore */
X return;
X }
X waitingForTrackInfo = 0;
X if (func == 0) return;
X boundsCheck (startrow)
X boundsCheck (firstrow)
X boundsCheck (lastrow)
X firstValidRow = firstrow;
X lastValidRow = lastrow;
X replyToEmacs = TRUE;
X StartSelect(startrow, startcol);
X}
X
XStartSelect(startrow, startcol)
Xint startrow, startcol;
X{
X TScreen *screen = &term->screen;
X
X if (screen->cursor_state)
X HideCursor ();
X if (numberOfClicks == 1) {
X /* set start of selection */
X rawRow = startrow;
X rawCol = startcol;
X
X } /* else use old values in rawRow, Col */
X
X saveStartRRow = startERow = rawRow;
X saveStartRCol = startECol = rawCol;
X saveEndRRow = endERow = rawRow;
X saveEndRCol = endECol = rawCol;
X if (Coordinate(startrow, startcol) < Coordinate(rawRow, rawCol)) {
X eventMode = LEFTEXTENSION;
X startERow = startrow;
X startECol = startcol;
X } else {
X eventMode = RIGHTEXTENSION;
X endERow = startrow;
X endECol = startcol;
X }
X ComputeSelect(startERow, startECol, endERow, endECol, False);
X
X}
X
XEndExtend(event, params, num_params, use_cursor_loc)
XXEvent *event; /* must be XButtonEvent */
XString *params; /* selections */
XCardinal num_params;
XBool use_cursor_loc;
X{
X int row, col;
X TScreen *screen = &term->screen;
X char line[9];
X
X if (use_cursor_loc) {
X row = screen->cursor_row;
X col = screen->cursor_col;
X } else {
X PointToRowCol(event->xbutton.y, event->xbutton.x, &row, &col);
X }
X ExtendExtend (row, col);
X lastButtonUpTime = event->xbutton.time;
X if (startSRow != endSRow || startSCol != endSCol) {
X if (replyToEmacs) {
X if (rawRow == startSRow && rawCol == startSCol
X && row == endSRow && col == endSCol) {
X /* Use short-form emacs select */
X strcpy(line, "\033[t");
X line[3] = ' ' + endSCol + 1;
X line[4] = ' ' + endSRow + 1;
X v_write(screen->respond, line, 5);
X } else {
X /* long-form, specify everything */
X strcpy(line, "\033[T");
X line[3] = ' ' + startSCol + 1;
X line[4] = ' ' + startSRow + 1;
X line[5] = ' ' + endSCol + 1;
X line[6] = ' ' + endSRow + 1;
X line[7] = ' ' + col + 1;
X line[8] = ' ' + row + 1;
X v_write(screen->respond, line, 9);
X }
X TrackText(0, 0, 0, 0);
X }
X }
X SelectSet(event, params, num_params);
X eventMode = NORMAL;
X}
X
XHandleSelectSet(w, event, params, num_params)
XWidget w;
XXEvent *event;
XString *params;
XCardinal *num_params;
X{
X SelectSet (event, params, *num_params);
X}
X
XSelectSet (event, params, num_params)
XXEvent *event;
XString *params;
XCardinal num_params;
X{
X /* Only do select stuff if non-null select */
X if (startSRow != endSRow || startSCol != endSCol) {
X SaltTextAway(startSRow, startSCol, endSRow, endSCol,
X params, num_params);
X } else
X DisownSelection(term);
X}
X
X#define Abs(x) ((x) < 0 ? -(x) : (x))
X
X/* ARGSUSED */
Xstatic void do_start_extend (w, event, params, num_params, use_cursor_loc)
XWidget w;
XXEvent *event; /* must be XButtonEvent* */
XString *params; /* unused */
XCardinal *num_params; /* unused */
XBool use_cursor_loc;
X{
X TScreen *screen = &((XtermWidget)w)->screen;
X int row, col, coord;
X
X if (SendMousePosition(w, event)) return;
X firstValidRow = 0;
X lastValidRow = screen->max_row;
X SetSelectUnit(event->xbutton.time, selectUnit);
X replyToEmacs = FALSE;
X
X if (numberOfClicks == 1) {
X /* Save existing selection so we can reestablish it if the guy
X extends past the other end of the selection */
X saveStartRRow = startERow = startRRow;
X saveStartRCol = startECol = startRCol;
X saveEndRRow = endERow = endRRow;
X saveEndRCol = endECol = endRCol;
X } else {
X /* He just needed the selection mode changed, use old values. */
X startERow = startRRow = saveStartRRow;
X startECol = startRCol = saveStartRCol;
X endERow = endRRow = saveEndRRow;
X endECol = endRCol = saveEndRCol;
X
X }
X if (use_cursor_loc) {
X row = screen->cursor_row;
X col = screen->cursor_col;
X } else {
X PointToRowCol(event->xbutton.y, event->xbutton.x, &row, &col);
X }
X coord = Coordinate(row, col);
X
X if (Abs(coord - Coordinate(startSRow, startSCol))
X < Abs(coord - Coordinate(endSRow, endSCol))
X || coord < Coordinate(startSRow, startSCol)) {
X /* point is close to left side of selection */
X eventMode = LEFTEXTENSION;
X startERow = row;
X startECol = col;
X } else {
X /* point is close to left side of selection */
X eventMode = RIGHTEXTENSION;
X endERow = row;
X endECol = col;
X }
X ComputeSelect(startERow, startECol, endERow, endECol, True);
X}
X
XExtendExtend (row, col)
Xint row, col;
X{
X int coord = Coordinate(row, col);
X
X if (eventMode == LEFTEXTENSION
X && (coord + (selectUnit!=SELECTCHAR)) > Coordinate(endSRow, endSCol)) {
X /* Whoops, he's changed his mind. Do RIGHTEXTENSION */
X eventMode = RIGHTEXTENSION;
X startERow = saveStartRRow;
X startECol = saveStartRCol;
X } else if (eventMode == RIGHTEXTENSION
X && coord < Coordinate(startSRow, startSCol)) {
X /* Whoops, he's changed his mind. Do LEFTEXTENSION */
X eventMode = LEFTEXTENSION;
X endERow = saveEndRRow;
X endECol = saveEndRCol;
X }
X if (eventMode == LEFTEXTENSION) {
X startERow = row;
X startECol = col;
X } else {
X endERow = row;
X endECol = col;
X }
X ComputeSelect(startERow, startECol, endERow, endECol, False);
X}
X
X
Xvoid HandleStartExtend(w, event, params, num_params)
XWidget w;
XXEvent *event; /* must be XButtonEvent* */
XString *params; /* unused */
XCardinal *num_params; /* unused */
X{
X do_start_extend (w, event, params, num_params, False);
X}
X
Xvoid HandleKeyboardStartExtend(w, event, params, num_params)
XWidget w;
XXEvent *event; /* must be XButtonEvent* */
XString *params; /* unused */
XCardinal *num_params; /* unused */
X{
X do_start_extend (w, event, params, num_params, True);
X}
X
X
X
X
X
XScrollSelection(screen, amount)
Xregister TScreen* screen;
Xregister int amount;
X{
X register int minrow = -screen->savedlines;
X
X /* Sent by scrollbar stuff, so amount never takes selection out of
X saved text */
X
X /* XXX - the preceeding is false; cat /etc/termcap (or anything
X larger than the number of saved lines plus the screen height) and then
X hit extend select */
X
X startRRow += amount; endRRow += amount;
X startSRow += amount; endSRow += amount;
X rawRow += amount;
X screen->startHRow += amount;
X screen->endHRow += amount;
X
X if (startRRow < minrow) {
X startRRow = minrow;
X startRCol = 0;
X }
X if (endRRow < minrow) {
X endRRow = minrow;
X endRCol = 0;
X }
X if (startSRow < minrow) {
X startSRow = minrow;
X startSCol = 0;
X }
X if (endSRow < minrow) {
X endSRow = minrow;
X endSCol = 0;
X }
X if (rawRow < minrow) {
X rawRow = minrow;
X rawCol = 0;
X }
X if (screen->startHRow < minrow) {
X screen->startHRow = minrow;
X screen->startHCol = 0;
X }
X if (screen->endHRow < minrow) {
X screen->endHRow = minrow;
X screen->endHCol = 0;
X }
X screen->startHCoord = Coordinate (screen->startHRow, screen->startHCol);
X screen->endHCoord = Coordinate (screen->endHRow, screen->endHCol);
X}
X
X
X/*ARGSUSED*/
XResizeSelection (screen, rows, cols)
X TScreen *screen;
X int rows, cols;
X{
X rows--; /* decr to get 0-max */
X cols--;
X
X if (startRRow > rows) startRRow = rows;
X if (startSRow > rows) startSRow = rows;
X if (endRRow > rows) endRRow = rows;
X if (endSRow > rows) endSRow = rows;
X if (rawRow > rows) rawRow = rows;
X
X if (startRCol > cols) startRCol = cols;
X if (startSCol > cols) startSCol = cols;
X if (endRCol > cols) endRCol = cols;
X if (endSCol > cols) endSCol = cols;
X if (rawCol > cols) rawCol = cols;
X}
X
Xstatic PointToRowCol(y, x, r, c)
Xregister int y, x;
Xint *r, *c;
X/* Convert pixel coordinates to character coordinates.
X Rows are clipped between firstValidRow and lastValidRow.
X Columns are clipped between to be 0 or greater, but are not clipped to some
X maximum value. */
X{
X register TScreen *screen = &term->screen;
X register row, col;
X
X row = (y - screen->border) / FontHeight(screen);
X if(row < firstValidRow)
X row = firstValidRow;
X else if(row > lastValidRow)
X row = lastValidRow;
X col = (x - screen->border - screen->scrollbar) / FontWidth(screen);
X if(col < 0)
X col = 0;
X else if(col > screen->max_col+1) {
X col = screen->max_col+1;
X }
X *r = row;
X *c = col;
X}
X
Xint LastTextCol(row)
Xregister int row;
X{
X register TScreen *screen = &term->screen;
X register int i;
X register Char *ch;
X
X for(i = screen->max_col,
X ch = screen->buf[4 * (row + screen->topline)] + i ;
X i > 0 && (*ch == ' ' || *ch == 0); ch--, i--);
X return(i);
X}
X
X/*
X** double click table for cut and paste in 8 bits
X**
X** This table is divided in four parts :
X**
X** - control characters [0,0x1f] U [0x80,0x9f]
X** - separators [0x20,0x3f] U [0xa0,0xb9]
X** - binding characters [0x40,0x7f] U [0xc0,0xff]
X** - execeptions
X*/
Xstatic int charClass[256] = {
X/* NUL SOH STX ETX EOT ENQ ACK BEL */
X 32, 1, 1, 1, 1, 1, 1, 1,
X/* BS HT NL VT NP CR SO SI */
X 1, 32, 1, 1, 1, 1, 1, 1,
X/* DLE DC1 DC2 DC3 DC4 NAK SYN ETB */
X 1, 1, 1, 1, 1, 1, 1, 1,
X/* CAN EM SUB ESC FS GS RS US */
X 1, 1, 1, 1, 1, 1, 1, 1,
X/* SP ! " # $ % & ' */
X 32, 33, 34, 35, 36, 37, 38, 39,
X/* ( ) * + , - . / */
X 40, 41, 42, 43, 44, 45, 46, 47,
X/* 0 1 2 3 4 5 6 7 */
X 48, 48, 48, 48, 48, 48, 48, 48,
X/* 8 9 : ; < = > ? */
X 48, 48, 58, 59, 60, 61, 62, 63,
X/* @ A B C D E F G */
X 64, 48, 48, 48, 48, 48, 48, 48,
X/* H I J K L M N O */
X 48, 48, 48, 48, 48, 48, 48, 48,
X/* P Q R S T U V W */
X 48, 48, 48, 48, 48, 48, 48, 48,
X/* X Y Z [ \ ] ^ _ */
X 48, 48, 48, 91, 92, 93, 94, 48,
X/* ` a b c d e f g */
X 96, 48, 48, 48, 48, 48, 48, 48,
X/* h i j k l m n o */
X 48, 48, 48, 48, 48, 48, 48, 48,
X/* p q r s t u v w */
X 48, 48, 48, 48, 48, 48, 48, 48,
X/* x y z { | } ~ DEL */
X 48, 48, 48, 123, 124, 125, 126, 1,
X/* x80 x81 x82 x83 IND NEL SSA ESA */
X 1, 1, 1, 1, 1, 1, 1, 1,
X/* HTS HTJ VTS PLD PLU RI SS2 SS3 */
X 1, 1, 1, 1, 1, 1, 1, 1,
X/* DCS PU1 PU2 STS CCH MW SPA EPA */
X 1, 1, 1, 1, 1, 1, 1, 1,
X/* x98 x99 x9A CSI ST OSC PM APC */
X 1, 1, 1, 1, 1, 1, 1, 1,
X/* - i c/ L ox Y- | So */
X 160, 161, 162, 163, 164, 165, 166, 167,
X/* .. c0 ip << _ R0 - */
X 168, 169, 170, 171, 172, 173, 174, 175,
X/* o +- 2 3 ' u q| . */
X 176, 177, 178, 179, 180, 181, 182, 183,
X/* , 1 2 >> 1/4 1/2 3/4 ? */
X 184, 185, 186, 187, 188, 189, 190, 191,
X/* A` A' A^ A~ A: Ao AE C, */
X 48, 48, 48, 48, 48, 48, 48, 48,
X/* E` E' E^ E: I` I' I^ I: */
X 48, 48, 48, 48, 48, 48, 48, 48,
X/* D- N~ O` O' O^ O~ O: X */
X 48, 48, 48, 48, 48, 48, 48, 216,
X/* O/ U` U' U^ U: Y' P B */
X 48, 48, 48, 48, 48, 48, 48, 48,
X/* a` a' a^ a~ a: ao ae c, */
X 48, 48, 48, 48, 48, 48, 48, 48,
X/* e` e' e^ e: i` i' i^ i: */
X 48, 48, 48, 48, 48, 48, 48, 48,
X/* d n~ o` o' o^ o~ o: -: */
X 48, 48, 48, 48, 48, 48, 48, 248,
X/* o/ u` u' u^ u: y' P y: */
X 48, 48, 48, 48, 48, 48, 48, 48};
X
Xint SetCharacterClassRange (low, high, value)
X register int low, high; /* in range of [0..255] */
X register int value; /* arbitrary */
X{
X
X if (low < 0 || high > 255 || high < low) return (-1);
X
X for (; low <= high; low++) charClass[low] = value;
X
X return (0);
X}
X
X
XComputeSelect(startRow, startCol, endRow, endCol, extend)
Xint startRow, startCol, endRow, endCol;
XBool extend;
X{
X register TScreen *screen = &term->screen;
X register Char *ptr;
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 {
X ptr = screen->buf[4*(startSRow+screen->topline)]
X + startSCol;
X class = charClass[*ptr];
X do {
X --startSCol;
X --ptr;
X } while (startSCol >= 0
X && charClass[*ptr] == class);
X ++startSCol;
X }
X if (endSCol > (LastTextCol(endSRow) + 1)) {
X endSCol = 0;
X endSRow++;
X } else {
X length = LastTextCol(endSRow);
X ptr = screen->buf[4*(endSRow+screen->topline)]
X + endSCol;
X class = charClass[*ptr];
X do {
X ++endSCol;
X ++ptr;
X } while (endSCol <= length
X && charClass[*ptr] == class);
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}
X
X
XTrackText(frow, fcol, trow, tcol)
Xregister int frow, fcol, trow, tcol;
X/* Guaranteed (frow, fcol) <= (trow, tcol) */
X{
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}
X
XReHiliteText(frow, fcol, trow, tcol)
Xregister int frow, fcol, trow, tcol;
X/* Guaranteed that (frow, fcol) <= (trow, tcol) */
X{
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}
X
XSaltTextAway(crow, ccol, row, col, params, num_params)
X/*register*/ int crow, ccol, row, col;
XString *params; /* selections */
XCardinal num_params;
X/* Guaranteed that (crow, ccol) <= (row, col), and that both points are valid
X (may have row = screen->max_row+1, col = 0) */
X{
X register TScreen *screen = &term->screen;
X register int i, j = 0;
X int eol;
X char *line, *lp;
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
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) {
X if((line = malloc((unsigned) j + 1)) == (char *)NULL)
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
X line[j] = '\0'; /* make sure it is null terminated */
X lp = line; /* lp points to where to save the text */
X if ( row == crow ) lp = SaveText(screen, row, ccol, col, lp, &eol);
X else {
X lp = SaveText(screen, crow, ccol, screen->max_col, lp, &eol);
X if (eol)
X *lp ++ = '\n'; /* put in newline at end of line */
X for(i = crow +1; i < row; i++) {
X lp = SaveText(screen, i, 0, screen->max_col, lp, &eol);
X if (eol)
X *lp ++ = '\n';
X }
X if (col >= 0)
X lp = SaveText(screen, row, 0, col, lp, &eol);
X }
X *lp = '\0'; /* make sure we have end marked */
X
X screen->selection_length = (lp - line);
X _OwnSelection(term, params, num_params);
X}
X
Xstatic Boolean ConvertSelection(w, selection, target,
X type, value, length, format)
XWidget w;
XAtom *selection, *target, *type;
Xcaddr_t *value;
Xunsigned long *length;
Xint *format;
X{
X Display* d = XtDisplay(w);
X XtermWidget xterm = (XtermWidget)w;
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)) {
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;
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)
X *(long*)*value = xterm->screen.selection_length;
X else {
X long temp = xterm->screen.selection_length;
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
X
Xstatic void LoseSelection(w, selection)
X Widget w;
X Atom *selection;
X{
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
X
X/* ARGSUSED */
Xstatic void SelectionDone(w, selection, target)
XWidget w;
XAtom *selection, *target;
X{
X /* empty proc so Intrinsics know we want to keep storage */
X}
X
X
Xstatic /* void */ _OwnSelection(term, selections, count)
Xregister XtermWidget term;
XString *selections;
XCardinal count;
X{
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)
X XStoreBuffer( XtDisplay((Widget)term), term->screen.selection,
X term->screen.selection_length, buffer );
X else if (!replyToEmacs) {
X have_selection |=
X XtOwnSelection( (Widget)term, atoms[i],
X term->screen.selection_time,
X ConvertSelection, LoseSelection, SelectionDone );
X }
X }
X if (!replyToEmacs)
X term->screen.selection_count = count;
X if (!have_selection)
X TrackText(0, 0, 0, 0);
X}
X
X/* void */ DisownSelection(term)
Xregister XtermWidget term;
X{
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
X
X/* returns number of chars in line from scol to ecol out */
Xint Length(screen, row, scol, ecol)
Xregister int row, scol, ecol;
Xregister TScreen *screen;
X{
X register Char *ch;
X
X ch = screen->buf[4 * (row + screen->topline)];
X while (ecol >= scol && (ch[ecol] == ' ' || ch[ecol] == 0))
X ecol--;
X return (ecol - scol + 1);
X}
X
X/* copies text into line, preallocated */
Xchar *SaveText(screen, row, scol, ecol, lp, eol)
Xint row;
Xint scol, ecol;
XTScreen *screen;
Xregister char *lp; /* pointer to where to put the text */
Xint *eol;
X{
X register int i = 0;
X register Char *ch = screen->buf[4 * (row + screen->topline)];
X Char attr;
X int oldecol = ecol;
X register int c;
X
X *eol = 1;
X if ((i = Length(screen, row, scol, ecol)) == 0) return(lp);
X ecol = scol + i;
X *eol = (ecol < oldecol) ? 1 : 0;
X if (*eol == 0) {
X if(ScrnGetAttributes(screen, row, ecol - 1, &attr, 1) == 1) {
X *eol = (attr & ENDLINE) ? 1 : 0;
X } else {
X /* If we can't get the attributes, assume ENDLINE */
X /* CANTHAPPEN */
X (void)fprintf(stderr, "%s: no attributes for %d, %d\n",
X xterm_name, row, ecol - 1);
X *eol = 1;
X }
X }
X for (i = scol; i < ecol; i++) {
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;
X }
X return(lp);
X}
X
XEditorButton(event)
Xregister XButtonEvent *event;
X{
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
X
X/*ARGSUSED*/
Xvoid HandleGINInput (w, event, param_list, nparamsp)
X Widget w;
X XEvent *event;
X String *param_list;
X Cardinal *nparamsp;
X{
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
X
X/* ARGSUSED */
Xvoid 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{
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);
X}
END_OF_FILE
if test 38111 -ne `wc -c <'xterm/button.c'`; then
echo shar: \"'xterm/button.c'\" unpacked with wrong size!
fi
# end of 'xterm/button.c'
fi
echo shar: End of archive 2 \(of 14\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 14 archives.
rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0
dan
----------------------------------------------------
O'Reilly && Associates argv at sun.com / argv at ora.com
Opinions expressed reflect those of the author only.
More information about the Comp.sources.x
mailing list