2012-04-14 03:02:46 -06:00
|
|
|
/* $XTermId: Tekproc.c,v 1.191 2011/12/27 10:19:51 tom Exp $ */
|
2006-11-26 04:11:12 -07:00
|
|
|
|
|
|
|
/*
|
2011-03-07 13:41:27 -07:00
|
|
|
* Copyright 2001-2010,2011 by Thomas E. Dickey
|
2010-08-22 07:38:11 -06:00
|
|
|
*
|
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* 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 ABOVE LISTED COPYRIGHT HOLDER(S) 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(s) of the above copyright
|
|
|
|
* holders shall not be used in advertising or otherwise to promote the
|
|
|
|
* sale, use or other dealings in this Software without prior written
|
|
|
|
* authorization.
|
|
|
|
*
|
|
|
|
* Copyright 1988 The Open Group
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
* documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
* the above copyright notice appear in all copies and that both that
|
|
|
|
* copyright notice and this permission notice appear in supporting
|
|
|
|
* documentation.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* OPEN GROUP 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 Open Group 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 Open Group.
|
|
|
|
*
|
2006-11-26 04:11:12 -07:00
|
|
|
* 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 */
|
|
|
|
|
|
|
|
#define RES_OFFSET(field) XtOffsetOf(TekWidgetRec, field)
|
|
|
|
|
|
|
|
#include <xterm.h>
|
|
|
|
|
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <X11/cursorfont.h>
|
|
|
|
#include <X11/Xmu/CharSet.h>
|
|
|
|
|
|
|
|
#if OPT_TOOLBAR
|
|
|
|
|
|
|
|
#if defined(HAVE_LIB_XAW)
|
|
|
|
#include <X11/Xaw/Form.h>
|
|
|
|
#elif defined(HAVE_LIB_XAW3D)
|
|
|
|
#include <X11/Xaw3d/Form.h>
|
|
|
|
#elif defined(HAVE_LIB_NEXTAW)
|
|
|
|
#include <X11/neXtaw/Form.h>
|
|
|
|
#elif defined(HAVE_LIB_XAWPLUS)
|
|
|
|
#include <X11/XawPlus/Form.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* OPT_TOOLBAR */
|
|
|
|
|
2010-08-22 07:38:11 -06:00
|
|
|
#include <assert.h>
|
2006-11-26 04:11:12 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <signal.h>
|
|
|
|
|
|
|
|
#include <Tekparse.h>
|
|
|
|
#include <data.h>
|
|
|
|
#include <error.h>
|
|
|
|
#include <menu.h>
|
2010-10-23 13:14:52 -06:00
|
|
|
#include <xstrings.h>
|
2006-11-26 04:11:12 -07:00
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
#define DefaultGCID XGContextFromGC(DefaultGC(XtDisplay(tw), DefaultScreen(XtDisplay(tw))))
|
2006-11-26 04:11:12 -07:00
|
|
|
|
|
|
|
/* Tek defines */
|
|
|
|
|
|
|
|
#define DOTDASHEDLINE 2
|
|
|
|
#define DOTTEDLINE 1
|
|
|
|
#define EAST 01
|
|
|
|
#define LINEMASK 07
|
|
|
|
#define LONGDASHEDLINE 4
|
|
|
|
#define MARGIN1 0
|
|
|
|
#define MARGIN2 1
|
|
|
|
#define MAX_PTS 150
|
|
|
|
#define MAX_VTX 300
|
|
|
|
#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
|
2007-06-15 13:34:50 -06:00
|
|
|
#define TEKHOME ( (TekChar[tekscr->page.fontsize].nlines - 1) \
|
|
|
|
* TekChar[tekscr->page.fontsize].vsize)
|
2006-11-26 04:11:12 -07:00
|
|
|
#define TEKMINHEIGHT 452
|
|
|
|
#define TEKMINWIDTH 600
|
|
|
|
#define TEKTOPPAD 34
|
|
|
|
#define TEKWIDTH 4096
|
|
|
|
#define WEST 02
|
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
#define TekMove(tw,x,y) tekscr->cur_X = x; tekscr->cur_Y = y
|
|
|
|
#define input() Tinput(tw)
|
2009-03-09 16:13:04 -06:00
|
|
|
#define unput(c) *Tpushback++ = (Char) c
|
2006-11-26 04:11:12 -07:00
|
|
|
/* *INDENT-OFF* */
|
|
|
|
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 */
|
|
|
|
};
|
|
|
|
/* *INDENT-ON* */
|
|
|
|
|
|
|
|
static Cursor GINcursor;
|
|
|
|
static XSegment *line_pt;
|
|
|
|
static int nplot;
|
|
|
|
static TekLink Tek0;
|
|
|
|
static jmp_buf Tekjump;
|
|
|
|
static TekLink *TekRecord;
|
|
|
|
static XSegment *Tline;
|
|
|
|
|
|
|
|
static Const int *curstate = Talptable;
|
|
|
|
static Const int *Tparsestate = Talptable;
|
|
|
|
|
|
|
|
static char defaultTranslations[] = "\
|
|
|
|
~Meta<KeyPress>: insert-seven-bit() \n\
|
|
|
|
Meta<KeyPress>: insert-eight-bit() \n\
|
|
|
|
!Ctrl <Btn1Down>: popup-menu(mainMenu) \n\
|
|
|
|
!Lock Ctrl <Btn1Down>: popup-menu(mainMenu) \n\
|
|
|
|
!Lock Ctrl @Num_Lock <Btn1Down>: popup-menu(mainMenu) \n\
|
|
|
|
!Ctrl @Num_Lock <Btn1Down>: popup-menu(mainMenu) \n\
|
|
|
|
!Ctrl <Btn2Down>: popup-menu(tekMenu) \n\
|
|
|
|
!Lock Ctrl <Btn2Down>: popup-menu(tekMenu) \n\
|
|
|
|
!Lock Ctrl @Num_Lock <Btn2Down>: popup-menu(tekMenu) \n\
|
|
|
|
!Ctrl @Num_Lock <Btn2Down>: popup-menu(tekMenu) \n\
|
|
|
|
Shift ~Meta<Btn1Down>: gin-press(L) \n\
|
|
|
|
~Meta<Btn1Down>: gin-press(l) \n\
|
|
|
|
Shift ~Meta<Btn2Down>: gin-press(M) \n\
|
|
|
|
~Meta<Btn2Down>: gin-press(m) \n\
|
|
|
|
Shift ~Meta<Btn3Down>: gin-press(R) \n\
|
|
|
|
~Meta<Btn3Down>: gin-press(r)";
|
|
|
|
/* *INDENT-OFF* */
|
|
|
|
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 },
|
|
|
|
#if OPT_TOOLBAR
|
|
|
|
{ "set-toolbar", HandleToolbar },
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
/* *INDENT-ON* */
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
#ifdef VMS
|
|
|
|
#define DFT_FONT_SMALL "FIXED"
|
|
|
|
#else
|
|
|
|
#define DFT_FONT_SMALL "6x10"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
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},
|
|
|
|
Fres("fontLarge", XtCFont, tek.Tfont[TEK_FONT_LARGE], "9x15"),
|
|
|
|
Fres("font2", XtCFont, tek.Tfont[TEK_FONT_2], "6x13"),
|
|
|
|
Fres("font3", XtCFont, tek.Tfont[TEK_FONT_3], "8x13"),
|
|
|
|
Fres("fontSmall", XtCFont, tek.Tfont[TEK_FONT_SMALL], DFT_FONT_SMALL),
|
2007-06-15 13:34:50 -06:00
|
|
|
Sres(XtNinitialFont, XtCInitialFont, tek.initial_font, "large"),
|
2006-11-26 04:11:12 -07:00
|
|
|
Sres("ginTerminator", "GinTerminator", tek.gin_terminator_str, GIN_TERM_NONE_STR),
|
|
|
|
#if OPT_TOOLBAR
|
|
|
|
Wres(XtNmenuBar, XtCMenuBar, tek.tb_info.menu_bar, 0),
|
|
|
|
Ires(XtNmenuHeight, XtCMenuHeight, tek.tb_info.menu_height, 25),
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
static IChar Tinput(TekWidget /* tw */ );
|
|
|
|
static int getpoint(TekWidget /* tw */ );
|
|
|
|
static void TCursorBack(TekWidget /* tw */ );
|
|
|
|
static void TCursorDown(TekWidget /* tw */ );
|
|
|
|
static void TCursorForward(TekWidget /* tw */ );
|
|
|
|
static void TCursorUp(TekWidget /* tw */ );
|
|
|
|
static void TekBackground(TekWidget /* tw */ ,
|
|
|
|
TScreen * /* screen */ );
|
|
|
|
static void TekConfigure(Widget /* w */ );
|
|
|
|
static void TekDraw(TekWidget /* tw */ ,
|
|
|
|
int /* x */ ,
|
|
|
|
int /* y */ );
|
|
|
|
static void TekEnq(TekWidget /* tw */ ,
|
|
|
|
unsigned /* status */ ,
|
|
|
|
int /* x */ ,
|
|
|
|
int /* y */ );
|
|
|
|
static void TekFlush(TekWidget /* tw */ );
|
|
|
|
static void TekInitialize(Widget /* request */ ,
|
|
|
|
Widget /* wnew */ ,
|
|
|
|
ArgList /* args */ ,
|
|
|
|
Cardinal * /* num_args */ );
|
|
|
|
static void TekPage(TekWidget /* tw */ );
|
|
|
|
static void TekRealize(Widget /* gw */ ,
|
|
|
|
XtValueMask * /* valuemaskp */ ,
|
|
|
|
XSetWindowAttributes * /* values */ );
|
2006-11-26 04:11:12 -07:00
|
|
|
|
|
|
|
static WidgetClassRec tekClassRec =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* core_class fields */
|
|
|
|
(WidgetClass) & widgetClassRec, /* superclass */
|
|
|
|
"Tek4014", /* class_name */
|
|
|
|
sizeof(TekWidgetRec), /* widget_size */
|
|
|
|
NULL, /* class_initialize */
|
|
|
|
NULL, /* class_part_initialize */
|
|
|
|
False, /* class_inited */
|
|
|
|
TekInitialize, /* initialize */
|
|
|
|
NULL, /* initialize_hook */
|
|
|
|
TekRealize, /* realize */
|
|
|
|
actionsList, /* actions */
|
|
|
|
XtNumber(actionsList), /* num_actions */
|
|
|
|
resources, /* resources */
|
|
|
|
XtNumber(resources), /* num_resources */
|
|
|
|
NULLQUARK, /* xrm_class */
|
|
|
|
True, /* compress_motion */
|
|
|
|
True, /* compress_exposure */
|
|
|
|
True, /* compress_enterleave */
|
|
|
|
False, /* visible_interest */
|
|
|
|
NULL, /* destroy */
|
|
|
|
TekConfigure, /* resize */
|
|
|
|
TekExpose, /* expose */
|
|
|
|
NULL, /* set_values */
|
|
|
|
NULL, /* set_values_hook */
|
|
|
|
XtInheritSetValuesAlmost, /* set_values_almost */
|
|
|
|
NULL, /* get_values_hook */
|
|
|
|
NULL, /* accept_focus */
|
|
|
|
XtVersion, /* version */
|
|
|
|
NULL, /* callback_offsets */
|
|
|
|
defaultTranslations, /* tm_table */
|
|
|
|
XtInheritQueryGeometry, /* query_geometry */
|
|
|
|
XtInheritDisplayAccelerator, /* display_accelerator */
|
|
|
|
NULL /* extension */
|
|
|
|
}
|
|
|
|
};
|
2007-06-15 13:34:50 -06:00
|
|
|
WidgetClass tekWidgetClass = (WidgetClass) & tekClassRec;
|
2006-11-26 04:11:12 -07:00
|
|
|
|
|
|
|
static Bool Tfailed = False;
|
|
|
|
|
|
|
|
int
|
|
|
|
TekInit(void)
|
|
|
|
{
|
|
|
|
Widget form_top, menu_top;
|
|
|
|
Dimension menu_high;
|
|
|
|
|
|
|
|
if (!Tfailed
|
|
|
|
&& tekWidget == 0) {
|
2007-06-15 13:34:50 -06:00
|
|
|
Cardinal nargs = 0;
|
|
|
|
Arg myArgs[3];
|
|
|
|
Boolean iconic = 0;
|
2006-11-26 04:11:12 -07:00
|
|
|
|
|
|
|
TRACE(("TekInit\n"));
|
2007-06-15 13:34:50 -06:00
|
|
|
XtSetArg(myArgs[nargs], XtNiconic, &iconic);
|
|
|
|
++nargs;
|
|
|
|
XtGetValues(toplevel, myArgs, nargs);
|
|
|
|
|
|
|
|
nargs = 0;
|
|
|
|
XtSetArg(myArgs[nargs], XtNiconic, iconic);
|
|
|
|
++nargs;
|
|
|
|
XtSetArg(myArgs[nargs], XtNallowShellResize, True);
|
|
|
|
++nargs;
|
|
|
|
XtSetArg(myArgs[nargs], XtNinput, True);
|
|
|
|
++nargs;
|
|
|
|
|
2006-11-26 04:11:12 -07:00
|
|
|
/* this causes the Initialize method to be called */
|
|
|
|
tekshellwidget =
|
|
|
|
XtCreatePopupShell("tektronix", topLevelShellWidgetClass,
|
2007-06-15 13:34:50 -06:00
|
|
|
toplevel, myArgs, nargs);
|
2006-11-26 04:11:12 -07:00
|
|
|
|
|
|
|
SetupMenus(tekshellwidget, &form_top, &menu_top, &menu_high);
|
|
|
|
|
|
|
|
/* this causes the Realize method to be called */
|
|
|
|
tekWidget = (TekWidget)
|
|
|
|
XtVaCreateManagedWidget("tek4014",
|
|
|
|
tekWidgetClass, form_top,
|
|
|
|
#if OPT_TOOLBAR
|
|
|
|
XtNmenuBar, menu_top,
|
|
|
|
XtNresizable, True,
|
|
|
|
XtNfromVert, menu_top,
|
|
|
|
XtNtop, XawChainTop,
|
|
|
|
XtNleft, XawChainLeft,
|
|
|
|
XtNright, XawChainRight,
|
|
|
|
XtNbottom, XawChainBottom,
|
|
|
|
XtNmenuHeight, menu_high,
|
|
|
|
#endif
|
|
|
|
(XtPointer) 0);
|
|
|
|
#if OPT_TOOLBAR
|
|
|
|
ShowToolbar(resource.toolBar);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return (!Tfailed);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we haven't allocated the PtyData struct, do so.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
TekPtyData(void)
|
|
|
|
{
|
|
|
|
if (Tpushb == 0) {
|
|
|
|
if ((Tpushb = TypeMallocN(Char, 10)) == NULL
|
|
|
|
|| (Tline = TypeMallocN(XSegment, MAX_VTX)) == NULL) {
|
2012-04-14 03:02:46 -06:00
|
|
|
xtermWarning("Not enough core for Tek mode\n");
|
2006-11-26 04:11:12 -07:00
|
|
|
if (Tpushb)
|
|
|
|
free(Tpushb);
|
|
|
|
Tfailed = True;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-06-15 13:34:50 -06:00
|
|
|
Tekparse(TekWidget tw)
|
2006-11-26 04:11:12 -07:00
|
|
|
{
|
2010-08-22 07:38:11 -06:00
|
|
|
XtermWidget xw = term;
|
|
|
|
TScreen *screen = TScreenOf(xw);
|
2007-06-15 13:34:50 -06:00
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
int x, y;
|
|
|
|
IChar c = 0;
|
|
|
|
IChar ch;
|
|
|
|
int nextstate;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
c = input();
|
|
|
|
/*
|
|
|
|
* The parsing tables all have 256 entries. If we're supporting
|
|
|
|
* wide characters, we handle them by treating them the same as
|
|
|
|
* printing characters.
|
|
|
|
*/
|
|
|
|
#if OPT_WIDE_CHARS
|
|
|
|
if (c > 255) {
|
|
|
|
nextstate = (Tparsestate == Talptable)
|
|
|
|
? CASE_PRINT
|
|
|
|
: CASE_IGNORE;
|
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
nextstate = Tparsestate[c];
|
|
|
|
TRACE(("Tekparse %04X -> %d\n", c, nextstate));
|
|
|
|
|
|
|
|
switch (nextstate) {
|
|
|
|
case CASE_REPORT:
|
|
|
|
TRACE(("case: report address\n"));
|
2007-06-15 13:34:50 -06:00
|
|
|
if (tekscr->TekGIN) {
|
|
|
|
TekGINoff(tw);
|
|
|
|
TekEnqMouse(tw, 0);
|
2006-11-26 04:11:12 -07:00
|
|
|
} else {
|
|
|
|
c = 064; /* has hard copy unit */
|
2007-06-15 13:34:50 -06:00
|
|
|
if (tekscr->margin == MARGIN2)
|
2006-11-26 04:11:12 -07:00
|
|
|
c |= 02;
|
2007-06-15 13:34:50 -06:00
|
|
|
TekEnq(tw, c, tekscr->cur_X, tekscr->cur_Y);
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
2007-06-15 13:34:50 -06:00
|
|
|
TekRecord->ptr[-1] = ANSI_NAK; /* remove from recording */
|
2006-11-26 04:11:12 -07:00
|
|
|
Tparsestate = curstate;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_VT_MODE:
|
|
|
|
TRACE(("case: special return to vt102 mode\n"));
|
|
|
|
Tparsestate = curstate;
|
2007-06-15 13:34:50 -06:00
|
|
|
TekRecord->ptr[-1] = ANSI_NAK; /* remove from recording */
|
2010-08-22 07:38:11 -06:00
|
|
|
FlushLog(xw);
|
2006-11-26 04:11:12 -07:00
|
|
|
return;
|
|
|
|
|
|
|
|
case CASE_SPT_STATE:
|
|
|
|
TRACE(("case: Enter Special Point Plot mode\n"));
|
2007-06-15 13:34:50 -06:00
|
|
|
if (tekscr->TekGIN)
|
|
|
|
TekGINoff(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
Tparsestate = curstate = Tspttable;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_GIN:
|
|
|
|
TRACE(("case: Do Tek GIN mode\n"));
|
2007-06-15 13:34:50 -06:00
|
|
|
tekscr->TekGIN = &TekRecord->ptr[-1];
|
2006-11-26 04:11:12 -07:00
|
|
|
/* Set cross-hair cursor raster array */
|
|
|
|
if ((GINcursor =
|
|
|
|
make_colored_cursor(XC_tcross,
|
|
|
|
T_COLOR(screen, MOUSE_FG),
|
|
|
|
T_COLOR(screen, MOUSE_BG))) != 0) {
|
2007-06-15 13:34:50 -06:00
|
|
|
XDefineCursor(XtDisplay(tw), TWindow(tekscr),
|
2006-11-26 04:11:12 -07:00
|
|
|
GINcursor);
|
|
|
|
}
|
|
|
|
Tparsestate = Tbyptable; /* Bypass mode */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_BEL:
|
|
|
|
TRACE(("case: BEL\n"));
|
2007-06-15 13:34:50 -06:00
|
|
|
if (tekscr->TekGIN)
|
|
|
|
TekGINoff(tw);
|
|
|
|
if (!tekRefreshList)
|
2010-08-22 07:38:11 -06:00
|
|
|
Bell(xw, XkbBI_TerminalBell, 0);
|
2006-11-26 04:11:12 -07:00
|
|
|
Tparsestate = curstate; /* clear bypass condition */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_BS:
|
|
|
|
TRACE(("case: BS\n"));
|
2007-06-15 13:34:50 -06:00
|
|
|
if (tekscr->TekGIN)
|
|
|
|
TekGINoff(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
Tparsestate = curstate; /* clear bypass condition */
|
2007-06-15 13:34:50 -06:00
|
|
|
TCursorBack(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_PT_STATE:
|
|
|
|
TRACE(("case: Enter Tek Point Plot mode\n"));
|
2007-06-15 13:34:50 -06:00
|
|
|
if (tekscr->TekGIN)
|
|
|
|
TekGINoff(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
Tparsestate = curstate = Tpttable;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_PLT_STATE:
|
|
|
|
TRACE(("case: Enter Tek Plot mode\n"));
|
2007-06-15 13:34:50 -06:00
|
|
|
if (tekscr->TekGIN)
|
|
|
|
TekGINoff(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
Tparsestate = curstate = Tplttable;
|
2007-06-15 13:34:50 -06:00
|
|
|
if ((c = input()) == ANSI_BEL)
|
|
|
|
tekscr->pen = PENDOWN;
|
2006-11-26 04:11:12 -07:00
|
|
|
else {
|
|
|
|
unput(c);
|
2007-06-15 13:34:50 -06:00
|
|
|
tekscr->pen = PENUP;
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_TAB:
|
|
|
|
TRACE(("case: HT\n"));
|
2007-06-15 13:34:50 -06:00
|
|
|
if (tekscr->TekGIN)
|
|
|
|
TekGINoff(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
Tparsestate = curstate; /* clear bypass condition */
|
2007-06-15 13:34:50 -06:00
|
|
|
TCursorForward(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_IPL_STATE:
|
|
|
|
TRACE(("case: Enter Tek Incremental Plot mode\n"));
|
2007-06-15 13:34:50 -06:00
|
|
|
if (tekscr->TekGIN)
|
|
|
|
TekGINoff(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
Tparsestate = curstate = Tipltable;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_ALP_STATE:
|
|
|
|
TRACE(("case: Enter Tek Alpha mode from any other mode\n"));
|
2007-06-15 13:34:50 -06:00
|
|
|
if (tekscr->TekGIN)
|
|
|
|
TekGINoff(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
/* if in one of graphics states, move alpha cursor */
|
|
|
|
if (nplot > 0) /* flush line VTbuffer */
|
2007-06-15 13:34:50 -06:00
|
|
|
TekFlush(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
Tparsestate = curstate = Talptable;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_UP:
|
|
|
|
TRACE(("case: cursor up\n"));
|
2007-06-15 13:34:50 -06:00
|
|
|
if (tekscr->TekGIN)
|
|
|
|
TekGINoff(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
Tparsestate = curstate; /* clear bypass condition */
|
2007-06-15 13:34:50 -06:00
|
|
|
TCursorUp(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_COPY:
|
|
|
|
TRACE(("case: make copy\n"));
|
2007-06-15 13:34:50 -06:00
|
|
|
if (tekscr->TekGIN)
|
|
|
|
TekGINoff(tw);
|
|
|
|
TekCopy(tw);
|
|
|
|
TekRecord->ptr[-1] = ANSI_NAK; /* remove from recording */
|
2006-11-26 04:11:12 -07:00
|
|
|
Tparsestate = curstate; /* clear bypass condition */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_PAGE:
|
|
|
|
TRACE(("case: Page Function\n"));
|
2007-06-15 13:34:50 -06:00
|
|
|
if (tekscr->TekGIN)
|
|
|
|
TekGINoff(tw);
|
|
|
|
TekPage(tw); /* clear bypass condition */
|
2006-11-26 04:11:12 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_BES_STATE:
|
|
|
|
TRACE(("case: Byp: an escape char\n"));
|
|
|
|
Tparsestate = Tbestable;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_BYP_STATE:
|
|
|
|
TRACE(("case: set bypass condition\n"));
|
|
|
|
Tparsestate = Tbyptable;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_IGNORE:
|
|
|
|
TRACE(("case: Esc: totally ignore CR, ESC, LF, ~\n"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_ASCII:
|
|
|
|
TRACE(("case: Select ASCII char set\n"));
|
|
|
|
/* ignore for now */
|
|
|
|
Tparsestate = curstate;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_APL:
|
|
|
|
TRACE(("case: Select APL char set\n"));
|
|
|
|
/* ignore for now */
|
|
|
|
Tparsestate = curstate;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_CHAR_SIZE:
|
|
|
|
TRACE(("case: character size selector\n"));
|
2009-09-05 09:58:09 -06:00
|
|
|
TekSetFontSize(tw, False, (int) (c & 03));
|
2006-11-26 04:11:12 -07:00
|
|
|
Tparsestate = curstate;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_BEAM_VEC:
|
|
|
|
TRACE(("case: beam and vector selector\n"));
|
|
|
|
/* only line types */
|
2011-03-07 13:41:27 -07:00
|
|
|
c = (IChar) (c & LINEMASK);
|
|
|
|
if (c != tekscr->cur.linetype) {
|
2006-11-26 04:11:12 -07:00
|
|
|
if (nplot > 0)
|
2007-06-15 13:34:50 -06:00
|
|
|
TekFlush(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
if (c <= TEKNUMLINES)
|
2007-06-15 13:34:50 -06:00
|
|
|
tekscr->cur.linetype = c;
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
Tparsestate = curstate;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_CURSTATE:
|
|
|
|
Tparsestate = curstate;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_PENUP:
|
|
|
|
TRACE(("case: Ipl: penup\n"));
|
2007-06-15 13:34:50 -06:00
|
|
|
tekscr->pen = PENUP;
|
2006-11-26 04:11:12 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_PENDOWN:
|
|
|
|
TRACE(("case: Ipl: pendown\n"));
|
2007-06-15 13:34:50 -06:00
|
|
|
tekscr->pen = PENDOWN;
|
2006-11-26 04:11:12 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_IPL_POINT:
|
|
|
|
TRACE(("case: Ipl: point\n"));
|
2007-06-15 13:34:50 -06:00
|
|
|
x = tekscr->cur_X;
|
|
|
|
y = tekscr->cur_Y;
|
2006-11-26 04:11:12 -07:00
|
|
|
if (c & NORTH)
|
|
|
|
y++;
|
|
|
|
else if (c & SOUTH)
|
|
|
|
y--;
|
|
|
|
if (c & EAST)
|
|
|
|
x++;
|
|
|
|
else if (c & WEST)
|
|
|
|
x--;
|
2007-06-15 13:34:50 -06:00
|
|
|
if (tekscr->pen == PENDOWN)
|
|
|
|
TekDraw(tw, x, y);
|
2006-11-26 04:11:12 -07:00
|
|
|
else
|
2007-06-15 13:34:50 -06:00
|
|
|
TekMove(tw, x, y);
|
2006-11-26 04:11:12 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_PLT_VEC:
|
|
|
|
TRACE(("case: Plt: vector\n"));
|
|
|
|
unput(c);
|
2007-06-15 13:34:50 -06:00
|
|
|
if (getpoint(tw)) {
|
|
|
|
if (tekscr->pen == PENDOWN) {
|
|
|
|
TekDraw(tw, tekscr->cur.x, tekscr->cur.y);
|
2006-11-26 04:11:12 -07:00
|
|
|
} else {
|
2007-06-15 13:34:50 -06:00
|
|
|
TekMove(tw, tekscr->cur.x, tekscr->cur.y);
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
2007-06-15 13:34:50 -06:00
|
|
|
tekscr->pen = PENDOWN;
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_PT_POINT:
|
|
|
|
TRACE(("case: Pt: point\n"));
|
|
|
|
unput(c);
|
2007-06-15 13:34:50 -06:00
|
|
|
if (getpoint(tw)) {
|
|
|
|
TekMove(tw, tekscr->cur.x, tekscr->cur.y);
|
|
|
|
TekDraw(tw, tekscr->cur.x, tekscr->cur.y);
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_SPT_POINT:
|
|
|
|
TRACE(("case: Spt: point\n"));
|
|
|
|
/* ignore intensity character in c */
|
2007-06-15 13:34:50 -06:00
|
|
|
if (getpoint(tw)) {
|
|
|
|
TekMove(tw, tekscr->cur.x, tekscr->cur.y);
|
|
|
|
TekDraw(tw, tekscr->cur.x, tekscr->cur.y);
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_CR:
|
|
|
|
TRACE(("case: CR\n"));
|
2007-06-15 13:34:50 -06:00
|
|
|
if (tekscr->TekGIN)
|
|
|
|
TekGINoff(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
if (nplot > 0) /* flush line VTbuffer */
|
2007-06-15 13:34:50 -06:00
|
|
|
TekFlush(tw);
|
|
|
|
tekscr->cur_X = tekscr->margin == MARGIN1 ? 0 :
|
2006-11-26 04:11:12 -07:00
|
|
|
TEKWIDTH / 2;
|
|
|
|
Tparsestate = curstate = Talptable;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_ESC_STATE:
|
|
|
|
TRACE(("case: ESC\n"));
|
|
|
|
Tparsestate = Tesctable;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_LF:
|
|
|
|
TRACE(("case: LF\n"));
|
2007-06-15 13:34:50 -06:00
|
|
|
if (tekscr->TekGIN)
|
|
|
|
TekGINoff(tw);
|
|
|
|
TCursorDown(tw);
|
|
|
|
if (!tekRefreshList)
|
2006-11-26 04:11:12 -07:00
|
|
|
do_xevents();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_SP:
|
|
|
|
TRACE(("case: SP\n"));
|
2007-06-15 13:34:50 -06:00
|
|
|
TCursorForward(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CASE_PRINT:
|
|
|
|
TRACE(("case: printable character\n"));
|
|
|
|
ch = c;
|
2007-06-15 13:34:50 -06:00
|
|
|
x = (int) (tekscr->cur_X * TekScale(tekscr))
|
2006-11-26 04:11:12 -07:00
|
|
|
+ screen->border;
|
2007-06-15 13:34:50 -06:00
|
|
|
y = (int) ((TEKHEIGHT + TEKTOPPAD - tekscr->cur_Y) * TekScale(tekscr))
|
2006-11-26 04:11:12 -07:00
|
|
|
+ screen->border;
|
|
|
|
|
|
|
|
#if OPT_WIDE_CHARS
|
|
|
|
if (screen->wide_chars
|
|
|
|
&& (ch > 255)) {
|
|
|
|
XChar2b sbuf;
|
2008-03-19 15:15:46 -06:00
|
|
|
sbuf.byte2 = LO_BYTE(ch);
|
|
|
|
sbuf.byte1 = HI_BYTE(ch);
|
2007-06-15 13:34:50 -06:00
|
|
|
XDrawImageString16(XtDisplay(tw),
|
|
|
|
TWindow(tekscr),
|
|
|
|
tekscr->TnormalGC,
|
2006-11-26 04:11:12 -07:00
|
|
|
x,
|
|
|
|
y,
|
|
|
|
&sbuf,
|
|
|
|
1);
|
|
|
|
} else
|
|
|
|
#endif
|
2008-02-16 02:40:00 -07:00
|
|
|
{
|
|
|
|
char ch2 = (char) ch;
|
2007-06-15 13:34:50 -06:00
|
|
|
XDrawString(XtDisplay(tw),
|
|
|
|
TWindow(tekscr),
|
|
|
|
tekscr->TnormalGC,
|
2006-11-26 04:11:12 -07:00
|
|
|
x,
|
|
|
|
y,
|
2008-02-16 02:40:00 -07:00
|
|
|
&ch2,
|
2006-11-26 04:11:12 -07:00
|
|
|
1);
|
2008-02-16 02:40:00 -07:00
|
|
|
}
|
2007-06-15 13:34:50 -06:00
|
|
|
TCursorForward(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
break;
|
|
|
|
case CASE_OSC:
|
|
|
|
/* FIXME: someone should disentangle the input queues
|
|
|
|
* of this code so that it can be state-driven.
|
|
|
|
*/
|
|
|
|
TRACE(("case: do osc escape\n"));
|
|
|
|
{
|
|
|
|
/*
|
2007-06-15 13:34:50 -06:00
|
|
|
* do_osc() can call TekExpose(), which calls TekRefresh(),
|
2006-11-26 04:11:12 -07:00
|
|
|
* and sends us recurring here - don't do that...
|
|
|
|
*/
|
|
|
|
static int nested;
|
|
|
|
|
|
|
|
Char buf2[512];
|
|
|
|
IChar c2;
|
2010-05-08 06:20:46 -06:00
|
|
|
size_t len = 0;
|
2007-06-15 13:34:50 -06:00
|
|
|
while ((c2 = input()) != ANSI_BEL) {
|
2009-03-09 16:13:04 -06:00
|
|
|
if (!isprint((int) (c2 & 0x7f))
|
2006-11-26 04:11:12 -07:00
|
|
|
|| len + 2 >= (int) sizeof(buf2))
|
|
|
|
break;
|
2009-03-09 16:13:04 -06:00
|
|
|
buf2[len++] = (Char) c2;
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
buf2[len] = 0;
|
|
|
|
if (!nested++) {
|
2007-06-15 13:34:50 -06:00
|
|
|
if (c2 == ANSI_BEL)
|
2010-08-22 07:38:11 -06:00
|
|
|
do_osc(xw, buf2, len, ANSI_BEL);
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
--nested;
|
|
|
|
}
|
|
|
|
Tparsestate = curstate;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rcnt;
|
|
|
|
static char *rptr;
|
|
|
|
static PtySelect Tselect_mask;
|
|
|
|
|
|
|
|
static IChar
|
2007-06-15 13:34:50 -06:00
|
|
|
Tinput(TekWidget tw)
|
2006-11-26 04:11:12 -07:00
|
|
|
{
|
2010-08-22 07:38:11 -06:00
|
|
|
XtermWidget xw = term;
|
2007-06-15 13:34:50 -06:00
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
2010-08-22 07:38:11 -06:00
|
|
|
TScreen *screen = TScreenOf(xw);
|
2006-11-26 04:11:12 -07:00
|
|
|
TekLink *tek;
|
|
|
|
|
|
|
|
if (Tpushback > Tpushb)
|
|
|
|
return (*--Tpushback);
|
2007-06-15 13:34:50 -06:00
|
|
|
if (tekRefreshList) {
|
2006-11-26 04:11:12 -07:00
|
|
|
if (rcnt-- > 0)
|
2009-03-09 16:13:04 -06:00
|
|
|
return (IChar) (*rptr++);
|
2007-06-15 13:34:50 -06:00
|
|
|
if ((tek = tekRefreshList->next) != 0) {
|
|
|
|
tekRefreshList = tek;
|
2006-11-26 04:11:12 -07:00
|
|
|
rptr = tek->data;
|
|
|
|
rcnt = tek->count - 1;
|
2009-09-05 09:58:09 -06:00
|
|
|
TekSetFontSize(tw, False, tek->fontsize);
|
2009-03-09 16:13:04 -06:00
|
|
|
return (IChar) (*rptr++);
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
2007-06-15 13:34:50 -06:00
|
|
|
tekRefreshList = (TekLink *) 0;
|
2006-11-26 04:11:12 -07:00
|
|
|
longjmp(Tekjump, 1);
|
|
|
|
}
|
|
|
|
again:
|
|
|
|
if (VTbuffer->next >= VTbuffer->last) {
|
|
|
|
int update = VTbuffer->update;
|
|
|
|
|
|
|
|
if (nplot > 0) /* flush line */
|
2007-06-15 13:34:50 -06:00
|
|
|
TekFlush(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
#ifdef VMS
|
|
|
|
Tselect_mask = pty_mask; /* force a read */
|
|
|
|
#else /* VMS */
|
|
|
|
XFD_COPYSET(&pty_mask, &Tselect_mask);
|
|
|
|
#endif /* VMS */
|
|
|
|
for (;;) {
|
|
|
|
#ifdef CRAY
|
|
|
|
struct timeval crocktimeout;
|
|
|
|
crocktimeout.tv_sec = 0;
|
|
|
|
crocktimeout.tv_usec = 0;
|
|
|
|
(void) Select(max_plus1,
|
|
|
|
&Tselect_mask, NULL, NULL,
|
|
|
|
&crocktimeout);
|
|
|
|
#endif
|
2010-08-22 07:38:11 -06:00
|
|
|
if (readPtyData(xw, &Tselect_mask, VTbuffer)) {
|
2006-11-26 04:11:12 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (Ttoggled && curstate == Talptable) {
|
2007-06-15 13:34:50 -06:00
|
|
|
TCursorToggle(tw, TOGGLE);
|
2006-11-26 04:11:12 -07:00
|
|
|
Ttoggled = False;
|
|
|
|
}
|
2011-09-17 05:51:57 -06:00
|
|
|
if (xtermAppPending() & XtIMXEvent) {
|
2006-11-26 04:11:12 -07:00
|
|
|
#ifdef VMS
|
|
|
|
Tselect_mask = X_mask;
|
|
|
|
#else /* VMS */
|
|
|
|
XFD_COPYSET(&X_mask, &Tselect_mask);
|
|
|
|
#endif /* VMS */
|
|
|
|
} else {
|
2007-06-15 13:34:50 -06:00
|
|
|
XFlush(XtDisplay(tw));
|
2006-11-26 04:11:12 -07:00
|
|
|
#ifdef VMS
|
|
|
|
Tselect_mask = Select_mask;
|
|
|
|
|
|
|
|
#else /* VMS */
|
|
|
|
XFD_COPYSET(&Select_mask, &Tselect_mask);
|
2006-11-26 08:48:06 -07:00
|
|
|
if (need_cleanup)
|
|
|
|
Cleanup(0);
|
2006-11-26 04:11:12 -07:00
|
|
|
if (Select(max_plus1, &Tselect_mask, NULL, NULL, NULL) < 0) {
|
|
|
|
if (errno != EINTR)
|
|
|
|
SysError(ERROR_TSELECT);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
#endif /* VMS */
|
|
|
|
}
|
|
|
|
#ifdef VMS
|
|
|
|
if (Tselect_mask & X_mask) {
|
|
|
|
xevents();
|
|
|
|
if (VTbuffer->update != update)
|
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
#else /* VMS */
|
2007-06-15 13:34:50 -06:00
|
|
|
if (FD_ISSET(ConnectionNumber(XtDisplay(tw)), &Tselect_mask)) {
|
2006-11-26 04:11:12 -07:00
|
|
|
xevents();
|
|
|
|
if (VTbuffer->update != update)
|
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
#endif /* VMS */
|
|
|
|
}
|
|
|
|
if (!Ttoggled && curstate == Talptable) {
|
2007-06-15 13:34:50 -06:00
|
|
|
TCursorToggle(tw, TOGGLE);
|
2006-11-26 04:11:12 -07:00
|
|
|
Ttoggled = True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tek = TekRecord;
|
|
|
|
if (tek->count >= TEK_LINK_BLOCK_SIZE
|
2007-06-15 13:34:50 -06:00
|
|
|
|| tek->fontsize != tekscr->cur.fontsize) {
|
2010-08-22 07:38:11 -06:00
|
|
|
if ((TekRecord = tek->next = CastMalloc(TekLink)) == 0) {
|
2006-11-26 04:11:12 -07:00
|
|
|
Panic("Tinput: malloc error (%d)\n", errno);
|
2010-08-22 07:38:11 -06:00
|
|
|
} else {
|
|
|
|
tek = tek->next;
|
|
|
|
tek->next = (TekLink *) 0;
|
|
|
|
tek->fontsize = (unsigned short) tekscr->cur.fontsize;
|
|
|
|
tek->count = 0;
|
|
|
|
tek->ptr = tek->data;
|
|
|
|
}
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
tek->count++;
|
|
|
|
|
|
|
|
(void) morePtyData(screen, VTbuffer);
|
2009-03-09 16:13:04 -06:00
|
|
|
return (IChar) (*tek->ptr++ = (char) nextPtyData(screen, VTbuffer));
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
static void
|
|
|
|
TekClear(TekWidget tw)
|
|
|
|
{
|
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
|
|
|
|
|
|
|
if (TWindow(tekscr))
|
|
|
|
XClearWindow(XtDisplay(tw), TWindow(tekscr));
|
|
|
|
}
|
|
|
|
|
2006-11-26 04:11:12 -07:00
|
|
|
/* this should become the Tek Widget's Resize proc */
|
|
|
|
static void
|
|
|
|
TekConfigure(Widget w)
|
|
|
|
{
|
2009-04-04 09:10:44 -06:00
|
|
|
TekWidget tw = getTekWidget(w);
|
|
|
|
if (tw != 0) {
|
2010-08-22 07:38:11 -06:00
|
|
|
XtermWidget xw = term;
|
2007-06-15 13:34:50 -06:00
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
2010-08-22 07:38:11 -06:00
|
|
|
TScreen *screen = TScreenOf(xw);
|
2007-06-15 13:34:50 -06:00
|
|
|
int border = 2 * screen->border;
|
|
|
|
double d;
|
|
|
|
|
|
|
|
TekClear(tw);
|
|
|
|
TWidth(tekscr) = w->core.width - border;
|
|
|
|
THeight(tekscr) = w->core.height - border;
|
|
|
|
TekScale(tekscr) = (double) TWidth(tekscr) / TEKWIDTH;
|
|
|
|
if ((d = (double) THeight(tekscr) / (TEKHEIGHT + TEKTOPPAD + TEKBOTTOMPAD))
|
|
|
|
< TekScale(tekscr))
|
|
|
|
TekScale(tekscr) = d;
|
|
|
|
TFullWidth(tekscr) = w->core.width;
|
|
|
|
TFullHeight(tekscr) = w->core.height;
|
|
|
|
}
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
|
|
|
void
|
2007-06-15 13:34:50 -06:00
|
|
|
TekExpose(Widget w,
|
2006-11-26 04:11:12 -07:00
|
|
|
XEvent * event GCC_UNUSED,
|
|
|
|
Region region GCC_UNUSED)
|
|
|
|
{
|
2009-04-04 09:10:44 -06:00
|
|
|
TekWidget tw = getTekWidget(w);
|
|
|
|
if (tw != 0) {
|
2007-06-15 13:34:50 -06:00
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
|
2009-04-04 09:10:44 -06:00
|
|
|
TRACE(("TekExpose {{\n"));
|
2006-11-26 04:11:12 -07:00
|
|
|
|
|
|
|
#ifdef lint
|
2007-06-15 13:34:50 -06:00
|
|
|
region = region;
|
2006-11-26 04:11:12 -07:00
|
|
|
#endif
|
2007-06-15 13:34:50 -06:00
|
|
|
if (!Ttoggled)
|
|
|
|
TCursorToggle(tw, CLEAR);
|
|
|
|
Ttoggled = True;
|
|
|
|
Tpushback = Tpushb;
|
|
|
|
tekscr->cur_X = 0;
|
|
|
|
tekscr->cur_Y = TEKHOME;
|
|
|
|
tekscr->cur = tekscr->page;
|
2009-09-05 09:58:09 -06:00
|
|
|
TekSetFontSize(tw, False, tekscr->cur.fontsize);
|
2007-06-15 13:34:50 -06:00
|
|
|
tekscr->margin = MARGIN1;
|
|
|
|
if (tekscr->TekGIN) {
|
|
|
|
tekscr->TekGIN = NULL;
|
|
|
|
TekGINoff(tw);
|
|
|
|
}
|
|
|
|
tekRefreshList = &Tek0;
|
|
|
|
rptr = tekRefreshList->data;
|
|
|
|
rcnt = tekRefreshList->count;
|
|
|
|
Tparsestate = curstate = Talptable;
|
|
|
|
TRACE(("TekExpose resets data to replay %d bytes\n", rcnt));
|
2007-08-25 12:58:42 -06:00
|
|
|
first_map_occurred();
|
2007-06-15 13:34:50 -06:00
|
|
|
if (!tekscr->waitrefresh)
|
|
|
|
TekRefresh(tw);
|
2009-04-04 09:10:44 -06:00
|
|
|
TRACE(("}} TekExpose\n"));
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-06-15 13:34:50 -06:00
|
|
|
TekRefresh(TekWidget tw)
|
2006-11-26 04:11:12 -07:00
|
|
|
{
|
2007-08-25 12:58:42 -06:00
|
|
|
if (tw != 0) {
|
2010-08-22 07:38:11 -06:00
|
|
|
XtermWidget xw = term;
|
|
|
|
TScreen *screen = TScreenOf(xw);
|
2007-08-25 12:58:42 -06:00
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
|
|
|
static Cursor wait_cursor = None;
|
|
|
|
|
|
|
|
if (wait_cursor == None)
|
|
|
|
wait_cursor = make_colored_cursor(XC_watch,
|
|
|
|
T_COLOR(screen, MOUSE_FG),
|
|
|
|
T_COLOR(screen, MOUSE_BG));
|
|
|
|
XDefineCursor(XtDisplay(tw), TWindow(tekscr), wait_cursor);
|
|
|
|
XFlush(XtDisplay(tw));
|
|
|
|
if (!setjmp(Tekjump))
|
|
|
|
Tekparse(tw);
|
|
|
|
XDefineCursor(XtDisplay(tw), TWindow(tekscr),
|
|
|
|
(tekscr->TekGIN && GINcursor) ? GINcursor : tekscr->arrow);
|
|
|
|
}
|
2007-06-15 13:34:50 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TekRepaint(TekWidget tw)
|
|
|
|
{
|
2009-04-04 09:10:44 -06:00
|
|
|
TRACE(("TekRepaint\n"));
|
2007-06-15 13:34:50 -06:00
|
|
|
TekClear(tw);
|
|
|
|
TekExpose((Widget) tw, (XEvent *) NULL, (Region) NULL);
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-06-15 13:34:50 -06:00
|
|
|
TekPage(TekWidget tw)
|
2006-11-26 04:11:12 -07:00
|
|
|
{
|
2007-06-15 13:34:50 -06:00
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
TekLink *tek;
|
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
TekClear(tw);
|
|
|
|
tekscr->cur_X = 0;
|
|
|
|
tekscr->cur_Y = TEKHOME;
|
|
|
|
tekscr->margin = MARGIN1;
|
|
|
|
tekscr->page = tekscr->cur;
|
|
|
|
if (tekscr->TekGIN)
|
|
|
|
TekGINoff(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
tek = TekRecord = &Tek0;
|
2009-03-09 16:13:04 -06:00
|
|
|
tek->fontsize = (unsigned short) tekscr->cur.fontsize;
|
2006-11-26 04:11:12 -07:00
|
|
|
tek->count = 0;
|
|
|
|
tek->ptr = tek->data;
|
|
|
|
tek = tek->next;
|
|
|
|
if (tek)
|
|
|
|
do {
|
|
|
|
TekLink *tek2 = tek->next;
|
|
|
|
|
|
|
|
free(tek);
|
|
|
|
tek = tek2;
|
|
|
|
} while (tek);
|
|
|
|
TekRecord->next = (TekLink *) 0;
|
2007-06-15 13:34:50 -06:00
|
|
|
tekRefreshList = (TekLink *) 0;
|
2006-11-26 04:11:12 -07:00
|
|
|
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
|
2007-06-15 13:34:50 -06:00
|
|
|
getpoint(TekWidget tw)
|
2006-11-26 04:11:12 -07:00
|
|
|
{
|
|
|
|
int c, x, y, e, lo_y = 0;
|
2007-06-15 13:34:50 -06:00
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
x = tekscr->cur.x;
|
|
|
|
y = tekscr->cur.y;
|
2006-11-26 04:11:12 -07:00
|
|
|
for (;;) {
|
2009-03-09 16:13:04 -06:00
|
|
|
if ((c = (int) input()) < ' ') { /* control character */
|
2006-11-26 04:11:12 -07:00
|
|
|
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;
|
2007-06-15 13:34:50 -06:00
|
|
|
tekscr->cur.x = x;
|
|
|
|
tekscr->cur.y = y;
|
2006-11-26 04:11:12 -07:00
|
|
|
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++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-06-15 13:34:50 -06:00
|
|
|
TCursorBack(TekWidget tw)
|
2006-11-26 04:11:12 -07:00
|
|
|
{
|
2007-06-15 13:34:50 -06:00
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
struct Tek_Char *t;
|
|
|
|
int x, l;
|
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
x = (tekscr->cur_X -=
|
|
|
|
(t = &TekChar[tekscr->cur.fontsize])->hsize
|
2006-11-26 04:11:12 -07:00
|
|
|
);
|
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
if (((tekscr->margin == MARGIN1) && (x < 0))
|
|
|
|
|| ((tekscr->margin == MARGIN2) && (x < TEKWIDTH / 2))) {
|
|
|
|
if ((l = (tekscr->cur_Y + (t->vsize - 1)) / t->vsize + 1) >=
|
2006-11-26 04:11:12 -07:00
|
|
|
t->nlines) {
|
2007-06-15 13:34:50 -06:00
|
|
|
tekscr->margin = !tekscr->margin;
|
2006-11-26 04:11:12 -07:00
|
|
|
l = 0;
|
|
|
|
}
|
2007-06-15 13:34:50 -06:00
|
|
|
tekscr->cur_Y = l * t->vsize;
|
|
|
|
tekscr->cur_X = (t->charsperline - 1) * t->hsize;
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-06-15 13:34:50 -06:00
|
|
|
TCursorForward(TekWidget tw)
|
2006-11-26 04:11:12 -07:00
|
|
|
{
|
2007-06-15 13:34:50 -06:00
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
struct Tek_Char *t;
|
|
|
|
int l;
|
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
if ((tekscr->cur_X +=
|
|
|
|
(t = &TekChar[tekscr->cur.fontsize])->hsize
|
2006-11-26 04:11:12 -07:00
|
|
|
) > TEKWIDTH
|
|
|
|
) {
|
2007-06-15 13:34:50 -06:00
|
|
|
if ((l = tekscr->cur_Y / t->vsize - 1) < 0) {
|
|
|
|
tekscr->margin = !tekscr->margin;
|
2006-11-26 04:11:12 -07:00
|
|
|
l = t->nlines - 1;
|
|
|
|
}
|
2007-06-15 13:34:50 -06:00
|
|
|
tekscr->cur_Y = l * t->vsize;
|
|
|
|
tekscr->cur_X = tekscr->margin == MARGIN1 ? 0 : TEKWIDTH / 2;
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-06-15 13:34:50 -06:00
|
|
|
TCursorUp(TekWidget tw)
|
2006-11-26 04:11:12 -07:00
|
|
|
{
|
2007-06-15 13:34:50 -06:00
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
struct Tek_Char *t;
|
|
|
|
int l;
|
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
t = &TekChar[tekscr->cur.fontsize];
|
2006-11-26 04:11:12 -07:00
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
if ((l = (tekscr->cur_Y + (t->vsize - 1)) / t->vsize + 1) >= t->nlines) {
|
2006-11-26 04:11:12 -07:00
|
|
|
l = 0;
|
2007-06-15 13:34:50 -06:00
|
|
|
if ((tekscr->margin = !tekscr->margin) != MARGIN1) {
|
|
|
|
if (tekscr->cur_X < TEKWIDTH / 2)
|
|
|
|
tekscr->cur_X += TEKWIDTH / 2;
|
|
|
|
} else if (tekscr->cur_X >= TEKWIDTH / 2)
|
|
|
|
tekscr->cur_X -= TEKWIDTH / 2;
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
2007-06-15 13:34:50 -06:00
|
|
|
tekscr->cur_Y = l * t->vsize;
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-06-15 13:34:50 -06:00
|
|
|
TCursorDown(TekWidget tw)
|
2006-11-26 04:11:12 -07:00
|
|
|
{
|
2007-06-15 13:34:50 -06:00
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
struct Tek_Char *t;
|
|
|
|
int l;
|
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
t = &TekChar[tekscr->cur.fontsize];
|
2006-11-26 04:11:12 -07:00
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
if ((l = tekscr->cur_Y / t->vsize - 1) < 0) {
|
2006-11-26 04:11:12 -07:00
|
|
|
l = t->nlines - 1;
|
2007-06-15 13:34:50 -06:00
|
|
|
if ((tekscr->margin = !tekscr->margin) != MARGIN1) {
|
|
|
|
if (tekscr->cur_X < TEKWIDTH / 2)
|
|
|
|
tekscr->cur_X += TEKWIDTH / 2;
|
|
|
|
} else if (tekscr->cur_X >= TEKWIDTH / 2)
|
|
|
|
tekscr->cur_X -= TEKWIDTH / 2;
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
2007-06-15 13:34:50 -06:00
|
|
|
tekscr->cur_Y = l * t->vsize;
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-06-15 13:34:50 -06:00
|
|
|
AddToDraw(TekWidget tw, int x1, int y1, int x2, int y2)
|
2006-11-26 04:11:12 -07:00
|
|
|
{
|
2010-08-22 07:38:11 -06:00
|
|
|
XtermWidget xw = term;
|
|
|
|
TScreen *screen = TScreenOf(xw);
|
2007-06-15 13:34:50 -06:00
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
XSegment *lp;
|
|
|
|
|
|
|
|
TRACE(("AddToDraw (%d,%d) (%d,%d)\n", x1, y1, x2, y2));
|
|
|
|
if (nplot >= MAX_PTS) {
|
2007-06-15 13:34:50 -06:00
|
|
|
TekFlush(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
lp = line_pt++;
|
2009-03-09 16:13:04 -06:00
|
|
|
lp->x1 = (short) (x1 * TekScale(tekscr) + screen->border);
|
|
|
|
lp->y1 = (short) ((TEKHEIGHT + TEKTOPPAD - y1) * TekScale(tekscr) +
|
|
|
|
screen->border);
|
|
|
|
lp->x2 = (short) (x2 * TekScale(tekscr) + screen->border);
|
|
|
|
lp->y2 = (short) ((TEKHEIGHT + TEKTOPPAD - y2) * TekScale(tekscr) +
|
|
|
|
screen->border);
|
2006-11-26 04:11:12 -07:00
|
|
|
nplot++;
|
|
|
|
TRACE(("...AddToDraw %d points\n", nplot));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-06-15 13:34:50 -06:00
|
|
|
TekDraw(TekWidget tw, int x, int y)
|
2006-11-26 04:11:12 -07:00
|
|
|
{
|
2007-06-15 13:34:50 -06:00
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
if (nplot == 0 || T_lastx != tekscr->cur_X || T_lasty != tekscr->cur_Y) {
|
2006-11-26 04:11:12 -07:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2007-06-15 13:34:50 -06:00
|
|
|
if (nplot > 0 && tekscr->cur.linetype != SOLIDLINE)
|
|
|
|
TekFlush(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
2007-06-15 13:34:50 -06:00
|
|
|
AddToDraw(tw, tekscr->cur_X, tekscr->cur_Y, x, y);
|
|
|
|
T_lastx = tekscr->cur_X = x;
|
|
|
|
T_lasty = tekscr->cur_Y = y;
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-06-15 13:34:50 -06:00
|
|
|
TekFlush(TekWidget tw)
|
2006-11-26 04:11:12 -07:00
|
|
|
{
|
2007-06-15 13:34:50 -06:00
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
|
|
|
|
TRACE(("TekFlush\n"));
|
2007-06-15 13:34:50 -06:00
|
|
|
XDrawSegments(XtDisplay(tw), TWindow(tekscr),
|
|
|
|
((tekscr->cur.linetype == SOLIDLINE)
|
|
|
|
? tekscr->TnormalGC
|
|
|
|
: tekscr->linepat[tekscr->cur.linetype - 1]),
|
2006-11-26 04:11:12 -07:00
|
|
|
Tline, nplot);
|
|
|
|
nplot = 0;
|
|
|
|
line_pt = Tline;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-06-15 13:34:50 -06:00
|
|
|
TekGINoff(TekWidget tw)
|
2006-11-26 04:11:12 -07:00
|
|
|
{
|
2007-06-15 13:34:50 -06:00
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
|
|
|
|
TRACE(("TekGINoff\n"));
|
2007-06-15 13:34:50 -06:00
|
|
|
XDefineCursor(XtDisplay(tw), TWindow(tekscr), tekscr->arrow);
|
2006-11-26 04:11:12 -07:00
|
|
|
if (GINcursor)
|
2007-06-15 13:34:50 -06:00
|
|
|
XFreeCursor(XtDisplay(tw), GINcursor);
|
|
|
|
if (tekscr->TekGIN) {
|
|
|
|
*tekscr->TekGIN = ANSI_CAN; /* modify recording */
|
|
|
|
tekscr->TekGIN = NULL;
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-06-15 13:34:50 -06:00
|
|
|
TekEnqMouse(TekWidget tw, int c) /* character pressed */
|
2006-11-26 04:11:12 -07:00
|
|
|
{
|
2010-08-22 07:38:11 -06:00
|
|
|
XtermWidget xw = term;
|
|
|
|
TScreen *screen = TScreenOf(xw);
|
2007-06-15 13:34:50 -06:00
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
int mousex, mousey, rootx, rooty;
|
|
|
|
unsigned int mask; /* XQueryPointer */
|
|
|
|
Window root, subw;
|
|
|
|
|
|
|
|
TRACE(("TekEnqMouse\n"));
|
|
|
|
XQueryPointer(
|
2007-06-15 13:34:50 -06:00
|
|
|
XtDisplay(tw), TWindow(tekscr),
|
2006-11-26 04:11:12 -07:00
|
|
|
&root, &subw,
|
|
|
|
&rootx, &rooty,
|
|
|
|
&mousex, &mousey,
|
|
|
|
&mask);
|
2007-06-15 13:34:50 -06:00
|
|
|
if ((mousex = (int) ((mousex - screen->border) / TekScale(tekscr))) < 0)
|
2006-11-26 04:11:12 -07:00
|
|
|
mousex = 0;
|
|
|
|
else if (mousex >= TEKWIDTH)
|
|
|
|
mousex = TEKWIDTH - 1;
|
|
|
|
if ((mousey = (int) (TEKHEIGHT + TEKTOPPAD - (mousey - screen->border) /
|
2007-06-15 13:34:50 -06:00
|
|
|
TekScale(tekscr))) < 0)
|
2006-11-26 04:11:12 -07:00
|
|
|
mousey = 0;
|
|
|
|
else if (mousey >= TEKHEIGHT)
|
|
|
|
mousey = TEKHEIGHT - 1;
|
2007-06-15 13:34:50 -06:00
|
|
|
TekEnq(tw, (unsigned) c, mousex, mousey);
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-06-15 13:34:50 -06:00
|
|
|
TekEnq(TekWidget tw,
|
|
|
|
unsigned status,
|
2006-11-26 04:11:12 -07:00
|
|
|
int x,
|
|
|
|
int y)
|
|
|
|
{
|
2010-08-22 07:38:11 -06:00
|
|
|
XtermWidget xw = term;
|
|
|
|
TScreen *screen = TScreenOf(xw);
|
2007-06-15 13:34:50 -06:00
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
Char cplot[7];
|
|
|
|
int len = 5;
|
|
|
|
int adj = (status != 0) ? 0 : 1;
|
|
|
|
|
|
|
|
TRACE(("TekEnq\n"));
|
2009-03-09 16:13:04 -06:00
|
|
|
cplot[0] = (Char) status;
|
2006-11-26 04:11:12 -07:00
|
|
|
/* Translate x and y to Tektronix code */
|
2009-03-09 16:13:04 -06:00
|
|
|
cplot[1] = (Char) (040 | ((x >> SHIFTHI) & FIVEBITS));
|
|
|
|
cplot[2] = (Char) (040 | ((x >> SHIFTLO) & FIVEBITS));
|
|
|
|
cplot[3] = (Char) (040 | ((y >> SHIFTHI) & FIVEBITS));
|
|
|
|
cplot[4] = (Char) (040 | ((y >> SHIFTLO) & FIVEBITS));
|
2006-11-26 04:11:12 -07:00
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
if (tekscr->gin_terminator != GIN_TERM_NONE)
|
2006-11-26 04:11:12 -07:00
|
|
|
cplot[len++] = '\r';
|
2007-06-15 13:34:50 -06:00
|
|
|
if (tekscr->gin_terminator == GIN_TERM_EOT)
|
2006-11-26 04:11:12 -07:00
|
|
|
cplot[len++] = '\004';
|
|
|
|
#ifdef VMS
|
|
|
|
tt_write(cplot + adj, len - adj);
|
|
|
|
#else /* VMS */
|
|
|
|
v_write(screen->respond, cplot + adj, (unsigned) (len - adj));
|
|
|
|
#endif /* VMS */
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TekRun(void)
|
|
|
|
{
|
2010-08-22 07:38:11 -06:00
|
|
|
XtermWidget xw = term;
|
|
|
|
|
|
|
|
assert(xw != 0);
|
2007-06-15 13:34:50 -06:00
|
|
|
if (tekWidget == 0) {
|
|
|
|
TekInit();
|
|
|
|
}
|
|
|
|
if (tekWidget != 0) {
|
|
|
|
TRACE(("TekRun ...\n"));
|
2006-11-26 04:11:12 -07:00
|
|
|
|
2010-08-22 07:38:11 -06:00
|
|
|
if (!TEK4014_SHOWN(xw)) {
|
2007-06-15 13:34:50 -06:00
|
|
|
set_tek_visibility(True);
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
2007-06-15 13:34:50 -06:00
|
|
|
update_vttekmode();
|
|
|
|
update_vtshow();
|
|
|
|
update_tekshow();
|
|
|
|
set_tekhide_sensitivity();
|
2006-11-26 04:11:12 -07:00
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
Tpushback = Tpushb;
|
2006-11-26 04:11:12 -07:00
|
|
|
Ttoggled = True;
|
2007-06-15 13:34:50 -06:00
|
|
|
if (!setjmp(Tekend))
|
|
|
|
Tekparse(tekWidget);
|
|
|
|
if (!Ttoggled) {
|
|
|
|
TCursorToggle(tekWidget, TOGGLE);
|
|
|
|
Ttoggled = True;
|
|
|
|
}
|
2010-08-22 07:38:11 -06:00
|
|
|
TEK4014_ACTIVE(xw) = False;
|
2007-06-15 13:34:50 -06:00
|
|
|
} else {
|
2010-08-22 07:38:11 -06:00
|
|
|
TEK4014_ACTIVE(xw) = False;
|
|
|
|
if (VWindow(TScreenOf(xw)) == 0) {
|
2007-06-15 13:34:50 -06:00
|
|
|
Exit(ERROR_TINIT);
|
|
|
|
}
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#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 to create the tekWidget
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2010-10-23 13:14:52 -06:00
|
|
|
TekInitialize(Widget wrequest,
|
|
|
|
Widget new_arg,
|
2006-11-26 04:11:12 -07:00
|
|
|
ArgList args GCC_UNUSED,
|
|
|
|
Cardinal *num_args GCC_UNUSED)
|
|
|
|
{
|
2010-10-23 13:14:52 -06:00
|
|
|
TekWidget request = (TekWidget) wrequest;
|
|
|
|
TekWidget wnew = (TekWidget) new_arg;
|
2006-11-26 04:11:12 -07:00
|
|
|
Widget tekparent = SHELL_OF(wnew);
|
2010-03-25 16:03:51 -06:00
|
|
|
#ifndef NO_ACTIVE_ICON
|
|
|
|
TekScreen *screen = TekScreenOf((TekWidget) wnew);
|
|
|
|
#endif
|
2010-10-23 13:14:52 -06:00
|
|
|
int n;
|
2006-11-26 04:11:12 -07:00
|
|
|
|
|
|
|
TRACE(("TekInitialize\n"));
|
|
|
|
|
|
|
|
/* look for focus related events on the shell, because we need
|
|
|
|
* to care about the shell's border being part of our focus.
|
|
|
|
*/
|
|
|
|
XtAddEventHandler(tekparent, EnterWindowMask, False,
|
|
|
|
HandleEnterWindow, (Opaque) 0);
|
|
|
|
XtAddEventHandler(tekparent, LeaveWindowMask, False,
|
|
|
|
HandleLeaveWindow, (Opaque) 0);
|
|
|
|
XtAddEventHandler(tekparent, FocusChangeMask, False,
|
|
|
|
HandleFocusChange, (Opaque) 0);
|
2010-10-23 13:14:52 -06:00
|
|
|
XtAddEventHandler(new_arg, PropertyChangeMask, False,
|
2006-11-26 04:11:12 -07:00
|
|
|
HandleBellPropertyChange, (Opaque) 0);
|
2007-06-15 13:34:50 -06:00
|
|
|
|
|
|
|
#ifndef NO_ACTIVE_ICON
|
2010-03-25 16:03:51 -06:00
|
|
|
screen->whichTwin = &(screen->fullTwin);
|
2007-06-15 13:34:50 -06:00
|
|
|
#endif /* NO_ACTIVE_ICON */
|
|
|
|
|
2010-10-23 13:14:52 -06:00
|
|
|
for (n = 0; n < TEKNUMFONTS; ++n) {
|
|
|
|
wnew->tek.Tfont[n] = request->tek.Tfont[n];
|
|
|
|
}
|
|
|
|
|
|
|
|
init_Sres(tek.initial_font);
|
|
|
|
init_Sres(tek.gin_terminator_str);
|
|
|
|
#if OPT_TOOLBAR
|
|
|
|
init_Ires(tek.tb_info.menu_height);
|
|
|
|
wnew->tek.tb_info.menu_bar = request->tek.tb_info.menu_bar;
|
|
|
|
#endif
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
TekRealize(Widget gw,
|
|
|
|
XtValueMask * valuemaskp,
|
|
|
|
XSetWindowAttributes * values)
|
|
|
|
{
|
2010-08-22 07:38:11 -06:00
|
|
|
XtermWidget xw = term;
|
|
|
|
TScreen *screen = TScreenOf(xw);
|
2006-11-26 04:11:12 -07:00
|
|
|
TekWidget tw = (TekWidget) gw;
|
2007-06-15 13:34:50 -06:00
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
int i;
|
|
|
|
TekLink *tek;
|
|
|
|
double d;
|
|
|
|
int border = 2 * screen->border;
|
|
|
|
int pr;
|
|
|
|
XGCValues gcv;
|
2009-09-05 09:58:09 -06:00
|
|
|
int winX, winY;
|
|
|
|
unsigned width, height;
|
2006-11-26 04:11:12 -07:00
|
|
|
char Tdefault[32];
|
2009-09-05 09:58:09 -06:00
|
|
|
unsigned long TEKgcFontMask;
|
2006-11-26 04:11:12 -07:00
|
|
|
|
|
|
|
TRACE(("TekRealize\n"));
|
2010-03-25 16:03:51 -06:00
|
|
|
memset(tekscr, 0, sizeof(*tekscr));
|
2006-11-26 04:11:12 -07:00
|
|
|
|
|
|
|
#ifndef NO_ACTIVE_ICON
|
2007-06-15 13:34:50 -06:00
|
|
|
tekscr->whichTwin = &tekscr->fullTwin;
|
2006-11-26 04:11:12 -07:00
|
|
|
#endif /* NO_ACTIVE_ICON */
|
|
|
|
|
2010-08-22 07:38:11 -06:00
|
|
|
BorderPixel(tw) = BorderPixel(xw);
|
2006-11-26 04:11:12 -07:00
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
tekscr->arrow = make_colored_cursor(XC_left_ptr,
|
|
|
|
T_COLOR(screen, MOUSE_FG),
|
|
|
|
T_COLOR(screen, MOUSE_BG));
|
|
|
|
|
2006-11-26 04:11:12 -07:00
|
|
|
for (i = 0; i < TEKNUMFONTS; i++) {
|
|
|
|
if (!tw->tek.Tfont[i]) {
|
2007-06-15 13:34:50 -06:00
|
|
|
tw->tek.Tfont[i] = XQueryFont(XtDisplay(tw), DefaultGCID);
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
TRACE(("Tfont[%d] %dx%d\n",
|
|
|
|
i,
|
|
|
|
tw->tek.Tfont[i]->ascent +
|
|
|
|
tw->tek.Tfont[i]->descent,
|
|
|
|
tw->tek.Tfont[i]->max_bounds.width));
|
|
|
|
tw->tek.tobaseline[i] = tw->tek.Tfont[i]->ascent;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!TekPtyData())
|
|
|
|
return;
|
|
|
|
|
2010-08-22 07:38:11 -06:00
|
|
|
if (xw->misc.T_geometry == NULL) {
|
2006-11-26 04:11:12 -07:00
|
|
|
int defwidth, defheight;
|
|
|
|
|
2010-08-22 07:38:11 -06:00
|
|
|
if (xw->misc.tekSmall) {
|
2006-11-26 04:11:12 -07:00
|
|
|
defwidth = TEKMINWIDTH;
|
|
|
|
defheight = TEKMINHEIGHT;
|
|
|
|
} else {
|
|
|
|
defwidth = TEKDEFWIDTH;
|
|
|
|
defheight = TEKDEFHEIGHT;
|
|
|
|
}
|
|
|
|
sprintf(Tdefault, "=%dx%d", defwidth + border, defheight + border);
|
2010-08-22 07:38:11 -06:00
|
|
|
xw->misc.T_geometry = Tdefault;
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
winX = 1;
|
|
|
|
winY = 1;
|
2009-09-05 09:58:09 -06:00
|
|
|
width = (unsigned) (TEKDEFWIDTH + border);
|
|
|
|
height = (unsigned) (TEKDEFHEIGHT + border);
|
2006-11-26 04:11:12 -07:00
|
|
|
|
2010-08-22 07:38:11 -06:00
|
|
|
TRACE(("parsing T_geometry %s\n", NonNull(xw->misc.T_geometry)));
|
|
|
|
pr = XParseGeometry(xw->misc.T_geometry,
|
2006-11-26 04:11:12 -07:00
|
|
|
&winX,
|
|
|
|
&winY,
|
2009-09-05 09:58:09 -06:00
|
|
|
&width,
|
|
|
|
&height);
|
2006-11-26 04:11:12 -07:00
|
|
|
TRACE(("... position %d,%d size %dx%d\n", winY, winX, height, width));
|
|
|
|
if ((pr & XValue) && (pr & XNegative))
|
2007-06-15 13:34:50 -06:00
|
|
|
winX += DisplayWidth(XtDisplay(tw), DefaultScreen(XtDisplay(tw)))
|
2010-08-22 07:38:11 -06:00
|
|
|
- (int) width - (BorderWidth(SHELL_OF(xw)) * 2);
|
2006-11-26 04:11:12 -07:00
|
|
|
if ((pr & YValue) && (pr & YNegative))
|
2007-06-15 13:34:50 -06:00
|
|
|
winY += DisplayHeight(XtDisplay(tw), DefaultScreen(XtDisplay(tw)))
|
2010-08-22 07:38:11 -06:00
|
|
|
- (int) height - (BorderWidth(SHELL_OF(xw)) * 2);
|
2006-11-26 04:11:12 -07:00
|
|
|
|
|
|
|
/* set up size hints */
|
|
|
|
tw->hints.min_width = TEKMINWIDTH + border;
|
|
|
|
tw->hints.min_height = TEKMINHEIGHT + border;
|
|
|
|
tw->hints.width_inc = 1;
|
|
|
|
tw->hints.height_inc = 1;
|
|
|
|
tw->hints.flags = PMinSize | PResizeInc;
|
|
|
|
tw->hints.x = winX;
|
|
|
|
tw->hints.y = winY;
|
|
|
|
if ((XValue & pr) || (YValue & pr)) {
|
|
|
|
tw->hints.flags |= USSize | USPosition;
|
|
|
|
tw->hints.flags |= PWinGravity;
|
|
|
|
switch (pr & (XNegative | YNegative)) {
|
|
|
|
case 0:
|
|
|
|
tw->hints.win_gravity = NorthWestGravity;
|
|
|
|
break;
|
|
|
|
case XNegative:
|
|
|
|
tw->hints.win_gravity = NorthEastGravity;
|
|
|
|
break;
|
|
|
|
case YNegative:
|
|
|
|
tw->hints.win_gravity = SouthWestGravity;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
tw->hints.win_gravity = SouthEastGravity;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* set a default size, but do *not* set position */
|
|
|
|
tw->hints.flags |= PSize;
|
|
|
|
}
|
2009-09-05 09:58:09 -06:00
|
|
|
tw->hints.width = (int) width;
|
|
|
|
tw->hints.height = (int) height;
|
2006-11-26 04:11:12 -07:00
|
|
|
if ((WidthValue & pr) || (HeightValue & pr))
|
|
|
|
tw->hints.flags |= USSize;
|
|
|
|
else
|
|
|
|
tw->hints.flags |= PSize;
|
|
|
|
|
2008-08-25 12:05:56 -06:00
|
|
|
(void) REQ_RESIZE((Widget) tw,
|
2009-09-05 09:58:09 -06:00
|
|
|
(Dimension) width, (Dimension) height,
|
2008-08-25 12:05:56 -06:00
|
|
|
&tw->core.width, &tw->core.height);
|
2006-11-26 04:11:12 -07:00
|
|
|
|
|
|
|
/* 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 (tw->hints.flags & USPosition)
|
|
|
|
XMoveWindow(XtDisplay(tw), TShellWindow, tw->hints.x, tw->hints.y);
|
|
|
|
|
|
|
|
XSetWMNormalHints(XtDisplay(tw), TShellWindow, &tw->hints);
|
|
|
|
XFlush(XtDisplay(tw)); /* get it out to window manager */
|
|
|
|
|
|
|
|
values->win_gravity = NorthWestGravity;
|
|
|
|
values->background_pixel = T_COLOR(screen, TEK_BG);
|
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
XtWindow(tw) = TWindow(tekscr) =
|
|
|
|
XCreateWindow(XtDisplay(tw),
|
2011-03-07 13:41:27 -07:00
|
|
|
VShellWindow(tw),
|
2006-11-26 04:11:12 -07:00
|
|
|
tw->core.x, tw->core.y,
|
|
|
|
tw->core.width, tw->core.height,
|
|
|
|
BorderWidth(tw),
|
|
|
|
(int) tw->core.depth,
|
|
|
|
InputOutput, CopyFromParent,
|
|
|
|
((*valuemaskp) | CWBackPixel | CWWinGravity),
|
|
|
|
values);
|
|
|
|
|
2009-03-09 16:13:04 -06:00
|
|
|
TFullWidth(tekscr) = (Dimension) width;
|
|
|
|
TFullHeight(tekscr) = (Dimension) height;
|
2009-09-05 09:58:09 -06:00
|
|
|
TWidth(tekscr) = (int) width - border;
|
|
|
|
THeight(tekscr) = (int) height - border;
|
2007-06-15 13:34:50 -06:00
|
|
|
TekScale(tekscr) = (double) TWidth(tekscr) / TEKWIDTH;
|
|
|
|
if ((d = (double) THeight(tekscr) / (TEKHEIGHT + TEKTOPPAD +
|
|
|
|
TEKBOTTOMPAD)) < TekScale(tekscr))
|
|
|
|
TekScale(tekscr) = d;
|
2006-11-26 04:11:12 -07:00
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
tekscr->cur.fontsize = TEK_FONT_LARGE;
|
2006-11-26 04:11:12 -07:00
|
|
|
if (tw->tek.initial_font) {
|
2007-06-15 13:34:50 -06:00
|
|
|
int result = TekGetFontSize(tw->tek.initial_font);
|
|
|
|
if (result >= 0)
|
|
|
|
tekscr->cur.fontsize = result;
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
#define TestGIN(s) XmuCompareISOLatin1(tw->tek.gin_terminator_str, s)
|
|
|
|
|
|
|
|
if (TestGIN(GIN_TERM_NONE_STR) == 0)
|
2007-06-15 13:34:50 -06:00
|
|
|
tekscr->gin_terminator = GIN_TERM_NONE;
|
2006-11-26 04:11:12 -07:00
|
|
|
else if (TestGIN(GIN_TERM_CR_STR) == 0)
|
2007-06-15 13:34:50 -06:00
|
|
|
tekscr->gin_terminator = GIN_TERM_CR;
|
2006-11-26 04:11:12 -07:00
|
|
|
else if (TestGIN(GIN_TERM_EOT_STR) == 0)
|
2007-06-15 13:34:50 -06:00
|
|
|
tekscr->gin_terminator = GIN_TERM_EOT;
|
2006-11-26 04:11:12 -07:00
|
|
|
else
|
2012-04-14 03:02:46 -06:00
|
|
|
xtermWarning("illegal GIN terminator setting \"%s\"\n",
|
|
|
|
tw->tek.gin_terminator_str);
|
2006-11-26 04:11:12 -07:00
|
|
|
|
|
|
|
gcv.graphics_exposures = True; /* default */
|
2007-06-15 13:34:50 -06:00
|
|
|
gcv.font = tw->tek.Tfont[tekscr->cur.fontsize]->fid;
|
2006-11-26 04:11:12 -07:00
|
|
|
gcv.foreground = T_COLOR(screen, TEK_FG);
|
|
|
|
gcv.background = T_COLOR(screen, TEK_BG);
|
|
|
|
|
|
|
|
/* 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.
|
|
|
|
*/
|
2009-09-05 09:58:09 -06:00
|
|
|
TEKgcFontMask = (unsigned long) ((gcv.font == DefaultGCID) ? 0 : GCFont);
|
2007-06-15 13:34:50 -06:00
|
|
|
tekscr->TnormalGC = XCreateGC(XtDisplay(tw), TWindow(tekscr),
|
2006-11-26 04:11:12 -07:00
|
|
|
(TEKgcFontMask | GCGraphicsExposures |
|
|
|
|
GCForeground | GCBackground),
|
|
|
|
&gcv);
|
|
|
|
|
|
|
|
gcv.function = GXinvert;
|
|
|
|
gcv.plane_mask = (T_COLOR(screen, TEK_BG) ^
|
|
|
|
T_COLOR(screen, TEK_CURSOR));
|
|
|
|
gcv.join_style = JoinMiter; /* default */
|
|
|
|
gcv.line_width = 1;
|
2007-06-15 13:34:50 -06:00
|
|
|
tekscr->TcursorGC = XCreateGC(XtDisplay(tw), TWindow(tekscr),
|
2006-11-26 04:11:12 -07:00
|
|
|
(GCFunction | GCPlaneMask), &gcv);
|
|
|
|
|
|
|
|
gcv.foreground = T_COLOR(screen, TEK_FG);
|
|
|
|
gcv.line_style = LineOnOffDash;
|
|
|
|
gcv.line_width = 0;
|
|
|
|
for (i = 0; i < TEKNUMLINES; i++) {
|
2007-06-15 13:34:50 -06:00
|
|
|
tekscr->linepat[i] = XCreateGC(XtDisplay(tw), TWindow(tekscr),
|
2006-11-26 04:11:12 -07:00
|
|
|
(GCForeground | GCLineStyle), &gcv);
|
2007-06-15 13:34:50 -06:00
|
|
|
XSetDashes(XtDisplay(tw), tekscr->linepat[i], 0,
|
2006-11-26 04:11:12 -07:00
|
|
|
(char *) dashes[i], dash_length[i]);
|
|
|
|
}
|
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
TekBackground(tw, screen);
|
2006-11-26 04:11:12 -07:00
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
tekscr->margin = MARGIN1; /* Margin 1 */
|
|
|
|
tekscr->TekGIN = False; /* GIN off */
|
2006-11-26 04:11:12 -07:00
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
XDefineCursor(XtDisplay(tw), TWindow(tekscr), tekscr->arrow);
|
2006-11-26 04:11:12 -07:00
|
|
|
|
|
|
|
{ /* 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(SHELL_OF(tw), args, 2);
|
2009-03-09 16:13:04 -06:00
|
|
|
tek_icon_name = XtMalloc((Cardinal) strlen(icon_name) + 7);
|
2006-11-26 04:11:12 -07:00
|
|
|
strcpy(tek_icon_name, icon_name);
|
|
|
|
strcat(tek_icon_name, "(Tek)");
|
2009-03-09 16:13:04 -06:00
|
|
|
tek_title = XtMalloc((Cardinal) strlen(title) + 7);
|
2006-11-26 04:11:12 -07:00
|
|
|
strcpy(tek_title, title);
|
|
|
|
strcat(tek_title, "(Tek)");
|
|
|
|
args[0].value = (XtArgVal) tek_icon_name;
|
|
|
|
args[1].value = (XtArgVal) tek_title;
|
|
|
|
XtSetValues(SHELL_OF(tw), args, 2);
|
|
|
|
XtFree(tek_icon_name);
|
|
|
|
XtFree(tek_title);
|
|
|
|
}
|
|
|
|
|
|
|
|
tek = TekRecord = &Tek0;
|
|
|
|
tek->next = (TekLink *) 0;
|
2009-03-09 16:13:04 -06:00
|
|
|
tek->fontsize = (unsigned short) tekscr->cur.fontsize;
|
2006-11-26 04:11:12 -07:00
|
|
|
tek->count = 0;
|
|
|
|
tek->ptr = tek->data;
|
|
|
|
Tpushback = Tpushb;
|
2007-06-15 13:34:50 -06:00
|
|
|
tekscr->cur_X = 0;
|
|
|
|
tekscr->cur_Y = TEKHOME;
|
2006-11-26 04:11:12 -07:00
|
|
|
line_pt = Tline;
|
|
|
|
Ttoggled = True;
|
2007-06-15 13:34:50 -06:00
|
|
|
tekscr->page = tekscr->cur;
|
2006-11-26 04:11:12 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
int
|
|
|
|
TekGetFontSize(const char *param)
|
2006-11-26 04:11:12 -07:00
|
|
|
{
|
2007-06-15 13:34:50 -06:00
|
|
|
int result;
|
|
|
|
|
|
|
|
if (XmuCompareISOLatin1(param, "l") == 0 ||
|
|
|
|
XmuCompareISOLatin1(param, "large") == 0)
|
|
|
|
result = TEK_FONT_LARGE;
|
|
|
|
else if (XmuCompareISOLatin1(param, "2") == 0 ||
|
|
|
|
XmuCompareISOLatin1(param, "two") == 0)
|
|
|
|
result = TEK_FONT_2;
|
|
|
|
else if (XmuCompareISOLatin1(param, "3") == 0 ||
|
|
|
|
XmuCompareISOLatin1(param, "three") == 0)
|
|
|
|
result = TEK_FONT_3;
|
|
|
|
else if (XmuCompareISOLatin1(param, "s") == 0 ||
|
|
|
|
XmuCompareISOLatin1(param, "small") == 0)
|
|
|
|
result = TEK_FONT_SMALL;
|
|
|
|
else
|
|
|
|
result = -1;
|
2006-11-26 04:11:12 -07:00
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
return result;
|
|
|
|
}
|
2006-11-26 04:11:12 -07:00
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
void
|
2009-09-05 09:58:09 -06:00
|
|
|
TekSetFontSize(TekWidget tw, Bool fromMenu, int newitem)
|
2007-06-15 13:34:50 -06:00
|
|
|
{
|
|
|
|
if (tw != 0) {
|
2010-08-22 07:38:11 -06:00
|
|
|
XtermWidget xw = term;
|
2007-06-15 13:34:50 -06:00
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
|
|
|
int oldsize = tekscr->cur.fontsize;
|
|
|
|
int newsize = MI2FS(newitem);
|
|
|
|
Font fid;
|
|
|
|
|
2009-04-04 09:10:44 -06:00
|
|
|
TRACE(("TekSetFontSize(%d) size %d ->%d\n", newitem, oldsize, newsize));
|
2007-06-15 13:34:50 -06:00
|
|
|
if (newsize < 0 || newsize >= TEKNUMFONTS) {
|
2010-08-22 07:38:11 -06:00
|
|
|
Bell(xw, XkbBI_MinorError, 0);
|
2007-06-15 13:34:50 -06:00
|
|
|
} else if (oldsize != newsize) {
|
|
|
|
if (!Ttoggled)
|
|
|
|
TCursorToggle(tw, TOGGLE);
|
|
|
|
set_tekfont_menu_item(oldsize, False);
|
|
|
|
|
2009-04-04 09:10:44 -06:00
|
|
|
tekscr->cur.fontsize = newsize;
|
2009-09-05 09:58:09 -06:00
|
|
|
if (fromMenu)
|
|
|
|
tekscr->page.fontsize = newsize;
|
2009-04-04 09:10:44 -06:00
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
fid = tw->tek.Tfont[newsize]->fid;
|
|
|
|
if (fid == DefaultGCID) {
|
|
|
|
/* we didn't succeed in opening a real font
|
|
|
|
for this size. Instead, use server default. */
|
|
|
|
XCopyGC(XtDisplay(tw),
|
|
|
|
DefaultGC(XtDisplay(tw), DefaultScreen(XtDisplay(tw))),
|
|
|
|
GCFont, tekscr->TnormalGC);
|
|
|
|
} else {
|
|
|
|
XSetFont(XtDisplay(tw), tekscr->TnormalGC, fid);
|
|
|
|
}
|
2006-11-26 04:11:12 -07:00
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
set_tekfont_menu_item(newsize, True);
|
|
|
|
if (!Ttoggled)
|
|
|
|
TCursorToggle(tw, TOGGLE);
|
2009-04-04 09:10:44 -06:00
|
|
|
|
2009-09-05 09:58:09 -06:00
|
|
|
if (fromMenu) {
|
|
|
|
/* we'll get an exposure event after changing fontsize, so we
|
|
|
|
* have to clear the screen to avoid painting over the previous
|
|
|
|
* text.
|
|
|
|
*/
|
|
|
|
TekClear(tw);
|
|
|
|
}
|
2007-06-15 13:34:50 -06:00
|
|
|
}
|
|
|
|
}
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-06-15 13:34:50 -06:00
|
|
|
ChangeTekColors(TekWidget tw, TScreen * screen, ScrnColors * pNew)
|
2006-11-26 04:11:12 -07:00
|
|
|
{
|
2007-06-15 13:34:50 -06:00
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
int i;
|
|
|
|
XGCValues gcv;
|
|
|
|
|
|
|
|
if (COLOR_DEFINED(pNew, TEK_FG)) {
|
|
|
|
T_COLOR(screen, TEK_FG) = COLOR_VALUE(pNew, TEK_FG);
|
|
|
|
TRACE(("... TEK_FG: %#lx\n", T_COLOR(screen, TEK_FG)));
|
|
|
|
}
|
|
|
|
if (COLOR_DEFINED(pNew, TEK_BG)) {
|
|
|
|
T_COLOR(screen, TEK_BG) = COLOR_VALUE(pNew, TEK_BG);
|
|
|
|
TRACE(("... TEK_BG: %#lx\n", T_COLOR(screen, TEK_BG)));
|
|
|
|
}
|
|
|
|
if (COLOR_DEFINED(pNew, TEK_CURSOR)) {
|
|
|
|
T_COLOR(screen, TEK_CURSOR) = COLOR_VALUE(pNew, TEK_CURSOR);
|
|
|
|
TRACE(("... TEK_CURSOR: %#lx\n", T_COLOR(screen, TEK_CURSOR)));
|
|
|
|
} else {
|
|
|
|
T_COLOR(screen, TEK_CURSOR) = T_COLOR(screen, TEK_FG);
|
|
|
|
TRACE(("... TEK_CURSOR: %#lx\n", T_COLOR(screen, TEK_CURSOR)));
|
|
|
|
}
|
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
if (tw) {
|
|
|
|
XSetForeground(XtDisplay(tw), tekscr->TnormalGC,
|
2006-11-26 04:11:12 -07:00
|
|
|
T_COLOR(screen, TEK_FG));
|
2007-06-15 13:34:50 -06:00
|
|
|
XSetBackground(XtDisplay(tw), tekscr->TnormalGC,
|
2006-11-26 04:11:12 -07:00
|
|
|
T_COLOR(screen, TEK_BG));
|
2007-06-15 13:34:50 -06:00
|
|
|
if (BorderPixel(tw) == T_COLOR(screen, TEK_BG)) {
|
|
|
|
BorderPixel(tw) = T_COLOR(screen, TEK_FG);
|
|
|
|
BorderPixel(XtParent(tw)) = T_COLOR(screen, TEK_FG);
|
|
|
|
if (XtWindow(XtParent(tw)))
|
|
|
|
XSetWindowBorder(XtDisplay(tw),
|
|
|
|
XtWindow(XtParent(tw)),
|
|
|
|
BorderPixel(tw));
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < TEKNUMLINES; i++) {
|
2007-06-15 13:34:50 -06:00
|
|
|
XSetForeground(XtDisplay(tw), tekscr->linepat[i],
|
2006-11-26 04:11:12 -07:00
|
|
|
T_COLOR(screen, TEK_FG));
|
|
|
|
}
|
|
|
|
|
|
|
|
gcv.plane_mask = (T_COLOR(screen, TEK_BG) ^
|
|
|
|
T_COLOR(screen, TEK_CURSOR));
|
2007-06-15 13:34:50 -06:00
|
|
|
XChangeGC(XtDisplay(tw), tekscr->TcursorGC, GCPlaneMask, &gcv);
|
|
|
|
TekBackground(tw, screen);
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-06-15 13:34:50 -06:00
|
|
|
TekReverseVideo(TekWidget tw)
|
2006-11-26 04:11:12 -07:00
|
|
|
{
|
2010-08-22 07:38:11 -06:00
|
|
|
XtermWidget xw = term;
|
|
|
|
TScreen *screen = TScreenOf(xw);
|
2007-06-15 13:34:50 -06:00
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
int i;
|
2009-03-09 16:13:04 -06:00
|
|
|
Pixel tmp;
|
2006-11-26 04:11:12 -07:00
|
|
|
XGCValues gcv;
|
|
|
|
|
2009-03-09 16:13:04 -06:00
|
|
|
EXCHANGE(T_COLOR(screen, TEK_FG), T_COLOR(screen, TEK_BG), tmp);
|
2006-11-26 04:11:12 -07:00
|
|
|
|
|
|
|
T_COLOR(screen, TEK_CURSOR) = T_COLOR(screen, TEK_FG);
|
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
if (tw) {
|
|
|
|
XSetForeground(XtDisplay(tw), tekscr->TnormalGC, T_COLOR(screen, TEK_FG));
|
|
|
|
XSetBackground(XtDisplay(tw), tekscr->TnormalGC, T_COLOR(screen, TEK_BG));
|
|
|
|
|
|
|
|
if (BorderPixel(tw) == T_COLOR(screen, TEK_BG)) {
|
|
|
|
BorderPixel(tw) = T_COLOR(screen, TEK_FG);
|
|
|
|
BorderPixel(XtParent(tw)) = T_COLOR(screen, TEK_FG);
|
|
|
|
if (XtWindow(XtParent(tw)))
|
|
|
|
XSetWindowBorder(XtDisplay(tw),
|
|
|
|
XtWindow(XtParent(tw)),
|
|
|
|
BorderPixel(tw));
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < TEKNUMLINES; i++) {
|
2007-06-15 13:34:50 -06:00
|
|
|
XSetForeground(XtDisplay(tw), tekscr->linepat[i],
|
2006-11-26 04:11:12 -07:00
|
|
|
T_COLOR(screen, TEK_FG));
|
|
|
|
}
|
|
|
|
|
|
|
|
gcv.plane_mask = (T_COLOR(screen, TEK_BG) ^
|
|
|
|
T_COLOR(screen, TEK_CURSOR));
|
2007-06-15 13:34:50 -06:00
|
|
|
XChangeGC(XtDisplay(tw), tekscr->TcursorGC, GCPlaneMask, &gcv);
|
|
|
|
TekBackground(tw, screen);
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-06-15 13:34:50 -06:00
|
|
|
TekBackground(TekWidget tw, TScreen * screen)
|
2006-11-26 04:11:12 -07:00
|
|
|
{
|
2007-06-15 13:34:50 -06:00
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
|
|
|
|
|
|
|
if (TWindow(tekscr))
|
|
|
|
XSetWindowBackground(XtDisplay(tw), TWindow(tekscr),
|
2006-11-26 04:11:12 -07:00
|
|
|
T_COLOR(screen, TEK_BG));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Toggles cursor on or off at cursor position in screen.
|
|
|
|
*/
|
|
|
|
void
|
2007-06-15 13:34:50 -06:00
|
|
|
TCursorToggle(TekWidget tw, int toggle) /* TOGGLE or CLEAR */
|
2006-11-26 04:11:12 -07:00
|
|
|
{
|
2010-08-22 07:38:11 -06:00
|
|
|
XtermWidget xw = term;
|
2007-06-15 13:34:50 -06:00
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
2010-08-22 07:38:11 -06:00
|
|
|
TScreen *screen = TScreenOf(xw);
|
2006-11-26 04:11:12 -07:00
|
|
|
int c, x, y;
|
|
|
|
unsigned int cellwidth, cellheight;
|
|
|
|
|
2010-08-22 07:38:11 -06:00
|
|
|
if (!TEK4014_SHOWN(xw))
|
2006-11-26 04:11:12 -07:00
|
|
|
return;
|
|
|
|
|
2009-04-04 09:10:44 -06:00
|
|
|
TRACE(("TCursorToggle %s\n", (toggle == TOGGLE) ? "toggle" : "clear"));
|
2007-06-15 13:34:50 -06:00
|
|
|
c = tekscr->cur.fontsize;
|
|
|
|
cellwidth = (unsigned) tw->tek.Tfont[c]->max_bounds.width;
|
|
|
|
cellheight = (unsigned) (tw->tek.Tfont[c]->ascent +
|
|
|
|
tw->tek.Tfont[c]->descent);
|
2006-11-26 04:11:12 -07:00
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
x = (int) ((tekscr->cur_X * TekScale(tekscr)) + screen->border);
|
|
|
|
y = (int) (((TEKHEIGHT + TEKTOPPAD - tekscr->cur_Y) * TekScale(tekscr))
|
|
|
|
+ screen->border - tw->tek.tobaseline[c]);
|
2006-11-26 04:11:12 -07:00
|
|
|
|
|
|
|
if (toggle == TOGGLE) {
|
|
|
|
if (screen->select || screen->always_highlight)
|
2007-06-15 13:34:50 -06:00
|
|
|
XFillRectangle(XtDisplay(tw), TWindow(tekscr),
|
|
|
|
tekscr->TcursorGC, x, y,
|
2006-11-26 04:11:12 -07:00
|
|
|
cellwidth, cellheight);
|
|
|
|
else { /* fix to use different GC! */
|
2007-06-15 13:34:50 -06:00
|
|
|
XDrawRectangle(XtDisplay(tw), TWindow(tekscr),
|
|
|
|
tekscr->TcursorGC, x, y,
|
2006-11-26 04:11:12 -07:00
|
|
|
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.
|
|
|
|
*/
|
2007-06-15 13:34:50 -06:00
|
|
|
XClearArea(XtDisplay(tw), TWindow(tekscr), x, y,
|
2006-11-26 04:11:12 -07:00
|
|
|
cellwidth, cellheight, False);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-06-15 13:34:50 -06:00
|
|
|
TekSimulatePageButton(TekWidget tw, Bool reset)
|
2006-11-26 04:11:12 -07:00
|
|
|
{
|
2007-06-15 13:34:50 -06:00
|
|
|
if (tw != 0) {
|
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
2006-11-26 04:11:12 -07:00
|
|
|
|
2007-06-15 13:34:50 -06:00
|
|
|
if (reset) {
|
2009-09-05 09:58:09 -06:00
|
|
|
memset(&tekscr->cur, 0, sizeof tekscr->cur);
|
2007-06-15 13:34:50 -06:00
|
|
|
}
|
|
|
|
tekRefreshList = (TekLink *) 0;
|
|
|
|
TekPage(tw);
|
|
|
|
tekscr->cur_X = 0;
|
|
|
|
tekscr->cur_Y = TEKHOME;
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* write copy of screen to a file */
|
|
|
|
|
|
|
|
void
|
2007-06-15 13:34:50 -06:00
|
|
|
TekCopy(TekWidget tw)
|
2006-11-26 04:11:12 -07:00
|
|
|
{
|
2007-08-25 12:58:42 -06:00
|
|
|
if (tw != 0) {
|
2010-08-22 07:38:11 -06:00
|
|
|
XtermWidget xw = term;
|
2007-08-25 12:58:42 -06:00
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
2010-08-22 07:38:11 -06:00
|
|
|
TScreen *screen = TScreenOf(xw);
|
2006-11-26 04:11:12 -07:00
|
|
|
|
2007-08-25 12:58:42 -06:00
|
|
|
TekLink *Tp;
|
2011-08-18 13:47:42 -06:00
|
|
|
char buf[TIMESTAMP_LEN + 10];
|
2007-08-25 12:58:42 -06:00
|
|
|
char initbuf[5];
|
|
|
|
int tekcopyfd;
|
2006-11-26 04:11:12 -07:00
|
|
|
|
2007-08-25 12:58:42 -06:00
|
|
|
timestamp_filename(buf, "COPY");
|
|
|
|
if (access(buf, F_OK) >= 0
|
|
|
|
&& access(buf, W_OK) < 0) {
|
2010-08-22 07:38:11 -06:00
|
|
|
Bell(xw, XkbBI_MinorError, 0);
|
2007-08-25 12:58:42 -06:00
|
|
|
return;
|
|
|
|
}
|
2006-11-26 04:11:12 -07:00
|
|
|
#ifndef VMS
|
2007-08-25 12:58:42 -06:00
|
|
|
if (access(".", W_OK) < 0) { /* can't write in directory */
|
2010-08-22 07:38:11 -06:00
|
|
|
Bell(xw, XkbBI_MinorError, 0);
|
2007-08-25 12:58:42 -06:00
|
|
|
return;
|
|
|
|
}
|
2006-11-26 04:11:12 -07:00
|
|
|
#endif
|
|
|
|
|
2007-08-25 12:58:42 -06:00
|
|
|
tekcopyfd = open_userfile(screen->uid, screen->gid, buf, False);
|
|
|
|
if (tekcopyfd >= 0) {
|
|
|
|
sprintf(initbuf, "%c%c%c%c",
|
|
|
|
ANSI_ESC, (char) (tekscr->page.fontsize + '8'),
|
|
|
|
ANSI_ESC, (char) (tekscr->page.linetype + '`'));
|
2009-10-31 08:11:57 -06:00
|
|
|
IGNORE_RC(write(tekcopyfd, initbuf, (size_t) 4));
|
2007-08-25 12:58:42 -06:00
|
|
|
Tp = &Tek0;
|
|
|
|
do {
|
2009-10-31 08:11:57 -06:00
|
|
|
IGNORE_RC(write(tekcopyfd, Tp->data, (size_t) Tp->count));
|
2007-08-25 12:58:42 -06:00
|
|
|
Tp = Tp->next;
|
|
|
|
} while (Tp);
|
|
|
|
close(tekcopyfd);
|
|
|
|
}
|
2006-11-26 04:11:12 -07:00
|
|
|
}
|
|
|
|
}
|
2007-06-15 13:34:50 -06:00
|
|
|
|
|
|
|
/*ARGSUSED*/
|
|
|
|
void
|
|
|
|
HandleGINInput(Widget w,
|
|
|
|
XEvent * event GCC_UNUSED,
|
|
|
|
String * param_list,
|
|
|
|
Cardinal *nparamsp)
|
|
|
|
{
|
2010-08-22 07:38:11 -06:00
|
|
|
XtermWidget xw = term;
|
2009-04-04 09:10:44 -06:00
|
|
|
TekWidget tw = getTekWidget(w);
|
2010-08-22 07:38:11 -06:00
|
|
|
|
2009-04-04 09:10:44 -06:00
|
|
|
if (tw != 0) {
|
2007-06-15 13:34:50 -06:00
|
|
|
TekScreen *tekscr = TekScreenOf(tw);
|
|
|
|
|
|
|
|
if (tekscr->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:
|
2010-08-22 07:38:11 -06:00
|
|
|
Bell(xw, XkbBI_MinorError, 0); /* let them know they goofed */
|
2007-06-15 13:34:50 -06:00
|
|
|
c = 'l'; /* provide a default */
|
|
|
|
}
|
|
|
|
TekEnqMouse(tw, c | 0x80);
|
|
|
|
TekGINoff(tw);
|
|
|
|
} else {
|
2010-08-22 07:38:11 -06:00
|
|
|
Bell(xw, XkbBI_MinorError, 0);
|
2007-06-15 13:34:50 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-04-04 09:10:44 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if the current widget, or any parent, is the VT100 "xterm" widget.
|
|
|
|
*/
|
|
|
|
TekWidget
|
|
|
|
getTekWidget(Widget w)
|
|
|
|
{
|
|
|
|
TekWidget xw;
|
|
|
|
|
|
|
|
if (w == 0) {
|
|
|
|
xw = (TekWidget) CURRENT_EMU();
|
|
|
|
if (!IsTekWidget(xw)) {
|
|
|
|
xw = 0;
|
|
|
|
}
|
|
|
|
} else if (IsTekWidget(w)) {
|
|
|
|
xw = (TekWidget) w;
|
|
|
|
} else {
|
|
|
|
xw = getTekWidget(XtParent(w));
|
|
|
|
}
|
|
|
|
TRACE2(("getTekWidget %p -> %p\n", w, xw));
|
|
|
|
return xw;
|
|
|
|
}
|