kterm-6.2.0.orig/ 40755 507 454 0 6171356171 12221 5ustar yosiakiauxkterm-6.2.0.orig/ConvProto.h100444 507 454 23131 5573557325 14447 0ustar yosiakiaux/* $Id: ConvProto.h,v 1.5 1991/10/24 04:12:41 ishisone Exp $ */ /* * Copyright (c) 1991 Software Research Associates, Inc. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Software Research Associates not be * used in advertising or publicity pertaining to distribution of the * software without specific, written prior permission. Software Research * Associates makes no representations about the suitability of this software * for any purpose. It is provided "as is" without express or implied * warranty. * * Author: Makoto Ishisone, Software Research Associates, Inc., Japan */ #ifndef _ConvProto_h #define _ConvProto_h /* $BJQ49%5!<%P$N%W%m%U%!%$%k$,F~$k%W%m%Q%F%#L>(B */ #define CONVERSION_PROFILE "_CONVERSION_PROFILE" /* $BJQ49%5!<%P$N%W%m%U%!%$%k$N%W%m%Q%F%#$HJQ49B0@-$N%W%m%Q%F%#$N%?%$%W(B */ #define CONVERSION_ATTRIBUTE_TYPE "_CONVERSION_ATTRIBUTE_TYPE" /* $B%W%m%H%3%k%P!<%8%g%sL>(B */ #define PROTOCOL_VERSION "PROTOCOL-2.0" #define CONV_ATTR(code,len) ((unsigned long)((code)<<16)+(len)) #define UPPER16U(data) (((data)>>16)&0xffff) #define UPPER16S(data) ((short)(((data)>>16)&0xffff)) #define LOWER16U(data) ((data)&0xffff) #define LOWER16S(data) ((short)((data)&0xffff)) #define CODE_OF_ATTR(head) UPPER16U(head) #define LENGTH_OF_ATTR(head) LOWER16U(head) /* * Conversion Profile Codes */ #define CONVPROF_PROTOCOL_VERSION 1 #define CONVPROF_SUPPORTED_STYLES 2 #define CONVPROF_SUPPORTED_EXTENSIONS 3 #define CONVPROF_EXTENSION_DATA 4 /* * Standard Conversion Attribute Codes (0-255) */ /* 0-127: can be specified at any time (startup and during conversion) */ #define CONVATTR_NONE 0 #define CONVATTR_INDIRECT 1 #define CONVATTR_FOCUS_WINDOW 2 #define CONVATTR_SPOT_LOCATION 3 #define CONVATTR_CLIENT_AREA 4 #define CONVATTR_STATUS_AREA 5 #define CONVATTR_COLORMAP 6 #define CONVATTR_COLOR 7 #define CONVATTR_BACKGROUND_PIXMAP 8 #define CONVATTR_LINE_SPACING 9 #define CONVATTR_FONT_ATOMS 10 #define CONVATTR_CURSOR 11 /* 128-255: can be specified only at startup time */ #define CONVATTR_INPUT_STYLE 128 #define CONVATTR_EVENT_CAPTURE_METHOD 129 #define CONVATTR_USE_EXTENSION 255 /* argument for CONVATTR_INPUT_STYLE and CONVPROP_SUPPORTED_STYLES */ #define CONVARG_ROOTWINDOW 1L #define CONVARG_OFFTHESPOT 2L #define CONVARG_OVERTHESPOT 4L /* argument for CONVATTR_EVENT_CAPTURE_METHOD */ #define CONVARG_NONE 0L #define CONVARG_CREATE_INPUTONLY 1L #define CONVARG_SELECT_FOCUS_WINDOW 2L /* * $B%W%m%U%!%$%k%G!<%?(B / $BJQ49B0@-%G!<%?$NI=8=J}K!(B * * $BJQ49%5!<%P$NFC@-$rI=$9%W%m%U%!%$%k%G!<%?$H!"JQ49$K4X$9$kB0@-$r;XDj$9(B * $B$kJQ49B0@-%G!<%?$O6&DL$N%U%)!<%^%C%H$rMQ$$$k!#(B * * $B8D!9$N%G!<%?$O(B 32bit$BCM$NG[Ns$GI=8=$5$l$k!#:G=i$N(B 1$B%o!<%I$O%X%C%@$G!"(B * $B$=$l$K(B 0$B%o!<%I0J>e$N%G!<%?$,B3$/!#%X%C%@$N>e0L(B 16bit $B$O$=$N%W%m%U%!%$(B * $B%k(B / $BJQ49B0@-$N%3!<%I$rI=$7!"2<0L(B 16 bit $B$OB3$/%G!<%?$N%o!<%I?t(B * (32bit $BC10L(B) $B$rI=$9!#(B * * +----------------+----------------+ * | Code (16bit) | Length (16bit) | * +----------------+----------------+ * | Data0 | * +---------------------------------+ * | ..... | * +---------------------------------+ * | DataN | * +---------------------------------+ * * $B!H(B) $B$rMQ$$$F$"$i$+(B * $B$8$a@k8@$9$kI,MW$,$"$k!#(B * * $BB0@-%G!<%?$N;XDjJ}K!$K$O!"JQ493+;O;~$K;XDj$9$kJ}K!$H!"JQ49Cf$K;XDj$9(B * $B$kJ}K!$N(B 2$BDL$j$,$"$k$,!"B0@-%3!<%I$K$h$C$F$OJQ493+;O;~$K$7$+;XDj$G$-(B * $B$J$$$b$N$,$"$k!#$=$3$G!"(B0-255 $B$NI8=`%3!<%I$N$&$A!"(B0 $B$+$i(B 127 $B$^$G$OJQ(B * $B493+;O;~$G$bJQ49Cf$G$b;XDj$G$-$k$b$N!"(B128 $B$+$i(B 255 $B$^$G$OJQ493+;O;~$K(B * $B$7$+;XDj$G$-$J$$$b$N!"$KJ,$1$F$"$k!#3HD%%3!<%I$K$D$$$F$OFC$K$3$N$h$&(B * $B$J6hJL$ODj$a$J$$!#(B * * $B$3$N%W%m%H%3%k$GDj5A$5$l$kB0@-%3!<%I$O$C$FB0@-$r@_Dj$9$k!#(BCONVERSION_ATTRIBUTE * $B%$%Y%s%H$GJ#?t$NB0@-%G!<%?$r@_Dj$7$?$$;~$d!"%$%Y%s%H$KB0@-%G!<%?$,(B * $BF~$j@Z$i$J$$;~$K;HMQ$9$k!#(B * * Focus Window: * code: 2 * data-length: 1 * data[0]: * CARD32: focus window (Window) * * $B%U%)!<%+%9%&%#%s%I%&$r;XDj$9$k!#(B * * Spot Location: * data-length: 1 * data[0]: * INT16(upper 16bit): X * INT16(lower 16bit): Y * * $B%9%]%C%H%m%1!<%7%g%s$r;XDj$9$k!#%Y!<%9%i%$%s$N3+;OE@$G;XDj$9$k!#(B * * Client Area: * data-length: 2 * data[0]: * INT16(upper 16bit): X * INT16(lower 16bit): Y * data[1]: * CARD16(upper 16bit): Width * CARD16(lower 16bit): Height * * $BJQ49%F%-%9%HI=<(NN0h$r;XDj$9$k!#(B * * Status Area: * data-length: 2 * data[0]: * INT16(upper 16bit): X * INT16(lower 16bit): Y * data[1]: * CARD16(upper 16bit): Width * CARD16(lower 16bit): Height * * $B%9%F!<%?%9I=<(NN0h$r;XDj$9$k!#(B * * Colormap: * data-length: 1 * data[0]: * CARD32: colormap (XID) * * $B%+%i!<%^%C%W(B ID $B$r;XDj$9$k!#(B * * Color: * data-length: 2 * data[0]: * CARD32: foreground pixel * data[1]: * CARD32: background pixel * * $B%U%)%"%0%i%&%s%I$H%P%C%/%0%i%&%s%I$N%T%/%;%kCM$r;XDj$9$k!#(B * * Background Pixmap: * data-length: 1 * data[0]: * CARD32: background pixmap (Pixmap) * * $B%P%C%/%0%i%&%s%I$N(B Pixmap ID $B$r;XDj$9$k!#(B * * Line Spacing: * data-length: 1 * data[0]: * CARD32: line spacing * * $B9T4V$r;XDj$9$k!#%Y!<%9%i%$%s4V$N5wN%$G;XDj$9$k!#(B * * Font Atoms: * data-length: N (>0) * data[0]: * CARD32: font atom 1 (Atom) * ... * data[N-1]: * CARD32: font atom N (Atom) * * $B;HMQ$9$k%U%)%s%H$N(B "FONT" $B%"%H%`$N%j%9%H$r;XDj$9$k!#(B * * Cursor: * data-length: 1 * data[0]: * CARD32: cursor (Cursor) * * $B%+!<%=%k(B ID $B$r;XDj$9$k!#(B * * -- $BJQ493+;O;~$N$_;XDj$G$-$k$b$N(B -- * * Input Style: * data-length: 1 * data[0]: * CARD32: input style * * $BF~NOJ}K!$r;XDj$9$k!#(B * $B%G%U%)%k%H$O(B Root Window Style $B$G$"$k!#(B * * Event Capture Method: * data-length: 1 * data[0]: * CARD32: event capture method * * $B%/%i%$%"%s%H%&%#%s%I%&$+$i$N%$%Y%s%H$N$NJ}K!$H$7$F$O!"(B * $B%U%)!<%+%9%&%#%s%I%&(B ($B%U%)!<%+%9%&%#%s%I%&$,;XDj$5$l$F$$$J$1$l$P(B * $B%/%i%$%"%s%H%&%#%s%I%&(B) $B$N%-!<%$%Y%s%H$rD>@\%;%l%/%H$9$k(B ($B$3$N>l(B * $B9g!"JQ49Cf$O%/%i%$%"%s%H$O%-!<%$%Y%s%H$rL5;k$7$J$/$F$O$J$i$J$$(B) * $B$b$N$H!"2?$b$7$J$$!"$D$^$jJQ49Cf$N%/%i%$%"%s%H$O%-!<%$%Y%s%H$r%U(B * $B%m%s%H%(%s%I$K(B SendEvent $B$7$J$/$F$O$J$i$J$$!"$H$$$&J}K!$,$"$k!#(B * * Use Extension: * data-length: N * data[0]: * CARD32: extension atom 1 (Atom) * ... * data[N-1]: * CARD32: extension atom N (Atom) * * $B$3$NB0@-@_Dj$G;HMQ$5$l$k3HD%$r;XDj$9$k!#$3$3$G;XDj$9$k3HD%$O%5!<(B * $B%P$,%5%]!<%H$7$F$$$k$b$N!"$D$^$j%W%m%U%!%$%k%G!<%?Cf$N(BSupported * Extensions $B$K=q$+$l$?3HD%$G$J$1$l$P$J$i$J$$!#(B */ #endif kterm-6.2.0.orig/DEMO.kt.uu100444 507 454 3674 6171110714 14031 0ustar yosiakiauxbegin 644 DEMO.kt M5&\@'EZ>WQ]?ALH0@DH15-#("@@0BD*4U=%1$E32 D)&RA#(R1 M04)#+BXN6%E:6UQ=7E]@86)C+BXN>'EZ>WQ]?ALH0@DH15-#("@@0RD*3D]2 M5T5'24%."1LH12,D0$%"0RXN+EA96EM<75Y?8&%B8RXN+GAY>GM\?7X;*$() M*$530R H($4I"DM!3D$)"1LH22,D0$%"0RXN+EA96EM<75Y?8&%B8RXN+GAY M>GM\?7X;*$()*$530R H($DI"DI)4U)/34%."1LH2B,D0$%"0RXN+EA96EM< M75Y?8&%B8RXN+GAY>GM\?7X;*$()*$530R H($HI"D=%4DU!3@D)&RA+(R1 M04)#+BXN6%E:6UQ=7E]@86)C+BXN>'EZ>WQ]?ALH0@DH15-#("@@2RD*1E)% M3D-("0D;*%(C)$!!0D,N+BY865I;7%U>7V!A8F,N+BYX>7I[?'U^&RA""2A% M4T,@*"!2*0I)5$%,24%."0D;*%DC)$!!0D,N+BY865I;7%U>7V!A8F,N+BYX M>7I[?'U^&RA""2A%4T,@*"!9*0I34$%.25-("0D;*%HC)$!!0D,N+BY865I; M7%U>7V!A8F,N+BYX>7I[?'U^&RA""2A%4T,@*"!:*0H*3$%424XQ4@D)&RU! M#D%"0T1%1D=(24I+3%U>86)C9&5F9VAI:FML?7X;)"E"#R H15-#("T@02!3 M3RD*3$%424XR4@D)&RU"#D%"0T1%1D=(24I+3%U>86)C9&5F9VAI:FML?7X; M)"E"#R H15-#("T@0B!33RD*3$%424XS4@D)&RU##D%"0T1%1D=(24I+3%U> M86)C9&5F9VAI:FML?7X;)"E"#R H15-#("T@0R!33RD*3$%424XT4@D)&RU$ M#D%"0T1%1D=(24I+3%U>86)C9&5F9VAI:FML?7X;)"E"#R H15-#("T@1"!3 M3RD*0UE224Q,24,)&RU,#D%"0T1%1D=(24I+3%U>86)C9&5F9VAI:FML?7X; M)"E"#R H15-#("T@3"!33RD*05)!0DE#"0D;+4<.04)#1$5&1TA)2DM,75YA M8F-D969G:&EJ:VQ]?ALD*4(/("A%4T,@+2!'(%-/*0I'4D5%2PD)&RU&#D%" M0T1%1D=(24I+3%U>86)C9&5F9VAI:FML?7X;)"E"#R H15-#("T@1B!33RD* M2$5"4D57"0D;+4@.04)#1$5&1TA)2DM,75YA8F-D969G:&EJ:VQ]?ALD*4(/ M("A%4T,@+2!((%-/*0I,051)3C52"0D;+4T.04)#1$5&1TA)2DM,75YA8F-D M969G:&EJ:VQ]?ALD*4(/("A%4T,@+2!-(%-/*0H*0VAI;F5S90D)&R1!5E!. M1"$A(2$P(3 B,",P)!LH0B H15-#("0@02D*2F%P86YE= 1 LDOVERRIDE = -L$(DESTDIR)$(USRLIBDIR) #else #if HasGcc LDOVERRIDE = -static -L$(DESTDIR)$(USRLIBDIR) #else LDOVERRIDE = -Bstatic -L$(DESTDIR)$(USRLIBDIR) LDRESUME = -Bdynamic #endif #endif #endif install:: kterm MakeDir($(DESTDIR)$(BINDIR)) RemoveFile(kterm.inst) LinkRule(kterm.inst,$(CDEBUGFLAGS) $(CCOPTIONS) $(EXTRA_LDOPTIONS) $(LOCAL_LDFLAGS),$(OBJS1),$(LDOVERRIDE) XawClientLibs $(LDRESUME) $(LDLIBS) $(TERMCAPLIB) $(PTYLIB)) $(INSTALL) -c $(INSTPGMFLAGS) $(INSTUIDFLAGS) kterm.inst $(DESTDIR)$(BINDIR)/kterm RemoveFile(kterm.inst) #else #if InstallXtermSetUID InstallProgramWithFlags(kterm,$(BINDIR),$(INSTUIDFLAGS)) #else InstallProgramWithFlags(kterm,$(BINDIR),NullParameter) #endif #endif InstallAppDefaults(KTerm) InstallManPage(kterm,$(MANDIR)) DependTarget() kterm-6.2.0.orig/KTerm.ad100444 507 454 11304 6163174626 13667 0ustar yosiakiaux! $XConsortium: XTerm.ad,v 1.32 94/02/09 18:19:21 converse Exp $ ! $Id: KTerm.ad,v 6.2 1996/06/23 08:00:09 kagotani Rel $ KTerm.JoinSession:False *SimpleMenu*BackingStore: NotUseful *SimpleMenu*menuLabel.font: -adobe-helvetica-bold-r-normal--*-120-*-*-*-*-iso8859-* *SimpleMenu*menuLabel.vertSpace: 100 *SimpleMenu*HorizontalMargins: 16 *SimpleMenu*Sme.height: 16 *SimpleMenu*Cursor: left_ptr *mainMenu.Label: Main Options *mainMenu*securekbd*Label: Secure Keyboard *mainMenu*allowsends*Label: Allow SendEvents *mainMenu*logging*Label: Log to File *mainMenu*redraw*Label: Redraw Window *mainMenu*suspend*Label: Send STOP Signal *mainMenu*continue*Label: Send CONT Signal *mainMenu*interrupt*Label: Send INT Signal *mainMenu*hangup*Label: Send HUP Signal *mainMenu*terminate*Label: Send TERM Signal *mainMenu*kill*Label: Send KILL Signal *mainMenu*quit*Label: Quit *vtMenu.Label: VT Options *vtMenu*scrollbar*Label: Enable Scrollbar *vtMenu*jumpscroll*Label: Enable Jump Scroll *vtMenu*reversevideo*Label: Enable Reverse Video *vtMenu*autowrap*Label: Enable Auto Wraparound *vtMenu*reversewrap*Label: Enable Reverse Wraparound *vtMenu*autolinefeed*Label: Enable Auto Linefeed *vtMenu*appcursor*Label: Enable Application Cursor Keys *vtMenu*appkeypad*Label: Enable Application Keypad *vtMenu*scrollkey*Label: Scroll to Bottom on Key Press *vtMenu*scrollttyoutput*Label: Scroll to Bottom on Tty Output *vtMenu*allow132*Label: Allow 80/132 Column Switching *vtMenu*cursesemul*Label: Enable Curses Emulation *vtMenu*visualbell*Label: Enable Visual Bell *vtMenu*marginbell*Label: Enable Margin Bell *vtMenu*altscreen*Label: Show Alternate Screen *vtMenu*softreset*Label: Do Soft Reset *vtMenu*hardreset*Label: Do Full Reset *vtMenu*clearsavedlines*Label: Reset and Clear Saved Lines *vtMenu*tekshow*Label: Show Tek Window *vtMenu*tekmode*Label: Switch to Tek Mode *vtMenu*vthide*Label: Hide VT Window *vtMenu*statusline*Label: Enable Status Line *vtMenu*reversestatus*Label: Status Line Reverse Video *vtMenu*eucmode*Label: Japanese EUC Mode *vtMenu*sjismode*Label: Shift-JIS Mode *vtMenu*openim*Label: Open Input Method *fontMenu.Label: VT Fonts *fontMenu*fontdefault*Label: Default *VT100*fontList: -*-fixed-medium-r-normal--14-*,\ -*-gothic-medium-r-normal--14-*,\ -*-mincho-medium-r-normal--14-* !*VT100*boldFontList: -*-fixed-bold-r-normal--14-*,\ ! -*-gothic-bold-r-normal--14-*,\ ! -*-mincho-bold-r-normal--14-* *fontMenu*font1*Label: Unreadable *VT100*fontList1: -*-fixed-medium-r-normal--2-*,\ -*-gothic-medium-r-normal--2-*,\ -*-mincho-medium-r-normal--2-* *VT100*font1: -misc-nil-medium-r-normal--2-*-misc-fontspecific *fontMenu*font2*Label: Tiny *VT100*fontList2: -*-fixed-medium-r-normal--14-*,\ -*-gothic-medium-r-normal--14-*,\ -*-mincho-medium-r-normal--14-* *fontMenu*font3*Label: Small *VT100*fontList3: -*-fixed-medium-r-normal--16-*,\ -*-gothic-medium-r-normal--16-*,\ -*-mincho-medium-r-normal--16-* *fontMenu*font4*Label: Medium *VT100*fontList4: -*-fixed-medium-r-normal--18-*,\ -*-gothic-medium-r-normal--18-*,\ -*-mincho-medium-r-normal--18-* *fontMenu*font5*Label: Large *VT100*fontList5: -*-fixed-medium-r-normal--24-*,\ -*-gothic-medium-r-normal--24-*,\ -*-mincho-medium-r-normal--24-* *fontMenu*font6*Label: Huge *VT100*fontList6: -*-fixed-medium-r-normal--26-*,\ -*-gothic-medium-r-normal--26-*,\ -*-mincho-medium-r-normal--26-* *fontMenu*fontescape*Label: Escape Sequence *fontMenu*fontsel*Label: Selection !fontescape and fontsel overridden by application ! You can specify a font for some specific character sets as follows !*VT100*font3: -*-*-medium-r-normal--16-*-iso8859-1 !*VT100*romanKanaFont3: -*-*-medium-r-normal--16-*-jisx0201.1976-0 !*VT100*kanjiFont3: -*-*-medium-r-normal--16-*-jisx0208.1983-0 !*VT100*boldFont3: -*-*-bold-r-normal--16-*-iso8859-1 !*VT100*romanKanaBoldFont3: -*-*-bold-r-normal--16-*-jisx0201.1976-0 !*VT100*kanjiBoldFont3: -*-*-bold-r-normal--16-*-jisx0208.1983-0 !*VT100*kanjiMode: jis !*VT100*lineSpace: 0 !*VT100*textColor0: Black !*VT100*textColor1: Red !*VT100*textColor2: Green !*VT100*textColor3: Yellow !*VT100*textColor4: Blue !*VT100*textColor5: Magenta !*VT100*textColor6: Cyan !*VT100*textColor7: White *tekMenu.Label: Tek Options *tekMenu*tektextlarge*Label: Large Characters *tekMenu*tektext2*Label: #2 Size Characters *tekMenu*tektext3*Label: #3 Size Characters *tekMenu*tektextsmall*Label: Small Characters *tekMenu*tekpage*Label: PAGE *tekMenu*tekreset*Label: RESET *tekMenu*tekcopy*Label: COPY *tekMenu*vtshow*Label: Show VT Window *tekMenu*vtmode*Label: Switch to VT Mode *tekMenu*tekhide*Label: Hide Tek Window *tek4014*fontLarge: 9x15 *tek4014*font2: 8x13 *tek4014*font3: 6x13 *tek4014*fontSmall: 6x10 kterm-6.2.0.orig/README.kt100444 507 454 10132 6171352674 13632 0ustar yosiakiaux--------------------------- README file for kterm-6.2.0 --------------------------- Kterm is an X11 terminal emulator that can handle multi-lingual text. This release is based on xterm of X11R6.1. Changes in this release ----------------------- o Kterm now handles multi-lingual text in addition to Japanese. o Kterm now supports X Input Method protocol in addition to kinput2 protocol. o Fonts are loaded dynamically by default. o Tektronix emulation is disabled by default configuration. o Many bug fixes. Configuration ------------- You can disable any of the features added to xterm by editing Imakefile and kterm.h. Imakefile: o KTERM: enables kterm features. see kterm.h part. o STATUSLINE: enables statusline support. o KEEPALIVE: enables keepalive socket option for the server connection. kterm.h: o KTERM_MBCS: enables support for MBCS text. o KTERM_MBCC: enables MB character class support. It is used for word selection. KTERM_MBCS must be defined. o KTERM_KANJIMODE: enables support for Kanji specific encodings, Japanese EUC and Shift-JIS. KTERM_MBCS must be defined. o KTERM_XIM: enables support for Kanji text input using X Input Method protocol. KTERM_MBCS must be defined. o KTERM_KINPUT2: enables support for Kanji text input using kinput2 protocol. KTERM_MBCS must be defined. o KTERM_COLOR: enables colored text support. o KTERM_NOTEK: disables Tektronix emulation. o KTERM_XAW3D: enables kterm to work with the Xaw3d library compiled with -DARROW_SCROLLBAR option (disables by default). Compilation ----------- This kterm basically needs X11R6.1 libraries and include files. In X11R6.1 environment, just type: % xmkmf -a; make In X11R6 environment, if you have some luck (your system supports fd_set type and FD_* macros), you can compile kterm without modification. Installation ------------ Install kterm and KTerm.ad: % make install Install kterm.man manual page: % make install.man If your system supports Japanese manual pages and you want to install kterm.jman, copy it to an appropriate directory/filename in an appropriate encoding by hand. Note that kterm.jman is encoded in JIS code. If your system does not have kterm entry in the termcap or terminfo, you may want to install termcap.kt or terminfo.kt by hand. Supported Systems ----------------- kterm-6.2.0 should be successfully built on the following systems: sparc SunOS 4.1.x (*1) SunOS 4.1.x-JLE* Solaris 2.x Solaris 2.xJ NetBSD-1.1B/sparc NetBSD/sparc-1.2_ALPHA UXP/DS V20L10 Y96021 [Fujitsu DS/90 7000] i386 Solaris 2.5 x86 NetBSD1.1 NetBSD/{i386,pc98} 1.2_ALPHA FreeBSD(98)2.1R Alpha (XFree86 3.1.2Eb) (*2) FreeBSD 2.2-96{0323,0612}-SNAP (XFree86 3.1.2E) (*2) (*3) BSD/OS 2.1 Linux-2.0.0 ELF libc 5.3.12 sony NEWS-OS 4.2.1a+RD NEWS-OS 6.0.2 sgi IRIX 5.3 {,IP22} IRIX 6.1 hp HP-UX 9.0[57] (with -DX_LOCALE, cc) HP-UX 10.01 dec OSF/1 3.0 [DEC 7000 AXP system 620] OSF/1 3.2A [DEC 3000/500] Digital UNIX 3.2C [DEC AlphaStation 200 4/100] Digital UNIX 3.2D [DEC AlphaServer 2100 4/275] *** does not work on DEC 3000 running DEC OSF/1 2.0 *** *1 Kterm and X libraries must be compiled with -DX_LOCALE to use XIM. *2 Kterm must be compiled with -DUSE_POSIX_WAIT to eliminate a warning. *3 Kterm must be linked with -lxpg4 to use XIM. CAUTION ------- Killing an IM server while it is establishing connection with a kterm, or on a kterm which is connected with the server may hang the kterm (because of imperfection around IM handling in Xlib). To Do ----- o Use of fontSet resources. o More ISO6429 attributes. Bug report ---------- If you find any bug, please make sure that it is not an xterm's bug, then report it to kagotani@in.it.okayama-u.ac.jp. Don't forget to include the version of kterm (see kterm.h or do "kterm -version") and information about your system. Enhancement ----------- If you would like to distribute your local enhancement, please change the version number to something like "6.2.0-yourname1". July 12, 1996 Hiroto Kagotani kagotani@in.it.okayama-u.ac.jp kterm-6.2.0.orig/TekPrsTbl.c100444 507 454 147430 5765737007 14414 0ustar yosiakiaux/* * $XConsortium: TekPrsTbl.c,v 1.8 95/06/08 23:20:39 gildea Exp $ */ /* * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ #include "Tekparse.h" #ifdef __STDC__ #define Const const #else #define Const /**/ #endif Const int Talptable[] = /* US (^_) normal alpha mode */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_BEL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_LF, CASE_UP, /* NP CR SO SI */ CASE_IGNORE, CASE_CR, CASE_IGNORE, CASE_IGNORE, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_ESC_STATE, /* FS GS RS US */ CASE_PT_STATE, CASE_PLT_STATE, CASE_IPL_STATE, CASE_ALP_STATE, /* SP ! " # */ CASE_SP, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* $ % & ' */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* ( ) * + */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* , - . / */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* 0 1 2 3 */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* 4 5 6 7 */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* 8 9 : ; */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* < = > ? */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* @ A B C */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* D E F G */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* H I J K */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* L M N O */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* P Q R S */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* T U V W */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* X Y Z [ */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* \ ] ^ _ */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* ` a b c */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* d e f g */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* h i j k */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* l m n o */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* p q r s */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* t u v w */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* x y z { */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* | } ~ DEL */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* currency yen brokenbar section */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* diaeresis copyright ordfeminine guillemotleft */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* notsign hyphen registered macron */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* degree plusminus twosuperior threesuperior */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* acute mu paragraph periodcentered */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* cedilla onesuperior masculine guillemotright */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* onequarter onehalf threequarters questiondown */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Agrave Aacute Acircumflex Atilde */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Adiaeresis Aring AE Ccedilla */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Eth Ntilde Ograve Oacute */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Udiaeresis Yacute Thorn ssharp */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* agrave aacute acircumflex atilde */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* adiaeresis aring ae ccedilla */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* egrave eacute ecircumflex ediaeresis */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* igrave iacute icircumflex idiaeresis */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* eth ntilde ograve oacute */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* ocircumflex otilde odiaeresis division */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* oslash ugrave uacute ucircumflex */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* udiaeresis yacute thorn ydiaeresis */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, }; Const int Tbestable[] = /* ESC while in bypass state */ { /* NUL SOH STX ETX */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_VT_MODE, /* EOT ENQ ACK BEL */ CASE_BYP_STATE, CASE_REPORT, CASE_BYP_STATE, CASE_BEL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_IGNORE, CASE_UP, /* NP CR SO SI */ CASE_PAGE, CASE_IGNORE, CASE_BYP_STATE, CASE_BYP_STATE, /* DLE DC1 DC2 DC3 */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* DC4 NAK SYN ETB */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_COPY, /* CAN EM SUB ESC */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_GIN, CASE_IGNORE, /* FS GS RS US */ CASE_SPT_STATE, CASE_PLT_STATE, CASE_IPL_STATE, CASE_ALP_STATE, /* SP ! " # */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* $ % & ' */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* ( ) * + */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* , - . / */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* 0 1 2 3 */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* 4 5 6 7 */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* 8 9 : ; */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* < = > ? */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* @ A B C */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* D E F G */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* H I J K */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* L M N O */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* P Q R S */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* T U V W */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* X Y Z [ */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* \ ] ^ _ */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* ` a b c */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* d e f g */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* h i j k */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* l m n o */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* p q r s */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* t u v w */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* x y z { */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* | } ~ DEL */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_IGNORE, CASE_BYP_STATE, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* currency yen brokenbar section */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* notsign hyphen registered macron */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* degree plusminus twosuperior threesuperior */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* acute mu paragraph periodcentered */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* cedilla onesuperior masculine guillemotright */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* onequarter onehalf threequarters questiondown */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* Agrave Aacute Acircumflex Atilde */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* Eth Ntilde Ograve Oacute */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* agrave aacute acircumflex atilde */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* adiaeresis aring ae ccedilla */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* eth ntilde ograve oacute */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* ocircumflex otilde odiaeresis division */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* oslash ugrave uacute ucircumflex */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, }; Const int Tbyptable[] = /* ESC CAN (^X) bypass state */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_BEL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_LF, CASE_UP, /* NP CR SO SI */ CASE_IGNORE, CASE_CR, CASE_IGNORE, CASE_IGNORE, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_BES_STATE, /* FS GS RS US */ CASE_PT_STATE, CASE_PLT_STATE, CASE_IPL_STATE, CASE_ALP_STATE, /* SP ! " # */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* $ % & ' */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ( ) * + */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* , - . / */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0 1 2 3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 4 5 6 7 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 8 9 : ; */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* < = > ? */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* @ A B C */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* D E F G */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* H I J K */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* L M N O */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* P Q R S */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* T U V W */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* X Y Z [ */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* \ ] ^ _ */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ` a b c */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* d e f g */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* h i j k */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* l m n o */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* p q r s */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* t u v w */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* x y z { */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* | } ~ DEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* currency yen brokenbar section */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* notsign hyphen registered macron */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* acute mu paragraph periodcentered */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* cedilla onesuperior masculine guillemotright */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* onequarter onehalf threequarters questiondown */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Adiaeresis Aring AE Ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Eth Ntilde Ograve Oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Udiaeresis Yacute Thorn ssharp */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* agrave aacute acircumflex atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* adiaeresis aring ae ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* egrave eacute ecircumflex ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* igrave iacute icircumflex idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* eth ntilde ograve oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ocircumflex otilde odiaeresis division */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* oslash ugrave uacute ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* udiaeresis yacute thorn ydiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, }; Const int Tesctable[] = /* ESC */ { /* NUL SOH STX ETX */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_VT_MODE, /* EOT ENQ ACK BEL */ CASE_CURSTATE, CASE_REPORT, CASE_CURSTATE, CASE_BEL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_IGNORE, CASE_UP, /* NP CR SO SI */ CASE_PAGE, CASE_IGNORE, CASE_APL, CASE_ASCII, /* DLE DC1 DC2 DC3 */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* DC4 NAK SYN ETB */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_COPY, /* CAN EM SUB ESC */ CASE_BYP_STATE, CASE_CURSTATE, CASE_GIN, CASE_IGNORE, /* FS GS RS US */ CASE_SPT_STATE, CASE_PLT_STATE, CASE_IPL_STATE, CASE_ALP_STATE, /* SP ! " # */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* $ % & ' */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* ( ) * + */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* , - . / */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* 0 1 2 3 */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* 4 5 6 7 */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* 8 9 : ; */ CASE_CHAR_SIZE, CASE_CHAR_SIZE, CASE_CHAR_SIZE, CASE_CHAR_SIZE, /* < = > ? */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* @ A B C */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* D E F G */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* H I J K */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* L M N O */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* P Q R S */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* T U V W */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* X Y Z [ */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* \ ] ^ _ */ CASE_CURSTATE, CASE_OSC, CASE_CURSTATE, CASE_CURSTATE, /* ` a b c */ CASE_BEAM_VEC, CASE_BEAM_VEC, CASE_BEAM_VEC, CASE_BEAM_VEC, /* d e f g */ CASE_BEAM_VEC, CASE_CURSTATE, CASE_CURSTATE, CASE_BEAM_VEC, /* h i j k */ CASE_BEAM_VEC, CASE_BEAM_VEC, CASE_BEAM_VEC, CASE_BEAM_VEC, /* l m n o */ CASE_BEAM_VEC, CASE_CURSTATE, CASE_CURSTATE, CASE_BEAM_VEC, /* p q r s */ CASE_BEAM_VEC, CASE_BEAM_VEC, CASE_BEAM_VEC, CASE_BEAM_VEC, /* t u v w */ CASE_BEAM_VEC, CASE_CURSTATE, CASE_CURSTATE, CASE_BEAM_VEC, /* x y z { */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* | } ~ DEL */ CASE_CURSTATE, CASE_CURSTATE, CASE_IGNORE, CASE_CURSTATE, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* currency yen brokenbar section */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* notsign hyphen registered macron */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* acute mu paragraph periodcentered */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* cedilla onesuperior masculine guillemotright */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* onequarter onehalf threequarters questiondown */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Adiaeresis Aring AE Ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Eth Ntilde Ograve Oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Udiaeresis Yacute Thorn ssharp */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* agrave aacute acircumflex atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* adiaeresis aring ae ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* egrave eacute ecircumflex ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* igrave iacute icircumflex idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* eth ntilde ograve oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ocircumflex otilde odiaeresis division */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* oslash ugrave uacute ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* udiaeresis yacute thorn ydiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, }; Const int Tipltable[] = /* RS (^^) incremental plot */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_BEL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_LF, CASE_UP, /* NP CR SO SI */ CASE_IGNORE, CASE_CR, CASE_IGNORE, CASE_IGNORE, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_ESC_STATE, /* FS GS RS US */ CASE_PT_STATE, CASE_PLT_STATE, CASE_IPL_STATE, CASE_ALP_STATE, /* SP ! " # */ CASE_PENUP, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* $ % & ' */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ( ) * + */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* , - . / */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0 1 2 3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 4 5 6 7 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 8 9 : ; */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* < = > ? */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* @ A B C */ CASE_IGNORE, CASE_IPL_POINT, CASE_IPL_POINT, CASE_IGNORE, /* D E F G */ CASE_IPL_POINT, CASE_IPL_POINT, CASE_IPL_POINT, CASE_IGNORE, /* H I J K */ CASE_IPL_POINT, CASE_IPL_POINT, CASE_IPL_POINT, CASE_IGNORE, /* L M N O */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* P Q R S */ CASE_PENDOWN, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* T U V W */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* X Y Z [ */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* \ ] ^ _ */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ` a b c */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* d e f g */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* h i j k */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* l m n o */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* p q r s */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* t u v w */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* x y z { */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* | } ~ DEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* currency yen brokenbar section */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* notsign hyphen registered macron */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* acute mu paragraph periodcentered */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* cedilla onesuperior masculine guillemotright */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* onequarter onehalf threequarters questiondown */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Adiaeresis Aring AE Ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Eth Ntilde Ograve Oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Udiaeresis Yacute Thorn ssharp */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* agrave aacute acircumflex atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* adiaeresis aring ae ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* egrave eacute ecircumflex ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* igrave iacute icircumflex idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* eth ntilde ograve oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ocircumflex otilde odiaeresis division */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* oslash ugrave uacute ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* udiaeresis yacute thorn ydiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, }; Const int Tplttable[] = /* GS (^]) graph (plot) mode */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_BEL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_LF, CASE_UP, /* NP CR SO SI */ CASE_IGNORE, CASE_CR, CASE_IGNORE, CASE_IGNORE, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_ESC_STATE, /* FS GS RS US */ CASE_PT_STATE, CASE_PLT_STATE, CASE_IPL_STATE, CASE_ALP_STATE, /* SP ! " # */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* $ % & ' */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* ( ) * + */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* , - . / */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* 0 1 2 3 */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* 4 5 6 7 */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* 8 9 : ; */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* < = > ? */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* @ A B C */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* D E F G */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* H I J K */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* L M N O */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* P Q R S */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* T U V W */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* X Y Z [ */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* \ ] ^ _ */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* ` a b c */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* d e f g */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* h i j k */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* l m n o */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* p q r s */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* t u v w */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* x y z { */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* | } ~ DEL */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* currency yen brokenbar section */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* notsign hyphen registered macron */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* acute mu paragraph periodcentered */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* cedilla onesuperior masculine guillemotright */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* onequarter onehalf threequarters questiondown */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Adiaeresis Aring AE Ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Eth Ntilde Ograve Oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Udiaeresis Yacute Thorn ssharp */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* agrave aacute acircumflex atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* adiaeresis aring ae ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* egrave eacute ecircumflex ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* igrave iacute icircumflex idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* eth ntilde ograve oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ocircumflex otilde odiaeresis division */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* oslash ugrave uacute ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* udiaeresis yacute thorn ydiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, }; Const int Tpttable[] = /* FS (^\) point plot mode */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_BEL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_LF, CASE_UP, /* NP CR SO SI */ CASE_IGNORE, CASE_CR, CASE_IGNORE, CASE_IGNORE, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_ESC_STATE, /* FS GS RS US */ CASE_PT_STATE, CASE_PLT_STATE, CASE_IPL_STATE, CASE_ALP_STATE, /* SP ! " # */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* $ % & ' */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* ( ) * + */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* , - . / */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* 0 1 2 3 */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* 4 5 6 7 */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* 8 9 : ; */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* < = > ? */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* @ A B C */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* D E F G */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* H I J K */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* L M N O */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* P Q R S */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* T U V W */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* X Y Z [ */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* \ ] ^ _ */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* ` a b c */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* d e f g */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* h i j k */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* l m n o */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* p q r s */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* t u v w */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* x y z { */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* | } ~ DEL */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* currency yen brokenbar section */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* notsign hyphen registered macron */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* acute mu paragraph periodcentered */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* cedilla onesuperior masculine guillemotright */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* onequarter onehalf threequarters questiondown */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Adiaeresis Aring AE Ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Eth Ntilde Ograve Oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Udiaeresis Yacute Thorn ssharp */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* agrave aacute acircumflex atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* adiaeresis aring ae ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* egrave eacute ecircumflex ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* igrave iacute icircumflex idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* eth ntilde ograve oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ocircumflex otilde odiaeresis division */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* oslash ugrave uacute ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* udiaeresis yacute thorn ydiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, }; Const int Tspttable[] = /* ESC FS (^\) special point plot */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_BEL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_LF, CASE_UP, /* NP CR SO SI */ CASE_IGNORE, CASE_CR, CASE_IGNORE, CASE_IGNORE, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_ESC_STATE, /* FS GS RS US */ CASE_PT_STATE, CASE_PLT_STATE, CASE_IPL_STATE, CASE_ALP_STATE, /* SP ! " # */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* $ % & ' */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* ( ) * + */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* , - . / */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* 0 1 2 3 */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* 4 5 6 7 */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* 8 9 : ; */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* < = > ? */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* @ A B C */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* D E F G */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* H I J K */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* L M N O */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* P Q R S */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* T U V W */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* X Y Z [ */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* \ ] ^ _ */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* ` a b c */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* d e f g */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* h i j k */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* l m n o */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* p q r s */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* t u v w */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* x y z { */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* | } ~ DEL */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* currency yen brokenbar section */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* notsign hyphen registered macron */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* acute mu paragraph periodcentered */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* cedilla onesuperior masculine guillemotright */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* onequarter onehalf threequarters questiondown */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Adiaeresis Aring AE Ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Eth Ntilde Ograve Oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Udiaeresis Yacute Thorn ssharp */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* agrave aacute acircumflex atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* adiaeresis aring ae ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* egrave eacute ecircumflex ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* igrave iacute icircumflex idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* eth ntilde ograve oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ocircumflex otilde odiaeresis division */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* oslash ugrave uacute ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* udiaeresis yacute thorn ydiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, }; kterm-6.2.0.orig/Tekparse.def100444 507 454 1214 4311027741 14540 0ustar yosiakiaux# # $XConsortium: Tekparse.def,v 1.2 88/09/06 14:35:12 jim Exp $ # # List of symbols that need to be defined for Tekparse.h. If you need to # change any of the CASE_ macros, make the change here and rerun the command # shown in Tekparse.h. # CASE_REPORT CASE_VT_MODE CASE_SPT_STATE CASE_GIN CASE_BEL CASE_BS CASE_PT_STATE CASE_PLT_STATE CASE_TAB CASE_IPL_STATE CASE_ALP_STATE CASE_UP CASE_COPY CASE_PAGE CASE_BES_STATE CASE_BYP_STATE CASE_IGNORE CASE_ASCII CASE_APL CASE_CHAR_SIZE CASE_BEAM_VEC CASE_CURSTATE CASE_PENUP CASE_PENDOWN CASE_IPL_POINT CASE_PLT_VEC CASE_PT_POINT CASE_SPT_POINT CASE_CR CASE_ESC_STATE CASE_LF CASE_SP CASE_PRINT CASE_OSC kterm-6.2.0.orig/Tekparse.h100444 507 454 4551 4741661211 14243 0ustar yosiakiaux/* * $XConsortium: Tekparse.h,v 1.4 91/01/06 12:46:47 rws Exp $ */ /* * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ /* @(#)Tekparse.h X10/6.6 11/7/86 */ /* * The following list of definitions is generated from Tekparse.def using the * following command line: * * egrep -v '^CASE_' Tekparse.def | \ * awk 'BEGIN {n = 0;} {printf "#define %s %d\n", $1, n; n++}' * * You you need to change something, change Tekparse.def and regenerate the * definitions. This would have been automatic, but since this doesn't change * very often, it isn't worth the makefile hassle. */ #define CASE_REPORT 0 #define CASE_VT_MODE 1 #define CASE_SPT_STATE 2 #define CASE_GIN 3 #define CASE_BEL 4 #define CASE_BS 5 #define CASE_PT_STATE 6 #define CASE_PLT_STATE 7 #define CASE_TAB 8 #define CASE_IPL_STATE 9 #define CASE_ALP_STATE 10 #define CASE_UP 11 #define CASE_COPY 12 #define CASE_PAGE 13 #define CASE_BES_STATE 14 #define CASE_BYP_STATE 15 #define CASE_IGNORE 16 #define CASE_ASCII 17 #define CASE_APL 18 #define CASE_CHAR_SIZE 19 #define CASE_BEAM_VEC 20 #define CASE_CURSTATE 21 #define CASE_PENUP 22 #define CASE_PENDOWN 23 #define CASE_IPL_POINT 24 #define CASE_PLT_VEC 25 #define CASE_PT_POINT 26 #define CASE_SPT_POINT 27 #define CASE_CR 28 #define CASE_ESC_STATE 29 #define CASE_LF 30 #define CASE_SP 31 #define CASE_PRINT 32 #define CASE_OSC 33 kterm-6.2.0.orig/Tekproc.c100444 507 454 130204 6171356064 14130 0ustar yosiakiaux/* * $XConsortium: Tekproc.c /main/118 1996/01/14 16:52:29 kaleb $ * $Id: Tekproc.c,v 6.0 1996/07/12 05:01:39 kagotani Rel $ * * Warning, there be crufty dragons here. */ /* Copyright (c) 1988 X Consortium Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium. * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ /* Tekproc.c */ #include "ptyx.h" #include #include #include #include #include #include #include #ifndef NO_XPOLL_H #include #else #define XFD_COPYSET(src, dst) memmove((dst), (src), sizeof(fd_set)) #define Select select #endif #include #include #include #include #include "Tekparse.h" #include "data.h" #include "error.h" #include "menu.h" #ifdef X_NOT_STDC_ENV extern int errno; #define Time_t long extern Time_t time (); #else #include #define Time_t time_t #endif /* * Check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX * systems are broken and return EWOULDBLOCK when they should return EAGAIN. * Note that this macro may evaluate its argument more than once. */ #if defined(EAGAIN) && defined(EWOULDBLOCK) #define E_TEST(err) ((err) == EAGAIN || (err) == EWOULDBLOCK) #else #ifdef EAGAIN #define E_TEST(err) ((err) == EAGAIN) #else #define E_TEST(err) ((err) == EWOULDBLOCK) #endif #endif extern jmp_buf Tekend; #ifndef X_NOT_STDC_ENV #include #else extern char *malloc(); extern void exit(); extern long time(); /* included in by Xos.h */ #endif extern fd_set Select_mask; extern fd_set X_mask; extern fd_set pty_mask; #define TekColormap DefaultColormap( screen->display, \ DefaultScreen(screen->display) ) #define DefaultGCID XGContextFromGC(DefaultGC(screen->display, DefaultScreen(screen->display))) /* Tek defines */ #define BEL 07 #define CANCEL 030 #define DOTDASHEDLINE 2 #define DOTTEDLINE 1 #define EAST 01 #define ETX 03 #define LINEMASK 07 #define LONGDASHEDLINE 4 #define MARGIN1 0 #define MARGIN2 1 #define MAX_PTS 150 #define MAX_VTX 300 #define NAK 025 #define NORTH 04 #define PENDOWN 1 #define PENUP 0 #define SHORTDASHEDLINE 3 #define SOLIDLINE 0 #define SOUTH 010 #define TEKBOTTOMPAD 23 #define TEKDEFHEIGHT 565 #define TEKDEFWIDTH 750 #define TEKHEIGHT 3072 #define TEKHOME ((TekChar[screen->page.fontsize].nlines - 1)\ * TekChar[screen->page.fontsize].vsize) #define TEKMINHEIGHT 452 #define TEKMINWIDTH 600 #define TEKTOPPAD 34 #define TEKWIDTH 4096 #define TEXT_BUF_SIZE 256 #define WEST 02 #define TekMove(x,y) screen->cur_X = x; screen->cur_Y = y #define input() Tinput() #define unput(c) *Tpushback++ = c extern Widget toplevel; static struct Tek_Char { int hsize; /* in Tek units */ int vsize; /* in Tek units */ int charsperline; int nlines; } TekChar[TEKNUMFONTS] = { {56, 88, 74, 35}, /* large */ {51, 82, 81, 38}, /* #2 */ {34, 53, 121, 58}, /* #3 */ {31, 48, 133, 64}, /* small */ }; static Cursor GINcursor; static XSegment *line_pt; static int nplot; static TekLink Tek0; static jmp_buf Tekjump; static TekLink *TekRecord; static XSegment *Tline; extern int Talptable[]; extern int Tbestable[]; extern int Tbyptable[]; extern int Tesctable[]; extern int Tipltable[]; extern int Tplttable[]; extern int Tpttable[]; extern int Tspttable[]; static int *curstate = Talptable; static int *Tparsestate = Talptable; static void TekEnq(); /* event handlers */ extern void HandleKeyPressed(), HandleEightBitKeyPressed(); extern void HandleStringEvent(); extern void HandleEnterWindow(); extern void HandleLeaveWindow(); extern void HandleFocusChange(); extern void HandleBellPropertyChange(); extern void HandleSecure(); extern void HandleGINInput(); extern void HandleCreateMenu(), HandlePopupMenu(); static char defaultTranslations[] = "\ ~Meta: insert-seven-bit() \n\ Meta: insert-eight-bit() \n\ !Ctrl : popup-menu(mainMenu) \n\ !Lock Ctrl : popup-menu(mainMenu) \n\ !Lock Ctrl @Num_Lock : popup-menu(mainMenu) \n\ !Ctrl @Num_Lock : popup-menu(mainMenu) \n\ !Ctrl : popup-menu(tekMenu) \n\ !Lock Ctrl : popup-menu(tekMenu) \n\ !Lock Ctrl @Num_Lock : popup-menu(tekMenu) \n\ !Ctrl @Num_Lock : popup-menu(tekMenu) \n\ Shift ~Meta: gin-press(L) \n\ ~Meta: gin-press(l) \n\ Shift ~Meta: gin-press(M) \n\ ~Meta: gin-press(m) \n\ Shift ~Meta: gin-press(R) \n\ ~Meta: gin-press(r)"; static XtActionsRec actionsList[] = { { "string", HandleStringEvent }, { "insert", HandleKeyPressed }, /* alias for insert-seven-bit */ { "insert-seven-bit", HandleKeyPressed }, { "insert-eight-bit", HandleEightBitKeyPressed }, { "gin-press", HandleGINInput }, { "secure", HandleSecure }, { "create-menu", HandleCreateMenu }, { "popup-menu", HandlePopupMenu }, /* menu actions */ { "allow-send-events", HandleAllowSends }, { "set-visual-bell", HandleSetVisualBell }, #ifdef ALLOWLOGGING { "set-logging", HandleLogging }, #endif { "redraw", HandleRedraw }, { "send-signal", HandleSendSignal }, { "quit", HandleQuit }, { "set-scrollbar", HandleScrollbar }, { "set-jumpscroll", HandleJumpscroll }, { "set-reverse-video", HandleReverseVideo }, { "set-autowrap", HandleAutoWrap }, { "set-reversewrap", HandleReverseWrap }, { "set-autolinefeed", HandleAutoLineFeed }, { "set-appcursor", HandleAppCursor }, { "set-appkeypad", HandleAppKeypad }, { "set-scroll-on-key", HandleScrollKey }, { "set-scroll-on-tty-output", HandleScrollTtyOutput }, { "set-allow132", HandleAllow132 }, { "set-cursesemul", HandleCursesEmul }, { "set-marginbell", HandleMarginBell }, { "set-altscreen", HandleAltScreen }, { "soft-reset", HandleSoftReset }, { "hard-reset", HandleHardReset }, { "set-terminal-type", HandleSetTerminalType }, { "set-visibility", HandleVisibility }, { "set-tek-text", HandleSetTekText }, { "tek-page", HandleTekPage }, { "tek-reset", HandleTekReset }, { "tek-copy", HandleTekCopy }, }; static Dimension defOne = 1; #define GIN_TERM_NONE_STR "none" #define GIN_TERM_CR_STR "CRonly" #define GIN_TERM_EOT_STR "CR&EOT" #define GIN_TERM_NONE 0 #define GIN_TERM_CR 1 #define GIN_TERM_EOT 2 static XtResource resources[] = { {XtNwidth, XtCWidth, XtRDimension, sizeof(Dimension), XtOffsetOf(CoreRec, core.width), XtRDimension, (caddr_t)&defOne}, {XtNheight, XtCHeight, XtRDimension, sizeof(Dimension), XtOffsetOf(CoreRec, core.height), XtRDimension, (caddr_t)&defOne}, {"fontLarge", XtCFont, XtRFontStruct, sizeof(XFontStruct *), XtOffsetOf(TekWidgetRec, tek.Tfont[TEK_FONT_LARGE]), XtRString, "9x15"}, {"font2", XtCFont, XtRFontStruct, sizeof(XFontStruct *), XtOffsetOf(TekWidgetRec, tek.Tfont[TEK_FONT_2]), XtRString, "6x13"}, {"font3", XtCFont, XtRFontStruct, sizeof(XFontStruct *), XtOffsetOf(TekWidgetRec, tek.Tfont[TEK_FONT_3]), XtRString, "8x13"}, {"fontSmall", XtCFont, XtRFontStruct, sizeof(XFontStruct *), XtOffsetOf(TekWidgetRec, tek.Tfont[TEK_FONT_SMALL]), XtRString, "6x10"}, {"initialFont", "InitialFont", XtRString, sizeof(char *), XtOffsetOf(TekWidgetRec, tek.initial_font), XtRString, "large"}, {"ginTerminator", "GinTerminator", XtRString, sizeof(char *), XtOffsetOf(TekWidgetRec, tek.gin_terminator_str), XtRString, GIN_TERM_NONE_STR}, }; static void TekInitialize(), TekRealize(), TekConfigure(); static int getpoint(); static int Tinput(); void TekExpose(); void TekSetFontSize(); static WidgetClassRec tekClassRec = { { /* core_class fields */ /* superclass */ (WidgetClass) &widgetClassRec, /* class_name */ "Tek4014", /* widget_size */ sizeof(TekWidgetRec), /* class_initialize */ NULL, /* class_part_initialize */ NULL, /* class_inited */ FALSE, /* initialize */ TekInitialize, /* initialize_hook */ NULL, /* realize */ TekRealize, /* actions */ actionsList, /* num_actions */ XtNumber(actionsList), /* resources */ resources, /* num_resources */ XtNumber(resources), /* xrm_class */ NULLQUARK, /* compress_motion */ TRUE, /* compress_exposure */ TRUE, /* compress_enterleave */ TRUE, /* visible_interest */ FALSE, /* destroy */ NULL, /* resize */ TekConfigure, /* expose */ TekExpose, /* set_values */ NULL, /* set_values_hook */ NULL, /* set_values_almost */ NULL, /* get_values_hook */ NULL, /* accept_focus */ NULL, /* version */ XtVersion, /* callback_offsets */ NULL, /* tm_table */ defaultTranslations, /* query_geometry */ XtInheritQueryGeometry, /* display_accelerator*/ XtInheritDisplayAccelerator, /* extension */ NULL } }; #define tekWidgetClass ((WidgetClass)&tekClassRec) static Boolean Tfailed = FALSE; static Widget tekshellwidget; static TekWidget CreateTekWidget () { extern Arg ourTopLevelShellArgs[]; extern int number_ourTopLevelShellArgs; /* this causes the Initialize method to be called */ tekshellwidget = XtCreatePopupShell ("tektronix", topLevelShellWidgetClass, toplevel, ourTopLevelShellArgs, number_ourTopLevelShellArgs); /* this causes the Realize method to be called */ tekWidget = (TekWidget) XtCreateManagedWidget ("tek4014", tekWidgetClass, tekshellwidget, NULL, 0); return (tekWidget); } int TekInit () { if (Tfailed) return (0); if (tekWidget) return (1); if (CreateTekWidget()) { return (1); } return (0); } static void Tekparse() { register TScreen *screen = &term->screen; register int c, x, y; char ch; for( ; ; ) { c = input(); switch(Tparsestate[c]) { case CASE_REPORT: /* report address */ if(screen->TekGIN) { TekGINoff(); TekEnqMouse(0); } else { c = 064; /* has hard copy unit */ if(screen->margin == MARGIN2) c |= 02; TekEnq(c, screen->cur_X, screen->cur_Y); } TekRecord->ptr[-1] = NAK; /* remove from recording */ Tparsestate = curstate; break; case CASE_VT_MODE: /* special return to vt102 mode */ Tparsestate = curstate; TekRecord->ptr[-1] = NAK; /* remove from recording */ #ifdef ALLOWLOGGING if(screen->logging) { FlushLog(screen); screen->logstart = buffer; } #endif return; case CASE_SPT_STATE: /* Enter Special Point Plot mode */ if(screen->TekGIN) TekGINoff(); Tparsestate = curstate = Tspttable; break; case CASE_GIN: /* Do Tek GIN mode */ screen->TekGIN = &TekRecord->ptr[-1]; /* Set cross-hair cursor raster array */ if (GINcursor = make_colored_cursor (XC_tcross, screen->mousecolor, screen->mousecolorback)) XDefineCursor (screen->display, TShellWindow, GINcursor); Tparsestate = Tbyptable; /* Bypass mode */ break; case CASE_BEL: /* BEL */ if(screen->TekGIN) TekGINoff(); if(!TekRefresh) Bell(XkbBI_TerminalBell,0); Tparsestate = curstate; /* clear bypass condition */ break; case CASE_BS: /* BS */ if(screen->TekGIN) TekGINoff(); Tparsestate = curstate; /* clear bypass condition */ TCursorBack(); break; case CASE_PT_STATE: /* Enter Tek Point Plot mode */ if(screen->TekGIN) TekGINoff(); Tparsestate = curstate = Tpttable; break; case CASE_PLT_STATE: /* Enter Tek Plot mode */ if(screen->TekGIN) TekGINoff(); Tparsestate = curstate = Tplttable; if((c = input()) == BEL) screen->pen = PENDOWN; else { unput(c); screen->pen = PENUP; } break; case CASE_TAB: /* HT */ if(screen->TekGIN) TekGINoff(); Tparsestate = curstate; /* clear bypass condition */ TCursorForward(); break; case CASE_IPL_STATE: /* Enter Tek Incremental Plot mode */ if(screen->TekGIN) TekGINoff(); Tparsestate = curstate = Tipltable; break; case CASE_ALP_STATE: /* Enter Tek Alpha mode from any other mode */ if(screen->TekGIN) TekGINoff(); /* if in one of graphics states, move alpha cursor */ if(nplot > 0) /* flush line Tbuffer */ TekFlush(); Tparsestate = curstate = Talptable; break; case CASE_UP: /* cursor up */ if(screen->TekGIN) TekGINoff(); Tparsestate = curstate; /* clear bypass condition */ TCursorUp(); break; case CASE_COPY: /* make copy */ if(screen->TekGIN) TekGINoff(); TekCopy(); TekRecord->ptr[-1] = NAK; /* remove from recording */ Tparsestate = curstate; /* clear bypass condition */ break; case CASE_PAGE: /* Page Function */ if(screen->TekGIN) TekGINoff(); TekPage(); /* clear bypass condition */ break; case CASE_BES_STATE: /* Byp: an escape char */ Tparsestate = Tbestable; break; case CASE_BYP_STATE: /* set bypass condition */ Tparsestate = Tbyptable; break; case CASE_IGNORE: /* Esc: totally ignore CR, ESC, LF, ~ */ break; case CASE_ASCII: /* Select ASCII char set */ /* ignore for now */ Tparsestate = curstate; break; case CASE_APL: /* Select APL char set */ /* ignore for now */ Tparsestate = curstate; break; case CASE_CHAR_SIZE: /* character size selector */ TekSetFontSize (c & 03); Tparsestate = curstate; break; case CASE_BEAM_VEC: /* beam and vector selector */ /* only line types */ if((c &= LINEMASK) != screen->cur.linetype) { if(nplot > 0) TekFlush(); if (c <= TEKNUMLINES) screen->cur.linetype = c; } Tparsestate = curstate; break; case CASE_CURSTATE: Tparsestate = curstate; break; case CASE_PENUP: /* Ipl: penup */ screen->pen = PENUP; break; case CASE_PENDOWN: /* Ipl: pendown */ screen->pen = PENDOWN; break; case CASE_IPL_POINT: /* Ipl: point */ x = screen->cur_X; y = screen->cur_Y; if(c & NORTH) y++; else if(c & SOUTH) y--; if(c & EAST) x++; else if(c & WEST) x--; if(screen->pen == PENDOWN) TekDraw(x, y); else TekMove(x, y); break; case CASE_PLT_VEC: /* Plt: vector */ unput(c); if(getpoint()) { if(screen->pen == PENDOWN) TekDraw(screen->cur.x, screen->cur.y); else TekMove(screen->cur.x, screen->cur.y); screen->pen = PENDOWN; } break; case CASE_PT_POINT: /* Pt: point */ unput(c); if(getpoint()) { TekMove(screen->cur.x, screen->cur.y); TekDraw(screen->cur.x, screen->cur.y); } break; case CASE_SPT_POINT: /* Spt: point */ /* ignore intensity character in c */ if(getpoint()) { TekMove(screen->cur.x, screen->cur.y); TekDraw(screen->cur.x, screen->cur.y); } break; case CASE_CR: /* CR */ if(screen->TekGIN) TekGINoff(); if(nplot > 0) /* flush line Tbuffer */ TekFlush(); screen->cur_X = screen->margin == MARGIN1 ? 0 : TEKWIDTH / 2; Tparsestate = curstate = Talptable; break; case CASE_ESC_STATE: /* ESC */ Tparsestate = Tesctable; break; case CASE_LF: /* LF */ if(screen->TekGIN) TekGINoff(); TCursorDown(); if (!TekRefresh && (QLength(screen->display) > 0 || GetBytesAvailable (ConnectionNumber(screen->display)) > 0)) xevents(); break; case CASE_SP: /* SP */ TCursorForward(); break; case CASE_PRINT: /* printable character */ ch = c; c = screen->cur.fontsize; XDrawString( screen->display, TWindow(screen), screen->TnormalGC, (int)(screen->cur_X * TekScale(screen)) + screen->border, (int)((TEKHEIGHT + TEKTOPPAD - screen->cur_Y) * TekScale(screen)) + screen->border, &ch, 1); TCursorForward(); break; case CASE_OSC: /* do osc escape */ do_osc(Tinput); Tparsestate = curstate; break; } } } static int rcnt; static char *rptr; static fd_set Tselect_mask; static int Tinput() { register TScreen *screen = &term->screen; register int i; register TekLink *tek; if(Tpushback > Tpushb) return(*--Tpushback); if(TekRefresh) { if(rcnt-- > 0) return(*rptr++); if(tek = TekRefresh->next) { TekRefresh = tek; rptr = tek->data; rcnt = tek->count - 1; TekSetFontSize(tek->fontsize); return(*rptr++); } TekRefresh = (TekLink *)0; longjmp(Tekjump, 1); } again: if(Tbcnt-- <= 0) { if(nplot > 0) /* flush line Tbuffer */ TekFlush(); XFD_COPYSET (&pty_mask, &Tselect_mask); for( ; ; ) { #ifdef CRAY struct timeval crocktimeout; crocktimeout.tv_sec = 0; crocktimeout.tv_usec = 0; (void) Select (max_plus1, &Tselect_mask, NULL, NULL, &crocktimeout); #endif if(FD_ISSET (screen->respond, &Tselect_mask)) { #ifdef ALLOWLOGGING if(screen->logging) FlushLog(screen); #endif Tbcnt = read(screen->respond, (char *)(Tbptr = Tbuffer), BUF_SIZE); if(Tbcnt < 0) { if(errno == EIO) Cleanup (0); else if(!E_TEST(errno)) Panic( "Tinput:read returned unexpected error (%d)\n", errno); } else if(Tbcnt == 0) Panic("input: read returned zero\n", 0); else { if (!screen->output_eight_bits) { register int bc = Tbcnt; register Char *b = Tbptr; for (; bc > 0; bc--, b++) { *b &= (Char) 0x7f; } } break; } } if (Ttoggled && curstate == Talptable) { TCursorToggle(TOGGLE); Ttoggled = FALSE; } if(QLength(screen->display)) { XFD_COPYSET (&X_mask, &Tselect_mask); } else { XFlush(screen->display); XFD_COPYSET (&Select_mask, &Tselect_mask); if((i = Select(max_plus1, &Tselect_mask, NULL, NULL, NULL)) < 0){ if (errno != EINTR) SysError(ERROR_TSELECT); continue; } } if(FD_ISSET (ConnectionNumber (screen->display), &Tselect_mask)) { xevents(); if(Tbcnt > 0) goto again; } } Tbcnt--; if (!Ttoggled && curstate == Talptable) { TCursorToggle(TOGGLE); Ttoggled = TRUE; } } tek = TekRecord; if(tek->count >= TEK_LINK_BLOCK_SIZE || tek->fontsize != screen->cur.fontsize) { if((TekRecord = tek->next = (TekLink *)malloc(sizeof(TekLink))) == (TekLink *)0) Panic("Tinput: malloc error (%d)\n", errno); tek = tek->next; tek->next = (TekLink *)0; tek->fontsize = screen->cur.fontsize; tek->count = 0; tek->ptr = tek->data; } tek->count++; return(*tek->ptr++ = *Tbptr++); } /* this should become the Tek Widget's Resize proc */ static void TekConfigure(w) Widget w; { register TScreen *screen = &term->screen; register int border = 2 * screen->border; register double d; if (TWindow(screen)) XClearWindow(screen->display, TWindow(screen)); TWidth(screen) = w->core.width - border; THeight(screen) = w->core.height - border; TekScale(screen) = (double)TWidth(screen) / TEKWIDTH; if((d = (double)THeight(screen) / (TEKHEIGHT + TEKTOPPAD + TEKBOTTOMPAD)) < TekScale(screen)) TekScale(screen) = d; TFullWidth(screen) = w->core.width; TFullHeight(screen) = w->core.height; } /*ARGSUSED*/ void TekExpose(w, event, region) Widget w; XEvent *event; Region region; { register TScreen *screen = &term->screen; extern Bool waiting_for_initial_map; #ifdef lint region = region; #endif if(!Ttoggled) TCursorToggle(CLEAR); Ttoggled = TRUE; Tpushback = Tpushb; screen->cur_X = 0; screen->cur_Y = TEKHOME; TekSetFontSize(screen->page.fontsize); screen->cur = screen->page; screen->margin = MARGIN1; if(screen->TekGIN) { screen->TekGIN = NULL; TekGINoff(); } TekRefresh = &Tek0; rptr = TekRefresh->data; rcnt = TekRefresh->count; Tparsestate = curstate = Talptable; if (waiting_for_initial_map) first_map_occurred (); if(!screen->waitrefresh) dorefresh(); } dorefresh() { register TScreen *screen = &term->screen; static Cursor wait_cursor = None; if (wait_cursor == None) wait_cursor = make_colored_cursor (XC_watch, screen->mousecolor, screen->mousecolorback); XDefineCursor(screen->display, TShellWindow, wait_cursor); XFlush(screen->display); if(!setjmp(Tekjump)) Tekparse(); XDefineCursor(screen->display, TShellWindow, (screen->TekGIN && GINcursor) ? GINcursor : screen->arrow); } TekPage() { register TScreen *screen = &term->screen; register TekLink *tek; XClearWindow(screen->display, TWindow(screen)); screen->cur_X = 0; screen->cur_Y = TEKHOME; screen->margin = MARGIN1; screen->page = screen->cur; if(screen->TekGIN) TekGINoff(); tek = TekRecord = &Tek0; tek->fontsize = screen->cur.fontsize; tek->count = 0; tek->ptr = tek->data; tek = tek->next; if(tek) do { TekLink *tek2 = tek->next; free((char *)tek); tek = tek2; } while(tek); TekRecord->next = (TekLink *)0; TekRefresh = (TekLink *)0; Ttoggled = TRUE; Tparsestate = curstate = Talptable; /* Tek Alpha mode */ } #define EXTRABITS 017 #define FIVEBITS 037 #define HIBITS (FIVEBITS << SHIFTHI) #define LOBITS (FIVEBITS << SHIFTLO) #define SHIFTHI 7 #define SHIFTLO 2 #define TWOBITS 03 static int getpoint() { register int c, x, y, e, lo_y = 0; register TScreen *screen = &term->screen; x = screen->cur.x; y = screen->cur.y; for( ; ; ) { if((c = input()) < ' ') { /* control character */ unput(c); return(0); } if(c < '@') { /* Hi X or Hi Y */ if(lo_y) { /* seen a Lo Y, so this must be Hi X */ x &= ~HIBITS; x |= (c & FIVEBITS) << SHIFTHI; continue; } /* else Hi Y */ y &= ~HIBITS; y |= (c & FIVEBITS) << SHIFTHI; continue; } if(c < '`') { /* Lo X */ x &= ~LOBITS; x |= (c & FIVEBITS) << SHIFTLO; screen->cur.x = x; screen->cur.y = y; return(1); /* OK */ } /* else Lo Y */ if(lo_y) { /* seen a Lo Y, so other must be extra bits */ e = (y >> SHIFTLO) & EXTRABITS; x &= ~TWOBITS; x |= e & TWOBITS; y &= ~TWOBITS; y |= (e >> SHIFTLO) & TWOBITS; } y &= ~LOBITS; y |= (c & FIVEBITS) << SHIFTLO; lo_y++; } } TCursorBack() { register TScreen *screen = &term->screen; register struct Tek_Char *t; register int x, l; x = ( screen->cur_X -= (t = &TekChar[screen->cur.fontsize])->hsize ); if(screen->margin == MARGIN1 && x < 0 || screen->margin == MARGIN2 && x < TEKWIDTH / 2) { if((l = (screen->cur_Y + (t->vsize - 1)) / t->vsize + 1) >= t->nlines) { screen->margin = !screen->margin; l = 0; } screen->cur_Y = l * t->vsize; screen->cur_X = (t->charsperline - 1) * t->hsize; } } TCursorForward() { register TScreen *screen = &term->screen; register struct Tek_Char *t; register int l; if( ( screen->cur_X += ( t = &TekChar[screen->cur.fontsize])->hsize ) > TEKWIDTH ) { if((l = screen->cur_Y / t->vsize - 1) < 0) { screen->margin = !screen->margin; l = t->nlines - 1; } screen->cur_Y = l * t->vsize; screen->cur_X = screen->margin == MARGIN1 ? 0 : TEKWIDTH / 2; } } TCursorUp() { register TScreen *screen = &term->screen; register struct Tek_Char *t; register int l; t = &TekChar[screen->cur.fontsize]; if((l = (screen->cur_Y + (t->vsize - 1)) / t->vsize + 1) >= t->nlines) { l = 0; if((screen->margin = !screen->margin) != MARGIN1) { if(screen->cur_X < TEKWIDTH / 2) screen->cur_X += TEKWIDTH / 2; } else if(screen->cur_X >= TEKWIDTH / 2) screen->cur_X -= TEKWIDTH / 2; } screen->cur_Y = l * t->vsize; } TCursorDown() { register TScreen *screen = &term->screen; register struct Tek_Char *t; register int l; t = &TekChar[screen->cur.fontsize]; if((l = screen->cur_Y / t->vsize - 1) < 0) { l = t->nlines - 1; if((screen->margin = !screen->margin) != MARGIN1) { if(screen->cur_X < TEKWIDTH / 2) screen->cur_X += TEKWIDTH / 2; } else if(screen->cur_X >= TEKWIDTH / 2) screen->cur_X -= TEKWIDTH / 2; } screen->cur_Y = l * t->vsize; } static void AddToDraw(x1, y1, x2, y2) int x1, y1, x2, y2; { register TScreen *screen = &term->screen; register XSegment *lp; if(nplot >= MAX_PTS) { TekFlush(); } lp = line_pt++; lp->x1 = x1 = x1 * TekScale(screen) + screen->border; lp->y1 = y1 = (TEKHEIGHT + TEKTOPPAD - y1) * TekScale(screen) + screen->border; lp->x2 = x2 = x2 * TekScale(screen) + screen->border; lp->y2 = y2 = (TEKHEIGHT + TEKTOPPAD - y2) * TekScale(screen) + screen->border; nplot++; } TekDraw (x, y) int x, y; { register TScreen *screen = &term->screen; if(nplot == 0 || T_lastx != screen->cur_X || T_lasty != screen->cur_Y) { /* * We flush on each unconnected line segment if the line * type is not solid. This solves a bug in X when drawing * points while the line type is not solid. */ if(nplot > 0 && screen->cur.linetype != SOLIDLINE) TekFlush(); } AddToDraw(screen->cur_X, screen->cur_Y, x, y); T_lastx = screen->cur_X = x; T_lasty = screen->cur_Y = y; } TekFlush () { register TScreen *screen = &term->screen; XDrawSegments(screen->display, TWindow(screen), ((screen->cur.linetype == SOLIDLINE)? screen->TnormalGC : screen->linepat[screen->cur.linetype - 1]), Tline, nplot); nplot = 0; line_pt = Tline; } TekGINoff() { register TScreen *screen = &term->screen; XDefineCursor(screen->display, TShellWindow, screen->arrow); if(GINcursor) XFreeCursor(screen->display, GINcursor); if(screen->TekGIN) { *screen->TekGIN = CANCEL; /* modify recording */ screen->TekGIN = NULL; } } TekEnqMouse(c) int c; /* character pressed */ { register TScreen *screen = &term->screen; int mousex, mousey, rootx, rooty; unsigned int mask; /* XQueryPointer */ Window root, subw; XQueryPointer( screen->display, TWindow(screen), &root, &subw, &rootx, &rooty, &mousex, &mousey, &mask); if((mousex = (mousex - screen->border) / TekScale(screen)) < 0) mousex = 0; else if(mousex >= TEKWIDTH) mousex = TEKWIDTH - 1; if((mousey = TEKHEIGHT + TEKTOPPAD - (mousey - screen->border) / TekScale(screen)) < 0) mousey = 0; else if(mousey >= TEKHEIGHT) mousey = TEKHEIGHT - 1; TekEnq(c, mousex, mousey); } static void TekEnq (status, x, y) int status; register int x, y; { register TScreen *screen = &term->screen; int pty = screen->respond; char cplot [7]; int len = 5; cplot[0] = status; /* Translate x and y to Tektronix code */ cplot[1] = 040 | ((x >> SHIFTHI) & FIVEBITS); cplot[2] = 040 | ((x >> SHIFTLO) & FIVEBITS); cplot[3] = 040 | ((y >> SHIFTHI) & FIVEBITS); cplot[4] = 040 | ((y >> SHIFTLO) & FIVEBITS); if (screen->gin_terminator != GIN_TERM_NONE) cplot[len++] = '\r'; if (screen->gin_terminator == GIN_TERM_EOT) cplot[len++] = '\004'; if(cplot[0]) v_write(pty, cplot, len); else v_write(pty, cplot+1, len-1); } TekRun() { register TScreen *screen = &term->screen; register int i; if(!TWindow(screen) && !TekInit()) { if(VWindow(screen)) { screen->TekEmu = FALSE; return; } Exit(ERROR_TINIT); } if(!screen->Tshow) { set_tek_visibility (TRUE); } update_vttekmode(); update_vtshow(); update_tekshow(); set_tekhide_sensitivity(); Tpushback = Tpushb; Tbptr = Tbuffer; for(i = Tbcnt = bcnt ; i > 0 ; i--) *Tbptr++ = *bptr++; Tbptr = Tbuffer; Ttoggled = TRUE; if(!setjmp(Tekend)) Tekparse(); if(!Ttoggled) { TCursorToggle(TOGGLE); Ttoggled = TRUE; } screen->TekEmu = FALSE; } #define DOTTED_LENGTH 2 #define DOT_DASHED_LENGTH 4 #define SHORT_DASHED_LENGTH 2 #define LONG_DASHED_LENGTH 2 static int dash_length[TEKNUMLINES] = { DOTTED_LENGTH, DOT_DASHED_LENGTH, SHORT_DASHED_LENGTH, LONG_DASHED_LENGTH, }; static unsigned char dotted[DOTTED_LENGTH] = {3, 1}; static unsigned char dot_dashed[DOT_DASHED_LENGTH] = {3, 4, 3, 1}; static unsigned char short_dashed[SHORT_DASHED_LENGTH] = {4, 4}; static unsigned char long_dashed[LONG_DASHED_LENGTH] = {4, 7}; static unsigned char *dashes[TEKNUMLINES] = { dotted, dot_dashed, short_dashed, long_dashed, }; /* * The following is called the create the tekWidget */ static void TekInitialize(request, new, args, num_args) Widget request, new; ArgList args; Cardinal *num_args; { /* look for focus related events on the shell, because we need * to care about the shell's border being part of our focus. */ XtAddEventHandler(XtParent(new), EnterWindowMask, FALSE, HandleEnterWindow, (caddr_t)NULL); XtAddEventHandler(XtParent(new), LeaveWindowMask, FALSE, HandleLeaveWindow, (caddr_t)NULL); XtAddEventHandler(XtParent(new), FocusChangeMask, FALSE, HandleFocusChange, (caddr_t)NULL); XtAddEventHandler((Widget)new, PropertyChangeMask, FALSE, HandleBellPropertyChange, (Opaque)NULL); } static void TekRealize (gw, valuemaskp, values) Widget gw; XtValueMask *valuemaskp; XSetWindowAttributes *values; { TekWidget tw = (TekWidget) gw; register TScreen *screen = &term->screen; register int i; register TekLink *tek; register double d; register int border = 2 * screen->border; int pr; XGCValues gcv; int winX, winY, width, height; XSizeHints sizehints; char Tdefault[32]; tw->core.border_pixel = term->core.border_pixel; for (i = 0; i < TEKNUMFONTS; i++) { if (!tw->tek.Tfont[i]) tw->tek.Tfont[i] = XQueryFont (screen->display, DefaultGCID); tw->tek.tobaseline[i] = tw->tek.Tfont[i]->ascent; } if((Tbuffer = (Char *)malloc(BUF_SIZE)) == NULL || (Tpushb = (Char *)malloc(10)) == NULL || (Tline = (XSegment *)malloc(MAX_VTX * sizeof(XSegment))) == NULL) { fprintf (stderr, "%s: Not enough core for Tek mode\n", xterm_name); if(Tpushb) free((char *)Tpushb); if(Tbuffer) free((char *)Tbuffer); Tfailed = TRUE; return; } screen->xorplane = 1; screen->Tbackground = term->core.background_pixel; screen->Tforeground = screen->foreground; screen->Tcursorcolor = screen->cursorcolor; if (term->misc.T_geometry == NULL) { int defwidth, defheight; if (term->misc.tekSmall) { defwidth = TEKMINWIDTH; defheight = TEKMINHEIGHT; } else { defwidth = TEKDEFWIDTH; defheight = TEKDEFHEIGHT; } sprintf (Tdefault, "=%dx%d", defwidth + border, defheight + border); term->misc.T_geometry = Tdefault; } winX = 1; winY = 1; width = TEKDEFWIDTH + border; height = TEKDEFHEIGHT + border; pr = XParseGeometry(term->misc.T_geometry, &winX, &winY, (unsigned int *)&width, (unsigned int *)&height); if ((pr & XValue) && (pr & XNegative)) winX += DisplayWidth(screen->display, DefaultScreen(screen->display)) - width - (term->core.parent->core.border_width * 2); if ((pr & YValue) && (pr & YNegative)) winY += DisplayHeight(screen->display, DefaultScreen(screen->display)) - height - (term->core.parent->core.border_width * 2); /* set up size hints */ sizehints.min_width = TEKMINWIDTH + border; sizehints.min_height = TEKMINHEIGHT + border; sizehints.width_inc = 1; sizehints.height_inc = 1; sizehints.flags = PMinSize|PResizeInc; sizehints.x = winX; sizehints.y = winY; if ((XValue&pr) || (YValue&pr)) { sizehints.flags |= USSize|USPosition; sizehints.flags |= PWinGravity; switch (pr & (XNegative | YNegative)) { case 0: sizehints.win_gravity = NorthWestGravity; break; case XNegative: sizehints.win_gravity = NorthEastGravity; break; case YNegative: sizehints.win_gravity = SouthWestGravity; break; default: sizehints.win_gravity = SouthEastGravity; break; } } else { sizehints.flags |= PSize; } sizehints.width = width; sizehints.height = height; if ((WidthValue&pr) || (HeightValue&pr)) sizehints.flags |= USSize; else sizehints.flags |= PSize; (void) XtMakeResizeRequest ((Widget) tw, width, height, &tw->core.width, &tw->core.height); /* XXX This is bogus. We are parsing geometries too late. This * is information that the shell widget ought to have before we get * realized, so that it can do the right thing. */ if (sizehints.flags & USPosition) XMoveWindow (XtDisplay(tw), tw->core.parent->core.window, sizehints.x, sizehints.y); XSetWMNormalHints (XtDisplay(tw), tw->core.parent->core.window, &sizehints); XFlush (XtDisplay(tw)); /* get it out to window manager */ values->win_gravity = NorthWestGravity; values->background_pixel = screen->Tbackground; tw->core.window = TWindow(screen) = XCreateWindow (screen->display, tw->core.parent->core.window, tw->core.x, tw->core.y, tw->core.width, tw->core.height, tw->core.border_width, (int) tw->core.depth, InputOutput, CopyFromParent, ((*valuemaskp)|CWBackPixel|CWWinGravity), values); TFullWidth(screen) = width; TFullHeight(screen) = height; TWidth(screen) = width - border; THeight(screen) = height - border; TekScale(screen) = (double)TWidth(screen) / TEKWIDTH; if((d = (double)THeight(screen) / (TEKHEIGHT + TEKTOPPAD + TEKBOTTOMPAD)) < TekScale(screen)) TekScale(screen) = d; screen->cur.fontsize = TEK_FONT_LARGE; if (tw->tek.initial_font) { char *s = tw->tek.initial_font; if (XmuCompareISOLatin1 (s, "large") == 0) screen->cur.fontsize = TEK_FONT_LARGE; else if (XmuCompareISOLatin1 (s, "2") == 0 || XmuCompareISOLatin1 (s, "two") == 0) screen->cur.fontsize = TEK_FONT_2; else if (XmuCompareISOLatin1 (s, "3") == 0 || XmuCompareISOLatin1 (s, "three") == 0) screen->cur.fontsize = TEK_FONT_3; else if (XmuCompareISOLatin1 (s, "small") == 0) screen->cur.fontsize = TEK_FONT_SMALL; } if(XmuCompareISOLatin1(tw->tek.gin_terminator_str, GIN_TERM_NONE_STR) == 0) screen->gin_terminator = GIN_TERM_NONE; else if(XmuCompareISOLatin1(tw->tek.gin_terminator_str, GIN_TERM_CR_STR) == 0) screen->gin_terminator = GIN_TERM_CR; else if(XmuCompareISOLatin1(tw->tek.gin_terminator_str, GIN_TERM_EOT_STR) == 0) screen->gin_terminator = GIN_TERM_EOT; else fprintf(stderr, "%s: illegal GIN terminator setting \"%s\"\n", xterm_name, tw->tek.gin_terminator_str); gcv.graphics_exposures = TRUE; /* default */ gcv.font = tw->tek.Tfont[screen->cur.fontsize]->fid; gcv.foreground = screen->Tforeground; gcv.background = screen->Tbackground; /* if font wasn't successfully opened, then gcv.font will contain the Default GC's ID, meaning that we must use the server default font. */ TEKgcFontMask = (gcv.font == DefaultGCID) ? 0 : GCFont; screen->TnormalGC = XCreateGC (screen->display, TWindow(screen), (TEKgcFontMask|GCGraphicsExposures| GCForeground|GCBackground), &gcv); gcv.function = GXinvert; gcv.plane_mask = screen->xorplane = (screen->Tbackground ^ screen->Tcursorcolor); gcv.join_style = JoinMiter; /* default */ gcv.line_width = 1; screen->TcursorGC = XCreateGC (screen->display, TWindow(screen), (GCFunction|GCPlaneMask), &gcv); gcv.foreground = screen->Tforeground; gcv.line_style = LineOnOffDash; gcv.line_width = 0; for(i = 0 ; i < TEKNUMLINES ; i++) { screen->linepat[i] = XCreateGC (screen->display, TWindow(screen), (GCForeground|GCLineStyle), &gcv); XSetDashes (screen->display, screen->linepat[i], 0, (char *) dashes[i], dash_length[i]); } TekBackground(screen); screen->margin = MARGIN1; /* Margin 1 */ screen->TekGIN = FALSE; /* GIN off */ XDefineCursor(screen->display, TShellWindow, screen->pointer_cursor); { /* there's gotta be a better way... */ static Arg args[] = { {XtNtitle, (XtArgVal)NULL}, {XtNiconName, (XtArgVal)NULL}, }; char *icon_name, *title, *tek_icon_name, *tek_title; args[0].value = (XtArgVal)&icon_name; args[1].value = (XtArgVal)&title; XtGetValues (tw->core.parent, args, 2); tek_icon_name = XtMalloc(strlen(icon_name)+7); strcpy(tek_icon_name, icon_name); strcat(tek_icon_name, "(Tek)"); tek_title = XtMalloc(strlen(title)+7); strcpy(tek_title, title); strcat(tek_title, "(Tek)"); args[0].value = (XtArgVal)tek_icon_name; args[1].value = (XtArgVal)tek_title; XtSetValues (tw->core.parent, args, 2); XtFree( tek_icon_name ); XtFree( tek_title ); } tek = TekRecord = &Tek0; tek->next = (TekLink *)0; tek->fontsize = screen->cur.fontsize; tek->count = 0; tek->ptr = tek->data; Tpushback = Tpushb; Tbptr = Tbuffer; screen->cur_X = 0; screen->cur_Y = TEKHOME; line_pt = Tline; Ttoggled = TRUE; screen->page = screen->cur; return; } void TekSetFontSize (newitem) int newitem; { register TScreen *screen = &term->screen; int oldsize = screen->cur.fontsize; int newsize = MI2FS(newitem); Font fid; if (!tekWidget || oldsize == newsize) return; if (!Ttoggled) TCursorToggle(TOGGLE); set_tekfont_menu_item (oldsize, FALSE); fid = tekWidget->tek.Tfont[newsize]->fid; if (fid == DefaultGCID) /* we didn't succeed in opening a real font for this size. Instead, use server default. */ XCopyGC (screen->display, DefaultGC(screen->display, DefaultScreen(screen->display)), GCFont, screen->TnormalGC); else XSetFont (screen->display, screen->TnormalGC, fid); screen->cur.fontsize = newsize; set_tekfont_menu_item (newsize, TRUE); if (!Ttoggled) TCursorToggle(TOGGLE); } TekReverseVideo(screen) register TScreen *screen; { register int i; XGCValues gcv; i = screen->Tbackground; screen->Tbackground = screen->Tforeground; screen->Tforeground = i; XSetForeground(screen->display, screen->TnormalGC, screen->Tforeground); XSetBackground(screen->display, screen->TnormalGC, screen->Tbackground); if (tekWidget) { if (tekWidget->core.border_pixel == screen->Tbackground) { tekWidget->core.border_pixel = screen->Tforeground; tekWidget->core.parent->core.border_pixel = screen->Tforeground; if (tekWidget->core.parent->core.window) XSetWindowBorder (screen->display, tekWidget->core.parent->core.window, tekWidget->core.border_pixel); } } for(i = 0 ; i < TEKNUMLINES ; i++) { XSetForeground(screen->display, screen->linepat[i], screen->Tforeground); } screen->Tcursorcolor = screen->Tforeground; gcv.plane_mask = screen->xorplane = (screen->Tbackground ^ screen->Tcursorcolor); XChangeGC (screen->display, screen->TcursorGC, GCPlaneMask, &gcv); TekBackground(screen); } TekBackground(screen) register TScreen *screen; { if(TWindow(screen)) XSetWindowBackground(screen->display, TWindow(screen), screen->Tbackground); } /* * Toggles cursor on or off at cursor position in screen. */ TCursorToggle(toggle) int toggle; /* TOGGLE or CLEAR */ { register TScreen *screen = &term->screen; register int c, x, y; unsigned int cellwidth, cellheight; if (!screen->Tshow) return; c = screen->cur.fontsize; cellwidth = (unsigned) tekWidget->tek.Tfont[c]->max_bounds.width; cellheight = (unsigned) (tekWidget->tek.Tfont[c]->ascent + tekWidget->tek.Tfont[c]->descent); x = (screen->cur_X * TekScale(screen)) + screen->border; y = ((TEKHEIGHT + TEKTOPPAD - screen->cur_Y) * TekScale(screen)) + screen->border - tekWidget->tek.tobaseline[c]; if (toggle == TOGGLE) { if (screen->select || screen->always_highlight) XFillRectangle(screen->display, TWindow(screen), screen->TcursorGC, x, y, cellwidth, cellheight); else { /* fix to use different GC! */ XDrawRectangle(screen->display, TWindow(screen), screen->TcursorGC, x, y, cellwidth-1, cellheight-1); } } else { /* Clear the entire rectangle, even though we may only * have drawn an outline. This fits with our refresh * scheme of redrawing the entire window on any expose * event and is easier than trying to figure out exactly * which part of the cursor needs to be erased. */ XClearArea(screen->display, TWindow(screen), x, y, cellwidth, cellheight, FALSE); } } void TekSimulatePageButton (reset) Bool reset; { register TScreen *screen = &term->screen; if (!tekWidget) return; if (reset) { /* bzero ((char *)&curmodes, sizeof(Tmodes)); */ bzero ((char *) &screen->cur, sizeof screen->cur); } TekRefresh = (TekLink *)0; /* screen->cur = curmodes; */ TekPage (); screen->cur_X = 0; screen->cur_Y = TEKHOME; } #ifndef X_NOT_POSIX #define HAS_WAITPID #endif /* write copy of screen to a file */ TekCopy() { register TScreen *screen = &term->screen; register struct tm *tp; Time_t l; char buf[32]; int waited; int pid; #ifndef HAS_WAITPID int (*chldfunc)(); chldfunc = signal(SIGCHLD, SIG_DFL); #endif time(&l); tp = localtime(&l); sprintf(buf, "COPY%02d-%02d-%02d.%02d:%02d:%02d", tp->tm_year, tp->tm_mon + 1, tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec); if(access(buf, F_OK) >= 0) { /* file exists */ if(access(buf, W_OK) < 0) { Bell(XkbBI_MinorError,0); return; } } else if(access(".", W_OK) < 0) { /* can't write in directory */ Bell(XkbBI_MinorError,0); return; } /* Write the file in an unprivileged child process because using access before the open still leaves a small window of opportunity. */ pid = fork(); switch (pid) { case 0: /* child */ { register int tekcopyfd; char initbuf[5]; register TekLink *Tp; setgid(screen->gid); setuid(screen->uid); tekcopyfd = open(buf, O_WRONLY | O_CREAT | O_TRUNC, 0666); if (tekcopyfd < 0) _exit(1); sprintf(initbuf, "\033%c\033%c", screen->page.fontsize + '8', screen->page.linetype + '`'); write(tekcopyfd, initbuf, 4); Tp = &Tek0; do { write(tekcopyfd, (char *)Tp->data, Tp->count); Tp = Tp->next; } while(Tp); close(tekcopyfd); _exit(0); } case -1: /* error */ Bell(XkbBI_MinorError,0); return; default: /* parent */ #ifdef HAS_WAITPID waitpid(pid, NULL, 0); #else waited = wait(NULL); signal(SIGCHLD, chldfunc); /* Since we had the signal handler uninstalled for a while, we might have missed the termination of our screen child. If we can check for this possibility without hanging, do so. */ do if (waited == term->screen.pid) Cleanup(0); while ( (waited=nonblocking_wait()) > 0); #endif } } kterm-6.2.0.orig/VTPrsTbl.c100444 507 454 242311 6163174627 14210 0ustar yosiakiaux/* * $XConsortium: VTPrsTbl.c,v 1.10 95/06/09 22:17:06 gildea Exp $ * $Id: VTPrsTbl.c,v 6.3 1996/06/23 08:00:09 kagotani Rel $ */ #include "kterm.h" /* * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ #include "VTparse.h" #ifdef __STDC__ #define Const const #else #define Const /**/ #endif /* * Stupid Apollo C preprocessor can't handle long lines. So... To keep * it happy, we put each onto a seperate line.... Sigh... */ Const int groundtable[] = { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* NP CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* $ % & ' */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* ( ) * + */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* , - . / */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* 0 1 2 3 */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* 4 5 6 7 */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* 8 9 : ; */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* < = > ? */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* @ A B C */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* D E F G */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* H I J K */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* L M N O */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* P Q R S */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* T U V W */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* X Y Z [ */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* \ ] ^ _ */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* ` a b c */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* d e f g */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* h i j k */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* l m n o */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* p q r s */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* t u v w */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* x y z { */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* | } ~ DEL */ CASE_PRINT, CASE_PRINT, CASE_PRINT, #ifdef KTERM CASE_PRINT, #else /* !KTERM */ CASE_GROUND_STATE, #endif /* !KTERM */ /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, #ifdef KTERM CASE_SS2, CASE_SS3, #else /* !KTERM */ CASE_IGNORE, CASE_IGNORE, #endif /* !KTERM */ /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, #ifdef KTERM CASE_CSI_STATE, #else /* !KTERM */ CASE_IGNORE, #endif /* !KTERM */ /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* currency yen brokenbar section */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* diaeresis copyright ordfeminine guillemotleft */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* notsign hyphen registered macron */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* degree plusminus twosuperior threesuperior */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* acute mu paragraph periodcentered */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* cedilla onesuperior masculine guillemotright */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* onequarter onehalf threequarters questiondown */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Agrave Aacute Acircumflex Atilde */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Adiaeresis Aring AE Ccedilla */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Eth Ntilde Ograve Oacute */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Udiaeresis Yacute Thorn ssharp */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* agrave aacute acircumflex atilde */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* adiaeresis aring ae ccedilla */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* egrave eacute ecircumflex ediaeresis */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* igrave iacute icircumflex idiaeresis */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* eth ntilde ograve oacute */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* ocircumflex otilde odiaeresis division */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* oslash ugrave uacute ucircumflex */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* udiaeresis yacute thorn ydiaeresis */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, }; Const int csitable[] = /* ESC [ */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* NP CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* $ % & ' */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* ( ) * + */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* , - . / */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* 0 1 2 3 */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, /* 4 5 6 7 */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, /* 8 9 : ; */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_IGNORE, CASE_ESC_SEMI, /* < = > ? */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_DEC_STATE, /* @ A B C */ CASE_ICH, CASE_CUU, CASE_CUD, CASE_CUF, /* D E F G */ CASE_CUB, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* H I J K */ CASE_CUP, CASE_GROUND_STATE, CASE_ED, CASE_EL, /* L M N O */ CASE_IL, CASE_DL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_DCH, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* T U V W */ CASE_TRACK_MOUSE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_DA1, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_CUP, CASE_TBC, /* h i j k */ CASE_SET, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_RST, CASE_SGR, CASE_CPR, CASE_GROUND_STATE, /* p q r s */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_DECSTBM, CASE_GROUND_STATE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_DECREQTPARM, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* currency yen brokenbar section */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* notsign hyphen registered macron */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* degree plusminus twosuperior threesuperior */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* acute mu paragraph periodcentered */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* cedilla onesuperior masculine guillemotright */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* onequarter onehalf threequarters questiondown */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, }; Const int dectable[] = /* ESC [ ? */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* NP CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* $ % & ' */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* ( ) * + */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* , - . / */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* 0 1 2 3 */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, /* 4 5 6 7 */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, /* 8 9 : ; */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_IGNORE, CASE_ESC_SEMI, /* < = > ? */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* @ A B C */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* D E F G */ CASE_GROUND_STATE, #ifdef STATUSLINE CASE_ERASE_STATUS, CASE_FROM_STATUS, #else /* !STATUSLINE */ CASE_GROUND_STATE, CASE_GROUND_STATE, #endif /* !STATUSLINE */ CASE_GROUND_STATE, /* H I J K */ #ifdef STATUSLINE CASE_HIDE_STATUS, #else /* !STATUSLINE */ CASE_GROUND_STATE, #endif /* !STATUSLINE */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* L M N O */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, #ifdef STATUSLINE CASE_SHOW_STATUS, #else /* !STATUSLINE */ CASE_GROUND_STATE, #endif /* !STATUSLINE */ /* T U V W */ #ifdef STATUSLINE CASE_TO_STATUS, #else /* !STATUSLINE */ CASE_GROUND_STATE, #endif /* !STATUSLINE */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_DECSET, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_DECRST, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* p q r s */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_XTERM_RESTORE, CASE_XTERM_SAVE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* currency yen brokenbar section */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* notsign hyphen registered macron */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* degree plusminus twosuperior threesuperior */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* acute mu paragraph periodcentered */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* cedilla onesuperior masculine guillemotright */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* onequarter onehalf threequarters questiondown */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, }; Const int eigtable[] = /* CASE_ESC_IGNORE */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* NP CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* $ % & ' */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ( ) * + */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* , - . / */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0 1 2 3 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 4 5 6 7 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 8 9 : ; */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* < = > ? */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* @ A B C */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* D E F G */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* H I J K */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* L M N O */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* T U V W */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* p q r s */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* currency yen brokenbar section */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* notsign hyphen registered macron */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* degree plusminus twosuperior threesuperior */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* acute mu paragraph periodcentered */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* cedilla onesuperior masculine guillemotright */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* onequarter onehalf threequarters questiondown */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, }; Const int esctable[] = /* ESC */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* NP CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_SCR_STATE, /* $ % & ' */ #ifdef KTERM_MBCS CASE_MBCS, #else /* !KTERM_MBCS */ CASE_ESC_IGNORE, #endif /* !KTERM_MBCS */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* ( ) * + */ #ifdef KTERM CASE_SCS_STATE, CASE_SCS_STATE, CASE_SCS_STATE, CASE_SCS_STATE, #else /* !KTERM */ CASE_SCS0_STATE, CASE_SCS1_STATE, CASE_SCS2_STATE, CASE_SCS3_STATE, #endif /* !KTERM */ /* , - . / */ #ifdef KTERM CASE_SCS_STATE, /* not defined in ISO2022 but used in Mule */ CASE_SCS_STATE, CASE_SCS_STATE, CASE_SCS_STATE, #else /* !KTERM */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, #endif /* !KTERM */ /* 0 1 2 3 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 4 5 6 7 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_DECSC, /* 8 9 : ; */ CASE_DECRC, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* < = > ? */ CASE_GROUND_STATE, CASE_DECKPAM, CASE_DECKPNM, CASE_GROUND_STATE, /* @ A B C */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* D E F G */ CASE_IND, CASE_NEL, CASE_HP_BUGGY_LL, CASE_GROUND_STATE, /* H I J K */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* L M N O */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* P Q R S */ CASE_IGNORE_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* T U V W */ CASE_XTERM_TITLE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_OSC, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_RIS, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_HP_MEM_LOCK, CASE_HP_MEM_UNLOCK, CASE_LS2, CASE_LS3, /* p q r s */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_LS3R, CASE_LS2R, CASE_LS1R, CASE_GROUND_STATE, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* currency yen brokenbar section */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* notsign hyphen registered macron */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* degree plusminus twosuperior threesuperior */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* acute mu paragraph periodcentered */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* cedilla onesuperior masculine guillemotright */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* onequarter onehalf threequarters questiondown */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, }; Const int iestable[] = /* CASE_IGNORE_ESC */ { /* NUL SOH STX ETX */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* EOT ENQ ACK BEL */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* BS HT NL VT */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* NP CR SO SI */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* DLE DC1 DC2 DC3 */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* DC4 NAK SYN ETB */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* CAN EM SUB ESC */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* FS GS RS US */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* SP ! " # */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* $ % & ' */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* ( ) * + */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* , - . / */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* 0 1 2 3 */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* 4 5 6 7 */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* 8 9 : ; */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* < = > ? */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* @ A B C */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* D E F G */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* H I J K */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* L M N O */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* P Q R S */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* T U V W */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* X Y Z [ */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* ` a b c */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* d e f g */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* h i j k */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* l m n o */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* p q r s */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* t u v w */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* x y z { */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* | } ~ DEL */ CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* currency yen brokenbar section */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* notsign hyphen registered macron */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* degree plusminus twosuperior threesuperior */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* acute mu paragraph periodcentered */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* cedilla onesuperior masculine guillemotright */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* onequarter onehalf threequarters questiondown */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, }; Const int igntable[] = /* CASE_IGNORE_STATE */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* BS HT NL VT */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* NP CR SO SI */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_IGNORE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* $ % & ' */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ( ) * + */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* , - . / */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0 1 2 3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 4 5 6 7 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 8 9 : ; */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* < = > ? */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* @ A B C */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* D E F G */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* H I J K */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* L M N O */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* P Q R S */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* T U V W */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* X Y Z [ */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* \ ] ^ _ */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ` a b c */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* d e f g */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* h i j k */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* l m n o */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* p q r s */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* t u v w */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* x y z { */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* | } ~ DEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* currency yen brokenbar section */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* notsign hyphen registered macron */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* degree plusminus twosuperior threesuperior */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* acute mu paragraph periodcentered */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* cedilla onesuperior masculine guillemotright */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* onequarter onehalf threequarters questiondown */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, }; Const int scrtable[] = /* ESC # */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* NP CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* $ % & ' */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* ( ) * + */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* , - . / */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* 0 1 2 3 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 4 5 6 7 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 8 9 : ; */ CASE_DECALN, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* < = > ? */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* @ A B C */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* D E F G */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* H I J K */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* L M N O */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* T U V W */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* p q r s */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* currency yen brokenbar section */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* notsign hyphen registered macron */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* degree plusminus twosuperior threesuperior */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* acute mu paragraph periodcentered */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* cedilla onesuperior masculine guillemotright */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* onequarter onehalf threequarters questiondown */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, }; Const int scstable[] = /* ESC ( etc. */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* NP CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* $ % & ' */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* ( ) * + */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* , - . / */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, #ifdef KTERM /* 0 1 2 3 */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* 4 5 6 7 */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* 8 9 : ; */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* < = > ? */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* @ A B C */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* D E F G */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* H I J K */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* L M N O */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* P Q R S */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* T U V W */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* X Y Z [ */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* \ ] ^ _ */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* ` a b c */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* d e f g */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* h i j k */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* l m n o */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GROUND_STATE, /* GSET('p') >= 0x40 (MBCS flag) */ /* p q r s */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* empty character set */ CASE_GROUND_STATE, #else /* !KTERM */ /* 0 1 2 3 */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GROUND_STATE, /* 4 5 6 7 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 8 9 : ; */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* < = > ? */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* @ A B C */ CASE_GROUND_STATE, CASE_GSETS, CASE_GSETS, CASE_GROUND_STATE, /* D E F G */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* H I J K */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* L M N O */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* T U V W */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* p q r s */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, #endif /* !KTERM */ /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* currency yen brokenbar section */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* notsign hyphen registered macron */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* degree plusminus twosuperior threesuperior */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* acute mu paragraph periodcentered */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* cedilla onesuperior masculine guillemotright */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* onequarter onehalf threequarters questiondown */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, }; #ifdef KTERM_MBCS Const int mbcstable[] = { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* NP CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* $ % & ' */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* ( ) * + */ CASE_SCS_STATE, CASE_SCS_STATE, CASE_SCS_STATE, CASE_SCS_STATE, /* , - . / */ CASE_ESC_IGNORE, CASE_SCS_STATE, CASE_SCS_STATE, CASE_SCS_STATE, /* 0 1 2 3 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 4 5 6 7 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 8 9 : ; */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* < = > ? */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* @ A B C */ CASE_GSETS, /* ESC-$-@ (JIS-78) */ CASE_GSETS, /* ESC-$-A (GB) */ CASE_GSETS, /* ESC-$-B (JIS-83) */ CASE_GROUND_STATE, /* D E F G */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* H I J K */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* L M N O */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_IGNORE_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* T U V W */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE_STATE, CASE_IGNORE_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* p q r s */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* currency yen brokenbar section */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* notsign hyphen registered macron */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* degree plusminus twosuperior threesuperior */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* acute mu paragraph periodcentered */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* cedilla onesuperior masculine guillemotright */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* onequarter onehalf threequarters questiondown */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, }; Const int smbcstable[] = { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* NP CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* $ % & ' */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* ( ) * + */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* , - . / */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* 0 1 2 3 */ CASE_GROUND_STATE, /* (2-byte or more) private character set */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 4 5 6 7 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 8 9 : ; */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* < = > ? */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* @ A B C */ CASE_GSETS, /* ESC-$-I-F */ CASE_GSETS, CASE_GSETS, CASE_GSETS, /* D E F G */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* H I J K */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* L M N O */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* P Q R S */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* T U V W */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* X Y Z [ */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* \ ] ^ _ */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* ` a b c */ CASE_GROUND_STATE, /* 3-byte character set */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* p q r s */ CASE_GROUND_STATE, /* 4-byte character set */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* currency yen brokenbar section */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* notsign hyphen registered macron */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* degree plusminus twosuperior threesuperior */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* acute mu paragraph periodcentered */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* cedilla onesuperior masculine guillemotright */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* onequarter onehalf threequarters questiondown */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, }; #endif /* KTERM_MBCS */ kterm-6.2.0.orig/VTparse.def100444 507 454 2327 6160504451 14356 0ustar yosiakiaux# # $XConsortium: VTparse.def,v 1.4 92/09/15 15:28:31 gildea Exp $ # $Id: VTparse.def,v 6.1 1996/06/15 09:57:20 kagotani Rel $ # # List of symbols that need to be defined for VTparse.h. If you need to # change any of the CASE_ macros, make the change here and rerun the command # shown in VTparse.h. # CASE_GROUND_STATE CASE_IGNORE_STATE CASE_IGNORE_ESC CASE_IGNORE CASE_BELL CASE_BS CASE_CR CASE_ESC CASE_VMOT CASE_TAB CASE_SI CASE_SO CASE_SCR_STATE CASE_SCS0_STATE CASE_SCS1_STATE CASE_SCS2_STATE CASE_SCS3_STATE CASE_ESC_IGNORE CASE_ESC_DIGIT CASE_ESC_SEMI CASE_DEC_STATE CASE_ICH CASE_CUU CASE_CUD CASE_CUF CASE_CUB CASE_CUP CASE_ED CASE_EL CASE_IL CASE_DL CASE_DCH CASE_DA1 CASE_TRACK_MOUSE CASE_TBC CASE_SET CASE_RST CASE_SGR CASE_CPR CASE_DECSTBM CASE_DECREQTPARM CASE_DECSET CASE_DECRST CASE_DECALN CASE_GSETS CASE_DECSC CASE_DECRC CASE_DECKPAM CASE_DECKPNM CASE_IND CASE_NEL CASE_HTS CASE_RI CASE_SS2 CASE_SS3 CASE_CSI_STATE CASE_OSC CASE_RIS CASE_LS2 CASE_LS3 CASE_LS3R CASE_LS2R CASE_LS1R CASE_PRINT CASE_XTERM_SAVE CASE_XTERM_RESTORE CASE_XTERM_TITLE CASE_DECID CASE_HP_MEM_LOCK CASE_HP_MEM_UNLOCK CASE_HP_BUGGY_LL CASE_TO_STATUS CASE_FROM_STATUS CASE_SHOW_STATUS CASE_HIDE_STATUS CASE_ERASE_STATUS CASE_MBCS CASE_SCS_STATE kterm-6.2.0.orig/VTparse.h100444 507 454 6542 6160504452 14053 0ustar yosiakiaux/* * $XConsortium: VTparse.h,v 1.6 92/09/15 15:28:31 gildea Exp $ * $Id: VTparse.h,v 6.1 1996/06/15 09:57:20 kagotani Rel $ */ #include "kterm.h" /* * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ /* * The following list of definitions is generated from VTparse.def using the * following command line: * * grep '^CASE_' VTparse.def | awk '{printf "#define %s %d\n", $1, n++}' * * You you need to change something, change VTparse.def and regenerate the * definitions. This would have been automatic, but since this doesn't change * very often, it isn't worth the makefile hassle. */ #define CASE_GROUND_STATE 0 #define CASE_IGNORE_STATE 1 #define CASE_IGNORE_ESC 2 #define CASE_IGNORE 3 #define CASE_BELL 4 #define CASE_BS 5 #define CASE_CR 6 #define CASE_ESC 7 #define CASE_VMOT 8 #define CASE_TAB 9 #define CASE_SI 10 #define CASE_SO 11 #define CASE_SCR_STATE 12 #define CASE_SCS0_STATE 13 #define CASE_SCS1_STATE 14 #define CASE_SCS2_STATE 15 #define CASE_SCS3_STATE 16 #define CASE_ESC_IGNORE 17 #define CASE_ESC_DIGIT 18 #define CASE_ESC_SEMI 19 #define CASE_DEC_STATE 20 #define CASE_ICH 21 #define CASE_CUU 22 #define CASE_CUD 23 #define CASE_CUF 24 #define CASE_CUB 25 #define CASE_CUP 26 #define CASE_ED 27 #define CASE_EL 28 #define CASE_IL 29 #define CASE_DL 30 #define CASE_DCH 31 #define CASE_DA1 32 #define CASE_TRACK_MOUSE 33 #define CASE_TBC 34 #define CASE_SET 35 #define CASE_RST 36 #define CASE_SGR 37 #define CASE_CPR 38 #define CASE_DECSTBM 39 #define CASE_DECREQTPARM 40 #define CASE_DECSET 41 #define CASE_DECRST 42 #define CASE_DECALN 43 #define CASE_GSETS 44 #define CASE_DECSC 45 #define CASE_DECRC 46 #define CASE_DECKPAM 47 #define CASE_DECKPNM 48 #define CASE_IND 49 #define CASE_NEL 50 #define CASE_HTS 51 #define CASE_RI 52 #define CASE_SS2 53 #define CASE_SS3 54 #define CASE_CSI_STATE 55 #define CASE_OSC 56 #define CASE_RIS 57 #define CASE_LS2 58 #define CASE_LS3 59 #define CASE_LS3R 60 #define CASE_LS2R 61 #define CASE_LS1R 62 #define CASE_PRINT 63 #define CASE_XTERM_SAVE 64 #define CASE_XTERM_RESTORE 65 #define CASE_XTERM_TITLE 66 #define CASE_DECID 67 #define CASE_HP_MEM_LOCK 68 #define CASE_HP_MEM_UNLOCK 69 #define CASE_HP_BUGGY_LL 70 #define CASE_TO_STATUS 71 #define CASE_FROM_STATUS 72 #define CASE_SHOW_STATUS 73 #define CASE_HIDE_STATUS 74 #define CASE_ERASE_STATUS 75 #define CASE_MBCS 76 #define CASE_SCS_STATE 77 kterm-6.2.0.orig/button.c100444 507 454 141154 6166126472 14044 0ustar yosiakiaux/* $XConsortium: button.c /main/70 1996/01/14 16:52:34 kaleb $ */ /* $Id: button.c,v 6.2 1996/07/02 05:01:31 kagotani Rel $ */ /* * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ /* button.c Handles button events in the terminal emulator. does cut/paste operations, change modes via menu, passes button events through to some applications. J. Gettys. */ #include "ptyx.h" /* Xlib headers included here. */ #include #include #include #include #include "data.h" #include "error.h" #include "menu.h" extern char *malloc(); extern void DoSecureKeyboard(); #define KeyState(x) (((x) & (ShiftMask|ControlMask)) + (((x) & Mod1Mask) ? 2 : 0)) /* adds together the bits: shift key -> 1 meta key -> 2 control key -> 4 */ #define TEXTMODES 4 #define NBUTS 3 #define DIRS 2 #define UP 1 #define DOWN 0 #define SHIFTS 8 /* three keys, so eight combinations */ #define Coordinate(r,c) ((r) * (term->screen.max_col+1) + (c)) extern char *xterm_name; static void PointToRowCol(); static void SelectionReceived(); static void TrackDown(); static void ComputeSelect(); static void EditorButton(); static void ExtendExtend(); static void ReHiliteText(); static void SelectSet(); static void StartSelect(); static int Length(); #ifdef KTERM static Ichr *SaveText(); #else /* !KTERM */ static char *SaveText(); #endif /* !KTERM */ extern XtermWidget term; /* Selection/extension variables */ /* Raw char position where the selection started */ static int rawRow, rawCol; /* Selected area before CHAR, WORD, LINE selectUnit processing */ static int startRRow, startRCol, endRRow, endRCol = 0; /* Selected area after CHAR, WORD, LINE selectUnit processing */ static int startSRow, startSCol, endSRow, endSCol = 0; /* Valid rows for selection clipping */ static int firstValidRow, lastValidRow; /* Start, end of extension */ static int startERow, startECol, endERow, endECol; /* Saved values of raw selection for extend to restore to */ static int saveStartRRow, saveStartRCol, saveEndRRow, saveEndRCol; /* Multi-click handling */ static int numberOfClicks = 0; #ifdef ENBUG /* kagotani */ static long int lastButtonUpTime = 0; #else static Time lastButtonUpTime = 0; #endif typedef int SelectUnit; #define SELECTCHAR 0 #define SELECTWORD 1 #define SELECTLINE 2 #define NSELECTUNITS 3 static SelectUnit selectUnit; /* Send emacs escape code when done selecting or extending? */ static int replyToEmacs; #if defined(KTERM) && defined(KTERM_MBCC) /* * by Kiyoshi KANAZAWA, Nov. 29, 1990. * Support word-select for MBCS. */ static int mbcsCharClass (); #endif /* KTERM && KTERM_MBCC */ Boolean SendMousePosition(w, event) Widget w; XEvent* event; { register TScreen *screen = &((XtermWidget)w)->screen; if (screen->send_mouse_pos == 0) return False; if (event->type != ButtonPress && event->type != ButtonRelease) return False; #define KeyModifiers \ (event->xbutton.state & (ShiftMask | LockMask | ControlMask | Mod1Mask | \ Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask )) #define ButtonModifiers \ (event->xbutton.state & (ShiftMask | LockMask | ControlMask | Mod1Mask | \ Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask )) switch (screen->send_mouse_pos) { case 1: /* X10 compatibility sequences */ if (KeyModifiers == 0) { if (event->type == ButtonPress) EditorButton(event); return True; } return False; case 2: /* DEC vt200 compatible */ if (KeyModifiers == 0 || KeyModifiers == ControlMask) { EditorButton(event); return True; } return False; case 3: /* DEC vt200 hilite tracking */ if ( event->type == ButtonPress && KeyModifiers == 0 && event->xbutton.button == Button1 ) { TrackDown(event); return True; } if (KeyModifiers == 0 || KeyModifiers == ControlMask) { EditorButton(event); return True; } /* fall through */ default: return False; } #undef KeyModifiers } /*ARGSUSED*/ void HandleSelectExtend(w, event, params, num_params) Widget w; XEvent *event; /* must be XMotionEvent */ String *params; /* unused */ Cardinal *num_params; /* unused */ { register TScreen *screen = &((XtermWidget)w)->screen; int row, col; screen->selection_time = event->xmotion.time; switch (eventMode) { case LEFTEXTENSION : case RIGHTEXTENSION : PointToRowCol (event->xmotion.y, event->xmotion.x, &row, &col); ExtendExtend (row, col); break; case NORMAL : /* will get here if send_mouse_pos != 0 */ break; } } static void EndExtend(); static void do_select_end (w, event, params, num_params, use_cursor_loc) Widget w; XEvent *event; /* must be XButtonEvent */ String *params; /* selections */ Cardinal *num_params; Bool use_cursor_loc; { ((XtermWidget)w)->screen.selection_time = event->xbutton.time; switch (eventMode) { case NORMAL : (void) SendMousePosition(w, event); break; case LEFTEXTENSION : case RIGHTEXTENSION : EndExtend(w, event, params, *num_params, use_cursor_loc); break; } } void HandleSelectEnd(w, event, params, num_params) Widget w; XEvent *event; /* must be XButtonEvent */ String *params; /* selections */ Cardinal *num_params; { do_select_end (w, event, params, num_params, False); } void HandleKeyboardSelectEnd(w, event, params, num_params) Widget w; XEvent *event; /* must be XButtonEvent */ String *params; /* selections */ Cardinal *num_params; { do_select_end (w, event, params, num_params, True); } struct _SelectionList { String *params; Cardinal count; Time time; #ifdef KTERM /* from exterm */ Boolean asked; Atom selection; #endif /* KTERM */ }; static void _GetSelection(w, time, params, num_params) Widget w; Time time; String *params; /* selections in precedence order */ Cardinal num_params; { Atom selection; int cutbuffer; XmuInternStrings(XtDisplay(w), params, (Cardinal)1, &selection); switch (selection) { case XA_CUT_BUFFER0: cutbuffer = 0; break; case XA_CUT_BUFFER1: cutbuffer = 1; break; case XA_CUT_BUFFER2: cutbuffer = 2; break; case XA_CUT_BUFFER3: cutbuffer = 3; break; case XA_CUT_BUFFER4: cutbuffer = 4; break; case XA_CUT_BUFFER5: cutbuffer = 5; break; case XA_CUT_BUFFER6: cutbuffer = 6; break; case XA_CUT_BUFFER7: cutbuffer = 7; break; default: cutbuffer = -1; } if (cutbuffer >= 0) { register TScreen *screen = &((XtermWidget)w)->screen; int inbytes; unsigned long nbytes; int fmt8 = 8; Atom type = XA_STRING; char *line = XFetchBuffer(screen->display, &inbytes, cutbuffer); nbytes = (unsigned long) inbytes; if (nbytes > 0) SelectionReceived(w, NULL, &selection, &type, (XtPointer)line, &nbytes, &fmt8); else if (num_params > 1) _GetSelection(w, time, params+1, num_params-1); } else { struct _SelectionList* list; if (--num_params) { list = XtNew(struct _SelectionList); list->params = params + 1; list->count = num_params; /* decremented above */ list->time = time; #ifdef KTERM /* from exterm */ list->asked = True; list->selection = selection; #endif /* KTERM */ } else list = NULL; #ifdef KTERM XtGetSelectionValue(w, selection, XA_TEXT(XtDisplay(w)), SelectionReceived, (XtPointer)list, time); #else /* !KTERM */ XtGetSelectionValue(w, selection, XA_STRING, SelectionReceived, (XtPointer)list, time); #endif /* !KTERM */ } } /* SelectionReceived: stuff received selection text into pty */ /* ARGSUSED */ static void SelectionReceived(w, client_data, selection, type, value, length, format) Widget w; XtPointer client_data; Atom *selection, *type; XtPointer value; unsigned long *length; int *format; { int pty = ((XtermWidget)w)->screen.respond; /* file descriptor of pty */ register char *lag, *cp, *end; char *line = (char*)value; #ifdef KTERM char lbuf[256 + 1]; #endif /* KTERM */ if (*type == 0 /*XT_CONVERT_FAIL*/ || *length == 0 || value == NULL) { /* could not get this selection, so see if there are more to try */ struct _SelectionList* list = (struct _SelectionList*)client_data; if (list != NULL) { #ifdef KTERM /* from exterm */ /* ask XA_STRING again. * Warning: hope owner not triggered between the 2 requests * XA_STRING and XA_COMPOUNT_TEXT. */ if (list->asked) { list->asked = False; XtGetSelectionValue(w, list->selection, XA_STRING, SelectionReceived, (XtPointer)list, list->time); } else { _GetSelection(w, list->time, list->params, list->count); XtFree(client_data); } #else /* !KTERM */ _GetSelection(w, list->time, list->params, list->count); XtFree(client_data); #endif /* !KTERM */ } return; } #ifdef KTERM if (*type == XA_COMPOUND_TEXT(XtDisplay(w))) { Char *ct = (Char *)value; Ichr *cs; int (*func)(); int n; int convCStoJIS(); # ifdef KTERM_KANJIMODE int convCStoEUC(), convCStoSJIS(); # endif /* KTERM_KANJIMODE */ Ichr cbuf[256 + 1]; n = convCTtoCS(ct, *length, NULL); if (n < 0) { /* data broken */ XtFree(client_data); XtFree(value); return; } cs = (n > 256) ? (Ichr *)XtMalloc((n + 1) * sizeof(Ichr)) : cbuf; (void)convCTtoCS(ct, *length, cs); # ifdef KTERM_KANJIMODE switch (((XtermWidget)w)->flags & (EUC_KANJI|SJIS_KANJI)) { case EUC_KANJI: func = convCStoEUC; break; case SJIS_KANJI: func = convCStoSJIS; break; default: func = convCStoJIS; break; } # else /* !KTERM_KANJIMODE */ func = convCStoJIS; # endif /* !KTERM_KANJIMODE */ n = (*func)(cs, NULL); line = (n > 256) ? XtMalloc(n + 1) : lbuf; (void)(*func)(cs, line); end = line + n; if (cs != cbuf) XtFree((char *)cs); } else { /* must be XA_STRING */ char *p, *q; int n = *length; line = (n > 256) ? XtMalloc(n + 1) : lbuf; memmove( line, (char *)value, n); line[n] = '\0'; p = (char *) value; q = line; while (n-- > 0) { if (!(*p & 0x80)) { *q++ = *p; } p++; } end = q; } #else /* !KTERM */ /* Write data to pty a line at a time. */ /* Doing this one line at a time may no longer be necessary because v_write has been re-written. */ end = &line[*length]; #endif /* !KTERM */ lag = line; for (cp = line; cp != end; cp++) { if (*cp != '\n') continue; *cp = '\r'; v_write(pty, lag, cp - lag + 1); lag = cp + 1; } if (lag != end) v_write(pty, lag, end - lag); #ifdef KTERM if (line != lbuf) XtFree(line); #endif /* KTERM */ XtFree(client_data); XtFree(value); } void HandleInsertSelection(w, event, params, num_params) Widget w; XEvent *event; /* assumed to be XButtonEvent* */ String *params; /* selections in precedence order */ Cardinal *num_params; { if (SendMousePosition(w, event)) return; _GetSelection(w, event->xbutton.time, params, *num_params); } static void SetSelectUnit(buttonDownTime, defaultUnit) Time buttonDownTime; SelectUnit defaultUnit; { #ifdef ENBUG /* kagotani */ /* Do arithmetic as integers, but compare as unsigned solves clock wraparound */ if ((long unsigned)((long int)buttonDownTime - lastButtonUpTime) #else if (buttonDownTime - lastButtonUpTime #endif > term->screen.multiClickTime) { numberOfClicks = 1; selectUnit = defaultUnit; } else { ++numberOfClicks; selectUnit = ((selectUnit + 1) % NSELECTUNITS); } } static void do_select_start (w, event, startrow, startcol) Widget w; XEvent *event; /* must be XButtonEvent* */ int startrow, startcol; { if (SendMousePosition(w, event)) return; SetSelectUnit(event->xbutton.time, SELECTCHAR); replyToEmacs = FALSE; StartSelect(startrow, startcol); } /* ARGSUSED */ void HandleSelectStart(w, event, params, num_params) Widget w; XEvent *event; /* must be XButtonEvent* */ String *params; /* unused */ Cardinal *num_params; /* unused */ { register TScreen *screen = &((XtermWidget)w)->screen; int startrow, startcol; firstValidRow = 0; lastValidRow = screen->max_row; PointToRowCol(event->xbutton.y, event->xbutton.x, &startrow, &startcol); do_select_start (w, event, startrow, startcol); } /* ARGSUSED */ void HandleKeyboardSelectStart(w, event, params, num_params) Widget w; XEvent *event; /* must be XButtonEvent* */ String *params; /* unused */ Cardinal *num_params; /* unused */ { register TScreen *screen = &((XtermWidget)w)->screen; do_select_start (w, event, screen->cursor_row, screen->cursor_col); } static void TrackDown(event) register XButtonEvent *event; { int startrow, startcol; SetSelectUnit(event->time, SELECTCHAR); if (numberOfClicks > 1 ) { PointToRowCol(event->y, event->x, &startrow, &startcol); replyToEmacs = TRUE; StartSelect(startrow, startcol); } else { waitingForTrackInfo = 1; EditorButton(event); } } #define boundsCheck(x) if (x < 0) \ x = 0; \ else if (x >= screen->max_row) \ x = screen->max_row; void TrackMouse(func, startrow, startcol, firstrow, lastrow) int func, startrow, startcol, firstrow, lastrow; { TScreen *screen = &term->screen; if (!waitingForTrackInfo) { /* Timed out, so ignore */ return; } waitingForTrackInfo = 0; if (func == 0) return; boundsCheck (startrow) boundsCheck (firstrow) boundsCheck (lastrow) firstValidRow = firstrow; lastValidRow = lastrow; replyToEmacs = TRUE; StartSelect(startrow, startcol); } static void StartSelect(startrow, startcol) int startrow, startcol; { TScreen *screen = &term->screen; if (screen->cursor_state) HideCursor (); if (numberOfClicks == 1) { /* set start of selection */ rawRow = startrow; rawCol = startcol; } /* else use old values in rawRow, Col */ saveStartRRow = startERow = rawRow; saveStartRCol = startECol = rawCol; saveEndRRow = endERow = rawRow; saveEndRCol = endECol = rawCol; if (Coordinate(startrow, startcol) < Coordinate(rawRow, rawCol)) { eventMode = LEFTEXTENSION; startERow = startrow; startECol = startcol; } else { eventMode = RIGHTEXTENSION; endERow = startrow; endECol = startcol; } ComputeSelect(startERow, startECol, endERow, endECol, False); } static void EndExtend(w, event, params, num_params, use_cursor_loc) Widget w; XEvent *event; /* must be XButtonEvent */ String *params; /* selections */ Cardinal num_params; Bool use_cursor_loc; { int row, col; TScreen *screen = &term->screen; char line[9]; if (use_cursor_loc) { row = screen->cursor_row; col = screen->cursor_col; } else { PointToRowCol(event->xbutton.y, event->xbutton.x, &row, &col); } ExtendExtend (row, col); lastButtonUpTime = event->xbutton.time; if (startSRow != endSRow || startSCol != endSCol) { if (replyToEmacs) { if (rawRow == startSRow && rawCol == startSCol && row == endSRow && col == endSCol) { /* Use short-form emacs select */ strcpy(line, "\033[t"); line[3] = ' ' + endSCol + 1; line[4] = ' ' + endSRow + 1; v_write(screen->respond, line, 5); } else { /* long-form, specify everything */ strcpy(line, "\033[T"); line[3] = ' ' + startSCol + 1; line[4] = ' ' + startSRow + 1; line[5] = ' ' + endSCol + 1; line[6] = ' ' + endSRow + 1; line[7] = ' ' + col + 1; line[8] = ' ' + row + 1; v_write(screen->respond, line, 9); } TrackText(0, 0, 0, 0); } } SelectSet(w, event, params, num_params); eventMode = NORMAL; } void HandleSelectSet(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { SelectSet (w, event, params, *num_params); } static void SaltTextAway(); /* ARGSUSED */ static void SelectSet (w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal num_params; { /* Only do select stuff if non-null select */ if (startSRow != endSRow || startSCol != endSCol) { SaltTextAway(startSRow, startSCol, endSRow, endSCol, params, num_params); } else DisownSelection(term); } #define Abs(x) ((x) < 0 ? -(x) : (x)) /* ARGSUSED */ static void do_start_extend (w, event, params, num_params, use_cursor_loc) Widget w; XEvent *event; /* must be XButtonEvent* */ String *params; /* unused */ Cardinal *num_params; /* unused */ Bool use_cursor_loc; { TScreen *screen = &((XtermWidget)w)->screen; int row, col, coord; if (SendMousePosition(w, event)) return; firstValidRow = 0; lastValidRow = screen->max_row; SetSelectUnit(event->xbutton.time, selectUnit); replyToEmacs = FALSE; if (numberOfClicks == 1) { /* Save existing selection so we can reestablish it if the guy extends past the other end of the selection */ saveStartRRow = startERow = startRRow; saveStartRCol = startECol = startRCol; saveEndRRow = endERow = endRRow; saveEndRCol = endECol = endRCol; } else { /* He just needed the selection mode changed, use old values. */ startERow = startRRow = saveStartRRow; startECol = startRCol = saveStartRCol; endERow = endRRow = saveEndRRow; endECol = endRCol = saveEndRCol; } if (use_cursor_loc) { row = screen->cursor_row; col = screen->cursor_col; } else { PointToRowCol(event->xbutton.y, event->xbutton.x, &row, &col); } coord = Coordinate(row, col); if (Abs(coord - Coordinate(startSRow, startSCol)) < Abs(coord - Coordinate(endSRow, endSCol)) || coord < Coordinate(startSRow, startSCol)) { /* point is close to left side of selection */ eventMode = LEFTEXTENSION; startERow = row; startECol = col; } else { /* point is close to left side of selection */ eventMode = RIGHTEXTENSION; endERow = row; endECol = col; } ComputeSelect(startERow, startECol, endERow, endECol, True); } static void ExtendExtend (row, col) int row, col; { int coord = Coordinate(row, col); if (eventMode == LEFTEXTENSION && (coord + (selectUnit!=SELECTCHAR)) > Coordinate(endSRow, endSCol)) { /* Whoops, he's changed his mind. Do RIGHTEXTENSION */ eventMode = RIGHTEXTENSION; startERow = saveStartRRow; startECol = saveStartRCol; } else if (eventMode == RIGHTEXTENSION && coord < Coordinate(startSRow, startSCol)) { /* Whoops, he's changed his mind. Do LEFTEXTENSION */ eventMode = LEFTEXTENSION; endERow = saveEndRRow; endECol = saveEndRCol; } if (eventMode == LEFTEXTENSION) { startERow = row; startECol = col; } else { endERow = row; endECol = col; } ComputeSelect(startERow, startECol, endERow, endECol, False); } void HandleStartExtend(w, event, params, num_params) Widget w; XEvent *event; /* must be XButtonEvent* */ String *params; /* unused */ Cardinal *num_params; /* unused */ { do_start_extend (w, event, params, num_params, False); } void HandleKeyboardStartExtend(w, event, params, num_params) Widget w; XEvent *event; /* must be XButtonEvent* */ String *params; /* unused */ Cardinal *num_params; /* unused */ { do_start_extend (w, event, params, num_params, True); } ScrollSelection(screen, amount) register TScreen* screen; register int amount; { register int minrow = -screen->savedlines - screen->topline; register int maxrow = screen->max_row - screen->topline; register int maxcol = screen->max_col; #define scroll_update_one(row, col) \ row += amount; \ if (row < minrow) { \ row = minrow; \ col = 0; \ } \ if (row > maxrow) { \ row = maxrow; \ col = maxcol; \ } scroll_update_one(startRRow, startRCol); scroll_update_one(endRRow, endRCol); scroll_update_one(startSRow, startSCol); scroll_update_one(endSRow, endSCol); scroll_update_one(rawRow, rawCol); scroll_update_one(screen->startHRow, screen->startHCol); scroll_update_one(screen->endHRow, screen->endHCol); screen->startHCoord = Coordinate (screen->startHRow, screen->startHCol); screen->endHCoord = Coordinate (screen->endHRow, screen->endHCol); } /*ARGSUSED*/ ResizeSelection (screen, rows, cols) TScreen *screen; int rows, cols; { rows--; /* decr to get 0-max */ cols--; if (startRRow > rows) startRRow = rows; if (startSRow > rows) startSRow = rows; if (endRRow > rows) endRRow = rows; if (endSRow > rows) endSRow = rows; if (rawRow > rows) rawRow = rows; if (startRCol > cols) startRCol = cols; if (startSCol > cols) startSCol = cols; if (endRCol > cols) endRCol = cols; if (endSCol > cols) endSCol = cols; if (rawCol > cols) rawCol = cols; } static void PointToRowCol(y, x, r, c) register int y, x; int *r, *c; /* Convert pixel coordinates to character coordinates. Rows are clipped between firstValidRow and lastValidRow. Columns are clipped between to be 0 or greater, but are not clipped to some maximum value. */ { register TScreen *screen = &term->screen; register row, col; row = (y - screen->border) / FontHeight(screen); if(row < firstValidRow) row = firstValidRow; else if(row > lastValidRow) row = lastValidRow; col = (x - screen->border - screen->scrollbar) / FontWidth(screen); if(col < 0) col = 0; else if(col > screen->max_col+1) { col = screen->max_col+1; } *r = row; *c = col; } static int LastTextCol(row) register int row; { register TScreen *screen = &term->screen; register int i; #ifdef KTERM register Bchr *ch; #else /* !KTERM */ register Char *ch; #endif /* !KTERM */ for ( i = screen->max_col, #ifdef KTERM ch = screen->buf[row + screen->topline] + i ; i >= 0 && !(ch->attr & CHARDRAWN) ; ch--, i--) #else /* !KTERM */ ch = screen->buf[2 * (row + screen->topline) + 1] + i ; i >= 0 && !(*ch & CHARDRAWN) ; ch--, i--) #endif /* !KTERM */ ; return(i); } /* ** double click table for cut and paste in 8 bits ** ** This table is divided in four parts : ** ** - control characters [0,0x1f] U [0x80,0x9f] ** - separators [0x20,0x3f] U [0xa0,0xb9] ** - binding characters [0x40,0x7f] U [0xc0,0xff] ** - execeptions */ static int charClass[256] = { /* NUL SOH STX ETX EOT ENQ ACK BEL */ 32, 1, 1, 1, 1, 1, 1, 1, /* BS HT NL VT NP CR SO SI */ 1, 32, 1, 1, 1, 1, 1, 1, /* DLE DC1 DC2 DC3 DC4 NAK SYN ETB */ 1, 1, 1, 1, 1, 1, 1, 1, /* CAN EM SUB ESC FS GS RS US */ 1, 1, 1, 1, 1, 1, 1, 1, /* SP ! " # $ % & ' */ 32, 33, 34, 35, 36, 37, 38, 39, /* ( ) * + , - . / */ 40, 41, 42, 43, 44, 45, 46, 47, /* 0 1 2 3 4 5 6 7 */ 48, 48, 48, 48, 48, 48, 48, 48, /* 8 9 : ; < = > ? */ 48, 48, 58, 59, 60, 61, 62, 63, /* @ A B C D E F G */ 64, 48, 48, 48, 48, 48, 48, 48, /* H I J K L M N O */ 48, 48, 48, 48, 48, 48, 48, 48, /* P Q R S T U V W */ 48, 48, 48, 48, 48, 48, 48, 48, /* X Y Z [ \ ] ^ _ */ 48, 48, 48, 91, 92, 93, 94, 48, /* ` a b c d e f g */ 96, 48, 48, 48, 48, 48, 48, 48, /* h i j k l m n o */ 48, 48, 48, 48, 48, 48, 48, 48, /* p q r s t u v w */ 48, 48, 48, 48, 48, 48, 48, 48, /* x y z { | } ~ DEL */ 48, 48, 48, 123, 124, 125, 126, 1, /* x80 x81 x82 x83 IND NEL SSA ESA */ 1, 1, 1, 1, 1, 1, 1, 1, /* HTS HTJ VTS PLD PLU RI SS2 SS3 */ 1, 1, 1, 1, 1, 1, 1, 1, /* DCS PU1 PU2 STS CCH MW SPA EPA */ 1, 1, 1, 1, 1, 1, 1, 1, /* x98 x99 x9A CSI ST OSC PM APC */ 1, 1, 1, 1, 1, 1, 1, 1, /* - i c/ L ox Y- | So */ 160, 161, 162, 163, 164, 165, 166, 167, /* .. c0 ip << _ R0 - */ 168, 169, 170, 171, 172, 173, 174, 175, /* o +- 2 3 ' u q| . */ 176, 177, 178, 179, 180, 181, 182, 183, /* , 1 2 >> 1/4 1/2 3/4 ? */ 184, 185, 186, 187, 188, 189, 190, 191, /* A` A' A^ A~ A: Ao AE C, */ 48, 48, 48, 48, 48, 48, 48, 48, /* E` E' E^ E: I` I' I^ I: */ 48, 48, 48, 48, 48, 48, 48, 48, /* D- N~ O` O' O^ O~ O: X */ 48, 48, 48, 48, 48, 48, 48, 216, /* O/ U` U' U^ U: Y' P B */ 48, 48, 48, 48, 48, 48, 48, 48, /* a` a' a^ a~ a: ao ae c, */ 48, 48, 48, 48, 48, 48, 48, 48, /* e` e' e^ e: i` i' i^ i: */ 48, 48, 48, 48, 48, 48, 48, 48, /* d n~ o` o' o^ o~ o: -: */ 48, 48, 48, 48, 48, 48, 48, 248, /* o/ u` u' u^ u: y' P y: */ 48, 48, 48, 48, 48, 48, 48, 48}; int SetCharacterClassRange (low, high, value) register int low, high; /* in range of [0..255] */ register int value; /* arbitrary */ { if (low < 0 || high > 255 || high < low) return (-1); for (; low <= high; low++) charClass[low] = value; return (0); } /* * sets startSRow startSCol endSRow endSCol * ensuring that they have legal values */ static void ComputeSelect(startRow, startCol, endRow, endCol, extend) int startRow, startCol, endRow, endCol; Bool extend; { register TScreen *screen = &term->screen; #ifdef KTERM register Bchr *ptr; Char gset; #else /* !KTERM */ register Char *ptr; #endif /* !KTERM */ register int length; register int class; int osc = startSCol; if (Coordinate(startRow, startCol) <= Coordinate(endRow, endCol)) { startSRow = startRRow = startRow; startSCol = startRCol = startCol; endSRow = endRRow = endRow; endSCol = endRCol = endCol; } else { /* Swap them */ startSRow = startRRow = endRow; startSCol = startRCol = endCol; endSRow = endRRow = startRow; endSCol = endRCol = startCol; } switch (selectUnit) { case SELECTCHAR : if (startSCol > (LastTextCol(startSRow) + 1)) { startSCol = 0; startSRow++; } if (endSCol > (LastTextCol(endSRow) + 1)) { endSCol = 0; endSRow++; } break; case SELECTWORD : if (startSCol > (LastTextCol(startSRow) + 1)) { startSCol = 0; startSRow++; } else { #ifdef KTERM ptr = screen->buf[startSRow+screen->topline] + startSCol; #ifdef KTERM_MBCC if (ptr->gset == MBC2) { /* 2nd byte of a mbcs character */ startSCol--; ptr--; } if (ptr->gset != MBC2 && (ptr->gset & MBCS) != 0) { /* 1st byte of a mbcs character */ class = mbcsCharClass (ptr); do { startSCol -= 2; ptr -= 2; } while (startSCol >= 0 && ptr->gset != MBC2 && (ptr->gset & MBCS) != 0 && class == mbcsCharClass (ptr)); startSCol++; ptr++; } else if (ptr->gset == GSET_KANA) do { --startSCol; --ptr; } while (startSCol >= 0 && ptr->gset == GSET_KANA); else { gset = ptr->gset; class = charClass[ptr->code]; do { --startSCol; --ptr; } while (startSCol >= 0 && ptr->gset == gset && charClass[ptr->code] == class); } #else /* !KTERM_MBCC */ class = charClass[ptr->code]; do { --startSCol; --ptr; } while (startSCol >= 0 && charClass[ptr->code] == class); #endif /* !KTERM_MBCC */ #else /* !KTERM */ ptr = screen->buf[2*(startSRow+screen->topline)] + startSCol; class = charClass[*ptr]; do { --startSCol; --ptr; } while (startSCol >= 0 && charClass[*ptr] == class); #endif /* !KTERM */ ++startSCol; } if (endSCol > (LastTextCol(endSRow) + 1)) { endSCol = 0; endSRow++; } else { length = LastTextCol(endSRow); #ifdef KTERM ptr = screen->buf[endSRow+screen->topline] + endSCol; #ifdef KTERM_MBCC if (ptr->gset == MBC2) { /* 2nd byte of a mbcs character */ endSCol--; ptr--; } if (ptr->gset != MBC2 && (ptr->gset & MBCS) != 0) { /* 1st byte of a mbcs character */ class = mbcsCharClass (ptr); do { endSCol += 2; ptr += 2; } while (endSCol < length && ptr->gset != MBC2 && (ptr->gset & MBCS) != 0 && class == mbcsCharClass (ptr)); } else if (ptr->gset == GSET_KANA) do { ++endSCol; ++ptr; } while (endSCol <= length && ptr->gset == GSET_KANA); else { gset = ptr->gset; class = charClass[ptr->code]; do { ++endSCol; ++ptr; } while (endSCol <= length && ptr->gset == gset && charClass[ptr->code] == class); } #else /* !KTERM_MBCC */ class = charClass[ptr->code]; do { ++endSCol; ++ptr; } while (endSCol <= length && charClass[ptr->code] == class); #endif /* !KTERM_MBCC */ #else /* !KTERM */ ptr = screen->buf[2*(endSRow+screen->topline)] + endSCol; class = charClass[*ptr]; do { ++endSCol; ++ptr; } while (endSCol <= length && charClass[*ptr] == class); #endif /* !KTERM */ /* Word select selects if pointing to any char in "word", especially in that it includes the last character in a word. So no --endSCol and do special eol handling */ if (endSCol > length+1) { endSCol = 0; ++endSRow; } } break; case SELECTLINE : if (term->screen.cutToBeginningOfLine) { startSCol = 0; } else if (!extend) { startSCol = osc; } if (term->screen.cutNewline) { endSCol = 0; ++endSRow; } else { endSCol = LastTextCol(endSRow) + 1; } break; } TrackText(startSRow, startSCol, endSRow, endSCol); return; } #if defined(KTERM) && defined(KTERM_MBCC) /* * by Kiyoshi KANAZAWA, Nov. 29, 1990. * * MBCS is divided to ARABIAN-number, ENGLISH, HIRAGANA, KATAKANA, * KANJI (including both dai_1_suijun and dai_2_suijun), GREEK, * RUSSIAN, KEISEN and OTHERS. * * It is assumed that * HIRAGANA, KATAKANA and KANJI belong to the same character class. * ARABIAN-number and ENGLISH belong to the same character class. * Each character in OTHERS makes one character class by itself. */ #define MBCS_ARABIAN 0 /* arabia suuji */ #define MBCS_ENGLISH MBCS_ARABIAN /* eigo */ #define MBCS_HIRAGANA (MBCS_ENGLISH + 1) /* hiragana */ #define MBCS_KATAKANA MBCS_HIRAGANA /* katakana */ #define MBCS_KANJI MBCS_KATAKANA /* kanji */ #define MBCS_GREEK (MBCS_KANJI + 1) /* girisha moji */ #define MBCS_RUSSIAN (MBCS_GREEK + 1) /* roshia moji */ #define MBCS_KEISEN (MBCS_RUSSIAN + 1) /* keisen */ static int mbcsCharClass (ptr) register Bchr *ptr; { register unsigned char c1, c2; c2 = (ptr + 1)->code; switch (c1 = ptr->code) { case 0x21: switch (c2) { case 0x38: case 0x39: case 0x3a: return (MBCS_KANJI); case 0x3c: return (MBCS_KATAKANA); } break; case 0x23: if (0x30 <= c2 && c2 <= 0x39) return (MBCS_ARABIAN); if (0x41 <= c2 && c2 <= 0x5a || 0x61 <= c2 && c2 <= 0x7a) return (MBCS_ENGLISH); break; case 0x24: if (0x21 <= c2 && c2 <= 0x73) return (MBCS_HIRAGANA); break; case 0x25: if (0x21 <= c2 && c2 <= 0x76) return (MBCS_KATAKANA); break; case 0x26: if (0x21 <= c2 && c2 <= 0x38 || 0x41 <= c2 && c2 <= 0x58) return (MBCS_GREEK); break; case 0x27: if (0x21 <= c2 && c2 <= 0x41 || 0x51 <= c2 && c2 <= 0x71) return (MBCS_RUSSIAN); break; case 0x28: if (0x21 <= c2 && c2 <= 0x40) return (MBCS_KEISEN); break; default: if (0x30 <= c1 && c1 <= 0x4e && 0x21 <= c2 && c2 <= 0x7e || c1 == 0x4f && (0x21 <= c2 || c2 <= 0x53)) /* dai_1_suijun */ return (MBCS_KANJI); if (0x50 <= c1 && c1 <= 0x73 && 0x21 <= c2 && c2 <= 0x7e || c1 == 0x74 && (0x21 <= c2 || c2 <= 0x24)) /* dai_2_suijun */ return (MBCS_KANJI); break; } return ((c1 << 8) | c2); /* return mbcs code */ } #endif /* KTERM && KTERM_MBCC */ TrackText(frow, fcol, trow, tcol) register int frow, fcol, trow, tcol; /* Guaranteed (frow, fcol) <= (trow, tcol) */ { register int from, to; register TScreen *screen = &term->screen; int old_startrow, old_startcol, old_endrow, old_endcol; old_startrow = screen->startHRow; old_startcol = screen->startHCol; old_endrow = screen->endHRow; old_endcol = screen->endHCol; if (frow == old_startrow && fcol == old_startcol && trow == old_endrow && tcol == old_endcol) return; screen->startHRow = frow; screen->startHCol = fcol; screen->endHRow = trow; screen->endHCol = tcol; from = Coordinate(frow, fcol); to = Coordinate(trow, tcol); if (to <= screen->startHCoord || from > screen->endHCoord) { /* No overlap whatsoever between old and new hilite */ ReHiliteText(old_startrow, old_startcol, old_endrow, old_endcol); ReHiliteText(frow, fcol, trow, tcol); } else { if (from < screen->startHCoord) { /* Extend left end */ ReHiliteText(frow, fcol, old_startrow, old_startcol); } else if (from > screen->startHCoord) { /* Shorten left end */ ReHiliteText(old_startrow, old_startcol, frow, fcol); } if (to > screen->endHCoord) { /* Extend right end */ ReHiliteText(old_endrow, old_endcol, trow, tcol); } else if (to < screen->endHCoord) { /* Shorten right end */ ReHiliteText(trow, tcol, old_endrow, old_endcol); } } screen->startHCoord = from; screen->endHCoord = to; } static void ReHiliteText(frow, fcol, trow, tcol) register int frow, fcol, trow, tcol; /* Guaranteed that (frow, fcol) <= (trow, tcol) */ { register TScreen *screen = &term->screen; register int i; if (frow < 0) frow = fcol = 0; else if (frow > screen->max_row) return; /* nothing to do, since trow >= frow */ if (trow < 0) return; /* nothing to do, since frow <= trow */ else if (trow > screen->max_row) { trow = screen->max_row; tcol = screen->max_col+1; } if (frow == trow && fcol == tcol) return; if(frow != trow) { /* do multiple rows */ if((i = screen->max_col - fcol + 1) > 0) { /* first row */ ScrnRefresh(screen, frow, fcol, 1, i, True); } if((i = trow - frow - 1) > 0) { /* middle rows*/ ScrnRefresh(screen, frow+1, 0,i, screen->max_col+1, True); } if(tcol > 0 && trow <= screen->max_row) { /* last row */ ScrnRefresh(screen, trow, 0, 1, tcol, True); } } else { /* do single row */ ScrnRefresh(screen, frow, fcol, 1, tcol - fcol, True); } } static void _OwnSelection(); static void 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 (may have row = screen->max_row+1, col = 0) */ { register TScreen *screen = &term->screen; register int i, j = 0; int eol; #ifdef KTERM Ichr *line, *lp; Bchr *ch; #else /* !KTERM */ char *line, *lp; #endif /* !KTERM */ if (crow == row && ccol > col) { int tmp = ccol; ccol = col; col = tmp; } --col; /* first we need to know how long the string is before we can save it*/ #ifdef KTERM ch = screen->buf[crow + screen->topline]; if (ch[ccol].gset == MBC2) ccol--; ch = screen->buf[row + screen->topline]; if (ch[col].gset & MBCS && ch[col].gset != MBC2) /* MBC1 */ col++; #endif /* !KTERM */ if ( row == crow ) j = Length(screen, crow, ccol, col); else { /* two cases, cut is on same line, cut spans multiple lines */ j += Length(screen, crow, ccol, screen->max_col) + 1; for(i = crow + 1; i < row; i++) j += Length(screen, i, 0, screen->max_col) + 1; if (col >= 0) j += Length(screen, row, 0, col); } /* now get some memory to save it in */ if (screen->selection_size <= j) { #ifdef KTERM if((line = (Ichr *)malloc((unsigned)((j + 1) * sizeof(Ichr)))) == (Ichr *)NULL) SysError(ERROR_BMALLOC2); XtFree((char *)screen->selection); #else /* !KTERM */ if((line = malloc((unsigned) j + 1)) == (char *)NULL) SysError(ERROR_BMALLOC2); XtFree(screen->selection); #endif /* !KTERM */ screen->selection = line; screen->selection_size = j + 1; } else line = screen->selection; if (!line || j < 0) return; #ifdef KTERM line[j].code = '\0'; /* make sure it is null terminated */ line[j].gset = 0; #else /* !KTERM */ line[j] = '\0'; /* make sure it is null terminated */ #endif /* !KTERM */ lp = line; /* lp points to where to save the text */ if ( row == crow ) lp = SaveText(screen, row, ccol, col, lp, &eol); else { lp = SaveText(screen, crow, ccol, screen->max_col, lp, &eol); if (eol) #ifdef KTERM { lp->code = '\n'; lp++->gset = GSET_ASCII; } #else /* !KTERM */ *lp ++ = '\n'; /* put in newline at end of line */ #endif /* !KTERM */ for(i = crow +1; i < row; i++) { lp = SaveText(screen, i, 0, screen->max_col, lp, &eol); if (eol) #ifdef KTERM { lp->code = '\n'; lp++->gset = GSET_ASCII; } #else /* !KTERM */ *lp ++ = '\n'; #endif /* !KTERM */ } if (col >= 0) lp = SaveText(screen, row, 0, col, lp, &eol); } #ifdef KTERM lp->code = '\0'; /* make sure we have end marked */ lp->gset = 0; #else /* !KTERM */ *lp = '\0'; /* make sure we have end marked */ #endif /* !KTERM */ screen->selection_length = (lp - line); _OwnSelection(term, params, num_params); } static Boolean ConvertSelection(w, selection, target, type, value, length, format) Widget w; Atom *selection, *target, *type; XtPointer *value; unsigned long *length; int *format; { Display* d = XtDisplay(w); XtermWidget xterm = (XtermWidget)w; if (xterm->screen.selection == NULL) return False; /* can this happen? */ if (*target == XA_TARGETS(d)) { Atom* targetP; Atom* std_targets; unsigned long std_length; XmuConvertStandardSelection( w, xterm->screen.selection_time, selection, target, type, (caddr_t*)&std_targets, &std_length, format ); *length = std_length + 5; *value = (XtPointer)XtMalloc(sizeof(Atom)*(*length)); targetP = *(Atom**)value; *targetP++ = XA_STRING; *targetP++ = XA_TEXT(d); *targetP++ = XA_COMPOUND_TEXT(d); *targetP++ = XA_LENGTH(d); *targetP++ = XA_LIST_LENGTH(d); memmove( (char*)targetP, (char*)std_targets, sizeof(Atom)*std_length); XtFree((char*)std_targets); *type = XA_ATOM; *format = 32; return True; } if (*target == XA_STRING || *target == XA_TEXT(d) || *target == XA_COMPOUND_TEXT(d)) { #ifdef KTERM if (*target == XA_COMPOUND_TEXT(d) || *target == XA_TEXT(d)) { *type = XA_COMPOUND_TEXT(d); *length = convCStoCT(xterm->screen.selection, NULL); *value = (caddr_t)XtMalloc(*length + 1); (void)convCStoCT(xterm->screen.selection, (Char *)*value); } else { *type = XA_STRING; *length = convCStoLatin1(xterm->screen.selection, NULL); *value = (caddr_t)XtMalloc(*length + 1); (void)convCStoLatin1(xterm->screen.selection, (Char *)*value); } #else /* !KTERM */ if (*target == XA_COMPOUND_TEXT(d)) *type = *target; else *type = XA_STRING; *value = xterm->screen.selection; *length = xterm->screen.selection_length; #endif /* !KTERM */ *format = 8; return True; } if (*target == XA_LIST_LENGTH(d)) { *value = XtMalloc(4); if (sizeof(long) == 4) *(long*)*value = 1; else { long temp = 1; memmove( (char*)*value, ((char*)&temp)+sizeof(long)-4, 4); } *type = XA_INTEGER; *length = 1; *format = 32; return True; } if (*target == XA_LENGTH(d)) { *value = XtMalloc(4); if (sizeof(long) == 4) #ifdef KTERM *(long*)*value = convCStoCT(xterm->screen.selection, NULL); #else /* !KTERM */ *(long*)*value = xterm->screen.selection_length; #endif /* !KTERM */ else { #ifdef KTERM long temp = convCStoCT(xterm->screen.selection, NULL); #else /* !KTERM */ long temp = xterm->screen.selection_length; #endif /* !KTERM */ memmove( (char*)*value, ((char*)&temp)+sizeof(long)-4, 4); } *type = XA_INTEGER; *length = 1; *format = 32; return True; } if (XmuConvertStandardSelection(w, xterm->screen.selection_time, selection, target, type, (caddr_t *)value, length, format)) return True; /* else */ return False; } static void LoseSelection(w, selection) Widget w; Atom *selection; { register TScreen* screen = &((XtermWidget)w)->screen; register Atom* atomP; int i; for (i = 0, atomP = screen->selection_atoms; i < screen->selection_count; i++, atomP++) { if (*selection == *atomP) *atomP = (Atom)0; switch (*atomP) { case XA_CUT_BUFFER0: case XA_CUT_BUFFER1: case XA_CUT_BUFFER2: case XA_CUT_BUFFER3: case XA_CUT_BUFFER4: case XA_CUT_BUFFER5: case XA_CUT_BUFFER6: case XA_CUT_BUFFER7: *atomP = (Atom)0; } } for (i = screen->selection_count; i; i--) { if (screen->selection_atoms[i-1] != 0) break; } screen->selection_count = i; for (i = 0, atomP = screen->selection_atoms; i < screen->selection_count; i++, atomP++) { if (*atomP == (Atom)0) { *atomP = screen->selection_atoms[--screen->selection_count]; } } if (screen->selection_count == 0) TrackText(0, 0, 0, 0); } #ifndef KTERM /* ARGSUSED */ static void SelectionDone(w, selection, target) Widget w; Atom *selection, *target; { /* empty proc so Intrinsics know we want to keep storage */ } #endif /* !KTERM */ static void _OwnSelection(termw, selections, count) register XtermWidget termw; String *selections; Cardinal count; { Atom* atoms = termw->screen.selection_atoms; int i; Boolean have_selection = False; if (termw->screen.selection_length < 0) return; if (count > termw->screen.sel_atoms_size) { XtFree((char*)atoms); atoms = (Atom*)XtMalloc(count*sizeof(Atom)); termw->screen.selection_atoms = atoms; termw->screen.sel_atoms_size = count; } XmuInternStrings( XtDisplay((Widget)termw), selections, count, atoms ); for (i = 0; i < count; i++) { int cutbuffer; switch (atoms[i]) { case XA_CUT_BUFFER0: cutbuffer = 0; break; case XA_CUT_BUFFER1: cutbuffer = 1; break; case XA_CUT_BUFFER2: cutbuffer = 2; break; case XA_CUT_BUFFER3: cutbuffer = 3; break; case XA_CUT_BUFFER4: cutbuffer = 4; break; case XA_CUT_BUFFER5: cutbuffer = 5; break; case XA_CUT_BUFFER6: cutbuffer = 6; break; case XA_CUT_BUFFER7: cutbuffer = 7; break; default: cutbuffer = -1; } if (cutbuffer >= 0) if ( termw->screen.selection_length > 4*XMaxRequestSize(XtDisplay((Widget)termw))-32) fprintf(stderr, "%s: selection too big (%d bytes), not storing in CUT_BUFFER%d\n", xterm_name, termw->screen.selection_length, cutbuffer); else #ifdef KTERM { /* Since type of a CUT_BUFFER is STRING, KANJI and KANA * characters can't be stored in a CUT_BUFFER */ int nw; int nc = 0; Ichr *p; char *s, *q; p = termw->screen.selection; for (nw = termw->screen.selection_length; nw > 0; nw--, p++) { if (p->gset == GSET_ASCII) nc++; } if (nc > 0) { char buf[256]; p = termw->screen.selection; s = q = (nc > 256) ? XtMalloc(nc) : buf; for (nw = termw->screen.selection_length; nw > 0; nw--, p++) { if (p->gset == GSET_ASCII) *q++ = p->code & 0x7f; } XStoreBuffer( XtDisplay((Widget)termw), s, nc, cutbuffer ); if (s != buf) XtFree(s); } else XStoreBuffer( XtDisplay((Widget)termw), NULL, nc, cutbuffer ); } #else /* !KTERM */ XStoreBuffer( XtDisplay((Widget)termw), termw->screen.selection, termw->screen.selection_length, cutbuffer ); #endif /* !KTERM */ else if (!replyToEmacs) { have_selection |= XtOwnSelection( (Widget)termw, atoms[i], termw->screen.selection_time, #ifdef KTERM ConvertSelection, LoseSelection, NULL ); #else /* !KTERM */ ConvertSelection, LoseSelection, SelectionDone ); #endif /* !KTERM */ } } if (!replyToEmacs) termw->screen.selection_count = count; if (!have_selection) TrackText(0, 0, 0, 0); } /* void */ DisownSelection(termw) register XtermWidget termw; { Atom* atoms = termw->screen.selection_atoms; Cardinal count = termw->screen.selection_count; int i; for (i = 0; i < count; i++) { int cutbuffer; switch (atoms[i]) { case XA_CUT_BUFFER0: cutbuffer = 0; break; case XA_CUT_BUFFER1: cutbuffer = 1; break; case XA_CUT_BUFFER2: cutbuffer = 2; break; case XA_CUT_BUFFER3: cutbuffer = 3; break; case XA_CUT_BUFFER4: cutbuffer = 4; break; case XA_CUT_BUFFER5: cutbuffer = 5; break; case XA_CUT_BUFFER6: cutbuffer = 6; break; case XA_CUT_BUFFER7: cutbuffer = 7; break; default: cutbuffer = -1; } if (cutbuffer < 0) XtDisownSelection( (Widget)termw, atoms[i], termw->screen.selection_time ); } termw->screen.selection_count = 0; termw->screen.startHRow = termw->screen.startHCol = 0; termw->screen.endHRow = termw->screen.endHCol = 0; } /* returns number of chars in line from scol to ecol out */ /* ARGSUSED */ static int Length(screen, row, scol, ecol) register int row, scol, ecol; register TScreen *screen; { register int lastcol = LastTextCol(row); if (ecol > lastcol) ecol = lastcol; return (ecol - scol + 1); } /* copies text into line, preallocated */ #ifdef KTERM static Ichr * #else /* !KTERM */ static char * #endif /* !KTERM */ SaveText(screen, row, scol, ecol, lp, eol) int row; int scol, ecol; TScreen *screen; #ifdef KTERM register Ichr *lp; /* pointer to where to put the text */ #else /* !KTERM */ register char *lp; /* pointer to where to put the text */ #endif /* !KTERM */ int *eol; { register int i = 0; #ifdef KTERM register Bchr *ch = screen->buf[row + screen->topline]; register Char g; #else /* !KTERM */ register Char *ch = screen->buf[2 * (row + screen->topline)]; #endif /* !KTERM */ Char attr; register int c; *eol = 0; i = Length(screen, row, scol, ecol); ecol = scol + i; if (*eol == 0) { if(ScrnGetAttributes(screen, row + screen->topline, 0, &attr, 1) == 1) { *eol = (attr & LINEWRAPPED) ? 0 : 1; } else { /* If we can't get the attributes, assume no wrap */ /* CANTHAPPEN */ (void)fprintf(stderr, "%s: no attributes for %d, %d\n", xterm_name, row, ecol - 1); *eol = 1; } } for (i = scol; i < ecol; i++) { #ifdef KTERM c = ch[i].code & 0x7f; g = ch[i].gset; if (c < ' ' || c == 0x7f && !(g & CS96)) { lp->code = ' '; lp->gset = GSET_ASCII; } else { lp->code = c; lp->gset = g; } lp++; #else /* !KTERM */ c = ch[i]; if (c == 0) c = ' '; else if(c < ' ') { if(c == '\036') c = '#'; /* char on screen is pound sterling */ else c += 0x5f; /* char is from DEC drawing set */ } else if(c == 0x7f) c = 0x5f; *lp++ = c; #endif /* !KTERM */ } return(lp); } static void EditorButton(event) register XButtonEvent *event; { register TScreen *screen = &term->screen; int pty = screen->respond; char line[6]; register unsigned row, col; int button; button = event->button - 1; row = (event->y - screen->border) / FontHeight(screen); col = (event->x - screen->border - screen->scrollbar) / FontWidth(screen); (void) strcpy(line, "\033[M"); if (screen->send_mouse_pos == 1) { line[3] = ' ' + button; } else { line[3] = ' ' + (KeyState(event->state) << 2) + ((event->type == ButtonPress)? button:3); } line[4] = ' ' + col + 1; line[5] = ' ' + row + 1; v_write(pty, line, 6); } #ifndef KTERM_NOTEK /*ARGSUSED*/ void HandleGINInput (w, event, param_list, nparamsp) Widget w; XEvent *event; String *param_list; Cardinal *nparamsp; { if (term->screen.TekGIN && *nparamsp == 1) { int c = param_list[0][0]; switch (c) { case 'l': case 'm': case 'r': case 'L': case 'M': case 'R': break; default: Bell (XkbBI_MinorError,0); /* let them know they goofed */ c = 'l'; /* provide a default */ } TekEnqMouse (c | 0x80); TekGINoff(); } else { Bell (XkbBI_MinorError,0); } } #endif /* !KTERM_NOTEK */ /* ARGSUSED */ void HandleSecure(w, event, params, param_count) Widget w; XEvent *event; /* unused */ String *params; /* [0] = volume */ Cardinal *param_count; /* 0 or 1 */ { Time time = CurrentTime; if ((event->xany.type == KeyPress) || (event->xany.type == KeyRelease)) time = event->xkey.time; else if ((event->xany.type == ButtonPress) || (event->xany.type == ButtonRelease)) time = event->xbutton.time; DoSecureKeyboard (time); } kterm-6.2.0.orig/charproc.c100444 507 454 455477 6171356060 14344 0ustar yosiakiaux/* * $XConsortium: charproc.c /main/191 1996/01/23 11:34:26 kaleb $ * $Id: charproc.c,v 6.5 1996/07/12 05:01:34 kagotani Rel $ */ /* Copyright (c) 1988 X Consortium Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium. */ /* * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ /* charproc.c */ #include "ptyx.h" #include #include #include #include #include #include #include #include #include #ifndef NO_XPOLL_H #include #else #define XFD_COPYSET(src, dst) memmove((dst), (src), sizeof(fd_set)) #define Select select #endif #include #include #include #include #include "VTparse.h" #include "data.h" #include "error.h" #include "menu.h" #include "main.h" /* * Check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX * systems are broken and return EWOULDBLOCK when they should return EAGAIN. * Note that this macro may evaluate its argument more than once. */ #if defined(EAGAIN) && defined(EWOULDBLOCK) #define E_TEST(err) ((err) == EAGAIN || (err) == EWOULDBLOCK) #else #ifdef EAGAIN #define E_TEST(err) ((err) == EAGAIN) #else #define E_TEST(err) ((err) == EWOULDBLOCK) #endif #endif #ifndef KTERM_NOTEK extern jmp_buf VTend; #endif /* !KTERM_NOTEK */ extern XtAppContext app_con; extern Widget toplevel; extern void exit(); extern char *malloc(); extern char *realloc(); extern fd_set Select_mask; extern fd_set X_mask; extern fd_set pty_mask; static void VTallocbuf(); static int finput(); static void dotext(); static void WriteText(); static void ToAlternate(); static void FromAlternate(); static void update_font_info(); static void bitset(), bitclr(); #define DEFAULT -1 #define TEXT_BUF_SIZE 256 #define TRACKTIMESEC 4L #define TRACKTIMEUSEC 0L #define BELLSUPPRESSMSEC 200 #define XtNalwaysHighlight "alwaysHighlight" #define XtNappcursorDefault "appcursorDefault" #define XtNappkeypadDefault "appkeypadDefault" #define XtNbellSuppressTime "bellSuppressTime" #define XtNboldFont "boldFont" #define XtNc132 "c132" #define XtNcharClass "charClass" #define XtNcurses "curses" #define XtNhpLowerleftBugCompat "hpLowerleftBugCompat" #define XtNcursorColor "cursorColor" #ifdef KTERM_COLOR #define XtNtextColor0 "textColor0" #define XtNtextColor1 "textColor1" #define XtNtextColor2 "textColor2" #define XtNtextColor3 "textColor3" #define XtNtextColor4 "textColor4" #define XtNtextColor5 "textColor5" #define XtNtextColor6 "textColor6" #define XtNtextColor7 "textColor7" #endif /* KTERM_COLOR */ #define XtNcutNewline "cutNewline" #define XtNcutToBeginningOfLine "cutToBeginningOfLine" #define XtNeightBitInput "eightBitInput" #define XtNeightBitOutput "eightBitOutput" #define XtNgeometry "geometry" #define XtNtekGeometry "tekGeometry" #define XtNinternalBorder "internalBorder" #define XtNjumpScroll "jumpScroll" #ifdef ALLOWLOGGING #define XtNlogFile "logFile" #define XtNlogging "logging" #define XtNlogInhibit "logInhibit" #endif #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 XtNresizeGravity "resizeGravity" #define XtNreverseWrap "reverseWrap" #define XtNautoWrap "autoWrap" #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_MBCS #define XtNkanjiFont "kanjiFont" #define XtNkanjiBoldFont "kanjiBoldFont" # endif /* KTERM_MBCS */ # ifdef KTERM_KANJIMODE #define XtNkanjiMode "kanjiMode" # endif /* KTERM_KANJIMODE */ #define XtNfontList "fontList" #define XtNboldFontList "boldFontList" #define XtNlineSpace "lineSpace" #endif /* KTERM */ #define XtCAlwaysHighlight "AlwaysHighlight" #define XtCAppcursorDefault "AppcursorDefault" #define XtCAppkeypadDefault "AppkeypadDefault" #define XtCBellSuppressTime "BellSuppressTime" #define XtCBoldFont "BoldFont" #define XtCC132 "C132" #define XtCCharClass "CharClass" #define XtCCurses "Curses" #define XtCHpLowerleftBugCompat "HpLowerleftBugCompat" #define XtCCutNewline "CutNewline" #define XtCCutToBeginningOfLine "CutToBeginningOfLine" #define XtCEightBitInput "EightBitInput" #define XtCEightBitOutput "EightBitOutput" #define XtCGeometry "Geometry" #define XtCJumpScroll "JumpScroll" #ifdef ALLOWLOGGING #define XtCLogfile "Logfile" #define XtCLogging "Logging" #define XtCLogInhibit "LogInhibit" #endif #define XtCLoginShell "LoginShell" #define XtCMarginBell "MarginBell" #define XtCMultiClickTime "MultiClickTime" #define XtCMultiScroll "MultiScroll" #define XtCColumn "Column" #define XtCResizeGravity "ResizeGravity" #define XtCReverseWrap "ReverseWrap" #define XtCAutoWrap "AutoWrap" #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 */ #ifndef KTERM_NOTEK #define XtCTekInhibit "TekInhibit" #define XtCTekSmall "TekSmall" #define XtCTekStartup "TekStartup" #endif /* !KTERM_NOTEK */ #define XtCTiteInhibit "TiteInhibit" #define XtCVisualBell "VisualBell" #define XtCAllowSendEvents "AllowSendEvents" #ifdef KTERM #define XtCRomanKanaFont "RomanKanaFont" # ifdef KTERM_MBCS #define XtCKanjiFont "KanjiFont" # endif /* KTERM_MBCS */ # ifdef KTERM_KANJIMODE #define XtCKanjiMode "KanjiMode" # endif /* KTERM_KANJIMODE */ #define XtCFontList "FontList" #define XtCLineSpace "LineSpace" #endif /* KTERM */ #define doinput() (bcnt-- > 0 ? *bptr++ : in_put()) static int nparam; static ANSI reply; static int param[NPARAM]; static unsigned long ctotal; static unsigned long ntotal; static jmp_buf vtjmpbuf; 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_MBCS extern int mbcstable[]; extern int smbcstable[]; static Char pending_byte; #endif /* KTERM_MBCS */ /* event handlers */ extern void HandleKeyPressed(), HandleEightBitKeyPressed(); extern void HandleStringEvent(); extern void HandleEnterWindow(); extern void HandleLeaveWindow(); extern void HandleBellPropertyChange(); 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 HandleVisualBell(); static void HandleIgnore(); extern void HandleSecure(); extern void HandleScrollForward(); extern void HandleScrollBack(); extern void HandleCreateMenu(), HandlePopupMenu(); extern void HandleSetFont(); extern void SetVTFont(); #ifdef KTERM_XIM extern void HandleOpenIM(); extern void HandleCloseIM(); #endif /* KTERM_XIM */ #ifdef KTERM_KINPUT2 extern void HandleBeginConversion(); #endif /* KTERM_KINPUT2 */ extern Boolean SendMousePosition(); extern void ScrnSetAttributes(); /* * NOTE: VTInitialize zeros out the entire ".screen" component of the * XtermWidget, so make sure to add an assignment statement in VTInitialize() * for each new ".screen" field added to this resource list. */ /* 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 int defaultBellSuppressTime = BELLSUPPRESSMSEC; static char * _Font_Selected_ = "yes"; /* string is arbitrary */ #ifdef KTERM_XIM static char * defaultEucJPLocale = EUCJPLOCALE; #endif /* KTERM_XIM */ /* * Warning, the following must be kept under 1024 bytes or else some * compilers (particularly AT&T 6386 SVR3.2) will barf). Workaround is to * declare a static buffer and copy in at run time (the the Athena text widget * does). Yuck. */ static char defaultTranslations[] = #ifdef KTERM_KINPUT2 "\ Ctrl Kanji:begin-conversion(_JAPANESE_CONVERSION) \n\ Shift Prior:scroll-back(1,halfpage) \n\ Shift Next:scroll-forw(1,halfpage) \n\ Shift Select:select-cursor-start() select-cursor-end(PRIMARY , CUT_BUFFER0) \n\ Shift Insert:insert-selection(PRIMARY, CUT_BUFFER0) \n\ ~Meta :insert-seven-bit() \n\ Meta :insert-eight-bit() \n\ !Ctrl :popup-menu(mainMenu) \n\ !Lock Ctrl :popup-menu(mainMenu) \n\ !Lock Ctrl @Num_Lock :popup-menu(mainMenu) \n\ ! @Num_Lock Ctrl :popup-menu(mainMenu) \n\ ~Meta :select-start() \n\ ~Meta :select-extend() \n\ !Ctrl :popup-menu(vtMenu) \n\ !Lock Ctrl :popup-menu(vtMenu) \n\ !Lock Ctrl @Num_Lock :popup-menu(vtMenu) \n\ ! @Num_Lock Ctrl :popup-menu(vtMenu) \n\ ~Ctrl ~Meta :ignore() \n\ ~Ctrl ~Meta :insert-selection(PRIMARY, CUT_BUFFER0) \n\ !Ctrl :popup-menu(fontMenu) \n\ !Lock Ctrl :popup-menu(fontMenu) \n\ !Lock Ctrl @Num_Lock :popup-menu(fontMenu) \n\ ! @Num_Lock Ctrl :popup-menu(fontMenu) \n\ ~Ctrl ~Meta :start-extend() \n\ ~Meta :select-extend() \n\ :select-end(PRIMARY, CUT_BUFFER0) \n\ :bell(0) \ "; #else /* !KTERM_KINPUT2 */ "\ Shift Prior:scroll-back(1,halfpage) \n\ Shift Next:scroll-forw(1,halfpage) \n\ Shift Select:select-cursor-start() select-cursor-end(PRIMARY , CUT_BUFFER0) \n\ Shift Insert:insert-selection(PRIMARY, CUT_BUFFER0) \n\ ~Meta :insert-seven-bit() \n\ Meta :insert-eight-bit() \n\ !Ctrl :popup-menu(mainMenu) \n\ !Lock Ctrl :popup-menu(mainMenu) \n\ !Lock Ctrl @Num_Lock :popup-menu(mainMenu) \n\ ! @Num_Lock Ctrl :popup-menu(mainMenu) \n\ ~Meta :select-start() \n\ ~Meta :select-extend() \n\ !Ctrl :popup-menu(vtMenu) \n\ !Lock Ctrl :popup-menu(vtMenu) \n\ !Lock Ctrl @Num_Lock :popup-menu(vtMenu) \n\ ! @Num_Lock Ctrl :popup-menu(vtMenu) \n\ ~Ctrl ~Meta :ignore() \n\ ~Ctrl ~Meta :insert-selection(PRIMARY, CUT_BUFFER0) \n\ !Ctrl :popup-menu(fontMenu) \n\ !Lock Ctrl :popup-menu(fontMenu) \n\ !Lock Ctrl @Num_Lock :popup-menu(fontMenu) \n\ ! @Num_Lock Ctrl :popup-menu(fontMenu) \n\ ~Ctrl ~Meta :start-extend() \n\ ~Meta :select-extend() \n\ :select-end(PRIMARY, CUT_BUFFER0) \n\ :bell(0) \ "; #endif /* !KTERM_KINPUT2 */ static XtActionsRec actionsList[] = { { "bell", HandleBell }, { "create-menu", HandleCreateMenu }, { "ignore", HandleIgnore }, { "insert", HandleKeyPressed }, /* alias for insert-seven-bit */ { "insert-seven-bit", HandleKeyPressed }, { "insert-eight-bit", HandleEightBitKeyPressed }, { "insert-selection", HandleInsertSelection }, { "keymap", HandleKeymapChange }, { "popup-menu", HandlePopupMenu }, { "secure", HandleSecure }, { "select-start", HandleSelectStart }, { "select-extend", HandleSelectExtend }, { "select-end", HandleSelectEnd }, { "select-set", HandleSelectSet }, { "select-cursor-start", HandleKeyboardSelectStart }, { "select-cursor-end", HandleKeyboardSelectEnd }, { "set-vt-font", HandleSetFont }, { "start-extend", HandleStartExtend }, { "start-cursor-extend", HandleKeyboardStartExtend }, { "string", HandleStringEvent }, { "scroll-forw", HandleScrollForward }, { "scroll-back", HandleScrollBack }, /* menu actions */ { "allow-send-events", HandleAllowSends }, { "set-visual-bell", HandleSetVisualBell }, #ifdef ALLOWLOGGING { "set-logging", HandleLogging }, #endif { "redraw", HandleRedraw }, { "send-signal", HandleSendSignal }, { "quit", HandleQuit }, { "set-scrollbar", HandleScrollbar }, { "set-jumpscroll", HandleJumpscroll }, { "set-reverse-video", HandleReverseVideo }, { "set-autowrap", HandleAutoWrap }, { "set-reversewrap", HandleReverseWrap }, { "set-autolinefeed", HandleAutoLineFeed }, { "set-appcursor", HandleAppCursor }, { "set-appkeypad", HandleAppKeypad }, { "set-scroll-on-key", HandleScrollKey }, { "set-scroll-on-tty-output", HandleScrollTtyOutput }, { "set-allow132", HandleAllow132 }, { "set-cursesemul", HandleCursesEmul }, { "set-marginbell", HandleMarginBell }, { "set-altscreen", HandleAltScreen }, { "soft-reset", HandleSoftReset }, { "hard-reset", HandleHardReset }, { "clear-saved-lines", HandleClearSavedLines }, #ifndef KTERM_NOTEK { "set-terminal-type", HandleSetTerminalType }, { "set-visibility", HandleVisibility }, { "set-tek-text", HandleSetTekText }, { "tek-page", HandleTekPage }, { "tek-reset", HandleTekReset }, { "tek-copy", HandleTekCopy }, #endif /* !KTERM_NOTEK */ { "visual-bell", HandleVisualBell }, #ifdef STATUSLINE { "set-statusline", HandleStatusLine }, { "set-reversestatus", HandleStatusReverse }, #endif /* STATUSLINE */ #ifdef KTERM_KANJIMODE { "set-kanji-mode", HandleSetKanjiMode }, #endif /* KTERM_KANJIMODE */ #ifdef KTERM_XIM { "open-im", HandleOpenIM }, { "close-im", HandleCloseIM }, #endif /* KTERM_XIM */ #ifdef KTERM_KINPUT2 { "begin-conversion", HandleBeginConversion }, #endif /* KTERM_KINPUT2 */ }; static XtResource resources[] = { #ifdef KTERM {XtNfont, XtCFont, XtRString, sizeof(String), XtOffset(XtermWidget, screen._menu_font_names[F_ISO8859_1][fontMenu_fontdefault]), XtRString, (XtPointer) NULL}, {XtNboldFont, XtCFont, XtRString, sizeof(String), XtOffset(XtermWidget, screen._menu_bfont_names[F_ISO8859_1][fontMenu_fontdefault]), XtRString, (XtPointer) NULL}, {XtNromanKanaFont, XtCRomanKanaFont, XtRString, sizeof(String), XtOffset(XtermWidget, screen._menu_font_names[F_JISX0201_0][fontMenu_fontdefault]), XtRString, (XtPointer) NULL}, {XtNromanKanaBoldFont, XtCRomanKanaFont, XtRString, sizeof(String), XtOffset(XtermWidget, screen._menu_bfont_names[F_JISX0201_0][fontMenu_fontdefault]), XtRString, (XtPointer) NULL}, # ifdef KTERM_MBCS {XtNkanjiFont, XtCKanjiFont, XtRString, sizeof(String), XtOffset(XtermWidget, screen._menu_font_names[F_JISX0208_0][fontMenu_fontdefault]), XtRString, (XtPointer) NULL}, {XtNkanjiBoldFont, XtCKanjiFont, XtRString, sizeof(String), XtOffset(XtermWidget, screen._menu_bfont_names[F_JISX0208_0][fontMenu_fontdefault]), XtRString, (XtPointer) NULL}, # endif /* KTERM_MBCS */ # ifdef KTERM_KANJIMODE {XtNkanjiMode, XtCKanjiMode, XtRString, sizeof(char *), XtOffset(XtermWidget, misc.k_m), XtRString, (XtPointer) NULL}, # endif /* KTERM_KANJIMODE */ {XtNfontList, XtCFontList, XtRString, sizeof(String), XtOffset(XtermWidget, screen.menu_font_list[fontMenu_fontdefault]), XtRString, (XtPointer) NULL}, {XtNboldFontList, XtCFontList, XtRString, sizeof(String), XtOffset(XtermWidget, screen.menu_bfont_list[fontMenu_fontdefault]), XtRString, (XtPointer) NULL}, {XtNlineSpace, XtCLineSpace, XtRInt, sizeof(int), XtOffset(XtermWidget, screen.linespace), XtRInt, (XtPointer) &defaultLineSpace}, #else /* !KTERM */ {XtNfont, XtCFont, XtRString, sizeof(char *), XtOffsetOf(XtermWidgetRec, misc.f_n), XtRString, DEFFONT}, {XtNboldFont, XtCBoldFont, XtRString, sizeof(char *), XtOffsetOf(XtermWidgetRec, misc.f_b), XtRString, DEFBOLDFONT}, #endif /* !KTERM */ {XtNc132, XtCC132, XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, screen.c132), XtRBoolean, (XtPointer) &defaultFALSE}, {XtNcharClass, XtCCharClass, XtRString, sizeof(char *), XtOffsetOf(XtermWidgetRec, screen.charClass), XtRString, (XtPointer) NULL}, {XtNcurses, XtCCurses, XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, screen.curses), XtRBoolean, (XtPointer) &defaultFALSE}, {XtNcutNewline, XtCCutNewline, XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, screen.cutNewline), XtRBoolean, (XtPointer) &defaultTRUE}, {XtNcutToBeginningOfLine, XtCCutToBeginningOfLine, XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, screen.cutToBeginningOfLine), XtRBoolean, (XtPointer) &defaultTRUE}, {XtNbackground, XtCBackground, XtRPixel, sizeof(Pixel), XtOffsetOf(XtermWidgetRec, core.background_pixel), XtRString, "XtDefaultBackground"}, {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), XtOffsetOf(XtermWidgetRec, screen.foreground), XtRString, "XtDefaultForeground"}, {XtNcursorColor, XtCForeground, XtRPixel, sizeof(Pixel), XtOffsetOf(XtermWidgetRec, screen.cursorcolor), XtRString, "XtDefaultForeground"}, #ifdef KTERM_COLOR {XtNtextColor0, XtCForeground, XtRPixel, sizeof(Pixel), XtOffsetOf(XtermWidgetRec, screen.textcolor[0]), XtRString, "Black"}, {XtNtextColor1, XtCForeground, XtRPixel, sizeof(Pixel), XtOffsetOf(XtermWidgetRec, screen.textcolor[1]), XtRString, "Red"}, {XtNtextColor2, XtCForeground, XtRPixel, sizeof(Pixel), XtOffsetOf(XtermWidgetRec, screen.textcolor[2]), XtRString, "Green"}, {XtNtextColor3, XtCForeground, XtRPixel, sizeof(Pixel), XtOffsetOf(XtermWidgetRec, screen.textcolor[3]), XtRString, "Yellow"}, {XtNtextColor4, XtCForeground, XtRPixel, sizeof(Pixel), XtOffsetOf(XtermWidgetRec, screen.textcolor[4]), XtRString, "Blue"}, {XtNtextColor5, XtCForeground, XtRPixel, sizeof(Pixel), XtOffsetOf(XtermWidgetRec, screen.textcolor[5]), XtRString, "Magenta"}, {XtNtextColor6, XtCForeground, XtRPixel, sizeof(Pixel), XtOffsetOf(XtermWidgetRec, screen.textcolor[6]), XtRString, "Cyan"}, {XtNtextColor7, XtCForeground, XtRPixel, sizeof(Pixel), XtOffsetOf(XtermWidgetRec, screen.textcolor[7]), XtRString, "White"}, #endif /* KTERM_COLOR */ {XtNeightBitInput, XtCEightBitInput, XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, screen.input_eight_bits), XtRBoolean, (XtPointer) &defaultTRUE}, {XtNeightBitOutput, XtCEightBitOutput, XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, screen.output_eight_bits), XtRBoolean, (XtPointer) &defaultTRUE}, {XtNgeometry,XtCGeometry, XtRString, sizeof(char *), XtOffsetOf(XtermWidgetRec, misc.geo_metry), XtRString, (XtPointer) NULL}, {XtNalwaysHighlight,XtCAlwaysHighlight,XtRBoolean, sizeof(Boolean),XtOffsetOf(XtermWidgetRec, screen.always_highlight), XtRBoolean, (XtPointer) &defaultFALSE}, {XtNappcursorDefault,XtCAppcursorDefault,XtRBoolean, sizeof(Boolean),XtOffsetOf(XtermWidgetRec, misc.appcursorDefault), XtRBoolean, (XtPointer) &defaultFALSE}, {XtNappkeypadDefault,XtCAppkeypadDefault,XtRBoolean, sizeof(Boolean),XtOffsetOf(XtermWidgetRec, misc.appkeypadDefault), XtRBoolean, (XtPointer) &defaultFALSE}, {XtNbellSuppressTime, XtCBellSuppressTime, XtRInt, sizeof(int), XtOffsetOf(XtermWidgetRec, screen.bellSuppressTime), XtRInt, (XtPointer) &defaultBellSuppressTime}, {XtNtekGeometry,XtCGeometry, XtRString, sizeof(char *), XtOffsetOf(XtermWidgetRec, misc.T_geometry), XtRString, (XtPointer) NULL}, {XtNinternalBorder,XtCBorderWidth,XtRInt, sizeof(int), XtOffsetOf(XtermWidgetRec, screen.border), XtRInt, (XtPointer) &defaultIntBorder}, {XtNjumpScroll, XtCJumpScroll, XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, screen.jumpscroll), XtRBoolean, (XtPointer) &defaultTRUE}, #ifdef ALLOWLOGGING {XtNlogFile, XtCLogfile, XtRString, sizeof(char *), XtOffsetOf(XtermWidgetRec, screen.logfile), XtRString, (XtPointer) NULL}, {XtNlogging, XtCLogging, XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, misc.log_on), XtRBoolean, (XtPointer) &defaultFALSE}, {XtNlogInhibit, XtCLogInhibit, XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, misc.logInhibit), XtRBoolean, (XtPointer) &defaultFALSE}, #endif {XtNloginShell, XtCLoginShell, XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, misc.login_shell), XtRBoolean, (XtPointer) &defaultFALSE}, {XtNmarginBell, XtCMarginBell, XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, screen.marginbell), XtRBoolean, (XtPointer) &defaultFALSE}, {XtNpointerColor, XtCForeground, XtRPixel, sizeof(Pixel), XtOffsetOf(XtermWidgetRec, screen.mousecolor), XtRString, "XtDefaultForeground"}, {XtNpointerColorBackground, XtCBackground, XtRPixel, sizeof(Pixel), XtOffsetOf(XtermWidgetRec, screen.mousecolorback), XtRString, "XtDefaultBackground"}, {XtNpointerShape,XtCCursor, XtRCursor, sizeof(Cursor), XtOffsetOf(XtermWidgetRec, screen.pointer_cursor), XtRString, (XtPointer) "xterm"}, {XtNmultiClickTime,XtCMultiClickTime, XtRInt, sizeof(int), XtOffsetOf(XtermWidgetRec, screen.multiClickTime), XtRInt, (XtPointer) &defaultMultiClickTime}, {XtNmultiScroll,XtCMultiScroll, XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, screen.multiscroll), XtRBoolean, (XtPointer) &defaultFALSE}, {XtNnMarginBell,XtCColumn, XtRInt, sizeof(int), XtOffsetOf(XtermWidgetRec, screen.nmarginbell), XtRInt, (XtPointer) &defaultNMarginBell}, {XtNreverseVideo,XtCReverseVideo,XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, misc.re_verse), XtRBoolean, (XtPointer) &defaultFALSE}, {XtNresizeGravity, XtCResizeGravity, XtRGravity, sizeof(XtGravity), XtOffsetOf(XtermWidgetRec, misc.resizeGravity), XtRImmediate, (XtPointer) SouthWestGravity}, {XtNreverseWrap,XtCReverseWrap, XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, misc.reverseWrap), XtRBoolean, (XtPointer) &defaultFALSE}, {XtNautoWrap,XtCAutoWrap, XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, misc.autoWrap), XtRBoolean, (XtPointer) &defaultTRUE}, {XtNsaveLines, XtCSaveLines, XtRInt, sizeof(int), XtOffsetOf(XtermWidgetRec, screen.savelines), XtRInt, (XtPointer) &defaultSaveLines}, {XtNscrollBar, XtCScrollBar, XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, misc.scrollbar), XtRBoolean, (XtPointer) &defaultFALSE}, {XtNscrollTtyOutput,XtCScrollCond, XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, screen.scrollttyoutput), XtRBoolean, (XtPointer) &defaultTRUE}, {XtNscrollKey, XtCScrollCond, XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, screen.scrollkey), XtRBoolean, (XtPointer) &defaultFALSE}, {XtNscrollLines, XtCScrollLines, XtRInt, sizeof(int), XtOffsetOf(XtermWidgetRec, screen.scrolllines), XtRInt, (XtPointer) &defaultScrollLines}, {XtNsignalInhibit,XtCSignalInhibit,XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, misc.signalInhibit), XtRBoolean, (XtPointer) &defaultFALSE}, #ifdef STATUSLINE {XtNstatusLine, XtCStatusLine, XtRBoolean, sizeof(Boolean), XtOffset(XtermWidget, misc.statusline), XtRBoolean, (XtPointer) &defaultFALSE}, {XtNstatusNormal, XtCStatusNormal, XtRBoolean, sizeof(Boolean), XtOffset(XtermWidget, misc.statusnormal), XtRBoolean, (XtPointer) &defaultFALSE}, #endif /* STATUSLINE */ #ifndef KTERM_NOTEK {XtNtekInhibit, XtCTekInhibit, XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, misc.tekInhibit), XtRBoolean, (XtPointer) &defaultFALSE}, {XtNtekSmall, XtCTekSmall, XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, misc.tekSmall), XtRBoolean, (XtPointer) &defaultFALSE}, {XtNtekStartup, XtCTekStartup, XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, screen.TekEmu), XtRBoolean, (XtPointer) &defaultFALSE}, #endif /* !KTERM_NOTEK */ {XtNtiteInhibit, XtCTiteInhibit, XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, misc.titeInhibit), XtRBoolean, (XtPointer) &defaultFALSE}, {XtNvisualBell, XtCVisualBell, XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, screen.visualbell), XtRBoolean, (XtPointer) &defaultFALSE}, {XtNallowSendEvents, XtCAllowSendEvents, XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, screen.allowSendEvents), XtRBoolean, (XtPointer) &defaultFALSE}, #ifdef KTERM {"dynamicFontLoad", "DynamicFontLoad", XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, screen.dynamic_font_load), XtRBoolean, (XtPointer) &defaultTRUE}, {"fontList1", "FontList1", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen.menu_font_list[fontMenu_font1]), XtRString, (XtPointer) NULL}, {"fontList2", "FontList2", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen.menu_font_list[fontMenu_font2]), XtRString, (XtPointer) NULL}, {"fontList3", "FontList3", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen.menu_font_list[fontMenu_font3]), XtRString, (XtPointer) NULL}, {"fontList4", "FontList4", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen.menu_font_list[fontMenu_font4]), XtRString, (XtPointer) NULL}, {"fontList5", "FontList5", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen.menu_font_list[fontMenu_font5]), XtRString, (XtPointer) NULL}, {"fontList6", "FontList6", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen.menu_font_list[fontMenu_font6]), XtRString, (XtPointer) NULL}, {"boldFontList1", "BoldFontList1", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen.menu_bfont_list[fontMenu_font1]), XtRString, (XtPointer) NULL}, {"boldFontList2", "BoldFontList2", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen.menu_bfont_list[fontMenu_font2]), XtRString, (XtPointer) NULL}, {"boldFontList3", "BoldFontList3", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen.menu_bfont_list[fontMenu_font3]), XtRString, (XtPointer) NULL}, {"boldFontList4", "BoldFontList4", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen.menu_bfont_list[fontMenu_font4]), XtRString, (XtPointer) NULL}, {"boldFontList5", "BoldFontList5", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen.menu_bfont_list[fontMenu_font5]), XtRString, (XtPointer) NULL}, {"boldFontList6", "BoldFontList6", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen.menu_bfont_list[fontMenu_font6]), XtRString, (XtPointer) NULL}, {"font1", "Font1", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_font_names[F_ISO8859_1][fontMenu_font1]), XtRString, (XtPointer) NULL}, {"font2", "Font2", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_font_names[F_ISO8859_1][fontMenu_font2]), XtRString, (XtPointer) NULL}, {"font3", "Font3", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_font_names[F_ISO8859_1][fontMenu_font3]), XtRString, (XtPointer) NULL}, {"font4", "Font4", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_font_names[F_ISO8859_1][fontMenu_font4]), XtRString, (XtPointer) NULL}, {"font5", "Font5", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_font_names[F_ISO8859_1][fontMenu_font5]), XtRString, (XtPointer) NULL}, {"font6", "Font6", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_font_names[F_ISO8859_1][fontMenu_font6]), XtRString, (XtPointer) NULL}, {"boldFont1", "BoldFont1", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_bfont_names[F_ISO8859_1][fontMenu_font1]), XtRString, (XtPointer) NULL}, {"boldFont2", "BoldFont2", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_bfont_names[F_ISO8859_1][fontMenu_font2]), XtRString, (XtPointer) NULL}, {"boldFont3", "BoldFont3", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_bfont_names[F_ISO8859_1][fontMenu_font3]), XtRString, (XtPointer) NULL}, {"boldFont4", "BoldFont4", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_bfont_names[F_ISO8859_1][fontMenu_font4]), XtRString, (XtPointer) NULL}, {"boldFont5", "BoldFont5", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_bfont_names[F_ISO8859_1][fontMenu_font5]), XtRString, (XtPointer) NULL}, {"boldFont6", "BoldFont6", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_bfont_names[F_ISO8859_1][fontMenu_font6]), XtRString, (XtPointer) NULL}, {"romanKanaFont1", "RomanKanaFont1", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_font_names[F_JISX0201_0][fontMenu_font1]), XtRString, (XtPointer) NULL}, {"romanKanaFont2", "RomanKanaFont2", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_font_names[F_JISX0201_0][fontMenu_font2]), XtRString, (XtPointer) NULL}, {"romanKanaFont3", "RomanKanaFont3", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_font_names[F_JISX0201_0][fontMenu_font3]), XtRString, (XtPointer) NULL}, {"romanKanaFont4", "RomanKanaFont4", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_font_names[F_JISX0201_0][fontMenu_font4]), XtRString, (XtPointer) NULL}, {"romanKanaFont5", "RomanKanaFont5", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_font_names[F_JISX0201_0][fontMenu_font5]), XtRString, (XtPointer) NULL}, {"romanKanaFont6", "RomanKanaFont6", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_font_names[F_JISX0201_0][fontMenu_font6]), XtRString, (XtPointer) NULL}, {"romanKanaBoldFont1", "RomanKanaBoldFont1", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_bfont_names[F_JISX0201_0][fontMenu_font1]), XtRString, (XtPointer) NULL}, {"romanKanaBoldFont2", "RomanKanaBoldFont2", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_bfont_names[F_JISX0201_0][fontMenu_font2]), XtRString, (XtPointer) NULL}, {"romanKanaBoldFont3", "RomanKanaBoldFont3", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_bfont_names[F_JISX0201_0][fontMenu_font3]), XtRString, (XtPointer) NULL}, {"romanKanaBoldFont4", "RomanKanaBoldFont4", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_bfont_names[F_JISX0201_0][fontMenu_font4]), XtRString, (XtPointer) NULL}, {"romanKanaBoldFont5", "RomanKanaBoldFont5", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_bfont_names[F_JISX0201_0][fontMenu_font5]), XtRString, (XtPointer) NULL}, {"romanKanaBoldFont6", "RomanKanaBoldFont6", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_bfont_names[F_JISX0201_0][fontMenu_font6]), XtRString, (XtPointer) NULL}, # ifdef KTERM_MBCS {"kanjiFont1", "KanjiFont1", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_font_names[F_JISX0208_0][fontMenu_font1]), XtRString, (XtPointer) NULL}, {"kanjiFont2", "KanjiFont2", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_font_names[F_JISX0208_0][fontMenu_font2]), XtRString, (XtPointer) NULL}, {"kanjiFont3", "KanjiFont3", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_font_names[F_JISX0208_0][fontMenu_font3]), XtRString, (XtPointer) NULL}, {"kanjiFont4", "KanjiFont4", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_font_names[F_JISX0208_0][fontMenu_font4]), XtRString, (XtPointer) NULL}, {"kanjiFont5", "KanjiFont5", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_font_names[F_JISX0208_0][fontMenu_font5]), XtRString, (XtPointer) NULL}, {"kanjiFont6", "KanjiFont6", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_font_names[F_JISX0208_0][fontMenu_font6]), XtRString, (XtPointer) NULL}, {"kanjiBoldFont1", "KanjiBoldFont1", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_bfont_names[F_JISX0208_0][fontMenu_font1]), XtRString, (XtPointer) NULL}, {"kanjiBoldFont2", "KanjiBoldFont2", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_bfont_names[F_JISX0208_0][fontMenu_font2]), XtRString, (XtPointer) NULL}, {"kanjiBoldFont3", "KanjiBoldFont3", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_bfont_names[F_JISX0208_0][fontMenu_font3]), XtRString, (XtPointer) NULL}, {"kanjiBoldFont4", "KanjiBoldFont4", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_bfont_names[F_JISX0208_0][fontMenu_font4]), XtRString, (XtPointer) NULL}, {"kanjiBoldFont5", "KanjiBoldFont5", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_bfont_names[F_JISX0208_0][fontMenu_font5]), XtRString, (XtPointer) NULL}, {"kanjiBoldFont6", "KanjiBoldFont6", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen._menu_bfont_names[F_JISX0208_0][fontMenu_font6]), XtRString, (XtPointer) NULL}, # endif /* KTERM_MBCS */ #else /* !KTERM */ {"font1", "Font1", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen.menu_font_names[fontMenu_font1]), XtRString, (XtPointer) NULL}, {"font2", "Font2", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen.menu_font_names[fontMenu_font2]), XtRString, (XtPointer) NULL}, {"font3", "Font3", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen.menu_font_names[fontMenu_font3]), XtRString, (XtPointer) NULL}, {"font4", "Font4", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen.menu_font_names[fontMenu_font4]), XtRString, (XtPointer) NULL}, {"font5", "Font5", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen.menu_font_names[fontMenu_font5]), XtRString, (XtPointer) NULL}, {"font6", "Font6", XtRString, sizeof(String), XtOffsetOf(XtermWidgetRec, screen.menu_font_names[fontMenu_font6]), XtRString, (XtPointer) NULL}, #endif /* !KTERM */ {XtNinputMethod, XtCInputMethod, XtRString, sizeof(char*), XtOffsetOf(XtermWidgetRec, misc.input_method), XtRString, (XtPointer)NULL}, #ifdef KTERM_XIM {XtNpreeditType, XtCPreeditType, XtRString, sizeof(char*), XtOffsetOf(XtermWidgetRec, misc.preedit_type), XtRString, (XtPointer)"OverTheSpot,Root"}, {XtNopenIm, XtCOpenIm, XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, misc.open_im), XtRImmediate, (XtPointer)FALSE}, {"eucJPLocale", "EucJPLocale", XtRString, sizeof(char*), XtOffsetOf(XtermWidgetRec, misc.eucjp_locale), XtRString, (XtPointer)EUCJPLOCALE}, #else /* !KTERM_XIM */ {XtNpreeditType, XtCPreeditType, XtRString, sizeof(char*), XtOffsetOf(XtermWidgetRec, misc.preedit_type), XtRString, (XtPointer)"Root"}, {XtNopenIm, XtCOpenIm, XtRBoolean, sizeof(Boolean), XtOffsetOf(XtermWidgetRec, misc.open_im), XtRImmediate, (XtPointer)TRUE}, #endif /* !KTERM_XIM */ }; static void VTClassInit(); static void VTInitialize(); static void VTRealize(); static void VTExpose(); static void VTResize(); static void VTDestroy(); static Boolean VTSetValues(); static void VTInitI18N(); static WidgetClassRec xtermClassRec = { { /* core_class fields */ /* superclass */ (WidgetClass) &widgetClassRec, /* class_name */ "VT100", /* widget_size */ sizeof(XtermWidgetRec), /* class_initialize */ VTClassInit, /* class_part_initialize */ NULL, /* class_inited */ FALSE, /* initialize */ VTInitialize, /* initialize_hook */ NULL, /* realize */ VTRealize, /* actions */ actionsList, /* num_actions */ XtNumber(actionsList), /* resources */ resources, /* num_resources */ XtNumber(resources), /* xrm_class */ NULLQUARK, /* compress_motion */ TRUE, /* compress_exposure */ FALSE, /* compress_enterleave */ TRUE, /* visible_interest */ FALSE, /* destroy */ VTDestroy, /* resize */ VTResize, /* expose */ VTExpose, /* set_values */ VTSetValues, /* set_values_hook */ NULL, /* set_values_almost */ NULL, /* get_values_hook */ NULL, /* accept_focus */ NULL, /* version */ XtVersion, /* callback_offsets */ NULL, /* tm_table */ defaultTranslations, /* query_geometry */ XtInheritQueryGeometry, /* display_accelerator*/ XtInheritDisplayAccelerator, /* extension */ NULL } }; WidgetClass xtermWidgetClass = (WidgetClass)&xtermClassRec; #ifdef KTERM doSS(gset) short gset; { register Char c, min, max, print_min, print_max; register Char *cp = bptr; min = 0x20 | *cp & 0x80; max = 0x7f | *cp & 0x80; if (gset & CS96) { print_min = min; print_max = max; } else { print_min = min + 1; print_max = max - 1; } # ifdef KTERM_MBCS if (gset & MBCS) { if (bcnt > 0) { /* first byte */ c = *cp++; if (bcnt == 1) { /* * Incomplete multi-byte character. * Preserve and skip its first byte. */ pending_byte = c; goto donottext; } if (c < print_min || print_max < c) { /* * Illegal multi-byte character. Skip it. */ cp++; goto donottext; } /* second byte */ c = *cp++; if (c < print_min || print_max < c) { /* * Illegal multi-byte character. Skip it. */ goto donottext; } } } else # endif /* KTERM_MBCS */ { if (bcnt > 0) { c = *cp++; if (c < print_min || print_max < c) goto donottext; } } dotext(&term->screen, term->flags, gset, bptr, cp); donottext: bcnt -= cp - bptr; bptr = cp; } doLS(gset) short gset; { register Char c, min, max, print_min, print_max; register Char *cp = bptr; register int cnt = bcnt > TEXT_BUF_SIZE ? TEXT_BUF_SIZE : bcnt; /* TEXT_BUF_SIZE must be an even number */ int skip = 0; min = 0x20 | *cp & 0x80; max = 0x7f | *cp & 0x80; if (gset & CS96) { print_min = min; print_max = max; } else { print_min = min + 1; print_max = max - 1; } # ifdef KTERM_MBCS if (gset & MBCS) { while (cnt > 0) { /* first byte */ c = *cp; if (c < print_min || print_max < c) break; cnt--; cp++; if (cnt == 0) { /* must be (bcnt == cp-bptr) */ /* * Incomplete multi-byte character. * Preserve and skip its first byte. */ pending_byte = c; skip = 1; break; } /* second byte */ c = *cp; cnt--; cp++; if (c < print_min || print_max < c) { /* * Illegal multi-byte character. Skip it. */ skip = 2; break; } } } else # endif /* KTERM_MBCS */ { if (!(gset & CS96) && !(*cp & 0x80)) { /* SBCS&CS94:GL */ print_min = min; /* SPACE is printable */ } while (cnt > 0) { c = *cp; if (c < print_min || print_max < c) break; cnt--; cp++; } } dotext(&term->screen, term->flags, gset, bptr, cp-skip); # ifdef KTERM_MBCS /* * Print printable SPCs in MBCS and CS94 and GL */ if (print_min == 0x21) { /* implies MBCS and CS94 and GL */ /* * Print SPACEs left */ bcnt -= cp - bptr; bptr = cp; while (cnt > 0) { c = *cp; if (c != 0x20) break; cnt--; cp++; } dotext(&term->screen, term->flags, GSET_ASCII, bptr, cp); } # endif /* KTERM_MBCS */ /* * Skip unprintable SPCs and DELs */ while (cnt > 0) { c = *cp; if (c < min || print_min <= c && c <= print_max || max < c) break; cnt--; cp++; } bcnt -= cp - bptr; bptr = cp; } # ifdef KTERM_KANJIMODE doSJIS() { Char dotextbuf[TEXT_BUF_SIZE]; register Char c1, c2; register Char *cp = bptr; register Char *dcp = dotextbuf; register int cnt = bcnt > TEXT_BUF_SIZE ? TEXT_BUF_SIZE : bcnt; /* TEXT_BUF_SIZE must be an even number */ # define SJIS1(c) ((0x81 <= c && c <= 0x9F) || (0xE0 <= c && c <= 0xEF)) # define SJIS2(c) (0x40 <= c && c <= 0xFC && c != 0x7F) while (cnt > 0) { /* first byte */ c1 = *cp; if (!SJIS1(c1)) break; cnt--; cp++; if (cnt == 0) { /* must be (bcnt == cp-bptr) */ /* * Incomplete multi-byte character. * Preserve and skip its first byte. */ pending_byte = c1; break; } /* second byte */ c2 = *cp; if (!SJIS2(c2)) { /* * Illegal shift-jis character. Skip it. */ break; } cnt--; cp++; /* SJIS to JIS code conversion */ if (c1 <= 0x9f) c1 = (c1-0x81)*2 + 0x21; else c1 = (c1-0xc1)*2 + 0x21; if (c2 <= 0x7e) c2 -= 0x1f; else if (c2 <= 0x9e) c2 -= 0x20; else c2 -= 0x7e, c1 += 1; /* copy to buffer */ *dcp++ = c1; *dcp++ = c2; } dotext(&term->screen, term->flags, GSET_KANJI, dotextbuf, dcp); bcnt -= cp - bptr; bptr = cp; } # endif /* KTERM_KANJIMODE */ #endif /* KTERM */ static void VTparse() { register TScreen *screen = &term->screen; register int *parsestate = groundtable; register unsigned int c; register unsigned char *cp; register int row, col, top, bot, scstype; #ifdef KTERM register Bchr *xp; Char cs96; # ifdef KTERM_MBCS Char mbcs; # endif /* KTERM_MBCS */ #endif /* KTERM */ extern int TrackMouse(); if(setjmp(vtjmpbuf)) parsestate = groundtable; #ifdef KTERM_MBCS pending_byte = 0; #endif /* KTERM_MBCS */ for( ; ; ) { #ifdef KTERM if (cs96 # ifdef KTERM_MBCS | mbcs && parsestate != mbcstable && parsestate != smbcstable # endif /* KTERM_MBCS */ && parsestate != scstable) { cs96 = 0; # ifdef KTERM_MBCS mbcs = 0; # endif /* KTERM_MBCS */ } #endif /* KTERM */ #ifdef KTERM_KANJIMODE c = doinput(); if (term->flags & SJIS_KANJI && SJIS1(c)) { bcnt++; *--bptr = c; doSJIS(); screen->curss = 0; continue; } switch (parsestate[c]) { #else /* !KTERM_KANJIMODE */ switch (parsestate[c = doinput()]) { #endif /* !KTERM_KANJIMODE */ case CASE_PRINT: /* printable characters */ #ifdef KTERM bcnt++; *--bptr = c; if(screen->curss) { doSS(screen->gsets[screen->curss]); # ifdef KTERM_MBCS if (pending_byte == 0) # endif /* KTERM_MBCS */ screen->curss = 0; break; /* switch */ } doLS(screen->gsets[c & 0x80 ? screen->curgr : screen->curgl]); #else /* !KTERM */ top = bcnt > TEXT_BUF_SIZE ? TEXT_BUF_SIZE : bcnt; cp = bptr; *--bptr = c; while(top > 0 && isprint(*cp & 0x7f)) { top--; bcnt--; cp++; } if(screen->curss) { dotext(screen, term->flags, screen->gsets[screen->curss], bptr, bptr + 1); screen->curss = 0; bptr++; } if(bptr < cp) dotext(screen, term->flags, screen->gsets[screen->curgl], bptr, cp); bptr = cp; #endif /* !KTERM */ break; case CASE_GROUND_STATE: /* exit ignore mode */ parsestate = groundtable; break; case CASE_IGNORE_STATE: /* Ies: ignore anything else */ parsestate = igntable; break; case CASE_IGNORE_ESC: /* Ign: escape */ parsestate = iestable; break; case CASE_IGNORE: /* Ignore character */ break; case CASE_BELL: /* bell */ Bell(XkbBI_TerminalBell,0); break; case CASE_BS: /* backspace */ CursorBack(screen, 1); break; case CASE_CR: /* carriage return */ CarriageReturn(screen); parsestate = groundtable; break; case CASE_ESC: /* escape */ parsestate = esctable; break; case CASE_VMOT: /* * form feed, line feed, vertical tab */ #ifdef STATUSLINE if (!screen->instatus) #endif /* STATUSLINE */ Index(screen, 1); if (term->flags & LINEFEED) CarriageReturn(screen); #ifdef KTERM_XAW3D if (XtAppPending(app_con) > 0 || #else /* !KTERM_XAW3D */ if (QLength(screen->display) > 0 || #endif /* !KTERM_XAW3D */ GetBytesAvailable (ConnectionNumber(screen->display)) > 0) xevents(); parsestate = groundtable; break; case CASE_TAB: /* tab */ screen->cur_col = TabNext(term->tabs, screen->cur_col); if (screen->cur_col > screen->max_col) screen->cur_col = screen->max_col; break; case CASE_SI: screen->curgl = 0; break; case CASE_SO: screen->curgl = 1; break; case CASE_SCR_STATE: /* enter scr state */ parsestate = scrtable; break; #ifdef KTERM_MBCS case CASE_MBCS: /* enter mbcs state */ mbcs = MBCS; scstype = 0; /* for ESC-$-F */ parsestate = mbcstable; break; #endif /* KTERM_MBCS */ #ifdef KTERM case CASE_SCS_STATE: /* enter scs state */ if (c >= ',') { /* , - . / */ cs96 = CS96; scstype = c - ','; } else { /* ( ) * + */ scstype = c - '('; } # ifdef KTERM_MBCS if (mbcs) parsestate = smbcstable; else # endif /* KTERM_MBCS */ parsestate = scstable; break; #else /* !KTERM */ case CASE_SCS0_STATE: /* enter scs state 0 */ scstype = 0; parsestate = scstable; break; case CASE_SCS1_STATE: /* enter scs state 1 */ scstype = 1; parsestate = scstable; break; case CASE_SCS2_STATE: /* enter scs state 2 */ scstype = 2; parsestate = scstable; break; case CASE_SCS3_STATE: /* enter scs state 3 */ scstype = 3; parsestate = scstable; break; #endif /* !KTERM */ case CASE_ESC_IGNORE: /* unknown escape sequence */ parsestate = eigtable; break; case CASE_ESC_DIGIT: /* digit in csi or dec mode */ if((row = param[nparam - 1]) == DEFAULT) row = 0; param[nparam - 1] = 10 * row + (c - '0'); break; case CASE_ESC_SEMI: /* semicolon in csi or dec mode */ if (nparam < NPARAM) param[nparam++] = DEFAULT; break; case CASE_DEC_STATE: /* enter dec mode */ parsestate = dectable; break; case CASE_ICH: /* ICH */ if((row = param[0]) < 1) row = 1; InsertChar(screen, row); parsestate = groundtable; break; case CASE_CUU: /* CUU */ if((row = param[0]) < 1) row = 1; #ifdef STATUSLINE if (!screen->instatus) #endif /* STATUSLINE */ CursorUp(screen, row); parsestate = groundtable; break; case CASE_CUD: /* CUD */ if((row = param[0]) < 1) row = 1; #ifdef STATUSLINE if (!screen->instatus) #endif /* STATUSLINE */ CursorDown(screen, row); parsestate = groundtable; break; case CASE_CUF: /* CUF */ if((row = param[0]) < 1) row = 1; CursorForward(screen, row); parsestate = groundtable; break; case CASE_CUB: /* CUB */ if((row = param[0]) < 1) row = 1; CursorBack(screen, row); parsestate = groundtable; break; case CASE_CUP: /* CUP | HVP */ if((row = param[0]) < 1) row = 1; if(nparam < 2 || (col = param[1]) < 1) col = 1; #ifdef STATUSLINE if (screen->instatus) { col--; if (col > screen->cur_col) CursorForward(screen, col - screen->cur_col); else if (col < screen->cur_col) CursorBack(screen, screen->cur_col - col); } else #endif /* STATUSLINE */ CursorSet(screen, row-1, col-1, term->flags); parsestate = groundtable; break; case CASE_HP_BUGGY_LL: /* Some HP-UX applications have the bug that they assume ESC F goes to the lower left corner of the screen, regardless of what terminfo says. */ if (screen->hp_ll_bc) CursorSet(screen, screen->max_row, 0, term->flags); parsestate = groundtable; break; case CASE_ED: /* ED */ switch (param[0]) { case DEFAULT: case 0: #ifdef STATUSLINE if (screen->instatus) ClearRight(screen); else #endif /* STATUSLINE */ ClearBelow(screen); break; case 1: #ifdef STATUSLINE if (screen->instatus) ClearLeft(screen); else #endif /* STATUSLINE */ ClearAbove(screen); break; case 2: #ifdef STATUSLINE if (screen->instatus) ClearLine(screen); else #endif /* STATUSLINE */ ClearScreen(screen); break; } parsestate = groundtable; break; case CASE_EL: /* EL */ switch (param[0]) { case DEFAULT: case 0: ClearRight(screen); break; case 1: ClearLeft(screen); break; case 2: ClearLine(screen); break; } parsestate = groundtable; break; case CASE_IL: /* IL */ if((row = param[0]) < 1) row = 1; #ifdef STATUSLINE if (!screen->instatus) #endif /* STATUSLINE */ InsertLine(screen, row); parsestate = groundtable; break; case CASE_DL: /* DL */ if((row = param[0]) < 1) row = 1; #ifdef STATUSLINE if (!screen->instatus) #endif /* STATUSLINE */ DeleteLine(screen, row); parsestate = groundtable; break; case CASE_DCH: /* DCH */ if((row = param[0]) < 1) row = 1; DeleteChar(screen, row); parsestate = groundtable; break; case CASE_TRACK_MOUSE: /* Track mouse as long as in window and between specified rows */ TrackMouse(param[0], param[2]-1, param[1]-1, param[3]-1, param[4]-2); break; case CASE_DECID: param[0] = -1; /* Default ID parameter */ /* Fall through into ... */ case CASE_DA1: /* DA1 */ if (param[0] <= 0) { /* less than means DEFAULT */ reply.a_type = CSI; reply.a_pintro = '?'; reply.a_nparam = 2; reply.a_param[0] = 1; /* VT102 */ reply.a_param[1] = 2; /* VT102 */ reply.a_inters = 0; reply.a_final = 'c'; unparseseq(&reply, screen->respond); } parsestate = groundtable; break; case CASE_TBC: /* TBC */ if ((row = param[0]) <= 0) /* less than means default */ TabClear(term->tabs, screen->cur_col); else if (row == 3) TabZonk(term->tabs); parsestate = groundtable; break; case CASE_SET: /* SET */ ansi_modes(term, bitset); parsestate = groundtable; break; case CASE_RST: /* RST */ ansi_modes(term, bitclr); parsestate = groundtable; break; case CASE_SGR: /* SGR */ for (row=0; rowflags &= ~(INVERSE|BOLD|UNDERLINE|FORECOLORED|BACKCOLORED); #else /* !KTERM_COLOR */ term->flags &= ~(INVERSE|BOLD|UNDERLINE); #endif /* !KTERM_COLOR */ break; case 1: case 5: /* Blink, really. */ term->flags |= BOLD; break; case 4: /* Underscore */ term->flags |= UNDERLINE; break; case 7: term->flags |= INVERSE; break; #ifdef KTERM_COLOR case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37: term->flags &= ~FORECOLORMASK; term->flags |= FORECOLORED|FORECOLOR(param[row]-30); break; case 39: term->flags &= ~FORECOLORED; break; case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47: term->flags &= ~BACKCOLORMASK; term->flags |= BACKCOLORED|BACKCOLOR(param[row]-40); break; case 49: term->flags &= ~BACKCOLORED; break; #endif /* KTERM_COLOR */ } } parsestate = groundtable; break; case CASE_CPR: /* CPR */ if ((row = param[0]) == 5) { reply.a_type = CSI; reply.a_pintro = 0; reply.a_nparam = 1; reply.a_param[0] = 0; reply.a_inters = 0; reply.a_final = 'n'; unparseseq(&reply, screen->respond); } else if (row == 6) { reply.a_type = CSI; reply.a_pintro = 0; reply.a_nparam = 2; reply.a_param[0] = screen->cur_row+1; reply.a_param[1] = screen->cur_col+1; reply.a_inters = 0; reply.a_final = 'R'; unparseseq(&reply, screen->respond); } parsestate = groundtable; break; case CASE_HP_MEM_LOCK: case CASE_HP_MEM_UNLOCK: if(screen->scroll_amt) FlushScroll(screen); if (parsestate[c] == CASE_HP_MEM_LOCK) screen->top_marg = screen->cur_row; else screen->top_marg = 0; parsestate = groundtable; break; case CASE_DECSTBM: /* DECSTBM - set scrolling region */ if((top = param[0]) < 1) top = 1; if(nparam < 2 || (bot = param[1]) == DEFAULT || bot > screen->max_row + 1 || bot == 0) bot = screen->max_row+1; if (bot > top) { if(screen->scroll_amt) FlushScroll(screen); screen->top_marg = top-1; screen->bot_marg = bot-1; #ifdef STATUSLINE if (!screen->instatus) #endif /* STATUSLINE */ CursorSet(screen, 0, 0, term->flags); } parsestate = groundtable; break; case CASE_DECREQTPARM: /* DECREQTPARM */ if ((row = param[0]) == DEFAULT) row = 0; if (row == 0 || row == 1) { reply.a_type = CSI; reply.a_pintro = 0; reply.a_nparam = 7; reply.a_param[0] = row + 2; reply.a_param[1] = 1; /* no parity */ reply.a_param[2] = 1; /* eight bits */ reply.a_param[3] = 112; /* transmit 9600 baud */ reply.a_param[4] = 112; /* receive 9600 baud */ reply.a_param[5] = 1; /* clock multiplier ? */ reply.a_param[6] = 0; /* STP flags ? */ reply.a_inters = 0; reply.a_final = 'x'; unparseseq(&reply, screen->respond); } parsestate = groundtable; break; case CASE_DECSET: /* DECSET */ dpmodes(term, bitset); parsestate = groundtable; #ifndef KTERM_NOTEK if(screen->TekEmu) return; #endif /* !KTERM_NOTEK */ break; case CASE_DECRST: /* DECRST */ dpmodes(term, bitclr); parsestate = groundtable; break; case CASE_DECALN: /* DECALN */ if(screen->cursor_state) HideCursor(); for(row = screen->max_row ; row >= 0 ; row--) { #ifdef KTERM col = screen->max_col + 1; for(xp = screen->buf[row] ; col > 0 ; col--) { xp->code = (unsigned char) 'E'; xp->gset = GSET_ASCII; xp->attr = 0; xp++; } #else /* !KTERM */ bzero(screen->buf[2 * row + 1], col = screen->max_col + 1); for(cp = (unsigned char *)screen->buf[2 * row] ; col > 0 ; col--) *cp++ = (unsigned char) 'E'; #endif /* !KTERM */ } ScrnRefresh(screen, 0, 0, screen->max_row + 1, screen->max_col + 1, False); parsestate = groundtable; break; case CASE_GSETS: #ifdef KTERM # ifdef KTERM_MBCS screen->gsets[scstype] = GSET(c) | cs96 | mbcs; # else /* !KTERM_MBCS */ screen->gsets[scstype] = GSET(c) | cs96; # endif /* !KTERM_MBCS */ #else /* !KTERM */ screen->gsets[scstype] = c; #endif /* !KTERM */ parsestate = groundtable; break; case CASE_DECSC: /* DECSC */ CursorSave(term, &screen->sc); parsestate = groundtable; break; case CASE_DECRC: /* DECRC */ CursorRestore(term, &screen->sc); parsestate = groundtable; break; case CASE_DECKPAM: /* DECKPAM */ term->keyboard.flags |= KYPD_APL; update_appkeypad(); parsestate = groundtable; break; case CASE_DECKPNM: /* DECKPNM */ term->keyboard.flags &= ~KYPD_APL; update_appkeypad(); parsestate = groundtable; break; case CASE_IND: /* IND */ #ifdef STATUSLINE if (!screen->instatus) #endif /* STATUSLINE */ Index(screen, 1); #ifdef KTERM_XAW3D if (XtAppPending(app_con) > 0 || #else /* !KTERM_XAW3D */ if (QLength(screen->display) > 0 || #endif /* !KTERM_XAW3D */ GetBytesAvailable (ConnectionNumber(screen->display)) > 0) xevents(); parsestate = groundtable; break; case CASE_NEL: /* NEL */ #ifdef STATUSLINE if (!screen->instatus) #endif /* STATUSLINE */ Index(screen, 1); CarriageReturn(screen); #ifdef KTERM_XAW3D if (XtAppPending(app_con) > 0 || #else /* !KTERM_XAW3D */ if (QLength(screen->display) > 0 || #endif /* !KTERM_XAW3D */ GetBytesAvailable (ConnectionNumber(screen->display)) > 0) xevents(); parsestate = groundtable; break; case CASE_HTS: /* HTS */ TabSet(term->tabs, screen->cur_col); parsestate = groundtable; break; case CASE_RI: /* RI */ #ifdef STATUSLINE if (!screen->instatus) #endif /* STATUSLINE */ RevIndex(screen, 1); parsestate = groundtable; break; case CASE_SS2: /* SS2 */ screen->curss = 2; parsestate = groundtable; break; case CASE_SS3: /* SS3 */ screen->curss = 3; parsestate = groundtable; break; case CASE_CSI_STATE: /* enter csi state */ nparam = 1; param[0] = DEFAULT; parsestate = csitable; break; case CASE_OSC: /* Operating System Command: ESC ] */ do_osc(finput); parsestate = groundtable; break; case CASE_RIS: /* RIS */ VTReset(TRUE); parsestate = groundtable; break; case CASE_LS2: /* LS2 */ screen->curgl = 2; parsestate = groundtable; break; case CASE_LS3: /* LS3 */ screen->curgl = 3; parsestate = groundtable; break; case CASE_LS3R: /* LS3R */ screen->curgr = 3; parsestate = groundtable; break; case CASE_LS2R: /* LS2R */ screen->curgr = 2; parsestate = groundtable; break; case CASE_LS1R: /* LS1R */ screen->curgr = 1; parsestate = groundtable; break; #ifdef STATUSLINE case CASE_TO_STATUS: if((col = param[0]) < 1) col = 1; ToStatus(col-1); parsestate = groundtable; break; case CASE_FROM_STATUS: FromStatus(); parsestate = groundtable; break; case CASE_SHOW_STATUS: ShowStatus(); parsestate = groundtable; break; case CASE_HIDE_STATUS: HideStatus(); parsestate = groundtable; break; case CASE_ERASE_STATUS: EraseStatus(); parsestate = groundtable; break; #endif /* STATUSLINE */ case CASE_XTERM_SAVE: savemodes(term); parsestate = groundtable; break; case CASE_XTERM_RESTORE: restoremodes(term); parsestate = groundtable; break; #ifdef KTERM_KANJIMODE } #else /* !KTERM_KANJIMODE */ } #endif /* !KTERM_KANJIMODE */ } } static finput() { return(doinput()); } static char *v_buffer; /* pointer to physical buffer */ static char *v_bufstr = NULL; /* beginning of area to write */ static char *v_bufptr; /* end of area to write */ static char *v_bufend; /* end of physical buffer */ #define ptymask() (v_bufptr > v_bufstr ? pty_mask : 0) /* Write data to the pty as typed by the user, pasted with the mouse, or generated by us in response to a query ESC sequence. */ v_write(f, d, len) int f; char *d; int len; { int riten; int c = len; if (v_bufstr == NULL && len > 0) { v_buffer = XtMalloc(len); v_bufstr = v_buffer; v_bufptr = v_buffer; v_bufend = v_buffer + len; } #ifdef DEBUG if (debug) { fprintf(stderr, "v_write called with %d bytes (%d left over)", len, v_bufptr - v_bufstr); if (len > 1 && len < 10) fprintf(stderr, " \"%.*s\"", len, d); fprintf(stderr, "\n"); } #endif if (!FD_ISSET (f, &pty_mask)) return(write(f, d, len)); /* * Append to the block we already have. * Always doing this simplifies the code, and * isn't too bad, either. If this is a short * block, it isn't too expensive, and if this is * a long block, we won't be able to write it all * anyway. */ if (len > 0) { if (v_bufend < v_bufptr + len) { /* we've run out of room */ if (v_bufstr != v_buffer) { /* there is unused space, move everything down */ /* possibly overlapping memmove here */ #ifdef DEBUG if (debug) fprintf(stderr, "moving data down %d\n", v_bufstr - v_buffer); #endif memmove( v_buffer, v_bufstr, v_bufptr - v_bufstr); v_bufptr -= v_bufstr - v_buffer; v_bufstr = v_buffer; } if (v_bufend < v_bufptr + len) { /* still won't fit: get more space */ /* Don't use XtRealloc because an error is not fatal. */ int size = v_bufptr - v_buffer; /* save across realloc */ v_buffer = realloc(v_buffer, size + len); if (v_buffer) { #ifdef DEBUG if (debug) fprintf(stderr, "expanded buffer to %d\n", size + len); #endif v_bufstr = v_buffer; v_bufptr = v_buffer + size; v_bufend = v_bufptr + len; } else { /* no memory: ignore entire write request */ fprintf(stderr, "%s: cannot allocate buffer space\n", xterm_name); v_buffer = v_bufstr; /* restore clobbered pointer */ c = 0; } } } if (v_bufend >= v_bufptr + len) { /* new stuff will fit */ memmove( v_bufptr, d, len); v_bufptr += len; } } /* * Write out as much of the buffer as we can. * Be careful not to overflow the pty's input silo. * We are conservative here and only write * a small amount at a time. * * If we can't push all the data into the pty yet, we expect write * to return a non-negative number less than the length requested * (if some data written) or -1 and set errno to EAGAIN, * EWOULDBLOCK, or EINTR (if no data written). * * (Not all systems do this, sigh, so the code is actually * a little more forgiving.) */ #define MAX_PTY_WRITE 128 /* 1/2 POSIX minimum MAX_INPUT */ if (v_bufptr > v_bufstr) { riten = write(f, v_bufstr, v_bufptr - v_bufstr <= MAX_PTY_WRITE ? v_bufptr - v_bufstr : MAX_PTY_WRITE); if (riten < 0) { #ifdef DEBUG if (debug) perror("write"); #endif riten = 0; } #ifdef DEBUG if (debug) fprintf(stderr, "write called with %d, wrote %d\n", v_bufptr - v_bufstr <= MAX_PTY_WRITE ? v_bufptr - v_bufstr : MAX_PTY_WRITE, riten); #endif v_bufstr += riten; if (v_bufstr >= v_bufptr) /* we wrote it all */ v_bufstr = v_bufptr = v_buffer; } /* * If we have lots of unused memory allocated, return it */ if (v_bufend - v_bufptr > 1024) { /* arbitrary hysteresis */ /* save pointers across realloc */ int start = v_bufstr - v_buffer; int size = v_bufptr - v_buffer; int allocsize = size ? size : 1; v_buffer = realloc(v_buffer, allocsize); if (v_buffer) { v_bufstr = v_buffer + start; v_bufptr = v_buffer + size; v_bufend = v_buffer + allocsize; #ifdef DEBUG if (debug) fprintf(stderr, "shrunk buffer to %d\n", allocsize); #endif } else { /* should we print a warning if couldn't return memory? */ v_buffer = v_bufstr - start; /* restore clobbered pointer */ } } return(c); } static fd_set select_mask; static fd_set write_mask; static int pty_read_bytes; in_put() { register TScreen *screen = &term->screen; register int i; static struct timeval select_timeout; for( ; ; ) { if (FD_ISSET (screen->respond, &select_mask) && eventMode == NORMAL) { #ifdef ALLOWLOGGING if (screen->logging) FlushLog(screen); #endif bcnt = read(screen->respond, (char *)(bptr = buffer), BUF_SIZE); if (bcnt < 0) { if (errno == EIO) Cleanup (0); else if (!E_TEST(errno)) Panic( "input: read returned unexpected error (%d)\n", errno); } else if (bcnt == 0) Panic("input: read returned zero\n", 0); else { /* read from pty was successful */ #ifdef KTERM_MBCS if (pending_byte) { /* * restore pending_byte to the top of * the text which just read. */ *--bptr = pending_byte; bcnt++; pending_byte = 0; } #endif /* KTERM_MBCS */ if (!screen->output_eight_bits) { register int bc = bcnt; register Char *b = bptr; for (; bc > 0; bc--, b++) { *b &= (Char) 0x7f; } } if ( screen->scrollWidget && screen->scrollttyoutput && screen->topline < 0) WindowScroll(screen, 0); /* Scroll to bottom */ pty_read_bytes += bcnt; /* stop speed reading at some point to look for X stuff */ /* (4096 is just a random large number.) */ if (pty_read_bytes > 4096) FD_CLR (screen->respond, &select_mask); break; } } pty_read_bytes = 0; /* update the screen */ if (screen->scroll_amt) FlushScroll(screen); if (screen->cursor_set && (screen->cursor_col != screen->cur_col || screen->cursor_row != screen->cur_row)) { if (screen->cursor_state) HideCursor(); ShowCursor(); } else if (screen->cursor_set != screen->cursor_state) { if (screen->cursor_set) ShowCursor(); else HideCursor(); } XFlush(screen->display); /* always flush writes before waiting */ /* Update the masks and, unless X events are already in the queue, wait for I/O to be possible. */ XFD_COPYSET (&Select_mask, &select_mask); if (v_bufptr > v_bufstr) { XFD_COPYSET (&pty_mask, &write_mask); } else FD_ZERO (&write_mask); select_timeout.tv_sec = 0; #ifdef KTERM_XAW3D /* * if there's either an XEvent or an XtTimeout pending, just take * a quick peek, i.e. timeout from the select() immediately. If * there's nothing pending, let select() block a little while, but * for a shorter interval than the arrow-style scrollbar timeout. */ if (XtAppPending(app_con)) select_timeout.tv_usec = 0; else select_timeout.tv_usec = 50000; i = Select(max_plus1, &select_mask, &write_mask, NULL, &select_timeout); #else /* !KTERM_XAW3D */ select_timeout.tv_usec = 0; i = Select(max_plus1, &select_mask, &write_mask, NULL, QLength(screen->display) ? &select_timeout : NULL); #endif /* !KTERM_XAW3D */ if (i < 0) { if (errno != EINTR) SysError(ERROR_SELECT); continue; } /* if there is room to write more data to the pty, go write more */ if (FD_ISSET (screen->respond, &write_mask)) { v_write(screen->respond, 0, 0); /* flush buffer */ } /* if there are X events already in our queue, it counts as being readable */ #ifdef KTERM_XAW3D if (XtAppPending(app_con) || #else /* !KTERM_XAW3D */ if (QLength(screen->display) || #endif /* !KTERM_XAW3D */ FD_ISSET (ConnectionNumber(screen->display), &select_mask)) { xevents(); } } bcnt--; return(*bptr++); } /* * process a string of characters according to the character set indicated * by charset. worry about end of line conditions (wraparound if selected). */ static void dotext(screen, flags, charset, buf, ptr) register TScreen *screen; unsigned flags; #ifdef KTERM Char charset; Char *buf; /* start of characters to process */ Char *ptr; /* end */ #else /* !KTERM */ char charset; char *buf; /* start of characters to process */ char *ptr; /* end */ #endif /* !KTERM */ { #ifdef KTERM int do_wrap = 0; #else /* !KTERM */ register char *s; #endif /* !KTERM */ register int len; register int n; register int next_col; #ifndef KTERM switch (charset) { case 'A': /* United Kingdom set */ for (s=buf; s=0x5f && *s<=0x7e) *s = *s == 0x5f ? 0x7f : *s - 0x5f; break; default: /* any character sets we don't recognize*/ return; } #endif /* !KTERM */ len = ptr - buf; ptr = buf; while (len > 0) { n = screen->max_col - screen->cur_col +1; if (n <= 1) { #ifdef STATUSLINE if (screen->do_wrap && (flags&WRAPAROUND) && !screen->instatus) { #else /* !STATUSLINE */ if (screen->do_wrap && (flags&WRAPAROUND)) { #endif /* !STATUSLINE */ /* mark that we had to wrap this line */ ScrnSetAttributes(screen, screen->cur_row, 0, LINEWRAPPED, LINEWRAPPED, 1); Index(screen, 1); screen->cur_col = 0; screen->do_wrap = 0; n = screen->max_col+1; } else n = 1; } if (len < n) n = len; #ifdef KTERM_MBCS if (charset & MBCS) { if (n == 1) { if (flags & WRAPAROUND) { n--; do_wrap = 1; } else n++; } else if (n & 1) n--; } #endif /* KTERM_MBCS */ next_col = screen->cur_col + n; #ifdef KTERM WriteText(screen, ptr, n, flags, charset); #else /* !KTERM */ WriteText(screen, ptr, n, flags); #endif /* !KTERM */ /* * the call to WriteText updates screen->cur_col. * If screen->cur_col != next_col, we must have * hit the right margin, so set the do_wrap flag. */ screen->do_wrap = (screen->cur_col < next_col); #ifdef KTERM_MBCS screen->do_wrap |= do_wrap; #endif /* KTERM_MBCS */ len -= n; ptr += n; } } /* * write a string str of length len onto the screen at * the current cursor position. update cursor position. */ #ifdef KTERM static void WriteText(screen, str, len, flags, gset) register TScreen *screen; register char *str; register int len; unsigned flags; register Char gset; { if(screen->cursor_state) HideCursor(); if (flags & INSERT) InsertChar(screen, len); # ifdef KTERM_MBCS BreakMBchar(screen); screen->cur_col += len; BreakMBchar(screen); screen->cur_col -= len; # endif /* KTERM_MBCS */ ScreenWrite(screen, str, flags, gset, len); if (screen->cur_row - screen->topline <= screen->max_row) { if (!(AddToRefresh(screen))) { if(screen->scroll_amt) FlushScroll(screen); ScreenDraw(screen, screen->cur_row, screen->cur_col, screen->cur_col+len, flags, False); } # ifdef STATUSLINE } else if (screen->instatus) { ScreenDraw(screen, screen->max_row + 1, screen->cur_col, screen->cur_col+len, flags, False); # endif /* STATUSLINE */ } CursorForward(screen, len); } #else /* !KTERM */ static void WriteText(screen, str, len, flags) register TScreen *screen; register char *str; register int len; unsigned flags; { register int cx, cy; register unsigned fgs = flags; GC currentGC; #ifndef ENBUG /* kagotai */ if (fgs & INSERT) InsertChar(screen, len); #endif #ifdef STATUSLINE if(screen->instatus && screen->reversestatus) fgs ^= INVERSE; if(screen->cur_row - screen->topline <= screen->max_row || screen->instatus) { #else /* !STATUSLINE */ if(screen->cur_row - screen->topline <= screen->max_row) { #endif /* !STATUSLINE */ /* if(screen->cur_row == screen->cursor_row && screen->cur_col <= screen->cursor_col && screen->cursor_col <= screen->cur_col + len - 1) screen->cursor_state = OFF; */ if(screen->cursor_state) HideCursor(); /* * make sure that the correct GC is current */ if (fgs & BOLD) if (fgs & INVERSE) currentGC = screen->reverseboldGC; else currentGC = screen->normalboldGC; else /* not bold */ if (fgs & INVERSE) currentGC = screen->reverseGC; else currentGC = screen->normalGC; #ifdef ENBUG /* kagotai */ if (fgs & INSERT) InsertChar(screen, len); #endif if (!(AddToRefresh(screen))) { if(screen->scroll_amt) FlushScroll(screen); cx = CursorX(screen, screen->cur_col); cy = CursorY(screen, screen->cur_row)+screen->fnt_norm->ascent; XDrawImageString(screen->display, TextWindow(screen), currentGC, cx, cy, str, len); if((fgs & BOLD) && screen->enbolden) if (currentGC == screen->normalGC || screen->reverseGC) XDrawString(screen->display, TextWindow(screen), currentGC,cx + 1, cy, str, len); if(fgs & UNDERLINE) XDrawLine(screen->display, TextWindow(screen), currentGC, cx, cy+1, cx + len * FontWidth(screen), cy+1); /* * the following statements compile data to compute the average * number of characters written on each call to XText. The data * may be examined via the use of a "hidden" escape sequence. */ ctotal += len; ++ntotal; } } ScreenWrite(screen, str, flags, len); CursorForward(screen, len); } #endif /* !KTERM */ /* * process ANSI modes set, reset */ ansi_modes(termw, func) XtermWidget termw; void (*func)(); { register int i; for (i=0; iflags, INSERT); break; case 20: /* LNM */ (*func)(&termw->flags, LINEFEED); update_autolinefeed(); break; } } } /* * process DEC private modes set, reset */ dpmodes(termw, func) XtermWidget termw; void (*func)(); { register TScreen *screen = &termw->screen; register int i, j; for (i=0; ikeyboard.flags, CURSOR_APL); update_appcursor(); break; case 2: /* ANSI/VT52 mode */ if (func == bitset) { screen->gsets[0] = screen->gsets[1] = screen->gsets[2] = screen->gsets[3] = 'B'; screen->curgl = 0; screen->curgr = 2; } break; case 3: /* DECCOLM */ if(screen->c132) { ClearScreen(screen); CursorSet(screen, 0, 0, termw->flags); if((j = func == bitset ? 132 : 80) != ((termw->flags & IN132COLUMNS) ? 132 : 80) || j != screen->max_col + 1) { Dimension replyWidth, replyHeight; XtGeometryResult status; status = XtMakeResizeRequest ( (Widget) termw, (Dimension) FontWidth(screen) * j + 2*screen->border + screen->scrollbar, (Dimension) FontHeight(screen) * (screen->max_row + 1) #ifdef STATUSLINE + screen->statusheight #endif /* STATUSLINE */ + 2 * screen->border, &replyWidth, &replyHeight); if (status == XtGeometryYes || status == XtGeometryDone) { ScreenResize (&termw->screen, replyWidth, replyHeight, &termw->flags); } } (*func)(&termw->flags, IN132COLUMNS); } break; case 4: /* DECSCLM (slow scroll) */ if (func == bitset) { screen->jumpscroll = 0; if (screen->scroll_amt) FlushScroll(screen); } else screen->jumpscroll = 1; (*func)(&termw->flags, SMOOTHSCROLL); update_jumpscroll(); break; case 5: /* DECSCNM */ j = termw->flags; (*func)(&termw->flags, REVERSE_VIDEO); if ((termw->flags ^ j) & REVERSE_VIDEO) ReverseVideo(termw); /* update_reversevideo done in RevVid */ break; case 6: /* DECOM */ (*func)(&termw->flags, ORIGIN); CursorSet(screen, 0, 0, termw->flags); break; case 7: /* DECAWM */ (*func)(&termw->flags, WRAPAROUND); update_autowrap(); break; case 8: /* DECARM */ /* ignore autorepeat */ break; case 9: /* MIT bogus sequence */ if(func == bitset) screen->send_mouse_pos = 1; else screen->send_mouse_pos = 0; break; #ifndef KTERM_NOTEK case 38: /* DECTEK */ if(func == bitset && !(screen->inhibit & I_TEK)) { #ifdef ALLOWLOGGING if(screen->logging) { FlushLog(screen); screen->logstart = Tbuffer; } #endif screen->TekEmu = TRUE; } break; #endif /* !KTERM_NOTEK */ case 40: /* 132 column mode */ screen->c132 = (func == bitset); update_allow132(); break; case 41: /* curses hack */ screen->curses = (func == bitset); update_cursesemul(); break; case 44: /* margin bell */ screen->marginbell = (func == bitset); if(!screen->marginbell) screen->bellarmed = -1; update_marginbell(); break; case 45: /* reverse wraparound */ (*func)(&termw->flags, REVERSEWRAP); update_reversewrap(); break; #ifdef ALLOWLOGGING case 46: /* logging */ #ifdef ALLOWLOGFILEONOFF /* * if this feature is enabled, logging may be * enabled and disabled via escape sequences. */ if(func == bitset) StartLog(screen); else CloseLog(screen); #else Bell(XkbBI_Info,0); Bell(XkbBI_Info,0); #endif /* ALLOWLOGFILEONOFF */ break; #endif case 47: /* alternate buffer */ if (!termw->misc.titeInhibit) { if(func == bitset) ToAlternate(screen); else FromAlternate(screen); } break; #ifdef STATUSLINE case 48: /* reverse statusline */ j = screen->reversestatus; if(func == bitset) screen->reversestatus = TRUE; else screen->reversestatus = FALSE; if (j != screen->reversestatus) ScrnRefresh(screen, screen->max_row + 1, 0, 1, screen->max_col + 1, False); break; #endif /* STATUSLINE */ case 1000: /* xterm bogus sequence */ if(func == bitset) screen->send_mouse_pos = 2; else screen->send_mouse_pos = 0; break; case 1001: /* xterm sequence w/hilite tracking */ if(func == bitset) screen->send_mouse_pos = 3; else screen->send_mouse_pos = 0; break; } } } /* * process xterm private modes save */ savemodes(termw) XtermWidget termw; { register TScreen *screen = &termw->screen; register int i; for (i = 0; i < nparam; i++) { switch (param[i]) { case 1: /* DECCKM */ screen->save_modes[0] = termw->keyboard.flags & CURSOR_APL; break; case 3: /* DECCOLM */ if(screen->c132) screen->save_modes[1] = termw->flags & IN132COLUMNS; break; case 4: /* DECSCLM (slow scroll) */ screen->save_modes[2] = termw->flags & SMOOTHSCROLL; break; case 5: /* DECSCNM */ screen->save_modes[3] = termw->flags & REVERSE_VIDEO; break; case 6: /* DECOM */ screen->save_modes[4] = termw->flags & ORIGIN; break; case 7: /* DECAWM */ screen->save_modes[5] = termw->flags & WRAPAROUND; break; case 8: /* DECARM */ /* ignore autorepeat */ break; case 9: /* mouse bogus sequence */ screen->save_modes[7] = screen->send_mouse_pos; break; case 40: /* 132 column mode */ screen->save_modes[8] = screen->c132; break; case 41: /* curses hack */ screen->save_modes[9] = screen->curses; break; case 44: /* margin bell */ screen->save_modes[12] = screen->marginbell; break; case 45: /* reverse wraparound */ screen->save_modes[13] = termw->flags & REVERSEWRAP; break; #ifdef ALLOWLOGGING case 46: /* logging */ screen->save_modes[14] = screen->logging; break; #endif case 47: /* alternate buffer */ screen->save_modes[15] = screen->alternate; break; #ifdef STATUSLINE case 48: /* reverse statusline */ screen->save_modes[16] = screen->reversestatus; break; #endif /* STATUSLINE */ case 1000: /* mouse bogus sequence */ case 1001: screen->save_modes[7] = screen->send_mouse_pos; break; } } } /* * process xterm private modes restore */ restoremodes(termw) XtermWidget termw; { register TScreen *screen = &termw->screen; register int i, j; for (i = 0; i < nparam; i++) { switch (param[i]) { case 1: /* DECCKM */ termw->keyboard.flags &= ~CURSOR_APL; termw->keyboard.flags |= screen->save_modes[0] & CURSOR_APL; update_appcursor(); break; case 3: /* DECCOLM */ if(screen->c132) { ClearScreen(screen); CursorSet(screen, 0, 0, termw->flags); if((j = (screen->save_modes[1] & IN132COLUMNS) ? 132 : 80) != ((termw->flags & IN132COLUMNS) ? 132 : 80) || j != screen->max_col + 1) { Dimension replyWidth, replyHeight; XtGeometryResult status; status = XtMakeResizeRequest ( (Widget) termw, (Dimension) FontWidth(screen) * j + 2*screen->border + screen->scrollbar, (Dimension) FontHeight(screen) * (screen->max_row + 1) + 2*screen->border, &replyWidth, &replyHeight); if (status == XtGeometryYes || status == XtGeometryDone) { ScreenResize (&termw->screen, replyWidth, replyHeight, &termw->flags); } } termw->flags &= ~IN132COLUMNS; termw->flags |= screen->save_modes[1] & IN132COLUMNS; } break; case 4: /* DECSCLM (slow scroll) */ if (screen->save_modes[2] & SMOOTHSCROLL) { screen->jumpscroll = 0; if (screen->scroll_amt) FlushScroll(screen); } else screen->jumpscroll = 1; termw->flags &= ~SMOOTHSCROLL; termw->flags |= screen->save_modes[2] & SMOOTHSCROLL; update_jumpscroll(); break; case 5: /* DECSCNM */ if((screen->save_modes[3] ^ termw->flags) & REVERSE_VIDEO) { termw->flags &= ~REVERSE_VIDEO; termw->flags |= screen->save_modes[3] & REVERSE_VIDEO; ReverseVideo(termw); /* update_reversevideo done in RevVid */ } break; case 6: /* DECOM */ termw->flags &= ~ORIGIN; termw->flags |= screen->save_modes[4] & ORIGIN; CursorSet(screen, 0, 0, termw->flags); break; case 7: /* DECAWM */ termw->flags &= ~WRAPAROUND; termw->flags |= screen->save_modes[5] & WRAPAROUND; update_autowrap(); break; case 8: /* DECARM */ /* ignore autorepeat */ break; case 9: /* MIT bogus sequence */ screen->send_mouse_pos = screen->save_modes[7]; break; case 40: /* 132 column mode */ screen->c132 = screen->save_modes[8]; update_allow132(); break; case 41: /* curses hack */ screen->curses = screen->save_modes[9]; update_cursesemul(); break; case 44: /* margin bell */ if(!(screen->marginbell = screen->save_modes[12])) screen->bellarmed = -1; update_marginbell(); break; case 45: /* reverse wraparound */ termw->flags &= ~REVERSEWRAP; termw->flags |= screen->save_modes[13] & REVERSEWRAP; update_reversewrap(); break; #ifdef ALLOWLOGGING case 46: /* logging */ #ifdef ALLOWLOGFILEONOFF if(screen->save_modes[14]) StartLog(screen); else CloseLog(screen); #endif /* ALLOWLOGFILEONOFF */ /* update_logging done by StartLog and CloseLog */ break; #endif case 47: /* alternate buffer */ if (!termw->misc.titeInhibit) { if(screen->save_modes[15]) ToAlternate(screen); else FromAlternate(screen); /* update_altscreen done by ToAlt and FromAlt */ } break; #ifdef STATUSLINE case 48: /* reverse statusline */ if (screen->save_modes[16] != screen->reversestatus) { screen->reversestatus = screen->save_modes[16]; ScrnRefresh(screen, screen->max_row + 1, 0, 1, screen->max_col + 1, False); } break; #endif /* STATUSLINE */ case 1000: /* mouse bogus sequence */ case 1001: screen->send_mouse_pos = screen->save_modes[7]; break; } } } /* * set a bit in a word given a pointer to the word and a mask. */ static void bitset(p, mask) unsigned *p; int mask; { *p |= mask; } /* * clear a bit in a word given a pointer to the word and a mask. */ static void bitclr(p, mask) unsigned *p; int mask; { *p &= ~mask; } unparseseq(ap, fd) register ANSI *ap; int fd; { register int c; register int i; register int inters; c = ap->a_type; if (c>=0x80 && c<=0x9F) { unparseputc(ESC, fd); c -= 0x40; } unparseputc(c, fd); c = ap->a_type; if (c==ESC || c==DCS || c==CSI || c==OSC || c==PM || c==APC) { if (ap->a_pintro != 0) unparseputc((char) ap->a_pintro, fd); for (i=0; ia_nparam; ++i) { if (i != 0) unparseputc(';', fd); unparseputn((unsigned int) ap->a_param[i], fd); } inters = ap->a_inters; for (i=3; i>=0; --i) { c = (inters >> (8*i)) & 0xff; if (c != 0) unparseputc(c, fd); } unparseputc((char) ap->a_final, fd); } } unparseputn(n, fd) unsigned int n; int fd; { unsigned int q; q = n/10; if (q != 0) unparseputn(q, fd); unparseputc((char) ('0' + (n%10)), fd); } unparseputc(c, fd) char c; int fd; { char buf[2]; register i = 1; extern XtermWidget term; if((buf[0] = c) == '\r' && (term->flags & LINEFEED)) { buf[1] = '\n'; i++; } v_write(fd, buf, i); } unparsefputs (s, fd) register char *s; int fd; { if (s) { while (*s) unparseputc (*s++, fd); } } static void SwitchBufs(); static void ToAlternate(screen) register TScreen *screen; { extern ScrnBuf Allocate(); if(screen->alternate) return; if(!screen->altbuf) screen->altbuf = Allocate(screen->max_row + 1, screen->max_col + 1, &screen->abuf_address); SwitchBufs(screen); screen->alternate = TRUE; update_altscreen(); } static void FromAlternate(screen) register TScreen *screen; { if(!screen->alternate) return; screen->alternate = FALSE; SwitchBufs(screen); update_altscreen(); } static void SwitchBufs(screen) register TScreen *screen; { register int rows, top; if(screen->cursor_state) HideCursor(); rows = screen->max_row + 1; SwitchBufPtrs(screen); TrackText(0, 0, 0, 0); /* remove any highlighting */ if((top = -screen->topline) <= screen->max_row) { if(screen->scroll_amt) FlushScroll(screen); #ifdef STATUSLINE if(top == 0 && !screen->statusheight) #else /* !STATUSLINE */ if(top == 0) #endif /* !STATUSLINE */ XClearWindow(screen->display, TextWindow(screen)); else XClearArea( screen->display, TextWindow(screen), (int) screen->border + screen->scrollbar, (int) top * FontHeight(screen) + screen->border, (unsigned) Width(screen), (unsigned) (screen->max_row - top + 1) * FontHeight(screen), FALSE); } ScrnRefresh(screen, 0, 0, rows, screen->max_col + 1, False); } /* swap buffer line pointers between alt and regular screens */ SwitchBufPtrs(screen) register TScreen *screen; { register int rows = screen->max_row + 1; #ifdef KTERM Bchr *savebuf [MAX_ROWS]; Bchr **save; save = rows > MAX_ROWS ? (Bchr **)XtMalloc(sizeof(Bchr *) * rows) : savebuf; memmove( (char *)save, (char *)screen->buf, sizeof(Bchr *) * rows); memmove( (char *)screen->buf, (char *)screen->altbuf, sizeof(Bchr *) * rows); memmove( (char *)screen->altbuf, (char *)save, sizeof(Bchr *) * rows); if (save != savebuf) XtFree((char *)save); #else /* !KTERM */ char *save [2 * MAX_ROWS]; memmove( (char *)save, (char *)screen->buf, 2 * sizeof(char *) * rows); memmove( (char *)screen->buf, (char *)screen->altbuf, 2 * sizeof(char *) * rows); memmove( (char *)screen->altbuf, (char *)save, 2 * sizeof(char *) * rows); #endif /* !KTERM */ } VTRun() { register TScreen *screen = &term->screen; register int i; #ifdef KTERM_NOTEK VTInit (); XtMapWidget (term->core.parent); #else /* !KTERM_NOTEK */ if (!screen->Vshow) { set_vt_visibility (TRUE); } update_vttekmode(); update_vtshow(); update_tekshow(); set_vthide_sensitivity(); #endif /* !KTERM_NOTEK */ if (screen->allbuf == NULL) VTallocbuf (); screen->cursor_state = OFF; screen->cursor_set = ON; bcnt = 0; bptr = buffer; #ifndef KTERM_NOTEK while(Tpushb > Tpushback) { *bptr++ = *--Tpushb; bcnt++; } bcnt += (i = Tbcnt); for( ; i > 0 ; i--) *bptr++ = *Tbptr++; #endif /* !KTERM_NOTEK */ bptr = buffer; #ifndef KTERM_NOTEK if(!setjmp(VTend)) #endif /* !KTERM_NOTEK */ VTparse(); HideCursor(); screen->cursor_set = OFF; } /*ARGSUSED*/ static void VTExpose(w, event, region) Widget w; XEvent *event; Region region; { register TScreen *screen = &term->screen; #ifdef DEBUG if(debug) fputs("Expose\n", stderr); #endif /* DEBUG */ if (event->type == Expose) HandleExposure (screen, event); } static void VTGraphicsOrNoExpose (event) XEvent *event; { register TScreen *screen = &term->screen; if (screen->incopy <= 0) { screen->incopy = 1; if (screen->scrolls > 0) screen->scrolls--; } if (event->type == GraphicsExpose) if (HandleExposure (screen, event)) screen->cursor_state = OFF; if ((event->type == NoExpose) || ((XGraphicsExposeEvent *)event)->count == 0) { if (screen->incopy <= 0 && screen->scrolls > 0) screen->scrolls--; if (screen->scrolls) screen->incopy = -1; else screen->incopy = 0; } } /*ARGSUSED*/ static void VTNonMaskableEvent (w, closure, event, cont) Widget w; /* unused */ XtPointer closure; /* unused */ XEvent *event; Boolean *cont; /* unused */ { switch (event->type) { case GraphicsExpose: case NoExpose: VTGraphicsOrNoExpose (event); break; } } static void VTResize(w) Widget w; { if (XtIsRealized(w)) ScreenResize (&term->screen, term->core.width, term->core.height, &term->flags); } extern Atom wm_delete_window; /* for ICCCM delete window */ static String xterm_trans = "WM_PROTOCOLS: DeleteWindow()\n\ : KeyboardMapping()\n"; int VTInit () { register TScreen *screen = &term->screen; Widget vtparent = term->core.parent; XtRealizeWidget (vtparent); XtOverrideTranslations(vtparent, XtParseTranslationTable(xterm_trans)); (void) XSetWMProtocols (XtDisplay(vtparent), XtWindow(vtparent), &wm_delete_window, 1); if (screen->allbuf == NULL) VTallocbuf (); return (1); } static void VTallocbuf () { register TScreen *screen = &term->screen; int nrows = screen->max_row + 1; extern ScrnBuf Allocate(); /* allocate screen buffer now, if necessary. */ if (screen->scrollWidget) nrows += screen->savelines; screen->allbuf = Allocate (nrows, screen->max_col + 1, &screen->sbuf_address); if (screen->scrollWidget) #ifdef KTERM screen->buf = &screen->allbuf[screen->savelines]; #else /* !KTERM */ screen->buf = &screen->allbuf[2 * screen->savelines]; #endif /* !KTERM */ else screen->buf = screen->allbuf; return; } static void VTClassInit () { XtAddConverter(XtRString, XtRGravity, XmuCvtStringToGravity, (XtConvertArgList) NULL, (Cardinal) 0); } /* ARGSUSED */ static void VTInitialize (wrequest, wnew, args, num_args) Widget wrequest, wnew; ArgList args; Cardinal *num_args; { XtermWidget request = (XtermWidget) wrequest; XtermWidget new = (XtermWidget) wnew; int i; #ifdef KTERM int fnum; #endif /* KTERM */ /* Zero out the entire "screen" component of "new" widget, then do field-by-field assigment of "screen" fields that are named in the resource list. */ bzero ((char *) &new->screen, sizeof(new->screen)); new->screen.c132 = request->screen.c132; new->screen.curses = request->screen.curses; new->screen.hp_ll_bc = request->screen.hp_ll_bc; new->screen.foreground = request->screen.foreground; new->screen.cursorcolor = request->screen.cursorcolor; #ifdef KTERM_COLOR memmove( new->screen.textcolor, request->screen.textcolor, sizeof new->screen.textcolor); #endif /* KTERM_COLOR */ new->screen.border = request->screen.border; new->screen.jumpscroll = request->screen.jumpscroll; #ifdef ALLOWLOGGING new->screen.logfile = request->screen.logfile; #endif new->screen.marginbell = request->screen.marginbell; new->screen.mousecolor = request->screen.mousecolor; new->screen.mousecolorback = request->screen.mousecolorback; new->screen.multiscroll = request->screen.multiscroll; new->screen.nmarginbell = request->screen.nmarginbell; new->screen.savelines = request->screen.savelines; new->screen.scrolllines = request->screen.scrolllines; new->screen.scrollttyoutput = request->screen.scrollttyoutput; new->screen.scrollkey = request->screen.scrollkey; new->screen.visualbell = request->screen.visualbell; #ifndef KTERM_NOTEK new->screen.TekEmu = request->screen.TekEmu; #endif /* !KTERM_NOTEK */ new->misc.re_verse = request->misc.re_verse; new->screen.multiClickTime = request->screen.multiClickTime; new->screen.bellSuppressTime = request->screen.bellSuppressTime; new->screen.charClass = request->screen.charClass; new->screen.cutNewline = request->screen.cutNewline; new->screen.cutToBeginningOfLine = request->screen.cutToBeginningOfLine; new->screen.always_highlight = request->screen.always_highlight; new->screen.pointer_cursor = request->screen.pointer_cursor; new->screen.input_eight_bits = request->screen.input_eight_bits; new->screen.output_eight_bits = request->screen.output_eight_bits; new->screen.allowSendEvents = request->screen.allowSendEvents; new->misc.titeInhibit = request->misc.titeInhibit; #ifdef STATUSLINE new->misc.statusline = request->misc.statusline; new->misc.statusnormal = request->misc.statusnormal; #endif /* STATUSLINE */ #ifdef KTERM new->screen.dynamic_font_load = request->screen.dynamic_font_load; for (fnum = F_ISO8859_1; fnum < FCNT; fnum++) { if (fnum == F_ISO8859_1 || fnum == F_JISX0201_0 || fnum == F_JISX0208_0) { for (i = fontMenu_fontdefault; i <= fontMenu_lastBuiltin; i++) { new->screen.menu_font_names[i] = request->screen.menu_font_names[i]; new->screen.menu_bfont_names[i] = request->screen.menu_bfont_names[i]; } } else { for (i = fontMenu_fontdefault; i <= fontMenu_lastBuiltin; i++) { new->screen.menu_font_names[i] = NULL; new->screen.menu_bfont_names[i] = NULL; } } /* set default in realize proc */ new->screen.menu_font_names[fontMenu_fontescape] = NULL; new->screen.menu_font_names[fontMenu_fontsel] = NULL; new->screen.menu_bfont_names[fontMenu_fontescape] = NULL; new->screen.menu_bfont_names[fontMenu_fontsel] = NULL; } for (i = fontMenu_fontdefault; i <= fontMenu_lastBuiltin; i++) { new->screen.menu_font_list[i] = request->screen.menu_font_list[i]; new->screen.menu_bfont_list[i] = request->screen.menu_bfont_list[i]; } /* set default in realize proc */ new->screen.menu_font_list[fontMenu_fontescape] = NULL; new->screen.menu_font_list[fontMenu_fontsel] = NULL; new->screen.menu_bfont_list[fontMenu_fontescape] = NULL; new->screen.menu_bfont_list[fontMenu_fontsel] = NULL; #else /* !KTERM */ for (i = fontMenu_font1; i <= fontMenu_lastBuiltin; i++) { new->screen.menu_font_names[i] = request->screen.menu_font_names[i]; } /* set default in realize proc */ new->screen.menu_font_names[fontMenu_fontdefault] = NULL; new->screen.menu_font_names[fontMenu_fontescape] = NULL; new->screen.menu_font_names[fontMenu_fontsel] = NULL; #endif /* !KTERM */ new->screen.menu_font_number = fontMenu_fontdefault; #ifdef KTERM new->screen.linespace = request->screen.linespace; #endif /* KTERM */ /* * The definition of -rv now is that it changes the definition of * XtDefaultForeground and XtDefaultBackground. So, we no longer * need to do anything special. */ new->keyboard.flags = 0; new->screen.display = new->core.screen->display; new->core.height = new->core.width = 1; /* dummy values so that we don't try to Realize the parent shell with height or width of 0, which is illegal in X. The real size is computed in the xtermWidget's Realize proc, but the shell's Realize proc is called first, and must see a valid size. */ /* look for focus related events on the shell, because we need * to care about the shell's border being part of our focus. */ XtAddEventHandler(XtParent(new), EnterWindowMask, FALSE, HandleEnterWindow, (Opaque)NULL); XtAddEventHandler(XtParent(new), LeaveWindowMask, FALSE, HandleLeaveWindow, (Opaque)NULL); XtAddEventHandler(XtParent(new), FocusChangeMask, FALSE, HandleFocusChange, (Opaque)NULL); XtAddEventHandler((Widget)new, 0L, TRUE, VTNonMaskableEvent, (Opaque)NULL); XtAddEventHandler((Widget)new, PropertyChangeMask, FALSE, HandleBellPropertyChange, (Opaque)NULL); new->screen.bellInProgress = FALSE; set_character_class (new->screen.charClass); /* create it, but don't realize it */ ScrollBarOn (new, TRUE, FALSE); /* make sure that the resize gravity acceptable */ if ( new->misc.resizeGravity != NorthWestGravity && new->misc.resizeGravity != SouthWestGravity) { extern XtAppContext app_con; Cardinal nparams = 1; XtAppWarningMsg(app_con, "rangeError", "resizeGravity", "XTermError", "unsupported resizeGravity resource value (%d)", (String *) &(new->misc.resizeGravity), &nparams); new->misc.resizeGravity = SouthWestGravity; } return; } static void VTDestroy (w) Widget w; { #ifdef KTERM XtFree((char *)(((XtermWidget)w)->screen.selection)); #else /* !KTERM */ XtFree(((XtermWidget)w)->screen.selection); #endif /* !KTERM */ } /*ARGSUSED*/ static void VTRealize (w, valuemask, values) Widget w; XtValueMask *valuemask; XSetWindowAttributes *values; { unsigned int width, height; register TScreen *screen = &term->screen; int xpos, ypos, pr; XSizeHints sizehints; int scrollbar_width; #ifdef KTERM int fnum; #endif /* KTERM */ TabReset (term->tabs); #ifdef KTERM for (fnum = F_ISO8859_1; fnum < FCNT; fnum ++) { screen->fnt_norm = screen->fnt_bold = NULL; } fnum = F_ISO8859_1; if (!LoadNewFont(screen, False, 0)) { if (screen->menu_font_names[fontMenu_fontdefault] == NULL || XmuCompareISOLatin1(screen->menu_font_names[fontMenu_fontdefault], "fixed") != 0) { fprintf (stderr, "%s: unable to open font \"%s\", trying \"fixed\"....\n", xterm_name, screen->menu_font_names[fontMenu_fontdefault] ? screen->menu_font_names[fontMenu_fontdefault] : ""); screen->menu_font_names[fontMenu_fontdefault] = "fixed"; (void) LoadNewFont (screen, False, 0); } } #else /* !KTERM */ screen->menu_font_names[fontMenu_fontdefault] = term->misc.f_n; screen->fnt_norm = screen->fnt_bold = NULL; if (!LoadNewFont(screen, term->misc.f_n, term->misc.f_b, False, 0)) { if (XmuCompareISOLatin1(term->misc.f_n, "fixed") != 0) { fprintf (stderr, "%s: unable to open font \"%s\", trying \"fixed\"....\n", xterm_name, term->misc.f_n); (void) LoadNewFont (screen, "fixed", NULL, False, 0); screen->menu_font_names[fontMenu_fontdefault] = "fixed"; } } #endif /* !KTERM */ /* really screwed if we couldn't open default font */ if (!screen->fnt_norm) { fprintf (stderr, "%s: unable to locate a suitable font\n", xterm_name); Exit (1); } /* making cursor */ if (!screen->pointer_cursor) screen->pointer_cursor = make_colored_cursor(XC_xterm, screen->mousecolor, screen->mousecolorback); else recolor_cursor (screen->pointer_cursor, screen->mousecolor, screen->mousecolorback); scrollbar_width = (term->misc.scrollbar ? screen->scrollWidget->core.width /* + screen->scrollWidget->core.border_width */ : 0); #ifdef STATUSLINE if (term->misc.statusline) screen->statusheight = -1; #endif /* STATUSLINE */ /* set defaults */ xpos = 1; ypos = 1; width = 80; height = 24; pr = XParseGeometry (term->misc.geo_metry, &xpos, &ypos, &width, &height); screen->max_col = (width - 1); /* units in character cells */ screen->max_row = (height - 1); /* units in character cells */ update_font_info (&term->screen, False); width = screen->fullVwin.fullwidth; height = screen->fullVwin.fullheight; if ((pr & XValue) && (XNegative&pr)) xpos += DisplayWidth(screen->display, DefaultScreen(screen->display)) - width - (term->core.parent->core.border_width * 2); if ((pr & YValue) && (YNegative&pr)) ypos += DisplayHeight(screen->display,DefaultScreen(screen->display)) - height - (term->core.parent->core.border_width * 2); /* set up size hints for window manager; min 1 char by 1 char */ sizehints.base_width = 2 * screen->border + scrollbar_width; sizehints.base_height = 2 * screen->border; sizehints.width_inc = FontWidth(screen); sizehints.height_inc = FontHeight(screen); sizehints.min_width = sizehints.base_width + sizehints.width_inc; sizehints.min_height = sizehints.base_height + sizehints.height_inc; sizehints.flags = (PBaseSize|PMinSize|PResizeInc); sizehints.x = xpos; sizehints.y = ypos; if ((XValue&pr) || (YValue&pr)) { sizehints.flags |= USSize|USPosition; sizehints.flags |= PWinGravity; switch (pr & (XNegative | YNegative)) { case 0: sizehints.win_gravity = NorthWestGravity; break; case XNegative: sizehints.win_gravity = NorthEastGravity; break; case YNegative: sizehints.win_gravity = SouthWestGravity; break; default: sizehints.win_gravity = SouthEastGravity; break; } } else { /* set a default size, but do *not* set position */ sizehints.flags |= PSize; } sizehints.width = width; sizehints.height = height; if ((WidthValue&pr) || (HeightValue&pr)) sizehints.flags |= USSize; else sizehints.flags |= PSize; #ifdef STATUSLINE sizehints.base_height += screen->statusheight; sizehints.min_height += screen->statusheight; #endif /* STATUSLINE */ (void) XtMakeResizeRequest((Widget) term, (Dimension)width, (Dimension)height, &term->core.width, &term->core.height); /* XXX This is bogus. We are parsing geometries too late. This * is information that the shell widget ought to have before we get * realized, so that it can do the right thing. */ if (sizehints.flags & USPosition) XMoveWindow (XtDisplay(term), term->core.parent->core.window, sizehints.x, sizehints.y); XSetWMNormalHints (XtDisplay(term), term->core.parent->core.window, &sizehints); XFlush (XtDisplay(term)); /* get it out to window manager */ /* use ForgetGravity instead of SouthWestGravity because translating the Expose events for ConfigureNotifys is too hard */ values->bit_gravity = term->misc.resizeGravity == NorthWestGravity ? NorthWestGravity : ForgetGravity; term->screen.fullVwin.window = term->core.window = XCreateWindow(XtDisplay(term), XtWindow(term->core.parent), term->core.x, term->core.y, term->core.width, term->core.height, term->core.border_width, (int) term->core.depth, InputOutput, CopyFromParent, *valuemask|CWBitGravity, values); VTInitI18N(); #ifdef KTERM set_cursor_gcs (screen, F_ISO8859_1); #else /* !KTERM */ set_cursor_gcs (screen); #endif /* !KTERM */ /* Reset variables used by ANSI emulation. */ #ifdef KTERM setupgset(); screen->gsets[0] = GSET_ASCII; # ifdef KTERM_KANJIMODE screen->gsets[1] = (term->flags & EUC_KANJI) ? GSET_KANJI : GSET_KANA; screen->gsets[2] = (term->flags & EUC_KANJI) ? GSET_KANA : GSET_ASCII; screen->gsets[3] = (term->flags & EUC_KANJI) ? GSET_HOJOKANJI : GSET_ASCII; # else /* !KTERM_KANJIMODE */ screen->gsets[1] = GSET_KANA; screen->gsets[2] = GSET_ASCII; screen->gsets[3] = GSET_ASCII; # endif /* !KTERM_KANJIMODE */ #else /* !KTERM */ screen->gsets[0] = 'B'; /* ASCII_G */ screen->gsets[1] = 'B'; screen->gsets[2] = 'B'; /* DEC supplemental. */ screen->gsets[3] = 'B'; #endif /* !KTERM */ screen->curgl = 0; /* G0 => GL. */ #ifdef KTERM screen->curgr = 1; /* G1 => GR. */ #else /* !KTERM */ screen->curgr = 2; /* G2 => GR. */ #endif /* !KTERM */ screen->curss = 0; /* No single shift. */ XDefineCursor(screen->display, VShellWindow, screen->pointer_cursor); screen->cur_col = screen->cur_row = 0; #ifdef KTERM screen->max_col = Width(screen)/FontWidth(screen) - 1; screen->top_marg = 0; screen->bot_marg = screen->max_row = Height(screen) / FontHeight(screen) - 1; #else /* !KTERM */ screen->max_col = Width(screen)/screen->fullVwin.f_width - 1; screen->top_marg = 0; screen->bot_marg = screen->max_row = Height(screen) / screen->fullVwin.f_height - 1; #endif /* !KTERM */ screen->sc.row = screen->sc.col = screen->sc.flags = 0; /* Mark screen buffer as unallocated. We wait until the run loop so that the child process does not fork and exec with all the dynamic memory it will never use. If we were to do it here, the swap space for new process would be huge for huge savelines. */ #ifndef KTERM_NOTEK /* XXX */ if (!tekWidget) /* if not called after fork */ #endif /* !KTERM_NOTEK */ screen->buf = screen->allbuf = NULL; screen->do_wrap = 0; screen->scrolls = screen->incopy = 0; set_vt_box (screen); screen->savedlines = 0; #ifdef STATUSLINE screen->reversestatus = !term->misc.statusnormal; update_reversestatus(); #endif /* STATUSLINE */ if (term->misc.scrollbar) { screen->scrollbar = 0; ScrollBarOn (term, FALSE, TRUE); } CursorSave (term, &screen->sc); return; } static void VTInitI18N() { #ifdef KTERM_XIM extern void SetLocale(); extern void SetLocaleModifiers(); extern void OpenIM(); #else /* !KTERM_XIM */ int i; char *p, *s, *ns, *end, tmp[1024], buf[32]; XIM xim = (XIM) NULL; XIMStyles *xim_styles; XIMStyle input_style = 0; Boolean found; #endif /* !KTERM_XIM */ term->screen.xic = NULL; #ifdef KTERM_XIM SetLocale(term->misc.eucjp_locale); if (term->misc.input_method) SetLocaleModifiers(&term->misc.input_method, 1); else SetLocaleModifiers(NULL, 0); #endif /* KTERM_XIM */ if (!term->misc.open_im) return; #ifdef KTERM_XIM OpenIM(&term->screen); #else /* !KTERM_XIM */ if (!term->misc.input_method || !*term->misc.input_method) { if ((p = XSetLocaleModifiers("@im=none")) != NULL && *p) xim = XOpenIM(XtDisplay(term), NULL, NULL, NULL); } else { strcpy(tmp, term->misc.input_method); for(ns=s=tmp; ns && *s;) { while (*s && isspace(*s)) s++; if (!*s) break; if ((ns = end = index(s, ',')) == 0) end = s + strlen(s); while (isspace(*end)) end--; *end = '\0'; strcpy(buf, "@im="); strcat(buf, s); if ((p = XSetLocaleModifiers(buf)) != NULL && *p && (xim = XOpenIM(XtDisplay(term), NULL, NULL, NULL)) != NULL) break; s = ns + 1; } } if (xim == NULL && (p = XSetLocaleModifiers("")) != NULL && *p) xim = XOpenIM(XtDisplay(term), NULL, NULL, NULL); if (!xim) { fprintf(stderr, "Failed to open input method"); return; } #ifdef KTERM_DEBUG printf("modifiers=%s\n",XSetLocaleModifiers(NULL)); #endif if (XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL) || !xim_styles) { fprintf(stderr, "input method doesn't support any style\n"); XCloseIM(xim); return; } found = False; strcpy(tmp, term->misc.preedit_type); for(s = tmp; s && !found;) { while (*s && isspace(*s)) s++; if (!*s) break; if (ns = end = index(s, ',')) ns++; else end = s + strlen(s); while (isspace(*end)) end--; *end = '\0'; if (!strcmp(s, "OverTheSpot")) { input_style = (XIMPreeditPosition | XIMStatusArea); } else if (!strcmp(s, "OffTheSpot")) { input_style = (XIMPreeditArea | XIMStatusArea); } else if (!strcmp(s, "Root")) { input_style = (XIMPreeditNothing | XIMStatusNothing); } for (i = 0; (unsigned short)i < xim_styles->count_styles; i++) if (input_style == xim_styles->supported_styles[i]) { found = True; break; } s = ns; } XFree(xim_styles); if (!found) { fprintf(stderr, "input method doesn't support my preedit type\n"); XCloseIM(xim); return; } /* * This program only understands the Root preedit_style yet * Then misc.preedit_type should default to: * "OverTheSpot,OffTheSpot,Root" * * /MaF */ if (input_style != (XIMPreeditNothing | XIMStatusNothing)) { fprintf(stderr,"This program only supports the 'Root' preedit type\n"); XCloseIM(xim); return; } term->screen.xic = XCreateIC(xim, XNInputStyle, input_style, XNClientWindow, term->core.window, XNFocusWindow, term->core.window, NULL); if (!term->screen.xic) { fprintf(stderr,"Failed to create input context\n"); XCloseIM(xim); } #endif /* !KTERM_XIM */ return; } static Boolean VTSetValues (cur, request, new, args, num_args) Widget cur, request, new; ArgList args; Cardinal *num_args; { XtermWidget curvt = (XtermWidget) cur; XtermWidget newvt = (XtermWidget) new; Boolean refresh_needed = FALSE; Boolean fonts_redone = FALSE; #ifdef KTERM int fnum = F_ISO8859_1; #endif /* KTERM */ #ifdef KTERM if(curvt->core.background_pixel != newvt->core.background_pixel || curvt->screen.foreground != newvt->screen.foreground || curvt->screen.menu_font_names[curvt->screen.menu_font_number] != newvt->screen.menu_font_names[newvt->screen.menu_font_number] || curvt->screen.menu_font_names[fontMenu_fontdefault] != newvt->screen.menu_font_names[fontMenu_fontdefault]) { if(curvt->screen.menu_font_names[fontMenu_fontdefault] != newvt->screen.menu_font_names[fontMenu_fontdefault]) newvt->screen.menu_font_names[fontMenu_fontdefault] = newvt->screen.menu_font_names[fontMenu_fontdefault]; fprintf(stderr, "kterm(VTSetValues): Font changing to %s\n", newvt->screen.menu_font_names[curvt->screen.menu_font_number]); if (LoadNewFont(&newvt->screen, TRUE, newvt->screen.menu_font_number)) { #else /* !KTERM */ if(curvt->core.background_pixel != newvt->core.background_pixel || curvt->screen.foreground != newvt->screen.foreground || curvt->screen.menu_font_names[curvt->screen.menu_font_number] != newvt->screen.menu_font_names[newvt->screen.menu_font_number] || curvt->misc.f_n != newvt->misc.f_n) { if(curvt->misc.f_n != newvt->misc.f_n) newvt->screen.menu_font_names[fontMenu_fontdefault] = newvt->misc.f_n; if (LoadNewFont(&newvt->screen, newvt->screen.menu_font_names[curvt->screen.menu_font_number], newvt->screen.menu_font_names[curvt->screen.menu_font_number], TRUE, newvt->screen.menu_font_number)) { #endif /* !KTERM */ /* resizing does the redisplay, so don't ask for it here */ refresh_needed = TRUE; fonts_redone = TRUE; } else #ifdef KTERM if(curvt->screen.menu_font_names[fontMenu_fontdefault] != newvt->screen.menu_font_names[fontMenu_fontdefault]) newvt->screen.menu_font_names[fontMenu_fontdefault] = curvt->screen.menu_font_names[fontMenu_fontdefault]; #else /* !KTERM */ if(curvt->misc.f_n != newvt->misc.f_n) newvt->screen.menu_font_names[fontMenu_fontdefault] = curvt->misc.f_n; #endif /* !KTERM */ } if(!fonts_redone && curvt->screen.cursorcolor != newvt->screen.cursorcolor) { #ifdef KTERM for (fnum = F_ISO8859_1; fnum < FCNT; fnum++) set_cursor_gcs(&newvt->screen, fnum); #else /* !KTERM */ set_cursor_gcs(&newvt->screen); #endif /* !KTERM */ refresh_needed = TRUE; } if(curvt->misc.re_verse != newvt->misc.re_verse) { newvt->flags ^= REVERSE_VIDEO; ReverseVideo(newvt); newvt->misc.re_verse = !newvt->misc.re_verse; /* ReverseVideo toggles */ refresh_needed = TRUE; } if(curvt->screen.mousecolor != newvt->screen.mousecolor || curvt->screen.mousecolorback != newvt->screen.mousecolorback) { recolor_cursor (newvt->screen.pointer_cursor, newvt->screen.mousecolor, newvt->screen.mousecolorback); refresh_needed = TRUE; } if (curvt->misc.scrollbar != newvt->misc.scrollbar) { if (newvt->misc.scrollbar) { ScrollBarOn (newvt, FALSE, FALSE); } else { ScrollBarOff (&newvt->screen); } update_scrollbar(); } #ifdef STATUSLINE if (curvt->misc.statusnormal != newvt->misc.statusnormal) { newvt->screen.reversestatus = !term->misc.statusnormal; if (newvt->screen.statusheight) ScrnRefresh(newvt->screen, newvt->screen.max_row + 1, 0, 1, newvt->screen.max_col + 1, False); update_reversestatus(); } if (curvt->misc.statusline != newvt->misc.statusline) { if (newvt->misc.statusline) { ShowStatus(&newvt->screen); } else { HideStatus(&newvt->screen); } update_statusline(); } #endif /* STATUSLINE */ return refresh_needed; } /* * Shows cursor at new cursor position in screen. */ ShowCursor() { register TScreen *screen = &term->screen; register int x, y, flags; #ifdef KTERM Char gset; #else /* !KTERM */ Char c; GC currentGC; #endif /* !KTERM */ Boolean in_selection; if (eventMode != NORMAL) return; #ifdef STATUSLINE if (screen->cur_row - screen->topline > screen->max_row && !screen->instatus) #else /* !STATUSLINE */ if (screen->cur_row - screen->topline > screen->max_row) #endif /* !STATUSLINE */ return; #ifdef KTERM gset = screen->buf[y = screen->cursor_row = screen->cur_row] [x = screen->cursor_col = screen->cur_col].gset; if (gset == MBC2) { gset = screen->buf[y][x-1].gset; x--; } flags = screen->buf[y][x].attr; #else /* !KTERM */ c = screen->buf[y = 2 * (screen->cursor_row = screen->cur_row)] [x = screen->cursor_col = screen->cur_col]; flags = screen->buf[y + 1][x]; if (c == 0) c = ' '; # ifdef STATUSLINE if (screen->instatus && screen->reversestatus) flags ^= INVERSE; # endif /* STATUSLINE */ #endif /* !KTERM */ if (screen->cur_row > screen->endHRow || (screen->cur_row == screen->endHRow && screen->cur_col >= screen->endHCol) || screen->cur_row < screen->startHRow || (screen->cur_row == screen->startHRow && screen->cur_col < screen->startHCol)) in_selection = False; else in_selection = True; #ifdef KTERM if ((screen->select || screen->always_highlight) ^ in_selection) flags ^= INVERSE; ScreenDraw(screen, y, x, x+(gset&MBCS?2:1), flags, True); #else /* !KTERM */ if(screen->select || screen->always_highlight) { if (( (flags & INVERSE) && !in_selection) || (!(flags & INVERSE) && in_selection)){ /* text is reverse video */ if (screen->cursorGC) { currentGC = screen->cursorGC; } else { if (flags & BOLD) { currentGC = screen->normalboldGC; } else { currentGC = screen->normalGC; } } } else { /* normal video */ if (screen->reversecursorGC) { currentGC = screen->reversecursorGC; } else { if (flags & BOLD) { currentGC = screen->reverseboldGC; } else { currentGC = screen->reverseGC; } } } } else { /* not selected */ if (( (flags & INVERSE) && !in_selection) || (!(flags & INVERSE) && in_selection)) { /* text is reverse video */ currentGC = screen->reverseGC; } else { /* normal video */ currentGC = screen->normalGC; } } x = CursorX (screen, screen->cur_col); y = CursorY(screen, screen->cur_row) + screen->fnt_norm->ascent; XDrawImageString(screen->display, TextWindow(screen), currentGC, x, y, (char *) &c, 1); if((flags & BOLD) && screen->enbolden) /* no bold font */ XDrawString(screen->display, TextWindow(screen), currentGC, x + 1, y, (char *) &c, 1); if(flags & UNDERLINE) XDrawLine(screen->display, TextWindow(screen), currentGC, x, y+1, x + FontWidth(screen), y+1); if (!screen->select && !screen->always_highlight) { screen->box->x = x; screen->box->y = y - screen->fnt_norm->ascent; XDrawLines (screen->display, TextWindow(screen), screen->cursoroutlineGC ? screen->cursoroutlineGC : currentGC, screen->box, NBOX, CoordModePrevious); } #endif /* !KTERM */ screen->cursor_state = ON; #ifdef KTERM_XIM IMSendSpot(screen); #endif /* KTERM_XIM */ #ifdef KTERM_KINPUT2 Kinput2SendSpot(); #endif /* KTERM_KINPUT2 */ } /* * hide cursor at previous cursor position in screen. */ HideCursor() { register TScreen *screen = &term->screen; #ifndef KTERM GC currentGC; #endif /* !KTERM */ register int x, y, flags; #ifdef KTERM Char gset; #else /* !KTERM */ char c; #endif /* !KTERM */ Boolean in_selection; #ifdef STATUSLINE Boolean in_status = (screen->cursor_row > screen->max_row); if(screen->cursor_row - screen->topline > screen->max_row && !in_status) #else /* !STATUSLINE */ if(screen->cursor_row - screen->topline > screen->max_row) #endif /* !STATUSLINE */ return; #ifdef KTERM gset = screen->buf[y = screen->cursor_row][x = screen->cursor_col].gset; if (gset == MBC2) { gset = screen->buf[y][x-1].gset; x--; } flags = screen->buf[y][x].attr; #else /* !KTERM */ c = screen->buf[y = 2 * screen->cursor_row][x = screen->cursor_col]; flags = screen->buf[y + 1][x]; # ifdef STATUSLINE if (in_status && screen->reversestatus) flags ^= INVERSE; # endif /* STATUSLINE */ #endif /* !KTERM */ if (screen->cursor_row > screen->endHRow || (screen->cursor_row == screen->endHRow && screen->cursor_col >= screen->endHCol) || screen->cursor_row < screen->startHRow || (screen->cursor_row == screen->startHRow && screen->cursor_col < screen->startHCol)) in_selection = False; else in_selection = True; #ifdef KTERM if (in_selection) flags ^= INVERSE; ScreenDraw(screen, y, x, x+(gset&MBCS?2:1), flags, False); #else /* !KTERM */ if (( (flags & INVERSE) && !in_selection) || (!(flags & INVERSE) && in_selection)) { if(flags & BOLD) { currentGC = screen->reverseboldGC; } else { currentGC = screen->reverseGC; } } else { if(flags & BOLD) { currentGC = screen->normalboldGC; } else { currentGC = screen->normalGC; } } if (c == 0) c = ' '; x = CursorX (screen, screen->cursor_col); # ifdef STATUSLINE y = CursorY (screen, screen->cursor_row); # else /* !STATUSLINE */ y = (((screen->cursor_row - screen->topline) * FontHeight(screen))) + screen->border; # endif /* !STATUSLINE */ y = y+screen->fnt_norm->ascent; XDrawImageString(screen->display, TextWindow(screen), currentGC, x, y, &c, 1); if((flags & BOLD) && screen->enbolden) XDrawString(screen->display, TextWindow(screen), currentGC, x + 1, y, &c, 1); if(flags & UNDERLINE) XDrawLine(screen->display, TextWindow(screen), currentGC, x, y+1, x + FontWidth(screen), y+1); #endif /* !KTERM */ screen->cursor_state = OFF; } VTReset(full) Boolean full; { register TScreen *screen = &term->screen; /* reset scrolling region */ screen->top_marg = 0; screen->bot_marg = screen->max_row; term->flags &= ~ORIGIN; if(full) { TabReset (term->tabs); term->keyboard.flags = 0; update_appcursor(); update_appkeypad(); #ifdef KTERM screen->gsets[0] = GSET_ASCII; # ifdef KTERM_KANJIMODE screen->gsets[1] = (term->flags & EUC_KANJI) ? GSET_KANJI : GSET_KANA; screen->gsets[2] = (term->flags & EUC_KANJI) ? GSET_KANA : GSET_ASCII; screen->gsets[3] = (term->flags & EUC_KANJI) ? GSET_HOJOKANJI : GSET_ASCII; # else /* !KTERM_KANJIMODE */ screen->gsets[1] = GSET_KANA; screen->gsets[2] = GSET_ASCII; screen->gsets[3] = GSET_ASCII; # endif /* !KTERM_KANJIMODE */ screen->curgl = 0; screen->curgr = 1; #else /* !KTERM */ screen->gsets[0] = 'B'; screen->gsets[1] = 'B'; screen->gsets[2] = 'B'; screen->gsets[3] = 'B'; screen->curgl = 0; screen->curgr = 2; #endif /* !KTERM */ screen->curss = 0; FromAlternate(screen); ClearScreen(screen); #ifdef STATUSLINE EraseStatus(); #endif /* STATUSLINE */ screen->cursor_state = OFF; if (term->flags & REVERSE_VIDEO) ReverseVideo(term); term->flags = term->initflags; update_reversevideo(); update_autowrap(); update_reversewrap(); update_autolinefeed(); screen->jumpscroll = !(term->flags & SMOOTHSCROLL); update_jumpscroll(); if(screen->c132 && (term->flags & IN132COLUMNS)) { Dimension junk; XtMakeResizeRequest( (Widget) term, (Dimension) 80*FontWidth(screen) + 2 * screen->border + screen->scrollbar, #ifdef STATUSLINE (Dimension) screen->statusheight + #endif /* STATUSLINE */ (Dimension) FontHeight(screen) * (screen->max_row + 1) + 2 * screen->border, &junk, &junk); XSync(screen->display, FALSE); /* synchronize */ #ifdef KTERM_XAW3D if(XtAppPending(app_con)) #else /* !KTERM_XAW3D */ if(QLength(screen->display) > 0) #endif /* !KTERM_XAW3D */ xevents(); } CursorSet(screen, 0, 0, term->flags); } longjmp(vtjmpbuf, 1); /* force ground state in parser */ } #ifdef STATUSLINE ToStatus(col) int col; { register TScreen *screen = &term->screen; if (screen->cursor_state) HideCursor(); if (col > screen->max_col) col = screen->max_col; if (!screen->instatus) { if (!screen->statusheight) ShowStatus(); CursorSave(term, &screen->statussc); screen->instatus = TRUE; screen->cur_row = screen->max_row + 1; } screen->cur_col = col; } FromStatus() { register TScreen *screen = &term->screen; if (!screen->instatus) return; screen->instatus = FALSE; CursorRestore(term, &screen->statussc); } ShowStatus() { register TScreen *screen = &term->screen; if (screen->statusheight) return; screen->statusheight = FontHeight(screen) + 2; DoResizeScreen(term); if (screen->scrollWidget) ResizeScrollBar(screen->scrollWidget, -1, -1, Height(screen) + screen->border * 2 + screen->statusheight); } HideStatus() { register TScreen *screen = &term->screen; # ifndef KTERM register int i, j; # endif /* !KTERM */ if (!screen->statusheight) return; if (screen->instatus) FromStatus(); screen->statusheight = 0; # ifdef KTERM bzero(screen->buf[screen->max_row + 1], sizeof(Bchr) * (screen->max_col+1)); # else /* !KTERM */ bzero(screen->buf[i = 2 * (screen->max_row + 1)], j = screen->max_col + 1); bzero(screen->buf[i + 1], j); # endif /* !KTERM */ DoResizeScreen(term); if (screen->scrollWidget) ResizeScrollBar(screen->scrollWidget, -1, -1, Height(screen) + screen->border * 2); } EraseStatus() { register TScreen *screen = &term->screen; register int j, pix; # ifdef KTERM int fnum = F_ISO8859_1; /* *GC */ # else /* !KTERM */ register int i; # endif /* !KTERM */ if (!screen->statusheight) return; # ifdef KTERM bzero(screen->buf[screen->max_row + 1], j = sizeof(Bchr) * (screen->max_col+1)); # else /* !KTERM */ bzero(screen->buf[i = 2 * (screen->max_row + 1)], j = screen->max_col + 1); bzero(screen->buf[i + 1], j) ; # endif /* !KTERM */ XFillRectangle(screen->display, TextWindow(screen), screen->reversestatus ? screen->normalGC : screen->reverseGC, screen->border - 1 + screen->scrollbar, Height(screen) + screen->border * 2 + 1, Width(screen), screen->statusheight - 2); } StatusBox(screen) register TScreen *screen; { # ifdef KTERM int fnum = F_ISO8859_1; /* *GC */ # endif /* KTERM */ XDrawRectangle(screen->display, TextWindow(screen), screen->normalGC, screen->scrollbar, Height(screen) + screen->border * 2, Width(screen) + screen->border * 2 - 1, screen->statusheight - 1); } #endif /* STATUSLINE */ /* * set_character_class - takes a string of the form * * low[-high]:val[,low[-high]:val[...]] * * and sets the indicated ranges to the indicated values. */ int set_character_class (s) register char *s; { register int i; /* iterator, index into s */ int len; /* length of s */ int acc; /* accumulator */ int low, high; /* bounds of range [0..127] */ int base; /* 8, 10, 16 (octal, decimal, hex) */ int numbers; /* count of numbers per range */ int digits; /* count of digits in a number */ static char *errfmt = "%s: %s in range string \"%s\" (position %d)\n"; extern char *ProgramName; if (!s || !s[0]) return -1; base = 10; /* in case we ever add octal, hex */ low = high = -1; /* out of range */ for (i = 0, len = strlen (s), acc = 0, numbers = digits = 0; i < len; i++) { char c = s[i]; if (isspace(c)) { continue; } else if (isdigit(c)) { acc = acc * base + (c - '0'); digits++; continue; } else if (c == '-') { low = acc; acc = 0; if (digits == 0) { fprintf (stderr, errfmt, ProgramName, "missing number", s, i); return (-1); } digits = 0; numbers++; continue; } else if (c == ':') { if (numbers == 0) low = acc; else if (numbers == 1) high = acc; else { fprintf (stderr, errfmt, ProgramName, "too many numbers", s, i); return (-1); } digits = 0; numbers++; acc = 0; continue; } else if (c == ',') { /* * now, process it */ if (high < 0) { high = low; numbers++; } if (numbers != 2) { fprintf (stderr, errfmt, ProgramName, "bad value number", s, i); } else if (SetCharacterClassRange (low, high, acc) != 0) { fprintf (stderr, errfmt, ProgramName, "bad range", s, i); } low = high = -1; acc = 0; digits = 0; numbers = 0; continue; } else { fprintf (stderr, errfmt, ProgramName, "bad character", s, i); return (-1); } /* end if else if ... else */ } if (low < 0 && high < 0) return (0); /* * now, process it */ if (high < 0) high = low; if (numbers < 1 || numbers > 2) { fprintf (stderr, errfmt, ProgramName, "bad value number", s, i); } else if (SetCharacterClassRange (low, high, acc) != 0) { fprintf (stderr, errfmt, ProgramName, "bad range", s, i); } return (0); } /* ARGSUSED */ static void HandleKeymapChange(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { static XtTranslations keymap, original; static XtResource key_resources[] = { { XtNtranslations, XtCTranslations, XtRTranslationTable, sizeof(XtTranslations), 0, XtRTranslationTable, (XtPointer)NULL} }; char mapName[1000]; char mapClass[1000]; if (*param_count != 1) return; if (original == NULL) original = w->core.tm.translations; if (strcmp(params[0], "None") == 0) { XtOverrideTranslations(w, original); return; } (void) sprintf( mapName, "%sKeymap", params[0] ); (void) strcpy( mapClass, mapName ); if (islower(mapClass[0])) mapClass[0] = toupper(mapClass[0]); XtGetSubresources( w, (XtPointer)&keymap, mapName, mapClass, key_resources, (Cardinal)1, NULL, (Cardinal)0 ); if (keymap != NULL) XtOverrideTranslations(w, keymap); } /* ARGSUSED */ static void HandleBell(w, event, params, param_count) Widget w; XEvent *event; /* unused */ String *params; /* [0] = volume */ Cardinal *param_count; /* 0 or 1 */ { int percent = (*param_count) ? atoi(params[0]) : 0; #ifdef XKB int which= XkbBI_TerminalBell; XkbStdBell(XtDisplay(w),XtWindow(w),percent,which); #else XBell( XtDisplay(w), percent ); #endif } /* ARGSUSED */ static void HandleVisualBell(w, event, params, param_count) Widget w; XEvent *event; /* unused */ String *params; /* unused */ Cardinal *param_count; /* unused */ { VisualBell(); } /* ARGSUSED */ static void HandleIgnore(w, event, params, param_count) Widget w; XEvent *event; /* unused */ String *params; /* unused */ Cardinal *param_count; /* unused */ { /* do nothing, but check for funny escape sequences */ (void) SendMousePosition(w, event); } /* ARGSUSED */ static void DoSetSelectedFont(w, client_data, selection, type, value, length, format) Widget w; XtPointer client_data; Atom *selection, *type; XtPointer value; unsigned long *length; int *format; { char *val = (char *)value; int len; if (*type != XA_STRING || *format != 8) { Bell(XkbBI_MinorError,0); return; } len = strlen(val); if (len > 0) { if (val[len-1] == '\n') val[len-1] = '\0'; /* Do some sanity checking to avoid sending a long selection back to the server in an OpenFont that is unlikely to succeed. XLFD allows up to 255 characters and no control characters; we are a little more liberal here. */ if (len > 1000 || strchr(val, '\n')) return; #ifdef KTERM /* if (term->screen.menu_font_list[fontMenu_fontsel]) XtFree(term->screen.menu_font_list[fontMenu_fontsel]); term->screen.menu_font_list[fontMenu_fontsel] = XtMalloc(len + 1); strcpy(term->screen.menu_font_list[fontMenu_fontsel], val); */ term->screen.menu_font_list[fontMenu_fontsel] = val; /* XXX */ if (!LoadNewFont (&term->screen, True, fontMenu_fontsel)) #else /* !KTERM */ if (!LoadNewFont (&term->screen, val, NULL, True, fontMenu_fontsel)) #endif /* !KTERM */ Bell(XkbBI_MinorError,0); } } void FindFontSelection (atom_name, justprobe) char *atom_name; Bool justprobe; { static AtomPtr *atoms; static int atomCount = 0; AtomPtr *pAtom; int a; Atom target; if (!atom_name) atom_name = "PRIMARY"; for (pAtom = atoms, a = atomCount; a; a--, pAtom++) { if (strcmp(atom_name, XmuNameOfAtom(*pAtom)) == 0) break; } if (!a) { atoms = (AtomPtr*) XtRealloc ((char *)atoms, sizeof(AtomPtr)*(atomCount+1)); *(pAtom = &atoms[atomCount++]) = XmuMakeAtom(atom_name); } target = XmuInternAtom(XtDisplay(term), *pAtom); if (justprobe) { #ifdef KTERM term->screen.menu_font_list[fontMenu_fontsel] = #else /* !KTERM */ term->screen.menu_font_names[fontMenu_fontsel] = #endif /* KTERM */ XGetSelectionOwner(XtDisplay(term), target) ? _Font_Selected_ : NULL; } else { XtGetSelectionValue((Widget)term, target, XA_STRING, DoSetSelectedFont, NULL, XtLastTimestampProcessed(XtDisplay(term))); } return; } /* ARGSUSED */ void HandleSetFont(w, event, params, param_count) Widget w; XEvent *event; /* unused */ String *params; /* unused */ Cardinal *param_count; /* unused */ { int fontnum; char *name1 = NULL, *name2 = NULL; if (*param_count == 0) { fontnum = fontMenu_fontdefault; } else { int maxparams = 1; /* total number of params allowed */ switch (params[0][0]) { case 'd': case 'D': case '0': fontnum = fontMenu_fontdefault; break; case '1': fontnum = fontMenu_font1; break; case '2': fontnum = fontMenu_font2; break; case '3': fontnum = fontMenu_font3; break; case '4': fontnum = fontMenu_font4; break; case '5': fontnum = fontMenu_font5; break; case '6': fontnum = fontMenu_font6; break; case 'e': case 'E': fontnum = fontMenu_fontescape; maxparams = 3; break; case 's': case 'S': fontnum = fontMenu_fontsel; maxparams = 2; break; default: Bell(XkbBI_MinorError,0); return; } if (*param_count > maxparams) { /* see if extra args given */ Bell(XkbBI_MinorError,0); return; } switch (*param_count) { /* assign 'em */ case 3: name2 = params[2]; /* fall through */ case 2: name1 = params[1]; break; } } SetVTFont (fontnum, True, name1, name2); } void SetVTFont (i, doresize, name1, name2) int i; Bool doresize; char *name1, *name2; { TScreen *screen = &term->screen; if (i < 0 || i >= NMENUFONTS) { Bell(XkbBI_MinorError,0); return; } if (i == fontMenu_fontsel) { /* go get the selection */ FindFontSelection (name1, False); /* name1 = atom, name2 is ignored */ return; } #ifdef KTERM if (i == fontMenu_fontescape) { if (name1) { if (screen->menu_font_list[i]) XtFree(screen->menu_font_list[i]); screen->menu_font_list[i] = XtMalloc(strlen(name1) + 1); strcpy(screen->menu_font_list[i], name1); } if (name2) { if (screen->menu_bfont_list[i]) XtFree(screen->menu_bfont_list[i]); screen->menu_bfont_list[i] = XtMalloc(strlen(name2) + 1); strcpy(screen->menu_bfont_list[i], name2); } } if (!LoadNewFont(screen, doresize, i)) { Bell(XkbBI_MinorError,0); } #else /* !KTERM */ if (!name1) name1 = screen->menu_font_names[i]; if (!LoadNewFont(screen, name1, name2, doresize, i)) { Bell(XkbBI_MinorError,0); } #endif /* !KTERM */ return; } #ifdef KTERM static char ** ListFonts(display, pattern, maxnames, actual_count_return) Display *display; char *pattern; int maxnames; int *actual_count_return; { static struct fontlist_t { char *pattern; char **list; int count; } *fontlists; static int fontlistscnt; static int fontlistslen; int i, count; for (i = 0; i < fontlistscnt; i++) { if (!XmuCompareISOLatin1(fontlists[i].pattern, pattern)) { if (actual_count_return) *actual_count_return = fontlists[i].count; return fontlists[i].list; } } if (fontlistscnt == fontlistslen) { fontlistslen += 10; if (fontlists) { fontlists = (struct fontlist_t *)XtRealloc((char *)fontlists, fontlistslen * sizeof(struct fontlist_t)); } else { fontlists = (struct fontlist_t *)XtMalloc(fontlistslen * sizeof(struct fontlist_t)); } } fontlistscnt++; fontlists[i].pattern = XtMalloc(strlen(pattern) + 1); strcpy(fontlists[i].pattern, pattern); fontlists[i].list = XListFonts(display, pattern, maxnames, &count); fontlists[i].count = count; if (actual_count_return) *actual_count_return = fontlists[i].count; return fontlists[i].list; } static char * search_font_matching(screen, xlfdlist, fnum) TScreen *screen; char *xlfdlist; int fnum; { extern char **ParseList(); extern char **csnames(); char **list; char **parsed_xlfdlist, **xlfd_p; char **tail_p; char *tmptail; int count, i; int taillen; if (!xlfdlist) return NULL; parsed_xlfdlist = ParseList(xlfdlist); for (tail_p = csnames(fnum); *tail_p; tail_p++) { taillen = strlen(*tail_p); for (xlfd_p = parsed_xlfdlist; *xlfd_p; xlfd_p++) { list = ListFonts(screen->display, *xlfd_p, 1000, &count); if (!list) continue; for (i = 0; i < count; i ++) { tmptail = list[i]+strlen(list[i])-taillen; if (tmptail[-1] == '-' && !XmuCompareISOLatin1(tmptail, *tail_p)) { return list[i]; } } } } return NULL; } int LoadOneFont(screen, doresize, fontnum, fnum, bold) TScreen *screen; int doresize; /* -1: recursive call */ int fontnum; int fnum; Boolean bold; { XFontStruct *fs = NULL; XFontStruct *normalfs = screen->fnt_norm; XFontStruct *asciinfs = screen->_fnt_norm[F_ISO8859_1]; XGCValues xgcv; unsigned long mask; GC new_normalGC = NULL; GC new_reverseGC = NULL; char *fontname; char *fn = (bold?screen->menu_bfont_names:screen->menu_font_names)[fontnum]; char *fl = (bold?screen->menu_bfont_list:screen->menu_font_list)[fontnum]; int f; if (fontname = fn) fs = XLoadQueryFont (screen->display, fontname); if (!fs && (fontname = search_font_matching(screen, fl, fnum))) fs = XLoadQueryFont (screen->display, fontname); if (!fs) { if (bold) { if (!normalfs) { LoadOneFont(screen, -1, fontnum, fnum, False); normalfs = screen->fnt_norm; } fs = normalfs; } else if (fnum != F_ISO8859_1) { fs = asciinfs; } } if (!fs) goto bad; if (bold && fs == normalfs) { new_normalGC = screen->normalGC; new_reverseGC = screen->reverseGC; } else { if (fs->ascent + fs->descent == 0 || fs->max_bounds.width == 0) goto bad; /* can't use a 0-sized font */ mask = (GCFont | GCForeground | GCBackground | GCGraphicsExposures | GCFunction); xgcv.font = fs->fid; xgcv.foreground = screen->foreground; xgcv.background = term->core.background_pixel; xgcv.graphics_exposures = FALSE; xgcv.function = GXcopy; new_normalGC = XtGetGC((Widget)term, mask, &xgcv); if (!new_normalGC) goto bad; xgcv.foreground = term->core.background_pixel; xgcv.background = screen->foreground; new_reverseGC = XtGetGC((Widget)term, mask, &xgcv); if (!new_reverseGC) goto bad; } if (bold) { screen->normalboldGC = new_normalGC; screen->reverseboldGC = new_reverseGC; screen->fnt_bold = fs; } else { screen->normalGC = new_normalGC; screen->reverseGC = new_reverseGC; screen->fnt_norm = fs; } if (!bold) { set_cursor_gcs (screen, fnum); } if (doresize != -1) update_font_info (screen, doresize); return 1; bad: if (new_normalGC) XtReleaseGC ((Widget) term, new_normalGC); if (new_reverseGC) XtReleaseGC ((Widget) term, new_reverseGC); if (fs && (fnum == F_ISO8859_1 || fs != asciinfs)) XFreeFont (screen->display, fs); return 0; } int LoadNewFont(screen, doresize, fontnum) TScreen *screen; Boolean doresize; int fontnum; { int fnum, f, succ = 0; GC nGC[FCNT], rGC[FCNT], nbGC[FCNT], rbGC[FCNT]; XFontStruct *fn[FCNT], *fb[FCNT], *fs; int enb[FCNT]; for (fnum = F_ISO8859_1; fnum < FCNT; fnum++) { nGC[fnum] = screen->_normalGC[fnum]; screen->_normalGC[fnum] = NULL; rGC[fnum] = screen->_reverseGC[fnum]; screen->_reverseGC[fnum] = NULL; fn[fnum] = screen->_fnt_norm[fnum]; screen->_fnt_norm[fnum] = NULL; nbGC[fnum] = screen->_normalboldGC[fnum]; screen->_normalboldGC[fnum] = NULL; rbGC[fnum] = screen->_reverseboldGC[fnum]; screen->_reverseboldGC[fnum] = NULL; fb[fnum] = screen->_fnt_bold[fnum]; screen->_fnt_bold[fnum] = NULL; } for (fnum = F_ISO8859_1; fnum < FCNT; fnum++) { if (!screen->dynamic_font_load || fn[fnum] || fnum == F_ISO8859_1) { succ += LoadOneFont(screen, -1, fontnum, fnum, False); } if (!screen->dynamic_font_load || fb[fnum]) { succ += LoadOneFont(screen, -1, fontnum, fnum, True); } } if (!succ) goto bad; for (fnum = F_ISO8859_1; fnum < FCNT; fnum++) { if (fs = fn[fnum]) { XtReleaseGC((Widget)term, nGC[fnum]); XtReleaseGC((Widget)term, rGC[fnum]); XFreeFontInfo(NULL, fn[fnum], 1); for (f = F_ISO8859_1; f < FCNT; f++) { if (fn[f] == fs) fn[f] = NULL; if (fb[f] == fs) fb[f] = NULL; } } if (fs = fb[fnum]) { XtReleaseGC((Widget)term, nbGC[fnum]); XtReleaseGC((Widget)term, rbGC[fnum]); XFreeFontInfo(NULL, fb[fnum], 1); for (f = F_ISO8859_1; f < FCNT; f++) { if (fn[f] == fs) fn[f] = NULL; if (fb[f] == fs) fb[f] = NULL; } } } set_menu_font (False); screen->menu_font_number = fontnum; set_menu_font (True); if (fontnum == fontMenu_fontescape) { set_sensitivity (term->screen.fontMenu, fontMenuEntries[fontMenu_fontescape].widget, TRUE); } #ifdef KTERM_XIM IMSendFonts(screen); #endif /* KTERM_XIM */ #ifdef KTERM_KINPUT2 Kinput2SendFonts(); #endif /* KTERM_KINPUT2 */ update_font_info (screen, doresize); return 1; bad: for (fnum = F_ISO8859_1; fnum < FCNT; fnum++) { screen->_normalGC[fnum] = nGC[fnum]; screen->_reverseGC[fnum] = rGC[fnum]; screen->_fnt_norm[fnum] = fn[fnum]; screen->_normalboldGC[fnum] = nbGC[fnum]; screen->_reverseboldGC[fnum] = rbGC[fnum]; screen->_fnt_bold[fnum] = fb[fnum]; } return 0; } #else /* !KTERM */ int LoadNewFont (screen, nfontname, bfontname, doresize, fontnum) TScreen *screen; char *nfontname, *bfontname; Bool doresize; int fontnum; { XFontStruct *nfs = NULL, *bfs = NULL; XGCValues xgcv; unsigned long mask; GC new_normalGC = NULL, new_normalboldGC = NULL; GC new_reverseGC = NULL, new_reverseboldGC = NULL; char *tmpname = NULL; if (!nfontname) return 0; if (fontnum == fontMenu_fontescape && nfontname != screen->menu_font_names[fontnum]) { tmpname = (char *) malloc (strlen(nfontname) + 1); if (!tmpname) return 0; strcpy (tmpname, nfontname); } if (!(nfs = XLoadQueryFont (screen->display, nfontname))) goto bad; if (nfs->ascent + nfs->descent == 0 || nfs->max_bounds.width == 0) goto bad; /* can't use a 0-sized font */ if (!(bfontname && (bfs = XLoadQueryFont (screen->display, bfontname)))) bfs = nfs; else if (bfs->ascent + bfs->descent == 0 || bfs->max_bounds.width == 0) goto bad; /* can't use a 0-sized font */ mask = (GCFont | GCForeground | GCBackground | GCGraphicsExposures | GCFunction); xgcv.font = nfs->fid; xgcv.foreground = screen->foreground; xgcv.background = term->core.background_pixel; xgcv.graphics_exposures = TRUE; /* default */ xgcv.function = GXcopy; new_normalGC = XtGetGC((Widget)term, mask, &xgcv); if (!new_normalGC) goto bad; if (nfs == bfs) { /* there is no bold font */ new_normalboldGC = new_normalGC; } else { xgcv.font = bfs->fid; new_normalboldGC = XtGetGC((Widget)term, mask, &xgcv); if (!new_normalboldGC) goto bad; } xgcv.font = nfs->fid; xgcv.foreground = term->core.background_pixel; xgcv.background = screen->foreground; new_reverseGC = XtGetGC((Widget)term, mask, &xgcv); if (!new_reverseGC) goto bad; if (nfs == bfs) { /* there is no bold font */ new_reverseboldGC = new_reverseGC; } else { xgcv.font = bfs->fid; new_reverseboldGC = XtGetGC((Widget)term, mask, &xgcv); if (!new_reverseboldGC) goto bad; } if (screen->normalGC != screen->normalboldGC) XtReleaseGC ((Widget) term, screen->normalboldGC); XtReleaseGC ((Widget) term, screen->normalGC); if (screen->reverseGC != screen->reverseboldGC) XtReleaseGC ((Widget) term, screen->reverseboldGC); XtReleaseGC ((Widget) term, screen->reverseGC); screen->normalGC = new_normalGC; screen->normalboldGC = new_normalboldGC; screen->reverseGC = new_reverseGC; screen->reverseboldGC = new_reverseboldGC; screen->fnt_norm = nfs; screen->fnt_bold = bfs; screen->enbolden = (nfs == bfs); set_menu_font (False); screen->menu_font_number = fontnum; set_menu_font (True); if (tmpname) { /* if setting escape or sel */ if (screen->menu_font_names[fontnum]) free (screen->menu_font_names[fontnum]); screen->menu_font_names[fontnum] = tmpname; if (fontnum == fontMenu_fontescape) { set_sensitivity (term->screen.fontMenu, fontMenuEntries[fontMenu_fontescape].widget, TRUE); } } set_cursor_gcs (screen); update_font_info (screen, doresize); return 1; bad: if (tmpname) free (tmpname); if (new_normalGC) XtReleaseGC ((Widget) term, screen->normalGC); if (new_normalGC && new_normalGC != new_normalboldGC) XtReleaseGC ((Widget) term, new_normalboldGC); if (new_reverseGC) XtReleaseGC ((Widget) term, new_reverseGC); if (new_reverseGC && new_reverseGC != new_reverseboldGC) XtReleaseGC ((Widget) term, new_reverseboldGC); if (nfs) XFreeFont (screen->display, nfs); if (bfs && nfs != bfs) XFreeFont (screen->display, bfs); return 0; } #endif /* !KTERM */ static void update_font_info (screen, doresize) TScreen *screen; Bool doresize; { int i, j, width, height, scrollbar_width; #ifdef KTERM int fnum; /* fnt_norm, fnt_bold */ int max_ascent = 0, max_descent = 0, max_width = 0; for (fnum = F_ISO8859_1; fnum < FCNT; fnum ++) { if (screen->fnt_norm) { # ifdef KTERM_MBCS if (screen->fnt_norm->max_byte1 > 0) /* MB font */ max_width = Max(max_width, screen->fnt_norm->max_bounds.width/2); else # endif /* KTERM_MBCS */ max_width = Max(max_width, screen->fnt_norm->max_bounds.width); max_ascent = Max(max_ascent, screen->fnt_norm->ascent); max_descent = Max(max_descent, screen->fnt_norm->descent); } if (screen->fnt_bold) { # ifdef KTERM_MBCS if (screen->fnt_bold->max_byte1 > 0) /* MB font */ max_width = Max(max_width, screen->fnt_bold->max_bounds.width/2); else # endif /* KTERM_MBCS */ max_width = Max(max_width, screen->fnt_bold->max_bounds.width); max_ascent = Max(max_ascent, screen->fnt_bold->ascent); max_descent = Max(max_descent, screen->fnt_bold->descent); } } doresize = (doresize && (screen->fullVwin.f_width != max_width || screen->max_ascent != max_ascent || screen->max_descent != max_descent)); screen->fullVwin.f_width = max_width; screen->max_ascent = max_ascent; screen->max_descent = max_descent; screen->fullVwin.f_height = max_ascent + max_descent; #else /* !KTERM */ screen->fullVwin.f_width = screen->fnt_norm->max_bounds.width; screen->fullVwin.f_height = (screen->fnt_norm->ascent + screen->fnt_norm->descent); #endif /* !KTERM */ scrollbar_width = (term->misc.scrollbar ? screen->scrollWidget->core.width + screen->scrollWidget->core.border_width : 0); i = 2 * screen->border + scrollbar_width; j = 2 * screen->border; #ifdef STATUSLINE if (screen->statusheight) j += (screen->statusheight = FontHeight(screen) + 2); #endif /* STATUSLINE */ #ifdef KTERM width = (screen->max_col + 1) * FontWidth(screen) + i; height = (screen->max_row + 1) * FontHeight(screen) + j; #else /* !KTERM */ width = (screen->max_col + 1) * screen->fullVwin.f_width + i; height = (screen->max_row + 1) * screen->fullVwin.f_height + j; #endif /* !KTERM */ screen->fullVwin.fullwidth = width; screen->fullVwin.fullheight = height; screen->fullVwin.width = width - i; screen->fullVwin.height = height - j; if (doresize) { if (VWindow(screen)) { XClearWindow (screen->display, VWindow(screen)); } DoResizeScreen (term); /* set to the new natural size */ if (screen->scrollWidget) ResizeScrollBar (screen->scrollWidget, -1, -1, #ifdef STATUSLINE screen->statusheight + #endif /* STATUSLINE */ Height(screen) + screen->border * 2); Redraw (); } set_vt_box (screen); #ifdef KTERM set_vt_graphics (screen); #endif /* KTERM */ } set_vt_box (screen) TScreen *screen; { XPoint *vp; #ifdef KTERM vp = &VTbox[1]; (vp++)->x = FontWidth(screen) - 1; (vp++)->y = screen->fullVwin.f_height - 1; (vp++)->x = -(FontWidth(screen) - 1); vp->y = -(screen->fullVwin.f_height - 1); # ifdef KTERM_MBCS vp = &VTwbox[1]; (vp++)->x = FontWidth(screen) * 2 - 1; (vp++)->y = screen->fullVwin.f_height - 1; (vp++)->x = -(FontWidth(screen) * 2 - 1); vp->y = -(screen->fullVwin.f_height - 1); # endif /* KTERM_MBCS */ set_vt_box_per_gset(screen); #else /* !KTERM */ vp = &VTbox[1]; (vp++)->x = FontWidth(screen) - 1; (vp++)->y = FontHeight(screen) - 1; (vp++)->x = -(FontWidth(screen) - 1); vp->y = -(FontHeight(screen) - 1); screen->box = VTbox; #endif /* !KTERM */ } #ifdef KTERM set_vt_graphics (screen) TScreen *screen; { static GC bmgc; static Pixmap gray; static Pixmap vtgraphics[256]; /* Bitmaps */ XPoint pts[4]; Display *dpy = screen->display; Window win = RootWindowOfScreen(XtScreen(term)); int W = FontWidth(screen), H = FontHeight(screen); int w = W - 1, h = H - 1; int w2 = w/2, h2 = h/2; int i; if (!gray) { /* static char gray_bits[] = { 0x08, 0x02, 0x04, 0x01 }; gray = XCreateBitmapFromData(dpy, win, gray_bits, 4, 4); */ static char gray_bits[] = { 0x11, 0x44 }; gray = XCreateBitmapFromData(dpy, win, gray_bits, 8, 2); } if (!bmgc) { bmgc = XCreateGC(dpy, gray, 0, NULL); } for (i = 0; i < 256; i ++) { if (vtgraphics[i]) { XFreePixmap(dpy, vtgraphics[i]); vtgraphics[i] = 0; } } vtgraphics[' '] = XCreatePixmap(dpy, win, W, H, 1); vtgraphics['`'] = XCreatePixmap(dpy, win, W, H, 1); vtgraphics['a'] = XCreatePixmap(dpy, win, W, H, 1); vtgraphics['j'] = XCreatePixmap(dpy, win, W, H, 1); vtgraphics['k'] = XCreatePixmap(dpy, win, W, H, 1); vtgraphics['l'] = XCreatePixmap(dpy, win, W, H, 1); vtgraphics['m'] = XCreatePixmap(dpy, win, W, H, 1); vtgraphics['n'] = XCreatePixmap(dpy, win, W, H, 1); vtgraphics['o'] = XCreatePixmap(dpy, win, W, H, 1); vtgraphics['p'] = XCreatePixmap(dpy, win, W, H, 1); vtgraphics['q'] = XCreatePixmap(dpy, win, W, H, 1); vtgraphics['r'] = XCreatePixmap(dpy, win, W, H, 1); vtgraphics['s'] = XCreatePixmap(dpy, win, W, H, 1); vtgraphics['t'] = XCreatePixmap(dpy, win, W, H, 1); vtgraphics['u'] = XCreatePixmap(dpy, win, W, H, 1); vtgraphics['v'] = XCreatePixmap(dpy, win, W, H, 1); vtgraphics['w'] = XCreatePixmap(dpy, win, W, H, 1); vtgraphics['x'] = XCreatePixmap(dpy, win, W, H, 1); vtgraphics['~'] = XCreatePixmap(dpy, win, W, H, 1); XSetForeground(dpy, bmgc, 0); XSetFillStyle(dpy, bmgc, FillSolid); for (i = 0; i < 256; i ++) { if (vtgraphics[i]) { XFillRectangle(dpy, vtgraphics[i], bmgc, 0, 0, W, H); } } XSetForeground(dpy, bmgc, 1); pts[0].x = w2; pts[0].y = 0; pts[1].x = 0; pts[1].y = h2; pts[2].x = w2; pts[2].y = h2*2; pts[3].x = w2*2; pts[3].y = h2; XFillPolygon(dpy, vtgraphics['`'], bmgc, pts, 4, Nonconvex, CoordModeOrigin); XSetFillStyle(dpy, bmgc, FillStippled); XSetStipple(dpy, bmgc, gray); XFillRectangle(dpy, vtgraphics['a'], bmgc, 0, 0, W, H); XSetFillStyle(dpy, bmgc, FillSolid); XDrawLine(dpy, vtgraphics['j'], bmgc, 0, h2, w2, h2); XDrawLine(dpy, vtgraphics['j'], bmgc, w2, 0, w2, h2); XDrawLine(dpy, vtgraphics['k'], bmgc, 0, h2, w2, h2); XDrawLine(dpy, vtgraphics['k'], bmgc, w2, h2, w2, h); XDrawLine(dpy, vtgraphics['l'], bmgc, w2, h2, w, h2); XDrawLine(dpy, vtgraphics['l'], bmgc, w2, h2, w2, h); XDrawLine(dpy, vtgraphics['m'], bmgc, w2, h2, w, h2); XDrawLine(dpy, vtgraphics['m'], bmgc, w2, 0, w2, h2); XDrawLine(dpy, vtgraphics['n'], bmgc, 0, h2, w, h2); XDrawLine(dpy, vtgraphics['n'], bmgc, w2, 0, w2, h); XDrawLine(dpy, vtgraphics['o'], bmgc, 0, 0, w, 0); XDrawLine(dpy, vtgraphics['p'], bmgc, 0, h/4, w, h/4); XDrawLine(dpy, vtgraphics['q'], bmgc, 0, h2, w, h2); XDrawLine(dpy, vtgraphics['r'], bmgc, 0, h*3/4, w, h*3/4); XDrawLine(dpy, vtgraphics['s'], bmgc, 0, h, w, h); XDrawLine(dpy, vtgraphics['t'], bmgc, w2, h2, w, h2); XDrawLine(dpy, vtgraphics['t'], bmgc, w2, 0, w2, h); XDrawLine(dpy, vtgraphics['u'], bmgc, 0, h2, w2, h2); XDrawLine(dpy, vtgraphics['u'], bmgc, w2, 0, w2, h); XDrawLine(dpy, vtgraphics['v'], bmgc, 0, h2, w, h2); XDrawLine(dpy, vtgraphics['v'], bmgc, w2, 0, w2, h2); XDrawLine(dpy, vtgraphics['w'], bmgc, 0, h2, w, h2); XDrawLine(dpy, vtgraphics['w'], bmgc, w2, h2, w2, h); XDrawLine(dpy, vtgraphics['x'], bmgc, w2, 0, w2, h); XDrawLine(dpy, vtgraphics['~'], bmgc, w2-1, h2, w2+1, h2); XDrawLine(dpy, vtgraphics['~'], bmgc, w2, h2-1, w2, h2+1); screen->graphics = vtgraphics; } #endif /* KTERM */ #ifdef KTERM set_cursor_gcs (screen, fnum) int fnum; #else /* !KTERM */ set_cursor_gcs (screen) #endif /* !KTERM */ TScreen *screen; { XGCValues xgcv; unsigned long mask; unsigned long cc = screen->cursorcolor; unsigned long fg = screen->foreground; unsigned long bg = term->core.background_pixel; GC new_cursorGC = NULL, new_reversecursorGC = NULL; GC new_cursoroutlineGC = NULL; /* * Let's see, there are three things that have "color": * * background * text * cursorblock * * And, there are four situation when drawing a cursor, if we decide * that we like have a solid block of cursor color with the letter * that it is highlighting shown in the background color to make it * stand out: * * selected window, normal video - background on cursor * selected window, reverse video - foreground on cursor * unselected window, normal video - foreground on background * unselected window, reverse video - background on foreground * * Since the last two are really just normalGC and reverseGC, we only * need two new GC's. Under monochrome, we get the same effect as * above by setting cursor color to foreground. */ xgcv.font = screen->fnt_norm->fid; mask = (GCForeground | GCBackground | GCFont); if (cc != fg && cc != bg) { /* we have a colored cursor */ xgcv.foreground = fg; xgcv.background = cc; new_cursorGC = XtGetGC ((Widget) term, mask, &xgcv); if (screen->always_highlight) { new_reversecursorGC = (GC) 0; new_cursoroutlineGC = (GC) 0; } else { xgcv.foreground = bg; xgcv.background = cc; new_reversecursorGC = XtGetGC ((Widget) term, mask, &xgcv); xgcv.foreground = cc; xgcv.background = bg; new_cursoroutlineGC = XtGetGC ((Widget) term, mask, &xgcv); } } else { new_cursorGC = (GC) 0; new_reversecursorGC = (GC) 0; new_cursoroutlineGC = (GC) 0; } if (screen->cursorGC) XtReleaseGC ((Widget)term, screen->cursorGC); if (screen->reversecursorGC) XtReleaseGC ((Widget)term, screen->reversecursorGC); if (screen->cursoroutlineGC) XtReleaseGC ((Widget)term, screen->cursoroutlineGC); screen->cursorGC = new_cursorGC; screen->reversecursorGC = new_reversecursorGC; screen->cursoroutlineGC = new_cursoroutlineGC; } #ifdef KTERM char ** ParseList(list) char *list; { static char **params; static int nparams; static char *listbuf; static int listbufsize; char *p, *q, *s, *e; int n; int len; len = strlen(list); if (listbuf && listbufsize < len) { XtFree(listbuf); listbuf = NULL; } if (!listbuf) { listbuf = XtMalloc(len + 1); listbufsize = len; } strcpy(listbuf, list); n = 0; for (p = listbuf; q = index(p, ','); p = q + 1) { n++; } n++; if (params && nparams < n) { XtFree((char *)params); params = NULL; } if (!params) { params = (char **)XtMalloc(sizeof(char *) * (n + 1)); nparams = n; } n = 0; for (p = listbuf; q = index(p, ','); p = q + 1) { for (e = q-1; p<=e && *e && isspace(*e); e--) /* empty */; for (s = p; s<=e && *s && isspace(*s); s++) /* empty */; params[n++] = s; *(e+1) = '\0'; } for (e = p+strlen(p)-1; p<=e && *e && isspace(*e); e--) /* empty */; for (s = p; s<=e && *s && isspace(*s); s++) /* empty */; params[n++] = s; *(e+1) = '\0'; params[n] = NULL; return params; } #endif /* KTERM */ kterm-6.2.0.orig/convert.c100444 507 454 31605 6163174631 14165 0ustar yosiakiaux/* * convert.c -- code converters for kterm * $Id: convert.c,v 6.2 1996/06/23 08:00:09 kagotani Rel $ */ /* * Copyright (c) 1989 Software Research Associates, Inc. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Software Research Associates not be * used in advertising or publicity pertaining to distribution of the * software without specific, written prior permission. Software Research * Associates makes no representations about the suitability of this software * for any purpose. It is provided "as is" without express or implied * warranty. * * Author: Makoto Ishisone, Software Research Associates, Inc., Japan */ #ifdef KTERM #include "ptyx.h" #define NUL 0x00 #define IsGsetKanji(gset) ((gset)==GSET_KANJI || (gset)==GSET_OLDKANJI) #define IsGsetAscii(gset) ((gset)==GSET_ASCII || (gset)==GSET_JISROMAN) #define JIStoSJIS(c1, c2, s1_p, s2_p) \ *(s1_p) = ((c1) - 0x21) / 2 + (((c1) <= 0x5e) ? 0x81 : 0xc1); \ if ((c1) & 1) /* odd */ \ *(s2_p) = (c2) + (((c2) <= 0x5f) ? 0x1f : 0x20); \ else \ *(s2_p) = (c2) + 0x7e; /* CS -> JIS using ESC-$-B */ int convCStoJIS(cs, js) Ichr *cs; Char *js; { return convCStoANY(cs, js, NULL); } /* CS -> EUC */ static int CStoEUC(cs_p, es_p) Ichr **cs_p; Char **es_p; { int c1, c2; Ichr *cs = *cs_p; Char *es = *es_p; if (cs->gset == GSET_KANA) { c1 = cs++->code; if (es) { *es++ = SS2; *es++ = c1 | 0x80; } *es_p = es; *cs_p = cs; return 2; } else if (IsGsetKanji(cs->gset)) { c1 = cs++->code; c2 = cs++->code; if (es) { *es++ = c1 | 0x80; *es++ = c2 | 0x80; } *es_p = es; *cs_p = cs; return 2; } return 0; } int convCStoEUC(cs, es) Ichr *cs; Char *es; { return convCStoANY(cs, es, CStoEUC); } /* CS -> SJIS */ static int CStoSJIS(cs_p, ss_p) Ichr **cs_p; Char **ss_p; { int c1, c2; Ichr *cs = *cs_p; Char *ss = *ss_p; if (cs->gset == GSET_KANA) { c1 = cs++->code; if (ss) { *ss++ = c1 | 0x80; } *ss_p = ss; *cs_p = cs; return 1; } else if (IsGsetKanji(cs->gset)) { c1 = cs++->code; c2 = cs++->code; if (ss) { JIStoSJIS(c1, c2, ss, ss+1); ss += 2; } *ss_p = ss; *cs_p = cs; return 2; } return 0; } int convCStoSJIS(cs, ss) Ichr *cs; Char *ss; { return convCStoANY(cs, ss, CStoSJIS); } /* CS -> any */ int convCStoANY(cs, as, func) Ichr *cs; Char *as; int (*func)(); { register int c1, c2; register int gset = GSET_ASCII; register int n = 0, m; while (c1 = cs->code) { if (func && (m = (*func)(&cs, &as))) { n += m; continue; } if (gset != cs->gset) { if (IsGsetAscii(cs->gset)) { /* JISROMAN HACK */ if (!IsGsetAscii(gset)) { if (as) { *as++ = ESC; *as++ = '('; *as++ = GSETFC(cs->gset); } n += 3; } } else if (IsGsetKanji(cs->gset) || cs->gset == GSET_HANZI) { /* Use ESC-$-F instead of ESC-$-(-F (for @AB) */ if (as) { *as++ = ESC; *as++ = '$'; *as++ = GSETFC(cs->gset); } n += 3; } else { if (as) { *as++ = ESC; if (cs->gset & MBCS) { *as++ = '$'; } if (cs->gset & CS96) { *as++ = '-'; } else { *as++ = '('; } *as++ = GSETFC(cs->gset); } if (cs->gset & MBCS) n += 4; else n += 3; } if (!(gset & CS96) && cs->gset & CS96) { if (as) *as++ = LS1; /* SO */ n++; } else if (gset & CS96 && !(cs->gset & CS96)) { if (as) *as++ = LS0; /* SI */ n++; } gset = cs->gset; } cs++; if (gset & MBCS) { c2 = cs++->code; if (as) { *as++ = c1 & ~0x80; *as++ = c2 & ~0x80; } n += 2; } else { if (as) *as++ = c1 & ~0x80; n++; } } if (!IsGsetAscii(gset)) { /* JISROMAN HACK */ if (as) { *as++ = ESC; *as++ = '('; *as++ = GSETFC(GSET_ASCII); } n += 3; } if (gset & CS96) { if (as) *as++ = LS0; /* SI */ n++; } if (as) *as = '\0'; return n; } /* CS -> ISO Latin-1 */ int convCStoLatin1(cs, ls) Ichr *cs; Char *ls; { register int c; register int n = 0; if (ls) { while (c = cs->code) { if (cs++->gset == GSET_ASCII) { *ls++ = c & ~0x80; n++; } } *ls = '\0'; } else { while (c = cs->code) { if (cs++->gset == GSET_ASCII) { n++; } } } return n; } /****************************************************************************** COMPOUND_TEXT Summary (based on Comopund Text Encoding Version 1 -- MIT X Consortium Standard) (1) Only G0 and G1 are used. G2 and G3 are not. (2) G0 is invoked into GL and G1 into GR. These invocation are not changed. (In other words, Locking Shift and Single Shift are not used) (3) In initial state, ISO Latin-1 is designated into G0/G1. (4) To designate MBCS into G0, ESC-$-F is not used but ESC-$-(-F. (5) In C0, only HT, NL, and ESC are used. (6) In C1, only CSI is used. (7) Text direction can be indecated. begin left-to-right string begin right-to-left string end of string ******************************************************************************/ /* convCStoCT -- Japanese Wide Character String -> COMPOUND_TEXT */ int convCStoCT(cs, as) register Ichr *cs; register Char *as; /* Convert Wide Character String cs to COMPOUND_TEXT xstr, return * length of xstr in bytes (not including the terminating null character). * If xstr is NULL, no conversion is done, but return length of xstr. */ { register int c1, c2; register int g0 = GSET_ASCII; register int g1 = GSET_LATIN1R; register int n = 0; while (c1 = cs->code) { if (cs->gset & CS96 || cs->gset & MBCS || cs->gset == GSET_KANA) { if (g1 != cs->gset) { g1 = cs->gset; if (as) { *as++ = ESC; if (g1 & MBCS) { *as++ = '$'; } if (g1 & CS96) { *as++ = '-'; } else { *as++ = ')'; } *as++ = GSETFC(g1); } n += 3; if (g1 & MBCS) n ++; } cs++; if (g1 & MBCS) { c2 = cs++->code; if (as) { *as++ = c1 | 0x80; *as++ = c2 | 0x80; } n += 2; } else { if (as) *as++ = c1 | 0x80; n++; } } else { if (g0 != cs->gset) { g0 = cs->gset; if (as) { *as++ = ESC; *as++ = '('; *as++ = GSETFC(g0); } n += 3; } cs++; if (as) *as++ = c1 & ~0x80; n++; } } if (g0 != GSET_ASCII) { if (as) { *as++ = ESC; *as++ = '('; *as++ = GSETFC(GSET_ASCII); } n += 3; } if (as) *as = '\0'; return n; } static Char * getesc(str, len) Char *str; int len; { register int c; /* Find intermediate characters and final character * following the escape character in an escape sequence. */ /* The intermediate character is 02/00 to 02/15 */ while (len > 0) { c = *str; if (c < 0x20 || 0x2f < c) break; len--, str++; } /* The final character is 03/00 to 07/14 */ if (--len < 0 || (c = *str++) < 0x30 || 0x7e < c) return NULL; return str; } static Char * getcsi(str, len) Char *str; int len; { register int c; /* Find parameter characters, intermediate characters * and final character following the CSI character * in a CSI sequence. */ /* The parameter characters is 03/00 to 03/15 */ while (len > 0) { c = *str; if (c < 0x30 || 0x3f < c) break; len--, str++; } /* The intermediate character is 02/00 to 02/15 */ while (len > 0) { c = *str; if (c < 0x20 || 0x2f < c) break; len--, str++; } /* The final character is 04/00 to 07/14 */ if (--len < 0 || (c = *str++) < 0x40 || 0x7e < c) return NULL; return str; } /* convCTtoCS -- COMPOUND_TEXT -> Japanese Wide Character String */ int convCTtoCS(xstr, len, cs) register Char *xstr; int len; Ichr *cs; /* Convert COMPOUND_TEXT xstr to Wide Character String cs, return * length of cs in characters (not including the terminating null character). * If cs is NULL, no conversion is done, but return length of cs. */ { register int c; int nskip; int n = 0; int g0, g1, gs; Char *xstr1; /* * Compound Text can include null octet. Therefore the length * of xstr is able to be specified by parameter len. * But if len is zero or negative, get length by strlen() assuming * that no null octet exists. */ if (len <= 0) { len = strlen((char *)xstr); } /* In initial state, ISO 8859/1 is designated into G0/G1 */ g0 = GSET_ASCII; /* ASCII -> G0 */ g1 = GSET_LATIN1R; /* Latin/1 right hand part -> G1 */ while (len-- > 0) { switch (c = *xstr++) { case NUL: break; case '\n': /* NEWLINE */ case '\t': /* TAB */ case ' ': /* SPACE (Note: GL is always 94 charset) */ if (cs) { cs->code = c; cs->gset = GSET_ASCII; cs++; } n++; break; case CSI: /* * CSI sequence is generally in following form: * CSI {P} {I} F * P : 03/00 to 03/15 * I : 02/00 to 02/15 * F : 04/00 to 07/14 */ /* * Currently only directionality is definde * as following: * CSI-1-] begin left-to-right text * CSI-2-] begin right-to-left text * CSI-] end of string * But this implementation ignores them. */ xstr1 = getcsi(xstr, len); if (xstr1 == NULL) return -1; len -= xstr1 - xstr; xstr = xstr1; break; case ESC: /* * ESC sequence is generally in following form: * ESC {I} F * I : 02/00 to 02/15 * F : 03/00 to 07/14 */ /* * Currently, following functions are defined: * Standard character set * ESC-(-F * ESC-$-(-F * ESC-)-F * ESC---F * ESC-$-)-F * Non standard character set * ESC-%-/-[0123] * Standard character set must be accepted correctly. * Non standard one is ignored but must be parsed * for skipping data. */ xstr1 = getesc(xstr, len); if (xstr1 == NULL) return -1; len -= xstr1 - xstr; switch (xstr1 - xstr) { case 2: /* ESC - I - F */ switch (*xstr++) { case '(': /* 94chars CS -> G0 */ g0 = GSET(*xstr); break; case ')': /* 94chars CS -> G1 */ g1 = GSET(*xstr); break; case '-': /* 96chars CS -> G1 */ g1 = GSET(*xstr) | CS96; break; default: /* ignore */ break; } break; case 3: /* ESC - I - I - F */ switch (*xstr++) { case '$': switch (*xstr++) { case '(': /* 94chars MBCS -> G0 */ g0 = GSET(*xstr) | MBCS; break; case ')': /* 94chars MBCS -> G1 */ g1 = GSET(*xstr) | MBCS; break; case '-': /* 96chars MBCS -> G1 */ g1 = GSET(*xstr) | CS96 | MBCS; break; default: /* ignore */ break; } break; case '%': if (*xstr++ != '/') { /* unknown sequence */ break; } /* * Private encoding is ignored. * But following data must be skipped. * ESC-%-/-F-M-L */ len -= 2; if (len < 0) return -1; nskip = (*xstr1 & ~0x80) * 128 + (*(xstr1 + 1) & ~0x80); if ((len -= nskip) < 0) return -1; xstr1 += nskip + 2; break; default: break; } break; default: break; } xstr = xstr1; break; default: if (!(c & 0x60)) { /* * Non NL/TAB/ESC/CSI character in C0 or C1 * is an obvious error. */ return -1; } gs = (c & 0x80) ? g1 : g0; if (cs) { cs->code = c & ~0x80; cs->gset = gs; cs++; } n++; break; } } if (cs) { cs->code = 0; cs->gset = 0; } return n; } /* EUC -> JIS */ int convEUCtoJIS(es, js) Char *es; Char *js; { Char e1, e2; Char gset = GSET_ASCII; int n = 0; while (e1 = *es++) { if (e1 == SS2) { if (e2 = *es++) { if (js) *js++ = e2 | 0x80; n++; } /* else { ??? } */ } else if (e1 & 0x80) { if (e2 = *es++) { if (gset != GSET_KANJI) { if (js) { *js++ = ESC; *js++ = '$'; *js++ = GSETFC(GSET_KANJI); } n += 3; gset = GSET_KANJI; } if (js) { *js++ = e1 & ~0x80; *js++ = e2 & ~0x80; } n += 2; } /* else { ??? } */ } else { if (gset != GSET_ASCII) { if (js) { *js++ = ESC; *js++ = '('; *js++ = GSETFC(GSET_ASCII); } n += 3; gset = GSET_ASCII; } if (js) { *js++ = e1 & ~0x80; } n++; } } if (gset != GSET_ASCII) { if (js) { *js++ = ESC; *js++ = '('; *js++ = GSETFC(GSET_ASCII); } n += 3; } if (js) { *js = 0; } return n; } /* EUC -> SJIS */ int convEUCtoSJIS(es, ss) Char *es; Char *ss; { Char e1, e2; int n = 0; while (e1 = *es++) { if (e1 == SS2) { if (e2 = *es++) { if (ss) *ss++ = e2 | 0x80; n++; } /* else { ??? } */ } else if (e1 & 0x80) { if (e2 = *es++) { if (ss) { e1 &= ~0x80; e2 &= ~0x80; JIStoSJIS(e1, e2, ss, ss+1); ss += 2; } n += 2; } /* else { ??? } */ } else { if (ss) *ss++ = e1; n++; } } if (ss) *ss = 0; return n; } #endif kterm-6.2.0.orig/convlib.c100444 507 454 100207 6140111427 14141 0ustar yosiakiaux/* * convlib2.c -- X11 $B%D!<%k%-%C%HJQ49F~NOMQ%i%$%V%i%j(B * * ishisone@sra.co.jp */ /* * Copyright (c) 1991 Software Research Associates, Inc. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Software Research Associates not be * used in advertising or publicity pertaining to distribution of the * software without specific, written prior permission. Software Research * Associates makes no representations about the suitability of this software * for any purpose. It is provided "as is" without express or implied * warranty. * * Author: Makoto Ishisone, Software Research Associates, Inc., Japan */ /* * --$B%$%s%?!<%U%'%$%9(B-- * * $BMQ0U$5$l$F$$$k%U%!%s%/%7%g%s$O$C$F$$$J$$!#$7$+$7(B Xt $B%D!<%k%-%C%H$r(B * $BMxMQ$9$k%W%m%0%i%`$J$i(B XIM $B$h$j$b$O$k$+$K4JC1$KAH$_9~$`$3$H$,$G$-$k$@(B * $B$m$&!#(B * * int _beginConversionWithAttributes( * Widget w, $BJQ49F~NO$r$7$?$$(B widget * Atom catom, $B%;%l%/%7%g%s%"%H%`(B eg "_JAPANESE_CONVERSION" * Atom tatom, $BJQ49%F%-%9%H%?%$%W(B eg "COMPOUND_TEXT" * void (*inputproc)(), $BJQ49%F%-%9%HF~NO%3!<%k%P%C%/4X?t(B * void (*startendproc)(), $BJQ493+;O(B / $B=*N;(B / $B%"%\!<%H(B $B%3!<%k%P%C%/4X?t(B * XtPointer client_data, $B%3!<%k%P%C%/4X?t$KEO$5$l$k%G!<%?(B * ArgList attrs, $BJQ49B0@-%j%9%H(B * Cardinal nattrs $BB0@-%j%9%H$N9`L\?t(B * ) * * $BJQ49$r3+;O$9$k!#$b$C$H@53N$K$$$&$H!"0z?t(B catom $B$K;XDj$5$l$?%;%l(B * $B%/%7%g%s%"%H%`$N%*!<%J!<(B ($B$3$l$,JQ49%U%m%s%H%(%s%I!"Nc$($P(B * kinput2 $B$G$"$k(B) $B$rC5$7!"JQ49$N%j%/%(%9%H$rAw$k!#F1;~$K0z?t(B attrs * $B$G;XDj$5$l$kJQ49B0@-(B ($BNc$($P%+!<%=%k$N0LCV(B) $B$r%U%m%s%H%(%s%I$KDL(B * $BCN$9$k!#JQ49B0@-$K$D$$$F$O8e$GJL$K@bL@$9$k!#%U%m%s%H%(%s%I$,B8:_(B * $B$7$J$$;~$K$O(B -1 $B$r!"$=$l0J30$O(B 0 $B$rJV$9!#(B * * startendproc $B$OJQ49$N>uBV$NJQ2=$r%"%W%j%1!<%7%g%s$KCN$i$;$k$?$a(B * $B$N%3!<%k%P%C%/$G$"$k!#$3$N%U%!%s%/%7%g%s$O$l(B * 0: $B%U%m%s%H%(%s%I$,JQ49%j%/%(%9%H$r$N%(%s%3!<(B * $B%G%#%s%0$r%5%]!<%H$9$k$+$I$&$+$O%U%m%s%H%(%s%I$N%$%s%W%j%a%s%F!<(B * $B%7%g%s$K0MB8$9$k!#=>$C$F(B COMPOUNT_TEXT $B0J30$N%(%s%3!<%G%#%s%0$r(B * $B;XDj$9$k$H!"$C$F(B XGetWindowProperty() $B$N@bL@$r;2>H$9$k$H(B * $B3F%Q%i%a!<%?$N0UL#$,$O$C$-$j$o$+$k$@$m$&!#(B * * void _changeConversionAttributes( * Widget w, * Atom catom, $B%;%l%/%7%g%s%"%H%`(B eg "_JAPANESE_CONVERSION" * ArgList attrs, $BJQ49B0@-%j%9%H(B * Cardinal nattrs $BB0@-%j%9%H$N9`L\?t(B * ) * * $BJQ49Cf$KJQ49B0@-$rJQ2=$5$;$k!#Nc$($P%+!<%=%k0LCV$,JQ$o$C$?$H$-$K(B * $B$3$N%U%!%s%/%7%g%s$G$=$l$r%U%m%s%H%(%s%I$KCN$i$;$k$3$H$,$G$-$k!#(B * * void _endConversion( * Widget w, * Atom catom, $B%;%l%/%7%g%s%"%H%`(B eg "_JAPANESE_CONVERSION" * Boolean throwaway $B$3$N8eMh$?JQ497k2L$ro!"JQ49$N=*N;$OJQ49%U%m%s%H%(%s%I$,9T$J$&$N(B * $B$GFC$K%"%W%j%1!<%7%g%s$+$i$3$N%U%!%s%/%7%g%s$r;H$C$F6/@)E*$K=*N;(B * $B$5$;$kI,MW$O$J$$!#(B * $B0z?t(B throwaway $B$,(B True $B$@$H$3$N%U%!%s%/%7%g%s$ruBV$NJQ2=$bCN$k$3$H$,$G$-$J$$$N$G!"$G$-$k$@$1(B * _beginConversionWithAttributes() $B$rMQ$$$k$N$,K>$^$7$$!#(B * * * --$B%;%l%/%7%g%s%"%H%`(B-- * * _beginConversionWithAttributes() $B$J$I$K;XDj$9$k%;%l%/%7%g%s%"%H%`$O(B * $BF~NO$7$?$$8@8l$K$h$C$F0[$J$j!"A0$K$J$C$F$$$k!#(B * "_<$B8@8lL>(B>_CONVERSION" * $BNc$($PF|K\8l$N>l9g$O(B "_JAPANESE_CONVERSION" $B$G$"$k!#(B * * * --$BJQ49B0@-%j%9%H(B-- * * $BJQ49B0@-$O(B XtSetValues() $B$J$I$G;HMQ$5$l$k%j%9%H$HF1$87A(B (ArgList) $B$G$"$k!#(B * $BB0@-$H$7$F;XDj$G$-$k$N$OH$7$F$[$7$$!#(B * * "inputStyle" : $BCM(B String * $BF~NO%9%?%$%k$r;XDj$9$k!#CM$O(B * "root" (root window style): $BJL%&%#%s%I%&$K$h$kJQ49(B * "off" (off-the-spot style): $B;XDj$7$?JQ49NN0hFb$G$NJQ49(B * "over" (over-the-spot style): $B$=$N>lJQ49(B * $B$N$I$l$+$NJ8;zNs$r;XDj$9$k!#(B * * "focusWindow" : $BCM(B Window * $BJQ49$r9T$J$&%&%#%s%I%&$r;XDj$9$k!#$3$l$,;XDj$5$l$?$J$+$C$?>l9g$K(B * $B$O(B _beginConversionWithAttributes() $B$G;XDj$7$?(B Widget $B$N%&%#%s%I(B * $B%&$,;H$o$l$k$N$GDL>o$O;XDj$7$J$/$F$h$$!#(B * * "spotX", "spotY" : $BCM(B Position * $B%9%]%C%H%m%1!<%7%g%s$r;XDj$9$k!#$3$l$OF~NO%9%?%$%k$,(B * over-the-spot $B$N;~$N$_M-8z$G$"$k!#J8;z$r=q$-;O$a$k0LCV$r;XDj$9$k(B * $B$,!"(BspotY $B$O%Y!<%9%i%$%s$N0LCV$G$"$k$3$H$KCm0U!#(B * spotX$B!"(BspotY $B$N$&$AJRJ}$@$1;XDj$7$F$bL58z!#(B * * "foreground", "background" : $BCM(B Pixel * $BA07J?'!"GX7J?'$r;XDj$9$k!#$3$l$bJRJ}$@$1;XDj$7$F$bL58z!#(B * * "eventCaptureMethod" : $BCM(B String * $B%U%m%s%H%(%s%I$,$I$N$h$&$KF~NO%$%Y%s%H$r$H$k$+$r;XDj$9$k!#(B * "none" $B2?$b$7$J$$(B * "inputOnly" InputOnly $B%&%#%s%I%&$K$h$k(B * "focusSelect" $B%U%)!<%+%9%&%#%s%I%&$N%$%Y%s%H$rD>@\(B * $B%;%l%/%H$9$k(B * $B$G$"$k!#(B * * "$B2?$b$7$J$$(B" $B$r;XDj$7$?>l9g!"%"%W%j%1!<%7%g%s$OJQ49Cf$K%"%W%j%1!<(B * $B%7%g%s$KMh$?%$%Y%s%H$r%U%m%s%H%(%s%I$KEO$7$F(B (XSendEvent() $B$r;H(B * $B$&(B) $B$d$i$J$1$l$P$J$i$J$$!#$3$N%$%Y%s%H$N%U%)%o!<%I:n6H$O$3$N%i%$(B * $B%V%i%j$G$O%5%]!<%H$7$F$$$J$$!#=>$C$F(B "$B2?$b$7$J$$(B" $B$r;XDj$9$k$3$H(B * $B$O$"$^$j$*4+$a$7$J$$!#(B * * "$B%U%)!<%+%9%&%#%s%I%&$N%$%Y%s%H$rD>@\%;%l%/%H$9$k(B" $B>l9g!"%"%W%j(B * $B%1!<%7%g%s$OJQ49Cf$O(B sendevent $B%U%i%0$NN)$C$F$$$J$$%-!<%$%Y%s%H(B * $B$rL5;k$7$J$/$F$O$J$i$J$$!#(Bsendevent $B%U%i%0$NN)$C$?%-!<%$%Y%s%H$O(B * $B%U%m%s%H%(%s%I$+$iLa$5$l$?%$%Y%s%H$G$"$k2DG=@-$,$"$j!"$3$l$OL5;k(B * $B$7$J$/$F$bNI$$$,!"EvA3$N$3$H$J$,$i%;%-%e%j%F%#$K$O5$$r$D$1$J$/$F(B * $B$O$J$i$J$$!#(B * * "InputOnly $B%&%#%s%I%&$K$h$k(B" $B$r;XDj$9$k$H%U%m%s%H%(%s%I$O%/%i%$(B * $B%"%s%H$N%&%#%s%I%&(B ($B$3$l$O%U%)!<%+%9%&%#%s%I%&$G$O$J$/!"(B * _beginConversionWithAttributes() $B$G;XDj$7$?(B Widget $B$N%&%#%s%I%&(B * $B$G$"$k(B) $B$NA0$KF)L@$J%&%#%s%I%&$r:n$j!"$=$3$KMh$?%$%Y%s%H$r2#l9g%$%Y%s%H$O%U%m%s%H%(%s%I$,>!$C$FJ}K!$H(B * $B$7$F$O$3$l$,0lHV4JC1$G$"$k!#$7$+$7$J$,$iNc$($P(B click-to-type $B7A(B * $B<0$N%&%#%s%I%&%^%M!<%8%c$r;H$C$?$j$7$F%-!l9g$K$O$&$^$/$$$+$J$$!#(B * * "lineSpacing" : $BCM(B int * $B9T4V3V$r;XDj$9$k!#%Y!<%9%i%$%s4V$N5wN%$r;XDj$9$k!#(B * * "clientArea" : $BCM(B XRectangle $B$X$N%]%$%s%?(B * $BJQ49%F%-%9%H$NI=<($K;HMQ$9$kNN0h$r;XDj$9$k!#(B * * "statusArea" : $BCM(B XRectangle $B$X$N%]%$%s%?(B * $B%b!<%II=<($K;HMQ$9$kNN0h$r;XDj$9$k!#(B * * "cursor" : $BCM(B Cursor * $B;HMQ$9$k%+!<%=%k(B ($B%^%&%9%+!<%=%k$M(B) $B$r;XDj$9$k!#(B * * "fonts" : $BCM(B NULL $B%?!<%_%M!<%H$5$l$?(B XFontStruct * $B$NG[Ns(B * $B;HMQ$9$k%U%)%s%H$r;XDj$9$k!#=gHV$O$I$&$G$b$h$$!#%U%m%s%H%(%s%IB&(B * $B$GH=CG$9$k!#$?$@$7(B XLFD $B$K=>$o$J$$%U%)%s%H$r;XDj$5$l$k$H!"%U%m%s(B * $B%H%(%s%I$G$=$N%-%c%i%/%?%;%C%H$,$o$+$i$:!"$=$N%U%)%s%H$,;H$o$l$J(B * $B$$$3$H$,$"$k!#(B * * $B>e5-$NB0@-$N$&$A!"(BinputStyle $B$H(B eventCaptureMethod $B$OJQ49ESCf$G(B ($B$D$^$j(B * _changeConversionAttributes() $B$G(B) $BJQ99$9$k$3$H$O$G$-$J$$!#(B */ #ifndef lint static char *rcsid = "$Id: convlib2.c,v 1.12 1994/06/03 09:13:19 ishisone Rel $"; #endif #include #include #include #include #include "ConvProto.h" typedef struct { Display *display; Atom profileAtom; /* "_CONVERSION_PROFILE" */ Atom typeAtom; /* "_CONVERSION_ATTRIBUTE_TYPE" */ Atom versionAtom; /* "PROTOCOL-2.0" */ Atom reqAtom; /* "CONVERSION_REQUEST" */ Atom notifyAtom; /* "CONVERSION_NOTIFY" */ Atom endAtom; /* "CONVERSION_END" */ Atom endReqAtom; /* "CONVERSION_END_REQUEST" */ Atom attrAtom; /* "CONVERSION_ATTRIBUTE" */ Atom attrNotifyAtom; /* "CONVERSION_ATTRIBUTE_NOTIFY" */ } ConversionAtoms; typedef struct { Atom convatom; Window convowner; Atom property; void (*inputproc)(); void (*startendproc)(); XtPointer closure; } ConversionContext; static XContext convertPrivContext; #if __STDC__ /* function prototype */ static void callStart(Widget, ConversionContext *, Window); static void callFail(Widget, ConversionContext *); static void callEnd(Widget, ConversionContext *); static long getInputStyle(String); static long getCaptureMethod(String); static ConversionAtoms *getAtoms(Widget); static ConversionContext *getConversionContext(Widget); static void recvConvAck(Widget, XtPointer, XEvent *, Boolean *); static void getConv(Widget, XtPointer, XEvent *, Boolean *); static Boolean setConvAttrProp(Widget, ArgList, Cardinal, Atom); static int makeAttrData(Widget, ArgList, Cardinal, unsigned long **); static Boolean checkProtocols(Display *, Window, ConversionAtoms *); #else static void callStart(); static void callFail(); static void callEnd(); static long getInputStyle(); static long getCaptureMethod(); static ConversionAtoms *getAtoms(); static ConversionContext *getConversionContext(); static void recvConvAck(); static void getConv(); static Boolean setConvAttrProp(); static int makeAttrData(); static Boolean checkProtocols(); #endif static void callStart(w, context, convwin) Widget w; ConversionContext *context; Window convwin; { if (context->startendproc != NULL) { (*context->startendproc)(w, context->convatom, 0, context->closure, convwin); } } static void callFail(w, context) Widget w; ConversionContext *context; { if (context->startendproc != NULL) { (*context->startendproc)(w, context->convatom, -1, context->closure, None); } } static void callEnd(w, context) Widget w; ConversionContext *context; { if (context->startendproc != NULL) { (*context->startendproc)(w, context->convatom, 1, context->closure, None); } } static long getInputStyle(s) String s; { String p; char buf[64]; (void)strcpy(buf, s); for (p = buf; *p != '\0'; p++) { if ('A' <= *p && *p <= 'Z') *p += 'a' - 'A'; } if (!strcmp(buf, "over")) return CONVARG_OVERTHESPOT; if (!strcmp(buf, "off")) return CONVARG_OFFTHESPOT; return CONVARG_ROOTWINDOW; } static long getCaptureMethod(s) String s; { String p; char buf[64]; (void)strcpy(buf, s); for (p = buf; *p != '\0'; p++) { if ('A' <= *p && *p <= 'Z') *p += 'a' - 'A'; } if (!strcmp(buf, "none")) return CONVARG_NONE; if (!strcmp(buf, "focusselect")) return CONVARG_SELECT_FOCUS_WINDOW; return CONVARG_CREATE_INPUTONLY; } static ConversionAtoms * getAtoms(w) Widget w; { int i; Display *disp = XtDisplay(w); ConversionAtoms *cap; static ConversionAtoms *convatomp; static Cardinal ndisp = 0; #define nalloc 2 /* * $B%"%H%`$O%G%#%9%W%l%$$4$H$K0c$&$N$G!"(B * $B%G%#%9%W%l%$$4$H$K:n$i$J$/$F$O$J$i$J$$(B */ /* $B$9$G$K%"%H%`$,:n$i$l$F$$$k$+$I$&$+D4$Y$k(B */ cap = convatomp; for (i = 0; i < ndisp; i++, cap++) { if (cap->display == disp) return cap; } /* * $B$^$@:n$i$l$F$$$J$$$N$G?7$7$/:n$k(B */ if (ndisp == 0) { /* $B:G=i$J$N$G(B Context $B$bF1;~$K:n$k(B */ convertPrivContext = XUniqueContext(); convatomp = (ConversionAtoms *) XtMalloc(sizeof(ConversionAtoms) * nalloc); cap = convatomp; } else if (ndisp % nalloc == 0) { /* $B%5%$%:$rA}$d$9(B */ convatomp = (ConversionAtoms *) XtRealloc((char *)convatomp, sizeof(ConversionAtoms) * (ndisp + nalloc)); cap = convatomp + ndisp; } else { cap = convatomp + ndisp; } /* $B%G%#%9%W%l%$$NEPO?(B */ cap->display = disp; /* Atom $B$N:n@.(B */ cap->profileAtom = XInternAtom(disp, CONVERSION_PROFILE, False); cap->typeAtom = XInternAtom(disp, CONVERSION_ATTRIBUTE_TYPE, False); cap->versionAtom = XInternAtom(disp, PROTOCOL_VERSION, False); cap->reqAtom = XInternAtom(disp, "CONVERSION_REQUEST", False); cap->notifyAtom = XInternAtom(disp, "CONVERSION_NOTIFY", False); cap->endAtom = XInternAtom(disp, "CONVERSION_END", False); cap->endReqAtom = XInternAtom(disp, "CONVERSION_END_REQUEST", False); cap->attrAtom = XInternAtom(disp, "CONVERSION_ATTRIBUTE", False); cap->attrNotifyAtom = XInternAtom(disp, "CONVERSION_ATTRIBUTE_NOTIFY", False); ndisp++; return cap; } static ConversionContext * getConversionContext(w) Widget w; { ConversionContext *context; if (XFindContext(XtDisplay(w), XtWindow(w), convertPrivContext, (caddr_t *)&context)) { /* error -- $BB?J,%3%s%F%-%9%H$,8+$D$+$i$J$+$C$?$?$a(B */ return NULL; } else { return context; } } /* ARGSUSED */ static void recvConvAck(w, closure, ev, junk) Widget w; XtPointer closure; XEvent *ev; Boolean *junk; /* NOTUSED */ { XClientMessageEvent *cev = &(ev->xclient); ConversionAtoms *cap; ConversionContext *context; if (ev->type != ClientMessage) return; cap = getAtoms(w); context = getConversionContext(w); /* $B@5$7$$%$%Y%s%H$+$I$&$+%A%'%C%/$9$k(B */ if (cev->window != XtWindow(w) || cev->message_type != cap->notifyAtom || cev->data.l[0] != context->convatom) { return; } /* * $B$3$N%O%s%I%i$O$b$&MQ:Q$_$J$N$G30$9(B */ XtRemoveEventHandler(w, NoEventMask, True, recvConvAck, closure); if (cev->data.l[2] == None) { XtWarning("selection request failed"); XDeleteContext(XtDisplay(w), XtWindow(w), convertPrivContext); callFail(w, context); XtFree((char *)context); return; } callStart(w, context, (Window)cev->data.l[3]); /* * PropertyNotify $B$H(B CONVERSION_END $BMQ$N%$%Y%s%H%O%s%I%i$r(B * $BEPO?$9$k(B */ XtAddEventHandler(w, PropertyChangeMask, True, getConv, closure); /* $B%W%m%Q%F%#L>$r%9%H%"$9$k(B */ context->property = cev->data.l[2]; } /* ARGSUSED */ static void getConv(w, closure, ev, junk) Widget w; XtPointer closure; XEvent *ev; Boolean *junk; /* NOTUSED */ { ConversionAtoms *cap; ConversionContext *context; /* PropertyNotify $B$H(B ClientMessage $B0J30$OL5;k$9$k(B */ if (ev->type != PropertyNotify && ev->type != ClientMessage) return; cap = getAtoms(w); context = getConversionContext(w); if (ev->type == ClientMessage) { XClientMessageEvent *cev = &(ev->xclient); /* * $BK\Ev$KF~NO=*N;$N%$%Y%s%H$+$I$&$+%A%'%C%/$9$k(B */ if (cev->message_type == cap->endAtom && cev->format == 32 && cev->data.l[0] == context->convatom) { /* $B%&%#%s%I%&$N%3%s%F%-%9%H$r:o=|$9$k(B */ XDeleteContext(XtDisplay(w), XtWindow(w), convertPrivContext); /* $B%$%Y%s%H%O%s%I%i$r30$9(B */ XtRemoveEventHandler(w, PropertyChangeMask, True, getConv, closure); callEnd(w, context); XtFree((char *)context); } } else { /* PropertyNotify */ XPropertyEvent *pev = &(ev->xproperty); Atom proptype; int propformat; unsigned long propsize, rest; unsigned char *propvalue; if (context->property == None) return; /* $B@5$7$$%$%Y%s%H$+$I$&$+$N%A%'%C%/(B */ if (pev->window != XtWindow(w) || pev->atom != context->property || pev->state != PropertyNewValue) { return; } /* $B$b$7%3!<%k%P%C%/4X?t(B context->inputproc $B$,(B * NULL $B$J$i$P%W%m%Q%F%#$r:o=|$9$k$@$1(B */ if (context->inputproc == NULL) { XDeleteProperty(XtDisplay(w), XtWindow(w), context->property); return; } /* $B%W%m%Q%F%#$+$iJQ49J8;zNs$rproperty, 0L, 100000L, True, AnyPropertyType, &proptype, &propformat, &propsize, &rest, &propvalue); /* $B%W%m%Q%F%#$N%?%$%W!&%U%)!<%^%C%H$N%A%'%C%/(B */ if (proptype == None) { /* $B%W%m%Q%F%#$,B8:_$7$J$+$C$?(B * $B$3$l$OO"B3$7$F2?2s$b%W%m%Q%F%#$K%G!<%?$,(B * $BF~$l$i$l$?;~!"0l2s$N(B GetWindowProperty $B$G(B * $BJ#?t$N%G!<%?$r$H$C$F$7$^$C$?$"$H$K5/$-$k(B * $B=>$C$F$3$l$O%(%i!<$G$O$J$$(B */ return; } /* $B%3!<%k%P%C%/$r8F$V(B */ (*context->inputproc)(w, context->convatom, proptype, propformat, propsize, propvalue, context->closure); } } static Boolean setConvAttrProp(w, attrs, nattrs, prop) Widget w; ArgList attrs; Cardinal nattrs; Atom prop; { unsigned long *data; int len; if ((len = makeAttrData(w, attrs, nattrs, &data)) > 0) { XChangeProperty(XtDisplay(w), XtWindow(w), prop, prop, 32, PropModeReplace, (unsigned char *)data, len); XtFree((char *)data); return True; } return False; } static int makeAttrData(w, args, nargs, datap) Widget w; ArgList args; Cardinal nargs; unsigned long **datap; { unsigned long *data; Cardinal len; Boolean spotx_specified = False, spoty_specified = False; Boolean fore_specified = False, back_specified = False; Pixel savedfg, savedbg; Position savedx, savedy; #define ALLOC(n) \ data = (unsigned long *)XtRealloc((char *)data, \ sizeof(unsigned long)*(len+(n))) data = NULL; len = 0; while (nargs-- > 0) { if (!strcmp(args->name, "spotX")) { savedx = (Position)args->value; spotx_specified = True; } else if (!strcmp(args->name, "spotY")) { savedy = (Position)args->value; spoty_specified = True; } else if (!strcmp(args->name, "foreground")) { savedfg = (Pixel)args->value; fore_specified = True; } else if (!strcmp(args->name, "background")) { savedbg = (Pixel)args->value; back_specified = True; } else if (!strcmp(args->name, "focusWindow")) { Window win = (Window)args->value; ALLOC(2); data[len] = CONV_ATTR(CONVATTR_FOCUS_WINDOW, 1); data[len + 1] = (unsigned long)win; len += 2; } else if (!strcmp(args->name, "inputStyle")) { long style = getInputStyle((String)args->value); ALLOC(2); data[len] = CONV_ATTR(CONVATTR_INPUT_STYLE, 1); data[len + 1] = style; len += 2; } else if (!strcmp(args->name, "eventCaptureMethod")) { long method = getCaptureMethod((String)args->value); ALLOC(2); data[len] = CONV_ATTR(CONVATTR_EVENT_CAPTURE_METHOD, 1); data[len + 1] = method; len += 2; } else if (!strcmp(args->name, "lineSpacing")) { int spacing = (int)args->value; ALLOC(2); data[len] = CONV_ATTR(CONVATTR_LINE_SPACING, 1); data[len + 1] = spacing; len += 2; } else if (!strcmp(args->name, "clientArea")) { XRectangle *rectp = (XRectangle *)args->value; ALLOC(3); data[len] = CONV_ATTR(CONVATTR_CLIENT_AREA, 2); data[len + 1] = (rectp->x << 16) | (rectp->y & 0xffff); data[len + 2] = (rectp->width << 16) | (rectp->height & 0xffff); len += 3; } else if (!strcmp(args->name, "statusArea")) { XRectangle *rectp = (XRectangle *)args->value; ALLOC(3); data[len] = CONV_ATTR(CONVATTR_STATUS_AREA, 2); data[len + 1] = (rectp->x << 16) | (rectp->y & 0xffff); data[len + 2] = (rectp->width << 16) | (rectp->height & 0xffff); len += 3; } else if (!strcmp(args->name, "cursor")) { Cursor cursor = (Cursor)args->value; ALLOC(2); data[len] = CONV_ATTR(CONVATTR_CURSOR, 1); data[len + 1] = cursor; len += 2; } else if (!strcmp(args->name, "fonts")) { XFontStruct **fontp = (XFontStruct **)args->value; int nfonts, nrealfonts; int i; for (nfonts = 0; fontp[nfonts] != NULL; nfonts++) ; ALLOC(nfonts + 1); nrealfonts = 0; for (i = 0; i < nfonts; i++) { unsigned long atom; if (XGetFontProperty(fontp[i], XA_FONT, &atom)) { data[len + ++nrealfonts] = atom; } } data[len] = CONV_ATTR(CONVATTR_FONT_ATOMS, nrealfonts); len += nrealfonts + 1; } else { String params[1]; Cardinal num_params; params[0] = args->name; XtAppWarningMsg(XtWidgetToApplicationContext(w), "conversionError", "invalidResource", "ConversionLibraryError", "_beginConversionWithAttributes: unknown resource %s", params, &num_params); } args++; } if (spotx_specified && spoty_specified) { ALLOC(2); data[len] = CONV_ATTR(CONVATTR_SPOT_LOCATION, 1); data[len + 1] = (savedx << 16) | (savedy & 0xffff); len += 2; } if (fore_specified && back_specified) { ALLOC(3); data[len] = CONV_ATTR(CONVATTR_COLOR, 2); data[len + 1] = savedfg; data[len + 2] = savedbg; len += 3; } *datap = data; return len; #undef ALLOC } static Boolean checkProtocols(dpy, window, cap) Display *dpy; Window window; ConversionAtoms *cap; { Atom type; int format; unsigned long nitems; unsigned long bytesafter; unsigned long *data, *saveddata; int err; Boolean ret; data = NULL; err = XGetWindowProperty(dpy, window, cap->profileAtom, 0L, 100L, False, cap->typeAtom, &type, &format, &nitems, &bytesafter, (unsigned char **)&data); if (err) return False; if (format != 32 || type != cap->typeAtom) { if (data != NULL) XtFree((char *)data); return False; } ret = False; saveddata = data; while (nitems > 0) { int code = CODE_OF_ATTR(*data); int len = LENGTH_OF_ATTR(*data); data++; nitems--; if (nitems < len) break; switch (code) { case CONVPROF_PROTOCOL_VERSION: if (*data == cap->versionAtom) ret = True; break; case CONVPROF_SUPPORTED_STYLES: break; /* XXX for now */ default: break; } data += len; nitems -= len; } XtFree((char *)saveddata); return ret; } /* * public functions */ int _beginConversionWithAttributes(w, catom, tatom, inputproc, startendproc, client_data, attrs, nattrs) Widget w; Atom catom; /* Selection Atom e.g. JAPANESE_CONVERSION */ Atom tatom; /* Property Type Atom e.g. COMPOUND_TEXT */ void (*inputproc)(); /* conversion text callback function */ void (*startendproc)(); /* conversion start/end callback function */ XtPointer client_data; /* client_data passed to callback function */ ArgList attrs; /* attribute data */ Cardinal nattrs; /* number of attr args */ { Window owner; XEvent event; ConversionAtoms *cap; ConversionContext *context; Boolean anyattr; cap = getAtoms(w); /* $BJQ49%5!<%P$rC5$9(B */ if ((owner = XGetSelectionOwner(XtDisplay(w), catom)) == None) { /* $B$J$$(B * $B$b$7$bJQ49Cf$@$C$?$iJQ49$rCf;_$9$k(B */ XtWarning("Conversion Server not found"); if ((context = getConversionContext(w)) != NULL) { /* $B%$%Y%s%H%O%s%I%i$r30$9(B */ XtRemoveEventHandler(w, NoEventMask, True, recvConvAck, (XtPointer)NULL); XtRemoveEventHandler(w, PropertyChangeMask, True, getConv, (XtPointer)NULL); /* $B%&%#%s%I%&$N%3%s%F%-%9%H$r:o=|$9$k(B */ XDeleteContext(XtDisplay(w), XtWindow(w), convertPrivContext); callEnd(w, context); XtFree((char *)context); } return -1; } /* * $B:#$9$G$KJQ49Cf$+$I$&$+D4$Y$k(B * $BJQ49Cf$J$i2?$b$;$:$K%j%?!<%s$9$k!D$o$1$K$O$$$+$J$$(B * $B$J$<$+$H$$$&$H!"JQ49%5!<%P$,2?$i$+$N;v>p$GESCf$G;`$s$@>l9g(B * CONVERSION_END $B$,%/%i%$%"%s%H$KMh$J$$$3$H$,$"$k$+$i$G$"$k(B * $B$=$3$G!"JQ49Cf$N>l9g$G$b(B SelectionOwner $B$rC5$7$F!"$=$l$,(B * $B:G=i$K(B _beginConversion() $B$,8F$P$l$?;~$H(B WindowID $B$,F1$8$+(B * $B$I$&$+3NG'$9$k(B * $BK\Ev$O(B SelectionOwner $B$K$J$C$?;~4V$b%A%'%C%/$7$?$$$N$@$,(B * ICCCM $B$K=R$Y$i$l$F$$$k$h$&$K!"(BGetSelectionOwner $B$G$O(B * $B$=$l$,$o$+$i$J$$$N$G$"$-$i$a$k(B */ if ((context = getConversionContext(w)) != NULL) { Window curOwner; curOwner = (catom == context->convatom) ? owner : XGetSelectionOwner(XtDisplay(w), context->convatom); if (curOwner == context->convowner) { /* $B2?$b$;$:$K%j%?!<%s(B */ return 0; } /* SelectionOwner $B$,JQ$o$C$F$$$k(B * $B$3$l$OESCf$GJQ49%5!<%P$,%/%i%C%7%e$7$?$K0c$$$J$$(B * $B$H$$$&$3$H$G(B CONVERSION_END $B$,Mh$?;~$HF1$8$h$&$J(B * $B=hM}$r$9$k(B */ /* $B%$%Y%s%H%O%s%I%i$r30$9(B * CONVERSION_NOTIFY $B$N%$%Y%s%H$,Mh$k$^$G$O(B * recvConvAck() $B$,%O%s%I%i$G!"$=$N8e$O(B * getConv() $B$,%O%s%I%i$G$"$k(B */ XtRemoveEventHandler(w, NoEventMask, True, recvConvAck, (XtPointer)NULL); XtRemoveEventHandler(w, PropertyChangeMask, True, getConv, (XtPointer)NULL); /* $B%&%#%s%I%&$N%3%s%F%-%9%H$r:o=|$9$k(B */ XDeleteContext(XtDisplay(w), XtWindow(w), convertPrivContext); callEnd(w, context); XtFree((char *)context); } /* * $B%5!<%P$+$i$N(B CONVERSION_NOTIFY $BMQ$N%$%Y%s%H%O%s%I%i$r(B * $BEPO?$9$k(B */ XtAddEventHandler(w, NoEventMask, True, recvConvAck, (XtPointer)NULL); /* * $B%3%s%F%-%9%H$r$D$/$C$FI,MW$J>pJs$rEPO?$9$k(B */ context = XtNew(ConversionContext); context->convatom = catom; context->convowner = owner; context->property = None; /* $B$3$l$O(B CONVERSION_NOTIFY $B$,Mh$?;~$K(B * $B@5$7$/@_Dj$5$l$k(B */ context->inputproc = inputproc; context->startendproc = startendproc; context->closure = client_data; XSaveContext(XtDisplay(w), XtWindow(w), convertPrivContext, (caddr_t)context); /* * $BJQ49B0@-%j%9%H$,;XDj$5$l$F$$$l$P%W%m%Q%F%#$K$=$l$rEPO?$9$k(B */ if (nattrs != 0 && attrs != NULL && checkProtocols(XtDisplay(w), owner, cap)) { anyattr = setConvAttrProp(w, attrs, nattrs, cap->attrAtom); } /* * ClientMessage $B%$%Y%s%H$r;H$C$FF|K\8lF~NO$r%j%/%(%9%H$9$k(B */ event.xclient.type = ClientMessage; event.xclient.window = owner; event.xclient.message_type = cap->reqAtom; event.xclient.format = 32; event.xclient.data.l[0] = catom; event.xclient.data.l[1] = XtWindow(w); event.xclient.data.l[2] = tatom; /* $B7k2L$r%9%H%"$9$k%W%m%Q%F%#L>$O!"B?8@8l$rF1;~$K;HMQ$9$k$3$H$r(B * $B9M$($F!"(Bselection atom $B$r;HMQ$9$k$3$H$K$9$k(B */ event.xclient.data.l[3] = catom; event.xclient.data.l[4] = anyattr ? cap->attrAtom : None; XSendEvent(XtDisplay(w), owner, False, NoEventMask, &event); return 0; } /* this is provided for backward compatibility */ void _beginConversion(w, catom, tatom, inputproc, client_data) Widget w; Atom catom; /* Selection Atom e.g. JAPANESE_CONVERSION */ Atom tatom; /* Property Type Atom e.g. COMPOUND_TEXT */ void (*inputproc)(); /* conversion text callback function */ XtPointer client_data; /* client_data passed to callback function */ { (void)_beginConversionWithAttributes(w, catom, tatom, inputproc, (void (*)())NULL, client_data, (ArgList)NULL, 0); } void _changeConversionAttributes(w, catom, attrs, nattrs) Widget w; Atom catom; /* Selection Atom e.g. JAPANESE_CONVERSION */ ArgList attrs; /* attribute data */ Cardinal nattrs; /* number of attr args */ { XEvent event; ConversionAtoms *cap; ConversionContext *context; unsigned long *data; int len; if (attrs == NULL || nattrs == 0) return; cap = getAtoms(w); context = getConversionContext(w); if (context == NULL || (catom != None && catom != context->convatom)) { return; } if (XGetSelectionOwner(XtDisplay(w), context->convatom) != context->convowner) { /* $BJQ49%5!<%P$,0[$J$k!"$"$k$$$O$J$$(B */ XtRemoveEventHandler(w, NoEventMask, True, recvConvAck, (XtPointer)NULL); XtRemoveEventHandler(w, PropertyChangeMask, True, getConv, (XtPointer)NULL); /* $B%&%#%s%I%&$N%3%s%F%-%9%H$r:o=|$9$k(B */ XDeleteContext(XtDisplay(w), XtWindow(w), convertPrivContext); callEnd(w, context); XtFree((char *)context); return; } data = NULL; if ((len = makeAttrData(w, attrs, nattrs, &data)) == 0) return; event.xclient.type = ClientMessage; event.xclient.window = context->convowner; event.xclient.message_type = cap->attrNotifyAtom; event.xclient.format = 32; event.xclient.data.l[0] = context->convatom; event.xclient.data.l[1] = XtWindow(w); if (len <= 3 && len == LENGTH_OF_ATTR(data[0]) + 1) { int i; /* $B%$%Y%s%H$NCf$K<}$^$k(B */ for (i = 0; i < len; i++) { event.xclient.data.l[2 + i] = data[i]; } } else { XChangeProperty(XtDisplay(w), XtWindow(w), cap->attrAtom, cap->attrAtom, 32, PropModeReplace, (unsigned char *)data, len); event.xclient.data.l[2] = CONV_ATTR(CONVATTR_INDIRECT, 1); event.xclient.data.l[3] = cap->attrAtom; } XSendEvent(XtDisplay(w), context->convowner, False, NoEventMask, &event); if (data != NULL) XtFree((char *)data); } void _endConversion(w, catom, throwaway) Widget w; Atom catom; /* Selection Atom */ Boolean throwaway; { XEvent event; ConversionAtoms *cap; ConversionContext *context; cap = getAtoms(w); context = getConversionContext(w); if (context == NULL || (catom != None && catom != context->convatom)) { return; } if (XGetSelectionOwner(XtDisplay(w), context->convatom) != context->convowner) { /* $BJQ49%5!<%P$,0[$J$k!"$"$k$$$O$J$$(B */ XtRemoveEventHandler(w, NoEventMask, True, recvConvAck, (XtPointer)NULL); XtRemoveEventHandler(w, PropertyChangeMask, True, getConv, (XtPointer)NULL); /* $B%&%#%s%I%&$N%3%s%F%-%9%H$r:o=|$9$k(B */ XDeleteContext(XtDisplay(w), XtWindow(w), convertPrivContext); /* $B%3!<%k%P%C%/$r8F$V(B */ callEnd(w, context); XtFree((char *)context); return; } if (throwaway) context->inputproc = NULL; event.xclient.type = ClientMessage; event.xclient.window = context->convowner; event.xclient.message_type = cap->endReqAtom; event.xclient.format = 32; event.xclient.data.l[0] = context->convatom; event.xclient.data.l[1] = XtWindow(w); XSendEvent(XtDisplay(w), context->convowner, False, NoEventMask, &event); } kterm-6.2.0.orig/cursor.c100444 507 454 13711 6160504460 14012 0ustar yosiakiaux/* * $XConsortium: cursor.c,v 1.14 93/09/20 17:42:23 hersh Exp $ * $Id: cursor.c,v 6.0 1994/06/04 15:44:00 kagotani Rel $ */ /* * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ /* cursor.c */ #include "ptyx.h" /* also gets Xlib.h */ static void _CheckSelection(screen) register TScreen *screen; { #ifdef ENBUG /* kagotani */ extern XtermWidget term; /* %%% gross */ #endif if (screen->cur_row > screen->endHRow || (screen->cur_row == screen->endHRow && screen->cur_col >= screen->endHCol)) {} else #ifdef ENBUG /* kagotani */ DisownSelection(term); #else TrackText(0, 0, 0, 0); #endif } /* * Moves the cursor to the specified position, checking for bounds. * (this includes scrolling regions) * The origin is considered to be 0, 0 for this procedure. */ CursorSet(screen, row, col, flags) register TScreen *screen; register int row, col; unsigned flags; { register int maxr; col = (col < 0 ? 0 : col); screen->cur_col = (col <= screen->max_col ? col : screen->max_col); maxr = screen->max_row; if (flags & ORIGIN) { row += screen->top_marg; maxr = screen->bot_marg; } row = (row < 0 ? 0 : row); screen->cur_row = (row <= maxr ? row : maxr); screen->do_wrap = 0; _CheckSelection(screen); } /* * moves the cursor left n, no wrap around */ CursorBack(screen, n) register TScreen *screen; int n; { register int i, j, k, rev; extern XtermWidget term; if((rev = (term->flags & (REVERSEWRAP | WRAPAROUND)) == (REVERSEWRAP | WRAPAROUND)) && screen->do_wrap) n--; if ((screen->cur_col -= n) < 0) { if(rev) { if((i = (j = screen->max_col + 1) * screen->cur_row + screen->cur_col) < 0) { k = j * (screen->max_row + 1); i += ((-i) / k + 1) * k; } screen->cur_row = i / j; screen->cur_col = i % j; } else screen->cur_col = 0; } screen->do_wrap = 0; _CheckSelection(screen); } /* * moves the cursor forward n, no wraparound */ CursorForward(screen, n) register TScreen *screen; int n; { screen->cur_col += n; if (screen->cur_col > screen->max_col) screen->cur_col = screen->max_col; screen->do_wrap = 0; _CheckSelection(screen); } /* * moves the cursor down n, no scrolling. * Won't pass bottom margin or bottom of screen. */ CursorDown(screen, n) register TScreen *screen; int n; { register int max; max = (screen->cur_row > screen->bot_marg ? screen->max_row : screen->bot_marg); screen->cur_row += n; if (screen->cur_row > max) screen->cur_row = max; screen->do_wrap = 0; _CheckSelection(screen); } /* * moves the cursor up n, no linestarving. * Won't pass top margin or top of screen. */ CursorUp(screen, n) register TScreen *screen; int n; { register int min; min = (screen->cur_row < screen->top_marg ? 0 : screen->top_marg); screen->cur_row -= n; if (screen->cur_row < min) screen->cur_row = min; screen->do_wrap = 0; _CheckSelection(screen); } /* * Moves cursor down amount lines, scrolls if necessary. * Won't leave scrolling region. No carriage return. */ Index(screen, amount) register TScreen *screen; register int amount; { register int j; /* * indexing when below scrolling region is cursor down. * if cursor high enough, no scrolling necessary. */ if (screen->cur_row > screen->bot_marg || screen->cur_row + amount <= screen->bot_marg) { CursorDown(screen, amount); return; } CursorDown(screen, j = screen->bot_marg - screen->cur_row); Scroll(screen, amount - j); } /* * Moves cursor up amount lines, reverse scrolls if necessary. * Won't leave scrolling region. No carriage return. */ RevIndex(screen, amount) register TScreen *screen; register int amount; { /* * reverse indexing when above scrolling region is cursor up. * if cursor low enough, no reverse indexing needed */ if (screen->cur_row < screen->top_marg || screen->cur_row-amount >= screen->top_marg) { CursorUp(screen, amount); return; } RevScroll(screen, amount - (screen->cur_row - screen->top_marg)); CursorUp(screen, screen->cur_row - screen->top_marg); } /* * Moves Cursor To First Column In Line */ CarriageReturn(screen) register TScreen *screen; { screen->cur_col = 0; screen->do_wrap = 0; _CheckSelection(screen); } /* * Save Cursor and Attributes */ CursorSave(term, sc) register XtermWidget term; register SavedCursor *sc; { register TScreen *screen = &term->screen; sc->row = screen->cur_row; sc->col = screen->cur_col; sc->flags = term->flags; sc->curgl = screen->curgl; sc->curgr = screen->curgr; memmove( sc->gsets, screen->gsets, sizeof(screen->gsets)); } /* * Restore Cursor and Attributes */ CursorRestore(term, sc) register XtermWidget term; register SavedCursor *sc; { register TScreen *screen = &term->screen; memmove( screen->gsets, sc->gsets, sizeof(screen->gsets)); screen->curgl = sc->curgl; screen->curgr = sc->curgr; term->flags &= ~(BOLD|INVERSE|UNDERLINE|ORIGIN); term->flags |= sc->flags & (BOLD|INVERSE|UNDERLINE|ORIGIN); CursorSet (screen, (term->flags & ORIGIN) ? sc->row - screen->top_marg : sc->row, sc->col, term->flags); } kterm-6.2.0.orig/data.c100444 507 454 6135 6166126474 13403 0ustar yosiakiaux/* * $XConsortium: data.c,v 1.12 95/04/05 19:58:47 kaleb Exp $ * $Id: data.c,v 6.2 1996/07/02 05:01:31 kagotani Rel $ */ /* * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ #include "ptyx.h" /* gets Xt stuff, too */ #ifndef NO_XPOLL_H #include #endif #include "data.h" #include #ifndef KTERM_NOTEK XPoint T_boxlarge[NBOX] = { {0, 0}, {8, 0}, {0, 14}, {-8, 0}, {0, -14}, }; XPoint T_box2[NBOX] = { {0, 0}, {7, 0}, {0, 12}, {-7, 0}, {0, -12}, }; XPoint T_box3[NBOX] = { {0, 0}, {5, 0}, {0, 12}, {-5, 0}, {0, -12}, }; XPoint T_boxsmall[NBOX] = { {0, 0}, {5, 0}, {0, 9}, {-5, 0}, {0, -9}, }; jmp_buf Tekend; int Tbcnt = 0; Char *Tbuffer; Char *Tbptr; TekLink *TekRefresh; Char *Tpushb; Char *Tpushback; int Ttoggled = 0; #endif /* !KTERM_NOTEK */ int bcnt = 0; #ifdef KTERM_MBCS /* * buffer[-1] is reserved for pending_byte in two-byte character. */ static Char Vbuffer[BUF_SIZE + 1]; Char *buffer = Vbuffer + 1; Char *bptr = Vbuffer + 1; #else /* !KTERM_MBCS */ Char buffer[BUF_SIZE]; Char *bptr = buffer; #endif /* !KTERM_MBCS */ #ifndef KTERM_NOTEK jmp_buf VTend; #endif /* !KTERM_NOTEK */ XPoint VTbox[NBOX] = { {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, }; #ifdef KTERM_MBCS XPoint VTwbox[NBOX] = { {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, }; #endif /* KTERM_MBCS */ #ifdef DEBUG int debug = 0; /* true causes error messages to be displayed */ #endif /* DEBUG */ XtermWidget term; /* master data structure for client */ char *xterm_name; /* argv[0] */ int am_slave = 0; /* set to 1 if running as a slave process */ int max_plus1; fd_set Select_mask; fd_set X_mask; fd_set pty_mask; char *ptydev; char *ttydev; #ifdef ALLOWLOGGING # ifdef KTERM char log_def_name[] = "KtermLog.XXXXX"; # else /* !KTERM */ char log_def_name[] = "XtermLog.XXXXX"; # endif /* !KTERM */ #endif #ifndef KTERM_NOTEK int T_lastx = -1; int T_lasty = -1; #endif /* !KTERM_NOTEK */ int waitingForTrackInfo = 0; EventMode eventMode = NORMAL; GC visualBellGC; int VTgcFontMask = GCFont; #ifndef KTERM_NOTEK int TEKgcFontMask = GCFont; TekWidget tekWidget; #endif /* !KTERM_NOTEK */ kterm-6.2.0.orig/data.h100444 507 454 5144 6166126474 13407 0ustar yosiakiaux/* * $XConsortium: data.h /main/12 1996/01/14 16:52:48 kaleb $ * $Id: data.h,v 6.2 1996/07/02 05:01:31 kagotani Rel $ */ /* * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ #ifndef KTERM_NOTEK extern TekLink *TekRefresh; extern XPoint T_box2[]; extern XPoint T_box3[]; extern XPoint T_boxlarge[]; extern XPoint T_boxsmall[]; #endif /* !KTERM_NOTEK */ extern XPoint VTbox[]; #ifdef KTERM_MBCS extern XPoint VTwbox[]; #endif /* KTERM_MBCS */ #ifndef KTERM_NOTEK extern Char *Tbptr; extern Char *Tbuffer; extern Char *Tpushb; extern Char *Tpushback; #endif /* !KTERM_NOTEK */ extern Char *bptr; #ifdef ALLOWLOGGING extern char log_def_name[]; #endif extern char *ptydev; extern char *ttydev; extern char *xterm_name; #ifdef KTERM_MBCS extern Char *buffer; #else /* !KTERM_MBCS */ extern Char buffer[]; #endif /* !KTERM_MBCS */ #ifndef KTERM_NOTEK extern int T_lastx; extern int T_lasty; extern int Tbcnt; extern int Ttoggled; #endif /* !KTERM_NOTEK */ extern int am_slave; extern int bcnt; #ifdef DEBUG extern int debug; #endif /* DEBUG */ extern int errno; extern int max_plus1; extern int switchfb[]; extern int waitingForTrackInfo; extern EventMode eventMode; extern GC visualBellGC; extern int VTgcFontMask; #ifndef KTERM_NOTEK extern int TEKgcFontMask; #endif /* !KTERM_NOTEK */ extern XtermWidget term; #ifndef KTERM_NOTEK extern TekWidget tekWidget; #endif /* !KTERM_NOTEK */ #ifdef XKB #include #else #define XkbBI_Info 0 #define XkbBI_MinorError 1 #define XkbBI_MajorError 2 #define XkbBI_TerminalBell 9 #define XkbBI_MarginBell 10 #define XkbBI_CursorStuck 11 #endif kterm-6.2.0.orig/error.h100444 507 454 12141 5472074254 13637 0ustar yosiakiaux/* * $XConsortium: error.h,v 1.9 93/02/25 17:21:29 gildea Exp $ */ /* * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ /* @(#)error.h X10/6.6 11/6/86 */ /* main.c */ #define ERROR_KMALLOC 10 /* main: malloc() failed for keyboardtype */ #define ERROR_FIONBIO 11 /* main: ioctl() failed on FIONBIO */ #define ERROR_OPDEVTTY 14 /* spawn: open() failed on /dev/tty */ #define ERROR_TIOCGETP 15 /* spawn: ioctl() failed on TIOCGETP */ #define ERROR_TIOCGETC 16 /* spawn: ioctl() failed on TIOCGETC */ #define ERROR_TIOCGETD 17 /* spawn: ioctl() failed on TIOCGETD */ #define ERROR_TIOCGLTC 18 /* spawn: ioctl() failed on TIOCGLTC */ #define ERROR_TIOCLGET 19 /* spawn: ioctl() failed on TIOCLGET */ #define ERROR_TIOCCONS 20 /* spawn: ioctl() failed on TIOCCONS */ #define ERROR_OPDEVTTY2 21 /* spawn: second open() failed on /dev/tty */ #define ERROR_NOTTY 22 /* spawn: ioctl() failed on TIOCNOTTY */ #define ERROR_TIOCSETP 23 /* spawn: ioctl() failed on TIOCSETP */ #define ERROR_TIOCSETC 24 /* spawn: ioctl() failed on TIOCSETC */ #define ERROR_TIOCSETD 25 /* spawn: ioctl() failed on TIOCSETD */ #define ERROR_TIOCSLTC 26 /* spawn: ioctl() failed on TIOCSLTC */ #define ERROR_TIOCLSET 27 /* spawn: ioctl() failed on TIOCLSET */ #define ERROR_FORK 29 /* spawn: fork() failed */ #define ERROR_EXEC 30 /* spawn: exec() failed */ #define ERROR_OPDEVTTY3 31 /* spawn: third open() failed on /dev/tty */ #define ERROR_PTYS 32 /* get_pty: not enough ptys */ #define ERROR_NOX 33 /* get_terminal: can't connect to server */ #define ERROR_PTY_EXEC 34 /* waiting for initial map */ #define ERROR_INIT 36 /* spawn: can't initialize window */ #define ERROR_NOCO 37 /* resize: no `co' in termcap */ #define ERROR_NOLI 38 /* resize: no `li' in termcap */ #define ERROR_BORDER 39 /* get_terminal: can't make border tile */ #define ERROR_BACK 40 /* get_terminal: can't make background tile */ #define ERROR_NOX3 43 /* get_terminal: bad pty from display server */ #define ERROR_TIOCKGET 44 /* spawn: ioctl() failed on TIOCKGET */ #define ERROR_TIOCKGETC 45 /* spawn: ioctl() failed on TIOCKGETC */ #define ERROR_TIOCKSET 46 /* spawn: ioctl() failed on TIOCKSET */ #define ERROR_TIOCKSETC 47 /* spawn: ioctl() failed on TIOCKSETC */ /* charproc.c */ #define ERROR_SELECT 50 /* in_put: select() failed */ #define ERROR_VINIT 54 /* VTInit: can't initialize window */ #define ERROR_CNMALLOC1 55 /* Changename: malloc failed */ #define ERROR_CNMALLOC2 56 /* Changename: malloc failed */ /* Tekproc.c */ #define ERROR_TSELECT 60 /* Tinput: select() failed */ #define ERROR_TINIT 64 /* TekInit: can't initialize window */ #define ERROR_TBACK 65 /* TekBackground: can't make background */ /* button.c */ #define ERROR_BMALLOC2 71 /* SaltTextAway: malloc() failed */ /* misc.c */ #ifdef ALLOWLOGGING #ifdef ALLOWLOGFILEEXEC #define ERROR_LOGEXEC 80 /* StartLog: exec() failed */ #endif #endif #define ERROR_XERROR 83 /* xerror: XError event */ #define ERROR_XIOERROR 84 /* xioerror: X I/O error */ #define ERROR_WINNAME 85 /* get_terminal: malloc failed */ /* screen.c */ #define ERROR_SCALLOC 90 /* Alloc: calloc() failed on base */ #define ERROR_SCALLOC2 91 /* Alloc: calloc() failed on rows */ #define ERROR_SREALLOC 92 /* ScreenResize: realloc() failed on alt base */ #define ERROR_SREALLOC2 93 /* ScreenResize: realloc() failed on alt rows */ #define ERROR_SREALLOC3 94 /* ScreenResize: realloc() failed on rows */ #define ERROR_SREALLOC4 95 /* ScreenResize: realloc() failed on rows */ #define ERROR_RESIZE 96 /* ScreenResize: malloc() or realloc() failed */ #define ERROR_RESIZE2 97 /* ScreenResize: malloc() or realloc() failed */ #define ERROR_RESIZROW 98 /* ScreenResize: realloc() failed on alt char */ #define ERROR_RESIZROW2 99 /* ScreenResize: realloc() failed on alt attr */ #define ERROR_RESIZROW3 100 /* ScreenResize: realloc() failed on attr */ #define ERROR_RESIZROW4 101 /* ScreenResize: realloc() failed on attr */ /* scrollbar.c */ #define ERROR_SBRALLOC 110 /* ScrollBarOn: realloc() failed on base */ #define ERROR_SBRALLOC2 111 /* ScrollBarOn: realloc() failed on rows */ /* util.c */ #define ERROR_UBACK 120 /* ReverseVideo: can't make background */ kterm-6.2.0.orig/gset.c100444 507 454 20625 6171356064 13450 0ustar yosiakiaux/* * $Id: gset.c,v 1.3 1996/07/02 05:01:31 kagotani Rel $ */ /* * Copyright (c) 1996 * XXI working group in Japan Unix Society (XXI). * * The X Consortium, and any party obtaining a copy of these files from * the X Consortium, directly or indirectly, is granted, free of charge, a * full and unrestricted irrevocable, world-wide, paid up, royalty-free, * nonexclusive right and license to deal in this software and * documentation files (the "Software"), including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons who receive * copies from any such party to do so. This license includes without * limitation a license to do the foregoing actions under any patents of * the party supplying this software to the X Consortium. * * Author: * Hiroto Kagotani * Department of Information Technology * Okayama University * 3-1-1 Tsushima-Naka, Okayama-shi 700, Japan * kagotani@in.it.okayama-u.ac.jp */ #include "ptyx.h" #include "data.h" int gsettofnum[256]; Boolean gsetontheright[256]; Char *gsetmaponfont[256]; static Char irv[128]; static Char uk[128]; static Char swedish[128]; static Char norwegian[128]; static Char german[128]; static Char french[128]; static Char italian[128]; static Char spanish[128]; void setupgset() { int i; for (i = 0; i < 128; i ++) { irv[i] = uk[i] = swedish[i] = norwegian[i] = german[i] = french[i] = italian[i] = spanish[i] = i; } gsettofnum[GSET_GRAPH] = F_ISO8859_1; gsetontheright[GSET_GRAPH] = False; gsettofnum[GSET_IRV] = F_ISO8859_1; gsetontheright[GSET_IRV] = False; gsetmaponfont[GSET_IRV] = irv; irv['$'] = '\244'; /* currency sign */ irv['~'] = '\257'; /* macron */ gsettofnum[GSET_UK] = F_ISO8859_1; gsetontheright[GSET_UK] = False; gsetmaponfont[GSET_UK] = uk; uk['#'] = '\243'; /* pound sign */ uk['~'] = '\257'; /* macron */ gsettofnum[GSET_ASCII] = F_ISO8859_1; gsetontheright[GSET_ASCII] = False; gsettofnum[GSET_SWEDISH] = F_ISO8859_1; gsetontheright[GSET_SWEDISH] = False; gsetmaponfont[GSET_SWEDISH] = swedish; swedish['@'] = '\311'; /* capital letter E with acute accent */ swedish['['] = '\304'; /* capital letter A with diaeresis */ swedish['\\']= '\326'; /* capital letter O with diaeresis */ swedish[']'] = '\305'; /* capital letter A with ring above */ swedish['^'] = '\334'; /* capital letter U with diaeresis */ swedish['`'] = '\351'; /* small letter e with acute accent */ swedish['{'] = '\344'; /* small letter a with diaeresis */ swedish['|'] = '\366'; /* small letter o with diaeresis */ swedish['}'] = '\345'; /* small letter a with ring above */ swedish['~'] = '\374'; /* small letter u with diaeresis */ gsettofnum[GSET_NORWEGIAN] = F_ISO8859_1; gsetontheright[GSET_NORWEGIAN] = False; gsetmaponfont[GSET_NORWEGIAN] = norwegian; norwegian['['] = '\306';/* capital diphthong A with E */ norwegian['\\']= '\330';/* capital letter O with oblique stroke */ norwegian[']'] = '\305';/* capital letter A with ring above */ norwegian['^'] = '\334';/* capital letter U with diaeresis */ norwegian['{'] = '\346';/* small diphthong e with e */ norwegian['|'] = '\370';/* small letter o with oblique stroke */ norwegian['}'] = '\345';/* small letter a with ring above */ norwegian['~'] = '\374';/* small letter u with diaeresis */ gsettofnum[GSET_GERMAN] = F_ISO8859_1; gsetontheright[GSET_GERMAN] = False; gsetmaponfont[GSET_GERMAN] = german; german['@'] = '\247'; /* paragraph sign, section sign */ german['['] = '\304'; /* capital letter A with diaeresis */ german['\\']= '\326'; /* capital letter O with diaeresis */ german[']'] = '\334'; /* capital letter U with diaeresis */ german['{'] = '\344'; /* small letter a with diaeresis */ german['|'] = '\366'; /* small letter o with diaeresis */ german['}'] = '\374'; /* small letter u with diaeresis */ german['~'] = '\337'; /* small german letter sharp s */ gsettofnum[GSET_FRENCH] = F_ISO8859_1; gsetontheright[GSET_FRENCH] = False; gsetmaponfont[GSET_FRENCH] = french; french['#'] = '\243'; /* pound sign */ french['@'] = '\340'; /* small letter a with grave accent */ french['['] = '\260'; /* ring above, degree sign */ french['\\']= '\347'; /* small letter c with cedilla */ french[']'] = '\247'; /* paragraph sign, section sign */ french['{'] = '\351'; /* small letter e with acute accent */ french['|'] = '\371'; /* small letter u with grave accent */ french['}'] = '\350'; /* small letter e with grave accent */ french['~'] = '\250'; /* diaeresis */ gsettofnum[GSET_ITALIAN] = F_ISO8859_1; gsetontheright[GSET_ITALIAN] = False; gsetmaponfont[GSET_ITALIAN] = italian; italian['#'] = '\243'; /* pound sign */ italian['@'] = '\247'; /* paragraph sign, section sign */ italian['['] = '\260'; /* ring above, degree sign */ italian['\\']= '\347'; /* small letter c with cedilla */ italian[']'] = '\351'; /* small letter e with acute accent */ italian['`'] = '\371'; /* small letter u with grave accent */ italian['{'] = '\340'; /* small letter a with grave accent */ italian['|'] = '\362'; /* small letter o with grave accent */ italian['}'] = '\350'; /* small letter e with grave accent */ italian['~'] = '\354'; /* small letter i with grave accent */ gsettofnum[GSET_SPANISH] = F_ISO8859_1; gsetontheright[GSET_SPANISH] = False; gsetmaponfont[GSET_SPANISH] = spanish; spanish['#'] = '\243'; /* pound sign */ spanish['@'] = '\247'; /* paragraph sign, section sign */ spanish['['] = '\241'; /* inverted exclamation mark */ spanish['\\']= '\321'; /* capital letter N with tilde */ spanish[']'] = '\277'; /* inverted question mark */ spanish['{'] = '\260'; /* ring above, degree sign */ spanish['|'] = '\361'; /* small letter n with tilde */ spanish['}'] = '\347'; /* small letter c with cedilla */ gsettofnum[GSET_LATIN1R] = F_ISO8859_1; gsetontheright[GSET_LATIN1R] = True; gsettofnum[GSET_LATIN2R] = F_ISO8859_2; gsetontheright[GSET_LATIN2R] = True; gsettofnum[GSET_LATIN3R] = F_ISO8859_3; gsetontheright[GSET_LATIN3R] = True; gsettofnum[GSET_LATIN4R] = F_ISO8859_4; gsetontheright[GSET_LATIN4R] = True; gsettofnum[GSET_CYRILLIC] = F_ISO8859_5; gsetontheright[GSET_CYRILLIC] = True; gsettofnum[GSET_ARABIC] = F_ISO8859_6; gsetontheright[GSET_ARABIC] = True; gsettofnum[GSET_GREEK] = F_ISO8859_7; gsetontheright[GSET_GREEK] = True; gsettofnum[GSET_HEBREW] = F_ISO8859_8; gsetontheright[GSET_HEBREW] = True; gsettofnum[GSET_LATIN5R] = F_ISO8859_9; gsetontheright[GSET_LATIN5R] = True; gsettofnum[GSET_JISROMAN] = F_JISX0201_0; gsetontheright[GSET_JISROMAN] = False; gsettofnum[GSET_KANA] = F_JISX0201_0; gsetontheright[GSET_KANA] = True; # ifdef KTERM_MBCS gsettofnum[GSET_OLDKANJI] = F_JISC6226_0; gsetontheright[GSET_OLDKANJI] = False; gsettofnum[GSET_KANJI] = F_JISX0208_0; gsetontheright[GSET_KANJI] = False; gsettofnum[GSET_HOJOKANJI] = F_JISX0212_0; gsetontheright[GSET_HOJOKANJI] = False; gsettofnum[GSET_HANZI] = F_GB2312_0; gsetontheright[GSET_HANZI] = False; gsettofnum[GSET_HANJA] = F_KSC5601_0; gsetontheright[GSET_HANJA] = False; # endif /* KTERM_MBCS */ } void set_vt_box_per_gset(screen) TScreen *screen; { screen->_box[F_ISO8859_1] = VTbox; screen->_box[F_ISO8859_2] = VTbox; screen->_box[F_ISO8859_3] = VTbox; screen->_box[F_ISO8859_4] = VTbox; screen->_box[F_ISO8859_5] = VTbox; screen->_box[F_ISO8859_6] = VTbox; screen->_box[F_ISO8859_7] = VTbox; screen->_box[F_ISO8859_8] = VTbox; screen->_box[F_ISO8859_9] = VTbox; screen->_box[F_JISX0201_0] = VTbox; #ifdef KTERM_MBCS screen->_box[F_JISX0208_0] = VTwbox; screen->_box[F_JISX0212_0] = VTwbox; screen->_box[F_GB2312_0] = VTwbox; screen->_box[F_KSC5601_0] = VTwbox; screen->_box[F_JISC6226_0] = VTwbox; #endif /* KTERM_MBCS */ } char ** csnames(fnum) int fnum; { static char *csnameslist[FCNT][3] = { {"iso8859-1"}, /* F_ISO8859_1 */ {"iso8859-2"}, /* F_ISO8859_2 */ {"iso8859-3"}, /* F_ISO8859_3 */ {"iso8859-4"}, /* F_ISO8859_4 */ {"iso8859-5"}, /* F_ISO8859_5 */ {"iso8859-6"}, /* F_ISO8859_6 */ {"iso8859-7"}, /* F_ISO8859_7 */ {"iso8859-8"}, /* F_ISO8859_8 */ {"iso8859-9"}, /* F_ISO8859_9 */ {"jisx0201.1976-0"}, /* F_JISX0201_0 */ #ifdef KTERM_MBCS {"jisx0208.1990-0", "jisx0208.1983-0"}, /* F_JISX0208_0 */ {"jisx0212.1990-0"}, /* F_JISX0212_0 */ {"gb2312.1980-0"}, /* F_GB2312_0 */ {"ksc5601.1987-0"}, /* F_KSC5601_0 */ {"jisc6226.1978-0", "jisx0208.1983-0"}, /* F_JISC6226_0 */ #endif /* KTERM_MBCS */ }; return csnameslist[fnum]; } kterm-6.2.0.orig/gset.h100444 507 454 5611 6171356065 13434 0ustar yosiakiaux/* * $Id: gset.h,v 1.3 1996/06/23 08:00:09 kagotani Rel $ */ /* * Copyright (c) 1996 * XXI working group in Japan Unix Society (XXI). * * The X Consortium, and any party obtaining a copy of these files from * the X Consortium, directly or indirectly, is granted, free of charge, a * full and unrestricted irrevocable, world-wide, paid up, royalty-free, * nonexclusive right and license to deal in this software and * documentation files (the "Software"), including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons who receive * copies from any such party to do so. This license includes without * limitation a license to do the foregoing actions under any patents of * the party supplying this software to the X Consortium. * * Author: * Hiroto Kagotani * Department of Information Technology * Okayama University * 3-1-1 Tsushima-Naka, Okayama-shi 700, Japan * kagotani@in.it.okayama-u.ac.jp */ #define CS96 0x80 /* character sets which have 96 characters */ #define MBCS 0x40 /* multi-byte character sets */ #define MBC2 0x7f /* second byte of a mbcs character */ /* * No character set uses designating characters less than '/'. * Final characters more than 'n' can not be used in current kterm. */ #define GSET(c) ((c) - '/') #define GSETFC(i) (((i) & ~(MBCS|CS96)) + '/') /* final character of a designation sequense for a gset */ /* code of Ichr,Bchr */ #define GSET_GRAPH GSET('0') #define GSET_IRV GSET('@') #define GSET_UK GSET('A') #define GSET_ASCII GSET('B') #define GSET_SWEDISH GSET('C') #define GSET_NORWEGIAN GSET('E') #define GSET_KANA GSET('I') #define GSET_JISROMAN GSET('J') #define GSET_GERMAN GSET('K') #define GSET_FRENCH GSET('R') #define GSET_ITALIAN GSET('Y') #define GSET_SPANISH GSET('Z') #define GSET_LATIN1R (CS96|GSET('A')) #define GSET_LATIN2R (CS96|GSET('B')) #define GSET_LATIN3R (CS96|GSET('C')) #define GSET_LATIN4R (CS96|GSET('D')) #define GSET_CYRILLIC (CS96|GSET('L')) #define GSET_ARABIC (CS96|GSET('G')) #define GSET_GREEK (CS96|GSET('F')) #define GSET_HEBREW (CS96|GSET('H')) #define GSET_LATIN5R (CS96|GSET('M')) #ifdef KTERM_MBCS # define GSET_OLDKANJI (MBCS|GSET('@')) # define GSET_HANZI (MBCS|GSET('A')) # define GSET_KANJI (MBCS|GSET('B')) # define GSET_HANJA (MBCS|GSET('C')) # define GSET_HOJOKANJI (MBCS|GSET('D')) #endif /* KTERM_MBCS */ #define F_ISO8859_1 0 #define F_ISO8859_2 1 #define F_ISO8859_3 2 #define F_ISO8859_4 3 #define F_ISO8859_5 4 #define F_ISO8859_6 5 #define F_ISO8859_7 6 #define F_ISO8859_8 7 #define F_ISO8859_9 8 #define F_JISX0201_0 9 #ifdef KTERM_MBCS # define F_JISX0208_0 10 # define F_JISX0212_0 11 # define F_GB2312_0 12 # define F_KSC5601_0 13 # define F_JISC6226_0 14 # define FCNT 15 #else # define FCNT 10 #endif extern int gsettofnum[]; extern Boolean gsetontheright[]; extern Char *gsetmaponfont[]; kterm-6.2.0.orig/input.c100444 507 454 21475 6171356060 13645 0ustar yosiakiaux/* * $XConsortium: input.c /main/20 1996/01/14 16:52:52 kaleb $ * $Id: input.c,v 6.4 1996/07/12 05:01:34 kagotani Rel $ */ /* * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ /* input.c */ #include "ptyx.h" /* gets Xt headers, too */ #include #include #include #include #include "data.h" static char *kypd_num = " XXXXXXXX\tXXX\rXXXxxxxXXXXXXXXXXXXXXXXXXXXX*+,-./0123456789XXX="; static char *kypd_apl = " ABCDEFGHIJKLMNOPQRSTUVWXYZ??????abcdefghijklmnopqrstuvwxyzXXX"; static char *cur = "DACB"; static int funcvalue(), sunfuncvalue(); extern Boolean sunFunctionKeys; static void AdjustAfterInput (screen) register TScreen *screen; { if(screen->scrollkey && screen->topline != 0) WindowScroll(screen, 0); if(screen->marginbell) { int col = screen->max_col - screen->nmarginbell; if(screen->bellarmed >= 0) { if(screen->bellarmed == screen->cur_row) { if(screen->cur_col >= col) { Bell(XkbBI_MarginBell,0); screen->bellarmed = -1; } } else screen->bellarmed = screen->cur_col < col ? screen->cur_row : -1; } else if(screen->cur_col < col) screen->bellarmed = screen->cur_row; } } Input (keyboard, screen, event, eightbit) register TKeyboard *keyboard; register TScreen *screen; register XKeyEvent *event; Bool eightbit; { #ifdef KTERM #define STRBUFSIZE 256 char _strbuf[STRBUFSIZE+1]; char *strbuf = &_strbuf[1]; #else /* !KTERM */ #define STRBUFSIZE 100 char strbuf[STRBUFSIZE]; #endif /* !KTERM */ register char *string; register int key = FALSE; int pty = screen->respond; int nbytes; KeySym keysym = 0; ANSI reply; Status status_return; #ifdef KTERM if (!screen->xic) { nbytes = XmuLookupKana (event, strbuf, STRBUFSIZE, &keysym, NULL); if (keysym>>8 == 4 && keysym & 0x80 && nbytes == 1) { /* fake ja_JP.eucJP & @im=none */ strbuf[-1] = SS2; nbytes ++; string = &strbuf[-1]; } else { string = &strbuf[0]; } } else { #endif /* KTERM */ nbytes = XmbLookupString (screen->xic, event, strbuf, STRBUFSIZE, &keysym, &status_return); string = &strbuf[0]; #ifdef KTERM } #endif /* KTERM */ reply.a_pintro = 0; reply.a_final = 0; reply.a_nparam = 0; reply.a_inters = 0; if (keysym >= XK_KP_Home && keysym <= XK_KP_Begin) { keysym += XK_Home - XK_KP_Home; } if (IsPFKey(keysym)) { reply.a_type = SS3; unparseseq(&reply, pty); unparseputc((char)(keysym-XK_KP_F1+'P'), pty); key = TRUE; } else if (IsCursorKey(keysym) && keysym != XK_Prior && keysym != XK_Next) { if (keyboard->flags & CURSOR_APL) { reply.a_type = SS3; unparseseq(&reply, pty); unparseputc(cur[keysym-XK_Left], pty); } else { reply.a_type = CSI; reply.a_final = cur[keysym-XK_Left]; unparseseq(&reply, pty); } key = TRUE; } else if (IsFunctionKey(keysym) || IsMiscFunctionKey(keysym) || keysym == XK_Prior || keysym == XK_Next || keysym == DXK_Remove || keysym == XK_KP_Delete || keysym == XK_KP_Insert) { reply.a_type = CSI; reply.a_nparam = 1; if (sunFunctionKeys) { reply.a_param[0] = sunfuncvalue (keysym); reply.a_final = 'z'; } else { reply.a_param[0] = funcvalue (keysym); reply.a_final = '~'; } if (reply.a_param[0] > 0) unparseseq(&reply, pty); key = TRUE; } else if (IsKeypadKey(keysym)) { if (keyboard->flags & KYPD_APL) { reply.a_type = SS3; unparseseq(&reply, pty); unparseputc(kypd_apl[keysym-XK_KP_Space], pty); } else unparseputc(kypd_num[keysym-XK_KP_Space], pty); key = TRUE; } else if (nbytes > 0) { #ifndef KTERM_NOTEK if(screen->TekGIN) { TekEnqMouse(*string++); TekGINoff(); nbytes--; } #endif /* !KTERM_NOTEK */ #ifdef KTERM if (nbytes == 1) { if (eightbit) { if (screen->input_eight_bits) *string |= 0x80; /* turn on eighth bit */ else unparseputc (033, pty); /* escape */ } unparseputc(*string, pty); } else { extern int convEUCtoJIS(), convEUCtoSJIS(); extern XtermWidget term; Char outbuf[STRBUFSIZE]; Char *obuf, *optr; int n, (*func)(); if (term->flags & EUC_KANJI) { while (nbytes-- > 0) unparseputc(*string++, pty); } else { if (term->flags & SJIS_KANJI) { func = convEUCtoSJIS; } else { func = convEUCtoJIS; } string[nbytes] = '\0'; n = (*func)(string, NULL); obuf = (n > STRBUFSIZE) ? (Char *)XtMalloc(n + 1) : outbuf; (void)(*func)(string, obuf); optr = obuf; while (*optr) unparseputc(*optr++, pty); if (obuf != outbuf) XtFree((char *)obuf); } } #else /* !KTERM */ if ((nbytes == 1) && eightbit) { if (screen->input_eight_bits) *string |= 0x80; /* turn on eighth bit */ else unparseputc (033, pty); /* escape */ } while (nbytes-- > 0) unparseputc(*string++, pty); #endif /* !KTERM */ key = TRUE; } #ifdef KTERM_NOTEK if(key) #else /* !KTERM_NOTEK */ if(key && !screen->TekEmu) #endif /* !KTERM_NOTEK */ AdjustAfterInput(screen); #ifndef KTERM_NOTEK #ifdef ENABLE_PRINT if (keysym == XK_F2) TekPrint(); #endif #endif /* !KTERM_NOTEK */ return; } StringInput (screen, string, nbytes) register TScreen *screen; register char *string; int nbytes; { int pty = screen->respond; #ifndef KTERM_NOTEK if(nbytes && screen->TekGIN) { TekEnqMouse(*string++); TekGINoff(); nbytes--; } #endif /* !KTERM_NOTEK */ while (nbytes-- > 0) unparseputc(*string++, pty); #ifndef KTERM_NOTEK if(!screen->TekEmu) #endif /* !KTERM_NOTEK */ AdjustAfterInput(screen); } static int funcvalue (keycode) int keycode; { switch (keycode) { case XK_F1: return(11); case XK_F2: return(12); case XK_F3: return(13); case XK_F4: return(14); case XK_F5: return(15); case XK_F6: return(17); case XK_F7: return(18); case XK_F8: return(19); case XK_F9: return(20); case XK_F10: return(21); case XK_F11: return(23); case XK_F12: return(24); case XK_F13: return(25); case XK_F14: return(26); case XK_F15: return(28); case XK_Help: return(28); case XK_F16: return(29); case XK_Menu: return(29); case XK_F17: return(31); case XK_F18: return(32); case XK_F19: return(33); case XK_F20: return(34); case XK_Find : return(1); case XK_Insert: return(2); case XK_KP_Insert: return(2); case XK_Delete: return(3); case XK_KP_Delete: return(3); case DXK_Remove: return(3); case XK_Select: return(4); case XK_Prior: return(5); case XK_Next: return(6); default: return(-1); } } static int sunfuncvalue (keycode) int keycode; { switch (keycode) { case XK_F1: return(224); case XK_F2: return(225); case XK_F3: return(226); case XK_F4: return(227); case XK_F5: return(228); case XK_F6: return(229); case XK_F7: return(230); case XK_F8: return(231); case XK_F9: return(232); case XK_F10: return(233); case XK_F11: return(192); case XK_F12: return(193); case XK_F13: return(194); case XK_F14: return(195); case XK_F15: return(196); case XK_Help: return(196); case XK_F16: return(197); case XK_Menu: return(197); case XK_F17: return(198); case XK_F18: return(199); case XK_F19: return(200); case XK_F20: return(201); case XK_R1: return(208); case XK_R2: return(209); case XK_R3: return(210); case XK_R4: return(211); case XK_R5: return(212); case XK_R6: return(213); case XK_R7: return(214); case XK_R8: return(215); case XK_R9: return(216); case XK_R10: return(217); case XK_R11: return(218); case XK_R12: return(219); case XK_R13: return(220); case XK_R14: return(221); case XK_R15: return(222); case XK_Find : return(1); case XK_Insert: return(2); case XK_KP_Insert: return(2); case XK_Delete: return(3); case XK_KP_Delete: return(3); case DXK_Remove: return(3); case XK_Select: return(4); case XK_Prior: return(5); case XK_Next: return(6); default: return(-1); } } kterm-6.2.0.orig/kinput2.c100444 507 454 22525 6171356066 14105 0ustar yosiakiaux/* $Id: kinput2.c,v 6.0 1996/07/12 05:01:39 kagotani Rel $ */ /* * Copyright (c) 1989 Software Research Associates, Inc. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Software Research Associates not be * used in advertising or publicity pertaining to distribution of the * software without specific, written prior permission. Software Research * Associates makes no representations about the suitability of this software * for any purpose. It is provided "as is" without express or implied * warranty. * * Author: Makoto Ishisone, Software Research Associates, Inc., Japan * ishisone@sra.co.jp */ #include #include #include #include #include #include #include #include #include #include #include "ptyx.h" #include "data.h" extern int _beginConversionWithAttributes(); extern void _changeConversionAttributes(); extern int convCTtoCS(); extern int convCStoEUC(); extern int convCStoSJIS(); extern int convCStoJIS(); static Atom japanese_conversion_atom; /* JAPANESE_CONVERSION */ static Atom compound_text_atom; /* COMPOUND_TEXT */ static int atominitialized; static int (*originalerrorhandler)(); static Atom converting = None; static Window forwardwin = None; static XEvent *event_queue; static int queue_event; static int queue_end; static struct kcres { Boolean forwardevent; Boolean keypressonly; int queuesize; } kcr; static XtResource resources[] = { { "forwardKeyEvent", "ForwardKeyEvent", XtRBoolean, sizeof(Boolean), XtOffsetOf(struct kcres, forwardevent), XtRImmediate, (XtPointer)True }, { "forwardKeyPressOnly", "ForwardKeyPressOnly", XtRBoolean, sizeof(Boolean), XtOffsetOf(struct kcres, keypressonly), XtRImmediate, (XtPointer)True }, { "forwardQueueSize", "ForwardQueueSize", XtRInt, sizeof(int), XtOffsetOf(struct kcres, queuesize), XtRImmediate, (XtPointer)32 }, }; static void flushEventQueue(dpy, win) Display *dpy; Window win; { int i; for (i = 0; i < queue_end; i++) { XEvent *ev = &event_queue[i]; ev->xkey.window = forwardwin; XSendEvent(dpy, win, False, 0L, ev); } queue_end = 0; } static void clearEventQueue() { queue_end = 0; } /* ARGSUSED */ static void forwardKeyEvent(w, cldata, ev, continuep) Widget w; XtPointer cldata; XEvent *ev; Boolean *continuep; { if (ev->xany.send_event) return; if (forwardwin != None) { /* send the event to IMS */ *continuep = False; if (ev->type == KeyPress || !kcr.keypressonly) { ev->xkey.window = forwardwin; XSendEvent(XtDisplay(w), forwardwin, False, 0L, ev); } } else if (queue_event) { *continuep = False; if (ev->type == KeyPress || !kcr.keypressonly) { event_queue[queue_end++] = *ev; if (queue_end >= kcr.queuesize) queue_event = 0; } } } static int forwardErrorHandler(dpy, error) Display *dpy; XErrorEvent *error; { if (error->request_code == X_SendEvent && error->error_code == BadWindow) { /* IMS dead */ forwardwin = None; queue_event = 0; } else { (*originalerrorhandler)(dpy, error); } } static void initializeForwarding(w) Widget w; { XtGetApplicationResources(w, (XtPointer)&kcr, resources, XtNumber(resources), (ArgList)NULL, 0); if (!kcr.forwardevent) return; XtInsertEventHandler(w, KeyPressMask|KeyReleaseMask, False, forwardKeyEvent, NULL, XtListHead); originalerrorhandler = XSetErrorHandler(forwardErrorHandler); if (kcr.queuesize < 0) kcr.queuesize = 0; if (kcr.queuesize > 0) { event_queue = (XEvent *)XtMalloc(kcr.queuesize * sizeof(XEvent)); } } /* ARGSUSED */ static void inputString(w, selection, type, format, size, str, client_data) Widget w; Atom selection; Atom type; int format; unsigned long size; unsigned char *str; caddr_t client_data; { unsigned char lbuf[256 + 1]; unsigned char *lstr, *p, *lp; int n; int (*convfunc)(); int pty = ((XtermWidget)w)->screen.respond; if (str == NULL) return; if (type == compound_text_atom && format == 8) { Ichr cbuf[256 + 1]; Ichr *cs; n = convCTtoCS(str, size, NULL); cs = (n > 256) ? (Ichr *)XtMalloc((n+1) * sizeof(Ichr)) : cbuf; (void)convCTtoCS(str, size, cs); if (term->flags & EUC_KANJI) convfunc = convCStoEUC; else if (term->flags & SJIS_KANJI) convfunc = convCStoSJIS; else convfunc = convCStoJIS; n = (*convfunc)(cs, NULL); lstr = (n > 256) ? (unsigned char *)XtMalloc(n + 1) : lbuf; (void)(*convfunc)(cs, lstr); if (cs != cbuf) XtFree((char *)cs); } else { /* ignore unknown type */ XtFree((char *)str); return; } /* * Hack: (since Compound Text can't send carriage return) * change each newline into carriage return. */ for (p = lp = lstr; *p; p++) { if (*p != '\n' && *p != '\r') continue; *p = '\r'; v_write(pty, lp, p - lp + 1); lp = p + 1; } if (lp != p) v_write(pty, lp, p - lp); XtFree((char *)str); if (lstr != lbuf) XtFree((char *)lstr); } /* ARGSUSED */ static void startendProc(w, selection, state, client_data, forward) Widget w; Atom selection; int state; caddr_t client_data; Window forward; { if (state == 0) { /* start */ converting = selection; forwardwin = forward; if (queue_event) flushEventQueue(XtDisplay(w), forwardwin); } else { /* end or fail */ converting = None; forwardwin = None; } queue_event = 0; clearEventQueue(); } Boolean Kinput2UnderConversion() { return (converting != None); } static void setSpot(arg_p) Arg *arg_p; { TScreen *screen = &term->screen; Position x, y; x = CursorX(screen, screen->cur_col); y = CursorY(screen, screen->cur_row) + screen->max_ascent; XtSetArg(arg_p[0], "spotX", x); XtSetArg(arg_p[1], "spotY", y); } void Kinput2SendSpot() { Arg arg[2]; Position x, y; if (converting == None) return; setSpot(&arg[0]); _changeConversionAttributes(term, converting, arg, 2); } static void setColor(arg_p) Arg *arg_p; { TScreen *screen = &term->screen; XtSetArg(arg_p[0], "foreground", screen->foreground); XtSetArg(arg_p[1], "background", term->core.background_pixel); } void Kinput2SendColor() { Arg arg[2]; if (converting == None) return; setColor(&arg[0]); _changeConversionAttributes(term, converting, arg, 2); } static void setSize(arg_p) Arg *arg_p; { TScreen *screen = &term->screen; static XRectangle area; area.x = screen->border + screen->scrollbar; area.y = screen->border; area.width = Width(screen); area.height = Height(screen); XtSetArg(arg_p[0], "clientArea", &area); } void Kinput2SendSize() { Arg arg[1]; XRectangle area; if (converting == None) return; setSize(&arg[0]); _changeConversionAttributes(term, converting, arg, 1); } static int setFonts(arg_p) Arg *arg_p; { TScreen *screen = &term->screen; static XFontStruct *fonts[FCNT + 1]; int nfonts = 0; if (!screen->_fnt_norm[F_ISO8859_1]) LoadOneFont(screen, True, screen->menu_font_number, F_ISO8859_1, False); if (!screen->_fnt_norm[F_JISX0201_0]) LoadOneFont(screen, True, screen->menu_font_number, F_JISX0201_0, False); if (!screen->_fnt_norm[F_JISX0208_0]) LoadOneFont(screen, True, screen->menu_font_number, F_JISX0208_0, False); if (screen->_fnt_norm[F_ISO8859_1]) fonts[nfonts++] = screen->_fnt_norm[F_ISO8859_1]; if (screen->_fnt_norm[F_JISX0201_0]) fonts[nfonts++] = screen->_fnt_norm[F_JISX0201_0]; if (screen->_fnt_norm[F_JISX0208_0]) fonts[nfonts++] = screen->_fnt_norm[F_JISX0208_0]; fonts[nfonts] = NULL; if (nfonts > 0) { XtSetArg(arg_p[0], "fonts", fonts); } return nfonts; } void Kinput2SendFonts() { Arg arg[1]; if (converting == None) return; if (setFonts(&arg[0]) > 0) { _changeConversionAttributes(term, converting, arg, 1); } } /* ARGSUSED */ void HandleBeginConversion(w, event, params, nparams) Widget w; XEvent *event; String *params; Cardinal *nparams; { Atom catom; Arg arg[10]; Cardinal i; Position x, y; int spacing; XRectangle area; TScreen *screen = &term->screen; Cardinal nfonts, j; XFontStruct *fonts[FCNT + 1]; #ifdef KTERM_XIM if (screen->imregistered) { Bell(XkbBI_MinorError,0); return; } #endif /* KTERM_XIM */ if (!atominitialized) { japanese_conversion_atom = XInternAtom(XtDisplay(w), "_JAPANESE_CONVERSION", False); compound_text_atom = XInternAtom(XtDisplay(w), "COMPOUND_TEXT", False); atominitialized = 1; initializeForwarding(w); } if (*nparams != 1) { catom = japanese_conversion_atom; } else { XmuInternStrings(XtDisplay(w), params, 1, &catom); } i = 0; XtSetArg(arg[i], "inputStyle", "over"); i++; setSpot(&arg[i]); i++; i++; setColor(&arg[i]); i++; i++; XtSetArg(arg[i], "lineSpacing", FontHeight(screen)); i++; if (setFonts(&arg[i]) > 0) i++; setSize(&arg[i]); i++; if (kcr.forwardevent) { queue_event = (kcr.queuesize > 0); clearEventQueue(); XtSetArg(arg[i], "eventCaptureMethod", "none"); i++; } if (_beginConversionWithAttributes(w, catom, compound_text_atom, inputString, startendProc, (XtPointer)NULL, arg, i) < 0) { queue_event = 0; } } kterm-6.2.0.orig/kterm.h100444 507 454 3054 6171356061 13607 0ustar yosiakiaux/* * $Id: kterm.h,v 6.5 1996/07/12 05:01:34 kagotani Rel $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, and 1996 * XXI working group in Japan Unix Society (XXI). * * The X Consortium, and any party obtaining a copy of these files from * the X Consortium, directly or indirectly, is granted, free of charge, a * full and unrestricted irrevocable, world-wide, paid up, royalty-free, * nonexclusive right and license to deal in this software and * documentation files (the "Software"), including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons who receive * copies from any such party to do so. This license includes without * limitation a license to do the foregoing actions under any patents of * the party supplying this software to the X Consortium. * * Author: * Hiroto Kagotani * Department of Information Technology * Okayama University * 3-1-1 Tsushima-Naka, Okayama-shi 700, Japan * kagotani@in.it.okayama-u.ac.jp */ #ifndef _KTERM_H_ #define _KTERM_H_ #define KTERM_VERSION "6.2.0" #define KTERM_MBCS /* multi-byte character set */ #define KTERM_MBCC /* multi-byte character class for word selection */ #define KTERM_KANJIMODE /* euc/sjis Kanji modes */ #define KTERM_XIM /* XIM protocol */ #define KTERM_KINPUT2 /* Kinput2 protocol */ #define KTERM_COLOR /* color sequence */ #define KTERM_NOTEK /* disables Tektronix emulation */ #undef KTERM_XAW3D /* Xaw3d -DARROW_SCROLLBAR support */ #endif /* !_KTERM_H_ */ kterm-6.2.0.orig/kterm.jman100444 507 454 32154 6171356061 14330 0ustar yosiakiaux.\" $Id: kterm.jman,v 6.4 1996/07/12 05:01:34 kagotani Rel $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993 and 1994 .\" XXI working group in Japan Unix Society (XXI). .\" .\" The X Consortium, and any party obtaining a copy of these files from .\" the X Consortium, directly or indirectly, is granted, free of charge, a .\" full and unrestricted irrevocable, world-wide, paid up, royalty-free, .\" nonexclusive right and license to deal in this software and .\" documentation files (the "Software"), including without limitation the .\" rights to use, copy, modify, merge, publish, distribute, sublicense, .\" and/or sell copies of the Software, and to permit persons who receive .\" copies from any such party to do so. This license includes without .\" limitation a license to do the foregoing actions under any patents of .\" the party supplying this software to the X Consortium. .\" " .TH KTERM 1 "12 July 1996" "X Version 11" .SH NAME kterm \- $BB?9q8lMQ(B X $BCJ}$rMxMQ$9$k$3$H$,$G$-$^$9!#>\$7$/$O(B USING XIM $B$H(B USING KINPUT2 $B$N@a$r;2>H$7$F$/$@$5$$!#(B .PP .SH OPTIONS \fIkterm\fP $B$O!"(B\fIxterm\fP(1) $B$N%3%^%s%I%i%$%s%*%W%7%g%s$K2C$(!"(B $B0J2<$N%*%W%7%g%s$ro$N(B($B%\!<%k%I(B $B$G$J$$(B) ISO8859/1 $B$N%U%)%s%H$r;XDj$7$^$9!#;XDj$5$l$F$$$J$$;~$O!"(B \fIfontlist\fP $B$NCf$+$iC5$7$^$9!#(B .TP 8 .BI \-fr " roman-kana-font" $BDL>o$N(B JISX0201 $B$N%U%)%s%H$r;XDj$7$^$9!#$3$N%U%)%s%H$O!"(BISO8859/1 $B$N%U%)(B $B%s%H$HF1$89b$5$HI}$r;}$C$F$$$J$1$l$P$J$j$^$;$s!#;XDj$5$l$F$$$J$$;~$O!"(B \fIfontlist\fP $B$NCf$+$iC5$7$^$9!#(B .TP 8 .BI \-fk " kanji-font" $B4A;z%F%-%9%H$rI=<($9$k;~$KMQ$$$kDL>o$N(B JISX0208 $B$N%U%)%s%H$r;XDj$7$^$9!#(B $B$3$N%U%)%s%H$O!"(BISO8859/1 $B$N%U%)%s%H$HF1$89b$5$G!"(B2$BG\$NI}$r;}$C$F$$$J(B $B$1$l$P$J$j$^$;$s!#;XDj$5$l$F$$$J$$;~$O!"(B\fIfontlist\fP $B$NCf$+$iC5$7$^(B $B$9!#(B .TP .BI \-flb " bold-fontlist" .TP .BI \-fb " bold-font" .TP .BI \-frb " roman-kana-bold-font" .TP 8 .BI \-fkb " kanji-bold-font" $B%\!<%k%I%U%)%s%H$r;XDj$7$^$9!#(B .TP 8 .BI \-lsp " dots" $B$3$N%*%W%7%g%s$O3F9T4V$KA^F~$9$k%9%Z!<%9$N%I%C%H?t$r;XDj$7$^$9!#(B .TP 8 .BI \-ka \fIkterm\fP $B$,(B X $B%5!<%P$H$N%=%1%C%H@\B3$K(B KEEPALIVE $B%*%W%7%g%s$rMQ$$$k(B $B$3$H$r;X<($7$^$9!#%5!<%P$,EE8;$r$7$P$7$P@Z$k(B X $BCl(B $B9g!"F~=PNO$OF|K\8l(B EUC $B$G$"$k$H2>Dj$7$^$9!#(B``sjis'' $B$N>l9g!"(BShift-JIS $B%3!<%I(B($B%^%$%/%m%=%U%H4A;z%3!<%I(B)$B$G$"$k$H2>Dj$7$^$9!#(B .TP 8 .BI \-sn $B%G%U%)%k%H$G$O!"%9%F!<%?%9%i%$%s$O(B($B%&%$%s%I%&$NB>$NItJ,$KBP$7$FAjBPE*(B $B$K(B)$BH?E>$7$^$9!#$3$N%*%W%7%g%s$O%9%F!<%?%9%i%$%s$rH?E>$7$J$/$7$^$9(B($B$7$+(B $B$7!"H"$G0O$^$l$^$9(B)$B!#(B .TP 8 .BI \+sn $B$3$N%*%W%7%g%s$O%9%F!<%?%9%i%$%s$rH?E>$7$^$9!#(B .TP 8 .BI \-st $B%9%F!<%?%9%i%$%s$,%9%?!<%H;~$KI=<($5$l$k$h$&$K$7$^$9!#(B .TP 8 .BI \+st $B%9%F!<%?%9%i%$%s$,%9%?!<%H;~$KI=<($5$l$J$$$h$&$K$7$^$9!#(B .TP 8 .BI \-version $BC1$K(B \fIkterm\fP $B$N%P!<%8%g%s$rI=<($7$^$9!#(B .TP 8 .BI \-xim \fIkterm\fP $B$N5/F0;~$K(B IM $B$r%*!<%W%s(B($B$7$h$&$H(B)$B$9$k$3$H$r;X<($7$^$9!#E,(B $B@Z$J(B IM $B%5!<%P$,Av$C$F$$$J$$>l9g$O!"(B\fIkterm\fP $B$O$=$l$rBT$D$3$H$O$J$/!"(B $B%5!<%P$,MxMQ2DG=$K$J$C$F$+$i@\B3$r9T$$$^$9!#(B .TP 8 .BI \+xim \fIkterm\fP $B$,5/F0;~$K(B IM $B$r%*!<%W%s$7$J$$$3$H$r;X<($7$^$9!#(B .SH RESOURCES $B$3$N%W%m%0%i%`$O!"(B\fIxterm\fP $B$N$9$Y$F$N%j%=!<%9$HF1MM$K!"0J2<$N(B \fIvt100\fP $B%&%#%8%'%C%HMQ%j%=!<%9$b2r$N%j%9%H$r;XDj$7$^$9!#%G%U%)%k%H$O(B ``-*-fixed-medium-r-normal--14-*, -*-gothic-medium-r-normal--14-*, -*-mincho-medium-r-normal--14-*'' $B$G$9!#(B .TP 8 .B "boldFontList (\fPclass\fB FontList)" $B%\!<%k%I%U%)%s%HL>$N%j%9%H$r;XDj$7$^$9!#%G%U%)%k%H$G$O;XDj$7$^$;$s!#(B .TP 8 .B "font (\fPclass\fB Font)" Latin-1 $B$N%U%)%s%HL>$r;XDj$7$^$9!#%G%U%)%k%H$G$O;XDj$7$^$;$s!#(B .TP 8 .B "boldFont (\fPclass\fB Font)" Latin-1 $B$N%\!<%k%I%U%)%s%HL>$r;XDj$7$^$9!#%G%U%)%k%H$G$O;XDj$7$^$;$s!#(B .TP 8 .B "romanKanaFont (\fPclass\fB RomanKanaFont)" JIS-Roman $B$HJR2>L>$N%U%)%s%HL>$r;XDj$7$^$9!#%G%U%)%k%H$G$O;XDj$7$^$;$s!#(B .TP 8 .B "romanKanaBoldFont (\fPclass\fB RomanKanaFont)" JIS-Roman $B$HJR2>L>$N%\!<%k%I%U%)%s%HL>$r;XDj$7$^$9!#%G%U%)%k%H$G$O;XDj$7$^$;$s!#(B .TP 8 .B "kanjiFont (\fPclass\fB KanjiFont)" $B4A;z$N%U%)%s%HL>$r;XDj$7$^$9!#%G%U%)%k%H$G$O;XDj$7$^$;$s!#(B .TP 8 .B "kanjiBoldFont (\fPclass\fB KanjiFont)" $B4A;z$N%\!<%k%I%U%)%s%HL>$r;XDj$7$^$9!#%G%U%)%k%H$G$O;XDj$7$^$;$s!#(B .TP 8 .B "kanjiMode (\fPclass\fB KanjiMode)" pty $B$H$d$j$H$j$9$k4A;z%3!<%I$r;XDj$7$^$9!#%G%U%)%k%H$O(B ``jis'' $B$G$9!#(B .TP 8 .B "lineSpace (\fPclass\fB LineSpace)" $B3F9T4V$KA^F~$9$k%9%Z!<%9NL$r;XDj$7$^$9!#%G%U%)%k%H$O(B ``0'' $B$G$9!#(B .TP 8 .B "keepAlive (\fPclass\fB KeepAlive)" \fIkterm\fP $B$,(B X $B%5!<%P$H$N%=%1%C%H@\B3$K(B KEEPALIVE $B%*%W%7%g%s$rMQ$$$k$+$I$&$+;XDj$7$^$9!#(B $B%G%U%)%k%H$O(B ``false'' $B$G$9!#(B .TP 8 .B "statusLine (\fPclass\fB StatusLine)" $B%9%F!<%?%9%i%$%s$r%9%?!<%H;~$KI=<($7$^$9!#%G%U%)%k%H$O(B ``false'' $B$G$9!#(B .TP 8 .B "statusNormal (\fPclass\fB StatusNormal)" $B%9%F!<%?%9%i%$%s$,H?E>$7$J$$$3$H$r;XDj$7$^$9!#%G%U%)%k%H$O(B ``false'' $B$G$9!#(B .TP 8 .B "forwardKeyEvent (\fPclass\fB ForwardKeyEvent)" false $B$@$HJQ49%5!<%P$K%-!<%$%Y%s%H$rAw$j$^$;$s!#$3$N>l9g!"%U%)!<%+%9$,(B \fIkterm\fP $B$K$"$k$,%]%$%s%?$OB>$N%&%$%s%I%&>e$K$"$k;~$K$OJQ49%5!<%P$O(B $B%$%Y%s%H$r\$7$/$O(B USING XIM $B$N@a$r;2>H$7$F$/$@$5(B $B$$!#(B .TP 8 .B "inputMethod (\fPclass\fB InputMethod)" $BF~NO%a%=%C%I%b%G%#%U%!%$%"$r;XDj$7$^$9!#%G%U%)%k%H$G$O;XDj$7$^$;$s!#(B ($B$3$l$O!"4D6-JQ?t(B XMODIFIERS $B$r;HMQ$9$k$H$$$&0UL#$G$9(B) .TP 8 .B "preeditType (\fPclass\fB PreeditType)" XIM $B%W%m%H%3%k$GMQ$$$kF~NO%9%?%$%k$r!"%+%s%^$G6h@Z$C$?%j%9%H$N7A<0$G;X(B $BDj$7$^$9!#8=:_$O(B ``OverTheSpot'' $B$H(B ``Root'' $B$,%5%]!<%H$5$l$F$$$^$9!#(B $B%G%U%)%k%H$O(B ``OverTheSpot,Root'' $B$G$9!#(B .SH ACTIONS \fIvt100\fP $B$N%H%i%s%9%l!<%7%g%s%j%=!<%9Fb$GMxMQ$G$-$k%"%/%7%g%s$,0J2<(B $B$N$h$&$KDI2C$5$l$F$$$^$9(B: .TP 8 .B "open-im([\fIinput-method\fP])" $B$3$N%"%/%7%g%s$O!";XDj$5$l$?F~NO%a%=%C%I%b%G%#%U%!%$%"$N(B IM $B$r%*!<%W%s(B ($B$7$h$&$H(B)$B$7$^$9!#$b$7(B \fIinput-method\fP $B$,>JN,$5$l$l$P!":G8e$K;XDj$5(B $B$l$?%b%G%#%U%!%$%"$,$=$N$^$^;HMQ$5$l$^$9!#$b$7(B \fIinput-method\fP $B$,%-!<(B $B%o!<%I(B XMODIFIERS $B$J$i$P!"4D6-JQ?t(B XMODIFIERS $B$,;HMQ$5$l$^$9!#(B .TP 8 .B "close-im()" $B$3$N%"%/%7%g%s$O(B IM $B$r%/%m!<%:$7$^$9!#(B .TP 8 .B "begin-conversion(\fIconversion-atom\fP)" $B$3$N%"%/%7%g%s$O!"(Bkinput2 $B%W%m%H%3%k$rMQ$$$F!"%F%-%9%HF~NO$N$?$a$NJQ49(B $B$r3+;O$7$^$9!#F|K\8lJQ49$N$?$a$N(B \fIconversion-atom\fP $B$O(B ``_JAPANESE_CONVERSION'' $B$G$9!#(B .SH TERMCAP \fIkterm\fP $B$GMxMQ$G$-$k(B \fItermcap\fP(5) $B%(%s%H%j$K$O!"(B``kterm'', ``xterm'', ``vt102'', ``vt100'' $B$*$h$S(B ``ansi'' $B$,$"$j$^$9!#(B .SH "USING XIM" \fIkterm\fP $B$O!"$^$:9q:]4D6-(B($B%m%1!<%k(B)$B$r!"(B\fIvt100\fP $B%j%=!<%9(B "eucJPLocale" $B$rMQ$$$F@_Dj$7$^$9!#4D6-JQ?t(B LANG $B$OL5;k$5$l$^$9!#$3$l$O(B \fIkterm\fP $B$,F|K\8l(B EUC $B$rFbItF~NO%3!<%I$H$7$FMQ$$$F$$$k$?$a$G$9!#$b(B $B$7!"$*;H$$$N%7%9%F%`$,!"%G%U%)%k%H$GMQ0U$5$l$F$$$k%m%1!<%kL>$r%5%]!<%H(B $B$7$F$$$J$$>l9g$O!"(Bapp-defaults $B%U%!%$%k$KE,@Z$K@_Dj$7$F$/$@$5$$!#$=$N(B $B8e(B \fIkterm\fP $B$O!"%m%1!<%k%b%G%#%U%!%$%"$r!"%j%=!<%9(B "inputMethod" $B$^(B $B$?$O4D6-JQ?t(B XMODIFIERS $B$K=>$C$F@_Dj$7$^$9!#(B .PP \fIkterm\fP $B$,!"(B"-xim" $B%*%W%7%g%s$G5/F0$5$l$?$j!"(BvtMenu $BFb$N(B "Open Input Method" $B$,A*Br$5$l$k$H!"(B\fIkterm\fP $B$OC1$K(B IM $B%5!<%P$N5/F0$rCN$i(B $B$;$k$?$a$N%3!<%k%P%C%/$rEPO?$9$k$3$H$7$+$7$^$;$s!#$3$N;~E@$GE,@Z$J%5!<(B $B%P$,Av$C$F$$$?$j!"8e$+$iMxMQ2DG=$K$J$k$H(B \fIkterm\fP $B$O$=$N%5!<%P$K@\(B $BB3$7$^$9!#JQ49$N3+;O$O!"(BIM $B%5!<%P$N@_Dj$K0MB8$7$^$9!#(B .PP $B$b$7!"(B\fIkterm\fP $B$,(B kinput2 $B%W%m%H%3%k$N%5!<%P$H@\B3$7$F$$$k$H!"(BIM $B$O(B $B%*!<%W%s$G$-$^$;$s!#(B .PP $B$5$i$K>\$7$$>pJs(B($B%F%-%9%H$NF~NO(B/$BJQ49(B/$B=$@5J}K!$J$I(B)$B$OJQ49%5!<%P$N%I%-%e(B $B%a%s%H(B(\fIkinput2\fP(1))$B$r;2>H$7$F2<$5$$!#(B .sp .B $BF|K\8l0J30$N8@8l(B .br $BF|K\8l0J30$N8@8l$rF~NO$9$k$K$O!"(B\fIvt100\fP $B%j%=!<%9(B "eucJPLocale" $B$r(B $BI,MW$J%m%1!<%kL>$K@_Dj$7!"4A;z%b!<%I$r(B("-km euc" $B%*%W%7%g%s!"(B "*vt100.kanjiMode: euc" $B%j%=!<%9!"$"$k$$$O(B vtMenu $B$N(B "Japanese EUC Mode" $B%(%s%H%j$rMQ$$$F(B)$BF|K\8l(B EUC $B$K@_Dj$7$F$/$@$5$$!#F|K\8l(B EUC $B%b!<(B $B%I$G$O!"(BIM $B$+$iF~NO$5$l$?J8;z$O!"=$@5$5$l$:$K(B pty $B$KEO$5$l$k$N$G!"$3$N(B $BJ}K!$O$I$N$h$&$J%m%1!<%k$KBP$7$F$bF0:n$9$k$O$:$G$9!#$?$@$7!"$3$N5!9=$O!"(B $B>-MhJQ99$5$l$k2DG=@-$,$"$j$^$9!#(B .sp .B $BCm0U(B .br $B@\B3$7$F$$$k(B IM $B%5!<%P$,$"$k%?%$%_%s%0$G;`$L$H(B \fIkterm\fP $B$,%O%s%0$7(B $B$F$7$^$&$3$H$,$"$j$^$9!#$"$k(B \fIkterm\fP $B>e$G$=$l$K@\B3$7$F$$$k%5!<%P!"(B $B$*$h$S!"(B\fIkterm\fP $B$H@\B3$r3NN)$7$h$&$H$7$F$$$k%5!<%P$r;&$7$F$O$$$1$^(B $B$;$s!#(BIM $B%5!<%P$r;&$9$H$-$O!"$I$N(B \fIkterm\fP $B$b$=$N%5!<%P$K@\B3$7$F$$(B $B$J$$$3$H$rI,$:3N$+$a$F$/$@$5$$!#(B .sp .B $B$*CN$i$;(B .br \fIkterm\fP $B$O!"(BX11R5 $B$K4p$E$/(B XIMP $B%W%m%H%3%k$rMQ$$$?%5!<%P$H$ODL?.$G(B $B$-$^$;$s!#(B .SH "USING KINPUT2" $B%G%U%)%k%H$G$O!"(Bcontrol-Kanji $B%-!<$r2!$9$H!"(Bkinput2 $B%W%m%H%3%k$rMQ$$$?(B $BF|K\8l%F%-%9%H$N$?$a$NJQ49$,;O$^$j$^$9!#(B\fIkinput2\fP(1) $B$J$I$NJQ49%5!<(B $B%P$O$=$l$^$G$KAv$i$;$F$"$kI,MW$,$"$j!"$G$J$1$l$P(B `Conversion Server not found' $B$H$$$&7Y9p%a%C%;!<%8$,8=$l$^$9!#B>$N8@8l$K$D$$$F$O!"$b$7%5!<(B $B%P$,MxMQ2DG=$J$i$P!"%H%i%s%9%l!<%7%g%s%F!<%V%k$rJQ99$9$k$3$H$K$h$C$F!"(B $BJQ49$r3+;O$9$k$?$a$N%-!<$r%P%$%s%I$9$k$3$H$,$G$-$^$9!#(B .PP IM $B$,%*!<%W%s$5$l(B($B$h$&$H$7(B)$B$F$$$k>l9g$O!"(Bkinput2 $B%W%m%H%3%k$rMQ$$$?JQ(B $B49$O3+;O$G$-$^$;$s!#(B .PP $B$5$i$K>\$7$$>pJs(B($B%F%-%9%H$NF~NO(B/$BJQ49(B/$B=$@5J}K!$J$I(B)$B$OJQ49%5!<%P$N%I%-%e(B $B%a%s%H(B(\fIkinput2\fP(1))$B$r;2>H$7$F2<$5$$!#(B .SH "SEE ALSO" xterm(1), resize(1), X(1), kinput2(1), pty(4), tty(4) .br .I ``Xterm Control Sequences'' .SH BUGS \fIkterm\fP $B$O(B2$B%P%$%HJ8;z$,(B1$B%P%$%HJ8;z$NFsG\$NI}$r;}$C$F$$$k$b$N$H2>Dj(B $B$7$^$9!#ITDjI}$N%U%)%s%H$O(B \fIxterm\fP $BF1MM07$&$3$H$,$G$-$^$;$s!#(B .PP $BK\%P!<%8%g%s$G$O(B JIS $B%b!<%I$G4A;z$rF~NO$9$k:]!"(B``ESC $ B'' $B$r4A;zJ8;z(B $B%;%C%H$N3dEv$KMQ$$$^$9!#(B .SH AUTHORS $B0J2<$r4^$`B?$/$N?M!9(B: .sp $B:4Ln>!Li(B ($B3t<02q1QIW(B ($B%=%K!<3t<02q:,?.(B ($B3t<02q #include #include #include #include #ifndef NO_XPOLL_H #include #endif #include #include #include #include "data.h" #include "error.h" #include "menu.h" #ifdef KEEPALIVE #include #endif /* KEEPALIVE */ #ifdef att #define ATT #endif #ifdef __osf__ #define USE_SYSV_UTMP #define USE_SYSV_SIGNALS #endif #ifdef SVR4 #ifndef SYSV #define SYSV /* SVR4 is (approx) superset of SVR3 */ #endif #define ATT #define USE_SYSV_UTMP #ifndef __sgi #define USE_TERMIOS #endif #define HAS_UTMP_UT_HOST #endif #if defined(SYSV) && defined(i386) && !defined(SVR4) #define USE_SYSV_UTMP #define ATT #define USE_HANDSHAKE static Bool IsPts = False; #endif #if defined(ATT) && !defined(__sgi) #define USE_USG_PTYS #else #define USE_HANDSHAKE #endif #if defined(SYSV) && !defined(SVR4) /* older SYSV systems cannot ignore SIGHUP. Shell hangs, or you get extra shells, or something like that */ #define USE_SYSV_SIGHUP #endif #if defined(sony) && defined(bsd43) && !defined(KANJI) #define KANJI #endif #ifdef linux #define USE_SYSV_TERMIO #define USE_SYSV_PGRP #define USE_SYSV_UTMP #define USE_SYSV_SIGNALS #define HAS_UTMP_UT_HOST #define LASTLOG #define WTMP #endif #include #include #ifdef USE_TERMIOS #include /* this hacked termios support only works on SYSV */ #define USE_SYSV_TERMIO #define termio termios #undef TCGETA #define TCGETA TCGETS #undef TCSETA #define TCSETA TCSETS #else /* USE_TERMIOS */ #ifdef SYSV #include #endif /* SYSV */ #endif /* USE_TERMIOS else */ #ifdef SVR4 #undef TIOCSLTC /* defined, but not useable */ #endif #if defined(__sgi) && OSMAJORVERSION >= 5 #undef TIOCLSET /* defined, but not useable */ #endif #ifdef SYSV /* { */ #ifdef USE_USG_PTYS /* AT&T SYSV has no ptyio.h */ #include /* get typedef used in ptem.h */ #include /* for I_PUSH */ #ifndef SVR4 #include /* get struct winsize */ #endif #include /* for POLLIN */ #endif /* USE_USG_PTYS */ #define USE_SYSV_TERMIO #define USE_SYSV_SIGNALS #define USE_SYSV_PGRP #define USE_SYSV_ENVVARS /* COLUMNS/LINES vs. TERMCAP */ /* * now get system-specific includes */ #ifdef CRAY #define USE_SYSV_UTMP #define HAS_UTMP_UT_HOST #define HAS_BSD_GROUPS #endif #ifdef macII #define USE_SYSV_UTMP #define HAS_UTMP_UT_HOST #define HAS_BSD_GROUPS #include #undef USE_SYSV_ENVVARS #undef FIOCLEX #undef FIONCLEX #define setpgrp2 setpgrp #include #include #endif #ifdef sco #define USE_SYSV_UTMP #define USE_POSIX_WAIT #endif /* sco */ #ifdef hpux #define HAS_BSD_GROUPS #define USE_SYSV_UTMP #define HAS_UTMP_UT_HOST #define USE_POSIX_WAIT #include #endif /* hpux */ #ifdef __sgi #define HAS_BSD_GROUPS #include #endif /* __sgi */ #ifdef sun #include #endif #ifdef AIXV3 #define USE_SYSV_UTMP #define HAS_UTMP_UT_HOST #endif #else /* } !SYSV { */ /* BSD systems */ #ifndef linux #include #endif #include #define HAS_UTMP_UT_HOST #define HAS_BSD_GROUPS #ifdef __osf__ #define USE_SYSV_UTMP #define setpgrp setpgid #endif #endif /* } !SYSV */ #ifdef _POSIX_SOURCE #define USE_POSIX_WAIT #endif #ifdef SVR4 #define USE_POSIX_WAIT #endif #include #include #include #ifdef X_NOT_STDC_ENV extern int errno; #define Time_t long extern Time_t time (); #else #include #define Time_t time_t #endif #ifdef hpux #include #endif /* hpux */ #if defined(apollo) && OSMAJORVERSION == 10 && OSMINORVERSION < 4 #define ttyslot() 1 #endif /* apollo */ #ifdef SVR4 #include #define setutent setutxent #define getutent getutxent #define getutid getutxid #define endutent endutxent #define pututline pututxline #else #include #if defined(_CRAY) && OSMAJORVERSION < 8 extern struct utmp *getutid __((struct utmp *_Id)); #endif #endif #ifdef LASTLOG # if !defined(BSD) || (BSD < 199103) #include # endif #endif #include /* for NOFILE */ #ifdef PUCC_PTYD #include int Ptyfd; #endif /* PUCC_PTYD */ #ifdef sequent #define USE_GET_PSEUDOTTY #endif #ifndef UTMP_FILENAME #ifdef UTMP_FILE #define UTMP_FILENAME UTMP_FILE #else #ifdef _PATH_UTMP #define UTMP_FILENAME _PATH_UTMP #else #define UTMP_FILENAME "/etc/utmp" #endif #endif #endif #ifndef LASTLOG_FILENAME #ifdef _PATH_LASTLOG #define LASTLOG_FILENAME _PATH_LASTLOG #else #define LASTLOG_FILENAME "/usr/adm/lastlog" /* only on BSD systems */ #endif #endif #ifndef WTMP_FILENAME #ifdef WTMP_FILE #define WTMP_FILENAME WTMP_FILE #else #ifdef _PATH_WTMP #define WTMP_FILENAME _PATH_WTMP #else #ifdef SYSV #define WTMP_FILENAME "/etc/wtmp" #else #define WTMP_FILENAME "/usr/adm/wtmp" #endif #endif #endif #endif #include #if defined(sco) || defined(ISC) #undef SIGTSTP /* defined, but not the BSD way */ #endif #ifdef SIGTSTP #include #ifdef hpux #include #endif #endif #ifdef SIGNALRETURNSINT #define SIGNAL_T int #define SIGNAL_RETURN return 0 #else #define SIGNAL_T void #define SIGNAL_RETURN return #endif SIGNAL_T Exit(); #ifndef X_NOT_POSIX #include #else extern long lseek(); #ifdef USG extern unsigned sleep(); #else extern void sleep(); #endif #endif #ifndef X_NOT_STDC_ENV #include #else extern char *malloc(); extern char *calloc(); extern char *realloc(); extern char *getenv(); extern void exit(); #endif #ifdef X_NOT_POSIX extern char *ttyname(); #endif #ifdef __sgi #include #endif #ifdef SYSV extern char *ptsname(); #endif extern char *strindex (); extern void HandlePopupMenu(); int switchfb[] = {0, 2, 1, 3}; static SIGNAL_T reapchild (); static Bool added_utmp_entry = False; static Bool xterm_exiting = False; /* ** Ordinarily it should be okay to omit the assignment in the following ** statement. Apparently the c89 compiler on AIX 4.1.3 has a bug, or does ** it? Without the assignment though the compiler will init command_to_exec ** to 0xffffffff instead of NULL; and subsequent usage, e.g. in spawn() to ** SEGV. */ static char **command_to_exec = NULL; #ifdef USE_SYSV_TERMIO /* The following structures are initialized in main() in order ** to eliminate any assumptions about the internal order of their ** contents. */ static struct termio d_tio; #ifdef TIOCSLTC static struct ltchars d_ltc; #endif /* TIOCSLTC */ #ifdef __sgi #undef TIOCLSET /* XXX why is this undef-ed again? */ #endif #ifdef TIOCLSET static unsigned int d_lmode; #endif /* TIOCLSET */ #else /* not USE_SYSV_TERMIO */ static struct sgttyb d_sg = { 0, 0, 0177, CKILL, EVENP|ODDP|ECHO|XTABS|CRMOD }; static struct tchars d_tc = { CINTR, CQUIT, CSTART, CSTOP, CEOF, CBRK, }; static struct ltchars d_ltc = { CSUSP, CDSUSP, CRPRNT, CFLUSH, CWERASE, CLNEXT }; static int d_disipline = NTTYDISC; #if defined(KTERM) && defined(LPASS8) static long int d_lmode = LCRTBS|LCRTERA|LCRTKIL|LCTLECH|LPASS8; #else static long int d_lmode = LCRTBS|LCRTERA|LCRTKIL|LCTLECH; #endif #ifdef sony static long int d_jmode = KM_SYSSJIS|KM_ASCII; static struct jtchars d_jtc = { 'J', 'B' }; #endif /* sony */ #endif /* USE_SYSV_TERMIO */ /* allow use of system default characters if defined and reasonable */ #ifndef CEOF #define CEOF ('D'&037) #endif #ifndef CSUSP #define CSUSP ('Z'&037) #endif #ifndef CQUIT #define CQUIT ('\\'&037) #endif #ifndef CEOL #define CEOL 0 #endif #ifndef CSWTCH #define CSWTCH 0 #endif #ifndef CLNEXT #define CLNEXT ('V'&037) #endif #ifndef CWERASE #define CWERASE ('W'&037) #endif #ifndef CRPRNT #define CRPRNT ('R'&037) #endif #ifndef CFLUSH #define CFLUSH ('O'&037) #endif #ifndef CSTOP #define CSTOP ('S'&037) #endif #ifndef CSTART #define CSTART ('Q'&037) #endif static int parse_tty_modes (); /* * SYSV has the termio.c_cc[V] and ltchars; BSD has tchars and ltchars; * SVR4 has only termio.c_cc, but it includes everything from ltchars. */ static int override_tty_modes = 0; struct _xttymodes { char *name; int len; int set; char value; } ttymodelist[] = { { "intr", 4, 0, '\0' }, /* tchars.t_intrc ; VINTR */ #define XTTYMODE_intr 0 { "quit", 4, 0, '\0' }, /* tchars.t_quitc ; VQUIT */ #define XTTYMODE_quit 1 { "erase", 5, 0, '\0' }, /* sgttyb.sg_erase ; VERASE */ #define XTTYMODE_erase 2 { "kill", 4, 0, '\0' }, /* sgttyb.sg_kill ; VKILL */ #define XTTYMODE_kill 3 { "eof", 3, 0, '\0' }, /* tchars.t_eofc ; VEOF */ #define XTTYMODE_eof 4 { "eol", 3, 0, '\0' }, /* VEOL */ #define XTTYMODE_eol 5 { "swtch", 5, 0, '\0' }, /* VSWTCH */ #define XTTYMODE_swtch 6 { "start", 5, 0, '\0' }, /* tchars.t_startc */ #define XTTYMODE_start 7 { "stop", 4, 0, '\0' }, /* tchars.t_stopc */ #define XTTYMODE_stop 8 { "brk", 3, 0, '\0' }, /* tchars.t_brkc */ #define XTTYMODE_brk 9 { "susp", 4, 0, '\0' }, /* ltchars.t_suspc ; VSUSP */ #define XTTYMODE_susp 10 { "dsusp", 5, 0, '\0' }, /* ltchars.t_dsuspc ; VDSUSP */ #define XTTYMODE_dsusp 11 { "rprnt", 5, 0, '\0' }, /* ltchars.t_rprntc ; VREPRINT */ #define XTTYMODE_rprnt 12 { "flush", 5, 0, '\0' }, /* ltchars.t_flushc ; VDISCARD */ #define XTTYMODE_flush 13 { "weras", 5, 0, '\0' }, /* ltchars.t_werasc ; VWERASE */ #define XTTYMODE_weras 14 { "lnext", 5, 0, '\0' }, /* ltchars.t_lnextc ; VLNEXT */ #define XTTYMODE_lnext 15 { NULL, 0, 0, '\0' }, /* end of data */ }; #ifdef USE_SYSV_UTMP #if defined(X_NOT_STDC_ENV) || (defined(AIXV3) && OSMAJORVERSION < 4) extern struct utmp *getutent(); extern struct utmp *getutid(); extern struct utmp *getutline(); extern void pututline(); extern void setutent(); extern void endutent(); extern void utmpname(); #endif /* !SVR4 */ #ifdef X_NOT_STDC_ENV /* could remove paragraph unconditionally? */ extern struct passwd *getpwent(); extern struct passwd *getpwuid(); extern struct passwd *getpwnam(); extern void setpwent(); extern void endpwent(); #endif extern struct passwd *fgetpwent(); #else /* not USE_SYSV_UTMP */ static char etc_utmp[] = UTMP_FILENAME; #ifdef LASTLOG static char etc_lastlog[] = LASTLOG_FILENAME; #endif #endif /* USE_SYSV_UTMP */ #ifdef WTMP static char etc_wtmp[] = WTMP_FILENAME; #endif /* * Some people with 4.3bsd /bin/login seem to like to use login -p -f user * to implement xterm -ls. They can turn on USE_LOGIN_DASH_P and turn off * WTMP and LASTLOG. */ #ifdef USE_LOGIN_DASH_P #ifndef LOGIN_FILENAME #define LOGIN_FILENAME "/bin/login" #endif static char bin_login[] = LOGIN_FILENAME; #endif static int inhibit; static char passedPty[2]; /* name if pty if slave */ #if defined(TIOCCONS) || defined(SRIOCSREDIR) static int Console; #include /* XmuGetHostname */ #define MIT_CONSOLE_LEN 12 #define MIT_CONSOLE "MIT_CONSOLE_" static char mit_console_name[255 + MIT_CONSOLE_LEN + 1] = MIT_CONSOLE; static Atom mit_console; #endif /* TIOCCONS */ #ifndef USE_SYSV_UTMP static int tslot; #endif /* USE_SYSV_UTMP */ static jmp_buf env; char *ProgramName; Boolean sunFunctionKeys; static struct _resource { char *xterm_name; char *icon_geometry; char *title; char *icon_name; char *term_name; char *tty_modes; Boolean utmpInhibit; Boolean sunFunctionKeys; /* %%% should be widget resource? */ Boolean wait_for_map; Boolean useInsertMode; #ifdef __sgi Boolean useLocale; #endif #ifdef KEEPALIVE Boolean keepalive; #endif } resource; /* used by VT (charproc.c) */ #define offset(field) XtOffsetOf(struct _resource, field) static XtResource application_resources[] = { {"name", "Name", XtRString, sizeof(char *), #ifdef KTERM offset(xterm_name), XtRString, "kterm"}, #else /* !KTERM */ offset(xterm_name), XtRString, "xterm"}, #endif /* !KTERM */ {"iconGeometry", "IconGeometry", XtRString, sizeof(char *), offset(icon_geometry), XtRString, (caddr_t) NULL}, {XtNtitle, XtCTitle, XtRString, sizeof(char *), offset(title), XtRString, (caddr_t) NULL}, {XtNiconName, XtCIconName, XtRString, sizeof(char *), offset(icon_name), XtRString, (caddr_t) NULL}, {"termName", "TermName", XtRString, sizeof(char *), offset(term_name), XtRString, (caddr_t) NULL}, {"ttyModes", "TtyModes", XtRString, sizeof(char *), offset(tty_modes), XtRString, (caddr_t) NULL}, {"utmpInhibit", "UtmpInhibit", XtRBoolean, sizeof (Boolean), offset(utmpInhibit), XtRString, "false"}, {"sunFunctionKeys", "SunFunctionKeys", XtRBoolean, sizeof (Boolean), offset(sunFunctionKeys), XtRString, "false"}, {"waitForMap", "WaitForMap", XtRBoolean, sizeof (Boolean), offset(wait_for_map), XtRString, "false"}, {"useInsertMode", "UseInsertMode", XtRBoolean, sizeof (Boolean), offset(useInsertMode), XtRString, "false"}, #ifdef __sgi {"useLocale", "UseLocale", XtRBoolean, sizeof(Boolean), offset(useLocale), XtRString, "true"}, #endif #ifdef KEEPALIVE {"keepAlive", "KeepAlive", XtRBoolean, sizeof (Boolean), offset(keepalive), XtRString, "false"}, #endif /* KEEPALIVE */ }; #undef offset static char *fallback_resources[] = { #ifdef KTERM "KTerm*SimpleMenu*menuLabel.vertSpace: 100", "KTerm*SimpleMenu*HorizontalMargins: 16", "KTerm*SimpleMenu*Sme.height: 16", "KTerm*SimpleMenu*Cursor: left_ptr", "KTerm*mainMenu.Label: Main Options (no app-defaults)", "KTerm*vtMenu.Label: VT Options (no app-defaults)", "KTerm*fontMenu.Label: VT Fonts (no app-defaults)", # ifndef KTERM_NOTEK "KTerm*tekMenu.Label: Tek Options (no app-defaults)", # endif /* !KTERM_NOTEK */ #else /* !KTERM */ "XTerm*SimpleMenu*menuLabel.vertSpace: 100", "XTerm*SimpleMenu*HorizontalMargins: 16", "XTerm*SimpleMenu*Sme.height: 16", "XTerm*SimpleMenu*Cursor: left_ptr", "XTerm*mainMenu.Label: Main Options (no app-defaults)", "XTerm*vtMenu.Label: VT Options (no app-defaults)", "XTerm*fontMenu.Label: VT Fonts (no app-defaults)", "XTerm*tekMenu.Label: Tek Options (no app-defaults)", #endif /* !KTERM */ NULL }; /* Command line options table. Only resources are entered here...there is a pass over the remaining options after XrmParseCommand is let loose. */ static XrmOptionDescRec optionDescList[] = { {"-geometry", "*vt100.geometry",XrmoptionSepArg, (caddr_t) NULL}, {"-132", "*c132", XrmoptionNoArg, (caddr_t) "on"}, {"+132", "*c132", XrmoptionNoArg, (caddr_t) "off"}, {"-ah", "*alwaysHighlight", XrmoptionNoArg, (caddr_t) "on"}, {"+ah", "*alwaysHighlight", XrmoptionNoArg, (caddr_t) "off"}, {"-b", "*internalBorder",XrmoptionSepArg, (caddr_t) NULL}, {"-cb", "*cutToBeginningOfLine", XrmoptionNoArg, (caddr_t) "off"}, {"+cb", "*cutToBeginningOfLine", XrmoptionNoArg, (caddr_t) "on"}, {"-cc", "*charClass", XrmoptionSepArg, (caddr_t) NULL}, {"-cn", "*cutNewline", XrmoptionNoArg, (caddr_t) "off"}, {"+cn", "*cutNewline", XrmoptionNoArg, (caddr_t) "on"}, {"-cr", "*cursorColor", XrmoptionSepArg, (caddr_t) NULL}, {"-cu", "*curses", XrmoptionNoArg, (caddr_t) "on"}, {"+cu", "*curses", XrmoptionNoArg, (caddr_t) "off"}, {"-e", NULL, XrmoptionSkipLine, (caddr_t) NULL}, #ifndef ENBUG /* kagotani */ {"-fn", "*vt100.font", XrmoptionSepArg, (caddr_t) NULL}, #endif {"-fb", "*boldFont", XrmoptionSepArg, (caddr_t) NULL}, #ifdef KTERM {"-dfl", "*dynamicFontLoad", XrmoptionNoArg, (caddr_t) "on"}, {"+dfl", "*dynamicFontLoad", XrmoptionNoArg, (caddr_t) "off"}, {"-fl", "*fontList", XrmoptionSepArg, (caddr_t) NULL}, {"-flb", "*boldFontList", XrmoptionSepArg, (caddr_t) NULL}, {"-fr", "*romanKanaFont", XrmoptionSepArg, (caddr_t) NULL}, {"-frb", "*romanKanaBoldFont", XrmoptionSepArg, (caddr_t) NULL}, #ifdef KTERM_MBCS {"-fk", "*kanjiFont", XrmoptionSepArg, (caddr_t) NULL}, {"-fkb", "*kanjiBoldFont", XrmoptionSepArg, (caddr_t) NULL}, #endif /* KTERM_MBCS */ #ifdef KTERM_KANJIMODE {"-km", "*kanjiMode", XrmoptionSepArg, (caddr_t) NULL}, #endif /* KTERM_KANJIMODE */ #ifdef KTERM_XIM { "-xim", "*openIm", XrmoptionNoArg, (caddr_t) "on"}, { "+xim", "*openIm", XrmoptionNoArg, (caddr_t) "off"}, #endif /* KTERM_XIM */ {"-lsp", "*lineSpace", XrmoptionSepArg, (caddr_t) NULL}, #endif /* KTERM */ {"-j", "*jumpScroll", XrmoptionNoArg, (caddr_t) "on"}, {"+j", "*jumpScroll", XrmoptionNoArg, (caddr_t) "off"}, #ifdef KEEPALIVE {"-ka", "*keepAlive", XrmoptionNoArg, (caddr_t) "on"}, {"+ka", "*keepAlive", XrmoptionNoArg, (caddr_t) "off"}, #endif /* KEEPALIVE */ /* parse logging options anyway for compatibility */ {"-l", "*logging", XrmoptionNoArg, (caddr_t) "on"}, {"+l", "*logging", XrmoptionNoArg, (caddr_t) "off"}, {"-lf", "*logFile", XrmoptionSepArg, (caddr_t) NULL}, {"-ls", "*loginShell", XrmoptionNoArg, (caddr_t) "on"}, {"+ls", "*loginShell", XrmoptionNoArg, (caddr_t) "off"}, {"-mb", "*marginBell", XrmoptionNoArg, (caddr_t) "on"}, {"+mb", "*marginBell", XrmoptionNoArg, (caddr_t) "off"}, {"-mc", "*multiClickTime", XrmoptionSepArg, (caddr_t) NULL}, {"-ms", "*pointerColor",XrmoptionSepArg, (caddr_t) NULL}, {"-nb", "*nMarginBell", XrmoptionSepArg, (caddr_t) NULL}, {"-rw", "*reverseWrap", XrmoptionNoArg, (caddr_t) "on"}, {"+rw", "*reverseWrap", XrmoptionNoArg, (caddr_t) "off"}, {"-aw", "*autoWrap", XrmoptionNoArg, (caddr_t) "on"}, {"+aw", "*autoWrap", XrmoptionNoArg, (caddr_t) "off"}, {"-s", "*multiScroll", XrmoptionNoArg, (caddr_t) "on"}, {"+s", "*multiScroll", XrmoptionNoArg, (caddr_t) "off"}, {"-sb", "*scrollBar", XrmoptionNoArg, (caddr_t) "on"}, {"+sb", "*scrollBar", XrmoptionNoArg, (caddr_t) "off"}, {"-sf", "*sunFunctionKeys", XrmoptionNoArg, (caddr_t) "on"}, {"+sf", "*sunFunctionKeys", XrmoptionNoArg, (caddr_t) "off"}, {"-si", "*scrollTtyOutput", XrmoptionNoArg, (caddr_t) "off"}, {"+si", "*scrollTtyOutput", XrmoptionNoArg, (caddr_t) "on"}, {"-sk", "*scrollKey", XrmoptionNoArg, (caddr_t) "on"}, {"+sk", "*scrollKey", XrmoptionNoArg, (caddr_t) "off"}, {"-sl", "*saveLines", XrmoptionSepArg, (caddr_t) NULL}, #ifndef KTERM_NOTEK {"-t", "*tekStartup", XrmoptionNoArg, (caddr_t) "on"}, {"+t", "*tekStartup", XrmoptionNoArg, (caddr_t) "off"}, #endif /* !KTERM_NOTEK */ {"-tm", "*ttyModes", XrmoptionSepArg, (caddr_t) NULL}, {"-tn", "*termName", XrmoptionSepArg, (caddr_t) NULL}, #ifdef __sgi {"-ul", "*useLocale", XrmoptionNoArg, (caddr_t) "on"}, {"+ul", "*useLocale", XrmoptionNoArg, (caddr_t) "off"}, #endif {"-ut", "*utmpInhibit", XrmoptionNoArg, (caddr_t) "on"}, {"+ut", "*utmpInhibit", XrmoptionNoArg, (caddr_t) "off"}, {"-im", "*useInsertMode", XrmoptionNoArg, (caddr_t) "on"}, {"+im", "*useInsertMode", XrmoptionNoArg, (caddr_t) "off"}, {"-vb", "*visualBell", XrmoptionNoArg, (caddr_t) "on"}, {"+vb", "*visualBell", XrmoptionNoArg, (caddr_t) "off"}, {"-wf", "*waitForMap", XrmoptionNoArg, (caddr_t) "on"}, {"+wf", "*waitForMap", XrmoptionNoArg, (caddr_t) "off"}, /* bogus old compatibility stuff for which there are standard XtAppInitialize options now */ #ifndef KTERM_NOTEK {"%", "*tekGeometry", XrmoptionStickyArg, (caddr_t) NULL}, #endif /* !KTERM_NOTEK */ {"#", ".iconGeometry",XrmoptionStickyArg, (caddr_t) NULL}, {"-T", "*title", XrmoptionSepArg, (caddr_t) NULL}, {"-n", "*iconName", XrmoptionSepArg, (caddr_t) NULL}, {"-r", "*reverseVideo",XrmoptionNoArg, (caddr_t) "on"}, {"+r", "*reverseVideo",XrmoptionNoArg, (caddr_t) "off"}, {"-rv", "*reverseVideo",XrmoptionNoArg, (caddr_t) "on"}, {"+rv", "*reverseVideo",XrmoptionNoArg, (caddr_t) "off"}, {"-w", ".borderWidth", XrmoptionSepArg, (caddr_t) NULL}, #ifdef STATUSLINE {"-sn", "*statusNormal", XrmoptionNoArg, (caddr_t) "on"}, {"+sn", "*statusNormal", XrmoptionNoArg, (caddr_t) "off"}, {"-st", "*statusLine", XrmoptionNoArg, (caddr_t) "on"}, {"+st", "*statusLine", XrmoptionNoArg, (caddr_t) "off"}, #endif /* STATUSLINE */ }; static struct _options { char *opt; char *desc; } options[] = { { "-help", "print out this message" }, #ifdef KTERM { "-version", "print out kterm version info" }, #endif /* KTERM */ { "-display displayname", "X server to contact" }, { "-geometry geom", "size (in characters) and position" }, { "-/+rv", "turn on/off reverse video" }, { "-bg color", "background color" }, { "-fg color", "foreground color" }, { "-bd color", "border color" }, { "-bw number", "border width in pixels" }, { "-fn fontname", "normal text font" }, { "-iconic", "start iconic" }, { "-name string", "client instance, icon, and title strings" }, { "-title string", "title string" }, { "-xrm resourcestring", "additional resource specifications" }, { "-/+132", "turn on/off column switch inhibiting" }, { "-/+ah", "turn on/off always highlight" }, { "-b number", "internal border in pixels" }, { "-/+cb", "turn on/off cut-to-beginning-of-line inhibit" }, { "-cc classrange", "specify additional character classes" }, { "-/+cn", "turn on/off cut newline inhibit" }, { "-cr color", "text cursor color" }, { "-/+cu", "turn on/off curses emulation" }, { "-fb fontname", "bold text font" }, #ifdef KTERM { "-/+dfl", "turn on/off dynamic font load" }, { "-fl fontlist", "normal fonts" }, { "-flb fontlist", "bold fonts" }, { "-fr fontname", "normal kana font" }, { "-frb fontname", "bold kana font" }, #ifdef KTERM_MBCS { "-fk fontname", "normal kanji font" }, { "-fkb fontname", "bold kanji font" }, #endif /* KTERM_MBCS */ #ifdef KTERM_KANJIMODE { "-km kanjimode", "kanji code (jis|euc|sjis)" }, #endif /* KTERM_KANJIMODE */ #ifdef KTERM_XIM { "-/+xim", "open IM at startup time" }, #endif /* KTERM_XIM */ { "-lsp number", "number of extra dots between lines" }, #endif /* KTERM */ { "-/+im", "use insert mode for TERMCAP" }, { "-/+j", "turn on/off jump scroll" }, #ifdef KEEPALIVE { "-/+ka", "turn on/off keeping connection alive" }, #endif /* KEEPALIVE */ #ifdef ALLOWLOGGING { "-/+l", "turn on/off logging" }, { "-lf filename", "logging filename" }, #else { "-/+l", "turn on/off logging (not supported)" }, { "-lf filename", "logging filename (not supported)" }, #endif { "-/+ls", "turn on/off login shell" }, { "-/+mb", "turn on/off margin bell" }, { "-mc milliseconds", "multiclick time in milliseconds" }, { "-ms color", "pointer color" }, { "-nb number", "margin bell in characters from right end" }, { "-/+aw", "turn on/off auto wraparound" }, { "-/+rw", "turn on/off reverse wraparound" }, { "-/+s", "turn on/off multiscroll" }, { "-/+sb", "turn on/off scrollbar" }, { "-/+sf", "turn on/off Sun Function Key escape codes" }, { "-/+si", "turn on/off scroll-on-tty-output inhibit" }, { "-/+sk", "turn on/off scroll-on-keypress" }, { "-sl number", "number of scrolled lines to save" }, #ifdef STATUSLINE { "-/+sn", "turn on/off status line norval video" }, { "-/+st", "turn on/off status line" }, #endif /* STATUSLINE */ { "-/+t", "turn on/off Tek emulation window" }, { "-tm string", "terminal mode keywords and characters" }, { "-tn name", "TERM environment variable name" }, #ifdef __sgi { "-/+ul", "use/don't use locale for character input" }, #endif #ifdef UTMP { "-/+ut", "turn on/off utmp inhibit" }, #else { "-/+ut", "turn on/off utmp inhibit (not supported)" }, #endif { "-/+vb", "turn on/off visual bell" }, { "-/+wf", "turn on/off wait for map before command exec" }, { "-e command args ...", "command to execute" }, { "%geom", "Tek window geometry" }, { "#geom", "icon window geometry" }, { "-T string", "title name for window" }, { "-n string", "icon name for window" }, #if defined(TIOCCONS) || defined(SRIOCSREDIR) { "-C", "intercept console messages" }, #else { "-C", "intercept console messages (not supported)" }, #endif { "-Sxxd", "slave mode on \"ttyxx\", file descriptor \"d\"" }, { NULL, NULL }}; static char *message[] = { "Fonts must be fixed width and, if both normal and bold are specified, must", "have the same size. If only a normal font is specified, it will be used for", "both normal and bold text (by doing overstriking). The -e option, if given,", "must be appear at the end of the command line, otherwise the user's default", "shell will be started. Options that start with a plus sign (+) restore the", "default.", NULL}; static void Syntax (badOption) char *badOption; { struct _options *opt; int col; fprintf (stderr, "%s: bad command line option \"%s\"\r\n\n", ProgramName, badOption); fprintf (stderr, "usage: %s", ProgramName); col = 8 + strlen(ProgramName); for (opt = options; opt->opt; opt++) { int len = 3 + strlen(opt->opt); /* space [ string ] */ if (col + len > 79) { fprintf (stderr, "\r\n "); /* 3 spaces */ col = 3; } fprintf (stderr, " [%s]", opt->opt); col += len; } fprintf (stderr, "\r\n\nType %s -help for a full description.\r\n\n", ProgramName); exit (1); } static void Help () { struct _options *opt; char **cpp; fprintf (stderr, "usage:\n %s [-options ...] [-e command args]\n\n", ProgramName); fprintf (stderr, "where options include:\n"); for (opt = options; opt->opt; opt++) { fprintf (stderr, " %-28s %s\n", opt->opt, opt->desc); } putc ('\n', stderr); for (cpp = message; *cpp; cpp++) { fputs (*cpp, stderr); putc ('\n', stderr); } putc ('\n', stderr); exit (0); } #if defined(TIOCCONS) || defined(SRIOCSREDIR) /* ARGSUSED */ static Boolean ConvertConsoleSelection(w, selection, target, type, value, length, format) Widget w; Atom *selection, *target, *type; XtPointer *value; unsigned long *length; int *format; { /* we don't save console output, so can't offer it */ return False; } #endif /* TIOCCONS */ #ifdef KTERM static void printopt(s) char *s; { static int optcol; if (optcol + strlen(s) >= 80) { fprintf (stderr, "\n "); optcol = 8; } optcol += strlen(s); fprintf (stderr, "%s", s); } static void Version() { fprintf(stderr, "kterm: version %s\n", KTERM_VERSION); printopt("options:"); # ifdef KTERM_MBCS printopt(" [KTERM_MBCS]"); # endif # ifdef KTERM_MBCC printopt(" [KTERM_MBCC]"); # endif # ifdef KTERM_KANJIMODE printopt(" [KTERM_KANJIMODE]"); # endif # ifdef KTERM_XIM printopt(" [KTERM_XIM]"); # endif # ifdef KTERM_KINPUT2 printopt(" [KTERM_KINPUT2]"); # endif # ifdef KTERM_COLOR printopt(" [KTERM_COLOR]"); # endif # ifdef KTERM_XAW3D printopt(" [KTERM_XAW3D]"); # endif # ifdef KTERM_NOTEK printopt(" [KTERM_NOTEK]"); # endif # ifdef STATUSLINE printopt(" [STATUSLINE]"); # endif # ifdef KEEPALIVE printopt(" [KEEPALIVE]"); # endif fprintf (stderr, "\n"); exit (0); } #endif /* KTERM */ extern WidgetClass xtermWidgetClass; Arg ourTopLevelShellArgs[] = { { XtNallowShellResize, (XtArgVal) TRUE }, { XtNinput, (XtArgVal) TRUE }, }; int number_ourTopLevelShellArgs = 2; XtAppContext app_con; Widget toplevel; Bool waiting_for_initial_map; extern void do_hangup(); extern void xt_error(); /* * DeleteWindow(): Action proc to implement ICCCM delete_window. */ /* ARGSUSED */ void DeleteWindow(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { #ifndef KTERM_NOTEK if (w == toplevel) if (term->screen.Tshow) hide_vt_window(); else do_hangup(w); else if (term->screen.Vshow) hide_tek_window(); else #endif /* !KTERM_NOTEK */ do_hangup(w); } /* ARGSUSED */ void KeyboardMapping(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { switch (event->type) { case MappingNotify: XRefreshKeyboardMapping(&event->xmapping); break; } } XtActionsRec actionProcs[] = { "DeleteWindow", DeleteWindow, "KeyboardMapping", KeyboardMapping, }; Atom wm_delete_window; extern fd_set Select_mask; extern fd_set X_mask; extern fd_set pty_mask; main (argc, argv) int argc; char **argv; { register TScreen *screen; int mode; char *base_name(); int xerror(), xioerror(); XtSetLanguageProc (NULL, NULL, NULL); ProgramName = argv[0]; /* +2 in case longer tty name like /dev/ttyq255 */ ttydev = (char *) malloc (sizeof(TTYDEV) + 2); #ifndef __osf__ ptydev = (char *) malloc (sizeof(PTYDEV) + 2); if (!ttydev || !ptydev) #else if (!ttydev) #endif { fprintf (stderr, "%s: unable to allocate memory for ttydev or ptydev\n", ProgramName); exit (1); } strcpy (ttydev, TTYDEV); #ifndef __osf__ strcpy (ptydev, PTYDEV); #endif #ifdef USE_SYSV_TERMIO /* { */ /* Initialization is done here rather than above in order ** to prevent any assumptions about the order of the contents ** of the various terminal structures (which may change from ** implementation to implementation). */ d_tio.c_iflag = ICRNL|IXON; d_tio.c_oflag = OPOST|ONLCR|TAB3; #if defined(macII) || defined(ATT) || defined(CRAY) /* { */ d_tio.c_cflag = B9600|CS8|CREAD|PARENB|HUPCL; d_tio.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK; #ifdef ECHOKE d_tio.c_lflag |= ECHOKE|IEXTEN; #endif #ifdef ECHOCTL d_tio.c_lflag |= ECHOCTL|IEXTEN; #endif #ifndef USE_TERMIOS /* { */ d_tio.c_line = 0; #endif /* } */ d_tio.c_cc[VINTR] = CINTR; d_tio.c_cc[VQUIT] = CQUIT; d_tio.c_cc[VERASE] = CERASE; d_tio.c_cc[VKILL] = CKILL; d_tio.c_cc[VEOF] = CEOF; d_tio.c_cc[VEOL] = CNUL; d_tio.c_cc[VEOL2] = CNUL; d_tio.c_cc[VSWTCH] = CNUL; #ifdef USE_TERMIOS /* { */ d_tio.c_cc[VSUSP] = CSUSP; d_tio.c_cc[VDSUSP] = CDSUSP; d_tio.c_cc[VREPRINT] = CRPRNT; d_tio.c_cc[VDISCARD] = CFLUSH; d_tio.c_cc[VWERASE] = CWERASE; d_tio.c_cc[VLNEXT] = CLNEXT; #endif /* } */ #ifdef TIOCSLTC /* { */ d_ltc.t_suspc = CSUSP; /* t_suspc */ d_ltc.t_dsuspc = CDSUSP; /* t_dsuspc */ d_ltc.t_rprntc = CRPRNT; d_ltc.t_flushc = CFLUSH; d_ltc.t_werasc = CWERASE; d_ltc.t_lnextc = CLNEXT; #endif /* } TIOCSLTC */ #ifdef TIOCLSET /* { */ d_lmode = 0; #endif /* } TIOCLSET */ #else /* }{ else !macII, ATT, CRAY */ #ifdef BAUD_0 /* { */ d_tio.c_cflag = CS8|CREAD|PARENB|HUPCL; #else /* }{ !BAUD_0 */ d_tio.c_cflag = B9600|CS8|CREAD|PARENB|HUPCL; #endif /* } !BAUD_0 */ d_tio.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK; #ifdef ECHOKE d_tio.c_lflag |= ECHOKE|IEXTEN; #endif #ifdef ECHOCTL d_tio.c_lflag |= ECHOCTL|IEXTEN; #endif #ifdef NTTYDISC d_tio.c_line = NTTYDISC; #else d_tio.c_line = 0; #endif #ifdef __sgi d_tio.c_cflag &= ~(HUPCL|PARENB); d_tio.c_iflag |= BRKINT|ISTRIP|IGNPAR; #endif d_tio.c_cc[VINTR] = 'C' & 0x3f; /* '^C' */ d_tio.c_cc[VERASE] = 0x7f; /* DEL */ d_tio.c_cc[VKILL] = 'U' & 0x3f; /* '^U' */ d_tio.c_cc[VQUIT] = CQUIT; /* '^\' */ d_tio.c_cc[VEOF] = CEOF; /* '^D' */ d_tio.c_cc[VEOL] = CEOL; /* '^@' */ #ifdef VSWTCH d_tio.c_cc[VSWTCH] = CSWTCH; /* usually '^Z' */ #endif #ifdef VLNEXT d_tio.c_cc[VLNEXT] = CLNEXT; #endif #ifdef VWERASE d_tio.c_cc[VWERASE] = CWERASE; #endif #ifdef VREPRINT d_tio.c_cc[VREPRINT] = CRPRNT; #endif #ifdef VRPRNT d_tio.c_cc[VRPRNT] = CRPRNT; #endif #ifdef VDISCARD d_tio.c_cc[VDISCARD] = CFLUSH; #endif #ifdef VFLUSHO d_tio.c_cc[VFLUSHO] = CFLUSH; #endif #ifdef VSTOP d_tio.c_cc[VSTOP] = CSTOP; #endif #ifdef VSTART d_tio.c_cc[VSTART] = CSTART; #endif #ifdef VSUSP d_tio.c_cc[VSUSP] = CSUSP; #endif #ifdef VDSUSP d_tio.c_cc[VDSUSP] = CDSUSP; #endif /* now, try to inherit tty settings */ { int i; for (i = 0; i <= 2; i++) { struct termio deftio; if (ioctl (i, TCGETA, &deftio) == 0) { d_tio.c_cc[VINTR] = deftio.c_cc[VINTR]; d_tio.c_cc[VQUIT] = deftio.c_cc[VQUIT]; d_tio.c_cc[VERASE] = deftio.c_cc[VERASE]; d_tio.c_cc[VKILL] = deftio.c_cc[VKILL]; d_tio.c_cc[VEOF] = deftio.c_cc[VEOF]; d_tio.c_cc[VEOL] = deftio.c_cc[VEOL]; #ifdef VSWTCH d_tio.c_cc[VSWTCH] = deftio.c_cc[VSWTCH]; #endif #ifdef VEOL2 d_tio.c_cc[VEOL2] = deftio.c_cc[VEOL2]; #endif #ifdef VLNEXT d_tio.c_cc[VLNEXT] = deftio.c_cc[VLNEXT]; #endif #ifdef VWERASE d_tio.c_cc[VWERASE] = deftio.c_cc[VWERASE]; #endif #ifdef VREPRINT d_tio.c_cc[VREPRINT] = deftio.c_cc[VREPRINT]; #endif #ifdef VRPRNT d_tio.c_cc[VRPRNT] = deftio.c_cc[VRPRNT]; #endif #ifdef VDISCARD d_tio.c_cc[VDISCARD] = deftio.c_cc[VDISCARD]; #endif #ifdef VFLUSHO d_tio.c_cc[VFLUSHO] = deftio.c_cc[VFLUSHO]; #endif #ifdef VSTOP d_tio.c_cc[VSTOP] = deftio.c_cc[VSTOP]; #endif #ifdef VSTART d_tio.c_cc[VSTART] = deftio.c_cc[VSTART]; #endif #ifdef VSUSP d_tio.c_cc[VSUSP] = deftio.c_cc[VSUSP]; #endif #ifdef VDSUSP d_tio.c_cc[VDSUSP] = deftio.c_cc[VDSUSP]; #endif break; } } } #ifdef TIOCSLTC /* { */ d_ltc.t_suspc = '\000'; /* t_suspc */ d_ltc.t_dsuspc = '\000'; /* t_dsuspc */ d_ltc.t_rprntc = '\377'; /* reserved...*/ d_ltc.t_flushc = '\377'; d_ltc.t_werasc = '\377'; d_ltc.t_lnextc = '\377'; #endif /* } TIOCSLTC */ #ifdef USE_TERMIOS /* { */ d_tio.c_cc[VSUSP] = CSUSP; d_tio.c_cc[VDSUSP] = '\000'; d_tio.c_cc[VREPRINT] = '\377'; d_tio.c_cc[VDISCARD] = '\377'; d_tio.c_cc[VWERASE] = '\377'; d_tio.c_cc[VLNEXT] = '\377'; #endif /* } USE_TERMIOS */ #ifdef TIOCLSET /* { */ d_lmode = 0; #endif /* } TIOCLSET */ #endif /* } macII, ATT, CRAY */ #endif /* } USE_SYSV_TERMIO */ /* Init the Toolkit. */ XtSetErrorHandler(xt_error); #ifdef KTERM toplevel = XtAppInitialize (&app_con, "KTerm", #else /* !KTERM */ toplevel = XtAppInitialize (&app_con, "XTerm", #endif /* !KTERM */ optionDescList, XtNumber(optionDescList), &argc, argv, fallback_resources, NULL, 0); XtGetApplicationResources(toplevel, (XtPointer) &resource, application_resources, XtNumber(application_resources), NULL, 0); #ifdef __sgi if (resource.useLocale) setlocale(LC_ALL,""); #endif waiting_for_initial_map = resource.wait_for_map; /* * ICCCM delete_window. */ XtAppAddActions(app_con, actionProcs, XtNumber(actionProcs)); #ifdef KEEPALIVE if (resource.keepalive) { int on = 1; (void)setsockopt(ConnectionNumber(XtDisplay(toplevel)), SOL_SOCKET, SO_KEEPALIVE, (char *)&on, sizeof(on)); } #endif /* KEEPALIVE */ /* * fill in terminal modes */ if (resource.tty_modes) { int n = parse_tty_modes (resource.tty_modes, ttymodelist); if (n < 0) { fprintf (stderr, "%s: bad tty modes \"%s\"\n", ProgramName, resource.tty_modes); } else if (n > 0) { override_tty_modes = 1; } } xterm_name = resource.xterm_name; sunFunctionKeys = resource.sunFunctionKeys; #ifdef KTERM if (strcmp(xterm_name, "-") == 0) xterm_name = "kterm"; #else /* KTERM */ if (strcmp(xterm_name, "-") == 0) xterm_name = "xterm"; #endif /* KTERM */ if (resource.icon_geometry != NULL) { int scr, junk; int ix, iy; Arg args[2]; for(scr = 0; /* yyuucchh */ XtScreen(toplevel) != ScreenOfDisplay(XtDisplay(toplevel),scr); scr++); args[0].name = XtNiconX; args[1].name = XtNiconY; XGeometry(XtDisplay(toplevel), scr, resource.icon_geometry, "", 0, 0, 0, 0, 0, &ix, &iy, &junk, &junk); args[0].value = (XtArgVal) ix; args[1].value = (XtArgVal) iy; XtSetValues( toplevel, args, 2); } XtSetValues (toplevel, ourTopLevelShellArgs, number_ourTopLevelShellArgs); /* Parse the rest of the command line */ for (argc--, argv++ ; argc > 0 ; argc--, argv++) { if(**argv != '-') Syntax (*argv); switch(argv[0][1]) { case 'h': Help (); /* NOTREACHED */ #ifdef KTERM case 'v': Version (); /* NOTREACHED */ #endif /* KTERM */ case 'C': #if defined(TIOCCONS) || defined(SRIOCSREDIR) #ifndef __sgi { struct stat sbuf; /* Must be owner and have read/write permission. xdm cooperates to give the console the right user. */ if ( !stat("/dev/console", &sbuf) && (sbuf.st_uid == getuid()) && !access("/dev/console", R_OK|W_OK)) { Console = TRUE; } else Console = FALSE; } #else /* __sgi */ Console = TRUE; #endif /* __sgi */ #endif /* TIOCCONS */ continue; case 'S': if (sscanf(*argv + 2, "%c%c%d", passedPty, passedPty+1, &am_slave) != 3) Syntax(*argv); continue; #ifdef DEBUG case 'D': debug = TRUE; continue; #endif /* DEBUG */ case 'e': if (argc <= 1) Syntax (*argv); command_to_exec = ++argv; break; default: Syntax (*argv); } break; } XawSimpleMenuAddGlobalActions (app_con); XtRegisterGrabAction (HandlePopupMenu, True, (ButtonPressMask|ButtonReleaseMask), GrabModeAsync, GrabModeAsync); term = (XtermWidget) XtCreateManagedWidget( "vt100", xtermWidgetClass, toplevel, NULL, 0); /* this causes the initialize method to be called */ screen = &term->screen; if (screen->savelines < 0) screen->savelines = 0; term->flags = 0; if (!screen->jumpscroll) { term->flags |= SMOOTHSCROLL; update_jumpscroll(); } if (term->misc.reverseWrap) { term->flags |= REVERSEWRAP; update_reversewrap(); } if (term->misc.autoWrap) { term->flags |= WRAPAROUND; update_autowrap(); } if (term->misc.re_verse) { term->flags |= REVERSE_VIDEO; update_reversevideo(); } #ifdef KTERM_KANJIMODE if (term->misc.k_m) { switch (term->misc.k_m[0]) { case 'e': case 'E': case 'x': case 'X': case 'u': case 'U': term->flags |= EUC_KANJI; update_eucmode(); break; case 's': case 'S': case 'm': case 'M': term->flags |= SJIS_KANJI; update_sjismode(); break; default: break; } } #endif /* KTERM_KANJIMODE */ inhibit = 0; #ifdef ALLOWLOGGING if (term->misc.logInhibit) inhibit |= I_LOG; #endif if (term->misc.signalInhibit) inhibit |= I_SIGNAL; #ifndef KTERM_NOTEK if (term->misc.tekInhibit) inhibit |= I_TEK; #endif /* !KTERM_NOTEK */ term->initflags = term->flags; if (term->misc.appcursorDefault) { term->keyboard.flags |= CURSOR_APL; update_appcursor(); } if (term->misc.appkeypadDefault) { term->keyboard.flags |= KYPD_APL; update_appkeypad(); } /* * Set title and icon name if not specified */ if (command_to_exec) { Arg args[2]; if (!resource.title) { if (command_to_exec) { resource.title = base_name (command_to_exec[0]); } /* else not reached */ } if (!resource.icon_name) resource.icon_name = resource.title; XtSetArg (args[0], XtNtitle, resource.title); XtSetArg (args[1], XtNiconName, resource.icon_name); XtSetValues (toplevel, args, 2); } #ifndef KTERM_NOTEK if(inhibit & I_TEK) screen->TekEmu = FALSE; if(screen->TekEmu && !TekInit()) exit(ERROR_INIT); #endif /* !KTERM_NOTEK */ #ifdef DEBUG { /* Set up stderr properly. Opening this log file cannot be done securely by a privileged xterm process (although we try), so the debug feature is disabled by default. */ int i = -1; if(debug) { creat_as (getuid(), getgid(), "xterm.debug.log", 0666); i = open ("xterm.debug.log", O_WRONLY | O_TRUNC, 0666); } if(i >= 0) { #if defined(USE_SYSV_TERMIO) && !defined(SVR4) && !defined(linux) /* SYSV has another pointer which should be part of the ** FILE structure but is actually a seperate array. */ unsigned char *old_bufend; old_bufend = (unsigned char *) _bufend(stderr); #ifdef hpux stderr->__fileH = (i >> 8); stderr->__fileL = i; #else stderr->_file = i; #endif _bufend(stderr) = old_bufend; #else /* USE_SYSV_TERMIO */ #ifndef linux stderr->_file = i; #else setfileno(stderr, i); #endif #endif /* USE_SYSV_TERMIO */ /* mark this file as close on exec */ (void) fcntl(i, F_SETFD, 1); } } #endif /* DEBUG */ /* open a terminal for client */ get_terminal (); spawn (); /* Child process is out there, let's catch its termination */ signal (SIGCHLD, reapchild); /* Realize procs have now been executed */ if (am_slave) { /* Write window id so master end can read and use */ char buf[80]; buf[0] = '\0'; #ifdef KTERM_NOTEK sprintf (buf, "%lx\n", XtWindow (XtParent (term))); #else /* !KTERM_NOTEK */ sprintf (buf, "%lx\n", screen->TekEmu ? XtWindow (XtParent (tekWidget)) : XtWindow (XtParent (term))); #endif /* !KTERM_NOTEK */ write (screen->respond, buf, strlen (buf)); } #ifdef ALLOWLOGGING if (term->misc.log_on) { StartLog(screen); } #endif screen->inhibit = inhibit; #ifdef AIXV3 #if OSMAJORVERSION < 4 /* In AIXV3, xterms started from /dev/console have CLOCAL set. * This means we need to clear CLOCAL so that SIGHUP gets sent * to the slave-pty process when xterm exits. */ { struct termio tio; if(ioctl(screen->respond, TCGETA, &tio) == -1) SysError(ERROR_TIOCGETP); tio.c_cflag &= ~(CLOCAL); if (ioctl (screen->respond, TCSETA, &tio) == -1) SysError(ERROR_TIOCSETP); } #endif #endif #ifdef USE_SYSV_TERMIO if (0 > (mode = fcntl(screen->respond, F_GETFL, 0))) Error(); #ifdef O_NDELAY mode |= O_NDELAY; #else mode |= O_NONBLOCK; #endif /* O_NDELAY */ if (fcntl(screen->respond, F_SETFL, mode)) Error(); #else /* USE_SYSV_TERMIO */ mode = 1; if (ioctl (screen->respond, FIONBIO, (char *)&mode) == -1) SysError (ERROR_FIONBIO); #endif /* USE_SYSV_TERMIO */ FD_ZERO (&pty_mask); FD_ZERO (&X_mask); FD_ZERO (&Select_mask); FD_SET (screen->respond, &pty_mask); FD_SET (ConnectionNumber(screen->display), &X_mask); FD_SET (screen->respond, &Select_mask); FD_SET (ConnectionNumber(screen->display), &Select_mask); max_plus1 = (screen->respond < ConnectionNumber(screen->display)) ? (1 + ConnectionNumber(screen->display)) : (1 + screen->respond); #ifdef DEBUG if (debug) printf ("debugging on\n"); #endif /* DEBUG */ XSetErrorHandler(xerror); XSetIOErrorHandler(xioerror); for( ; ; ) { #ifndef KTERM_NOTEK if(screen->TekEmu) { TekRun(); } else #endif /* !KTERM_NOTEK */ VTRun(); } } char *base_name(name) char *name; { register char *cp; cp = strrchr(name, '/'); return(cp ? cp + 1 : name); } /* This function opens up a pty master and stuffs its value into pty. * If it finds one, it returns a value of 0. If it does not find one, * it returns a value of !0. This routine is designed to be re-entrant, * so that if a pty master is found and later, we find that the slave * has problems, we can re-enter this function and get another one. */ get_pty (pty) int *pty; { #ifdef __osf__ int tty; return (openpty(pty, &tty, ttydev, NULL, NULL)); #endif #if defined(SYSV) && defined(i386) && !defined(SVR4) /* The order of this code is *important*. On SYSV/386 we want to open a /dev/ttyp? first if at all possible. If none are available, then we'll try to open a /dev/pts??? device. The reason for this is because /dev/ttyp? works correctly, where as /dev/pts??? devices have a number of bugs, (won't update screen correcly, will hang -- it more or less works, but you really don't want to use it). Most importantly, for boxes of this nature, one of the major "features" is that you can emulate a 8086 by spawning off a UNIX program on 80386/80486 in v86 mode. In other words, you can spawn off multiple MS-DOS environments. On ISC the program that does this is named "vpix." The catcher is that "vpix" will *not* work with a /dev/pts??? device, will only work with a /dev/ttyp? device. Since we can open either a /dev/ttyp? or a /dev/pts??? device, the flag "IsPts" is set here so that we know which type of device we're dealing with in routine spawn(). That's the reason for the "if (IsPts)" statement in spawn(); we have two different device types which need to be handled differently. */ if (pty_search(pty) == 0) return 0; #endif /* SYSV && i386 && !SVR4 */ #if defined(ATT) && !defined(__sgi) if ((*pty = open ("/dev/ptmx", O_RDWR)) < 0) { return 1; } #if defined(SVR4) || defined(i386) strcpy(ttydev, ptsname(*pty)); #if defined (SYSV) && defined(i386) && !defined(SVR4) IsPts = True; #endif #endif return 0; #else /* ATT else */ #ifdef AIXV3 if ((*pty = open ("/dev/ptc", O_RDWR)) < 0) { return 1; } strcpy(ttydev, ttyname(*pty)); return 0; #endif #if defined(__sgi) && OSMAJORVERSION >= 4 { char *tty_name; tty_name = _getpty (pty, O_RDWR, 0622, 0); if (tty_name == 0) return 1; strcpy (ttydev, tty_name); return 0; } #endif #ifdef __convex__ { char *pty_name, *getpty(); while ((pty_name = getpty()) != NULL) { if ((*pty = open (pty_name, O_RDWR)) >= 0) { strcpy(ptydev, pty_name); strcpy(ttydev, pty_name); ttydev[5] = 't'; return 0; } } return 1; } #endif /* __convex__ */ #ifdef USE_GET_PSEUDOTTY return ((*pty = getpseudotty (&ttydev, &ptydev)) >= 0 ? 0 : 1); #else #if (defined(__sgi) && OSMAJORVERSION < 4) || (defined(umips) && defined (SYSTYPE_SYSV)) struct stat fstat_buf; *pty = open ("/dev/ptc", O_RDWR); if (*pty < 0 || (fstat (*pty, &fstat_buf)) < 0) { return(1); } sprintf (ttydev, "/dev/ttyq%d", minor(fstat_buf.st_rdev)); #ifndef __sgi sprintf (ptydev, "/dev/ptyq%d", minor(fstat_buf.st_rdev)); if ((*tty = open (ttydev, O_RDWR)) < 0) { close (*pty); return(1); } #endif /* !__sgi */ /* got one! */ return(0); #else /* __sgi or umips */ return pty_search(pty); #endif /* __sgi or umips else */ #endif /* USE_GET_PSEUDOTTY else */ #endif /* ATT else */ } /* * Called from get_pty to iterate over likely pseudo terminals * we might allocate. Used on those systems that do not have * a functional interface for allocating a pty. * Returns 0 if found a pty, 1 if fails. */ int pty_search(pty) int *pty; { static int devindex, letter = 0; #if defined(CRAY) || defined(sco) for (; devindex < MAXPTTYS; devindex++) { sprintf (ttydev, TTYFORMAT, devindex); sprintf (ptydev, PTYFORMAT, devindex); if ((*pty = open (ptydev, O_RDWR)) >= 0) { /* We need to set things up for our next entry * into this function! */ (void) devindex++; return 0; } } #else /* CRAY || sco */ while (PTYCHAR1[letter]) { ttydev [strlen(ttydev) - 2] = ptydev [strlen(ptydev) - 2] = PTYCHAR1 [letter]; while (PTYCHAR2[devindex]) { ttydev [strlen(ttydev) - 1] = ptydev [strlen(ptydev) - 1] = PTYCHAR2 [devindex]; /* for next time around loop or next entry to this function */ devindex++; if ((*pty = open (ptydev, O_RDWR)) >= 0) { #ifdef sun /* Need to check the process group of the pty. * If it exists, then the slave pty is in use, * and we need to get another one. */ int pgrp_rtn; if (ioctl(*pty, TIOCGPGRP, &pgrp_rtn) == 0 || errno != EIO) { close(*pty); continue; } #endif /* sun */ return 0; } } devindex = 0; (void) letter++; } #endif /* CRAY || sco else */ /* * We were unable to allocate a pty master! Return an error * condition and let our caller terminate cleanly. */ return 1; } get_terminal () /* * sets up X and initializes the terminal structure except for term.buf.fildes. */ { register TScreen *screen = &term->screen; screen->arrow = make_colored_cursor (XC_left_ptr, screen->mousecolor, screen->mousecolorback); } #ifndef KTERM_NOTEK /* * The only difference in /etc/termcap between 4014 and 4015 is that * the latter has support for switching character sets. We support the * 4015 protocol, but ignore the character switches. Therefore, we * choose 4014 over 4015. * * Features of the 4014 over the 4012: larger (19") screen, 12-bit * graphics addressing (compatible with 4012 10-bit addressing), * special point plot mode, incremental plot mode (not implemented in * later Tektronix terminals), and 4 character sizes. * All of these are supported by xterm. */ static char *tekterm[] = { "tek4014", "tek4015", /* 4014 with APL character set support */ "tek4012", /* 4010 with lower case */ "tek4013", /* 4012 with APL character set support */ "tek4010", /* small screen, upper-case only */ "dumb", 0 }; #endif /* !KTERM_NOTEK */ /* The VT102 is a VT100 with the Advanced Video Option included standard. * It also adds Escape sequences for insert/delete character/line. * The VT220 adds 8-bit character sets, selective erase. * The VT320 adds a 25th status line, terminal state interrogation. * The VT420 has up to 48 lines on the screen. */ static char *vtterm[] = { #ifdef KTERM "kterm", #endif #ifdef USE_X11TERM "x11term", /* for people who want special term name */ #endif "xterm", /* the prefered name, should be fastest */ "vt102", "vt100", "ansi", "dumb", 0 }; /* ARGSUSED */ SIGNAL_T hungtty(i) int i; { longjmp(env, 1); SIGNAL_RETURN; } /* * declared outside USE_HANDSHAKE so HsSysError() callers can use */ static int pc_pipe[2]; /* this pipe is used for parent to child transfer */ static int cp_pipe[2]; /* this pipe is used for child to parent transfer */ #ifdef USE_HANDSHAKE typedef enum { /* c == child, p == parent */ PTY_BAD, /* c->p: can't open pty slave for some reason */ PTY_FATALERROR, /* c->p: we had a fatal error with the pty */ PTY_GOOD, /* c->p: we have a good pty, let's go on */ PTY_NEW, /* p->c: here is a new pty slave, try this */ PTY_NOMORE, /* p->c; no more pty's, terminate */ UTMP_ADDED, /* c->p: utmp entry has been added */ UTMP_TTYSLOT, /* c->p: here is my ttyslot */ PTY_EXEC /* p->c: window has been mapped the first time */ } status_t; typedef struct { status_t status; int error; int fatal_error; int tty_slot; int rows; int cols; char buffer[1024]; } handshake_t; /* HsSysError() * * This routine does the equivalent of a SysError but it handshakes * over the errno and error exit to the master process so that it can * display our error message and exit with our exit code so that the * user can see it. */ void HsSysError(pf, error) int pf; int error; { handshake_t handshake; handshake.status = PTY_FATALERROR; handshake.error = errno; handshake.fatal_error = error; strcpy(handshake.buffer, ttydev); write(pf, (char *) &handshake, sizeof(handshake)); exit(error); } void first_map_occurred () { handshake_t handshake; register TScreen *screen = &term->screen; handshake.status = PTY_EXEC; handshake.rows = screen->max_row; handshake.cols = screen->max_col; write (pc_pipe[1], (char *) &handshake, sizeof(handshake)); close (cp_pipe[0]); close (pc_pipe[1]); waiting_for_initial_map = False; } #else /* * temporary hack to get xterm working on att ptys */ void HsSysError(pf, error) int pf; int error; { fprintf(stderr, "%s: fatal pty error %d (errno=%d) on tty %s\n", xterm_name, error, errno, ttydev); exit(error); } void first_map_occurred () { return; } #endif /* USE_HANDSHAKE else !USE_HANDSHAKE */ spawn () /* * Inits pty and tty and forks a login process. * Does not close fd Xsocket. * If slave, the pty named in passedPty is already open for use */ { extern char *SysErrorMsg(); register TScreen *screen = &term->screen; #ifdef USE_HANDSHAKE handshake_t handshake; #else int fds[2]; #endif int tty = -1; int discipline; int done; #ifdef USE_SYSV_TERMIO struct termio tio; struct termio dummy_tio; #ifdef TIOCLSET unsigned lmode; #endif /* TIOCLSET */ #ifdef TIOCSLTC struct ltchars ltc; #endif /* TIOCSLTC */ int one = 1; int zero = 0; int status; #else /* else not USE_SYSV_TERMIO */ unsigned lmode; struct tchars tc; struct ltchars ltc; struct sgttyb sg; #ifdef sony int jmode; struct jtchars jtc; #endif /* sony */ #endif /* USE_SYSV_TERMIO */ char termcap [1024]; char newtc [1024]; char *ptr, *shname, *shname_minus; int i, no_dev_tty = FALSE; #ifdef USE_SYSV_TERMIO char *dev_tty_name = (char *) 0; int fd; /* for /etc/wtmp */ #endif /* USE_SYSV_TERMIO */ char **envnew; /* new environment */ int envsize; /* elements in new environment */ char buf[64]; char *TermName = NULL; int ldisc = 0; #if defined(sun) && !defined(SVR4) #ifdef TIOCSSIZE struct ttysize ts; #endif /* TIOCSSIZE */ #else /* not sun */ #ifdef TIOCSWINSZ struct winsize ws; #endif /* TIOCSWINSZ */ #endif /* sun */ struct passwd *pw = NULL; #ifdef UTMP #ifdef SVR4 struct utmpx utmp; #else struct utmp utmp; #endif #ifdef LASTLOG struct lastlog lastlog; #endif /* LASTLOG */ #endif /* UTMP */ screen->uid = getuid(); screen->gid = getgid(); #ifdef linux bzero(termcap, sizeof termcap); bzero(newtc, sizeof newtc); #endif #ifdef SIGTTOU /* so that TIOCSWINSZ || TIOCSIZE doesn't block */ signal(SIGTTOU,SIG_IGN); #endif if (am_slave) { screen->respond = am_slave; #ifndef __osf__ ptydev[strlen(ptydev) - 2] = ttydev[strlen(ttydev) - 2] = passedPty[0]; ptydev[strlen(ptydev) - 1] = ttydev[strlen(ttydev) - 1] = passedPty[1]; #endif /* __osf__ */ setgid (screen->gid); setuid (screen->uid); } else { Bool tty_got_hung = False; /* * Sometimes /dev/tty hangs on open (as in the case of a pty * that has gone away). Simply make up some reasonable * defaults. */ signal(SIGALRM, hungtty); alarm(2); /* alarm(1) might return too soon */ if (! setjmp(env)) { tty = open ("/dev/tty", O_RDWR, 0); alarm(0); } else { tty_got_hung = True; tty = -1; errno = ENXIO; } signal(SIGALRM, SIG_DFL); /* * Check results and ignore current control terminal if * necessary. ENXIO is what is normally returned if there is * no controlling terminal, but some systems (e.g. SunOS 4.0) * seem to return EIO. Solaris 2.3 is said to return EINVAL. */ if (tty < 0) { if (tty_got_hung || errno == ENXIO || errno == EIO || errno == EINVAL || errno == ENOTTY) { no_dev_tty = TRUE; #ifdef TIOCSLTC ltc = d_ltc; #endif /* TIOCSLTC */ #ifdef TIOCLSET lmode = d_lmode; #endif /* TIOCLSET */ #ifdef USE_SYSV_TERMIO tio = d_tio; #else /* not USE_SYSV_TERMIO */ sg = d_sg; tc = d_tc; discipline = d_disipline; #ifdef sony jmode = d_jmode; jtc = d_jtc; #endif /* sony */ #endif /* USE_SYSV_TERMIO */ } else { SysError(ERROR_OPDEVTTY); } } else { /* Get a copy of the current terminal's state, * if we can. Some systems (e.g., SVR4 and MacII) * may not have a controlling terminal at this point * if started directly from xdm or xinit, * in which case we just use the defaults as above. */ #ifdef TIOCSLTC if(ioctl(tty, TIOCGLTC, <c) == -1) ltc = d_ltc; #endif /* TIOCSLTC */ #ifdef TIOCLSET if(ioctl(tty, TIOCLGET, &lmode) == -1) lmode = d_lmode; #endif /* TIOCLSET */ #ifdef USE_SYSV_TERMIO if(ioctl(tty, TCGETA, &tio) == -1) tio = d_tio; #else /* not USE_SYSV_TERMIO */ if(ioctl(tty, TIOCGETP, (char *)&sg) == -1) sg = d_sg; if(ioctl(tty, TIOCGETC, (char *)&tc) == -1) tc = d_tc; if(ioctl(tty, TIOCGETD, (char *)&discipline) == -1) discipline = d_disipline; #ifdef sony if(ioctl(tty, TIOCKGET, (char *)&jmode) == -1) jmode = d_jmode; if(ioctl(tty, TIOCKGETC, (char *)&jtc) == -1) jtc = d_jtc; #endif /* sony */ #endif /* USE_SYSV_TERMIO */ close (tty); /* tty is no longer an open fd! */ tty = -1; } #ifdef PUCC_PTYD if(-1 == (screen->respond = openrpty(ttydev, ptydev, (resource.utmpInhibit ? OPTY_NOP : OPTY_LOGIN), getuid(), XDisplayString(screen->display)))) { #else /* not PUCC_PTYD */ if (get_pty (&screen->respond)) { #endif /* PUCC_PTYD */ /* no ptys! */ (void) fprintf(stderr, "%s: no available ptys\n", xterm_name); exit (ERROR_PTYS); #ifdef PUCC_PTYD } #else } /* keep braces balanced for emacs */ #endif #ifdef PUCC_PTYD else { /* * set the fd of the master in a global var so * we can undo all this on exit * */ Ptyfd = screen->respond; } #endif /* PUCC_PTYD */ } /* avoid double MapWindow requests */ #ifdef KTERM_NOTEK XtSetMappedWhenManaged( XtParent(term), False ); #else /* !KTERM_NOTEK */ XtSetMappedWhenManaged( screen->TekEmu ? XtParent(tekWidget) : XtParent(term), False ); #endif /* !KTERM_NOTEK */ wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW", False); #ifndef KTERM_NOTEK if (!screen->TekEmu) #endif /* !KTERM_NOTEK */ VTInit(); /* realize now so know window size for tty driver */ #if defined(TIOCCONS) || defined(SRIOCSREDIR) if (Console) { /* * Inform any running xconsole program * that we are going to steal the console. */ XmuGetHostname (mit_console_name + MIT_CONSOLE_LEN, 255); mit_console = XInternAtom(screen->display, mit_console_name, False); /* the user told us to be the console, so we can use CurrentTime */ # ifdef KTERM_NOTEK XtOwnSelection(XtParent(term), mit_console, CurrentTime, ConvertConsoleSelection, NULL, NULL); # else /* !KTERM_NOTEK */ XtOwnSelection(screen->TekEmu ? XtParent(tekWidget) : XtParent(term), mit_console, CurrentTime, ConvertConsoleSelection, NULL, NULL); # endif /* !KTERM_NOTEK */ } #endif #ifndef KTERM_NOTEK if(screen->TekEmu) { envnew = tekterm; ptr = newtc; } else { #endif /* !KTERM_NOTEK */ envnew = vtterm; ptr = termcap; #ifndef KTERM_NOTEK } #endif /* !KTERM_NOTEK */ TermName = NULL; if (resource.term_name) { if (tgetent (ptr, resource.term_name) == 1) { TermName = resource.term_name; #ifndef KTERM_NOTEK if (!screen->TekEmu) #endif /* !KTERM_NOTEK */ resize (screen, TermName, termcap, newtc); } else { fprintf (stderr, "%s: invalid termcap entry \"%s\".\n", ProgramName, resource.term_name); } } if (!TermName) { while (*envnew != NULL) { if(tgetent(ptr, *envnew) == 1) { TermName = *envnew; #ifndef KTERM_NOTEK if(!screen->TekEmu) #endif /* !KTERM_NOTEK */ resize(screen, TermName, termcap, newtc); break; } envnew++; } if (TermName == NULL) { fprintf (stderr, "%s: unable to find usable termcap entry.\n", ProgramName); Exit (1); } } #if defined(sun) && !defined(SVR4) #ifdef TIOCSSIZE /* tell tty how big window is */ # ifndef KTERM_NOTEK if(screen->TekEmu) { ts.ts_lines = 38; ts.ts_cols = 81; } else { # endif /* !KTERM_NOTEK */ ts.ts_lines = screen->max_row + 1; ts.ts_cols = screen->max_col + 1; # ifndef KTERM_NOTEK } # endif /* !KTERM_NOTEK */ #endif /* TIOCSSIZE */ #else /* not sun */ #ifdef TIOCSWINSZ /* tell tty how big window is */ # ifndef KTERM_NOTEK if(screen->TekEmu) { ws.ws_row = 38; ws.ws_col = 81; ws.ws_xpixel = TFullWidth(screen); ws.ws_ypixel = TFullHeight(screen); } else { # endif /* !KTERM_NOTEK */ ws.ws_row = screen->max_row + 1; ws.ws_col = screen->max_col + 1; ws.ws_xpixel = FullWidth(screen); ws.ws_ypixel = FullHeight(screen); # ifndef KTERM_NOTEK } # endif /* !KTERM_NOTEK */ #endif /* TIOCSWINSZ */ #endif /* sun */ if (!am_slave) { #ifdef USE_HANDSHAKE if (pipe(pc_pipe) || pipe(cp_pipe)) SysError (ERROR_FORK); #endif if ((screen->pid = fork ()) == -1) SysError (ERROR_FORK); if (screen->pid == 0) { /* * now in child process */ extern char **environ; #if defined(_POSIX_SOURCE) || defined(SVR4) || defined(__convex__) int pgrp = setsid(); #else int pgrp = getpid(); #endif #ifdef USE_SYSV_TERMIO char numbuf[12]; #endif /* USE_SYSV_TERMIO */ #if defined(UTMP) && defined(USE_SYSV_UTMP) char* ptyname; # ifndef __sgi char* ptynameptr; # endif #endif #ifdef USE_USG_PTYS #if defined(SYSV) && defined(i386) && !defined(SVR4) if (IsPts) { /* SYSV386 supports both, which did we open? */ #endif /* SYSV && i386 && !SVR4 */ int ptyfd; setpgrp(); grantpt (screen->respond); unlockpt (screen->respond); if ((ptyfd = open (ptsname(screen->respond), O_RDWR)) < 0) { SysError (1); } if (ioctl (ptyfd, I_PUSH, "ptem") < 0) { SysError (2); } #if !defined(SVR4) && !(defined(SYSV) && defined(i386)) if (!getenv("CONSEM") && ioctl (ptyfd, I_PUSH, "consem") < 0) { SysError (3); } #endif /* !SVR4 */ if (ioctl (ptyfd, I_PUSH, "ldterm") < 0) { SysError (4); } #ifdef SVR4 /* from Sony */ if (ioctl (ptyfd, I_PUSH, "ttcompat") < 0) { SysError (5); } #endif /* SVR4 */ tty = ptyfd; close (screen->respond); #ifdef TIOCSWINSZ /* tell tty how big window is */ # ifndef KTERM_NOTEK if(screen->TekEmu) { ws.ws_row = 24; ws.ws_col = 80; ws.ws_xpixel = TFullWidth(screen); ws.ws_ypixel = TFullHeight(screen); } else { # endif /* !KTERM_NOTEK */ ws.ws_row = screen->max_row + 1; ws.ws_col = screen->max_col + 1; ws.ws_xpixel = FullWidth(screen); ws.ws_ypixel = FullHeight(screen); # ifndef KTERM_NOTEK } # endif /* !KTERM_NOTEK */ #endif #if defined(SYSV) && defined(i386) && !defined(SVR4) } else { /* else pty, not pts */ #endif /* SYSV && i386 && !SVR4 */ #endif /* USE_USG_PTYS */ #ifdef USE_HANDSHAKE /* warning, goes for a long ways */ /* close parent's sides of the pipes */ close (cp_pipe[0]); close (pc_pipe[1]); /* Make sure that our sides of the pipes are not in the * 0, 1, 2 range so that we don't fight with stdin, out * or err. */ if (cp_pipe[1] <= 2) { if ((i = fcntl(cp_pipe[1], F_DUPFD, 3)) >= 0) { (void) close(cp_pipe[1]); cp_pipe[1] = i; } } if (pc_pipe[0] <= 2) { if ((i = fcntl(pc_pipe[0], F_DUPFD, 3)) >= 0) { (void) close(pc_pipe[0]); pc_pipe[0] = i; } } /* we don't need the socket, or the pty master anymore */ close (ConnectionNumber(screen->display)); close (screen->respond); /* Now is the time to set up our process group and * open up the pty slave. */ #ifdef USE_SYSV_PGRP #if defined(CRAY) && (OSMAJORVERSION > 5) (void) setsid(); #else (void) setpgrp(); #endif #endif /* USE_SYSV_PGRP */ while (1) { #ifdef TIOCNOTTY if (!no_dev_tty && (tty = open ("/dev/tty", O_RDWR)) >= 0) { ioctl (tty, TIOCNOTTY, (char *) NULL); close (tty); } #endif /* TIOCNOTTY */ if ((tty = open(ttydev, O_RDWR, 0)) >= 0) { #if defined(CRAY) && defined(TCSETCTTY) /* make /dev/tty work */ ioctl(tty, TCSETCTTY, 0); #endif #ifdef USE_SYSV_PGRP /* We need to make sure that we are acutally * the process group leader for the pty. If * we are, then we should now be able to open * /dev/tty. */ if ((i = open("/dev/tty", O_RDWR, 0)) >= 0) { /* success! */ close(i); break; } #else /* USE_SYSV_PGRP */ break; #endif /* USE_SYSV_PGRP */ } #ifdef TIOCSCTTY ioctl(tty, TIOCSCTTY, 0); #endif /* let our master know that the open failed */ handshake.status = PTY_BAD; handshake.error = errno; strcpy(handshake.buffer, ttydev); write(cp_pipe[1], (char *) &handshake, sizeof(handshake)); /* get reply from parent */ i = read(pc_pipe[0], (char *) &handshake, sizeof(handshake)); if (i <= 0) { /* parent terminated */ exit(1); } if (handshake.status == PTY_NOMORE) { /* No more ptys, let's shutdown. */ exit(1); } /* We have a new pty to try */ free(ttydev); ttydev = malloc((unsigned) (strlen(handshake.buffer) + 1)); strcpy(ttydev, handshake.buffer); } /* use the same tty name that everyone else will use ** (from ttyname) */ if (ptr = ttyname(tty)) { /* it may be bigger */ ttydev = realloc (ttydev, (unsigned) (strlen(ptr) + 1)); (void) strcpy(ttydev, ptr); } #if defined(SYSV) && defined(i386) && !defined(SVR4) } /* end of IsPts else clause */ #endif /* SYSV && i386 && !SVR4 */ #endif /* USE_HANDSHAKE -- from near fork */ #ifdef USE_TTY_GROUP { #include struct group *ttygrp; if (ttygrp = getgrnam("tty")) { /* change ownership of tty to real uid, "tty" gid */ chown (ttydev, screen->uid, ttygrp->gr_gid); chmod (ttydev, 0620); } else { /* change ownership of tty to real group and user id */ chown (ttydev, screen->uid, screen->gid); chmod (ttydev, 0622); } endgrent(); } #else /* else !USE_TTY_GROUP */ /* change ownership of tty to real group and user id */ chown (ttydev, screen->uid, screen->gid); /* change protection of tty */ chmod (ttydev, 0622); #endif /* USE_TTY_GROUP */ /* * set up the tty modes */ { #ifdef USE_SYSV_TERMIO #if defined(umips) || defined(CRAY) || defined(linux) /* If the control tty had its modes screwed around with, eg. by lineedit in the shell, or emacs, etc. then tio will have bad values. Let's just get termio from the new tty and tailor it. */ if (ioctl (tty, TCGETA, &tio) == -1) SysError (ERROR_TIOCGETP); tio.c_lflag |= ECHOE; #endif /* umips */ /* Now is also the time to change the modes of the * child pty. */ /* input: nl->nl, don't ignore cr, cr->nl */ tio.c_iflag &= ~(INLCR|IGNCR); tio.c_iflag |= ICRNL; /* ouput: cr->cr, nl is not return, no delays, ln->cr/nl */ tio.c_oflag &= ~(OCRNL|ONLRET|NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY); tio.c_oflag |= ONLCR; #ifdef OPOST tio.c_oflag |= OPOST; #endif /* OPOST */ #ifdef BAUD_0 /* baud rate is 0 (don't care) */ tio.c_cflag &= ~(CBAUD); #else /* !BAUD_0 */ /* baud rate is 9600 (nice default) */ tio.c_cflag &= ~(CBAUD); tio.c_cflag |= B9600; #endif /* !BAUD_0 */ tio.c_cflag &= ~CSIZE; if (screen->input_eight_bits) tio.c_cflag |= CS8; else tio.c_cflag |= CS7; /* enable signals, canonical processing (erase, kill, etc), ** echo */ tio.c_lflag |= ISIG|ICANON|ECHO|ECHOE|ECHOK; #ifdef ECHOKE tio.c_lflag |= ECHOKE|IEXTEN; #endif #ifdef ECHOCTL tio.c_lflag |= ECHOCTL|IEXTEN; #endif /* reset EOL to default value */ tio.c_cc[VEOL] = CEOL; /* '^@' */ /* certain shells (ksh & csh) change EOF as well */ tio.c_cc[VEOF] = CEOF; /* '^D' */ #ifdef VLNEXT tio.c_cc[VLNEXT] = CLNEXT; #endif #ifdef VWERASE tio.c_cc[VWERASE] = CWERASE; #endif #ifdef VREPRINT tio.c_cc[VREPRINT] = CRPRNT; #endif #ifdef VRPRNT tio.c_cc[VRPRNT] = CRPRNT; #endif #ifdef VDISCARD tio.c_cc[VDISCARD] = CFLUSH; #endif #ifdef VFLUSHO tio.c_cc[VFLUSHO] = CFLUSH; #endif #ifdef VSTOP tio.c_cc[VSTOP] = CSTOP; #endif #ifdef VSTART tio.c_cc[VSTART] = CSTART; #endif #ifdef VSUSP tio.c_cc[VSUSP] = CSUSP; #endif #ifdef VDSUSP tio.c_cc[VDSUSP] = CDSUSP; #endif #define TMODE(ind,var) if (ttymodelist[ind].set) var = ttymodelist[ind].value; if (override_tty_modes) { /* sysv-specific */ TMODE (XTTYMODE_intr, tio.c_cc[VINTR]); TMODE (XTTYMODE_quit, tio.c_cc[VQUIT]); TMODE (XTTYMODE_erase, tio.c_cc[VERASE]); TMODE (XTTYMODE_kill, tio.c_cc[VKILL]); TMODE (XTTYMODE_eof, tio.c_cc[VEOF]); TMODE (XTTYMODE_eol, tio.c_cc[VEOL]); #ifdef VSWTCH TMODE (XTTYMODE_swtch, tio.c_cc[VSWTCH]); #endif #ifdef VSUSP TMODE (XTTYMODE_susp, tio.c_cc[VSUSP]); #endif #ifdef VDSUSP TMODE (XTTYMODE_dsusp, tio.c_cc[VDSUSP]); #endif #ifdef VREPRINT TMODE (XTTYMODE_rprnt, tio.c_cc[VREPRINT]); #endif #ifdef VRPRNT TMODE (XTTYMODE_rprnt, tio.c_cc[VRPRNT]); #endif #ifdef VDISCARD TMODE (XTTYMODE_flush, tio.c_cc[VDISCARD]); #endif #ifdef VFLUSHO TMODE (XTTYMODE_flush, tio.c_cc[VFLUSHO]); #endif #ifdef VWERASE TMODE (XTTYMODE_weras, tio.c_cc[VWERASE]); #endif #ifdef VLNEXT TMODE (XTTYMODE_lnext, tio.c_cc[VLNEXT]); #endif #ifdef VSTART TMODE (XTTYMODE_start, tio.c_cc[VSTART]); #endif #ifdef VSTOP TMODE (XTTYMODE_stop, tio.c_cc[VSTOP]); #endif #ifdef TIOCSLTC /* both SYSV and BSD have ltchars */ TMODE (XTTYMODE_susp, ltc.t_suspc); TMODE (XTTYMODE_dsusp, ltc.t_dsuspc); TMODE (XTTYMODE_rprnt, ltc.t_rprntc); TMODE (XTTYMODE_flush, ltc.t_flushc); TMODE (XTTYMODE_weras, ltc.t_werasc); TMODE (XTTYMODE_lnext, ltc.t_lnextc); #endif } #undef TMODE #ifdef TIOCSLTC if (ioctl (tty, TIOCSLTC, <c) == -1) HsSysError(cp_pipe[1], ERROR_TIOCSETC); #endif /* TIOCSLTC */ #ifdef TIOCLSET if (ioctl (tty, TIOCLSET, (char *)&lmode) == -1) HsSysError(cp_pipe[1], ERROR_TIOCLSET); #endif /* TIOCLSET */ if (ioctl (tty, TCSETA, &tio) == -1) HsSysError(cp_pipe[1], ERROR_TIOCSETP); #else /* USE_SYSV_TERMIO */ #ifdef KTERM sg.sg_flags &= ~(ALLDELAY | XTABS | CBREAK | RAW | EVENP | ODDP); #else /* !KTERM */ sg.sg_flags &= ~(ALLDELAY | XTABS | CBREAK | RAW); #endif /* !KTERM */ sg.sg_flags |= ECHO | CRMOD; /* make sure speed is set on pty so that editors work right*/ sg.sg_ispeed = B9600; sg.sg_ospeed = B9600; /* reset t_brkc to default value */ tc.t_brkc = -1; #ifdef LPASS8 if (screen->input_eight_bits) lmode |= LPASS8; else lmode &= ~(LPASS8); #endif #ifdef sony jmode &= ~KM_KANJI; # ifdef KTERM_KANJIMODE if (term->misc.k_m) { switch (term->misc.k_m[0]) { case 'a': case 'A': jmode |= KM_ASCII; lmode &= ~LPASS8; break; case 'e': case 'E': case 'x': case 'X': case 'u': case 'U': jmode |= KM_EUC; break; case 's': case 'S': case 'm': case 'M': jmode |= KM_SJIS; break; default: jmode |= KM_JIS; break; } } # endif /* KTERM_KANJIMODE */ jmode &= ~KM_SYSKANJI; if (ptr = getenv("SYS_CODE")) { switch (*ptr) { case 's': case 'm': jmode |= KM_SYSSJIS; break; case 'e': jmode |= KM_SYSEUC; break; } } else { jmode |= KM_SYSSJIS; } #endif /* sony */ #define TMODE(ind,var) if (ttymodelist[ind].set) var = ttymodelist[ind].value; if (override_tty_modes) { TMODE (XTTYMODE_intr, tc.t_intrc); TMODE (XTTYMODE_quit, tc.t_quitc); TMODE (XTTYMODE_erase, sg.sg_erase); TMODE (XTTYMODE_kill, sg.sg_kill); TMODE (XTTYMODE_eof, tc.t_eofc); TMODE (XTTYMODE_start, tc.t_startc); TMODE (XTTYMODE_stop, tc.t_stopc); TMODE (XTTYMODE_brk, tc.t_brkc); /* both SYSV and BSD have ltchars */ TMODE (XTTYMODE_susp, ltc.t_suspc); TMODE (XTTYMODE_dsusp, ltc.t_dsuspc); TMODE (XTTYMODE_rprnt, ltc.t_rprntc); TMODE (XTTYMODE_flush, ltc.t_flushc); TMODE (XTTYMODE_weras, ltc.t_werasc); TMODE (XTTYMODE_lnext, ltc.t_lnextc); } #undef TMODE if (ioctl (tty, TIOCSETP, (char *)&sg) == -1) HsSysError (cp_pipe[1], ERROR_TIOCSETP); if (ioctl (tty, TIOCSETC, (char *)&tc) == -1) HsSysError (cp_pipe[1], ERROR_TIOCSETC); if (ioctl (tty, TIOCSETD, (char *)&discipline) == -1) HsSysError (cp_pipe[1], ERROR_TIOCSETD); if (ioctl (tty, TIOCSLTC, (char *)<c) == -1) HsSysError (cp_pipe[1], ERROR_TIOCSLTC); if (ioctl (tty, TIOCLSET, (char *)&lmode) == -1) HsSysError (cp_pipe[1], ERROR_TIOCLSET); #ifdef sony if (ioctl (tty, TIOCKSET, (char *)&jmode) == -1) HsSysError (cp_pipe[1], ERROR_TIOCKSET); if (ioctl (tty, TIOCKSETC, (char *)&jtc) == -1) HsSysError (cp_pipe[1], ERROR_TIOCKSETC); #endif /* sony */ #endif /* !USE_SYSV_TERMIO */ #if defined(TIOCCONS) || defined(SRIOCSREDIR) if (Console) { #ifdef TIOCCONS int on = 1; if (ioctl (tty, TIOCCONS, (char *)&on) == -1) fprintf(stderr, "%s: cannot open console\n", xterm_name); #endif #ifdef SRIOCSREDIR int fd = open("/dev/console",O_RDWR); if (fd == -1 || ioctl (fd, SRIOCSREDIR, tty) == -1) fprintf(stderr, "%s: cannot open console\n", xterm_name); (void) close (fd); #endif } #endif /* TIOCCONS */ } signal (SIGCHLD, SIG_DFL); #ifdef USE_SYSV_SIGHUP /* watch out for extra shells (I don't understand either) */ signal (SIGHUP, SIG_DFL); #else signal (SIGHUP, SIG_IGN); #endif /* restore various signals to their defaults */ signal (SIGINT, SIG_DFL); signal (SIGQUIT, SIG_DFL); signal (SIGTERM, SIG_DFL); /* copy the environment before Setenving */ for (i = 0 ; environ [i] != NULL ; i++) ; /* compute number of Setenv() calls below */ envsize = 1; /* (NULL terminating entry) */ envsize += 3; /* TERM, WINDOWID, DISPLAY */ #ifdef UTMP envsize += 1; /* LOGNAME */ #endif /* UTMP */ #ifdef USE_SYSV_ENVVARS #ifndef TIOCSWINSZ /* window size not stored in driver? */ envsize += 2; /* COLUMNS, LINES */ #endif /* TIOCSWINSZ */ #ifdef UTMP envsize += 2; /* HOME, SHELL */ #endif /* UTMP */ #else /* USE_SYSV_ENVVARS */ envsize += 1; /* TERMCAP */ #endif /* USE_SYSV_ENVVARS */ envnew = (char **) calloc ((unsigned) i + envsize, sizeof(char *)); memmove( (char *)envnew, (char *)environ, i * sizeof(char *)); environ = envnew; Setenv ("TERM=", TermName); if(!TermName) *newtc = 0; #ifdef KTERM_NOTEK sprintf (buf, "%lu", ((unsigned long) XtWindow (XtParent(term)))); #else /* !KTERM_NOTEK */ sprintf (buf, "%lu", screen->TekEmu ? ((unsigned long) XtWindow (XtParent(tekWidget))) : ((unsigned long) XtWindow (XtParent(term)))); #endif /* !KTERM_NOTEK */ Setenv ("WINDOWID=", buf); /* put the display into the environment of the shell*/ Setenv ("DISPLAY=", XDisplayString (screen->display)); signal(SIGTERM, SIG_DFL); /* this is the time to go and set up stdin, out, and err */ { #if defined(CRAY) && (OSMAJORVERSION >= 6) (void) close(tty); (void) close(0); if (open ("/dev/tty", O_RDWR)) { fprintf(stderr, "cannot open /dev/tty\n"); exit(1); } (void) close(1); (void) close(2); dup(0); dup(0); #else /* dup the tty */ for (i = 0; i <= 2; i++) if (i != tty) { (void) close(i); (void) dup(tty); } #ifndef ATT /* and close the tty */ if (tty > 2) (void) close(tty); #endif #endif /* CRAY */ } #ifndef USE_SYSV_PGRP #ifdef TIOCSCTTY setsid(); ioctl(0, TIOCSCTTY, 0); #endif ioctl(0, TIOCSPGRP, (char *)&pgrp); #ifndef __osf__ setpgrp(0,0); #else setpgid(0,0); #endif close(open(ttydev, O_WRONLY, 0)); #ifndef __osf__ setpgrp (0, pgrp); #else setpgid (0, pgrp); #endif #endif /* !USE_SYSV_PGRP */ #ifdef UTMP pw = getpwuid(screen->uid); if (pw && pw->pw_name) Setenv ("LOGNAME=", pw->pw_name); /* for POSIX */ #ifdef USE_SYSV_UTMP /* Set up our utmp entry now. We need to do it here ** for the following reasons: ** - It needs to have our correct process id (for ** login). ** - If our parent was to set it after the fork(), ** it might make it out before we need it. ** - We need to do it before we go and change our ** user and group id's. */ #ifdef CRAY #define PTYCHARLEN 4 #else #ifdef __osf__ #define PTYCHARLEN 5 #else #define PTYCHARLEN 2 #endif #endif (void) setutent (); /* set up entry to search for */ ptyname = ttydev; #ifndef __sgi if (PTYCHARLEN >= (int)strlen(ptyname)) ptynameptr = ptyname; else ptynameptr = ptyname + strlen(ptyname) - PTYCHARLEN; (void) strncpy(utmp.ut_id, ptynameptr, sizeof (utmp.ut_id)); #else (void) strncpy(utmp.ut_id,ptyname + sizeof("/dev/tty")-1, sizeof (utmp.ut_id)); #endif utmp.ut_type = DEAD_PROCESS; /* position to entry in utmp file */ (void) getutid(&utmp); /* set up the new entry */ utmp.ut_type = USER_PROCESS; #ifndef linux utmp.ut_exit.e_exit = 2; #endif (void) strncpy(utmp.ut_user, (pw && pw->pw_name) ? pw->pw_name : "????", sizeof(utmp.ut_user)); #ifndef __sgi (void)strncpy(utmp.ut_id, ptynameptr, sizeof(utmp.ut_id)); #else (void) strncpy(utmp.ut_id,ptyname + sizeof("/dev/tty")-1, sizeof (utmp.ut_id)); #endif (void) strncpy (utmp.ut_line, ptyname + strlen("/dev/"), sizeof (utmp.ut_line)); #ifdef HAS_UTMP_UT_HOST (void) strncpy(buf, DisplayString(screen->display), sizeof(buf)); #ifndef linux { char *disfin = strrchr(buf, ':'); if (disfin) *disfin = '\0'; } #endif (void) strncpy(utmp.ut_host, buf, sizeof(utmp.ut_host)); #endif (void) strncpy(utmp.ut_name, pw->pw_name, sizeof(utmp.ut_name)); utmp.ut_pid = getpid(); #ifdef SVR4 utmp.ut_session = getsid(0); utmp.ut_xtime = time ((Time_t *) 0); utmp.ut_tv.tv_usec = 0; #else utmp.ut_time = time ((Time_t *) 0); #endif /* write out the entry */ if (!resource.utmpInhibit) (void) pututline(&utmp); #ifdef WTMP #ifdef SVR4 if (term->misc.login_shell) updwtmpx(WTMPX_FILE, &utmp); #else if (term->misc.login_shell && (i = open(etc_wtmp, O_WRONLY|O_APPEND)) >= 0) { write(i, (char *)&utmp, sizeof(struct utmp)); close(i); } #endif #endif /* close the file */ (void) endutent(); #else /* USE_SYSV_UTMP */ /* We can now get our ttyslot! We can also set the initial * UTMP entry. */ tslot = ttyslot(); added_utmp_entry = False; { if (pw && !resource.utmpInhibit && (i = open(etc_utmp, O_WRONLY)) >= 0) { bzero((char *)&utmp, sizeof(struct utmp)); (void) strncpy(utmp.ut_line, ttydev + strlen("/dev/"), sizeof(utmp.ut_line)); (void) strncpy(utmp.ut_name, pw->pw_name, sizeof(utmp.ut_name)); #ifdef HAS_UTMP_UT_HOST (void) strncpy(utmp.ut_host, XDisplayString (screen->display), sizeof(utmp.ut_host)); #endif /* cast needed on Ultrix 4.4 */ time((Time_t*)&utmp.ut_time); lseek(i, (long)(tslot * sizeof(struct utmp)), 0); write(i, (char *)&utmp, sizeof(struct utmp)); close(i); added_utmp_entry = True; #ifdef WTMP if (term->misc.login_shell && (i = open(etc_wtmp, O_WRONLY|O_APPEND)) >= 0) { int status; status = write(i, (char *)&utmp, sizeof(struct utmp)); status = close(i); } #endif /* WTMP */ #ifdef LASTLOG if (term->misc.login_shell && (i = open(etc_lastlog, O_WRONLY)) >= 0) { bzero((char *)&lastlog, sizeof (struct lastlog)); (void) strncpy(lastlog.ll_line, ttydev + sizeof("/dev"), sizeof (lastlog.ll_line)); (void) strncpy(lastlog.ll_host, XDisplayString (screen->display), sizeof (lastlog.ll_host)); time(&lastlog.ll_time); lseek(i, (long)(screen->uid * sizeof (struct lastlog)), 0); write(i, (char *)&lastlog, sizeof (struct lastlog)); close(i); } #endif /* LASTLOG */ } else tslot = -tslot; } /* Let's pass our ttyslot to our parent so that it can * clean up after us. */ #ifdef USE_HANDSHAKE handshake.tty_slot = tslot; #endif /* USE_HANDSHAKE */ #endif /* USE_SYSV_UTMP */ #ifdef USE_HANDSHAKE /* Let our parent know that we set up our utmp entry * so that it can clean up after us. */ handshake.status = UTMP_ADDED; handshake.error = 0; strcpy(handshake.buffer, ttydev); (void)write(cp_pipe[1], (char *)&handshake, sizeof(handshake)); #endif /* USE_HANDSHAKE */ #endif/* UTMP */ (void) setgid (screen->gid); #ifdef HAS_BSD_GROUPS if (geteuid() == 0 && pw) initgroups (pw->pw_name, pw->pw_gid); #endif (void) setuid (screen->uid); #ifdef USE_HANDSHAKE /* mark the pipes as close on exec */ fcntl(cp_pipe[1], F_SETFD, 1); fcntl(pc_pipe[0], F_SETFD, 1); /* We are at the point where we are going to * exec our shell (or whatever). Let our parent * know we arrived safely. */ handshake.status = PTY_GOOD; handshake.error = 0; (void)strcpy(handshake.buffer, ttydev); (void)write(cp_pipe[1], (char *)&handshake, sizeof(handshake)); if (waiting_for_initial_map) { i = read (pc_pipe[0], (char *) &handshake, sizeof(handshake)); if (i != sizeof(handshake) || handshake.status != PTY_EXEC) { /* some very bad problem occurred */ exit (ERROR_PTY_EXEC); } if(handshake.rows > 0 && handshake.cols > 0) { screen->max_row = handshake.rows; screen->max_col = handshake.cols; #if defined(sun) && !defined(SVR4) #ifdef TIOCSSIZE ts.ts_lines = screen->max_row + 1; ts.ts_cols = screen->max_col + 1; #endif /* TIOCSSIZE */ #else /* !sun */ #ifdef TIOCSWINSZ ws.ws_row = screen->max_row + 1; ws.ws_col = screen->max_col + 1; ws.ws_xpixel = FullWidth(screen); ws.ws_ypixel = FullHeight(screen); #endif /* TIOCSWINSZ */ #endif /* sun else !sun */ } } #endif /* USE_HANDSHAKE */ #ifdef USE_SYSV_ENVVARS #ifndef TIOCSWINSZ sprintf (numbuf, "%d", screen->max_col + 1); Setenv("COLUMNS=", numbuf); sprintf (numbuf, "%d", screen->max_row + 1); Setenv("LINES=", numbuf); #endif #ifdef UTMP if (pw) { /* SVR4 doesn't provide these */ if (!getenv("HOME")) Setenv("HOME=", pw->pw_dir); if (!getenv("SHELL")) Setenv("SHELL=", pw->pw_shell); } #endif /* UTMP */ #else /* USE_SYSV_ENVVAR */ # ifndef KTERM_NOTEK if(!screen->TekEmu) { # endif /* !KTERM_NOTEK */ strcpy (termcap, newtc); resize (screen, TermName, termcap, newtc); # ifndef KTERM_NOTEK } # endif /* !KTERM_NOTEK */ if (term->misc.titeInhibit) { remove_termcap_entry (newtc, ":ti="); remove_termcap_entry (newtc, ":te="); } /* * work around broken termcap entries */ if (resource.useInsertMode) { remove_termcap_entry (newtc, ":ic="); /* don't get duplicates */ remove_termcap_entry (newtc, ":im="); remove_termcap_entry (newtc, ":ei="); remove_termcap_entry (newtc, ":mi"); strcat (newtc, ":im=\\E[4h:ei=\\E[4l:mi:"); } Setenv ("TERMCAP=", newtc); # ifdef sony switch (jmode & KM_KANJI) { case KM_JIS: Setenv ("TTYPE=", "jis"); break; case KM_SJIS: Setenv ("TTYPE=", "sjis"); break; case KM_EUC: Setenv ("TTYPE=", "euc"); break; case KM_ASCII: defaults: Setenv ("TTYPE=", "ascii"); break; } # endif /* sony */ #endif /* USE_SYSV_ENVVAR */ /* need to reset after all the ioctl bashing we did above */ #if defined(sun) && !defined(SVR4) #ifdef TIOCSSIZE ioctl (0, TIOCSSIZE, &ts); #endif /* TIOCSSIZE */ #else /* not sun */ #ifdef TIOCSWINSZ ioctl (0, TIOCSWINSZ, (char *)&ws); #endif /* TIOCSWINSZ */ #endif /* sun */ signal(SIGHUP, SIG_DFL); if (command_to_exec) { execvp(*command_to_exec, command_to_exec); /* print error message on screen */ fprintf(stderr, "%s: Can't execvp %s\n", xterm_name, *command_to_exec); } #ifdef USE_SYSV_SIGHUP /* fix pts sh hanging around */ signal (SIGHUP, SIG_DFL); #endif #ifdef UTMP if(((ptr = getenv("SHELL")) == NULL || *ptr == 0) && ((pw == NULL && (pw = getpwuid(screen->uid)) == NULL) || *(ptr = pw->pw_shell) == 0)) #else /* UTMP */ if(((ptr = getenv("SHELL")) == NULL || *ptr == 0) && ((pw = getpwuid(screen->uid)) == NULL || *(ptr = pw->pw_shell) == 0)) #endif /* UTMP */ ptr = "/bin/sh"; if(shname = strrchr(ptr, '/')) shname++; else shname = ptr; shname_minus = malloc(strlen(shname) + 2); (void) strcpy(shname_minus, "-"); (void) strcat(shname_minus, shname); #ifndef USE_SYSV_TERMIO ldisc = XStrCmp("csh", shname + strlen(shname) - 3) == 0 ? NTTYDISC : 0; ioctl(0, TIOCSETD, (char *)&ldisc); #endif /* !USE_SYSV_TERMIO */ #ifdef USE_LOGIN_DASH_P if (term->misc.login_shell && pw && added_utmp_entry) execl (bin_login, "login", "-p", "-f", pw->pw_name, 0); #endif execlp (ptr, (term->misc.login_shell ? shname_minus : shname), 0); /* Exec failed. */ fprintf (stderr, "%s: Could not exec %s!\n", xterm_name, ptr); (void) sleep(5); exit(ERROR_EXEC); } /* end if in child after fork */ #ifdef USE_HANDSHAKE /* Parent process. Let's handle handshaked requests to our * child process. */ /* close childs's sides of the pipes */ close (cp_pipe[1]); close (pc_pipe[0]); for (done = 0; !done; ) { if (read(cp_pipe[0], (char *) &handshake, sizeof(handshake)) <= 0) { /* Our child is done talking to us. If it terminated * due to an error, we will catch the death of child * and clean up. */ break; } switch(handshake.status) { case PTY_GOOD: /* Success! Let's free up resources and * continue. */ done = 1; break; case PTY_BAD: /* The open of the pty failed! Let's get * another one. */ (void) close(screen->respond); if (get_pty(&screen->respond)) { /* no more ptys! */ (void) fprintf(stderr, "%s: child process can find no available ptys\n", xterm_name); handshake.status = PTY_NOMORE; write(pc_pipe[1], (char *) &handshake, sizeof(handshake)); exit (ERROR_PTYS); } handshake.status = PTY_NEW; (void) strcpy(handshake.buffer, ttydev); write(pc_pipe[1], (char *) &handshake, sizeof(handshake)); break; case PTY_FATALERROR: errno = handshake.error; close(cp_pipe[0]); close(pc_pipe[1]); SysError(handshake.fatal_error); case UTMP_ADDED: /* The utmp entry was set by our slave. Remember * this so that we can reset it later. */ added_utmp_entry = True; #ifndef USE_SYSV_UTMP tslot = handshake.tty_slot; #endif /* USE_SYSV_UTMP */ free(ttydev); ttydev = malloc((unsigned) strlen(handshake.buffer) + 1); strcpy(ttydev, handshake.buffer); break; default: fprintf(stderr, "%s: unexpected handshake status %d\n", xterm_name, handshake.status); } } /* close our sides of the pipes */ if (!waiting_for_initial_map) { close (cp_pipe[0]); close (pc_pipe[1]); } #endif /* USE_HANDSHAKE */ } /* end if no slave */ /* * still in parent (xterm process) */ #ifdef USE_SYSV_SIGHUP /* hung sh problem? */ signal (SIGHUP, SIG_DFL); #else signal (SIGHUP,SIG_IGN); #endif /* * Unfortunately, System V seems to have trouble divorcing the child process * from the process group of xterm. This is a problem because hitting the * INTR or QUIT characters on the keyboard will cause xterm to go away if we * don't ignore the signals. This is annoying. */ #if defined(USE_SYSV_SIGNALS) && !defined(SIGTSTP) signal (SIGINT, SIG_IGN); #ifndef SYSV /* hung shell problem */ signal (SIGQUIT, SIG_IGN); #endif signal (SIGTERM, SIG_IGN); #else /* else is bsd or has job control */ #if defined(SYSV) || defined(__osf__) /* if we were spawned by a jobcontrol smart shell (like ksh or csh), * then our pgrp and pid will be the same. If we were spawned by * a jobcontrol dumb shell (like /bin/sh), then we will be in our * parent's pgrp, and we must ignore keyboard signals, or we will * tank on everything. */ if (getpid() == getpgrp()) { (void) signal(SIGINT, Exit); (void) signal(SIGQUIT, Exit); (void) signal(SIGTERM, Exit); } else { (void) signal(SIGINT, SIG_IGN); (void) signal(SIGQUIT, SIG_IGN); (void) signal(SIGTERM, SIG_IGN); } (void) signal(SIGPIPE, Exit); #else /* SYSV */ signal (SIGINT, Exit); signal (SIGQUIT, Exit); signal (SIGTERM, Exit); signal (SIGPIPE, Exit); #endif /* SYSV */ #endif /* USE_SYSV_SIGNALS and not SIGTSTP */ return 0; } /* end spawn */ SIGNAL_T Exit(n) int n; { register TScreen *screen = &term->screen; int pty = term->screen.respond; /* file descriptor of pty */ #ifdef UTMP #ifdef USE_SYSV_UTMP #ifdef SVR4 struct utmpx utmp; struct utmpx *utptr; #else struct utmp utmp; struct utmp *utptr; #endif char* ptyname; char* ptynameptr; #if defined(WTMP) && !defined(SVR4) int fd; /* for /etc/wtmp */ int i; #endif /* don't do this more than once */ if (xterm_exiting) SIGNAL_RETURN; xterm_exiting = True; #ifdef PUCC_PTYD closepty(ttydev, ptydev, (resource.utmpInhibit ? OPTY_NOP : OPTY_LOGIN), Ptyfd); #endif /* PUCC_PTYD */ /* cleanup the utmp entry we forged earlier */ if (!resource.utmpInhibit #ifdef USE_HANDSHAKE /* without handshake, no way to know */ && added_utmp_entry #endif /* USE_HANDSHAKE */ ) { ptyname = ttydev; utmp.ut_type = USER_PROCESS; if (PTYCHARLEN >= (int)strlen(ptyname)) ptynameptr = ptyname; else ptynameptr = ptyname + strlen(ptyname) - PTYCHARLEN; (void) strncpy(utmp.ut_id, ptynameptr, sizeof(utmp.ut_id)); (void) setutent(); utptr = getutid(&utmp); /* write it out only if it exists, and the pid's match */ if (utptr && (utptr->ut_pid == screen->pid)) { utptr->ut_type = DEAD_PROCESS; #ifdef SVR4 utmp.ut_session = getsid(0); utmp.ut_xtime = time ((Time_t *) 0); utmp.ut_tv.tv_usec = 0; #else utptr->ut_time = time((Time_t *) 0); #endif (void) pututline(utptr); #ifdef WTMP #ifdef SVR4 updwtmpx(WTMPX_FILE, &utmp); #else /* set wtmp entry if wtmp file exists */ if ((fd = open(etc_wtmp, O_WRONLY | O_APPEND)) >= 0) { i = write(fd, utptr, sizeof(utmp)); i = close(fd); } #endif #endif } (void) endutent(); } #else /* not USE_SYSV_UTMP */ register int wfd; register int i; struct utmp utmp; if (!resource.utmpInhibit && added_utmp_entry && (!am_slave && tslot > 0 && (wfd = open(etc_utmp, O_WRONLY)) >= 0)){ bzero((char *)&utmp, sizeof(struct utmp)); lseek(wfd, (long)(tslot * sizeof(struct utmp)), 0); write(wfd, (char *)&utmp, sizeof(struct utmp)); close(wfd); #ifdef WTMP if (term->misc.login_shell && (wfd = open(etc_wtmp, O_WRONLY | O_APPEND)) >= 0) { (void) strncpy(utmp.ut_line, ttydev + sizeof("/dev"), sizeof (utmp.ut_line)); time(&utmp.ut_time); i = write(wfd, (char *)&utmp, sizeof(struct utmp)); i = close(wfd); } #endif /* WTMP */ } #endif /* USE_SYSV_UTMP */ #endif /* UTMP */ close(pty); /* close explicitly to avoid race with slave side */ #ifdef ALLOWLOGGING if(screen->logging) CloseLog(screen); #endif if (!am_slave) { /* restore ownership of tty and pty */ chown (ttydev, 0, 0); #if (!defined(__sgi) && !defined(__osf__)) chown (ptydev, 0, 0); #endif /* restore modes of tty and pty */ chmod (ttydev, 0666); #if (!defined(__sgi) && !defined(__osf__)) chmod (ptydev, 0666); #endif } exit(n); SIGNAL_RETURN; } /* ARGSUSED */ resize(screen, TermName, oldtc, newtc) TScreen *screen; char *TermName; register char *oldtc, *newtc; { #ifndef USE_SYSV_ENVVARS register char *ptr1, *ptr2; register int i; register int li_first = 0; register char *temp; if ((ptr1 = strindex (oldtc, "co#")) == NULL){ strcat (oldtc, "co#80:"); ptr1 = strindex (oldtc, "co#"); } if ((ptr2 = strindex (oldtc, "li#")) == NULL){ strcat (oldtc, "li#24:"); ptr2 = strindex (oldtc, "li#"); } if(ptr1 > ptr2) { li_first++; temp = ptr1; ptr1 = ptr2; ptr2 = temp; } ptr1 += 3; ptr2 += 3; strncpy (newtc, oldtc, i = ptr1 - oldtc); newtc += i; sprintf (newtc, "%d", li_first ? screen->max_row + 1 : screen->max_col + 1); newtc += strlen(newtc); ptr1 = strchr(ptr1, ':'); strncpy (newtc, ptr1, i = ptr2 - ptr1); newtc += i; sprintf (newtc, "%d", li_first ? screen->max_col + 1 : screen->max_row + 1); ptr2 = strchr(ptr2, ':'); strcat (newtc, ptr2); #endif /* USE_SYSV_ENVVARS */ } /* * Does a non-blocking wait for a child process. If the system * doesn't support non-blocking wait, do nothing. * Returns the pid of the child, or 0 or -1 if none or error. */ int nonblocking_wait() { #ifdef USE_POSIX_WAIT pid_t pid; pid = waitpid(-1, NULL, WNOHANG); #else /* USE_POSIX_WAIT */ #if defined(USE_SYSV_SIGNALS) && (defined(CRAY) || !defined(SIGTSTP)) /* cannot do non-blocking wait */ int pid = 0; #else /* defined(USE_SYSV_SIGNALS) && (defined(CRAY) || !defined(SIGTSTP)) */ union wait status; register int pid; pid = wait3 (&status, WNOHANG, (struct rusage *)NULL); #endif /* defined(USE_SYSV_SIGNALS) && !defined(SIGTSTP) */ #endif /* USE_POSIX_WAIT else */ return pid; } /* ARGSUSED */ static SIGNAL_T reapchild (n) int n; { int pid; pid = wait(NULL); #ifdef USE_SYSV_SIGNALS /* cannot re-enable signal before waiting for child because then SVR4 loops. Sigh. HP-UX 9.01 too. */ (void) signal(SIGCHLD, reapchild); #endif do { if (pid == term->screen.pid) { #ifdef DEBUG if (debug) fputs ("Exiting\n", stderr); #endif Cleanup (0); } } while ( (pid=nonblocking_wait()) > 0); SIGNAL_RETURN; } /* VARARGS1 */ consolepr(fmt,x0,x1,x2,x3,x4,x5,x6,x7,x8,x9) char *fmt; { extern char *SysErrorMsg(); int oerrno; int f; char buf[ BUFSIZ ]; oerrno = errno; strcpy(buf, "xterm: "); sprintf(buf+strlen(buf), fmt, x0,x1,x2,x3,x4,x5,x6,x7,x8,x9); strcat(buf, ": "); strcat(buf, SysErrorMsg (oerrno)); strcat(buf, "\n"); f = open("/dev/console",O_WRONLY); write(f, buf, strlen(buf)); close(f); #ifdef TIOCNOTTY if ((f = open("/dev/tty", 2)) >= 0) { ioctl(f, TIOCNOTTY, (char *)NULL); close(f); } #endif /* TIOCNOTTY */ } remove_termcap_entry (buf, str) char *buf; char *str; { register char *strinbuf; strinbuf = strindex (buf, str); if (strinbuf) { register char *colonPtr = strchr(strinbuf+1, ':'); if (colonPtr) { while (*colonPtr) { *strinbuf++ = *colonPtr++; /* copy down */ } *strinbuf = '\0'; } else { strinbuf[1] = '\0'; } } return 0; } /* * parse_tty_modes accepts lines of the following form: * * [SETTING] ... * * where setting consists of the words in the modelist followed by a character * or ^char. */ static int parse_tty_modes (s, modelist) char *s; struct _xttymodes *modelist; { struct _xttymodes *mp; int c; int count = 0; while (1) { while (*s && isascii(*s) && isspace(*s)) s++; if (!*s) return count; for (mp = modelist; mp->name; mp++) { if (strncmp (s, mp->name, mp->len) == 0) break; } if (!mp->name) return -1; s += mp->len; while (*s && isascii(*s) && isspace(*s)) s++; if (!*s) return -1; if (*s == '^') { s++; c = ((*s == '?') ? 0177 : *s & 31); /* keep control bits */ } else { c = *s; } mp->value = c; mp->set = 1; count++; s++; } } int GetBytesAvailable (fd) int fd; { #ifdef FIONREAD static long arg; ioctl (fd, FIONREAD, (char *) &arg); return (int) arg; #else #if defined(KTERM_XAW3D) && defined(FIORDCK) return ioctl (fd, FIORDCHK, NULL); #else /* !KTERM_XAW3D || !FIORDCK */ struct pollfd pollfds[1]; pollfds[0].fd = fd; pollfds[0].events = POLLIN; return poll (pollfds, 1, 0); #endif /* !KTERM_XAW3D || !FIORDCK */ #endif } /* Utility function to try to hide system differences from everybody who used to call killpg() */ int kill_process_group(pid, sig) int pid; int sig; { #ifndef X_NOT_POSIX return kill (-pid, sig); #else #if defined(SVR4) || defined(SYSV) return kill (-pid, sig); #else return killpg (pid, sig); #endif #endif } kterm-6.2.0.orig/main.h100444 507 454 2424 4754067206 13416 0ustar yosiakiaux/* * $XConsortium: main.h,v 1.5 91/02/06 16:00:15 gildea Exp $ */ /* * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ #define DEFFONT "fixed" #define DEFBOLDFONT NULL /* no bold font uses overstriking */ #define DEFBORDER 2 #define DEFBORDERWIDTH 2 kterm-6.2.0.orig/menu.c100444 507 454 104606 6165124573 13475 0ustar yosiakiaux/* $XConsortium: menu.c,v 1.63 94/04/17 20:23:30 gildea Exp $ */ /* $XConsortium: menu.c /main/64 1996/01/14 16:52:55 kaleb $ */ /* Copyright (c) 1989 X Consortium Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium. */ #include "ptyx.h" #include "data.h" #include "menu.h" #include #include #ifdef KTERM_XIM #include #endif /* KTERM_XIM */ #include #include #include #include #include #include extern void FindFontSelection(); Arg menuArgs[2] = {{ XtNleftBitmap, (XtArgVal) 0 }, { XtNsensitive, (XtArgVal) 0 }}; void do_hangup(); static void do_securekbd(), do_allowsends(), do_visualbell(), #ifdef ALLOWLOGGING do_logging(), #endif do_redraw(), do_suspend(), do_continue(), do_interrupt(), do_terminate(), do_kill(), do_quit(), do_scrollbar(), do_jumpscroll(), do_reversevideo(), do_autowrap(), do_reversewrap(), do_autolinefeed(), do_appcursor(), do_appkeypad(), do_scrollkey(), do_scrollttyoutput(), #ifdef KTERM_NOTEK do_allow132(), do_cursesemul(), do_marginbell(), do_altscreen(), do_softreset(), do_hardreset(), do_clearsavedlines(), do_vtfont(); #else /* !KTERM_NOTEK */ do_allow132(), do_cursesemul(), do_marginbell(), do_tekshow(), do_altscreen(), do_softreset(), do_hardreset(), do_clearsavedlines(), do_tekmode(), do_vthide(), do_tektextlarge(), do_tektext2(), do_tektext3(), do_tektextsmall(), do_tekpage(), do_tekreset(), do_tekcopy(), do_vtshow(), do_vtmode(), do_tekhide(), do_vtfont(); #endif /* !KTERM_NOTEK */ #ifdef STATUSLINE static void do_statusline(), do_reversestatus(); #endif /* STATUSLINE */ #ifdef KTERM_KANJIMODE static void do_eucmode(); static void do_sjismode(); #endif /* KTERM_KANJIMODE */ #ifdef KTERM_XIM static void do_openim(); #endif /* KTERM_XIM */ /* * The order entries MUST match the values given in menu.h */ MenuEntry mainMenuEntries[] = { { "securekbd", do_securekbd, NULL }, /* 0 */ { "allowsends", do_allowsends, NULL }, /* 1 */ #ifdef ALLOWLOGGING { "logging", do_logging, NULL }, /* 2 */ #endif { "redraw", do_redraw, NULL }, /* 3 */ { "line1", NULL, NULL }, /* 4 */ { "suspend", do_suspend, NULL }, /* 5 */ { "continue", do_continue, NULL }, /* 6 */ { "interrupt", do_interrupt, NULL }, /* 7 */ { "hangup", do_hangup, NULL }, /* 8 */ { "terminate", do_terminate, NULL }, /* 9 */ { "kill", do_kill, NULL }, /* 10 */ { "line2", NULL, NULL }, /* 11 */ { "quit", do_quit, NULL }}; /* 12 */ MenuEntry vtMenuEntries[] = { { "scrollbar", do_scrollbar, NULL }, /* 0 */ { "jumpscroll", do_jumpscroll, NULL }, /* 1 */ { "reversevideo", do_reversevideo, NULL }, /* 2 */ { "autowrap", do_autowrap, NULL }, /* 3 */ { "reversewrap", do_reversewrap, NULL }, /* 4 */ { "autolinefeed", do_autolinefeed, NULL }, /* 5 */ { "appcursor", do_appcursor, NULL }, /* 6 */ { "appkeypad", do_appkeypad, NULL }, /* 7 */ { "scrollkey", do_scrollkey, NULL }, /* 8 */ { "scrollttyoutput",do_scrollttyoutput, NULL }, /* 9 */ { "allow132", do_allow132, NULL }, /* 10 */ { "cursesemul", do_cursesemul, NULL }, /* 11 */ { "visualbell", do_visualbell, NULL }, /* 12 */ { "marginbell", do_marginbell, NULL }, /* 13 */ { "altscreen", do_altscreen, NULL }, /* 14 */ { "line1", NULL, NULL }, /* 15 */ { "softreset", do_softreset, NULL }, /* 16 */ { "hardreset", do_hardreset, NULL }, /* 17 */ { "clearsavedlines",do_clearsavedlines, NULL }, /* 18 */ #ifndef KTERM_NOTEK { "line2", NULL, NULL }, /* 19 */ { "tekshow", do_tekshow, NULL }, /* 20 */ { "tekmode", do_tekmode, NULL }, /* 21 */ #endif /* !KTERM_NOTEK */ #if defined(STATUSLINE) || defined(KTERM) # ifndef KTERM_NOTEK { "vthide", do_vthide, NULL }, /* 22 */ # endif /* !KTERM_NOTEK */ { "line3", NULL, NULL }, /* 23 */ # ifdef STATUSLINE { "statusline", do_statusline, NULL }, /* 24 */ { "reversestatus", do_reversestatus, NULL }, /* 25 */ # endif /* STATUSLINE */ # ifdef KTERM_KANJIMODE { "eucmode", do_eucmode, NULL }, /* 24 or 26 */ { "sjismode", do_sjismode, NULL }, /* 25 or 27 */ # endif /* KTERM_KANJIMODE */ # ifdef KTERM_XIM { "openim", do_openim, NULL }, /* 24, 26 or 28 */ # endif /* KTERM_XIM */ }; #else /* !STATUSLINE && !KTERM */ { "vthide", do_vthide, NULL }}; /* 22 */ #endif /* !STATUSLINE && !KTERM */ MenuEntry fontMenuEntries[] = { { "fontdefault", do_vtfont, NULL }, /* 0 */ { "font1", do_vtfont, NULL }, /* 1 */ { "font2", do_vtfont, NULL }, /* 2 */ { "font3", do_vtfont, NULL }, /* 3 */ { "font4", do_vtfont, NULL }, /* 4 */ { "font5", do_vtfont, NULL }, /* 5 */ { "font6", do_vtfont, NULL }, /* 6 */ { "fontescape", do_vtfont, NULL }, /* 7 */ { "fontsel", do_vtfont, NULL }}; /* 8 */ /* this should match NMENUFONTS in ptyx.h */ #ifndef KTERM_NOTEK MenuEntry tekMenuEntries[] = { { "tektextlarge", do_tektextlarge, NULL }, /* 0 */ { "tektext2", do_tektext2, NULL }, /* 1 */ { "tektext3", do_tektext3, NULL }, /* 2 */ { "tektextsmall", do_tektextsmall, NULL }, /* 3 */ { "line1", NULL, NULL }, /* 4 */ { "tekpage", do_tekpage, NULL }, /* 5 */ { "tekreset", do_tekreset, NULL }, /* 6 */ { "tekcopy", do_tekcopy, NULL }, /* 7 */ { "line2", NULL, NULL }, /* 8 */ { "vtshow", do_vtshow, NULL }, /* 9 */ { "vtmode", do_vtmode, NULL }, /* 10 */ { "tekhide", do_tekhide, NULL }}; /* 11 */ #endif /* !KTERM_NOTEK */ static Widget create_menu(); extern Widget toplevel; /* * we really want to do these dynamically */ #define check_width 9 #define check_height 8 static unsigned char check_bits[] = { 0x00, 0x01, 0x80, 0x01, 0xc0, 0x00, 0x60, 0x00, 0x31, 0x00, 0x1b, 0x00, 0x0e, 0x00, 0x04, 0x00 }; /* * public interfaces */ /* ARGSUSED */ static Bool domenu (w, event, params, param_count) Widget w; XEvent *event; /* unused */ String *params; /* mainMenu, vtMenu, or tekMenu */ Cardinal *param_count; /* 0 or 1 */ { TScreen *screen = &term->screen; if (*param_count != 1) { Bell(XkbBI_MinorError,0); return False; } switch (params[0][0]) { case 'm': if (!screen->mainMenu) { screen->mainMenu = create_menu (term, toplevel, "mainMenu", mainMenuEntries, XtNumber(mainMenuEntries)); update_securekbd(); update_allowsends(); #ifdef ALLOWLOGGING update_logging(); #endif #ifndef SIGTSTP set_sensitivity (screen->mainMenu, mainMenuEntries[mainMenu_suspend].widget, FALSE); #endif #ifndef SIGCONT set_sensitivity (screen->mainMenu, mainMenuEntries[mainMenu_continue].widget, FALSE); #endif } break; case 'v': if (!screen->vtMenu) { screen->vtMenu = create_menu (term, toplevel, "vtMenu", vtMenuEntries, XtNumber(vtMenuEntries)); /* and turn off the alternate screen entry */ set_altscreen_sensitivity (FALSE); update_scrollbar(); update_jumpscroll(); update_reversevideo(); update_autowrap(); update_reversewrap(); update_autolinefeed(); update_appcursor(); update_appkeypad(); update_scrollkey(); update_scrollttyoutput(); update_allow132(); update_cursesemul(); update_visualbell(); update_marginbell(); #ifdef STATUSLINE update_statusline(); set_reversestatus_sensitivity(); update_reversestatus(); #endif /* STATUSLINE */ #ifdef KTERM_KANJIMODE update_eucmode(); update_sjismode(); #endif /* KTERM_KANJIMODE */ #ifdef KTERM_XIM update_openim(); #endif /* KTERM_XIM */ } break; case 'f': if (!screen->fontMenu) { screen->fontMenu = create_menu (term, toplevel, "fontMenu", fontMenuEntries, NMENUFONTS); set_menu_font (True); #ifdef KTERM set_sensitivity (screen->fontMenu, fontMenuEntries[fontMenu_fontescape].widget, (screen->menu_font_list[fontMenu_fontescape] ? TRUE : FALSE)); #else /* !KTERM */ set_sensitivity (screen->fontMenu, fontMenuEntries[fontMenu_fontescape].widget, (screen->menu_font_names[fontMenu_fontescape] ? TRUE : FALSE)); #endif /* !KTERM */ } FindFontSelection (NULL, True); #ifdef KTERM set_sensitivity (screen->fontMenu, fontMenuEntries[fontMenu_fontsel].widget, (screen->menu_font_list[fontMenu_fontsel] ? TRUE : FALSE)); #else /* !KTERM */ set_sensitivity (screen->fontMenu, fontMenuEntries[fontMenu_fontsel].widget, (screen->menu_font_names[fontMenu_fontsel] ? TRUE : FALSE)); #endif /* !KTERM */ break; #ifndef KTERM_NOTEK case 't': if (!screen->tekMenu) { screen->tekMenu = create_menu (term, toplevel, "tekMenu", tekMenuEntries, XtNumber(tekMenuEntries)); set_tekfont_menu_item (screen->cur.fontsize, TRUE); } break; #endif /* !KTERM_NOTEK */ default: Bell(XkbBI_MinorError,0); return False; } return True; } void HandleCreateMenu (w, event, params, param_count) Widget w; XEvent *event; /* unused */ String *params; /* mainMenu, vtMenu, or tekMenu */ Cardinal *param_count; /* 0 or 1 */ { (void) domenu (w, event, params, param_count); } void HandlePopupMenu (w, event, params, param_count) Widget w; XEvent *event; /* unused */ String *params; /* mainMenu, vtMenu, or tekMenu */ Cardinal *param_count; /* 0 or 1 */ { if (domenu (w, event, params, param_count)) { XtCallActionProc (w, "XawPositionSimpleMenu", event, params, 1); XtCallActionProc (w, "MenuPopup", event, params, 1); } } /* * private interfaces - keep out! */ /* * create_menu - create a popup shell and stuff the menu into it. */ static Widget create_menu (xtw, toplevelw, name, entries, nentries) XtermWidget xtw; Widget toplevelw; char *name; struct _MenuEntry *entries; int nentries; { Widget m; TScreen *screen = &xtw->screen; static XtCallbackRec cb[2] = { { NULL, NULL }, { NULL, NULL }}; static Arg arg = { XtNcallback, (XtArgVal) cb }; #ifdef KTERM_XIM char *locale, localebuf[256]; int len; #endif /* KTERM_XIM */ if (screen->menu_item_bitmap == None) { screen->menu_item_bitmap = XCreateBitmapFromData (XtDisplay(xtw), RootWindowOfScreen(XtScreen(xtw)), (char *)check_bits, check_width, check_height); } #ifdef KTERM_XIM if ((len = strlen(setlocale(LC_CTYPE, NULL))) < 256) locale = localebuf; else locale = XtMalloc(len + 1); strcpy(locale, setlocale(LC_CTYPE, NULL)); setlocale(LC_CTYPE, ""); #endif /* KTERM_XIM */ m = XtCreatePopupShell (name, simpleMenuWidgetClass, toplevelw, NULL, 0); for (; nentries > 0; nentries--, entries++) { cb[0].callback = (XtCallbackProc) entries->function; cb[0].closure = (caddr_t) entries->name; entries->widget = XtCreateManagedWidget (entries->name, (entries->function ? smeBSBObjectClass : smeLineObjectClass), m, &arg, (Cardinal) 1); } #ifdef KTERM_XIM setlocale(LC_CTYPE, locale); if (locale != localebuf) XtFree(locale); #endif /* KTERM_XIM */ /* do not realize at this point */ return m; } /* ARGSUSED */ static void handle_send_signal (gw, sig) Widget gw; int sig; { register TScreen *screen = &term->screen; if (screen->pid > 1) kill_process_group (screen->pid, sig); } /* * action routines */ /* ARGSUSED */ void DoSecureKeyboard (time) Time time; { do_securekbd (term->screen.mainMenu, NULL, NULL); } static void do_securekbd (gw, closure, data) Widget gw; caddr_t closure, data; { register TScreen *screen = &term->screen; Time time = CurrentTime; /* XXX - wrong */ if (screen->grabbedKbd) { XUngrabKeyboard (screen->display, time); ReverseVideo (term); screen->grabbedKbd = FALSE; } else { if (XGrabKeyboard (screen->display, term->core.window, True, GrabModeAsync, GrabModeAsync, time) != GrabSuccess) { Bell(XkbBI_MinorError, 100); } else { ReverseVideo (term); screen->grabbedKbd = TRUE; } } update_securekbd(); } static void do_allowsends (gw, closure, data) Widget gw; caddr_t closure, data; { register TScreen *screen = &term->screen; screen->allowSendEvents = !screen->allowSendEvents; update_allowsends (); } static void do_visualbell (gw, closure, data) Widget gw; caddr_t closure, data; { register TScreen *screen = &term->screen; screen->visualbell = !screen->visualbell; update_visualbell(); } #ifdef ALLOWLOGGING static void do_logging (gw, closure, data) Widget gw; caddr_t closure, data; { register TScreen *screen = &term->screen; if (screen->logging) { CloseLog (screen); } else { StartLog (screen); } /* update_logging done by CloseLog and StartLog */ } #endif static void do_redraw (gw, closure, data) Widget gw; caddr_t closure, data; { Redraw (); } /* * The following cases use the pid instead of the process group so that we * don't get hosed by programs that change their process group */ /* ARGSUSED */ static void do_suspend (gw, closure, data) Widget gw; caddr_t closure, data; { #ifdef SIGTSTP handle_send_signal (gw, SIGTSTP); #endif } /* ARGSUSED */ static void do_continue (gw, closure, data) Widget gw; caddr_t closure, data; { #ifdef SIGCONT handle_send_signal (gw, SIGCONT); #endif } /* ARGSUSED */ static void do_interrupt (gw, closure, data) Widget gw; caddr_t closure, data; { handle_send_signal (gw, SIGINT); } /* ARGSUSED */ void do_hangup (gw, closure, data) Widget gw; caddr_t closure, data; { handle_send_signal (gw, SIGHUP); } /* ARGSUSED */ static void do_terminate (gw, closure, data) Widget gw; caddr_t closure, data; { handle_send_signal (gw, SIGTERM); } /* ARGSUSED */ static void do_kill (gw, closure, data) Widget gw; caddr_t closure, data; { handle_send_signal (gw, SIGKILL); } static void do_quit (gw, closure, data) Widget gw; caddr_t closure, data; { Cleanup (0); } /* * vt menu callbacks */ static void do_scrollbar (gw, closure, data) Widget gw; caddr_t closure, data; { register TScreen *screen = &term->screen; if (screen->scrollbar) { ScrollBarOff (screen); } else { ScrollBarOn (term, FALSE, FALSE); } update_scrollbar(); } static void do_jumpscroll (gw, closure, data) Widget gw; caddr_t closure, data; { register TScreen *screen = &term->screen; term->flags ^= SMOOTHSCROLL; if (term->flags & SMOOTHSCROLL) { screen->jumpscroll = FALSE; if (screen->scroll_amt) FlushScroll(screen); } else { screen->jumpscroll = TRUE; } update_jumpscroll(); } static void do_reversevideo (gw, closure, data) Widget gw; caddr_t closure, data; { term->flags ^= REVERSE_VIDEO; ReverseVideo (term); /* update_reversevideo done in ReverseVideo */ } static void do_autowrap (gw, closure, data) Widget gw; caddr_t closure, data; { term->flags ^= WRAPAROUND; update_autowrap(); } static void do_reversewrap (gw, closure, data) Widget gw; caddr_t closure, data; { term->flags ^= REVERSEWRAP; update_reversewrap(); } static void do_autolinefeed (gw, closure, data) Widget gw; caddr_t closure, data; { term->flags ^= LINEFEED; update_autolinefeed(); } static void do_appcursor (gw, closure, data) Widget gw; caddr_t closure, data; { term->keyboard.flags ^= CURSOR_APL; update_appcursor(); } static void do_appkeypad (gw, closure, data) Widget gw; caddr_t closure, data; { term->keyboard.flags ^= KYPD_APL; update_appkeypad(); } static void do_scrollkey (gw, closure, data) Widget gw; caddr_t closure, data; { register TScreen *screen = &term->screen; screen->scrollkey = !screen->scrollkey; update_scrollkey(); } static void do_scrollttyoutput (gw, closure, data) Widget gw; caddr_t closure, data; { register TScreen *screen = &term->screen; screen->scrollttyoutput = !screen->scrollttyoutput; update_scrollttyoutput(); } static void do_allow132 (gw, closure, data) Widget gw; caddr_t closure, data; { register TScreen *screen = &term->screen; screen->c132 = !screen->c132; update_allow132(); } static void do_cursesemul (gw, closure, data) Widget gw; caddr_t closure, data; { register TScreen *screen = &term->screen; screen->curses = !screen->curses; update_cursesemul(); } static void do_marginbell (gw, closure, data) Widget gw; caddr_t closure, data; { register TScreen *screen = &term->screen; if (!(screen->marginbell = !screen->marginbell)) screen->bellarmed = -1; update_marginbell(); } #ifndef KTERM_NOTEK static void handle_tekshow (gw, allowswitch) Widget gw; Bool allowswitch; { register TScreen *screen = &term->screen; if (!screen->Tshow) { /* not showing, turn on */ set_tek_visibility (TRUE); } else if (screen->Vshow || allowswitch) { /* is showing, turn off */ set_tek_visibility (FALSE); end_tek_mode (); /* WARNING: this does a longjmp */ } else Bell(XkbBI_MinorError, 0); } /* ARGSUSED */ static void do_tekshow (gw, closure, data) Widget gw; caddr_t closure, data; { handle_tekshow (gw, True); } /* ARGSUSED */ static void do_tekonoff (gw, closure, data) Widget gw; caddr_t closure, data; { handle_tekshow (gw, False); } #endif /* !KTERM_NOTEK */ /* ARGSUSED */ static void do_altscreen (gw, closure, data) Widget gw; caddr_t closure, data; { /* do nothing for now; eventually, will want to flip screen */ } static void do_softreset (gw, closure, data) Widget gw; caddr_t closure, data; { VTReset (FALSE); } static void do_hardreset (gw, closure, data) Widget gw; caddr_t closure, data; { VTReset (TRUE); } static void do_clearsavedlines (gw, closure, data) Widget gw; caddr_t closure, data; { register TScreen *screen = &term->screen; screen->savedlines = 0; ScrollBarDrawThumb(screen->scrollWidget); VTReset (TRUE); } #ifndef KTERM_NOTEK static void do_tekmode (gw, closure, data) Widget gw; caddr_t closure, data; { register TScreen *screen = &term->screen; switch_modes (screen->TekEmu); /* switch to tek mode */ } /* ARGSUSED */ static void do_vthide (gw, closure, data) Widget gw; caddr_t closure, data; { hide_vt_window(); } #endif /* !KTERM_NOTEK */ #ifdef STATUSLINE static void do_statusline (gw, closure, data) Widget gw; caddr_t closure, data; { register TScreen *screen = &term->screen; if (screen->statusheight) { HideStatus(); } else { ShowStatus(); } update_statusline(); set_reversestatus_sensitivity(); } static void do_reversestatus (gw, closure, data) Widget gw; caddr_t closure, data; { register TScreen *screen = &term->screen; screen->reversestatus = !screen->reversestatus; update_reversestatus(); ScrnRefresh(screen, screen->max_row+1, 0, 1, screen->max_col+1, False); } #endif /* STATUSLINE */ #ifdef KTERM_KANJIMODE static void do_jismode (gw, closure, data) Widget gw; caddr_t closure, data; { register TScreen *screen = &term->screen; term->flags &= ~EUC_KANJI; term->flags &= ~SJIS_KANJI; screen->gsets[0] = GSET_ASCII; screen->gsets[1] = GSET_KANA; screen->gsets[2] = GSET_ASCII; screen->gsets[3] = GSET_ASCII; screen->curgr = 1; update_eucmode(); update_sjismode(); } static void do_eucmode (gw, closure, data) Widget gw; caddr_t closure, data; { register TScreen *screen = &term->screen; if (term->flags & EUC_KANJI) { do_jismode(gw, closure, data); } else { term->flags |= EUC_KANJI; term->flags &= ~SJIS_KANJI; screen->gsets[0] = GSET_ASCII; screen->gsets[1] = GSET_KANJI; screen->gsets[2] = GSET_KANA; screen->gsets[3] = GSET_HOJOKANJI; screen->curgr = 1; update_eucmode(); update_sjismode(); } } static void do_sjismode (gw, closure, data) Widget gw; caddr_t closure, data; { register TScreen *screen = &term->screen; if (term->flags & SJIS_KANJI) { do_jismode(gw, closure, data); } else { term->flags &= ~EUC_KANJI; term->flags |= SJIS_KANJI; screen->gsets[0] = GSET_ASCII; screen->gsets[1] = GSET_KANA; screen->gsets[2] = GSET_ASCII; screen->gsets[3] = GSET_ASCII; screen->curgr = 1; update_eucmode(); update_sjismode(); } } #endif /* KTERM_KANJIMODE */ #ifdef KTERM_XIM static void do_openim (gw, closure, data) Widget gw; caddr_t closure, data; { register TScreen *screen = &term->screen; extern void CloseIM(), OpenIM(); if (screen->imregistered) { CloseIM(screen); } else { OpenIM(screen); } /* update_openim() is done in CloseIM() and OpenIM(). */ } #endif /* KTERM_XIM */ /* * vtfont menu */ static void do_vtfont (gw, closure, data) Widget gw; caddr_t closure, data; { char *entryname = (char *) closure; int i; for (i = 0; i < NMENUFONTS; i++) { if (strcmp (entryname, fontMenuEntries[i].name) == 0) { SetVTFont (i, True, NULL, NULL); return; } } Bell(XkbBI_MinorError, 0); } #ifndef KTERM_NOTEK /* * tek menu */ static void do_tektextlarge (gw, closure, data) Widget gw; caddr_t closure, data; { TekSetFontSize (tekMenu_tektextlarge); } static void do_tektext2 (gw, closure, data) Widget gw; caddr_t closure, data; { TekSetFontSize (tekMenu_tektext2); } static void do_tektext3 (gw, closure, data) Widget gw; caddr_t closure, data; { TekSetFontSize (tekMenu_tektext3); } static void do_tektextsmall (gw, closure, data) Widget gw; caddr_t closure, data; { TekSetFontSize (tekMenu_tektextsmall); } static void do_tekpage (gw, closure, data) Widget gw; caddr_t closure, data; { TekSimulatePageButton (False); } static void do_tekreset (gw, closure, data) Widget gw; caddr_t closure, data; { TekSimulatePageButton (True); } static void do_tekcopy (gw, closure, data) Widget gw; caddr_t closure, data; { TekCopy (); } static void handle_vtshow (gw, allowswitch) Widget gw; Bool allowswitch; { register TScreen *screen = &term->screen; if (!screen->Vshow) { /* not showing, turn on */ set_vt_visibility (TRUE); } else if (screen->Tshow || allowswitch) { /* is showing, turn off */ set_vt_visibility (FALSE); if (!screen->TekEmu && TekRefresh) dorefresh (); end_vt_mode (); } else Bell(XkbBI_MinorError, 0); } static void do_vtshow (gw, closure, data) Widget gw; caddr_t closure, data; { handle_vtshow (gw, True); } static void do_vtonoff (gw, closure, data) Widget gw; caddr_t closure, data; { handle_vtshow (gw, False); } static void do_vtmode (gw, closure, data) Widget gw; caddr_t closure, data; { register TScreen *screen = &term->screen; switch_modes (screen->TekEmu); /* switch to vt, or from */ } /* ARGSUSED */ static void do_tekhide (gw, closure, data) Widget gw; caddr_t closure, data; { hide_tek_window(); } #endif /* !KTERM_NOTEK */ /* * public handler routines */ static void handle_toggle (proc, var, params, nparams, w, closure, data) void (*proc)(); int var; String *params; Cardinal nparams; Widget w; caddr_t closure, data; { int dir = -2; switch (nparams) { case 0: dir = -1; break; case 1: if (XmuCompareISOLatin1 (params[0], "on") == 0) dir = 1; else if (XmuCompareISOLatin1 (params[0], "off") == 0) dir = 0; else if (XmuCompareISOLatin1 (params[0], "toggle") == 0) dir = -1; break; } switch (dir) { case -2: Bell(XkbBI_MinorError, 0); break; case -1: (*proc) (w, closure, data); break; case 0: if (var) (*proc) (w, closure, data); else Bell(XkbBI_MinorError, 0); break; case 1: if (!var) (*proc) (w, closure, data); else Bell(XkbBI_MinorError, 0); break; } return; } void HandleAllowSends(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { handle_toggle (do_allowsends, (int) term->screen.allowSendEvents, params, *param_count, w, NULL, NULL); } void HandleSetVisualBell(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { handle_toggle (do_visualbell, (int) term->screen.visualbell, params, *param_count, w, NULL, NULL); } #ifdef ALLOWLOGGING void HandleLogging(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { handle_toggle (do_logging, (int) term->screen.logging, params, *param_count, w, NULL, NULL); } #endif /* ARGSUSED */ void HandleRedraw(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { do_redraw(w, NULL, NULL); } /* ARGSUSED */ void HandleSendSignal(w, event, params, param_count) Widget w; XEvent *event; /* unused */ String *params; Cardinal *param_count; { static struct sigtab { char *name; int sig; } signals[] = { #ifdef SIGTSTP { "suspend", SIGTSTP }, { "tstp", SIGTSTP }, #endif #ifdef SIGCONT { "cont", SIGCONT }, #endif { "int", SIGINT }, { "hup", SIGHUP }, { "quit", SIGQUIT }, { "alrm", SIGALRM }, { "alarm", SIGALRM }, { "term", SIGTERM }, { "kill", SIGKILL }, { NULL, 0 }, }; if (*param_count == 1) { struct sigtab *st; for (st = signals; st->name; st++) { if (XmuCompareISOLatin1 (st->name, params[0]) == 0) { handle_send_signal (w, st->sig); return; } } /* one could allow numeric values, but that would be a security hole */ } Bell(XkbBI_MinorError, 0); } /* ARGSUSED */ void HandleQuit(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { do_quit(w, NULL, NULL); } void HandleScrollbar(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { handle_toggle (do_scrollbar, (int) term->screen.scrollbar, params, *param_count, w, NULL, NULL); } void HandleJumpscroll(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { handle_toggle (do_jumpscroll, (int) term->screen.jumpscroll, params, *param_count, w, NULL, NULL); } void HandleReverseVideo(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { handle_toggle (do_reversevideo, (int) (term->flags & REVERSE_VIDEO), params, *param_count, w, NULL, NULL); } void HandleAutoWrap(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { handle_toggle (do_autowrap, (int) (term->flags & WRAPAROUND), params, *param_count, w, NULL, NULL); } void HandleReverseWrap(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { handle_toggle (do_reversewrap, (int) (term->flags & REVERSEWRAP), params, *param_count, w, NULL, NULL); } void HandleAutoLineFeed(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { handle_toggle (do_autolinefeed, (int) (term->flags & LINEFEED), params, *param_count, w, NULL, NULL); } void HandleAppCursor(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { handle_toggle (do_appcursor, (int) (term->keyboard.flags & CURSOR_APL), params, *param_count, w, NULL, NULL); } void HandleAppKeypad(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { handle_toggle (do_appkeypad, (int) (term->keyboard.flags & KYPD_APL), params, *param_count, w, NULL, NULL); } void HandleScrollKey(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { handle_toggle (do_scrollkey, (int) term->screen.scrollkey, params, *param_count, w, NULL, NULL); } void HandleScrollTtyOutput(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { handle_toggle (do_scrollttyoutput, (int) term->screen.scrollttyoutput, params, *param_count, w, NULL, NULL); } void HandleAllow132(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { handle_toggle (do_allow132, (int) term->screen.c132, params, *param_count, w, NULL, NULL); } void HandleCursesEmul(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { handle_toggle (do_cursesemul, (int) term->screen.curses, params, *param_count, w, NULL, NULL); } void HandleMarginBell(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { handle_toggle (do_marginbell, (int) term->screen.marginbell, params, *param_count, w, NULL, NULL); } void HandleAltScreen(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { /* eventually want to see if sensitive or not */ handle_toggle (do_altscreen, (int) term->screen.alternate, params, *param_count, w, NULL, NULL); } /* ARGSUSED */ void HandleSoftReset(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { do_softreset(w, NULL, NULL); } /* ARGSUSED */ void HandleHardReset(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { do_hardreset(w, NULL, NULL); } /* ARGSUSED */ void HandleClearSavedLines(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { do_clearsavedlines(w, NULL, NULL); } #ifndef KTERM_NOTEK void HandleSetTerminalType(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { if (*param_count == 1) { switch (params[0][0]) { case 'v': case 'V': if (term->screen.TekEmu) do_vtmode (w, NULL, NULL); break; case 't': case 'T': if (!term->screen.TekEmu) do_tekmode (w, NULL, NULL); break; default: Bell(XkbBI_MinorError, 0); } } else { Bell(XkbBI_MinorError, 0); } } void HandleVisibility(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { if (*param_count == 2) { switch (params[0][0]) { case 'v': case 'V': handle_toggle (do_vtonoff, (int) term->screen.Vshow, params+1, (*param_count) - 1, w, NULL, NULL); break; case 't': case 'T': handle_toggle (do_tekonoff, (int) term->screen.Tshow, params+1, (*param_count) - 1, w, NULL, NULL); break; default: Bell(XkbBI_MinorError, 0); } } else { Bell(XkbBI_MinorError, 0); } } /* ARGSUSED */ void HandleSetTekText(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { void (*proc)() = NULL; switch (*param_count) { case 0: proc = do_tektextlarge; break; case 1: switch (params[0][0]) { case 'l': case 'L': proc = do_tektextlarge; break; case '2': proc = do_tektext2; break; case '3': proc = do_tektext3; break; case 's': case 'S': proc = do_tektextsmall; break; } break; } if (proc) (*proc) (w, NULL, NULL); else Bell(XkbBI_MinorError, 0); } /* ARGSUSED */ void HandleTekPage(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { do_tekpage(w, NULL, NULL); } /* ARGSUSED */ void HandleTekReset(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { do_tekreset(w, NULL, NULL); } /* ARGSUSED */ void HandleTekCopy(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { do_tekcopy(w, NULL, NULL); } #endif /* !KTERM_NOTEK */ #ifdef STATUSLINE void HandleStatusLine(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { /* eventually want to see if sensitive or not */ handle_toggle (do_statusline, (int) term->screen.statusheight, params, *param_count, w, NULL, NULL); } void HandleStatusReverse(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { /* eventually want to see if sensitive or not */ handle_toggle (do_reversestatus, (int) term->screen.reversestatus, params, *param_count, w, NULL, NULL); } #endif /* STATUSLINE */ #ifdef KTERM_KANJIMODE void HandleSetKanjiMode(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { if (*param_count == 1) { switch (params[0][0]) { case 'j': case 'J': do_jismode (w, NULL, NULL); break; case 'e': case 'E': case 'x': case 'X': case 'u': case 'U': term->flags &= ~EUC_KANJI; do_eucmode (w, NULL, NULL); break; case 's': case 'S': case 'm': case 'M': term->flags &= ~SJIS_KANJI; do_sjismode (w, NULL, NULL); break; default: Bell(XkbBI_MinorError, 0); } } else { Bell(XkbBI_MinorError, 0); } } #endif /* KTERM_KANJIMODE */ kterm-6.2.0.orig/menu.h100444 507 454 27122 6166126500 13450 0ustar yosiakiaux/* $XConsortium: menu.h,v 1.25 94/04/17 20:23:31 gildea Exp $ */ /* $Id: menu.h,v 6.2 1996/07/02 05:01:31 kagotani Rel $ */ /* Copyright (c) 1989 X Consortium Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium. */ typedef struct _MenuEntry { char *name; void (*function)(); Widget widget; } MenuEntry; #ifdef KTERM_NOTEK extern MenuEntry mainMenuEntries[], vtMenuEntries[]; #else /* !KTERM_NOTEK */ extern MenuEntry mainMenuEntries[], vtMenuEntries[], tekMenuEntries[]; #endif /* !KTERM_NOTEK */ extern MenuEntry fontMenuEntries[]; extern Arg menuArgs[]; extern void HandleAllowSends(); extern void HandleSetVisualBell(); #ifdef ALLOWLOGGING extern void HandleLogging(); #endif extern void HandleRedraw(); extern void HandleSendSignal(); extern void HandleQuit(); extern void HandleScrollbar(); extern void HandleJumpscroll(); extern void HandleReverseVideo(); extern void HandleAutoWrap(); extern void HandleReverseWrap(); extern void HandleAutoLineFeed(); extern void HandleAppCursor(); extern void HandleAppKeypad(); extern void HandleScrollKey(); extern void HandleScrollTtyOutput(); extern void HandleAllow132(); extern void HandleCursesEmul(); extern void HandleMarginBell(); extern void HandleAltScreen(); extern void HandleSoftReset(); extern void HandleHardReset(); extern void HandleClearSavedLines(); extern void HandleSetTerminalType(); extern void HandleVisibility(); extern void HandleSetTekText(); extern void HandleTekPage(); extern void HandleTekReset(); extern void HandleTekCopy(); extern void DoSecureKeyboard(); #ifdef STATUSLINE extern void HandleStatusLine(); extern void HandleStatusReverse(); #endif /* STATUSLINE */ #ifdef KTERM_KANJIMODE extern void HandleSetKanjiMode(); #endif /* KTERM_KANJIMODE */ /* * The following definitions MUST match the order of entries given in * the mainMenuEntries, vtMenuEntries, and tekMenuEntries arrays in menu.c. */ /* * items in primary menu */ #define mainMenu_securekbd 0 #define mainMenu_allowsends 1 #ifdef ALLOWLOGGING #define mainMenu_logging 2 #endif #define mainMenu_redraw 3 #define mainMenu_line1 4 #define mainMenu_suspend 5 #define mainMenu_continue 6 #define mainMenu_interrupt 7 #define mainMenu_hangup 8 #define mainMenu_terminate 9 #define mainMenu_kill 10 #define mainMenu_line2 11 #define mainMenu_quit 12 /* * items in vt100 mode menu */ #define vtMenu_scrollbar 0 #define vtMenu_jumpscroll 1 #define vtMenu_reversevideo 2 #define vtMenu_autowrap 3 #define vtMenu_reversewrap 4 #define vtMenu_autolinefeed 5 #define vtMenu_appcursor 6 #define vtMenu_appkeypad 7 #define vtMenu_scrollkey 8 #define vtMenu_scrollttyoutput 9 #define vtMenu_allow132 10 #define vtMenu_cursesemul 11 #define vtMenu_visualbell 12 #define vtMenu_marginbell 13 #define vtMenu_altscreen 14 #define vtMenu_line1 15 #define vtMenu_softreset 16 #define vtMenu_hardreset 17 #define vtMenu_clearsavedlines 18 #ifdef KTERM_NOTEK /* implies KTERM */ # define vtMenu_line3 19 #else /* !KTERM_NOTEK */ #define vtMenu_line2 19 #define vtMenu_tekshow 20 #define vtMenu_tekmode 21 #define vtMenu_vthide 22 # if defined(STATUSLINE) || defined(KTERM) # define vtMenu_line3 23 # endif /* STATUSLINE || KTERM */ #endif /* !KTERM_NOTEK */ #ifdef STATUSLINE # define vtMenu_statusline (vtMenu_line3+1) # define vtMenu_reversestatus (vtMenu_statusline+1) #endif /* STATUSLINE */ #ifdef KTERM_KANJIMODE # ifdef vtMenu_reversestatus # define vtMenu_eucmode (vtMenu_reversestatus+1) # else # define vtMenu_eucmode (vtMenu_line3+1) # endif # define vtMenu_sjismode (vtMenu_eucmode+1) #endif /* KTERM_KANJIMODE */ #ifdef KTERM_XIM # ifdef vtMenu_sjismode # define vtMenu_openim (vtMenu_sjismode+1) # else # ifdef vtMenu_reversestatus # define vtMenu_openim (vtMenu_reversestatus+1) # else # define vtMenu_openim (vtMenu_line3+1) # endif # endif #endif /* KTERM_XIM */ /* * items in vt100 font menu */ #define fontMenu_fontdefault 0 #define fontMenu_font1 1 #define fontMenu_font2 2 #define fontMenu_font3 3 #define fontMenu_font4 4 #define fontMenu_font5 5 #define fontMenu_font6 6 #define fontMenu_lastBuiltin fontMenu_font6 #define fontMenu_fontescape 7 #define fontMenu_fontsel 8 /* number of non-line items should match NMENUFONTS in ptyx.h */ #ifndef KTERM_NOTEK /* * items in tek4014 mode menu */ #define tekMenu_tektextlarge 0 #define tekMenu_tektext2 1 #define tekMenu_tektext3 2 #define tekMenu_tektextsmall 3 #define tekMenu_line1 4 #define tekMenu_tekpage 5 #define tekMenu_tekreset 6 #define tekMenu_tekcopy 7 #define tekMenu_line2 8 #define tekMenu_vtshow 9 #define tekMenu_vtmode 10 #define tekMenu_tekhide 11 #endif /* !KTERM_NOTEK */ /* * macros for updating menus */ #define update_menu_item(w,mi,val) { if (mi) { \ menuArgs[0].value = (XtArgVal) ((val) ? term->screen.menu_item_bitmap \ : None); \ XtSetValues (mi, menuArgs, (Cardinal) 1); }} #define set_sensitivity(w,mi,val) { if (mi) { \ menuArgs[1].value = (XtArgVal) (val); \ XtSetValues (mi, menuArgs+1, (Cardinal) 1); }} /* * there should be one of each of the following for each checkable item */ #define update_securekbd() \ update_menu_item (term->screen.mainMenu, \ mainMenuEntries[mainMenu_securekbd].widget, \ term->screen.grabbedKbd) #define update_allowsends() \ update_menu_item (term->screen.mainMenu, \ mainMenuEntries[mainMenu_allowsends].widget, \ term->screen.allowSendEvents) #ifdef ALLOWLOGGING #define update_logging() \ update_menu_item (term->screen.mainMenu, \ mainMenuEntries[mainMenu_logging].widget, \ term->screen.logging) #endif #define update_scrollbar() \ update_menu_item (term->screen.vtMenu, \ vtMenuEntries[vtMenu_scrollbar].widget, \ term->screen.scrollbar) #define update_jumpscroll() \ update_menu_item (term->screen.vtMenu, \ vtMenuEntries[vtMenu_jumpscroll].widget, \ term->screen.jumpscroll) #define update_reversevideo() \ update_menu_item (term->screen.vtMenu, \ vtMenuEntries[vtMenu_reversevideo].widget, \ (term->flags & REVERSE_VIDEO)) #define update_autowrap() \ update_menu_item (term->screen.vtMenu, \ vtMenuEntries[vtMenu_autowrap].widget, \ (term->flags & WRAPAROUND)) #define update_reversewrap() \ update_menu_item (term->screen.vtMenu, \ vtMenuEntries[vtMenu_reversewrap].widget, \ (term->flags & REVERSEWRAP)) #define update_autolinefeed() \ update_menu_item (term->screen.vtMenu, \ vtMenuEntries[vtMenu_autolinefeed].widget, \ (term->flags & LINEFEED)) #define update_appcursor() \ update_menu_item (term->screen.vtMenu, \ vtMenuEntries[vtMenu_appcursor].widget, \ (term->keyboard.flags & CURSOR_APL)) #define update_appkeypad() \ update_menu_item (term->screen.vtMenu, \ vtMenuEntries[vtMenu_appkeypad].widget, \ (term->keyboard.flags & KYPD_APL)) #define update_scrollkey() \ update_menu_item (term->screen.vtMenu, \ vtMenuEntries[vtMenu_scrollkey].widget, \ term->screen.scrollkey) #define update_scrollttyoutput() \ update_menu_item (term->screen.vtMenu, \ vtMenuEntries[vtMenu_scrollttyoutput].widget, \ term->screen.scrollttyoutput) #define update_allow132() \ update_menu_item (term->screen.vtMenu, \ vtMenuEntries[vtMenu_allow132].widget, \ term->screen.c132) #define update_cursesemul() \ update_menu_item (term->screen.vtMenu, \ vtMenuEntries[vtMenu_cursesemul].widget, \ term->screen.curses) #define update_visualbell() \ update_menu_item (term->screen.vtMenu, \ vtMenuEntries[vtMenu_visualbell].widget, \ term->screen.visualbell) #define update_marginbell() \ update_menu_item (term->screen.vtMenu, \ vtMenuEntries[vtMenu_marginbell].widget, \ term->screen.marginbell) #define update_altscreen() \ update_menu_item (term->screen.vtMenu, \ vtMenuEntries[vtMenu_altscreen].widget, \ term->screen.alternate) #ifndef KTERM_NOTEK #define update_tekshow() \ update_menu_item (term->screen.vtMenu, \ vtMenuEntries[vtMenu_tekshow].widget, \ term->screen.Tshow) #define update_vttekmode() { \ update_menu_item (term->screen.vtMenu, \ vtMenuEntries[vtMenu_tekmode].widget, \ term->screen.TekEmu) \ update_menu_item (term->screen.tekMenu, \ tekMenuEntries[tekMenu_vtmode].widget, \ !term->screen.TekEmu) } #define update_vtshow() \ update_menu_item (term->screen.tekMenu, \ tekMenuEntries[tekMenu_vtshow].widget, \ term->screen.Vshow) #endif /* !KTERM_NOTEK */ #ifdef STATUSLINE #define update_statusline() \ update_menu_item (term->screen.vtMenu, \ vtMenuEntries[vtMenu_statusline].widget, \ term->screen.statusheight) #define update_reversestatus() \ update_menu_item (term->screen.vtMenu, \ vtMenuEntries[vtMenu_reversestatus].widget, \ term->screen.reversestatus) #endif /* STATUSLINE */ #ifdef KTERM_KANJIMODE #define update_eucmode() \ update_menu_item (term->screen.vtMenu, \ vtMenuEntries[vtMenu_eucmode].widget, \ term->flags & EUC_KANJI) #define update_sjismode() \ update_menu_item (term->screen.vtMenu, \ vtMenuEntries[vtMenu_sjismode].widget, \ term->flags & SJIS_KANJI) #endif /* KTERM_KANJIMODE */ #ifdef KTERM_XIM #define update_openim() \ update_menu_item (term->screen.vtMenu, \ vtMenuEntries[vtMenu_openim].widget, \ term->screen.imregistered) #endif /* KTERM_XIM */ #ifndef KTERM_NOTEK #define set_vthide_sensitivity() \ set_sensitivity (term->screen.vtMenu, \ vtMenuEntries[vtMenu_vthide].widget, \ term->screen.Tshow) #define set_tekhide_sensitivity() \ set_sensitivity (term->screen.tekMenu, \ tekMenuEntries[tekMenu_tekhide].widget, \ term->screen.Vshow) #endif /* !KTERM_NOTEK */ #define set_altscreen_sensitivity(val) \ set_sensitivity (term->screen.vtMenu,\ vtMenuEntries[vtMenu_altscreen].widget, (val)) #ifdef STATUSLINE #define set_reversestatus_sensitivity() \ set_sensitivity (term->screen.vtMenu, \ vtMenuEntries[vtMenu_reversestatus].widget, \ term->screen.statusheight) #endif /* STATUSLINE */ /* * macros for mapping font size to tekMenu placement */ #define FS2MI(n) (n) /* font_size_to_menu_item */ #define MI2FS(n) (n) /* menu_item_to_font_size */ #ifndef KTERM_NOTEK #define set_tekfont_menu_item(n,val) \ update_menu_item (term->screen.tekMenu, \ tekMenuEntries[FS2MI(n)].widget, \ (val)) #endif /* !KTERM_NOTEK */ #define set_menu_font(val) \ update_menu_item (term->screen.fontMenu, \ fontMenuEntries[term->screen.menu_font_number].widget, \ (val)) kterm-6.2.0.orig/misc.c100444 507 454 64206 6171356067 13447 0ustar yosiakiaux/* * $XConsortium: misc.c /main/106 1996/02/02 14:27:57 kaleb $ * $Id: misc.c,v 1.2 1996/07/02 05:01:31 kagotani Rel $ */ /* * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ #include "ptyx.h" /* X headers included here. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "data.h" #include "error.h" #include "menu.h" extern jmp_buf Tekend; extern jmp_buf VTend; #ifndef X_NOT_STDC_ENV #include #else extern char *malloc(); extern char *getenv(); #endif static void DoSpecialEnterNotify(); static void DoSpecialLeaveNotify(); xevents() { XEvent event; register TScreen *screen = &term->screen; extern XtAppContext app_con; #ifdef KTERM_XAW3D XtInputMask input_mask; #endif /* KTERM_XAW3D */ if(screen->scroll_amt) FlushScroll(screen); #ifdef KTERM_XAW3D /* * process timeouts, relying on the fact that XtAppProcessEvent * will process the timeout and return without blockng on the * XEvent queue. Other sources i.e. the pty are handled elsewhere * with select(). */ while ((input_mask = XtAppPending(app_con)) & XtIMTimer) XtAppProcessEvent(app_con, XtIMTimer); /* * If there's no XEvents, don't wait around... */ if ((input_mask & XtIMXEvent) != XtIMXEvent) return; #else /* !KTERM_XAW3D */ if (!XPending (screen->display)) /* protect against events/errors being swallowed by us or Xlib */ return; #endif /* !KTERM_XAW3D */ do { if (waitingForTrackInfo) return; #ifdef KTERM_XAW3D XtAppNextEvent (app_con, &event); #else /* !KTERM_XAW3D */ XNextEvent (screen->display, &event); #endif /* !KTERM_XAW3D */ /* * Hack to get around problems with the toolkit throwing away * eventing during the exclusive grab of the menu popup. By * looking at the event ourselves we make sure that we can * do the right thing. */ #ifdef KTERM_NOTEK if(event.type == EnterNotify && (event.xcrossing.window == XtWindow(XtParent(term)))) #else /* !KTERM_NOTEK */ if(event.type == EnterNotify && (event.xcrossing.window == XtWindow(XtParent(term)) || (tekWidget && event.xcrossing.window == XtWindow(XtParent(tekWidget))))) #endif /* !KTERM_NOTEK */ DoSpecialEnterNotify (&event.xcrossing); else #ifdef KTERM_NOTEK if(event.type == LeaveNotify && (event.xcrossing.window == XtWindow(XtParent(term)))) #else /* !KTERM_NOTEK */ if(event.type == LeaveNotify && (event.xcrossing.window == XtWindow(XtParent(term)) || (tekWidget && event.xcrossing.window == XtWindow(XtParent(tekWidget))))) #endif /* !KTERM_NOTEK */ DoSpecialLeaveNotify (&event.xcrossing); if (!event.xany.send_event || screen->allowSendEvents || ((event.xany.type != KeyPress) && (event.xany.type != KeyRelease) && (event.xany.type != ButtonPress) && (event.xany.type != ButtonRelease))) XtDispatchEvent(&event); #ifdef KTERM_XAW3D } while ((input_mask = XtAppPending(app_con)) & XtIMXEvent); #else /* !KTERM_XAW3D */ } while (QLength(screen->display) > 0); #endif /* !KTERM_XAW3D */ } Cursor make_colored_cursor (cursorindex, fg, bg) int cursorindex; /* index into font */ unsigned long fg, bg; /* pixel value */ { register TScreen *screen = &term->screen; Cursor c; register Display *dpy = screen->display; c = XCreateFontCursor (dpy, cursorindex); if (c == (Cursor) 0) return (c); recolor_cursor (c, fg, bg); return (c); } /* ARGSUSED */ void HandleKeyPressed(w, event, params, nparams) Widget w; XEvent *event; String *params; Cardinal *nparams; { register TScreen *screen = &term->screen; #ifdef ACTIVEWINDOWINPUTONLY if (w == (screen->TekEmu ? (Widget)tekWidget : (Widget)term)) #endif Input (&term->keyboard, screen, &event->xkey, False); } /* ARGSUSED */ void HandleEightBitKeyPressed(w, event, params, nparams) Widget w; XEvent *event; String *params; Cardinal *nparams; { register TScreen *screen = &term->screen; #ifdef ACTIVEWINDOWINPUTONLY # ifdef KTERM_NOTEK if (w == (Widget)term) # else /* !KTERM_NOTEK */ if (w == (screen->TekEmu ? (Widget)tekWidget : (Widget)term)) # endif /* !KTERM_NOTEK */ #endif Input (&term->keyboard, screen, &event->xkey, True); } /* ARGSUSED */ void HandleStringEvent(w, event, params, nparams) Widget w; XEvent *event; String *params; Cardinal *nparams; { register TScreen *screen = &term->screen; #ifdef ACTIVEWINDOWINPUTONLY # ifdef KTERM_NOTEK if (w != (Widget)term) return; # else /* !KTERM_NOTEK */ if (w != (screen->TekEmu ? (Widget)tekWidget : (Widget)term)) return; # endif /* !KTERM_NOTEK */ #endif if (*nparams != 1) return; if ((*params)[0] == '0' && (*params)[1] == 'x' && (*params)[2] != '\0') { char c, *p, hexval[2]; hexval[0] = hexval[1] = 0; for (p = *params+2; (c = *p); p++) { hexval[0] *= 16; if (isupper(c)) c = tolower(c); if (c >= '0' && c <= '9') hexval[0] += c - '0'; else if (c >= 'a' && c <= 'f') hexval[0] += c - 'a' + 10; else break; } if (c == '\0') StringInput (screen, hexval, 1); } else { StringInput (screen, *params, strlen(*params)); } } static void DoSpecialEnterNotify (ev) register XEnterWindowEvent *ev; { register TScreen *screen = &term->screen; #ifdef ACTIVEWINDOWINPUTONLY # ifdef KTERM_NOTEK if (ev->window == XtWindow(XtParent((Widget)term))) # else /* !KTERM_NOTEK */ if (ev->window == XtWindow(XtParent(screen->TekEmu ? (Widget)tekWidget : (Widget)term))) # endif /* !KTERM_NOTEK */ #endif if (((ev->detail) != NotifyInferior) && ev->focus && !(screen->select & FOCUS)) selectwindow(screen, INWINDOW); } /*ARGSUSED*/ void HandleEnterWindow(w, eventdata, event) Widget w; register XEnterWindowEvent *event; caddr_t eventdata; { /* NOP since we handled it above */ } static void DoSpecialLeaveNotify (ev) register XEnterWindowEvent *ev; { register TScreen *screen = &term->screen; #ifdef ACTIVEWINDOWINPUTONLY # ifdef KTERM_NOTEK if (ev->window == XtWindow(XtParent((Widget)term))) # else /* !KTERM_NOTEK */ if (ev->window == XtWindow(XtParent(screen->TekEmu ? (Widget)tekWidget : (Widget)term))) # endif /* !KTERM_NOTEK */ #endif if (((ev->detail) != NotifyInferior) && ev->focus && !(screen->select & FOCUS)) unselectwindow(screen, INWINDOW); } /*ARGSUSED*/ void HandleLeaveWindow(w, eventdata, event) Widget w; register XEnterWindowEvent *event; caddr_t eventdata; { /* NOP since we handled it above */ } /*ARGSUSED*/ void HandleFocusChange(w, eventdata, event) Widget w; register XFocusChangeEvent *event; caddr_t eventdata; { register TScreen *screen = &term->screen; if(event->type == FocusIn) selectwindow(screen, (event->detail == NotifyPointer) ? INWINDOW : FOCUS); else { unselectwindow(screen, (event->detail == NotifyPointer) ? INWINDOW : FOCUS); if (screen->grabbedKbd && (event->mode == NotifyUngrab)) { Bell(XkbBI_Info, 100); ReverseVideo(term); screen->grabbedKbd = FALSE; update_securekbd(); } } } selectwindow(screen, flag) register TScreen *screen; register int flag; { #ifndef KTERM_NOTEK if(screen->TekEmu) { if(!Ttoggled) TCursorToggle(TOGGLE); screen->select |= flag; if(!Ttoggled) TCursorToggle(TOGGLE); return; } else { #endif /* !KTERM_NOTEK */ if (screen->xic) XSetICFocus(screen->xic); if(screen->cursor_state && (screen->cursor_col != screen->cur_col || screen->cursor_row != screen->cur_row)) HideCursor(); screen->select |= flag; if(screen->cursor_state) ShowCursor(); return; #ifndef KTERM_NOTEK } #endif /* !KTERM_NOTEK */ } unselectwindow(screen, flag) register TScreen *screen; register int flag; { if (screen->always_highlight) return; #ifndef KTERM_NOTEK if(screen->TekEmu) { if(!Ttoggled) TCursorToggle(TOGGLE); screen->select &= ~flag; if(!Ttoggled) TCursorToggle(TOGGLE); } else { #endif /* !KTERM_NOTEK */ if (screen->xic) XUnsetICFocus(screen->xic); screen->select &= ~flag; if(screen->cursor_state && (screen->cursor_col != screen->cur_col || screen->cursor_row != screen->cur_row)) HideCursor(); if(screen->cursor_state) ShowCursor(); #ifndef KTERM_NOTEK } #endif /* !KTERM_NOTEK */ } static long lastBellTime; /* in milliseconds */ Bell(which,percent) int which; int percent; { extern XtermWidget term; register TScreen *screen = &term->screen; struct timeval curtime; long now_msecs; #ifdef KTERM_XAW3D extern XtAppContext app_con; #endif /* KTERM_XAW3D */ /* has enough time gone by that we are allowed to ring the bell again? */ if(screen->bellSuppressTime) { if(screen->bellInProgress) { #ifdef KTERM_XAW3D if (XtAppPending(app_con) > 0 || #else /* !KTERM_XAW3D */ if (QLength(screen->display) > 0 || #endif /* !KTERM_XAW3D */ GetBytesAvailable (ConnectionNumber(screen->display)) > 0) xevents(); if(screen->bellInProgress) { /* even after new events? */ return; } } X_GETTIMEOFDAY(&curtime); now_msecs = 1000*curtime.tv_sec + curtime.tv_usec/1000; if(lastBellTime != 0 && now_msecs - lastBellTime >= 0 && now_msecs - lastBellTime < screen->bellSuppressTime) { return; } lastBellTime = now_msecs; } if (screen->visualbell) VisualBell(); else #ifdef XKB XkbStdBell(screen->display,TWindow(screen),percent,which); #else XBell(screen->display, percent); #endif if(screen->bellSuppressTime) { /* now we change a property and wait for the notify event to come back. If the server is suspending operations while the bell is being emitted (problematic for audio bell), this lets us know when the previous bell has finished */ #ifdef KTERM_NOTEK Widget w = (Widget) term; #else /* !KTERM_NOTEK */ Widget w = screen->TekEmu ? (Widget) tekWidget : (Widget) term; #endif /* !KTERM_NOTEK */ XChangeProperty(XtDisplay(w), XtWindow(w), XA_NOTICE, XA_NOTICE, 8, PropModeAppend, NULL, 0); screen->bellInProgress = TRUE; } } VisualBell() { extern XtermWidget term; register TScreen *screen = &term->screen; register Pixel xorPixel = screen->foreground ^ term->core.background_pixel; XGCValues gcval; GC visualGC; gcval.function = GXxor; gcval.foreground = xorPixel; visualGC = XtGetGC((Widget)term, GCFunction+GCForeground, &gcval); #ifndef KTERM_NOTEK if(screen->TekEmu) { XFillRectangle( screen->display, TWindow(screen), visualGC, 0, 0, (unsigned) TFullWidth(screen), (unsigned) TFullHeight(screen)); XFlush(screen->display); XFillRectangle( screen->display, TWindow(screen), visualGC, 0, 0, (unsigned) TFullWidth(screen), (unsigned) TFullHeight(screen)); } else { #endif /* !KTERM_NOTEK */ XFillRectangle( screen->display, VWindow(screen), visualGC, 0, 0, (unsigned) FullWidth(screen), (unsigned) FullHeight(screen)); XFlush(screen->display); XFillRectangle( screen->display, VWindow(screen), visualGC, 0, 0, (unsigned) FullWidth(screen), (unsigned) FullHeight(screen)); #ifndef KTERM_NOTEK } #endif /* !KTERM_NOTEK */ } /* ARGSUSED */ void HandleBellPropertyChange(w, data, ev, more) Widget w; XtPointer data; XEvent *ev; Boolean *more; { register TScreen *screen = &term->screen; if (ev->xproperty.atom == XA_NOTICE) { screen->bellInProgress = FALSE; } } Redraw() { extern XtermWidget term; register TScreen *screen = &term->screen; XExposeEvent event; event.type = Expose; event.display = screen->display; event.x = 0; event.y = 0; event.count = 0; if(VWindow(screen)) { event.window = VWindow(screen); event.width = term->core.width; event.height = term->core.height; (*term->core.widget_class->core_class.expose)((Widget)term, (XEvent *)&event, NULL); if(screen->scrollbar) (*screen->scrollWidget->core.widget_class->core_class.expose)(screen->scrollWidget, (XEvent *)&event, NULL); } #ifndef KTERM_NOTEK if(TWindow(screen) && screen->Tshow) { event.window = TWindow(screen); event.width = tekWidget->core.width; event.height = tekWidget->core.height; TekExpose (tekWidget, &event, NULL); } #endif /* !KTERM_NOTEK */ } #if defined(ALLOWLOGGING) || defined(DEBUG) #ifndef X_NOT_POSIX #define HAS_WAITPID #endif /* * create a file only if we could with the permissions of the real user id. * We could emulate this with careful use of access() and following * symbolic links, but that is messy and has race conditions. * Forking is messy, too, but we can't count on setreuid() or saved set-uids * being available. */ void creat_as(uid, gid, pathname, mode) int uid; int gid; char *pathname; int mode; { int fd; int waited; int pid; #ifndef HAS_WAITPID int (*chldfunc)(); chldfunc = signal(SIGCHLD, SIG_DFL); #endif pid = fork(); switch (pid) { case 0: /* child */ setgid(gid); setuid(uid); fd = open(pathname, O_WRONLY|O_CREAT|O_APPEND, mode); if (fd >= 0) { close(fd); _exit(0); } else _exit(1); case -1: /* error */ return; default: /* parent */ #ifdef HAS_WAITPID waitpid(pid, NULL, 0); #else waited = wait(NULL); signal(SIGCHLD, chldfunc); /* Since we had the signal handler uninstalled for a while, we might have missed the termination of our screen child. If we can check for this possibility without hanging, do so. */ do if (waited == term->screen.pid) Cleanup(0); while ( (waited=nonblocking_wait()) > 0); #endif } } #endif #ifdef ALLOWLOGGING /* * logging is a security hole, since it allows a setuid program to * write arbitrary data to an arbitrary file. So it is disabled * by default. */ StartLog(screen) register TScreen *screen; { register char *cp; register int i; static char *log_default; #ifdef ALLOWLOGFILEEXEC void logpipe(); #ifdef SYSV /* SYSV has another pointer which should be part of the ** FILE structure but is actually a separate array. */ unsigned char *old_bufend; #endif /* SYSV */ #endif /* ALLOWLOGFILEEXEC */ if(screen->logging || (screen->inhibit & I_LOG)) return; if(screen->logfile == NULL || *screen->logfile == 0) { if(screen->logfile) free(screen->logfile); if(log_default == NULL) log_default = log_def_name; mktemp(log_default); if((screen->logfile = malloc((unsigned)strlen(log_default) + 1)) == NULL) return; strcpy(screen->logfile, log_default); } if(*screen->logfile == '|') { /* exec command */ #ifdef ALLOWLOGFILEEXEC /* * Warning, enabling this "feature" allows arbitrary programs * to be run. If ALLOWLOGFILECHANGES is enabled, this can be * done through escape sequences.... You have been warned. */ int p[2]; static char *shell; if(pipe(p) < 0 || (i = fork()) < 0) return; if(i == 0) { /* child */ close(p[1]); dup2(p[0], 0); close(p[0]); dup2(fileno(stderr), 1); dup2(fileno(stderr), 2); #ifdef SYSV old_bufend = _bufend(stderr); #endif /* SYSV */ close(fileno(stderr)); stderr->_file = 2; #ifdef SYSV _bufend(stderr) = old_bufend; #endif /* SYSV */ close(ConnectionNumber(screen->display)); close(screen->respond); if(!shell) { register struct passwd *pw; struct passwd *getpwuid(); if(((cp = getenv("SHELL")) == NULL || *cp == 0) && ((pw = getpwuid(screen->uid)) == NULL || *(cp = pw->pw_shell) == 0) || (shell = malloc((unsigned) strlen(cp) + 1)) == NULL) shell = "/bin/sh"; else strcpy(shell, cp); } signal(SIGHUP, SIG_DFL); signal(SIGCHLD, SIG_DFL); setgid(screen->gid); setuid(screen->uid); execl(shell, shell, "-c", &screen->logfile[1], 0); fprintf(stderr, "%s: Can't exec `%s'\n", xterm_name, &screen->logfile[1]); exit(ERROR_LOGEXEC); } close(p[0]); screen->logfd = p[1]; signal(SIGPIPE, logpipe); #else Bell(XkbBI_Info,0); Bell(XkbBI_Info,0); return; #endif } else { if(access(screen->logfile, F_OK) != 0) { if (errno == ENOENT) creat_as(screen->uid, screen->gid, screen->logfile, 0644); else return; } if(access(screen->logfile, F_OK) != 0 || access(screen->logfile, W_OK) != 0) return; if((screen->logfd = open(screen->logfile, O_WRONLY | O_APPEND, 0644)) < 0) return; } #ifdef KTERM_NOTEK screen->logstart = bptr; #else /* !KTERM_NOTEK */ screen->logstart = screen->TekEmu ? Tbptr : bptr; #endif /* !KTERM_NOTEK */ screen->logging = TRUE; update_logging(); } CloseLog(screen) register TScreen *screen; { if(!screen->logging || (screen->inhibit & I_LOG)) return; FlushLog(screen); close(screen->logfd); screen->logging = FALSE; update_logging(); } FlushLog(screen) register TScreen *screen; { register Char *cp; register int i; #ifdef KTERM_NOTEK cp = bptr; #else /* !KTERM_NOTEK */ cp = screen->TekEmu ? Tbptr : bptr; #endif /* !KTERM_NOTEK */ if((i = cp - screen->logstart) > 0) write(screen->logfd, (char *)screen->logstart, i); #ifdef KTERM_NOTEK screen->logstart = buffer; #else /* !KTERM_NOTEK */ screen->logstart = screen->TekEmu ? Tbuffer : buffer; #endif /* !KTERM_NOTEK */ } #ifdef ALLOWLOGFILEEXEC void logpipe() { register TScreen *screen = &term->screen; #ifdef SYSV (void) signal(SIGPIPE, SIG_IGN); #endif /* SYSV */ if(screen->logging) CloseLog(screen); } #endif /* ALLOWLOGFILEEXEC */ #endif /* ALLOWLOGGING */ do_osc(func) int (*func)(); { register int mode, c; register char *cp; char buf[512]; char *bufend = &buf[(sizeof buf) - 1]; /* leave room for null */ Bool okay = True; /* * lines should be of the form ] number ; string * * where number is one of 0, 1, 2, or 46 */ mode = 0; while(isdigit(c = (*func)())) mode = 10 * mode + (c - '0'); if (c != ';') okay = False; cp = buf; while(isprint((c = (*func)()) & 0x7f) && cp < bufend) *cp++ = c; if (c != 7) okay = False; *cp = 0; if (okay) switch(mode) { case 0: /* new icon name and title*/ Changename(buf); Changetitle(buf); break; case 1: /* new icon name only */ Changename(buf); break; case 2: /* new title only */ Changetitle(buf); break; #ifdef ALLOWLOGGING case 46: /* new log file */ #ifdef ALLOWLOGFILECHANGES /* * Warning, enabling this feature allows people to overwrite * arbitrary files accessible to the person running xterm. */ if((cp = malloc((unsigned)strlen(buf) + 1)) == NULL) break; strcpy(cp, buf); if(term->screen.logfile) free(term->screen.logfile); term->screen.logfile = cp; #else Bell(XkbBI_Info,0); Bell(XkbBI_Info,0); #endif break; #endif /* ALLOWLOGGING */ case 50: SetVTFont (fontMenu_fontescape, True, buf, NULL); break; /* * One could write code to send back the display and host names, * but that could potentially open a fairly nasty security hole. */ } } static ChangeGroup(attribute, value) String attribute; XtArgVal value; { extern Widget toplevel; Arg args[1]; XtSetArg( args[0], attribute, value ); XtSetValues( toplevel, args, 1 ); } Changename(name) register char *name; { ChangeGroup( XtNiconName, (XtArgVal)name ); } Changetitle(name) register char *name; { ChangeGroup( XtNtitle, (XtArgVal)name ); } #ifndef DEBUG /* ARGSUSED */ #endif Panic(s, a) char *s; int a; { #ifdef DEBUG if(debug) { fprintf(stderr, "%s: PANIC! ", xterm_name); fprintf(stderr, s, a); fputs("\r\n", stderr); fflush(stderr); } #endif /* DEBUG */ } char *SysErrorMsg (n) int n; { register char *s = strerror(n); return s ? s : "unknown error"; } SysError (i) int i; { int oerrno; oerrno = errno; /* perror(3) write(2)s to file descriptor 2 */ fprintf (stderr, "%s: Error %d, errno %d: ", xterm_name, i, oerrno); fprintf (stderr, "%s\n", SysErrorMsg (oerrno)); Cleanup(i); } Error (i) int i; { fprintf (stderr, "%s: Error %d\n", xterm_name, i); Cleanup(i); } /* * cleanup by sending SIGHUP to client processes */ Cleanup (code) int code; { extern XtermWidget term; register TScreen *screen; screen = &term->screen; if (screen->pid > 1) { (void) kill_process_group (screen->pid, SIGHUP); } Exit (code); } /* * sets the value of var to be arg in the Unix 4.2 BSD environment env. * Var should end with '=' (bindings are of the form "var=value"). * This procedure assumes the memory for the first level of environ * was allocated using calloc, with enough extra room at the end so not * to have to do a realloc(). */ Setenv (var, value) register char *var, *value; { extern char **environ; register int envindex = 0; register int len = strlen(var); while (environ [envindex] != NULL) { if (strncmp (environ [envindex], var, len) == 0) { /* found it */ environ[envindex] = (char *)malloc ((unsigned)len + strlen (value) + 1); strcpy (environ [envindex], var); strcat (environ [envindex], value); return; } envindex ++; } #ifdef DEBUG if (debug) fputs ("expanding env\n", stderr); #endif /* DEBUG */ environ [envindex] = (char *) malloc ((unsigned)len + strlen (value) + 1); (void) strcpy (environ [envindex], var); strcat (environ [envindex], value); environ [++envindex] = NULL; } /* * returns a pointer to the first occurrence of s2 in s1, * or NULL if there are none. */ char *strindex (s1, s2) register char *s1, *s2; { register char *s3; int s2len = strlen (s2); while ((s3=strchr(s1, *s2)) != NULL) { if (strncmp(s3, s2, s2len) == 0) return (s3); s1 = ++s3; } return (NULL); } /*ARGSUSED*/ xerror(d, ev) Display *d; register XErrorEvent *ev; { fprintf (stderr, "%s: warning, error event receieved:\n", xterm_name); (void) XmuPrintDefaultErrorMessage (d, ev, stderr); Exit (ERROR_XERROR); } /*ARGSUSED*/ xioerror(dpy) Display *dpy; { (void) fprintf (stderr, "%s: fatal IO error %d (%s) or KillClient on X server \"%s\"\r\n", xterm_name, errno, SysErrorMsg (errno), DisplayString (dpy)); Exit(ERROR_XIOERROR); } void xt_error(message) String message; { extern char *ProgramName; (void) fprintf (stderr, "%s Xt error: %s\n", ProgramName, message); exit(1); } XStrCmp(s1, s2) char *s1, *s2; { if (s1 && s2) return(strcmp(s1, s2)); if (s1 && *s1) return(1); if (s2 && *s2) return(-1); return(0); } #ifndef KTERM_NOTEK static void withdraw_window (dpy, w, scr) Display *dpy; Window w; int scr; { (void) XmuUpdateMapHints (dpy, w, NULL); XWithdrawWindow (dpy, w, scr); return; } void set_vt_visibility (on) Boolean on; { register TScreen *screen = &term->screen; if (on) { if (!screen->Vshow && term) { VTInit (); XtMapWidget (term->core.parent); screen->Vshow = TRUE; } } else { if (screen->Vshow && term) { withdraw_window (XtDisplay (term), XtWindow(XtParent(term)), XScreenNumberOfScreen(XtScreen(term))); screen->Vshow = FALSE; } } set_vthide_sensitivity(); set_tekhide_sensitivity(); update_vttekmode(); update_tekshow(); update_vtshow(); return; } extern Atom wm_delete_window; /* for ICCCM delete window */ void set_tek_visibility (on) Boolean on; { register TScreen *screen = &term->screen; if (on) { if (!screen->Tshow && (tekWidget || TekInit())) { Widget tekParent = tekWidget->core.parent; XtRealizeWidget (tekParent); XtMapWidget (tekParent); XtOverrideTranslations(tekParent, XtParseTranslationTable ("WM_PROTOCOLS: DeleteWindow()")); (void) XSetWMProtocols (XtDisplay(tekParent), XtWindow(tekParent), &wm_delete_window, 1); screen->Tshow = TRUE; } } else { if (screen->Tshow && tekWidget) { withdraw_window (XtDisplay (tekWidget), XtWindow(XtParent(tekWidget)), XScreenNumberOfScreen(XtScreen(tekWidget))); screen->Tshow = FALSE; } } set_tekhide_sensitivity(); set_vthide_sensitivity(); update_vtshow(); update_tekshow(); update_vttekmode(); return; } void end_tek_mode () { register TScreen *screen = &term->screen; if (screen->TekEmu) { #ifdef ALLOWLOGGING if (screen->logging) { FlushLog (screen); screen->logstart = buffer; } #endif longjmp(Tekend, 1); } return; } void end_vt_mode () { register TScreen *screen = &term->screen; if (!screen->TekEmu) { #ifdef ALLOWLOGGING if(screen->logging) { FlushLog(screen); screen->logstart = Tbuffer; } #endif screen->TekEmu = TRUE; longjmp(VTend, 1); } return; } void switch_modes (tovt) Bool tovt; /* if true, then become vt mode */ { if (tovt) { if (TekRefresh) dorefresh(); end_tek_mode (); /* WARNING: this does a longjmp... */ } else { end_vt_mode (); /* WARNING: this does a longjmp... */ } } void hide_vt_window () { register TScreen *screen = &term->screen; set_vt_visibility (FALSE); if (!screen->TekEmu) switch_modes (False); /* switch to tek mode */ } void hide_tek_window () { register TScreen *screen = &term->screen; set_tek_visibility (FALSE); TekRefresh = (TekLink *)0; if (screen->TekEmu) switch_modes (True); /* does longjmp to vt mode */ } #endif /* !KTERM_NOTEK */ kterm-6.2.0.orig/ptyx.h100444 507 454 55010 6166126501 13506 0ustar yosiakiaux/* * $XConsortium: ptyx.h /main/66 1995/12/09 08:58:41 kaleb $ * $Id: ptyx.h,v 6.2 1996/07/02 05:01:31 kagotani Rel $ */ #ifdef KTERM #include "kterm.h" #endif /* KTERM */ /* * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ /* ptyx.h */ /* @(#)ptyx.h X10/6.6 11/10/86 */ #include #include /* For Max() and Min(). */ #include #include /* Extra Xlib definitions */ #define AllButtonsUp(detail, ignore) (\ ((ignore) == Button1) ? \ (((detail)&(Button2Mask|Button3Mask)) == 0) \ : \ (((ignore) == Button2) ? \ (((detail)&(Button1Mask|Button3Mask)) == 0) \ : \ (((detail)&(Button1Mask|Button2Mask)) == 0)) \ ) #define MAX_COLS 200 #define MAX_ROWS 128 /* ** System V definitions */ #ifdef SYSV #ifdef X_NOT_POSIX #ifndef CRAY #define dup2(fd1,fd2) ((fd1 == fd2) ? fd1 : \ (close(fd2), fcntl(fd1, F_DUPFD, fd2))) #endif #endif #endif /* SYSV */ /* ** allow for mobility of the pty master/slave directories */ #ifndef PTYDEV #ifdef hpux #define PTYDEV "/dev/ptym/ptyxx" #else /* !hpux */ #ifndef __osf__ #define PTYDEV "/dev/ptyxx" #endif #endif /* !hpux */ #endif /* !PTYDEV */ #ifndef TTYDEV #ifdef hpux #define TTYDEV "/dev/pty/ttyxx" #else /* !hpux */ #ifdef __osf__ #define TTYDEV "/dev/ttydirs/xxx/xxxxxxxxxxxxxx" #else #define TTYDEV "/dev/ttyxx" #endif #endif /* !hpux */ #endif /* !TTYDEV */ #ifndef PTYCHAR1 #ifdef hpux #define PTYCHAR1 "zyxwvutsrqp" #else /* !hpux */ #define PTYCHAR1 "pqrstuvwxyzPQRSTUVWXYZ" #endif /* !hpux */ #endif /* !PTYCHAR1 */ #ifndef PTYCHAR2 #ifdef hpux #define PTYCHAR2 "fedcba9876543210" #else /* !hpux */ #ifdef __FreeBSD__ #define PTYCHAR2 "0123456789abcdefghijklmnopqrstuv" #else #define PTYCHAR2 "0123456789abcdef" #endif #endif /* !hpux */ #endif /* !PTYCHAR2 */ #ifndef TTYFORMAT #ifdef CRAY #define TTYFORMAT "/dev/ttyp%03d" #else #define TTYFORMAT "/dev/ttyp%d" #endif #endif #ifndef PTYFORMAT #ifdef CRAY #define PTYFORMAT "/dev/pty/%03d" #else #define PTYFORMAT "/dev/ptyp%d" #endif #endif #ifndef MAXPTTYS #ifdef CRAY #define MAXPTTYS 256 #else #define MAXPTTYS 2048 #endif #endif /* Until the translation manager comes along, I have to do my own translation of * mouse events into the proper routines. */ typedef enum {NORMAL, LEFTEXTENSION, RIGHTEXTENSION} EventMode; /* * The origin of a screen is 0, 0. Therefore, the number of rows * on a screen is screen->max_row + 1, and similarly for columns. */ typedef unsigned char Char; /* to support 8 bit chars */ #ifdef KTERM #include "gset.h" /* uses Boolean and Char */ #endif /* KTERM */ #ifdef KTERM typedef struct { Char gset; Char code; # ifdef KTERM_COLOR unsigned short attr; # else /* !KTERM_COLOR */ Char attr; # endif /* !KTERM_COLOR */ } Bchr; /* char for screen buffers */ typedef Bchr **ScrnBuf; typedef struct { Char gset; Char code; } Ichr; /* char for interchanging with other processes */ #else /* !KTERM */ typedef Char **ScrnBuf; #endif /* !KTERM */ /* * ANSI emulation. */ #define INQ 0x05 #define FF 0x0C /* C0, C1 control names */ #define LS1 0x0E #define LS0 0x0F #define CAN 0x18 #define SUB 0x1A #define ESC 0x1B #define US 0x1F #define DEL 0x7F #define HTS ('H'+0x40) #define SS2 0x8E #define SS3 0x8F #define DCS 0x90 #define OLDID 0x9A /* ESC Z */ #define CSI 0x9B #define ST 0x9C #define OSC 0x9D #define PM 0x9E #define APC 0x9F #define RDEL 0xFF #define NMENUFONTS 9 /* entries in fontMenu */ #define NBOX 5 /* Number of Points in box */ #define NPARAM 10 /* Max. parameters */ #define MINHILITE 32 typedef struct { unsigned char a_type; unsigned char a_pintro; unsigned char a_final; unsigned char a_inters; char a_nparam; /* # of parameters */ char a_dflt[NPARAM]; /* Default value flags */ short a_param[NPARAM]; /* Parameters */ char a_nastyf; /* Error flag */ } ANSI; typedef struct { int row; int col; unsigned flags; /* Vt100 saves graphics rendition. Ugh! */ char curgl; char curgr; #ifdef KTERM Char gsets[4]; #else /* !KTERM */ char gsets[4]; #endif /* !KTERM */ } SavedCursor; #ifndef KTERM_NOTEK #define TEK_FONT_LARGE 0 #define TEK_FONT_2 1 #define TEK_FONT_3 2 #define TEK_FONT_SMALL 3 #define TEKNUMFONTS 4 /* Actually there are 5 types of lines, but four are non-solid lines */ #define TEKNUMLINES 4 typedef struct { int x; int y; int fontsize; int linetype; } Tmodes; typedef struct { int Twidth; int Theight; } T_fontsize; typedef struct { short *bits; int x; int y; int width; int height; } BitmapBits; #endif /* !KTERM_NOTEK */ #define SAVELINES 64 /* default # lines to save */ #define SCROLLLINES 1 /* default # lines to scroll */ #ifdef KTERM # define LINESPACE 0 /* default space between lines */ #endif /* KTERM */ #ifdef KTERM_XIM # define EUCJPLOCALE "ja_JP.eucJP,ja_JP.ujis,ja_JP.EUC,japanese.euc,Japanese-EUC,ja,japan" #endif /* KTERM_XIM */ typedef struct { /* These parameters apply to both windows */ Display *display; /* X display for screen */ int respond; /* socket for responses (position report, etc.) */ long pid; /* pid of process on far side */ int uid; /* user id of actual person */ int gid; /* group id of actual person */ #ifdef KTERM GC _normalGC[FCNT]; GC _reverseGC[FCNT]; GC _normalboldGC[FCNT]; GC _reverseboldGC[FCNT]; GC _cursorGC[FCNT]; GC _reversecursorGC[FCNT]; # define normalGC _normalGC[fnum] # define reverseGC _reverseGC[fnum] # define normalboldGC _normalboldGC[fnum] # define reverseboldGC _reverseboldGC[fnum] # define cursorGC _cursorGC[fnum] # define reversecursorGC _reversecursorGC[fnum] #else /* !KTERM */ GC normalGC; /* normal painting */ GC reverseGC; /* reverse painting */ GC normalboldGC; /* normal painting, bold font */ GC reverseboldGC; /* reverse painting, bold font */ GC cursorGC; /* normal cursor painting */ GC reversecursorGC;/* reverse cursor painting */ #endif /* !KTERM */ GC cursoroutlineGC;/* for painting lines around */ Pixel foreground; /* foreground color */ Pixel cursorcolor; /* Cursor color */ Pixel mousecolor; /* Mouse color */ Pixel mousecolorback; /* Mouse color background */ #ifdef KTERM_COLOR Pixel textcolor[8]; /* text colors */ #endif /* KTERM_COLOR */ int border; /* inner border */ Cursor arrow; /* arrow cursor */ unsigned short send_mouse_pos; /* user wants mouse transition */ /* and position information */ int select; /* xterm selected */ Boolean visualbell; /* visual bell mode */ Boolean allowSendEvents;/* SendEvent mode */ Boolean grabbedKbd; /* keyboard is grabbed */ #ifdef ALLOWLOGGING int logging; /* logging mode */ int logfd; /* file descriptor of log */ char *logfile; /* log file name */ unsigned char *logstart; /* current start of log buffer */ #endif int inhibit; /* flags for inhibiting changes */ /* VT window parameters */ struct { Window window; /* X window id */ int width; /* width of columns */ int height; /* height of rows */ int fullwidth; /* full width of window */ int fullheight; /* full height of window */ int f_width; /* width of fonts in pixels */ int f_height; /* height of fonts in pixels */ } fullVwin; Cursor pointer_cursor; /* pointer cursor in window */ /* Terminal fonts must be of the same size and of fixed width */ #ifdef KTERM XFontStruct *_fnt_norm[FCNT]; XFontStruct *_fnt_bold[FCNT]; XPoint *_box[FCNT]; # define fnt_norm _fnt_norm[fnum] # define fnt_bold _fnt_bold[fnum] # define box _box[fnum] int linespace; /* space between lines */ int max_ascent; int max_descent; Pixmap *graphics; #else /* !KTERM */ XFontStruct *fnt_norm; /* normal font of terminal */ XFontStruct *fnt_bold; /* bold font of terminal */ int enbolden; /* overstrike for bold font */ XPoint *box; /* draw unselected cursor */ #endif /* !KTERM */ int cursor_state; /* ON or OFF */ int cursor_set; /* requested state */ int cursor_col; /* previous cursor column */ int cursor_row; /* previous cursor row */ int cur_col; /* current cursor column */ int cur_row; /* current cursor row */ int max_col; /* rightmost column */ int max_row; /* bottom row */ int top_marg; /* top line of scrolling region */ int bot_marg; /* bottom line of " " */ Widget scrollWidget; /* pointer to scrollbar struct */ int scrollbar; /* if > 0, width of scrollbar, and scrollbar is showing */ int topline; /* line number of top, <= 0 */ int savedlines; /* number of lines that've been saved */ int savelines; /* number of lines off top to save */ int scrolllines; /* number of lines to button scroll */ Boolean scrollttyoutput; /* scroll to bottom on tty output */ Boolean scrollkey; /* scroll to bottom on key */ ScrnBuf buf; /* ptr to visible screen buf (main) */ ScrnBuf allbuf; /* screen buffer (may include lines scrolled off top) */ char *sbuf_address; /* main screen memory address */ ScrnBuf altbuf; /* alternate screen buffer */ char *abuf_address; /* alternate screen memory address */ Boolean alternate; /* true if using alternate buf */ unsigned short do_wrap; /* true if cursor in last column and character just output */ int incopy; /* 0 idle; 1 XCopyArea issued; -1 first GraphicsExpose seen, but last not seen */ int copy_src_x; /* params from last XCopyArea ... */ int copy_src_y; unsigned int copy_width; unsigned int copy_height; int copy_dest_x; int copy_dest_y; Boolean c132; /* allow change to 132 columns */ Boolean curses; /* kludge line wrap for more */ Boolean hp_ll_bc; /* kludge HP-style ll for xdb */ Boolean marginbell; /* true if margin bell on */ int nmarginbell; /* columns from right margin */ int bellarmed; /* cursor below bell margin */ Boolean multiscroll; /* true if multi-scroll */ int scrolls; /* outstanding scroll count, used only with multiscroll */ SavedCursor sc; /* data for restore cursor */ int save_modes[19]; /* save dec private modes */ #ifdef STATUSLINE int statusheight; /* status line height */ Boolean instatus; /* cursor in status line */ SavedCursor statussc; /* status line restore cursor */ Boolean reversestatus; /* status line reversed */ #endif /* STATUSLINE */ /* Improved VT100 emulation stuff. */ #ifdef KTERM Char gsets[4]; /* G0 through G3. */ #else /* !KTERM */ char gsets[4]; /* G0 through G3. */ #endif /* !KTERM */ char curgl; /* Current GL setting. */ char curgr; /* Current GR setting. */ char curss; /* Current single shift. */ int scroll_amt; /* amount to scroll */ int refresh_amt; /* amount to refresh */ Boolean jumpscroll; /* whether we should jumpscroll */ Boolean always_highlight; /* whether to highlight cursor */ #ifndef KTERM_NOTEK /* Tektronix window parameters */ GC TnormalGC; /* normal painting */ GC TcursorGC; /* normal cursor painting */ Pixel Tforeground; /* foreground color */ Pixel Tbackground; /* Background color */ Pixel Tcursorcolor; /* Cursor color */ int Tcolor; /* colors used */ Boolean Vshow; /* VT window showing */ Boolean Tshow; /* Tek window showing */ Boolean waitrefresh; /* postpone refresh */ struct { Window window; /* X window id */ int width; /* width of columns */ int height; /* height of rows */ int fullwidth; /* full width of window */ int fullheight; /* full height of window */ double tekscale; /* scale factor Tek -> vs100 */ } fullTwin; int xorplane; /* z plane for inverts */ GC linepat[TEKNUMLINES]; /* line patterns */ Boolean TekEmu; /* true if Tektronix emulation */ int cur_X; /* current x */ int cur_Y; /* current y */ Tmodes cur; /* current tek modes */ Tmodes page; /* starting tek modes on page */ int margin; /* 0 -> margin 1, 1 -> margin 2 */ int pen; /* current Tektronix pen 0=up, 1=dn */ char *TekGIN; /* nonzero if Tektronix GIN mode*/ int gin_terminator; /* Tek strap option */ #endif /* !KTERM_NOTEK */ int multiClickTime; /* time between multiclick selects */ int bellSuppressTime; /* msecs after Bell before another allowed */ Boolean bellInProgress; /* still ringing/flashing prev bell? */ char *charClass; /* for overriding word selection */ Boolean cutNewline; /* whether or not line cut has \n */ Boolean cutToBeginningOfLine; /* line cuts to BOL? */ #ifdef KTERM Ichr *selection; /* the current selection */ #else /* !KTERM */ char *selection; /* the current selection */ #endif /* !KTERM */ int selection_size; /* size of allocated buffer */ int selection_length; /* number of significant bytes */ Time selection_time; /* latest event timestamp */ int startHRow, startHCol, /* highlighted text */ endHRow, endHCol, startHCoord, endHCoord; Atom* selection_atoms; /* which selections we own */ Cardinal sel_atoms_size; /* how many atoms allocated */ Cardinal selection_count; /* how many atoms in use */ Boolean input_eight_bits;/* use 8th bit instead of ESC prefix */ Boolean output_eight_bits; /* honor all bits or strip */ Pixmap menu_item_bitmap; /* mask for checking items */ #ifdef KTERM_NOTEK Widget mainMenu, vtMenu, fontMenu; #else /* !KTERM_NOTEK */ Widget mainMenu, vtMenu, tekMenu, fontMenu; #endif /* !KTERM_NOTEK */ #ifdef KTERM Boolean dynamic_font_load; /* load fonts on demand */ char* menu_font_list[NMENUFONTS]; char* menu_bfont_list[NMENUFONTS]; char* _menu_font_names[FCNT][NMENUFONTS]; char* _menu_bfont_names[FCNT][NMENUFONTS]; # define menu_font_names _menu_font_names[fnum] # define menu_bfont_names _menu_bfont_names[fnum] #else /* !KTERM */ char* menu_font_names[NMENUFONTS]; #endif /* !KTERM */ int menu_font_number; XIC xic; #ifdef KTERM_XIM XIMStyle xicstyle; XFontSet xicfontset; Boolean imregistered; #ifdef INTHEFUTURE Boolean imserverdied; char **modifier_list; #endif #endif /* KTERM_XIM */ } TScreen; #ifndef KTERM_NOTEK typedef struct _TekPart { XFontStruct *Tfont[TEKNUMFONTS]; int tobaseline[TEKNUMFONTS]; /* top to baseline for each font */ char *initial_font; /* large, 2, 3, small */ char *gin_terminator_str; /* ginTerminator resource */ } TekPart; #endif /* !KTERM_NOTEK */ /* meaning of bits in screen.select flag */ #define INWINDOW 01 /* the mouse is in one of the windows */ #define FOCUS 02 /* one of the windows is the focus window */ #define MULTICLICKTIME 250 /* milliseconds */ typedef struct { unsigned flags; } TKeyboard; typedef struct _Misc { char *geo_metry; char *T_geometry; #ifndef KTERM char *f_n; char *f_b; #endif /* !KTERM */ #ifdef ALLOWLOGGING Boolean log_on; #endif Boolean login_shell; Boolean re_verse; int resizeGravity; Boolean reverseWrap; Boolean autoWrap; Boolean logInhibit; Boolean signalInhibit; #ifndef KTERM_NOTEK Boolean tekInhibit; #endif /* !KTERM_NOTEK */ Boolean scrollbar; Boolean titeInhibit; #ifndef KTERM_NOTEK Boolean tekSmall; /* start tek window in small size */ #endif /* !KTERM_NOTEK */ Boolean appcursorDefault; Boolean appkeypadDefault; #ifdef KTERM_KANJIMODE char *k_m; #endif /* KTERM_KANJIMODE */ #ifdef KTERM_XIM char* eucjp_locale; #endif /* !KTERM_XIM */ char* input_method; char* preedit_type; Boolean open_im; Boolean shared_ic; #ifdef STATUSLINE Boolean statusline; Boolean statusnormal; #endif /* STATUSLINE */ } Misc; #ifdef KTERM_NOTEK typedef struct {int foo;} XtermClassPart; #else /* !KTERM_NOTEK */ typedef struct {int foo;} XtermClassPart, TekClassPart; #endif /* !KTERM_NOTEK */ typedef struct _XtermClassRec { CoreClassPart core_class; XtermClassPart xterm_class; } XtermClassRec; #ifndef KTERM_NOTEK typedef struct _TekClassRec { CoreClassPart core_class; TekClassPart tek_class; } TekClassRec; #endif /* !KTERM_NOTEK */ /* define masks for flags */ #define CAPS_LOCK 0x01 #define KYPD_APL 0x02 #define CURSOR_APL 0x04 #define N_MARGINBELL 10 #define MAX_TABS 320 #define TAB_ARRAY_SIZE 10 /* number of ints to provide MAX_TABS bits */ typedef unsigned Tabs [TAB_ARRAY_SIZE]; typedef struct _XtermWidgetRec { CorePart core; TKeyboard keyboard; /* terminal keyboard */ TScreen screen; /* terminal screen */ unsigned flags; /* mode flags */ unsigned initflags; /* initial mode flags */ Tabs tabs; /* tabstops of the terminal */ Misc misc; /* miscellaneous parameters */ } XtermWidgetRec, *XtermWidget; #ifndef KTERM_NOTEK typedef struct _TekWidgetRec { CorePart core; TekPart tek; } TekWidgetRec, *TekWidget; #endif /* !KTERM_NOTEK */ #define BUF_SIZE 4096 /* * terminal flags * There are actually two namespaces mixed together here. * One is the set of flags that can go in screen->buf attributes * and which must fit in a char. * The other is the global setting stored in * term->flags and screen->save_modes. This need only fit in an unsigned. */ #ifdef KTERM_COLOR #define ATTRIBUTES 0xff07 /* mask: user-visible attributes */ #else /* !KTERM_COLOR */ #define ATTRIBUTES 0x07 /* mask: user-visible attributes */ #endif /* !KTERM_COLOR */ /* global flags and character flags (visible character attributes) */ #define INVERSE 0x01 /* invert the characters to be output */ #define UNDERLINE 0x02 /* true if underlining */ #define BOLD 0x04 /* character flags (internal attributes) */ #define LINEWRAPPED 0x08 /* used on the first character in a * line to indicate that it wraps onto * the next line so we can tell the * difference between lines that have * wrapped around and lines that have * ended naturally with a CR at column * max_col. */ #define CHARDRAWN 0x10 /* a character has been drawn here on the screen. Used to distinguish blanks from empty parts of the screen when selecting */ #ifdef KTERM_COLOR #define FORECOLORED 0x0800 #define FORECOLORMASK 0x0700 #define FORECOLOR(c) ((c) << 8) #define FORECOLORNUM(f) (((f) & FORECOLORMASK) >> 8) #define BACKCOLORED 0x8000 #define BACKCOLORMASK 0x7000 #define BACKCOLOR(c) ((c) << 12) #define BACKCOLORNUM(f) (((f) & BACKCOLORMASK) >> 12) #endif /* KTERM_COLOR */ /* global flags */ #ifdef KTERM #define WRAPAROUND 0x40000 /* true if auto wraparound mode */ #define REVERSEWRAP 0x80000 /* true if reverse wraparound mode */ #define REVERSE_VIDEO 0x100000 /* true if screen white on black */ #define LINEFEED 0x200000 /* true if in auto linefeed mode */ #define ORIGIN 0x400000 /* true if in origin mode */ #define INSERT 0x800000 /* true if in insert mode */ #define SMOOTHSCROLL 0x1000000 /* true if in smooth scroll mode */ #define IN132COLUMNS 0x2000000 /* true if in 132 column mode */ #ifdef KTERM_KANJIMODE #define EUC_KANJI 0x4000000 /* true if in EUC mode */ #define SJIS_KANJI 0x8000000 /* true if in SJIS mode */ #endif /* KTERM_KANJIMODE */ #else /* !KTERM */ #define WRAPAROUND 0x400 /* true if auto wraparound mode */ #define REVERSEWRAP 0x800 /* true if reverse wraparound mode */ #define REVERSE_VIDEO 0x1000 /* true if screen white on black */ #define LINEFEED 0x2000 /* true if in auto linefeed mode */ #define ORIGIN 0x4000 /* true if in origin mode */ #define INSERT 0x8000 /* true if in insert mode */ #define SMOOTHSCROLL 0x10000 /* true if in smooth scroll mode */ #define IN132COLUMNS 0x20000 /* true if in 132 column mode */ #endif /* !KTERM */ #define VWindow(screen) (screen->fullVwin.window) #define VShellWindow term->core.parent->core.window #define TextWindow(screen) (screen->fullVwin.window) #ifndef KTERM_NOTEK #define TWindow(screen) (screen->fullTwin.window) #define TShellWindow tekWidget->core.parent->core.window #endif /* !KTERM_NOTEK */ #define Width(screen) (screen->fullVwin.width) #define Height(screen) (screen->fullVwin.height) #define FullWidth(screen) (screen->fullVwin.fullwidth) #define FullHeight(screen) (screen->fullVwin.fullheight) #define FontWidth(screen) (screen->fullVwin.f_width) #ifdef KTERM #define FontHeight(screen) (screen->fullVwin.f_height + screen->linespace) #else /* !KTERM */ #define FontHeight(screen) (screen->fullVwin.f_height) #endif /* !KTERM */ #ifndef KTERM_NOTEK #define TWidth(screen) (screen->fullTwin.width) #define THeight(screen) (screen->fullTwin.height) #define TFullWidth(screen) (screen->fullTwin.fullwidth) #define TFullHeight(screen) (screen->fullTwin.fullheight) #define TekScale(screen) (screen->fullTwin.tekscale) #endif /* !KTERM_NOTEK */ #define CursorX(screen,col) ((col) * FontWidth(screen) + screen->border \ + screen->scrollbar) #ifdef STATUSLINE #define CursorY(screen,row) ((row)>screen->max_row \ ? (row) * FontHeight(screen) + screen->border * 2 + 1 \ : ((row) - screen->topline) * FontHeight(screen) + screen->border) #else /* !STATUSLINE */ #define CursorY(screen,row) ((((row) - screen->topline) * FontHeight(screen)) \ + screen->border) #endif /* !STATUSLINE */ #define TWINDOWEVENTS (KeyPressMask | ExposureMask | ButtonPressMask |\ ButtonReleaseMask | StructureNotifyMask |\ EnterWindowMask | LeaveWindowMask | FocusChangeMask) #define WINDOWEVENTS (TWINDOWEVENTS | PointerMotionMask) #ifndef KTERM_NOTEK #define TEK_LINK_BLOCK_SIZE 1024 typedef struct Tek_Link { struct Tek_Link *next; /* pointer to next TekLink in list NULL <=> this is last TekLink */ short fontsize; /* character size, 0-3 */ short count; /* number of chars in data */ char *ptr; /* current pointer into data */ char data [TEK_LINK_BLOCK_SIZE]; } TekLink; #endif /* !KTERM_NOTEK */ /* flags for cursors */ #define OFF 0 #define ON 1 #define CLEAR 0 #define TOGGLE 1 /* flags for inhibit */ #ifdef ALLOWLOGGING #define I_LOG 0x01 #endif #define I_SIGNAL 0x02 #ifndef KTERM_NOTEK #define I_TEK 0x04 #endif /* !KTERM_NOTEK */ extern Cursor make_colored_cursor(); extern int GetBytesAvailable(); extern void first_map_occurred(); extern int kill_process_group(); kterm-6.2.0.orig/screen.c100444 507 454 105734 6163174632 14012 0ustar yosiakiaux/* * $XConsortium: screen.c,v 1.33 94/04/02 17:34:36 gildea Exp $ * $Id: screen.c,v 6.3 1996/06/23 08:00:09 kagotani Rel $ */ /* * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ /* screen.c */ #include "ptyx.h" #include "error.h" #include "data.h" #include #include #if defined(SVR4) || defined(hpux) #include #else #include #endif #ifdef att #include #include /* get typedef used in ptem.h */ #include #endif extern Char *calloc(), *malloc(), *realloc(); extern void free(); ScrnBuf Allocate (nrow, ncol, addr) /* allocates memory for a 2-dimensional array of chars and returns a pointer thereto each line is formed from a pair of char arrays. The first (even) one is the actual character array and the second (odd) one is the attributes. */ register int nrow, ncol; #ifdef KTERM Bchr **addr; #else /* !KTERM */ Char **addr; #endif /* !KTERM */ { register ScrnBuf base; #ifdef KTERM register Bchr *tmp; #else /* !KTERM */ register Char *tmp; #endif /* !KTERM */ register int i; #ifdef STATUSLINE nrow++; #endif /* STATUSLINE */ #ifdef KTERM if ((base = (ScrnBuf) calloc ((unsigned)nrow, sizeof (Bchr *))) == 0) #else /* !KTERM */ if ((base = (ScrnBuf) calloc ((unsigned)(nrow *= 2), sizeof (char *))) == 0) #endif /* !KTERM */ SysError (ERROR_SCALLOC); #ifdef KTERM if ((tmp = (Bchr *)calloc ((unsigned) (nrow * ncol), sizeof(Bchr))) == 0) #else /* !KTERM */ if ((tmp = calloc ((unsigned) (nrow * ncol), sizeof(char))) == 0) #endif /* !KTERM */ SysError (ERROR_SCALLOC2); *addr = tmp; for (i = 0; i < nrow; i++, tmp += ncol) base[i] = tmp; return (base); } /* * This is called when the screen is resized. * Returns the number of lines the text was moved down (neg for up). * (Return value only necessary with SouthWestGravity.) */ static Reallocate(sbuf, sbufaddr, nrow, ncol, oldrow, oldcol) ScrnBuf *sbuf; #ifdef KTERM Bchr **sbufaddr; #else /* !KTERM */ Char **sbufaddr; #endif /* !KTERM */ int nrow, ncol, oldrow, oldcol; { register ScrnBuf base; #ifdef KTERM register Bchr *tmp; register int i, minrows, mincols; Bchr *oldbuf; # ifdef STATUSLINE Bchr *oldstat; # endif /* STATUSLINE */ #else /* !KTERM */ register Char *tmp; register int i, minrows, mincols; Char *oldbuf; # ifdef STATUSLINE Char *oldstat; # endif /* STATUSLINE */ #endif /* !KTERM */ int move_down = 0, move_up = 0; if (sbuf == NULL || *sbuf == NULL) return 0; #ifdef STATUSLINE nrow++; oldrow++; /* save pointers for the statusline (the last row) */ oldstat = (*sbuf)[oldrow-1]; #endif /* STATUSLINE */ #ifndef KTERM oldrow *= 2; #endif /* !KTERM */ oldbuf = *sbufaddr; /* * Special case if oldcol == ncol - straight forward realloc and * update of the additional lines in sbuf */ /* this is a good idea, but doesn't seem to be implemented. -gildea */ /* * realloc sbuf, the pointers to all the lines. * If the screen shrinks, remove lines off the top of the buffer * if resizeGravity resource says to do so. */ #ifdef KTERM if (nrow < oldrow && term->misc.resizeGravity == SouthWestGravity) { /* Remove lines off the top of the buffer if necessary. */ move_up = oldrow-nrow - (term->screen.max_row - term->screen.cur_row); if (move_up < 0) move_up = 0; /* Overlapping memmove here! */ memmove( *sbuf, *sbuf+move_up, (oldrow-move_up)*sizeof((*sbuf)[0]) ); } *sbuf = (ScrnBuf) realloc((char *) (*sbuf), (unsigned) (nrow * sizeof(Bchr *))); #else /* !KTERM */ nrow *= 2; if (nrow < oldrow && term->misc.resizeGravity == SouthWestGravity) { /* Remove lines off the top of the buffer if necessary. */ move_up = oldrow-nrow - 2*(term->screen.max_row - term->screen.cur_row); if (move_up < 0) move_up = 0; /* Overlapping memmove here! */ memmove( *sbuf, *sbuf+move_up, (oldrow-move_up)*sizeof((*sbuf)[0]) ); } *sbuf = (ScrnBuf) realloc((char *) (*sbuf), (unsigned) (nrow * sizeof(char *))); #endif /* !KTERM */ if (*sbuf == 0) SysError(ERROR_RESIZE); base = *sbuf; /* * create the new buffer space and copy old buffer contents there * line by line. */ #ifdef KTERM if ((tmp = (Bchr *)calloc((unsigned) (nrow * ncol), sizeof(Bchr))) == 0) #else /* !KTERM */ if ((tmp = calloc((unsigned) (nrow * ncol), sizeof(char))) == 0) #endif /* !KTERM */ SysError(ERROR_SREALLOC); #ifdef STATUSLINE nrow--; oldrow--; #endif /* STATUSLINE */ *sbufaddr = tmp; minrows = (oldrow < nrow) ? oldrow : nrow; mincols = (oldcol < ncol) ? oldcol : ncol; #ifdef KTERM mincols *= sizeof(Bchr); #endif /* KTERM */ if (nrow > oldrow && term->misc.resizeGravity == SouthWestGravity) { /* move data down to bottom of expanded screen */ #ifdef KTERM move_down = Min(nrow-oldrow, term->screen.savedlines); #else /* !KTERM */ move_down = Min(nrow-oldrow, 2*term->screen.savedlines); #endif /* !KTERM */ tmp += ncol*move_down; } for (i = 0; i < minrows; i++, tmp += ncol) { memmove( tmp, base[i], mincols); } /* * update the pointers in sbuf */ for (i = 0, tmp = *sbufaddr; i < nrow; i++, tmp += ncol) base[i] = tmp; #ifdef STATUSLINE memmove( tmp, oldstat, mincols); base[nrow] = tmp; # ifndef KTERM tmp += ncol; oldstat += oldcol; memmove( tmp, oldstat, mincols); base[nrow+1] = tmp; # endif /* !KTERM */ #endif /* STATUSLINE */ /* Now free the old buffer */ free(oldbuf); #ifdef KTERM return move_down ? move_down : -move_up; #else /* !KTERM */ return move_down ? move_down/2 : -move_up/2; /* convert to rows */ #endif /* !KTERM */ } #ifdef KTERM ScreenWrite (screen, str, flags, gset, length) #else /* !KTERM */ ScreenWrite (screen, str, flags, length) #endif /* !KTERM */ /* Writes str into buf at row row and column col. Characters are set to match flags. */ TScreen *screen; #ifdef KTERM Char *str; register unsigned flags; register Char gset; #else /* !KTERM */ char *str; register unsigned flags; #endif /* !KTERM */ register int length; /* length of string */ { #ifdef KTERM register int avail = screen->max_col - screen->cur_col + 1; register Bchr *col, *col0; Boolean ontheright = gsetontheright[gset]; #else /* !KTERM */ register Char *attrs, *attrs0; register int avail = screen->max_col - screen->cur_col + 1; register Char *col; #endif /* !KTERM */ register int wrappedbit; if (length > avail) length = avail; if (length <= 0) return; #ifdef KTERM col = col0 = screen->buf[avail = screen->cur_row] + screen->cur_col; wrappedbit = col0->attr&LINEWRAPPED; #else /* !KTERM */ col = screen->buf[avail = 2 * screen->cur_row] + screen->cur_col; attrs = attrs0 = screen->buf[avail + 1] + screen->cur_col; wrappedbit = *attrs0&LINEWRAPPED; #endif /* !KTERM */ flags &= ATTRIBUTES; flags |= CHARDRAWN; #ifdef KTERM # ifdef KTERM_MBCS if (gset & MBCS) { while(length > 0) { col->code = ontheright ? *str++|0x80 : *str++&0x7f; col->gset = gset; col->attr = flags; col++; col->code = ontheright ? *str++|0x80 : *str++&0x7f; col->gset = MBC2; col->attr = flags; col++; length -= 2; } } else # endif /* KTERM_MBCS */ { while(length-- > 0) { col->code = ontheright ? *str++|0x80 : *str++&0x7f; col->gset = gset; col->attr = flags; col++; } } if (wrappedbit) col0->attr |= LINEWRAPPED; #else /* !KTERM */ memmove( col, str, length); while(length-- > 0) *attrs++ = flags; if (wrappedbit) *attrs0 |= LINEWRAPPED; #endif /* !KTERM */ } ScrnInsertLine (sb, last, where, n, size) /* Inserts n blank lines at sb + where, treating last as a bottom margin. Size is the size of each entry in sb. Requires: 0 <= where < where + n <= last n <= MAX_ROWS */ register ScrnBuf sb; int last; register int where, n, size; { register int i; #ifdef KTERM Bchr *savebuf [MAX_ROWS]; Bchr **save; save = n > MAX_ROWS ? (Bchr **)XtMalloc(sizeof(Bchr *) * n) : savebuf; #else /* !KTERM */ char *save [2 * MAX_ROWS]; #endif /* !KTERM */ /* save n lines at bottom */ #ifdef KTERM memmove( (char *) save, (char *) &sb [last -= n - 1], sizeof (Bchr *) * n); #else /* !KTERM */ memmove( (char *) save, (char *) &sb [2 * (last -= n - 1)], 2 * sizeof (char *) * n); #endif /* !KTERM */ /* clear contents of old rows */ #ifdef KTERM for (i = n - 1; i >= 0; i--) bzero ((char *) save [i], size *sizeof(Bchr)); #else /* !KTERM */ for (i = 2 * n - 1; i >= 0; i--) bzero ((char *) save [i], size); #endif /* !KTERM */ /* * WARNING, overlapping copy operation. Move down lines (pointers). * * +----|---------|--------+ * * is copied in the array to: * * +--------|---------|----+ */ #ifdef KTERM memmove( (char *) &sb [where + n], (char *) &sb [where], sizeof (Bchr *) * (last - where)); #else /* !KTERM */ memmove( (char *) &sb [2 * (where + n)], (char *) &sb [2 * where], 2 * sizeof (char *) * (last - where)); #endif /* !KTERM */ /* reuse storage for new lines at where */ #ifdef KTERM memmove( (char *) &sb[where], (char *)save, sizeof(Bchr *) * n); if (save != savebuf) XtFree((char *)save); #else /* !KTERM */ memmove( (char *) &sb[2 * where], (char *)save, 2 * sizeof(char *) * n); #endif /* !KTERM */ } ScrnDeleteLine (sb, last, where, n, size) /* Deletes n lines at sb + where, treating last as a bottom margin. Size is the size of each entry in sb. Requires 0 <= where < where + n < = last n <= MAX_ROWS */ register ScrnBuf sb; register int n, last, size; int where; { register int i; #ifdef KTERM Bchr *savebuf [MAX_ROWS]; Bchr **save; save = n > MAX_ROWS ? (Bchr **)XtMalloc(sizeof(Bchr *) * n) : savebuf; #else /* !KTERM */ char *save [2 * MAX_ROWS]; #endif /* !KTERM */ /* save n lines at where */ #ifdef KTERM memmove( (char *)save, (char *) &sb[where], sizeof(Bchr *) * n); #else /* !KTERM */ memmove( (char *)save, (char *) &sb[2 * where], 2 * sizeof(char *) * n); #endif /* !KTERM */ /* clear contents of old rows */ #ifdef KTERM for (i = n - 1 ; i >= 0 ; i--) bzero ((char *) save [i], size * sizeof(Bchr)); #else /* !KTERM */ for (i = 2 * n - 1 ; i >= 0 ; i--) bzero ((char *) save [i], size); #endif /* !KTERM */ /* move up lines */ #ifdef KTERM memmove( (char *) &sb[where], (char *) &sb[where + n], sizeof (Bchr *) * ((last -= n - 1) - where)); #else /* !KTERM */ memmove( (char *) &sb[2 * where], (char *) &sb[2 * (where + n)], 2 * sizeof (char *) * ((last -= n - 1) - where)); #endif /* !KTERM */ /* reuse storage for new bottom lines */ #ifdef KTERM memmove( (char *) &sb[last], (char *)save, sizeof(Bchr *) * n); if (save != savebuf) XtFree((char *)save); #else /* !KTERM */ memmove( (char *) &sb[2 * last], (char *)save, 2 * sizeof(char *) * n); #endif /* !KTERM */ } ScrnInsertChar (sb, row, col, n, size) /* Inserts n blanks in sb at row, col. Size is the size of each row. */ ScrnBuf sb; int row, size; register int col, n; { register int i, j; #ifdef KTERM register Bchr *ptr = sb [row]; int wrappedbit = ptr[0].attr&LINEWRAPPED; ptr[0].attr &= ~LINEWRAPPED; /* make sure the bit isn't moved */ #else /* !KTERM */ register Char *ptr = sb [2 * row]; register Char *attrs = sb [2 * row + 1]; int wrappedbit = attrs[0]&LINEWRAPPED; attrs[0] &= ~LINEWRAPPED; /* make sure the bit isn't moved */ #endif /* !KTERM */ for (i = size - 1; i >= col + n; i--) { ptr[i] = ptr[j = i - n]; #ifndef KTERM attrs[i] = attrs[j]; #endif /* !KTERM */ } #ifdef KTERM for (i=col; iborder + screen->fnt_norm->ascent; #endif /* !KTERM */ register int row; register int topline = screen->topline; int maxrow = toprow + nrows - 1; int scrollamt = screen->scroll_amt; int max = screen->max_row; #ifdef STATUSLINE if(screen->cursor_col >= leftcol && screen->cursor_col <= (leftcol + ncols - 1) && (screen->cursor_row >= toprow + topline && screen->cursor_row <= maxrow - (maxrow > screen->max_row) + topline || maxrow > screen->max_row && screen->cursor_row > screen->max_row)) screen->cursor_state = OFF; #else /* !STATUSLINE */ if(screen->cursor_col >= leftcol && screen->cursor_col <= (leftcol + ncols - 1) && screen->cursor_row >= toprow + topline && screen->cursor_row <= maxrow + topline) screen->cursor_state = OFF; #endif /* !STATUSLINE */ #ifdef KTERM for (row = toprow; row <= maxrow; row++) { register Bchr *chars; Char gset; #else /* !KTERM */ for (row = toprow; row <= maxrow; y += FontHeight(screen), row++) { register Char *chars; register Char *attrs; #endif /* !KTERM */ register int col = leftcol; int maxcol = leftcol + ncols - 1; int lastind; int flags; #ifndef KTERM int x, n; GC gc; #endif /* !KTERM */ Boolean hilite; #ifdef STATUSLINE if (row > screen->max_row) { /* implies (row > screen->bot_marg) */ int dostatus = 0, left, width; # ifdef KTERM int fnum = F_ISO8859_1; /* *GC */ # endif /* KTERM */ topline = 0; max = screen->max_row + 1; /* statusline buffer */ left = CursorX(screen, leftcol); width = ncols * FontWidth(screen); if (leftcol == 0) { left = screen->scrollbar; width += screen->border; } if (leftcol + ncols - 1 >= screen->max_col) width += screen->border; XFillRectangle(screen->display, TextWindow(screen), screen->reversestatus ? screen->normalGC : screen->reverseGC, left, Height(screen) + screen->border * 2, width, screen->statusheight); if (!screen->reversestatus) StatusBox(screen); } #endif /* STATUSLINE */ if (row < screen->top_marg || row > screen->bot_marg) lastind = row; else lastind = row - scrollamt; if (lastind < 0 || lastind > max) continue; #ifdef KTERM chars = screen->buf [lastind + topline]; #else /* !KTERM */ chars = screen->buf [2 * (lastind + topline)]; attrs = screen->buf [2 * (lastind + topline) + 1]; #endif /* !KTERM */ if (row < screen->startHRow || row > screen->endHRow || (row == screen->startHRow && maxcol < screen->startHCol) || (row == screen->endHRow && col >= screen->endHCol)) { /* row does not intersect selection; don't hilite */ if (!force) { #ifdef KTERM while (col <= maxcol && (chars[col].attr & ~BOLD) == 0 && !(chars[col].gset & CS96) && (chars[col].code & ~040) == 0) #else /* !KTERM */ while (col <= maxcol && (attrs[col] & ~BOLD) == 0 && (chars[col] & ~040) == 0) #endif /* !KTERM */ col++; #ifdef KTERM while (col <= maxcol && (chars[maxcol].attr & ~BOLD) == 0 && !(chars[maxcol].gset & CS96) && (chars[maxcol].code & ~040) == 0) #else /* !KTERM */ while (col <= maxcol && (attrs[maxcol] & ~BOLD) == 0 && (chars[maxcol] & ~040) == 0) #endif /* !KTERM */ maxcol--; } hilite = False; } else { /* row intersects selection; split into pieces of single type */ if (row == screen->startHRow && col < screen->startHCol) { ScrnRefresh(screen, row, col, 1, screen->startHCol - col, force); col = screen->startHCol; } if (row == screen->endHRow && maxcol >= screen->endHCol) { ScrnRefresh(screen, row, screen->endHCol, 1, maxcol - screen->endHCol + 1, force); maxcol = screen->endHCol - 1; } /* remaining piece should be hilited */ hilite = True; } #ifdef KTERM_MBCS if (chars[col].gset == MBC2 && col != 0) col--; if (chars[maxcol].gset & MBCS && chars[maxcol].gset != MBC2) maxcol++; #endif /* KTERM_MBCS */ if (col > maxcol) continue; #ifdef KTERM flags = chars[col].attr; gset = chars[col].gset; #else /* !KTERM */ flags = attrs[col]; # ifdef STATUSLINE if (((!hilite && (flags & INVERSE) != 0) || (hilite && (flags & INVERSE) == 0)) ^ (row > screen->max_row && screen->reversestatus)) # else /* !STATUSLINE */ if ( (!hilite && (flags & INVERSE) != 0) || (hilite && (flags & INVERSE) == 0) ) # endif /* !STATUSLINE */ if (flags & BOLD) gc = screen->reverseboldGC; else gc = screen->reverseGC; else if (flags & BOLD) gc = screen->normalboldGC; else gc = screen->normalGC; x = CursorX(screen, col); #endif /* !KTERM */ lastind = col; for (; col <= maxcol; col++) { #ifdef KTERM if (chars[col].attr != flags || chars[col].gset != gset) { if (hilite) flags ^= INVERSE; ScreenDraw(screen, row + topline, lastind, col, flags, False); #else /* !KTERM */ if (attrs[col] != flags) { XDrawImageString(screen->display, TextWindow(screen), gc, x, y, (char *) &chars[lastind], n = col - lastind); if((flags & BOLD) && screen->enbolden) XDrawString(screen->display, TextWindow(screen), gc, x + 1, y, (char *) &chars[lastind], n); if(flags & UNDERLINE) XDrawLine(screen->display, TextWindow(screen), gc, x, y+1, x+n*FontWidth(screen), y+1); x += (col - lastind) * FontWidth(screen); #endif /* !KTERM */ lastind = col; #ifdef KTERM flags = chars[col].attr; gset = chars[col].gset; } if (gset & MBCS) col++; #else /* !KTERM */ flags = attrs[col]; # ifdef STATUSLINE if (((!hilite && (flags & INVERSE) != 0) || (hilite && (flags & INVERSE) == 0)) ^ (row > screen->max_row && screen->reversestatus)) # else /* !STATUSLINE */ if ((!hilite && (flags & INVERSE) != 0) || (hilite && (flags & INVERSE) == 0) ) # endif /* !STATUSLINE */ if (flags & BOLD) gc = screen->reverseboldGC; else gc = screen->reverseGC; else if (flags & BOLD) gc = screen->normalboldGC; else gc = screen->normalGC; } if(chars[col] == 0) chars[col] = ' '; #endif /* !KTERM */ } #ifdef KTERM if (hilite) flags ^= INVERSE; ScreenDraw(screen, row + topline, lastind, col, flags, False); #else /* !KTERM */ # ifdef STATUSLINE if (((!hilite && (flags & INVERSE) != 0) || (hilite && (flags & INVERSE) == 0)) ^ (row > screen->max_row && screen->reversestatus)) # else /* !STATUSLINE */ if ( (!hilite && (flags & INVERSE) != 0) || (hilite && (flags & INVERSE) == 0) ) # endif /* !STATUSLINE */ if (flags & BOLD) gc = screen->reverseboldGC; else gc = screen->reverseGC; else if (flags & BOLD) gc = screen->normalboldGC; else gc = screen->normalGC; XDrawImageString(screen->display, TextWindow(screen), gc, x, y, (char *) &chars[lastind], n = col - lastind); if((flags & BOLD) && screen->enbolden) XDrawString(screen->display, TextWindow(screen), gc, x + 1, y, (char *) &chars[lastind], n); if(flags & UNDERLINE) XDrawLine(screen->display, TextWindow(screen), gc, x, y+1, x + n * FontWidth(screen), y+1); #endif /* !KTERM */ } } ClearBufRows (screen, first, last) /* Sets the rows first though last of the buffer of screen to spaces. Requires first <= last; first, last are rows of screen->buf. */ register TScreen *screen; register int first, last; { #ifdef KTERM while (first <= last) bzero (screen->buf [first++], (screen->max_col + 1) * sizeof(Bchr)); #else /* !KTERM */ first *= 2; last = 2 * last + 1; while (first <= last) bzero (screen->buf [first++], (screen->max_col + 1)); #endif /* !KTERM */ } /* Resizes screen: 1. If new window would have fractional characters, sets window size so as to discard fractional characters and returns -1. Minimum screen size is 1 X 1. Note that this causes another ExposeWindow event. 2. Enlarges screen->buf if necessary. New space is appended to the bottom and to the right 3. Reduces screen->buf if necessary. Old space is removed from the bottom and from the right 4. Cursor is positioned as closely to its former position as possible 5. Sets screen->max_row and screen->max_col to reflect new size 6. Maintains the inner border (and clears the border on the screen). 7. Clears origin mode and sets scrolling region to be entire screen. 8. Returns 0 */ ScreenResize (screen, width, height, flags) register TScreen *screen; int width, height; unsigned *flags; { int rows, cols; int border = 2 * screen->border; int move_down_by; #if defined(sun) && !defined(SVR4) #ifdef TIOCSSIZE struct ttysize ts; #endif /* TIOCSSIZE */ #else /* sun */ #ifdef TIOCSWINSZ struct winsize ws; #endif /* TIOCSWINSZ */ #endif /* sun */ Window tw = TextWindow (screen); /* clear the right and bottom internal border because of NorthWest gravity might have left junk on the right and bottom edges */ XClearArea (screen->display, tw, width - screen->border, 0, /* right edge */ #ifdef STATUSLINE screen->border, height - screen->statusheight, #else /* !STATUSLINE */ screen->border, height, /* from top to bottom */ #endif /* !STATUSLINE */ False); XClearArea (screen->display, tw, #ifdef STATUSLINE 0, height - screen->border - screen->statusheight, #else /* !STATUSLINE */ 0, height - screen->border, /* bottom */ #endif /* !STATUSLINE */ width, screen->border, /* all across the bottom */ False); /* round so that it is unlikely the screen will change size on */ /* small mouse movements. */ #ifdef STATUSLINE rows = (height + FontHeight(screen) / 2 - border - screen->statusheight) / #else /* !STATUSLINE */ rows = (height + FontHeight(screen) / 2 - border) / #endif /* !STATUSLINE */ FontHeight(screen); cols = (width + FontWidth(screen) / 2 - border - screen->scrollbar) / FontWidth(screen); if (rows < 1) rows = 1; if (cols < 1) cols = 1; #ifdef STATUSLINE if (screen->statusheight && term->misc.resizeGravity == NorthWestGravity) { /* bit_gravity != ForgetGravity */ if (rows > screen->max_row + 1) { XClearArea (screen->display, tw, screen->scrollbar, (screen->max_row + 1) * FontHeight(screen) + screen->border * 2, (screen->max_col + 1) * FontHeight(screen) + screen->border * 2, screen->statusheight, True); } else if (rows < screen->max_row + 1) { XClearArea (screen->display, tw, screen->scrollbar, rows * FontHeight(screen) + screen->border * 2, cols * FontWidth(screen) + screen->border * 2, screen->statusheight, True); } screen->cursor_state = OFF; } #endif /* STATUSLINE */ /* update buffers if the screen has changed size */ if (screen->max_row != rows - 1 || screen->max_col != cols - 1) { register int savelines = screen->scrollWidget ? screen->savelines : 0; int delta_rows = rows - (screen->max_row + 1); if(screen->cursor_state) HideCursor(); if ( screen->alternate && term->misc.resizeGravity == SouthWestGravity ) /* swap buffer pointers back to make all this hair work */ SwitchBufPtrs(screen); if (screen->altbuf) (void) Reallocate(&screen->altbuf, (Char **)&screen->abuf_address, rows, cols, screen->max_row + 1, screen->max_col + 1); move_down_by = Reallocate(&screen->allbuf, (Char **)&screen->sbuf_address, rows + savelines, cols, screen->max_row + 1 + savelines, screen->max_col + 1); #ifdef KTERM screen->buf = &screen->allbuf[savelines]; #else /* !KTERM */ screen->buf = &screen->allbuf[2 * savelines]; #endif /* !KTERM */ screen->max_row += delta_rows; screen->max_col = cols - 1; if (term->misc.resizeGravity == SouthWestGravity) { screen->savedlines -= move_down_by; if (screen->savedlines < 0) screen->savedlines = 0; if (screen->savedlines > screen->savelines) screen->savedlines = screen->savelines; if (screen->topline < -screen->savedlines) screen->topline = -screen->savedlines; screen->cur_row += move_down_by; screen->cursor_row += move_down_by; ScrollSelection(screen, move_down_by); if (screen->alternate) SwitchBufPtrs(screen); /* put the pointers back */ } /* adjust scrolling region */ screen->top_marg = 0; screen->bot_marg = screen->max_row; *flags &= ~ORIGIN; #ifdef STATUSLINE if (screen->instatus) screen->cur_row = screen->max_row + 1; else #endif /* STATUSLINE */ if (screen->cur_row > screen->max_row) screen->cur_row = screen->max_row; if (screen->cur_col > screen->max_col) screen->cur_col = screen->max_col; #ifdef STATUSLINE screen->fullVwin.height = height - border - screen->statusheight; #else /* !STATUSLINE */ screen->fullVwin.height = height - border; #endif /* !STATUSLINE */ screen->fullVwin.width = width - border - screen->scrollbar; } else if(FullHeight(screen) == height && FullWidth(screen) == width) return(0); /* nothing has changed at all */ if(screen->scrollWidget) ResizeScrollBar(screen->scrollWidget, -1, -1, height); screen->fullVwin.fullheight = height; screen->fullVwin.fullwidth = width; ResizeSelection (screen, rows, cols); #if defined(sun) && !defined(SVR4) #ifdef TIOCSSIZE /* Set tty's idea of window size */ ts.ts_lines = rows; ts.ts_cols = cols; ioctl (screen->respond, TIOCSSIZE, &ts); #ifdef SIGWINCH if(screen->pid > 1) { int pgrp; if (ioctl (screen->respond, TIOCGPGRP, &pgrp) != -1) kill_process_group(pgrp, SIGWINCH); } #endif /* SIGWINCH */ #endif /* TIOCSSIZE */ #else /* sun */ #ifdef TIOCSWINSZ /* Set tty's idea of window size */ ws.ws_row = rows; ws.ws_col = cols; ws.ws_xpixel = width; ws.ws_ypixel = height; ioctl (screen->respond, TIOCSWINSZ, (char *)&ws); #ifdef notdef /* change to SIGWINCH if this doesn't work for you */ if(screen->pid > 1) { int pgrp; if (ioctl (screen->respond, TIOCGPGRP, &pgrp) != -1) kill_process_group(pgrp, SIGWINCH); } #endif /* SIGWINCH */ #endif /* TIOCSWINSZ */ #endif /* sun */ #ifdef KTERM_XIM IMSendSize(screen); IMSendSpot(screen); #endif /* KTERM_XIM */ #ifdef KTERM_KINPUT2 Kinput2SendSize(); Kinput2SendSpot(); #endif /* KTERM_KINPUT2 */ return (0); } /* * Sets the attributes from the row, col, to row, col + length according to * mask and value. The bits in the attribute byte specified by the mask are * set to the corresponding bits in the value byte. If length would carry us * over the end of the line, it stops at the end of the line. */ void ScrnSetAttributes(screen, row, col, mask, value, length) TScreen *screen; int row, col; unsigned mask, value; register int length; /* length of string */ { #ifdef KTERM register Bchr *cp; #else /* !KTERM */ register Char *attrs; #endif /* !KTERM */ register int avail = screen->max_col - col + 1; if (length > avail) length = avail; if (length <= 0) return; #ifdef KTERM cp = screen->buf[row] + col; #else /* !KTERM */ attrs = screen->buf[2 * row + 1] + col; #endif /* !KTERM */ value &= mask; /* make sure we only change the bits allowed by mask*/ while(length-- > 0) { #ifdef KTERM cp->attr &= ~mask; /* clear the bits */ cp->attr |= value; /* copy in the new values */ cp++; #else /* !KTERM */ *attrs &= ~mask; /* clear the bits */ *attrs |= value; /* copy in the new values */ attrs++; #endif /* !KTERM */ } } /* * Gets the attributes from the row, col, to row, col + length into the * supplied array, which is assumed to be big enough. If length would carry us * over the end of the line, it stops at the end of the line. Returns * the number of bytes of attributes (<= length) */ int ScrnGetAttributes(screen, row, col, str, length) TScreen *screen; int row, col; Char *str; register int length; /* length of string */ { #ifdef KTERM register Bchr *cp; #else /* !KTERM */ register Char *attrs; #endif /* !KTERM */ register int avail = screen->max_col - col + 1; int ret; if (length > avail) length = avail; if (length <= 0) return 0; ret = length; #ifdef KTERM cp = screen->buf[row] + col; #else /* !KTERM */ attrs = screen->buf[2 * row + 1] + col; #endif /* !KTERM */ while(length-- > 0) { #ifdef KTERM *str++ = cp++->attr; #else /* !KTERM */ *str++ = *attrs++; #endif /* !KTERM */ } return ret; } Bool non_blank_line(sb, row, col, len) ScrnBuf sb; register int row, col, len; { register int i; #ifdef KTERM register Bchr *cp = sb [row]; #else /* !KTERM */ register Char *ptr = sb [2 * row]; #endif /* !KTERM */ for (i = col; i < len; i++) { #ifdef KTERM if (cp[i].code) #else /* !KTERM */ if (ptr[i]) #endif /* !KTERM */ return True; } return False; } #ifdef KTERM ScreenDraw(screen, row, col, endcol, flags, oncursor) TScreen *screen; int row; /* in screen->buf */ int col; int endcol; #ifdef KTERM_COLOR unsigned short flags; #else /* !KTERM_COLOR */ Char flags; #endif /* !KTERM_COLOR */ Boolean oncursor; { GC gc; Boolean hilitecursor = oncursor && (screen->select || screen->always_highlight); Bchr *str; Char gset; int fnum; /* for *GC, and box */ XChar2b drawbuf2[256], *dbuf2 = drawbuf2; char drawbuf[256], *dbuf = drawbuf; int n, c; int x, y; x = CursorX(screen, col); y = CursorY(screen, row); if (row >= screen->top_marg && row <= screen->bot_marg) row -= screen->scroll_amt; str = screen->buf[row]; # ifdef STATUSLINE if (row > screen->max_row && screen->reversestatus) flags ^= INVERSE; # endif /* STATUSLINE */ gset = str[col].gset; fnum = gsettofnum[gset]; # ifdef KTERM_MBCS if (gset & MBCS) { if ((endcol-col+1)/2 > 256) dbuf2 = (XChar2b *)XtMalloc((endcol-col+1)/2 * sizeof(XChar2b)); for (c = col, n = 0; c < endcol; c++, n++) { dbuf2[n].byte1 = str[c++].code; dbuf2[n].byte2 = str[c].code; } } else # endif /* KTERM_MBCS */ { if (endcol-col > 256) dbuf = XtMalloc((endcol-col) * sizeof(char)); if (gset) { for (c = col, n = 0; c < endcol; c++, n++) { dbuf[n] = gsetmaponfont[gset] ? gsetmaponfont[gset][str[c].code] : str[c].code; } } else { for (c = col, n = 0; c < endcol; c++, n++) { dbuf[n] = ' '; } } } if (!(flags & BOLD) && !screen->normalGC) LoadOneFont(screen, True, screen->menu_font_number, fnum, False); else if (flags & BOLD && !screen->normalboldGC) LoadOneFont(screen, True, screen->menu_font_number, fnum, True); if (flags & INVERSE) { if (hilitecursor && screen->reversecursorGC) gc = screen->reversecursorGC; else if (flags & BOLD) gc = screen->reverseboldGC; else gc = screen->reverseGC; } else { if (hilitecursor && screen->cursorGC) gc = screen->cursorGC; else if (flags & BOLD) gc = screen->normalboldGC; else gc = screen->normalGC; } #ifdef KTERM_COLOR if (!hilitecursor && flags & (FORECOLORED|BACKCOLORED)) { XGCValues xgcv; unsigned long f, b; f = flags&FORECOLORED ? screen->textcolor[FORECOLORNUM(flags)] : screen->foreground; b = flags&BACKCOLORED ? screen->textcolor[BACKCOLORNUM(flags)] : term->core.background_pixel; if (flags & INVERSE) { xgcv.foreground = b; xgcv.background = f; } else { xgcv.foreground = f; xgcv.background = b; } XChangeGC(screen->display, gc, GCForeground|GCBackground, &xgcv); } #endif /* KTERM_COLOR */ if (gset == GSET_GRAPH) { int col, X; Pixmap pm; for (col = 0, X = x; col < n; col ++, X += FontWidth(screen)) { if ((pm = screen->graphics[dbuf[col]]) || (pm = screen->graphics[' '])) { XCopyPlane(screen->display, pm, TextWindow(screen), gc, 0, 0, FontWidth(screen), FontHeight(screen), X, y, 1); } } } else { int Y = y + screen->linespace / 2 + screen->max_ascent; #ifdef KTERM_MBCS if (gset & MBCS) { XDrawImageString16(screen->display, TextWindow(screen), gc, x, Y, dbuf2, n); if (flags & BOLD && screen->normalboldGC == screen->normalGC) XDrawString16(screen->display, TextWindow(screen), gc, x + 1, Y, dbuf2, n); } else #endif /* KTERM_MBCS */ { XDrawImageString(screen->display, TextWindow(screen), gc, x, Y, dbuf, n); if (flags & BOLD && screen->normalboldGC == screen->normalGC) XDrawString(screen->display, TextWindow(screen), gc, x + 1, Y, dbuf, n); } if (flags & UNDERLINE) XDrawLine(screen->display, TextWindow(screen), gc, x, Y+1, x + (endcol-col) * FontWidth(screen), Y+1); } if (oncursor && !hilitecursor) { screen->box->x = x; screen->box->y = y + screen->linespace / 2; XDrawLines (screen->display, TextWindow(screen), screen->cursoroutlineGC ? screen->cursoroutlineGC : gc, screen->box, NBOX, CoordModePrevious); } #ifdef KTERM_COLOR if (!hilitecursor && flags & (FORECOLORED|BACKCOLORED)) { XGCValues xgcv; if (flags & INVERSE) { xgcv.foreground = term->core.background_pixel; xgcv.background = screen->foreground; } else { xgcv.foreground = screen->foreground; xgcv.background = term->core.background_pixel; } XChangeGC(screen->display, gc, GCForeground|GCBackground, &xgcv); } #endif /* KTERM_COLOR */ #ifdef KTERM_MBCS if (dbuf2 != drawbuf2) XtFree((char *)dbuf2); #endif /* KTERM_MBCS */ if (dbuf != drawbuf) XtFree(dbuf); } #endif /* KTERM */ kterm-6.2.0.orig/scrollbar.c100444 507 454 36050 6171356063 14467 0ustar yosiakiaux/* * $XConsortium: scrollbar.c /main/45 1996/01/14 16:53:05 kaleb $ * $Id: scrollbar.c,v 6.3 1996/07/12 05:01:34 kagotani Rel $ */ /* * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ #include "ptyx.h" /* gets Xt headers, too */ #include #include #include #include #include #include #include "data.h" #include "error.h" #include "menu.h" /* Event handlers */ static void ScrollTextTo(); static void ScrollTextUpDownBy(); /* resize the text window for a terminal screen, modifying the * appropriate WM_SIZE_HINTS and taking advantage of bit gravity. */ static void ResizeScreen(xw, min_width, min_height ) register XtermWidget xw; int min_width, min_height; { register TScreen *screen = &xw->screen; #ifndef nothack XSizeHints sizehints; long supp; #endif XtGeometryResult geomreqresult; Dimension reqWidth, reqHeight, repWidth, repHeight; /* * I'm going to try to explain, as I understand it, why we * have to do XGetWMNormalHints and XSetWMNormalHints here, * although I can't guarantee that I've got it right. * * In a correctly written toolkit program, the Shell widget * parses the user supplied geometry argument. However, * because of the way xterm does things, the VT100 widget does * the parsing of the geometry option, not the Shell widget. * The result of this is that the Shell widget doesn't set the * correct window manager hints, and doesn't know that the * user has specified a geometry. * * The XtVaSetValues call below tells the Shell widget to * change its hints. However, since it's confused about the * hints to begin with, it doesn't get them all right when it * does the SetValues -- it undoes some of what the VT100 * widget did when it originally set the hints. * * To fix this, we do the following: * * 1. Get the sizehints directly from the window, going around * the (confused) shell widget. * 2. Call XtVaSetValues to let the shell widget know which * hints have changed. Note that this may not even be * necessary, since we're going to right ahead after that * and set the hints ourselves, but it's good to put it * here anyway, so that when we finally do fix the code so * that the Shell does the right thing with hints, we * already have the XtVaSetValues in place. * 3. We set the sizehints directly, this fixing up whatever * damage was done by the Shell widget during the * XtVaSetValues. * * Gross, huh? * * The correct fix is to redo VTRealize, VTInitialize and * VTSetValues so that font processing happens early enough to * give back responsibility for the size hints to the Shell. * * Someday, we hope to have time to do this. Someday, we hope * to have time to completely rewrite xterm. */ # ifdef STATUSLINE min_height += screen->statusheight; # endif /* STATUSLINE */ #ifndef nothack /* * NOTE: If you change the way any of the hints are calculated * below, make sure you change the calculation both in the * sizehints assignments and in the XtVaSetValues. */ if (! XGetWMNormalHints(screen->display, XtWindow(XtParent(xw)), &sizehints, &supp)) sizehints.flags = 0; sizehints.base_width = min_width; sizehints.base_height = min_height; sizehints.width_inc = FontWidth(screen); sizehints.height_inc = FontHeight(screen); sizehints.min_width = sizehints.base_width + sizehints.width_inc; sizehints.min_height = sizehints.base_height + sizehints.height_inc; sizehints.flags |= (PBaseSize|PMinSize|PResizeInc); /* These are obsolete, but old clients may use them */ sizehints.width = (screen->max_col + 1) * FontWidth(screen) + min_width; sizehints.height = (screen->max_row + 1) * FontHeight(screen) + min_height; #endif /* * Note: width and height are not set here because they are * obsolete. */ XtVaSetValues(XtParent(xw), XtNbaseWidth, min_width, XtNbaseHeight, min_height, XtNwidthInc, FontWidth(screen), XtNheightInc, FontHeight(screen), XtNminWidth, min_width + FontWidth(screen), XtNminHeight, min_height + FontHeight(screen), NULL); reqWidth = (screen->max_col + 1) * FontWidth(screen) + min_width; reqHeight = FontHeight(screen) * (screen->max_row + 1) + min_height; geomreqresult = XtMakeResizeRequest ((Widget)xw, reqWidth, reqHeight, &repWidth, &repHeight); if (geomreqresult == XtGeometryAlmost) { geomreqresult = XtMakeResizeRequest ((Widget)xw, repWidth, repHeight, NULL, NULL); } #ifndef nothack XSetWMNormalHints(screen->display, XtWindow(XtParent(xw)), &sizehints); #endif #ifdef KTERM_XIM IMSendSize(screen); IMSendSpot(screen); #endif /* KTERM_XIM */ #ifdef KTERM_KINPUT2 Kinput2SendSize(); Kinput2SendSpot(); #endif /* KTERM_KINPUT2 */ } void DoResizeScreen (xw) register XtermWidget xw; { int border = 2 * xw->screen.border; ResizeScreen (xw, border + xw->screen.scrollbar, border); } static Widget CreateScrollBar(xw, x, y, height) XtermWidget xw; int x, y, height; { Widget scrollWidget; static Arg argList[] = { {XtNx, (XtArgVal) 0}, {XtNy, (XtArgVal) 0}, {XtNheight, (XtArgVal) 0}, {XtNreverseVideo, (XtArgVal) 0}, {XtNorientation, (XtArgVal) XtorientVertical}, {XtNborderWidth, (XtArgVal) 1}, }; argList[0].value = (XtArgVal) x; argList[1].value = (XtArgVal) y; argList[2].value = (XtArgVal) height; argList[3].value = (XtArgVal) xw->misc.re_verse; scrollWidget = XtCreateWidget("scrollbar", scrollbarWidgetClass, (Widget)xw, argList, XtNumber(argList)); XtAddCallback (scrollWidget, XtNscrollProc, ScrollTextUpDownBy, 0); XtAddCallback (scrollWidget, XtNjumpProc, ScrollTextTo, 0); return (scrollWidget); } static void RealizeScrollBar (sbw, screen) Widget sbw; TScreen *screen; { XtRealizeWidget (sbw); } ScrollBarReverseVideo(scrollWidget) register Widget scrollWidget; { Arg args[4]; int nargs = XtNumber(args); unsigned long bg, fg, bdr; Pixmap bdpix; XtSetArg(args[0], XtNbackground, &bg); XtSetArg(args[1], XtNforeground, &fg); XtSetArg(args[2], XtNborderColor, &bdr); XtSetArg(args[3], XtNborderPixmap, &bdpix); XtGetValues (scrollWidget, args, nargs); args[0].value = (XtArgVal) fg; args[1].value = (XtArgVal) bg; nargs--; /* don't set border_pixmap */ if (bdpix == XtUnspecifiedPixmap) { /* if not pixmap then pixel */ args[2].value = args[1].value; /* set border to new fg */ } else { /* ignore since pixmap */ nargs--; /* don't set border pixel */ } XtSetValues (scrollWidget, args, nargs); } ScrollBarDrawThumb(scrollWidget) register Widget scrollWidget; { register TScreen *screen = &term->screen; register int thumbTop, thumbHeight, totalHeight; thumbTop = screen->topline + screen->savedlines; thumbHeight = screen->max_row + 1; totalHeight = thumbHeight + screen->savedlines; XawScrollbarSetThumb(scrollWidget, ((float)thumbTop) / totalHeight, ((float)thumbHeight) / totalHeight); } ResizeScrollBar(scrollWidget, x, y, height) register Widget scrollWidget; int x, y; unsigned height; { XtConfigureWidget(scrollWidget, x, y, scrollWidget->core.width, height, scrollWidget->core.border_width); ScrollBarDrawThumb(scrollWidget); } WindowScroll(screen, top) register TScreen *screen; int top; { register int i, lines; register int scrolltop, scrollheight, refreshtop; register int x = 0; #ifdef KTERM int fnum = F_ISO8859_1; /* refered by normalGC */ #endif /* KTERM */ if (top < -screen->savedlines) top = -screen->savedlines; else if (top > 0) top = 0; if((i = screen->topline - top) == 0) { ScrollBarDrawThumb(screen->scrollWidget); return; } if(screen->cursor_state) HideCursor(); lines = i > 0 ? i : -i; if(lines > screen->max_row + 1) lines = screen->max_row + 1; scrollheight = screen->max_row - lines + 1; if(i > 0) refreshtop = scrolltop = 0; else { scrolltop = lines; refreshtop = scrollheight; } x = screen->scrollbar + screen->border; scrolling_copy_area(screen, scrolltop, scrollheight, -i); screen->topline = top; ScrollSelection(screen, i); XClearArea( screen->display, TextWindow(screen), (int) x, (int) refreshtop * FontHeight(screen) + screen->border, (unsigned) Width(screen), (unsigned) lines * FontHeight(screen), FALSE); ScrnRefresh(screen, refreshtop, 0, lines, screen->max_col + 1, False); ScrollBarDrawThumb(screen->scrollWidget); } ScrollBarOn (xw, init, doalloc) XtermWidget xw; int init, doalloc; { register TScreen *screen = &xw->screen; register int border = 2 * screen->border; register int i; Char *realloc(), *calloc(); if(screen->scrollbar) return; if (init) { /* then create it only */ if (screen->scrollWidget) return; /* make it a dummy size and resize later */ if ((screen->scrollWidget = CreateScrollBar (xw, -1, - 1, 5)) == NULL) { Bell(XkbBI_MinorError,0); return; } return; } if (!screen->scrollWidget) { Bell (XkbBI_MinorError,0); Bell (XkbBI_MinorError,0); return; } if (doalloc && screen->allbuf) { #ifdef KTERM if((screen->allbuf = (ScrnBuf) realloc((char *) screen->buf, (unsigned) (screen->max_row + 2 + screen->savelines) * sizeof(Bchr *))) == NULL) Error (ERROR_SBRALLOC); screen->buf = &screen->allbuf[screen->savelines]; memmove( (char *)screen->buf, (char *)screen->allbuf, (screen->max_row + 2) * sizeof (Bchr *)); for(i = screen->savelines - 1 ; i >= 0 ; i--) { if((screen->allbuf[i] = (Bchr *)calloc((unsigned) screen->max_col + 1, sizeof(Bchr))) == NULL) Error (ERROR_SBRALLOC2); } #else /* !KTERM */ if((screen->allbuf = (ScrnBuf) realloc((char *) screen->buf, (unsigned) 2*(screen->max_row + 2 + screen->savelines) * sizeof(char *))) == NULL) Error (ERROR_SBRALLOC); screen->buf = &screen->allbuf[2 * screen->savelines]; memmove( (char *)screen->buf, (char *)screen->allbuf, 2 * (screen->max_row + 2) * sizeof (char *)); for(i = 2 * screen->savelines - 1 ; i >= 0 ; i--) if((screen->allbuf[i] = calloc((unsigned) screen->max_col + 1, sizeof(char))) == NULL) Error (ERROR_SBRALLOC2); #endif /* !KTERM */ } ResizeScrollBar (screen->scrollWidget, -1, -1, #ifdef STATUSLINE screen->statusheight + #endif /* STATUSLINE */ Height (screen) + border); RealizeScrollBar (screen->scrollWidget, screen); screen->scrollbar = screen->scrollWidget->core.width + screen->scrollWidget->core.border_width; ScrollBarDrawThumb(screen->scrollWidget); DoResizeScreen (xw); XtMapWidget(screen->scrollWidget); update_scrollbar (); if (screen->buf) { XClearWindow (screen->display, XtWindow (term)); Redraw (); } } ScrollBarOff(screen) register TScreen *screen; { if(!screen->scrollbar) return; XtUnmapWidget(screen->scrollWidget); screen->scrollbar = 0; DoResizeScreen (term); update_scrollbar (); if (screen->buf) { XClearWindow (screen->display, XtWindow (term)); Redraw (); } } /*ARGSUSED*/ static void ScrollTextTo(scrollbarWidget, client_data, call_data) Widget scrollbarWidget; XtPointer client_data; XtPointer call_data; { float *topPercent = (float *) call_data; register TScreen *screen = &term->screen; int thumbTop; /* relative to first saved line */ int newTopLine; /* screen->savedlines : Number of offscreen text lines, screen->maxrow + 1 : Number of onscreen text lines, screen->topline : -Number of lines above the last screen->max_row+1 lines */ thumbTop = *topPercent * (screen->savedlines + screen->max_row+1); newTopLine = thumbTop - screen->savedlines; WindowScroll(screen, newTopLine); } /*ARGSUSED*/ static void ScrollTextUpDownBy(scrollbarWidget, client_data, call_data) Widget scrollbarWidget; XtPointer client_data; XtPointer call_data; { int pixels = (int) call_data; register TScreen *screen = &term->screen; register int rowOnScreen, newTopLine; rowOnScreen = pixels / FontHeight(screen); if (rowOnScreen == 0) { if (pixels < 0) rowOnScreen = -1; else if (pixels > 0) rowOnScreen = 1; } newTopLine = screen->topline + rowOnScreen; WindowScroll(screen, newTopLine); } /* * assume that b is lower case and allow plural */ static int specialcmplowerwiths (a, b) char *a, *b; { register char ca, cb; if (!a || !b) return 0; while (1) { ca = *a; cb = *b; if (isascii(ca) && isupper(ca)) { /* lowercasify */ #ifdef _tolower ca = _tolower (ca); #else ca = tolower (ca); #endif } if (ca != cb || ca == '\0') break; /* if not eq else both nul */ a++, b++; } if (cb == '\0' && (ca == '\0' || (ca == 's' && a[1] == '\0'))) return 1; return 0; } static int params_to_pixels (screen, params, n) TScreen *screen; String *params; int n; { register mult = 1; register char *s; switch (n > 2 ? 2 : n) { case 2: s = params[1]; if (specialcmplowerwiths (s, "page")) { mult = (screen->max_row + 1) * FontHeight(screen); } else if (specialcmplowerwiths (s, "halfpage")) { mult = ((screen->max_row + 1) * FontHeight(screen)) >> 1; } else if (specialcmplowerwiths (s, "pixel")) { mult = 1; } /* else assume that it is Line */ mult *= atoi (params[0]); break; case 1: mult = atoi (params[0]) * FontHeight(screen); /* lines */ break; default: mult = screen->scrolllines * FontHeight(screen); break; } return mult; } /*ARGSUSED*/ void HandleScrollForward (gw, event, params, nparams) Widget gw; XEvent *event; String *params; Cardinal *nparams; { XtermWidget w = (XtermWidget) gw; register TScreen *screen = &w->screen; ScrollTextUpDownBy (gw, (XtPointer) NULL, (XtPointer)params_to_pixels (screen, params, (int) *nparams)); return; } /*ARGSUSED*/ void HandleScrollBack (gw, event, params, nparams) Widget gw; XEvent *event; String *params; Cardinal *nparams; { XtermWidget w = (XtermWidget) gw; register TScreen *screen = &w->screen; ScrollTextUpDownBy (gw, (XtPointer) NULL, (XtPointer)-params_to_pixels (screen, params, (int) *nparams)); return; } kterm-6.2.0.orig/tabs.c100444 507 454 4516 5011343263 13405 0ustar yosiakiaux/* * $XConsortium: tabs.c,v 1.4 91/05/06 17:12:18 gildea Exp $ */ /* * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ /* tabs.c */ #include "ptyx.h" /* * This file presumes 32bits/word. This is somewhat of a crock, and should * be fixed sometime. */ /* * places tabstops at only every 8 columns */ TabReset(tabs) Tabs tabs; { register int i; for (i=0; i> 5] |= (1 << (col & 31)); } /* * clears a tabstop at col */ TabClear(tabs, col) Tabs tabs; int col; { tabs[col >> 5] &= ~(1 << (col & 31)); } /* * returns the column of the next tabstop * (or MAX_TABS - 1 if there are no more). * A tabstop at col is ignored. */ TabNext (tabs, col) Tabs tabs; int col; { extern XtermWidget term; register TScreen *screen = &term->screen; if(screen->curses && screen->do_wrap && (term->flags & WRAPAROUND)) { Index(screen, 1); col = screen->cur_col = screen->do_wrap = 0; } for (++col; col> 5] & (1 << (col & 31))) return (col); return (MAX_TABS - 1); } /* * clears all tabs */ TabZonk (tabs) Tabs tabs; { register int i; for (i=0; i static void horizontal_copy_area(); static void vertical_copy_area(); #ifdef KTERM static int fnum = F_ISO8859_1; /* refered by *GC in many functions */ #endif /* KTERM */ /* * These routines are used for the jump scroll feature */ FlushScroll(screen) register TScreen *screen; { register int i; register int shift = -screen->topline; register int bot = screen->max_row - shift; register int refreshtop; register int refreshheight; register int scrolltop; register int scrollheight; if(screen->cursor_state) HideCursor(); if(screen->scroll_amt > 0) { refreshheight = screen->refresh_amt; scrollheight = screen->bot_marg - screen->top_marg - refreshheight + 1; if((refreshtop = screen->bot_marg - refreshheight + 1 + shift) > (i = screen->max_row - screen->scroll_amt + 1)) refreshtop = i; if(screen->scrollWidget && !screen->alternate && screen->top_marg == 0) { scrolltop = 0; if((scrollheight += shift) > i) scrollheight = i; if((i = screen->bot_marg - bot) > 0 && (refreshheight -= i) < screen->scroll_amt) refreshheight = screen->scroll_amt; if((i = screen->savedlines) < screen->savelines) { if((i += screen->scroll_amt) > screen->savelines) i = screen->savelines; screen->savedlines = i; ScrollBarDrawThumb(screen->scrollWidget); } } else { scrolltop = screen->top_marg + shift; if((i = bot - (screen->bot_marg - screen->refresh_amt + screen->scroll_amt)) > 0) { if(bot < screen->bot_marg) refreshheight = screen->scroll_amt + i; } else { scrollheight += i; refreshheight = screen->scroll_amt; if((i = screen->top_marg + screen->scroll_amt - 1 - bot) > 0) { refreshtop += i; refreshheight -= i; } } } } else { refreshheight = -screen->refresh_amt; scrollheight = screen->bot_marg - screen->top_marg - refreshheight + 1; refreshtop = screen->top_marg + shift; scrolltop = refreshtop + refreshheight; if((i = screen->bot_marg - bot) > 0) scrollheight -= i; if((i = screen->top_marg + refreshheight - 1 - bot) > 0) refreshheight -= i; } scrolling_copy_area(screen, scrolltop+screen->scroll_amt, scrollheight, screen->scroll_amt); ScrollSelection(screen, -(screen->scroll_amt)); screen->scroll_amt = 0; screen->refresh_amt = 0; if(refreshheight > 0) { XClearArea ( screen->display, TextWindow(screen), (int) screen->border + screen->scrollbar, (int) refreshtop * FontHeight(screen) + screen->border, (unsigned) Width(screen), (unsigned) refreshheight * FontHeight(screen), FALSE); ScrnRefresh(screen, refreshtop, 0, refreshheight, screen->max_col + 1, False); } } AddToRefresh(screen) register TScreen *screen; { register int amount = screen->refresh_amt; register int row = screen->cur_row; #ifdef STATUSLINE if(amount == 0 || screen->instatus) #else /* !STATUSLINE */ if(amount == 0) #endif /* !STATUSLINE */ return(0); if(amount > 0) { register int bottom; if(row == (bottom = screen->bot_marg) - amount) { screen->refresh_amt++; return(1); } return(row >= bottom - amount + 1 && row <= bottom); } else { register int top; amount = -amount; if(row == (top = screen->top_marg) + amount) { screen->refresh_amt--; return(1); } return(row <= top + amount - 1 && row >= top); } } /* * scrolls the screen by amount lines, erases bottom, doesn't alter * cursor position (i.e. cursor moves down amount relative to text). * All done within the scrolling region, of course. * requires: amount > 0 */ Scroll(screen, amount) register TScreen *screen; register int amount; { register int i = screen->bot_marg - screen->top_marg + 1; register int shift; register int bot; register int refreshtop = 0; register int refreshheight; register int scrolltop; register int scrollheight; if(screen->cursor_state) HideCursor(); if (amount > i) amount = i; if(screen->jumpscroll) { if(screen->scroll_amt > 0) { if(screen->refresh_amt + amount > i) FlushScroll(screen); screen->scroll_amt += amount; screen->refresh_amt += amount; } else { if(screen->scroll_amt < 0) FlushScroll(screen); screen->scroll_amt = amount; screen->refresh_amt = amount; } refreshheight = 0; } else { ScrollSelection(screen, -(amount)); if (amount == i) { ClearScreen(screen); return; } shift = -screen->topline; bot = screen->max_row - shift; scrollheight = i - amount; refreshheight = amount; if((refreshtop = screen->bot_marg - refreshheight + 1 + shift) > (i = screen->max_row - refreshheight + 1)) refreshtop = i; if(screen->scrollWidget && !screen->alternate && screen->top_marg == 0) { scrolltop = 0; if((scrollheight += shift) > i) scrollheight = i; if((i = screen->savedlines) < screen->savelines) { if((i += amount) > screen->savelines) i = screen->savelines; screen->savedlines = i; ScrollBarDrawThumb(screen->scrollWidget); } } else { scrolltop = screen->top_marg + shift; if((i = screen->bot_marg - bot) > 0) { scrollheight -= i; if((i = screen->top_marg + amount - 1 - bot) >= 0) { refreshtop += i; refreshheight -= i; } } } if (screen->multiscroll && amount == 1 && screen->topline == 0 && screen->top_marg == 0 && screen->bot_marg == screen->max_row) { if (screen->incopy < 0 && screen->scrolls == 0) CopyWait(screen); screen->scrolls++; } scrolling_copy_area(screen, scrolltop+amount, scrollheight, amount); if(refreshheight > 0) { XClearArea ( screen->display, TextWindow(screen), (int) screen->border + screen->scrollbar, (int) refreshtop * FontHeight(screen) + screen->border, (unsigned) Width(screen), (unsigned) refreshheight * FontHeight(screen), FALSE); if(refreshheight > shift) refreshheight = shift; } } if(screen->scrollWidget && !screen->alternate && screen->top_marg == 0) ScrnDeleteLine(screen->allbuf, screen->bot_marg + screen->savelines, 0, amount, screen->max_col + 1); else ScrnDeleteLine(screen->buf, screen->bot_marg, screen->top_marg, amount, screen->max_col + 1); if(refreshheight > 0) ScrnRefresh(screen, refreshtop, 0, refreshheight, screen->max_col + 1, False); } /* * Reverse scrolls the screen by amount lines, erases top, doesn't alter * cursor position (i.e. cursor moves up amount relative to text). * All done within the scrolling region, of course. * Requires: amount > 0 */ RevScroll(screen, amount) register TScreen *screen; register int amount; { register int i = screen->bot_marg - screen->top_marg + 1; register int shift; register int bot; register int refreshtop; register int refreshheight; register int scrolltop; register int scrollheight; if(screen->cursor_state) HideCursor(); if (amount > i) amount = i; if(screen->jumpscroll) { if(screen->scroll_amt < 0) { if(-screen->refresh_amt + amount > i) FlushScroll(screen); screen->scroll_amt -= amount; screen->refresh_amt -= amount; } else { if(screen->scroll_amt > 0) FlushScroll(screen); screen->scroll_amt = -amount; screen->refresh_amt = -amount; } } else { shift = -screen->topline; bot = screen->max_row - shift; refreshheight = amount; scrollheight = screen->bot_marg - screen->top_marg - refreshheight + 1; refreshtop = screen->top_marg + shift; scrolltop = refreshtop + refreshheight; if((i = screen->bot_marg - bot) > 0) scrollheight -= i; if((i = screen->top_marg + refreshheight - 1 - bot) > 0) refreshheight -= i; if (screen->multiscroll && amount == 1 && screen->topline == 0 && screen->top_marg == 0 && screen->bot_marg == screen->max_row) { if (screen->incopy < 0 && screen->scrolls == 0) CopyWait(screen); screen->scrolls++; } scrolling_copy_area(screen, scrolltop-amount, scrollheight, -amount); if(refreshheight > 0) XClearArea ( screen->display, TextWindow(screen), (int) screen->border + screen->scrollbar, (int) refreshtop * FontHeight(screen) + screen->border, (unsigned) Width(screen), (unsigned) refreshheight * FontHeight(screen), FALSE); } ScrnInsertLine (screen->buf, screen->bot_marg, screen->top_marg, amount, screen->max_col + 1); } /* * If cursor not in scrolling region, returns. Else, * inserts n blank lines at the cursor's position. Lines above the * bottom margin are lost. */ InsertLine (screen, n) register TScreen *screen; register int n; { register int i; register int shift; register int bot; register int refreshtop; register int refreshheight; register int scrolltop; register int scrollheight; if (screen->cur_row < screen->top_marg || screen->cur_row > screen->bot_marg) return; if(screen->cursor_state) HideCursor(); screen->do_wrap = 0; if (n > (i = screen->bot_marg - screen->cur_row + 1)) n = i; if(screen->jumpscroll) { if(screen->scroll_amt <= 0 && screen->cur_row <= -screen->refresh_amt) { if(-screen->refresh_amt + n > screen->max_row + 1) FlushScroll(screen); screen->scroll_amt -= n; screen->refresh_amt -= n; } else if(screen->scroll_amt) FlushScroll(screen); } if(!screen->scroll_amt) { shift = -screen->topline; bot = screen->max_row - shift; refreshheight = n; scrollheight = screen->bot_marg - screen->cur_row - refreshheight + 1; refreshtop = screen->cur_row + shift; scrolltop = refreshtop + refreshheight; if((i = screen->bot_marg - bot) > 0) scrollheight -= i; if((i = screen->cur_row + refreshheight - 1 - bot) > 0) refreshheight -= i; vertical_copy_area(screen, scrolltop-n, scrollheight, -n); if(refreshheight > 0) XClearArea ( screen->display, TextWindow(screen), (int) screen->border + screen->scrollbar, (int) refreshtop * FontHeight(screen) + screen->border, (unsigned) Width(screen), (unsigned) refreshheight * FontHeight(screen), FALSE); } /* adjust screen->buf */ ScrnInsertLine(screen->buf, screen->bot_marg, screen->cur_row, n, screen->max_col + 1); } /* * If cursor not in scrolling region, returns. Else, deletes n lines * at the cursor's position, lines added at bottom margin are blank. */ DeleteLine(screen, n) register TScreen *screen; register int n; { register int i; register int shift; register int bot; register int refreshtop; register int refreshheight; register int scrolltop; register int scrollheight; if (screen->cur_row < screen->top_marg || screen->cur_row > screen->bot_marg) return; if(screen->cursor_state) HideCursor(); screen->do_wrap = 0; if (n > (i = screen->bot_marg - screen->cur_row + 1)) n = i; if(screen->jumpscroll) { if(screen->scroll_amt >= 0 && screen->cur_row == screen->top_marg) { if(screen->refresh_amt + n > screen->max_row + 1) FlushScroll(screen); screen->scroll_amt += n; screen->refresh_amt += n; } else if(screen->scroll_amt) FlushScroll(screen); } if(!screen->scroll_amt) { shift = -screen->topline; bot = screen->max_row - shift; scrollheight = i - n; refreshheight = n; if((refreshtop = screen->bot_marg - refreshheight + 1 + shift) > (i = screen->max_row - refreshheight + 1)) refreshtop = i; if(screen->scrollWidget && !screen->alternate && screen->cur_row == 0) { scrolltop = 0; if((scrollheight += shift) > i) scrollheight = i; if((i = screen->savedlines) < screen->savelines) { if((i += n) > screen->savelines) i = screen->savelines; screen->savedlines = i; ScrollBarDrawThumb(screen->scrollWidget); } } else { scrolltop = screen->cur_row + shift; if((i = screen->bot_marg - bot) > 0) { scrollheight -= i; if((i = screen->cur_row + n - 1 - bot) >= 0) { refreshheight -= i; } } } vertical_copy_area(screen, scrolltop+n, scrollheight, n); if(refreshheight > 0) XClearArea ( screen->display, TextWindow(screen), (int) screen->border + screen->scrollbar, (int) refreshtop * FontHeight(screen) + screen->border, (unsigned) Width(screen), (unsigned) refreshheight * FontHeight(screen), FALSE); } /* adjust screen->buf */ if(screen->scrollWidget && !screen->alternate && screen->cur_row == 0) ScrnDeleteLine(screen->allbuf, screen->bot_marg + screen->savelines, 0, n, screen->max_col + 1); else ScrnDeleteLine(screen->buf, screen->bot_marg, screen->cur_row, n, screen->max_col + 1); } /* * Insert n blanks at the cursor's position, no wraparound */ InsertChar (screen, n) register TScreen *screen; register int n; { register int cx, cy; if(screen->cursor_state) HideCursor(); screen->do_wrap = 0; #ifdef KTERM_MBCS BreakMBchar(screen); #endif /* KTERM_MBCS */ #ifdef STATUSLINE if(screen->cur_row - screen->topline <= screen->max_row || screen->instatus) { #else /* !STATUSLINE */ if(screen->cur_row - screen->topline <= screen->max_row) { #endif /* !STATUSLINE */ if(!AddToRefresh(screen)) { if(screen->scroll_amt) FlushScroll(screen); /* * prevent InsertChar from shifting the end of a line over * if it is being appended to */ if (non_blank_line (screen->buf, screen->cur_row, screen->cur_col, screen->max_col + 1)) horizontal_copy_area(screen, screen->cur_col, screen->max_col+1 - (screen->cur_col+n), n); cx = CursorX (screen, screen->cur_col); cy = CursorY (screen, screen->cur_row); XFillRectangle( screen->display, TextWindow(screen), #ifdef STATUSLINE screen->instatus && screen->reversestatus ? screen->normalGC : #endif /* STATUSLINE */ screen->reverseGC, cx, cy, (unsigned) n * FontWidth(screen), (unsigned) FontHeight(screen)); } } /* adjust screen->buf */ ScrnInsertChar(screen->buf, screen->cur_row, screen->cur_col, n, screen->max_col + 1); } /* * Deletes n chars at the cursor's position, no wraparound. */ DeleteChar (screen, n) register TScreen *screen; register int n; { register int width; if(screen->cursor_state) HideCursor(); screen->do_wrap = 0; if (n > (width = screen->max_col + 1 - screen->cur_col)) n = width; #ifdef KTERM_MBCS BreakMBchar(screen); screen->cur_col += n; BreakMBchar(screen); screen->cur_col -= n; #endif /* KTERM_MBCS */ #ifdef STATUSLINE if(screen->cur_row - screen->topline <= screen->max_row || screen->instatus) { #else /* !STATUSLINE */ if(screen->cur_row - screen->topline <= screen->max_row) { #endif /* !STATUSLINE */ if(!AddToRefresh(screen)) { if(screen->scroll_amt) FlushScroll(screen); horizontal_copy_area(screen, screen->cur_col+n, screen->max_col+1 - (screen->cur_col+n), -n); XFillRectangle (screen->display, TextWindow(screen), #ifdef STATUSLINE screen->instatus && screen->reversestatus ? screen->normalGC : #endif /* STATUSLINE */ screen->reverseGC, screen->border + screen->scrollbar + Width(screen) - n*FontWidth(screen), CursorY (screen, screen->cur_row), n * FontWidth(screen), FontHeight(screen)); } } /* adjust screen->buf */ ScrnDeleteChar (screen->buf, screen->cur_row, screen->cur_col, n, screen->max_col + 1); } /* * Clear from cursor position to beginning of display, inclusive. */ ClearAbove (screen) register TScreen *screen; { register top, height; if(screen->cursor_state) HideCursor(); if((top = -screen->topline) <= screen->max_row) { if(screen->scroll_amt) FlushScroll(screen); if((height = screen->cur_row + top) > screen->max_row) height = screen->max_row; if((height -= top) > 0) XClearArea(screen->display, TextWindow(screen), screen->border + screen->scrollbar, top * FontHeight(screen) + screen->border, Width(screen), height * FontHeight(screen), FALSE); if(screen->cur_row - screen->topline <= screen->max_row) ClearLeft(screen); } ClearBufRows(screen, 0, screen->cur_row - 1); } /* * Clear from cursor position to end of display, inclusive. */ ClearBelow (screen) register TScreen *screen; { register top; ClearRight(screen); if((top = screen->cur_row - screen->topline) <= screen->max_row) { if(screen->scroll_amt) FlushScroll(screen); if(++top <= screen->max_row) XClearArea(screen->display, TextWindow(screen), screen->border + screen->scrollbar, top * FontHeight(screen) + screen->border, Width(screen), (screen->max_row - top + 1) * FontHeight(screen), FALSE); } ClearBufRows(screen, screen->cur_row + 1, screen->max_row); } /* * Clear last part of cursor's line, inclusive. */ ClearRight (screen) register TScreen *screen; { if(screen->cursor_state) HideCursor(); screen->do_wrap = 0; #ifdef KTERM_MBCS BreakMBchar(screen); #endif /* KTERM_MBCS */ #ifdef STATUSLINE if(screen->cur_row - screen->topline <= screen->max_row || screen->instatus) { #else /* !STATUSLINE */ if(screen->cur_row - screen->topline <= screen->max_row) { #endif /* !STATUSLINE */ if(!AddToRefresh(screen)) { if(screen->scroll_amt) FlushScroll(screen); XFillRectangle(screen->display, TextWindow(screen), #ifdef STATUSLINE screen->instatus && screen->reversestatus ? screen->normalGC : #endif /* STATUSLINE */ screen->reverseGC, CursorX(screen, screen->cur_col), CursorY(screen, screen->cur_row), Width(screen) - screen->cur_col * FontWidth(screen), FontHeight(screen)); } } #ifdef KTERM bzero(screen->buf[screen->cur_row] + screen->cur_col, (screen->max_col - screen->cur_col + 1) * sizeof(Bchr)); /* with the right part cleared, we can't be wrapping */ screen->buf [screen->cur_row] [0].attr &= ~LINEWRAPPED; #else /* !KTERM */ bzero(screen->buf [2 * screen->cur_row] + screen->cur_col, (screen->max_col - screen->cur_col + 1)); bzero(screen->buf [2 * screen->cur_row + 1] + screen->cur_col, (screen->max_col - screen->cur_col + 1)); /* with the right part cleared, we can't be wrapping */ screen->buf [2 * screen->cur_row + 1] [0] &= ~LINEWRAPPED; #endif /* !KTERM */ } /* * Clear first part of cursor's line, inclusive. */ ClearLeft (screen) register TScreen *screen; { int i; #ifdef KTERM Bchr *cp; #else /* !TERM */ Char *cp; #endif /* !TERM */ if(screen->cursor_state) HideCursor(); screen->do_wrap = 0; #ifdef KTERM_MBCS BreakMBchar(screen); #endif /* KTERM_MBCS */ #ifdef STATUSLINE if(screen->cur_row - screen->topline <= screen->max_row || screen->instatus) { #else /* !STATUSLINE */ if(screen->cur_row - screen->topline <= screen->max_row) { #endif /* !STATUSLINE */ if(!AddToRefresh(screen)) { if(screen->scroll_amt) FlushScroll(screen); XFillRectangle (screen->display, TextWindow(screen), #ifdef STATUSLINE screen->instatus && screen->reversestatus ? screen->normalGC : #endif /* STATUSLINE */ screen->reverseGC, screen->border + screen->scrollbar, CursorY (screen, screen->cur_row), (screen->cur_col + 1) * FontWidth(screen), FontHeight(screen)); } } #ifdef KTERM for ( i=0, cp=screen->buf[screen->cur_row]; i < screen->cur_col + 1; i++, cp++) { cp->gset = GSET_ASCII; cp->code = ' '; cp->attr = CHARDRAWN; } #else /* !KTERM */ for ( i=0, cp=screen->buf[2 * screen->cur_row]; i < screen->cur_col + 1; i++, cp++) *cp = ' '; for ( i=0, cp=screen->buf[2 * screen->cur_row + 1]; i < screen->cur_col + 1; i++, cp++) *cp = CHARDRAWN; #endif /* !KTERM */ } /* * Erase the cursor's line. */ ClearLine(screen) register TScreen *screen; { if(screen->cursor_state) HideCursor(); screen->do_wrap = 0; #ifdef STATUSLINE if(screen->cur_row - screen->topline <= screen->max_row || screen->instatus) { #else /* !STATUSLINE */ if(screen->cur_row - screen->topline <= screen->max_row) { #endif /* !STATUSLINE */ if(!AddToRefresh(screen)) { if(screen->scroll_amt) FlushScroll(screen); XFillRectangle (screen->display, TextWindow(screen), #ifdef STATUSLINE screen->instatus && screen->reversestatus ? screen->normalGC : #endif /* STATUSLINE */ screen->reverseGC, screen->border + screen->scrollbar, CursorY (screen, screen->cur_row), Width(screen), FontHeight(screen)); } } #ifdef KTERM bzero (screen->buf[screen->cur_row], (screen->max_col + 1) * sizeof(Bchr)); #else /* !KTERM */ bzero (screen->buf [2 * screen->cur_row], (screen->max_col + 1)); bzero (screen->buf [2 * screen->cur_row + 1], (screen->max_col + 1)); #endif /* !KTERM */ } ClearScreen(screen) register TScreen *screen; { register int top; if(screen->cursor_state) HideCursor(); screen->do_wrap = 0; if((top = -screen->topline) <= screen->max_row) { if(screen->scroll_amt) FlushScroll(screen); #ifdef STATUSLINE if(top == 0 && !screen->statusheight) #else /* !STATUSLINE */ if(top == 0) #endif /* !STATUSLINE */ XClearWindow(screen->display, TextWindow(screen)); else XClearArea(screen->display, TextWindow(screen), screen->border + screen->scrollbar, top * FontHeight(screen) + screen->border, Width(screen), (screen->max_row - top + 1) * FontHeight(screen), FALSE); } ClearBufRows (screen, 0, screen->max_row); } CopyWait(screen) register TScreen *screen; { XEvent reply; XEvent *rep = &reply; while (1) { XWindowEvent (screen->display, VWindow(screen), ExposureMask, &reply); switch (reply.type) { case Expose: HandleExposure (screen, &reply); break; case NoExpose: case GraphicsExpose: if (screen->incopy <= 0) { screen->incopy = 1; if (screen->scrolls > 0) screen->scrolls--; } if (reply.type == GraphicsExpose) HandleExposure (screen, &reply); if ((reply.type == NoExpose) || ((XExposeEvent *)rep)->count == 0) { if (screen->incopy <= 0 && screen->scrolls > 0) screen->scrolls--; if (screen->scrolls == 0) { screen->incopy = 0; return; } screen->incopy = -1; } break; } } } /* * used by vertical_copy_area and and horizontal_copy_area */ static void copy_area(screen, src_x, src_y, width, height, dest_x, dest_y) TScreen *screen; int src_x, src_y; unsigned int width, height; int dest_x, dest_y; { #ifdef KTERM static GC copygc; #endif /* KTERM */ /* wait for previous CopyArea to complete unless multiscroll is enabled and active */ if (screen->incopy && screen->scrolls == 0) CopyWait(screen); screen->incopy = -1; /* save for translating Expose events */ screen->copy_src_x = src_x; screen->copy_src_y = src_y; screen->copy_width = width; screen->copy_height = height; screen->copy_dest_x = dest_x; screen->copy_dest_y = dest_y; #ifdef KTERM if (!copygc) copygc = XtGetGC((Widget)term, 0, NULL); /* graphics_exposures = TRUE */ XCopyArea(screen->display, TextWindow(screen), TextWindow(screen), copygc, src_x, src_y, width, height, dest_x, dest_y); #else /* !KTERM */ XCopyArea(screen->display, TextWindow(screen), TextWindow(screen), screen->normalGC, src_x, src_y, width, height, dest_x, dest_y); #endif /* !KTERM */ } /* * use when inserting or deleting characters on the current line */ static void horizontal_copy_area(screen, firstchar, nchars, amount) TScreen *screen; int firstchar; /* char pos on screen to start copying at */ int nchars; int amount; /* number of characters to move right */ { int src_x = CursorX(screen, firstchar); int src_y = CursorY(screen, screen->cur_row); copy_area(screen, src_x, src_y, (unsigned)nchars*FontWidth(screen), FontHeight(screen), src_x + amount*FontWidth(screen), src_y); } /* * use when inserting or deleting lines from the screen */ static void vertical_copy_area(screen, firstline, nlines, amount) TScreen *screen; int firstline; /* line on screen to start copying at */ int nlines; int amount; /* number of lines to move up (neg=down) */ { if(nlines > 0) { int src_x = screen->border + screen->scrollbar; int src_y = firstline * FontHeight(screen) + screen->border; copy_area(screen, src_x, src_y, (unsigned)Width(screen), nlines*FontHeight(screen), src_x, src_y - amount*FontHeight(screen)); } } /* * use when scrolling the entire screen */ scrolling_copy_area(screen, firstline, nlines, amount) TScreen *screen; int firstline; /* line on screen to start copying at */ int nlines; int amount; /* number of lines to move up (neg=down) */ { if(nlines > 0) { vertical_copy_area(screen, firstline, nlines, amount); } } /* * Handler for Expose events on the VT widget. * Returns 1 iff the area where the cursor was got refreshed. */ HandleExposure (screen, event) register TScreen *screen; register XEvent *event; { register XExposeEvent *reply = (XExposeEvent *)event; /* if not doing CopyArea or if this is a GraphicsExpose, don't translate */ if(!screen->incopy || event->type != Expose) return handle_translated_exposure (screen, reply->x, reply->y, reply->width, reply->height); else { /* compute intersection of area being copied with area being exposed. */ int both_x1 = Max(screen->copy_src_x, reply->x); int both_y1 = Max(screen->copy_src_y, reply->y); int both_x2 = Min(screen->copy_src_x+screen->copy_width, reply->x+reply->width); int both_y2 = Min(screen->copy_src_y+screen->copy_height, reply->y+reply->height); int value = 0; /* was anything copied affected? */ if(both_x2 > both_x1 && both_y2 > both_y1) { /* do the copied area */ value = handle_translated_exposure (screen, reply->x + screen->copy_dest_x - screen->copy_src_x, reply->y + screen->copy_dest_y - screen->copy_src_y, reply->width, reply->height); } /* was anything not copied affected? */ if(reply->x < both_x1 || reply->y < both_y1 || reply->x+reply->width > both_x2 || reply->y+reply->height > both_y2) value = handle_translated_exposure (screen, reply->x, reply->y, reply->width, reply->height); return value; } } /* * Called by the ExposeHandler to do the actual repaint after the coordinates * have been translated to allow for any CopyArea in progress. * The rectangle passed in is pixel coordinates. */ handle_translated_exposure (screen, rect_x, rect_y, rect_width, rect_height) register TScreen *screen; register int rect_x, rect_y; register unsigned int rect_width, rect_height; { register int toprow, leftcol, nrows, ncols; extern Bool waiting_for_initial_map; toprow = (rect_y - screen->border) / FontHeight(screen); if(toprow < 0) toprow = 0; #ifdef STATUSLINE if(toprow > screen->max_row + 1) toprow = screen->max_row + 1; #endif /* STATUSLINE */ leftcol = (rect_x - screen->border - screen->scrollbar) / FontWidth(screen); if(leftcol < 0) leftcol = 0; nrows = (rect_y + rect_height - 1 - screen->border) / FontHeight(screen) - toprow + 1; ncols = (rect_x + rect_width - 1 - screen->border - screen->scrollbar) / FontWidth(screen) - leftcol + 1; toprow -= screen->scrolls; if (toprow < 0) { nrows += toprow; toprow = 0; } if (toprow + nrows - 1 > screen->max_row) #ifdef STATUSLINE nrows = screen->max_row - toprow + 1 + !!screen->statusheight; /* !!statusheight == (statusheight ? 1 : 0) */ #else /* !STATUSLINE */ nrows = screen->max_row - toprow + 1; #endif /* !STATUSLINE */ if (leftcol + ncols - 1 > screen->max_col) ncols = screen->max_col - leftcol + 1; if (nrows > 0 && ncols > 0) { ScrnRefresh (screen, toprow, leftcol, nrows, ncols, False); if (waiting_for_initial_map) { first_map_occurred (); } if (screen->cur_row >= toprow && screen->cur_row < toprow + nrows && screen->cur_col >= leftcol && screen->cur_col < leftcol + ncols) return (1); } return (0); } ReverseVideo (termw) XtermWidget termw; { register TScreen *screen = &termw->screen; GC tmpGC; #ifndef KTERM_NOTEK Window tek = TWindow(screen); #endif /* !KTERM_NOTEK */ unsigned long tmp; #ifdef KTERM int fnum; #endif /* KTERM */ tmp = termw->core.background_pixel; if(screen->cursorcolor == screen->foreground) screen->cursorcolor = tmp; termw->core.background_pixel = screen->foreground; screen->foreground = tmp; tmp = screen->mousecolorback; screen->mousecolorback = screen->mousecolor; screen->mousecolor = tmp; #ifdef KTERM for (fnum=F_ISO8859_1; fnumnormalGC; screen->normalGC = screen->reverseGC; screen->reverseGC = tmpGC; tmpGC = screen->normalboldGC; screen->normalboldGC = screen->reverseboldGC; screen->reverseboldGC = tmpGC; tmpGC = screen->cursorGC; screen->cursorGC = screen->reversecursorGC; screen->reversecursorGC = tmpGC; } #else /* !KTERM */ tmpGC = screen->normalGC; screen->normalGC = screen->reverseGC; screen->reverseGC = tmpGC; tmpGC = screen->normalboldGC; screen->normalboldGC = screen->reverseboldGC; screen->reverseboldGC = tmpGC; # ifndef ENBUG /* * Bug fix by michael * 3 non null lines are inserted. */ tmpGC = screen->cursorGC; screen->cursorGC = screen->reversecursorGC; screen->reversecursorGC = tmpGC; # endif /* !ENBUG */ #endif /* !KTERM */ recolor_cursor (screen->pointer_cursor, screen->mousecolor, screen->mousecolorback); recolor_cursor (screen->arrow, screen->mousecolor, screen->mousecolorback); termw->misc.re_verse = !termw->misc.re_verse; XDefineCursor(screen->display, TextWindow(screen), screen->pointer_cursor); #ifndef KTERM_NOTEK if(tek) XDefineCursor(screen->display, tek, screen->arrow); #endif /* !KTERM_NOTEK */ if(screen->scrollWidget) ScrollBarReverseVideo(screen->scrollWidget); XSetWindowBackground(screen->display, TextWindow(screen), termw->core.background_pixel); #ifndef KTERM_NOTEK if(tek) { TekReverseVideo(screen); } #endif /* !KTERM_NOTEK */ XClearWindow(screen->display, TextWindow(screen)); #ifdef STATUSLINE ScrnRefresh (screen, 0, 0, screen->max_row + 1 + !!screen->statusheight, /* !!statusheight == (statusheight ? 1 : 0) */ #else /* !STATUSLINE */ ScrnRefresh (screen, 0, 0, screen->max_row + 1, #endif /* !STATUSLINE */ screen->max_col + 1, False); #ifndef KTERM_NOTEK if(screen->Tshow) { XClearWindow(screen->display, tek); TekExpose((Widget)NULL, (XEvent *)NULL, (Region)NULL); } #endif /* !KTERM_NOTEK */ update_reversevideo(); #ifdef KTERM_XIM IMSendColor(screen); #endif /* KTERM_XIM */ #ifdef KTERM_KINPUT2 Kinput2SendColor(); #endif /* KTERM_KINPUT2 */ } recolor_cursor (cursor, fg, bg) Cursor cursor; /* X cursor ID to set */ unsigned long fg, bg; /* pixel indexes to look up */ { register TScreen *screen = &term->screen; register Display *dpy = screen->display; XColor colordefs[2]; /* 0 is foreground, 1 is background */ colordefs[0].pixel = fg; colordefs[1].pixel = bg; XQueryColors (dpy, DefaultColormap (dpy, DefaultScreen (dpy)), colordefs, 2); XRecolorCursor (dpy, cursor, colordefs, colordefs+1); return; } #ifdef KTERM_MBCS /* * If the cursor points the second byte of a multi byte character, * replace this character with two blanks. */ BreakMBchar(screen) register TScreen *screen; { register Bchr *ptr; if (screen->cur_col >= 1 && screen->cur_col <= screen->max_col && screen->buf[screen->cur_row][screen->cur_col].gset == MBC2) { #ifdef STATUSLINE if(screen->cur_row - screen->topline <= screen->max_row || screen->instatus) { #else /* !STATUSLINE */ if(screen->cur_row - screen->topline <= screen->max_row) { #endif /* !STATUSLINE */ if(!AddToRefresh(screen)) { if(screen->scroll_amt) FlushScroll(screen); XFillRectangle(screen->display, TextWindow(screen), #ifdef STATUSLINE screen->instatus && screen->reversestatus ? screen->normalGC : #endif /* STATUSLINE */ screen->reverseGC, CursorX(screen, screen->cur_col - 1), CursorY(screen, screen->cur_row), 2 * FontWidth(screen), FontHeight(screen)); } } ptr = screen->buf[screen->cur_row] + screen->cur_col - 1; bzero((char*)ptr, 2 * sizeof(Bchr)); } } #endif /* KTERM_MBCS */ kterm-6.2.0.orig/xim.c100444 507 454 24755 6171356067 13316 0ustar yosiakiaux/* * $Id: xim.c,v 6.0 1996/07/12 05:01:39 kagotani Rel $ */ /* * Copyright (c) 1996 * XXI working group in Japan Unix Society (XXI). * * The X Consortium, and any party obtaining a copy of these files from * the X Consortium, directly or indirectly, is granted, free of charge, a * full and unrestricted irrevocable, world-wide, paid up, royalty-free, * nonexclusive right and license to deal in this software and * documentation files (the "Software"), including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons who receive * copies from any such party to do so. This license includes without * limitation a license to do the foregoing actions under any patents of * the party supplying this software to the X Consortium. */ #include #include #include #include "ptyx.h" #include "menu.h" #include "data.h" extern char ** ParseList(); static void setColor(screen, fg_p, bg_p) TScreen *screen; unsigned long *fg_p; unsigned long *bg_p; { extern XtermWidget term; *fg_p = screen->foreground; *bg_p = term->core.background_pixel; } void IMSendColor(screen) TScreen *screen; { unsigned long fg, bg; XVaNestedList preedit_attr; if (!screen->xic || !(screen->xicstyle & XIMPreeditPosition)) return; setColor(screen, &fg, &bg); preedit_attr = XVaCreateNestedList(0, XNForeground, fg, XNBackground, bg, NULL); XSetICValues(screen->xic, XNPreeditAttributes, preedit_attr, NULL); XFree(preedit_attr); } static void setSpot(screen, spot_p) TScreen *screen; XPoint *spot_p; { spot_p->x = CursorX(screen, screen->cur_col); spot_p->y = CursorY(screen, screen->cur_row) + screen->max_ascent; } void IMSendSpot(screen) TScreen *screen; { XPoint spot; XVaNestedList preedit_attr; if (!screen->xic || !(screen->xicstyle & XIMPreeditPosition)) return; setSpot(screen, &spot); preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL); XSetICValues(screen->xic, XNPreeditAttributes, preedit_attr, NULL); XFree(preedit_attr); } static void setFonts(screen, fontset_p) TScreen *screen; XFontSet *fontset_p; { char **missing_list, *def_string; int missing_count; int i, fnum, len; int fontnum = screen->menu_font_number; char *fn; static char *fontnamelist; static int fontnamelistlen; len = 0; for (fnum = F_ISO8859_1; fnum < FCNT; fnum++) if (fn = screen->_menu_font_names[fnum][fontnum]) len += strlen(fn) + 1; if (fn = screen->menu_font_list[fontnum]) len += strlen(fn) + 1; if (len > fontnamelistlen) { if (fontnamelist) XtFree(fontnamelist); fontnamelist = XtMalloc(fontnamelistlen = len); } fontnamelist[0] = '\0'; for (fnum = F_ISO8859_1; fnum < FCNT; fnum++) if (fn = screen->_menu_font_names[fnum][fontnum]) { strcat(fontnamelist, fn); strcat(fontnamelist, ","); } if (fn = screen->menu_font_list[fontnum]) { strcat(fontnamelist, fn); } *fontset_p = XCreateFontSet(screen->display, fontnamelist, &missing_list, &missing_count, &def_string); for(i = 0; i < missing_count; i++) fprintf(stderr, "Warning: missing font: %s\n", missing_list[i]); XFreeStringList(missing_list); } void IMSendFonts(screen) TScreen *screen; { XFontSet fontset; XVaNestedList preedit_attr; if (!screen->xic || !(screen->xicstyle & XIMPreeditPosition)) return; setFonts(screen, &fontset); if (fontset) { preedit_attr = XVaCreateNestedList(0, XNFontSet, fontset, NULL); XSetICValues(screen->xic, XNPreeditAttributes, preedit_attr, NULL); XFree(preedit_attr); if (screen->xicfontset) XFreeFontSet(screen->display, screen->xicfontset); screen->xicfontset = fontset; } } static void setSize(screen, rect_p) TScreen *screen; XRectangle *rect_p; { rect_p->x = screen->scrollbar; rect_p->y = 0; rect_p->width = FullWidth(screen) - screen->scrollbar; rect_p->height = FullHeight(screen); } void IMSendSize(screen) TScreen *screen; { XRectangle rect; XVaNestedList preedit_attr; if (!screen->xic || !(screen->xicstyle & XIMPreeditPosition)) return; setSize(screen, &rect); preedit_attr = XVaCreateNestedList(0, XNArea, &rect, NULL); XSetICValues(screen->xic, XNPreeditAttributes, preedit_attr, NULL); XFree(preedit_attr); } void SetLocale(localelist) char *localelist; { char **locales; for (locales = ParseList(localelist); *locales; locales++) { if (setlocale(LC_CTYPE, *locales) && XSupportsLocale()) return; } fprintf(stderr, "Couldn't set locale: %s\n", localelist); } static XIMStyle BestStyle(im_styles, style_name) XIMStyles *im_styles; char *style_name; { static XIMStyle OverTheSpot_styles[] = { XIMPreeditPosition | XIMStatusNothing, /* * *** Where can I display the status *** * XIMPreeditPosition | XIMStatusArea, */ 0 }; static XIMStyle Root_styles[] = { XIMPreeditNothing | XIMStatusNothing, XIMPreeditNone | XIMStatusNone, 0 }; XIMStyle *styles; unsigned short i; if (!strcmp(style_name, "OverTheSpot")) { styles = OverTheSpot_styles; } else if (!strcmp(style_name, "Root")) { styles = Root_styles; } else { return 0; } for (; *styles; styles++) for (i = 0; i < im_styles->count_styles; i++) if (*styles == im_styles->supported_styles[i]) return *styles; return 0; } /* ARGSUSED */ static void IMDestroyCallback(im, client_data, call_data) XIM im; XPointer client_data; XPointer call_data; /* unused */ { extern XtermWidget term; TScreen *screen = &term->screen; #ifdef KTERM_DEBUG printf("IMDestroyCallback()\n"); #endif screen->xic = NULL; } /* ARGSUSED */ static void IMInstantiateCallback(display, client_data, call_data) Display *display; XPointer client_data; /* unused */ XPointer call_data; /* unused */ { extern XtermWidget term; TScreen *screen = &term->screen; char **types; XIM im = NULL; XIMCallback ximcallback; XIMStyles *im_styles; XIMStyle best_style = 0; XPoint spot; XRectangle rect; XFontSet fontset; unsigned long fg, bg; XVaNestedList preedit_attr = NULL; #ifdef KTERM_DEBUG printf("IMInstantiateCallback()\n"); #endif if (screen->xic) return; im = XOpenIM(display, NULL, NULL, NULL); if (!im) return; ximcallback.callback = IMDestroyCallback; ximcallback.client_data = NULL; XSetIMValues(im, XNDestroyCallback, &ximcallback, NULL); XGetIMValues(im, XNQueryInputStyle, &im_styles, NULL); #ifdef KTERM_DEBUG { int i; printf("IM supported styles =\n"); for (i = 0; i < im_styles->count_styles; i++) { printf(" "); if(im_styles->supported_styles[i] & XIMPreeditArea) printf("XIMPreeditArea"); else if(im_styles->supported_styles[i] & XIMPreeditCallbacks) printf("XIMPreeditCallbacks"); else if(im_styles->supported_styles[i] & XIMPreeditPosition) printf("XIMPreeditPosition"); else if(im_styles->supported_styles[i] & XIMPreeditNothing) printf("XIMPreeditNothing"); else if(im_styles->supported_styles[i] & XIMPreeditNone) printf("XIMPreeditNone"); printf(" | "); if(im_styles->supported_styles[i] & XIMStatusArea) printf("XIMStatusArea"); else if(im_styles->supported_styles[i] & XIMStatusCallbacks) printf("XIMStatusCallbacks"); else if(im_styles->supported_styles[i] & XIMStatusNothing) printf("XIMStatusNothing"); else if(im_styles->supported_styles[i] & XIMStatusNone) printf("XIMStatusNone"); printf("\n"); } } #endif for (types = ParseList(term->misc.preedit_type); *types; types++) { best_style = BestStyle(im_styles, *types); if (best_style) break; } XFree(im_styles); if (!best_style) { fprintf(stderr, "input method doesn't support my preedit type: %s\n", term->misc.preedit_type); XCloseIM(im); return; } if (best_style & XIMPreeditPosition) { setSize(screen, &rect); setSpot(screen, &spot); setFonts(screen, &fontset); setColor(screen, &fg, &bg); preedit_attr = XVaCreateNestedList(0, XNArea, &rect, XNSpotLocation, &spot, XNFontSet, fontset, XNForeground, fg, XNBackground, bg, XNLineSpace, FontHeight(screen), NULL); } screen->xic = XCreateIC(im, XNInputStyle, best_style, XNClientWindow, XtWindow(term), XNFocusWindow, XtWindow(term), preedit_attr ? XNPreeditAttributes : NULL, preedit_attr, NULL); XFree(preedit_attr); if (!screen->xic) { fprintf(stderr, "Couldn't create input context.\n"); XCloseIM(im); } screen->xicstyle = best_style; if (preedit_attr) screen->xicfontset = fontset; } void CloseIM(screen) TScreen *screen; { extern XtermWidget term; /* for update_openim() */ char *p; char **mp; if (!screen->imregistered) return; #ifdef KTERM_DEBUG { Bool ret; ret = #endif XUnregisterIMInstantiateCallback(screen->display, NULL, NULL, NULL, IMInstantiateCallback, NULL); #ifdef KTERM_DEBUG if (ret) printf("Unregister succeeded.\n"); else printf("Unregister failed.\n"); } #endif screen->imregistered = False; if (screen->xic) { XCloseIM(XIMOfIC(screen->xic)); screen->xic = NULL; } update_openim(); } /* ARGSUSED */ void HandleCloseIM(gw, event, params, nparams) Widget gw; XEvent *event; String *params; Cardinal *nparams; { XtermWidget w = (XtermWidget) gw; TScreen *screen = &w->screen; CloseIM(screen); } static char * methodtomodifier(method) char *method; { char *mod; if (!strcmp(method, "XMODIFIERS")) { mod = XtMalloc(1); *mod = '\0'; /* "" */ } else { mod = XtMalloc(strlen(method) + 5); strcpy(mod, "@im="); strcat(mod, method); } return mod; } void SetLocaleModifiers(params, nparams) String *params; /* array of comma-separated strings */ Cardinal nparams; /* number of the strings */ { char *p; char *mod; if (nparams) { mod = methodtomodifier(params[0]); /* "@im=..." */ } else { mod = methodtomodifier("XMODIFIERS"); /* "" */ } p = XSetLocaleModifiers(mod); #ifdef KTERM_DEBUG printf("XSetLocaleModifiers(\"%s\") = \"%s\"\n", mod, p); #endif XtFree(mod); if (!p) { fprintf(stderr, "Couldn't set locale modifiers: %s\n", mod); return; } } void OpenIM(screen) TScreen *screen; { extern XtermWidget term; /* for update_openim() */ #ifdef KTERM_KINPUT2 extern Boolean Kinput2UnderConversion(); if (Kinput2UnderConversion()) { Bell(XkbBI_MinorError,0); return; } #endif /* KTERM_KINPUT2 */ XRegisterIMInstantiateCallback(screen->display, NULL, NULL, NULL, IMInstantiateCallback, NULL); screen->imregistered = True; update_openim(); } /* ARGSUSED */ void HandleOpenIM(gw, event, params, nparams) Widget gw; XEvent *event; /* unused */ String *params; Cardinal *nparams; { TScreen *screen = &((XtermWidget)gw)->screen; CloseIM(screen); if (*nparams) { SetLocaleModifiers(params, *nparams); } OpenIM(screen); }