/* * CDE - Common Desktop Environment * * Copyright (c) 1993-2012, The Open Group. All rights reserved. * * These libraries and programs are free software; you can * redistribute them and/or modify them under the terms of the GNU * Lesser General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) * any later version. * * These libraries and programs are distributed in the hope that * they will be useful, but WITHOUT ANY WARRANTY; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public * License along with these libraries and programs; if not, write * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth * Floor, Boston, MA 02110-1301 USA */ /* * * (c) Copyright 1993, 1994, 1996 Hewlett-Packard Company * * (c) Copyright 1993, 1994, 1996 International Business Machines Corp. * * (c) Copyright 1993, 1994, 1996 Sun Microsystems, Inc. * * (c) Copyright 1993, 1994, 1996 Novell, Inc. * * (c) Copyright 1996 Digital Equipment Corporation. * * (c) Copyright 1996 FUJITSU LIMITED. * * (c) Copyright 1996 Hitachi. * */ extern char _DtTermPullInTermWhatString[]; static char *termWhatString = _DtTermPullInTermWhatString; #include "TermHeader.h" #include "TermPrimDebug.h" #include "TermP.h" #include "TermPrimAction.h" #include "TermData.h" #include "TermBufferP.h" #include "TermAction.h" #include "TermParseTable.h" #include "TermPrimLineFontP.h" #include "TermLineData.h" #include "TermColor.h" #include "TermFunctionKey.h" #include "TermPrimRenderLineDraw.h" #include "TermPrimMessageCatI.h" #include "TermPrimSelectP.h" static int TextInsertProc(Widget w, unsigned char *buffer, int length); static void Resize(Widget w); static void ClassInitialize(void); static void ClassPartInitialize(WidgetClass wc); static void Initialize(Widget rw, Widget nw, Arg *args, Cardinal *num_args); static Boolean SetValues(Widget cw, Widget rw, Widget nw, ArgList args, Cardinal *num_args); static void Realize(Widget w, XtValueMask *p_valueMask, XSetWindowAttributes *attributes); static void Destroy(Widget w); static void InitializeVerticalScrollBar(Widget w, Boolean initCallbacks); static void VerticalScrollBarCallback(Widget w, XtPointer client_data, XtPointer call_data); static void StatusChangeNotify(Widget w, unsigned long mask); static void PositionUpdate(Widget w, short row, short column); static void GetAutoWrap( Widget wid, int offset, XtArgVal *value) ; static XmImportOperator SetAutoWrap( Widget wid, int offset, XtArgVal *value) ; static void GetReverseWrap( Widget wid, int offset, XtArgVal *value) ; static XmImportOperator SetReverseWrap( Widget wid, int offset, XtArgVal *value) ; static void GetAppCursorMode( Widget wid, int offset, XtArgVal *value ); static XmImportOperator SetAppCursorMode( Widget wid, int offset, XtArgVal *value ); static void GetAppKeypadMode( Widget wid, int offset, XtArgVal *value ); static XmImportOperator SetAppKeypadMode( Widget wid, int offset, XtArgVal *value ); /* action list for class: Term... */ static XtActionsRec actionsList[] = { {"beginning-of-buffer", _DtTermActionBeginningOfBuffer}, {"vt-break", _DtTermActionBreak}, {"end-of-buffer", _DtTermActionEndOfBuffer}, {"vt-function-key-execute", _DtTermActionFunctionKeyExecute}, {"hard-reset", _DtTermActionHardReset}, {"insert-line", _DtTermActionInsertLine}, {"keypad-key-execute", _DtTermActionKeypadKeyExecute}, {"move-cursor", _DtTermActionMoveCursor}, {"scroll", _DtTermActionScroll}, {"soft-reset", _DtTermActionSoftReset}, {"tab", _DtTermActionTab}, {"vt-edit-key", _DtTermActionEditKeyExecute}, {"process-press", _DtTermPrimSelect2ButtonMouse}, }; /* the resource list for Term... */ static XtResource resources[] = { { DtNsunFunctionKeys, DtCSunFunctionKeys, XmRBoolean, sizeof(Boolean), XtOffsetOf(struct _DtTermRec, vt.sunFunctionKeys), XtRImmediate, (XtPointer) False }, { DtNautoWrap, DtCAutoWrap, XmRBoolean, sizeof(Boolean), XtOffsetOf(struct _DtTermRec, vt.autoWrap), XtRImmediate, (XtPointer) True }, { DtNreverseWrap, DtCReverseWrap, XmRBoolean, sizeof(Boolean), XtOffsetOf(struct _DtTermRec, vt.reverseWrap), XtRImmediate, (XtPointer) False }, { DtNemulationId, DtCEmulationId, XmRString, sizeof(char *), XtOffsetOf( struct _DtTermPrimitiveRec, term.emulationId), XtRImmediate, (XtPointer) "DtTermWidget" }, { DtNtermId, DtCTermId, XmRString, sizeof(char *), XtOffsetOf( struct _DtTermPrimitiveRec, term.termId), XtRImmediate, (XtPointer) "vt220" }, { DtNtermName, DtCTermName, XmRString, sizeof(char *), XtOffsetOf( struct _DtTermPrimitiveRec, term.termName), XtRImmediate, (XtPointer) "dtterm" }, { DtNc132, DtCC132, XmRBoolean, sizeof(Boolean), XtOffsetOf(struct _DtTermRec, vt.c132), XtRImmediate, (XtPointer) False }, { DtNappCursorDefault, DtCAppCursorDefault, XmRBoolean, sizeof(Boolean), XtOffsetOf(struct _DtTermRec, vt.appCursorMode), XtRImmediate, (XtPointer) False }, { DtNappKeypadDefault, DtCAppKeypadDefault, XmRBoolean, sizeof(Boolean), XtOffsetOf(struct _DtTermRec, vt.appKeypadMode), XtRImmediate, (XtPointer) False }, #ifdef DKS { DtNstickyPrevCursor, DtCStickyCursor, XmRBoolean, sizeof(Boolean), XtOffsetOf(struct _DtTermRec, vt.stickyPrevCursor), XtRImmediate, (XtPointer) False }, { DtNstickyNextCursor, DtCStickyCursor, XmRBoolean, sizeof(Boolean), XtOffsetOf(struct _DtTermRec, vt.stickyNextCursor), XtRImmediate, (XtPointer) False }, { DtNstatusChangeCallback, DtCCallback, XmRCallback, sizeof(XtCallbackList), XtOffsetOf( struct _DtTermRec, vt.statusChangeCallback), XmRPointer, (XtPointer) NULL }, { DtNverticalScrollBar, DtCVerticalScrollBar, XmRWidget, sizeof(Widget), XtOffsetOf( struct _DtTermRec, vt.verticalScrollBar), XmRImmediate, (XtPointer) NULL }, #endif /* DKS */ }; /**************** * * Synthetic resources for those ugly wart variables... * ****************/ static XmSyntheticResource GetResources[] = { { DtNautoWrap, sizeof (Boolean), XtOffsetOf(struct _DtTermRec, vt.autoWrap), GetAutoWrap, SetAutoWrap }, { DtNreverseWrap, sizeof (Boolean), XtOffsetOf(struct _DtTermRec, vt.reverseWrap), GetReverseWrap, SetReverseWrap }, { DtNappCursorDefault, sizeof (Boolean), XtOffsetOf(struct _DtTermRec, vt.appCursorMode), GetAppCursorMode, SetAppCursorMode }, { DtNappKeypadDefault, sizeof (Boolean), XtOffsetOf(struct _DtTermRec, vt.appKeypadMode), GetAppKeypadMode, SetAppKeypadMode }, }; /* * Goofy debug'ed code by HP. * IBM's JP kbd accepts Shift+KP_Multiply as a valid key sequence. * I don't know why HP added non-exposed(internal) Xt's action ??? * Anyway, remove KP_Multiply entry from defaultTranslations[] */ static char defaultTranslations[] = "\ :osfCancel: process-cancel()\n\ :osfCopy: copy-clipboard()\n\ :osfCut: copy-clipboard()\n\ :osfPaste: paste-clipboard()\n\ :osfBeginLine: beginning-of-buffer()\n\ Home: beginning-of-buffer()\n\ :osfEndLine: end-of-buffer()\n\ End: end-of-buffer()\n\ ShiftosfUp: scroll(1,line)\n\ ShiftUp: scroll(1,line)\n\ ShiftosfDown: scroll(-1,line)\n\ ShiftDown: scroll(-1,line)\n\ :osfUp: move-cursor(up)\n\ Up: move-cursor(up)\n\ :osfDown: move-cursor(down)\n\ Down: move-cursor(down)\n\ :osfLeft: move-cursor(backward)\n\ Left: move-cursor(backward)\n\ :osfRight: move-cursor(forward)\n\ Right: move-cursor(forward)\n\ Find: vt-edit-key(find)\n\ :osfInsert: vt-edit-key(insert)\n\ Insert: vt-edit-key(insert)\n\ :osfDelete: vt-edit-key(delete)\n\ :Delete: vt-edit-key(delete)\n\ :osfSelect: vt-edit-key(select)\n\ Select: vt-edit-key(select)\n\ :~ShiftosfPageUp: vt-edit-key(prior)\n\ ~ShiftPrior: vt-edit-key(prior)\n\ :~ShiftosfPageDown: vt-edit-key(next)\n\ ~ShiftNext: vt-edit-key(next)\n\ Help: vt-edit-key(help)\n\ Menu: vt-edit-key(do)\n\ :osfPageUp: scroll(-1,page)\n\ Prior: scroll(-1,page)\n\ :osfPageDown: scroll(1,page)\n\ Next: scroll(1,page)\n\ Mod1Break: soft-reset()\n\ ShiftBreak: hard-reset()\n\ ~Shift ~Mod1Break: vt-break(long)\n\ CtrlCancel: stop(long)\n\ ~CtrlCancel: stop()\n\ ~ShiftTab: tab()\n\ osfActivate: keypad-key-execute(enter)\n\ KP_Space: keypad-key-execute(space)\n\ KP_Tab: keypad-key-execute(tab)\n\ KP_Enter: keypad-key-execute(enter)\n\ KP_F1: keypad-key-execute(f1)\n\ KP_F2: keypad-key-execute(f2)\n\ KP_F3: keypad-key-execute(f3)\n\ KP_F4: keypad-key-execute(f4)\n\ KP_Equal: keypad-key-execute(equal)\n\ KP_Multiply: keypad-key-execute(multiply)\n\ KP_Add: keypad-key-execute(add)\n\ KP_Separator: keypad-key-execute(separator)\n\ KP_Subtract: keypad-key-execute(subtract)\n\ KP_Decimal: keypad-key-execute(decimal)\n\ KP_Divide: keypad-key-execute(divide)\n\ !Mod1KP_0: insert()\n\ !Mod1KP_1: insert()\n\ !Mod1KP_2: insert()\n\ !Mod1KP_3: insert()\n\ !Mod1KP_4: insert()\n\ !Mod1KP_5: insert()\n\ !Mod1KP_6: insert()\n\ !Mod1KP_7: insert()\n\ !Mod1KP_8: insert()\n\ !Mod1KP_9: insert()\n\ KP_0: keypad-key-execute(0)\n\ KP_1: keypad-key-execute(1)\n\ KP_2: keypad-key-execute(2)\n\ KP_3: keypad-key-execute(3)\n\ KP_4: keypad-key-execute(4)\n\ KP_5: keypad-key-execute(5)\n\ KP_6: keypad-key-execute(6)\n\ KP_7: keypad-key-execute(7)\n\ KP_8: keypad-key-execute(8)\n\ KP_9: keypad-key-execute(9)\n\ ShiftF1: vt-function-key-execute(1, UDK)\n\ ShiftF2: vt-function-key-execute(2, UDK)\n\ ShiftF3: vt-function-key-execute(3, UDK)\n\ ShiftF4: vt-function-key-execute(4, UDK)\n\ ShiftF5: vt-function-key-execute(5, UDK)\n\ ShiftF6: vt-function-key-execute(6, UDK)\n\ ShiftF7: vt-function-key-execute(7, UDK)\n\ ShiftF8: vt-function-key-execute(8, UDK)\n\ ShiftF9: vt-function-key-execute(9, UDK)\n\ ShiftF10: vt-function-key-execute(10, UDK)\n\ ShiftF11: vt-function-key-execute(11, UDK)\n\ ShiftF12: vt-function-key-execute(12, UDK)\n\ ShiftF13: vt-function-key-execute(13, UDK)\n\ ShiftF14: vt-function-key-execute(14, UDK)\n\ ShiftF15: vt-function-key-execute(15, UDK)\n\ ShiftF16: vt-function-key-execute(16, UDK)\n\ ShiftF17: vt-function-key-execute(17, UDK)\n\ ShiftF18: vt-function-key-execute(18, UDK)\n\ ShiftF19: vt-function-key-execute(19, UDK)\n\ ShiftF20: vt-function-key-execute(20, UDK)\n\ ShiftF21: vt-function-key-execute(21, UDK)\n\ ShiftF22: vt-function-key-execute(22, UDK)\n\ ShiftF23: vt-function-key-execute(23, UDK)\n\ ShiftF24: vt-function-key-execute(24, UDK)\n\ ShiftF25: vt-function-key-execute(25, UDK)\n\ ShiftF26: vt-function-key-execute(26, UDK)\n\ ShiftF27: vt-function-key-execute(27, UDK)\n\ ShiftF28: vt-function-key-execute(28, UDK)\n\ ShiftF29: vt-function-key-execute(29, UDK)\n\ ShiftF30: vt-function-key-execute(30, UDK)\n\ ShiftF31: vt-function-key-execute(31, UDK)\n\ ShiftF32: vt-function-key-execute(32, UDK)\n\ ShiftF33: vt-function-key-execute(33, UDK)\n\ ShiftF34: vt-function-key-execute(34, UDK)\n\ ShiftF35: vt-function-key-execute(35, UDK)\n\ ~ShiftF1: vt-function-key-execute(1, function)\n\ ~ShiftF2: vt-function-key-execute(2, function)\n\ ~ShiftF3: vt-function-key-execute(3, function)\n\ ~ShiftF4: vt-function-key-execute(4, function)\n\ ~ShiftF5: vt-function-key-execute(5, function)\n\ ~ShiftF6: vt-function-key-execute(6, function)\n\ ~ShiftF7: vt-function-key-execute(7, function)\n\ ~ShiftF8: vt-function-key-execute(8, function)\n\ ~ShiftF9: vt-function-key-execute(9, function)\n\ ~ShiftF10: vt-function-key-execute(10, function)\n\ ~ShiftF11: vt-function-key-execute(11, function)\n\ ~ShiftF12: vt-function-key-execute(12, function)\n\ ~ShiftF13: vt-function-key-execute(13, function)\n\ ~ShiftF14: vt-function-key-execute(14, function)\n\ ~ShiftF15: vt-function-key-execute(15, function)\n\ ~ShiftF16: vt-function-key-execute(16, function)\n\ ~ShiftF17: vt-function-key-execute(17, function)\n\ ~ShiftF18: vt-function-key-execute(18, function)\n\ ~ShiftF19: vt-function-key-execute(19, function)\n\ ~ShiftF20: vt-function-key-execute(20, function)\n\ ~ShiftF21: vt-function-key-execute(21, function)\n\ ~ShiftF22: vt-function-key-execute(22, function)\n\ ~ShiftF23: vt-function-key-execute(23, function)\n\ ~ShiftF24: vt-function-key-execute(24, function)\n\ ~ShiftF25: vt-function-key-execute(25, function)\n\ ~ShiftF26: vt-function-key-execute(26, function)\n\ ~ShiftF27: vt-function-key-execute(27, function)\n\ ~ShiftF28: vt-function-key-execute(28, function)\n\ ~ShiftF29: vt-function-key-execute(29, function)\n\ ~ShiftF30: vt-function-key-execute(30, function)\n\ ~ShiftF31: vt-function-key-execute(31, function)\n\ ~ShiftF32: vt-function-key-execute(32, function)\n\ ~ShiftF33: vt-function-key-execute(33, function)\n\ ~ShiftF34: vt-function-key-execute(34, function)\n\ ~ShiftF35: vt-function-key-execute(35, function)\n\ : key-release()\n\ : insert()\n\ ~Shift~Ctrl: grab-focus()\n\ Shift~Ctrl: extend-start()\n\ ~Ctrl: select-adjust()\n\ ~Ctrl: extend-end()\n\ ~Shift: process-bdrag()\n\ ~Shift: copy-to()\n\ ~Shift ~Ctrl : scroll(-1,line)\n\ ~Shift ~Ctrl : scroll(1,line)\n\ Shift ~Ctrl : scroll(-3,line)\n\ Shift ~Ctrl : scroll(3,line)\n\ Ctrl ~Shift : scroll(-1,page)\n\ Ctrl ~Shift : scroll(1,page)\n\ : enter()\n\ : leave()\n\ : focus-in()\n\ : focus-out()\n\ "; /* global class record for instances of class: Vt */ externaldef(vtclassrec) DtTermClassRec dtTermClassRec = { /* core class record */ { /* superclass */ (WidgetClass) &dtTermPrimitiveClassRec, /* class_name */ "DtTerm", /* widget_size */ sizeof(DtTermRec), /* class_initialize */ ClassInitialize, /* class_part_init */ ClassPartInitialize, /* class_inited */ FALSE, /* initialize */ Initialize, /* initialize_hook */ (XtArgsProc) NULL, /* realize */ XtInheritRealize, /* actions */ actionsList, /* num_actions */ XtNumber(actionsList), /* resources */ resources, /* num_resources */ XtNumber(resources), /* xrm_class */ NULLQUARK, /* compress_motion */ TRUE, /* compress_exposure */ FALSE, /* compress_enterlv */ TRUE, /* visible_interest */ TRUE, /* destroy */ Destroy, /* resize */ XtInheritResize, /* Resize */ /* expose */ XtInheritExpose, /* set_values */ SetValues, /* set_values_hook */ (XtArgsFunc) NULL, /* set_values_almost */ XtInheritSetValuesAlmost, /* get_values_hook */ (XtArgsProc) NULL, /* accept_focus */ (XtAcceptFocusProc) NULL, /* version */ XtVersion, /* callback_private */ (XtPointer) NULL, /* tm_table */ defaultTranslations, /* query_geometry */ (XtGeometryHandler) NULL, /* display_accelerator */ (XtStringProc) NULL, /* extension */ (XtPointer) NULL, }, /* primitive class rec */ { /* Primitive border_highlight */ XmInheritWidgetProc, /* Primitive border_unhighlight */ XmInheritWidgetProc, /* translations */ "" /*NULL*/ /*XtInheritTranslations*/, /* arm_and_activate */ NULL, /* get resources */ (XmSyntheticResource *) GetResources, /* num get_resources */ XtNumber(GetResources), /* extension */ (XtPointer) NULL, }, /* term class record */ { /* parser_start_state */ &_DtTermStateStart, /* use_history_buffer */ True, /* allow_scroll_below_buffer */ False, /* wrap_right_after_insert */ False, /* buffer_create_proc */ _DtTermBufferCreateBuffer, /* buffer_free_proc */ _DtTermBufferFreeBuffer, /* term_insert_proc */ TextInsertProc, /* sizeOfBuffer */ (short) sizeof(DtTermBufferRec), /* sizeOfLine */ (short) sizeof(DtTermLineRec), /* sizeOfEnh */ (short) sizeof(DtTermEnhPart), }, /* vt class record */ { 0 } }; externaldef(vtwidgetclass) WidgetClass dtTermWidgetClass = (WidgetClass)&dtTermClassRec; /* Class Initialize... */ static void ClassInitialize(void) { return; } static void ClassPartInitialize(WidgetClass w_class) { } /* ** Initialize the modes to their default values... */ static void initializeModes ( DtTermData td ) { td->applicationMode = False; /* Normal mode */ td->applicationKPMode= False; /* Normal mode */ td->tpd->transmitFunctions = True; /* ALWAYS true for ANSI */ td->originMode = False; /* true when origin mode is active */ td->S8C1TMode = False; /* use 7 bit c1 codes */ td->enhFieldState = FIELD_UNPROTECT; /* Vt selective erase mode */ td->fixCursesMode = False; /* xterm fix curses */ td->userKeysLocked = False; /* are User Defined Keys locked? */ td->needToLockUserKeys = False; /* Parser state */ td->saveCursor.cursorRow = 0; /* init for Save Cursor (Esc 7) */ td->saveCursor.cursorColumn = 0; /* init for Save Cursor (Esc 7) */ td->saveCursor.originMode = False; /* init for Save Cursor (Esc 7) */ td->saveCursor.wrapMode = True; /* init for Save Cursor (Esc 7) */ td->saveCursor.enhVideoState = 0; /* init for Save Cursor (Esc 7) */ td->saveCursor.enhFieldState = FIELD_UNPROTECT; td->saveCursor.enhFgColorState = 0; td->saveCursor.enhBgColorState = 0; /* init for Save Cursor (Esc 7) */ td->saveCursor.GL = td->GL; /* init for Save Cursor (Esc 7) */ td->saveCursor.GR = td->GR; /* init for Save Cursor (Esc 7) */ td->saveCursor.G0 = td->G0; /* init for Save Cursor (Esc 7) */ td->saveCursor.G1 = td->G1; /* init for Save Cursor (Esc 7) */ td->saveCursor.G2 = td->G2; /* init for Save Cursor (Esc 7) */ td->saveCursor.G3 = td->G3; /* init for Save Cursor (Esc 7) */ td->saveCursor.singleShiftFont = td->singleShiftFont; td->saveCursor.singleShiftPending = td->singleShiftPending; td->saveDECMode.allow80_132ColMode = False; td->saveDECMode.col132Mode = False; td->saveDECMode.applicationMode = False; td->saveDECMode.applicationKPMode = False; td->saveDECMode.originMode = False; td->saveDECMode.wrapMode = False; td->saveDECMode.jumpScrollMode = True; td->saveDECMode.inverseVideoMode = False; td->saveDECMode.fixCursesMode = False; td->saveDECMode.reverseWrapMode = False; td->saveDECMode.marginBellMode = False; td->saveDECMode.cursorVisible = True; td->saveDECMode.logging = False; } unsigned char _DtTermGetRenderFontIndex(Widget w, int id) { DtTermWidget tw = (DtTermWidget) w; DtTermData td = tw->vt.td; int i; /* search for the index that matches this id... */ for (i = 0; i < (sizeof(td->renderFonts) / sizeof(td->renderFonts[0])); i++) { if (td->renderFonts[i].id == id) { return(i); } } /* default to base if not found... */ return(0); } /*ARGSUSED*/ static void Initialize(Widget ref_w, Widget w, Arg *args, Cardinal *num_args) { DtTermPrimitiveWidget tpw = (DtTermPrimitiveWidget) w; DtTermWidget tw = (DtTermWidget) w; DtTermData td; int i; Debug('T', timeStamp("Term Initialize() starting")); /* initialize... */ /* malloc Vt dataspace... */ tw->vt.td = (DtTermData) XtMalloc(sizeof(DtTermDataRec)); td = tw->vt.td; /* clear malloc'ed memory... */ (void) memset(td, '\0', sizeof(DtTermDataRec)); /* stick a pointer to the DtTermPrimData struct in our DtTermData... */ td->tpd = tw->term.tpd; /* set up our fonts... */ for (i = 0; i < (sizeof(td->renderFonts) / sizeof(td->renderFonts[0])); i++) { td->renderFonts[i].termFont = (TermFont) 0; td->renderFonts[i].id = -1; } td->renderFonts[0].termFont = td->tpd->defaultTermFont; td->renderFonts[0].id = 'B'; td->baseFontIndex = 0; /* allocate a line drawing font... */ td->renderFonts[1].termFont = _DtTermPrimRenderLineDrawCreate(w, /* Widget */ _DtTermGlyphs, /* glyphInfo */ _DtTermNumGlyphs, /* numGlyphs */ tw->term.widthInc, /* width */ tw->term.ascent, /* ascent */ tw->term.heightInc - tw->term.ascent); /* descent */ td->renderFonts[1].id = '0'; td->altFontIndex = 1; td->renderFonts[2].termFont = td->tpd->defaultBoldTermFont; td->G0 = RENDER_FONT_NORMAL; td->G1 = RENDER_FONT_LINEDRAW; /* DKS!!! change this */ td->G2 = RENDER_FONT_NORMAL; td->G3 = RENDER_FONT_NORMAL; td->GL = &td->G0; td->GR = &td->G0; td->singleShiftFont = RENDER_FONT_NORMAL; td->singleShiftPending = False; _DtTermFunctionKeyInit(w); /* ** Initialize modes... */ initializeModes(td); tpw->term.tpd->autoWrapRight = tw->vt.autoWrap ; tw->vt.td->reverseWrapMode = tw->vt.reverseWrap ; /* Initialize color... */ (void) _DtTermColorInit(w); if ( !strcmp(tpw->term.termId,"vt100")) td->terminalId = 100 ; else if ( !strcmp(tpw->term.termId,"vt101")) td->terminalId = 101 ; else if ( !strcmp(tpw->term.termId,"vt102")) td->terminalId = 102 ; else td->terminalId = 220 ; /* vt200 */ if ( td->terminalId < 200 ) td->compatLevel = 1; else td->compatLevel = 2; _DtTermPrimSelectInitBtnEvents(w) ; /* set button events */ Debug('T', timeStamp("Term Initialize() finished")); return; } #ifdef DKS static void InitializeVerticalScrollBar(Widget w, Boolean initCallbacks) { DtTermWidget tw = (DtTermWidget) w; Arg arglist[20]; int i; if (initCallbacks) { /* set up the scrollbar callbacks... */ (void) XtAddCallback(tw->vt.verticalScrollBar, XmNdragCallback, VerticalScrollBarCallback, (XtPointer) w); (void) XtAddCallback(tw->vt.verticalScrollBar, XmNvalueChangedCallback, VerticalScrollBarCallback, (XtPointer) w); } if (!tw->vt.td) { /* no termBuffer yet, we set anything yet... */ return; } /* update the scrollbar... */ if (tw->vt.verticalScrollBar) { tw->vt.verticalScrollBarMaximum = (tw->term.tpd->lastUsedRow - tw->term.tpd->memoryLockRow) + (tw->term.tpd->term.rows - tw->term.tpd->memoryLockRow); tw->vt.verticalScrollBarSliderSize = tw->term.rows - tw->term.tpd->memoryLockRow; tw->vt.verticalScrollBarPageIncrement = tw->term.rows - tw->term.tpd->memoryLockRow; tw->vt.verticalScrollBarValue = tw->term.tpd->topRow; i = 0; (void) XtSetArg(arglist[i], XmNincrement, 1); i++; (void) XtSetArg(arglist[i], XmNminimum, 0); i++; (void) XtSetArg(arglist[i], XmNmaximum, tw->term.verticalScrollBarMaximum); i++; (void) XtSetArg(arglist[i], XmNpageIncrement, tw->term.verticalScrollBarPageIncrement); i++; (void) XtSetArg(arglist[i], XmNsliderSize, tw->term.verticalScrollBarSliderSize); i++; (void) XtSetArg(arglist[i], XmNvalue, tw->term.verticalScrollBarValue); i++; (void) XtSetValues(tw->term.verticalScrollBar, arglist, i); } } #endif /* DKS */ static void Resize(Widget w) { DtTermWidget tw = (DtTermWidget) w; /* let our superclass (the Term Widget) perform the resize... */ tw->core.widget_class->core_class.superclass->core_class.resize(w); #ifdef DKS /* and update the scrollbar... */ (void) InitializeVerticalScrollBar(w, False); #endif /* DKS */ } /*************************************************************************** * * * Import and Export functions for those resources that can't really be * * accessed through the widget DS. * * * ***************************************************************************/ /* ARGSUSED */ static void GetAutoWrap( Widget wid, int offset, XtArgVal *value ) { DtTermWidget tw = (DtTermWidget) wid ; (*value) = (XtArgVal) tw->term.tpd->autoWrapRight; } /* ARGSUSED */ static XmImportOperator SetAutoWrap( Widget wid, int offset, XtArgVal *value ) { DtTermWidget tw = (DtTermWidget) wid ; tw->term.tpd->autoWrapRight = (* (int *) value); /* return (XmSYNTHETIC_LOAD);*/ return (XmSYNTHETIC_NONE); } /* ARGSUSED */ static void GetReverseWrap( Widget wid, int offset, XtArgVal *value ) { DtTermWidget tw = (DtTermWidget) wid ; (*value) = (XtArgVal) tw->vt.td->reverseWrapMode;; } /* ARGSUSED */ static XmImportOperator SetReverseWrap( Widget wid, int offset, XtArgVal *value ) { DtTermWidget tw = (DtTermWidget) wid ; tw->vt.td->reverseWrapMode = (* (int *) value); /* return (XmSYNTHETIC_LOAD);*/ return (XmSYNTHETIC_NONE); } /* ARGSUSED */ static void GetAppCursorMode( Widget wid, int offset, XtArgVal *value ) { DtTermWidget tw = (DtTermWidget) wid ; (*value) = (XtArgVal) tw->vt.td->applicationMode;; } /* ARGSUSED */ static XmImportOperator SetAppCursorMode( Widget wid, int offset, XtArgVal *value ) { DtTermWidget tw = (DtTermWidget) wid ; tw->vt.td->applicationMode = (* (int *) value); return (XmSYNTHETIC_NONE); } /* ARGSUSED */ static void GetAppKeypadMode( Widget wid, int offset, XtArgVal *value ) { DtTermWidget tw = (DtTermWidget) wid ; (*value) = (XtArgVal) tw->vt.td->applicationKPMode;; } /* ARGSUSED */ static XmImportOperator SetAppKeypadMode( Widget wid, int offset, XtArgVal *value ) { DtTermWidget tw = (DtTermWidget) wid ; tw->vt.td->applicationKPMode = (* (int *) value); return (XmSYNTHETIC_NONE); } /* SetValues... */ /*ARGSUSED*/ static Boolean SetValues(Widget cur_w, Widget ref_w, Widget w, ArgList args, Cardinal *num_args) { DtTermWidget cur_tw = (DtTermWidget) cur_w; DtTermWidget tw = (DtTermWidget) w; Boolean flag = False; /* return value... */ #ifdef DKS /* DKS: this needs to be done later... */ if (cur_tw->vt.verticalScrollBar != tw->vt.verticalScrollBar) { if (tw->vt.verticalScrollBar) { /* set up the scrollbar values and callbacks... */ (void) InitializeVerticalScrollBar(w, True); } } #endif /* DKS */ if (tw->term.fontList != cur_tw->term.fontList) { /* the font has been changed... */ XmFontList fontList; XFontSet fontSet; XFontStruct *font; /* replace the base font... */ tw->vt.td->renderFonts[0].termFont = tw->term.tpd->termFont; /* replace the linedraw font... */ /* release the old font... */ (void) _DtTermPrimDestroyFont(w, tw->vt.td->renderFonts[1].termFont); /* replace the font... */ tw->vt.td->renderFonts[1].termFont = _DtTermPrimRenderLineDrawCreate(w, _DtTermGlyphs, _DtTermNumGlyphs, tw->term.widthInc, tw->term.ascent, tw->term.heightInc - tw->term.ascent); /* replace the bold font. If the base font is the default, then * use the default bold font that we generated. Else, null it out * and we will fake by overstriking... */ if (tw->vt.td->renderFonts[0].termFont == tw->vt.td->tpd->defaultTermFont) { tw->vt.td->renderFonts[2].termFont = tw->vt.td->tpd->defaultBoldTermFont; } else { tw->vt.td->renderFonts[2].termFont = (TermFont) 0; } flag = True; } return(flag); } /* Destroy... */ static void Destroy(Widget w) { DtTermWidget tw = (DtTermWidget) w; /* remove the DtTermData structure contents, followed by the structure... */ if (tw->vt.td) { /* free up any fonts we allocated for this widget... */ /* don't free the others because they're done in TermPrim Destroy()*/ (void) _DtTermPrimDestroyFont(w, tw->vt.td->renderFonts[1].termFont); /* free up any color cells that we allocated for this widget... */ (void) _DtTermColorDestroy(w); /* free up our function key related resources... */ (void) _DtTermFunctionKeyClear(w); /* ** free up the block mode stuff... _vtBlockModeDestroy(td->blockModeInfo); td->blockModeInfo = (BlockModeInfo) 0; */ /* free up the DtTermData structure... */ (void) XtFree((char *) tw->vt.td); tw->vt.td = (DtTermData) 0; } } #ifdef DKS static void StatusChangeNotify(Widget w, unsigned long mask) { DtTermWidget tw = (DtTermWidget) w; struct termData *tpd = tw->term.tpd; struct vtData *td = tw->vt.td; TermVtCallbackStruct cb; if (!tw->vt.statusChangeCallback) { /* no callback, nothing to do... */ return; } /***************************************************************** * Caps Lock */ if (mask & TermSTATUS_CHANGE_NOTIFY_CAPS_LOCK) { (void) memset(&cb, '\0', sizeof(cb)); cb.reason = DtTermCR_CAPS_LOCK_CHANGE; cb.capsLock = tpd->capsLock; (void) XtCallCallbackList(w, tw->vt.statusChangeCallback, (XtPointer) &cb); } /***************************************************************** * Insert Char Mode */ if (mask & TermSTATUS_CHANGE_NOTIFY_INSERT_MODE) { (void) memset(&cb, '\0', sizeof(cb)); cb.reason = DtTermCR_INSERT_MODE_CHANGE; cb.insertCharMode = tpd->insertCharMode; (void) XtCallCallbackList(w, tw->vt.statusChangeCallback, (XtPointer) &cb); } /***************************************************************** * Stop */ if (mask & TermSTATUS_CHANGE_NOTIFY_STOP) { (void) memset(&cb, '\0', sizeof(cb)); cb.reason = DtTermCR_STOP_CHANGE; cb.stop = tpd->stop; (void) XtCallCallbackList(w, tw->vt.statusChangeCallback, (XtPointer) &cb); } } static void PositionUpdate(Widget w, short row, short column) { DtTermWidget tw = (DtTermWidget) w; struct termData *tpd = tw->term.tpd; struct vtData *td = tw->vt.td; TermVtCallbackStruct cb; if (!tw->vt.statusChangeCallback) { /* no callback, nothing to do... */ return; } cb.reason = DtTermCR_CURSOR_MOTION; cb.cursorColumn = tpd->cursorColumn; cb.cursorRow = tpd->cursorRow = tpd->topRow; (void) XtCallCallbackList(w, tw->vt.statusChangeCallback, (XtPointer) &cb); } #endif /* DKS */ Widget DtCreateTerm(Widget parent, char *name, ArgList arglist, Cardinal argcount) { Widget w; _DtTermWidgetToAppContext(parent); _DtTermAppLock(app); Debug('T', timeStamp("DtCreateTerm() starting")); w = XtCreateWidget(name, dtTermWidgetClass, parent, arglist, argcount); Debug('T', timeStamp("DtCreateTerm() finished")); _DtTermAppUnlock(app); return(w); } #ifdef DKS static void VerticalScrollBarCallback(Widget wid, XtPointer client_data, XtPointer call_data) { DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) client_data; struct termData *tpd = tw->term.tpd; XmScrollBarCallbackStruct *cb = (XmScrollBarCallbackStruct *) call_data; (void) _DtTermPrimScrollTextTo((Widget) tw, cb->value); /* we need to complete the scroll or it won't happen... */ (void) _DtTermPrimScrollComplete((Widget) tw, True); if (cb->reason != XmCR_DRAG) { _DtTermPrimCursorOn((Widget) tw); } } #endif /* DKS */ static int TextInsertProc ( Widget w, unsigned char *buffer, int length ) { DtTermWidget tw = (DtTermWidget) w; DtTermPrimData tpd = tw->term.tpd; DtTermData td = tw->vt.td; int partialLen = 0; int holdFont; if (td->singleShiftPending) { /* save away the active GL font... */ holdFont = *td->GL; /* make it the single shift font... */ *td->GL = td->singleShiftFont; (void) _DtTermPrimBufferSetEnhancement(tpd->termBuffer, tpd->topRow + tpd->cursorRow, tpd->cursorColumn, enhFont, *td->GL); /* insert the first character... */ partialLen = _DtTermPrimInsertText(w, buffer, 1); /* restore the active GL font... */ *td->GL = holdFont; (void) _DtTermPrimBufferSetEnhancement(tpd->termBuffer, tpd->topRow + tpd->cursorRow, tpd->cursorColumn, enhFont, *td->GL); if (partialLen == 1) { /* successful insert... */ /* clear the pending flag... */ td->singleShiftPending = False; /* skip over the character... */ (void) buffer++; (void) length--; } else { return(partialLen); } } if (length > 0) { partialLen += _DtTermPrimInsertText(w, buffer, length); } return(partialLen); }