2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * (c) Copyright 1993, 1994, 1996 Hewlett-Packard Company *
25 * (c) Copyright 1993, 1994, 1996 International Business Machines Corp. *
26 * (c) Copyright 1993, 1994, 1996 Sun Microsystems, Inc. *
27 * (c) Copyright 1993, 1994, 1996 Novell, Inc. *
28 * (c) Copyright 1996 Digital Equipment Corporation. *
29 * (c) Copyright 1996 FUJITSU LIMITED. *
30 * (c) Copyright 1996 Hitachi. *
35 #include "TermHeader.h"
36 #include "TermPrimDebug.h"
37 #include "TermPrimP.h"
38 #include "TermPrimI.h"
40 #include "TermPrimData.h"
42 #include "TermPrimBuffer.h"
43 #include "TermPrimParserP.h"
44 #include "TermFunction.h"
45 #include "TermBuffer.h"
46 #include "TermFunctionKey.h"
47 #include "TermParseTableP.h"
48 #include "TermBufferP.h"
49 #include "TermPrimUtil.h"
50 #include "TermPrimParseTable.h"
54 * On HP MAXINT is defined in both <values.h> and <sys/param.h>
58 #if defined(CSRG_BASED)
59 #define MAXSHORT SHRT_MAX
64 /*****************************************************************************/
67 #define PCOUNT(c) ((c)->parms[0])
68 #define BASE 1 /* row and column count base 0 or 1 */
70 /*********************************************************************
71 * Macros for handling cursor constraints - return values in coordinate
72 * system for Term widget (base 0) BASE which is 1 reflects the Vt base
74 * These defines need to account of for Origin mode eventually TMH */
76 #define TOPROW(w) (1-BASE)
77 #define TOPMARGIN(w) ((w)->term.tpd->scrollLockTopRow-(1-BASE))
78 #define BOTTOMMARGIN(w) ((w)->term.tpd->scrollLockBottomRow-(1-BASE))
79 #define BOTTOMROW(w) ((w)->term.rows-BASE)
80 /* FIRSTCOLUMN(w) ABS(BASE-1) */
81 #define FIRSTCOLUMN(w) 0
82 #define LASTCOLUMN(w) ((w)->term.columns-BASE)
83 #define FLOOR(w) ((w)->vt.td->originMode?(w)->term.tpd->scrollLockBottomRow:\
85 #define CEILING(w) ((w)->vt.td->originMode?(w)->term.tpd->scrollLockTopRow:\
87 #define KILLWRAP(w) if((w)->term.tpd->cursorColumn>LASTCOLUMN(w)) \
88 (w)->term.tpd->cursorColumn=LASTCOLUMN(w)
89 #define STORELASTARG(c) (c)->parms[PCOUNT(c)]=(c)->workingNum
91 /******************************************************************
92 * Upon entering a parse routine the parameter count is contained
93 * in context->parms[0].
95 * The last parmameter parsed is in context->workingNum
96 * Next to last parmameter is in {context->parms[0]==1?context->workingNum:
97 * context->parms[context->param[0]-1]}
101 * First parameter is in context->parms[1]
103 * In some of the parse routines, the default case of too many parameters
104 * needs to be handled like Vt (silently use the first n parameters)
105 * Vt has a max of 16 numeric parameters; The rest fall off the end
107 *******************************************************************/
110 _DtTermClearParam(Widget w)
112 ParserContext context ;
113 context = GetParserContext(w) ;
116 _DtTermPrimParserClearParm(w) ;
117 _DtTermPrimParserClrStrParm(w) ;
121 _DtTermEnterNum(Widget w)
123 ParserContext context ;
124 context = GetParserContext(w) ;
125 _DtTermPrimParserEnterNum(w) ;
126 if (!PCOUNT(context)) PCOUNT(context)++ ; /* increment for first number ONLY*/
130 _DtTermParsePushNum(Widget w)
132 ParserContext context ;
133 context = GetParserContext(w) ;
134 /* parmN(w,PCOUNT(c)) ; Should use this but not global */
135 if ( context->workingNumIsDefault != True) { /* did we actually parse a num*/
136 _DtTermPrimParserNumParmPush(w,PCOUNT(context)) ;
139 if (!PCOUNT(context)) PCOUNT(context)++ ;/* increment for first number ONLY*/
142 if ( ++PCOUNT(context)>NPARAM ) {
143 Debug('P',fprintf(stderr,">>Too many parameters\n")) ;
149 _DtTermSaveChar(Widget w)
151 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
152 ParserContext context ;
154 context = GetParserContext(w) ;
156 mbtowc(&c,(char *)context->inputChar,MB_CUR_MAX);
157 if ( context->stringParms[0].length < STR_SIZE && iswprint(c) ) {
159 (char *)&context->stringParms[0].str[context->stringParms[0].length]),
160 (char *)context->inputChar, context->inputCharLen) ;
161 context->stringParms[0].length += context->inputCharLen ;
166 _DtTermPrintState(Widget w)
168 ParserContext context ;
169 context = GetParserContext(w) ;
170 /* fprintf(stderr,"Warning: Not a valid escape sequence\n") ;*/
171 context->stateTable = _DtTermStateStart ;
172 _DtTermClearParam(w) ;
175 /* a utility for checking for S8C1TMode */
177 sendEscSequence(Widget w, char *transmitString)
179 DtTermWidget tw = (DtTermWidget)w;
180 DtTermData td = tw->vt.td;
182 if ( td->S8C1TMode ) {
183 char *cbuf =malloc(strlen(transmitString)+1);
184 strcpy(cbuf,transmitString) ;
186 (void) _DtTermPrimSendInput(w, (unsigned char *) (cbuf+1),
191 (void) _DtTermPrimSendInput(w, (unsigned char *) transmitString,
192 strlen(transmitString));
197 _DtTermDeviceStatus(Widget w) /* DSR CSI?pn */
199 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
200 DtTermData vtd = ((DtTermWidget)w)->vt.td;
201 ParserContext context ;
204 Debug('P', fprintf(stderr,">>In func _DtTermDeviceStatus\n")) ;
205 context = GetParserContext(w) ;
206 STORELASTARG(context) ;
207 switch ( context->parms[1] ) {
208 case 15: /* printer status - we don't have one */
209 sendEscSequence(w,"\033[?13n") ;
211 case 25: /* User defined keys locked? */
212 if ( vtd->userKeysLocked )
213 sendEscSequence(w,"\033[?21n") ;
215 sendEscSequence(w,"\033[?20n") ;
217 case 26: /* keyboard status - always send North American */
218 sendEscSequence(w,"\033[?27;1n") ;
224 _DtTermDeviceStatusAnsi(Widget w) /* DSR CSIpn */
226 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
227 DtTermData vtd = ((DtTermWidget)w)->vt.td;
228 ParserContext context ;
231 Debug('P', fprintf(stderr,">>In func _DtTermDeviceStatus\n")) ;
232 context = GetParserContext(w) ;
233 STORELASTARG(context) ;
234 switch ( context->parms[1] ) {
235 case 5: /* as far as I know, all's well... So send OK */
236 sendEscSequence(w,"\033[0n") ;
239 /* cursor could be past last row (for autowrap) */
240 if ((col=tw->term.tpd->cursorColumn)>LASTCOLUMN(tw))
242 row = tw->term.tpd->cursorRow+BASE ;
243 if (vtd->originMode==True) row -= TOPMARGIN(tw) ;
244 sprintf(buf,"\033[%d;%dR",row , col+BASE) ;
245 sendEscSequence(w,buf) ;
251 _DtTermPModeSet(Widget w) /* DECSET CSI?ph */
253 ParserContext context ;
254 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
255 DtTermWidget vtw = (DtTermWidget)w;
257 Debug('P', fprintf(stderr,">>In func _DtTermPModeSet\n")) ;
258 context = GetParserContext(w) ;
259 STORELASTARG(context) ;
260 cnt = PCOUNT(context) ;
261 for (i=1;i<=cnt;i++) {
262 switch ( context->parms[i]) {
264 case 1: /* Cursor key (Application) */
265 vtw->vt.td->applicationMode=True;
267 /* case 2: can't return from vt52 mode */
268 case 3: /* Column (132) */
269 if ( vtw->vt.c132 ) { /* xterm allow 132 mode */
270 (void) _DtTermFuncClearBuffer(w, 0, fromParser);
271 vtw->term.tpd->cursorRow = TOPROW(vtw) ;
272 vtw->term.tpd->cursorColumn = FIRSTCOLUMN(vtw) ;
273 vtw->term.tpd->scrollLockTopRow = TOPROW(vtw);
274 vtw->term.tpd->scrollLockBottomRow = BOTTOMROW(vtw) ;
275 XtVaSetValues(w, DtNcolumns, 132, NULL) ;
276 vtw->vt.td->col132Mode = True ;
279 case 4: /* Scroll (smooth) */
280 _DtTermPrimScrollComplete(w, True) ;
281 vtw->term.jumpScroll = False ;
283 case 5: /* Screen (Reverse) */
284 /*DKS: this is just to test out the functionality... */
285 vtw->term.reverseVideo = True;
286 /* clear the window to force refresh... */
287 (void) XClearArea(XtDisplay(w), XtWindow(w),
290 case 6: /* Origin mode (On) */
291 vtw->vt.td->originMode=True;
292 _DtTermPrimCursorMove(w, TOPMARGIN(vtw), 0);
294 case 7: /* Auto wrap (On) */
295 vtw->term.tpd->autoWrapRight=True ;
297 /* case 8: ** Auto repeat (On)
298 * ** This is handled by the X server
301 * case 18: ** Print form feed (On)
303 * case 19: ** Print extent (full screen)
306 case 25: /* Text cursor enable (On) */
307 (void) _DtTermPrimSetCursorVisible(w, True);
310 case 40: /* 80/132 mode (allow) */
311 vtw->vt.c132 = True ;
313 case 41: /* curses fix */
314 vtw->vt.td->fixCursesMode = True ;
316 case 44: /* margin bell (on) */
317 vtw->term.marginBell = True ;
319 case 45: /* Reverse-wraparound mode */
320 vtw->vt.td->reverseWrapMode=True;
322 case 46: /* logging (start) */
323 vtw->term.logging = True ;
324 _DtTermPrimStartLog(w);
326 /* case 47: ** screen buffer (alternate)
328 * case 1000: ** Send mouse x and y
330 * case 1001: ** Use hilite mouse tracking
339 _DtTermPModeReset(Widget w) /* DECRST CSI?pl */
341 ParserContext context ;
342 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
343 DtTermWidget vtw = (DtTermWidget)w;
345 Debug ('P', fprintf(stderr,">>In func _DtTermPModeReset\n")) ;
346 context = GetParserContext(w) ;
347 STORELASTARG(context) ;
348 cnt = PCOUNT(context) ;
349 for (i=1;i<=cnt;i++) {
350 switch ( context->parms[i]) {
352 case 1: /* Cursor key (Normal) */
353 vtw->vt.td->applicationMode=False;
355 /* case 2: ** set vt52 mode */
356 case 3: /* Column (80) */
357 if (vtw->vt.c132) { /* allow 132 mode */
358 (void) _DtTermFuncClearBuffer(w, 0, fromParser);
359 vtw->term.tpd->cursorRow = TOPROW(vtw) ;
360 vtw->term.tpd->cursorColumn = FIRSTCOLUMN(vtw) ;
361 vtw->term.tpd->scrollLockTopRow = TOPROW(vtw);
362 vtw->term.tpd->scrollLockBottomRow = BOTTOMROW(vtw) ;
363 XtVaSetValues(w, DtNcolumns, 80, NULL) ;
364 vtw->vt.td->col132Mode = False ;
367 case 4: /* Scroll (jump) */
368 _DtTermPrimScrollComplete(w, True) ;
369 vtw->term.jumpScroll = True ;
371 case 5: /* Screen (normal ) */
372 /*DKS: this is just to test out the functionality... */
373 vtw->term.reverseVideo = False;
374 /* clear the window to force refresh... */
375 (void) XClearArea(XtDisplay(w), XtWindow(w),
378 case 6: /* Normal cursor (not Origin mode) */
379 vtw->vt.td->originMode=False;
380 _DtTermPrimCursorMove(w, 0, 0);
382 case 7: /* Auto wrap (Off) */
383 vtw->term.tpd->autoWrapRight=False;
385 /* case 8: ** Auto repeat (Off)
386 * ** implemented in the server
388 * case 18: ** Print form feed (Off)
390 * case 19: ** Print extent (scrolling region)
393 case 25: /* Text cursor enable (Off) */
394 (void) _DtTermPrimSetCursorVisible(w, False);
397 case 40: /* 80/132 mode (disallow) */
398 vtw->vt.c132 = False;
400 case 41: /* curses fix */
401 vtw->vt.td->fixCursesMode = False;
403 case 44: /* margin bell (off) */
404 vtw->term.marginBell = False ;
406 case 45: /* Reverse-wraparound mode */
407 vtw->vt.td->reverseWrapMode=False;
409 case 46: /* logging (stop ) */
410 vtw->term.logging = False ;
411 _DtTermPrimCloseLog(w) ;
413 /* case 47: ** screen buffer (normal)
415 * case 1000: ** don't send mouse x and y
417 * case 1001: ** don't use hilite mouse tracking
425 _DtTermSetMode(Widget w) /* SM CSIph */
427 ParserContext context ;
428 DtTermWidget vtw = (DtTermWidget)w ;
430 Debug('P', fprintf(stderr,">>In func _DtTermSetMode\n")) ;
431 context = GetParserContext(w) ;
432 STORELASTARG(context) ;
433 cnt = PCOUNT(context) ;
434 for (i=1;i<=cnt;i++) {
435 switch ( context->parms[i]) {
436 case 2: /* KAM Keyboard Action (locked) */
437 vtw->term.tpd->keyboardLocked.escape=True ;
438 (void) _DtTermPrimInvokeStatusChangeCallback(w);
440 case 4: /* Insert mode */
441 _DtTermPrimInsertCharUpdate(w, DtTERM_INSERT_CHAR_ON) ;
443 case 12: /* SRM Send/Receive (Off) */
444 vtw->term.tpd->halfDuplex = False;
446 case 20: /* Line feed/newline (new line) */
447 vtw->term.tpd->autoLineFeed=True ;
454 _DtTermResetMode(Widget w) /* RM CSIpl */
456 ParserContext context ;
457 DtTermWidget vtw = (DtTermWidget)w ;
459 Debug('P', fprintf(stderr,">>In func _DtTermResetMode\n")) ;
460 context = GetParserContext(w) ;
461 STORELASTARG(context) ;
462 cnt = PCOUNT(context) ;
463 for (i=1;i<=cnt;i++) {
464 switch ( context->parms[i]) {
465 case 2: /* KAM Keyboard Action (unlocked) */
466 vtw->term.tpd->keyboardLocked.escape=False;
467 (void) _DtTermPrimInvokeStatusChangeCallback(w);
469 case 4: /* Replace mode */
470 _DtTermPrimInsertCharUpdate(w, DtTERM_INSERT_CHAR_OFF) ;
472 case 12: /* SRM Send/Receive (On) */
473 vtw->term.tpd->halfDuplex = True;
475 case 20: /* Line feed/newline (line feed) */
476 vtw->term.tpd->autoLineFeed=False ;
483 _DtTermCursorPos(Widget w) /* CUP CSIp;pH */
485 ParserContext context ;
486 DtTermWidget vtw = (DtTermWidget) w;
488 Debug( 'P', fprintf(stderr,">>In func _DtTermCursorPos\n")) ;
489 context = GetParserContext(w) ;
490 STORELASTARG(context) ;
491 row = context->parms[1] ;
492 col = context->parms[2] ;
495 if (vtw->vt.td->originMode) row += vtw->term.tpd->scrollLockTopRow ;
496 if (row > FLOOR(vtw)) row = FLOOR(vtw) ;
497 if (col > LASTCOLUMN(vtw)) col = LASTCOLUMN(vtw) ;
498 vtw->term.tpd->cursorRow = row ;
499 vtw->term.tpd->cursorColumn = col ;
503 _DtTermEraseDisplay(Widget w) /* ED CSIpJ */
506 DtTermWidget vtw = (DtTermWidget) w;
507 ParserContext context ;
508 DtEraseMode eraseMode;
511 Debug('P', fprintf(stderr,">>In func _DtTermEraseDisplay\n")) ;
512 context = GetParserContext(w) ;
514 STORELASTARG(context) ;
515 row = vtw->term.tpd->cursorRow;
516 col = vtw->term.tpd->cursorColumn ;
519 ** pick the correct erase mode...
521 switch (context->parms[1])
524 eraseMode = eraseToEOB;
527 eraseMode = eraseFromRow0Col0;
530 eraseMode = eraseBuffer;
533 _DtTermFuncEraseInDisplay(w, (int)eraseMode, fromParser);
534 vtw->term.tpd->cursorRow = row;
535 vtw->term.tpd->cursorColumn = col;
539 _DtTermEraseChars(Widget w) /* ECH CSIpX */
541 ParserContext context ;
542 DtTermWidget vtw = (DtTermWidget) w;
544 Debug('P', fprintf(stderr,">>In func _DtTermEraseChars\n")) ;
546 context = GetParserContext(w) ;
547 row = vtw->term.tpd->cursorRow ;
548 col = vtw->term.tpd->cursorColumn ;
549 STORELASTARG(context) ;
550 cnt = context->parms[1] ;
553 if ( cnt > LASTCOLUMN(vtw)-col+1 ) cnt = LASTCOLUMN(vtw)-col+1 ;
555 _DtTermFuncEraseCharacter(w, cnt, fromParser);
559 _DtTermInsertChars(Widget w) /* ICH CSIp@ */
561 DtTermWidget vtw = (DtTermWidget) w;
562 ParserContext context ;
564 DtTermInsertCharMode saveInsertCharMode;
566 Debug('P', fprintf(stderr,">>In func _DtTermInsertChars\n")) ;
568 context = GetParserContext(w) ;
569 vtw->term.tpd->parserNotInStartState = False ;
570 row = vtw->term.tpd->cursorRow ;
571 col = vtw->term.tpd->cursorColumn ;
572 STORELASTARG(context) ;
573 cnt = context->parms[1] ;
577 if (cnt > LASTCOLUMN(vtw) - col + 1)
578 cnt = LASTCOLUMN(vtw) - col + 1;
580 /* save away the insert char mode... */
581 saveInsertCharMode = vtw->term.tpd->insertCharMode;
583 /* turn on insert char mode. We don't want to invoke any status
584 * change callbacks, so we will justs set it directly...
586 vtw->term.tpd->insertCharMode = DtTERM_INSERT_CHAR_ON;
588 /* insert blanks... */
590 (void) _DtTermPrimInsertText(w,(unsigned char *) " ", 1) ;
592 /* restore the insert char mode... */
593 vtw->term.tpd->insertCharMode = saveInsertCharMode;
595 _DtTermPrimCursorMove(w,row,col) ;
599 _DtTermCursorUp(Widget w) /* CUU CISpA */
601 ParserContext context ;
602 DtTermWidget vtw = (DtTermWidget) w;
603 int trow, row, tmargin, cnt;
604 Debug('P', fprintf(stderr,">>In func _DtTermCursorUp\n")) ;
605 context = GetParserContext(w) ;
607 tmargin = TOPMARGIN(vtw) ;
609 STORELASTARG(context) ;
610 cnt = context->parms[1] ;
612 else if (cnt>MAXSHORT) cnt=MAXSHORT-100;
613 row = vtw->term.tpd->cursorRow-cnt;
614 /* are we about the top margin and did we actually cross it? */
615 /* This handles the case top margin == top row */
616 if (row < tmargin && row+cnt >= tmargin) row = tmargin;
617 _DtTermPrimCursorMove(w, row, vtw->term.tpd->cursorColumn) ;
621 _DtTermCursorDown(Widget w) /* CUD CISpB */
623 ParserContext context ;
624 DtTermWidget vtw = (DtTermWidget) w;
625 int bmargin, row, cnt, brow ;
626 Debug('P', fprintf(stderr,">>In func _DtTermCursorDown\n")) ;
627 context = GetParserContext(w) ;
629 bmargin = BOTTOMMARGIN(vtw) ;
630 brow = BOTTOMROW(vtw) ;
631 STORELASTARG(context) ;
632 cnt = context->parms[1] ;
634 row = vtw->term.tpd->cursorRow+cnt;
635 /* are we below bottom margin and did we actually cross it? */
636 /* NOTE that this also handles the case when bmargin == brow */
637 if (row > bmargin && row-cnt <= bmargin) row = bmargin;
638 /* did we start below bottom margin and cross bottom row? */
639 if (row > brow && bmargin < brow ) row = brow;
640 _DtTermPrimCursorMove(w, row, vtw->term.tpd->cursorColumn) ;
644 _DtTermCursorForward(Widget w) /* CUF CISpC */
646 ParserContext context ;
647 DtTermWidget vtw = (DtTermWidget) w;
649 Debug('P', fprintf(stderr,">>In func _DtTermCursorForward\n")) ;
650 context = GetParserContext(w) ;
652 lcol = LASTCOLUMN(vtw) ;
653 STORELASTARG(context) ;
654 cnt = context->parms[1] ;
656 col = vtw->term.tpd->cursorColumn+cnt;
657 if (col>lcol) col=lcol;
658 _DtTermPrimCursorMove(w,vtw->term.tpd->cursorRow,col);
662 _DtTermCursorBack(Widget w) /* CUB CISpD */
664 ParserContext context ;
665 DtTermWidget vtw = (DtTermWidget) w;
666 int i,k,j,row,col,fcol,cnt ;
667 Debug('P', fprintf(stderr,">>In func _DtTermCursorBack\n")) ;
669 context = GetParserContext(w) ;
670 STORELASTARG(context) ;
671 cnt = context->parms[1] ;
672 fcol = FIRSTCOLUMN(vtw) ;
673 row = vtw->term.tpd->cursorRow;
674 col = vtw->term.tpd->cursorColumn;
676 if ((col -= cnt) < 0) {
677 if(vtw->vt.td->reverseWrapMode && vtw->term.tpd->autoWrapRight) {
678 int lastrow = BOTTOMROW(vtw);
679 if (vtw->vt.td->originMode) {
680 row-=TOPMARGIN(vtw) ;
681 lastrow = BOTTOMMARGIN(vtw)-TOPMARGIN(vtw);
683 if((i = (j = LASTCOLUMN(vtw) + 1) * row + col) < 0) {
684 k = j * (lastrow + 1);
685 i += ((-i) / k + 1) * k;
688 if (vtw->vt.td->originMode) row+=TOPMARGIN(vtw);
693 _DtTermPrimCursorMove(w,row,col);
697 _DtTermCursorToLineUp(Widget w) /* CPL CSIpF */
699 DtTermWidget vtw = (DtTermWidget) w;
700 ParserContext context ;
701 Debug('P', fprintf(stderr,">>In func _DtTermCursorToLineUp\n")) ;
703 context = GetParserContext(w) ;
704 vtw->term.tpd->cursorColumn = FIRSTCOLUMN(vtw) ;
709 _DtTermCursorToCol(Widget w) /* CHA CSIpG */
711 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
712 ParserContext context ;
713 context = GetParserContext(w) ;
714 STORELASTARG(context) ;
715 if (!context->parms[1] ) context->parms[1]=1;
716 if (context->parms[1]>tw->term.columns) context->parms[1]=tw->term.columns;
717 tw->term.tpd->cursorColumn = context->parms[1] - BASE ;
721 _DtTermEraseInLine(Widget w) /* EL ESC[pK */
723 DtTermWidget vtw = (DtTermWidget) w;
724 ParserContext context ;
725 DtEraseMode eraseMode;
728 Debug('P', fprintf(stderr,">>In func _DtTermEraseInLine\n")) ;
730 context = GetParserContext(w) ;
731 STORELASTARG(context) ;
733 ** pick the correct erase mode...
735 switch ( context->parms[1] )
738 eraseMode = eraseToEOL;
742 eraseMode = eraseFromCol0;
746 eraseMode = eraseLine;
750 _DtTermFuncEraseInLine(w, (int)eraseMode, fromParser);
754 _DtTermInsertLines(Widget w) /* IL CSIpL */
756 DtTermWidget vtw = (DtTermWidget) w;
757 ParserContext context ;
759 Debug('P', fprintf(stderr,">>In func _DtTermInsertLines\n")) ;
760 if ( vtw->term.tpd->cursorRow < TOPMARGIN(vtw) ||
761 vtw->term.tpd->cursorRow > BOTTOMMARGIN(vtw) )/*outside scrolling region*/
763 context = GetParserContext(w) ;
764 KILLWRAP((DtTermWidget)w) ;
765 STORELASTARG(context) ;
766 cnt=context->parms[1];
768 lines = BOTTOMMARGIN(vtw) - vtw->term.tpd->cursorRow + 1;
769 if (cnt > lines) cnt=lines ;
770 _DtTermFuncInsertLine(w,cnt,fromParser) ;
774 _DtTermDeleteLines(Widget w) /* DL CSIpM */
776 DtTermWidget vtw = (DtTermWidget) w;
777 ParserContext context ;
779 Debug('P', fprintf(stderr,">>In func _DtTermDeleteLines\n")) ;
781 if ( vtw->term.tpd->cursorRow < TOPMARGIN(vtw) ||
782 vtw->term.tpd->cursorRow > BOTTOMMARGIN(vtw) ) /* outside scrolling region*/
784 KILLWRAP((DtTermWidget)w) ;
785 context = GetParserContext(w) ;
786 STORELASTARG(context) ;
787 cnt = context->parms[1];
789 _DtTermFuncDeleteLine(w,cnt,fromParser) ;
793 _DtTermDeleteChars(Widget w) /* DCH CSIpP */
795 ParserContext context ;
796 DtTermWidget vtw = (DtTermWidget) w;
798 Debug('P', fprintf(stderr,">>In func _DtTermDeleteChars\n")) ;
800 context = GetParserContext(w) ;
801 STORELASTARG(context) ;
802 cnt= context->parms[1];
804 else if (cnt>MAXSHORT) cnt=MAXSHORT-100;
805 _DtTermFuncDeleteChar(w,cnt,fromParser) ;
809 _DtTermNextLine(Widget w) /* NEL ESCE */
811 DtTermWidget vtw = (DtTermWidget) w;
813 Debug('P', fprintf(stderr,">>In func _DtTermNextLine\n")) ;
814 vtw->term.tpd->cursorColumn = FIRSTCOLUMN(vtw) ;
815 _DtTermIndex(w) ; /* use IND */
819 _DtTermReverseIndex(Widget w) /* RI ESCM */
821 DtTermWidget vtw = (DtTermWidget) w;
822 int tmargin, trow, col;
823 Debug('P', fprintf(stderr,">>In func _DtTermReverseIndex\n")) ;
826 tmargin = TOPMARGIN(vtw) ;
827 col = vtw->term.tpd->cursorColumn ;
828 if ( vtw->term.tpd->cursorRow == tmargin) {
829 _DtTermFuncInsertLine(w,1,fromParser) ;
830 /* _DtTermFuncInsertLine sets column to first column */
831 vtw->term.tpd->cursorColumn = col ;
833 else if (vtw->term.tpd->cursorRow > trow){
834 vtw->term.tpd->cursorRow-- ;
839 _DtTermIndex(Widget w) /* IND ESCD */
841 DtTermWidget vtw = (DtTermWidget) w;
843 Debug('P', fprintf(stderr,">>In func _DtTermIndex\n")) ;
845 brow = BOTTOMROW(vtw) ;
846 bmargin = BOTTOMMARGIN(vtw) ;
847 if ( vtw->term.tpd->cursorRow == bmargin) {
848 (void) _DtTermPrimScrollText(w, 1);
850 else if (vtw->term.tpd->cursorRow < brow){
851 vtw->term.tpd->cursorRow++ ;
853 (void) _DtTermPrimFillScreenGap(w);
857 _DtTermScrollingRegion(Widget w) /* DECSTBM CSIp;pr */
859 DtTermWidget vtw = (DtTermWidget)w ;
860 ParserContext context ;
862 Debug('P', fprintf(stderr,">>In func _DtTermScrollingRegion\n")) ;
863 context = GetParserContext(w) ;
864 STORELASTARG(context) ;
865 row1 = context->parms[1] ;
866 row2 = context->parms[2] ;
867 if (!row1) row1 = 1 ;
868 if (!row2 || row2>vtw->term.rows) row2 = vtw->term.rows ;
872 if ( row1 == TOPROW(vtw) && row2 == BOTTOMROW(vtw))
873 vtw->term.tpd->memoryLockMode=SCROLL_LOCKoff ;
875 vtw->term.tpd->memoryLockMode=SCROLL_LOCKon ;
876 vtw->term.tpd->scrollLockTopRow = row1 ;
877 vtw->term.tpd->scrollLockBottomRow = row2 ;
878 if (vtw->vt.td->originMode) _DtTermPrimCursorMove(w,row1,0) ;
879 else _DtTermPrimCursorMove(w,0,0) ;
884 _DtTermCharAttributes(Widget w) /* SGR CSIpm */
886 ParserContext context ;
888 Debug('P', fprintf(stderr,">>In func _DtTermCharAttributes\n")) ;
889 context = GetParserContext(w) ;
890 STORELASTARG(context) ;
891 cnt = PCOUNT(context) ;
892 if(PCOUNT(context)) {
893 for (cnt=1; cnt <= PCOUNT(context); cnt++)
894 _DtTermVideoEnhancement(w,context->parms[cnt]) ;
897 _DtTermVideoEnhancement(w,0) ;
901 _DtTermDeviceAttributes(Widget w) /* DA CSIpc */
903 DtTermWidget vtw = (DtTermWidget) w;
904 ParserContext context ;
907 Debug('P', fprintf(stderr,">>In func _DtTermDeviceAttributes\n")) ;
908 context = GetParserContext(w) ;
909 STORELASTARG(context) ;
910 switch(context->parms[1]) {
912 switch(vtw->vt.td->terminalId ) {
914 sprintf(buf,"\033[?%d;%dc",1,2) ;
917 sprintf(buf,"\033[?%d;%dc",1,0) ;
920 sprintf(buf,"\033[?%dc",6) ;
923 /* class 2 terminal (62), 132 columns (1), printer port (2),
924 * selective erase (6), DRCS (7), UDK (8),
925 * national replacement char sets
927 sprintf(buf,"\033[?%d;%d;%d;%d;%d;%d;%dc",62,1,2,6,7,8,9) ;
930 sendEscSequence(w,buf) ;
936 _DtTermChangeTextParam(Widget w) /* xterm CSIp;pcCtrl-G */
938 ParserContext context ;
939 DtTermWidget tw = (DtTermWidget) w;
940 DtTermData vtd = tw->vt.td;
944 Debug('P', fprintf(stderr,">>In func _DtTermChangeTextParam\n")) ;
945 context = GetParserContext(w) ;
947 for (sw = w; !XtIsShell(sw); sw = XtParent(sw));
949 * context->parms[1] is inited to 0, so if no numeric param was entered,
950 * we default appropriately to case 0.
952 switch(context->parms[1]) {
953 case 0: /* change Icon name and Window title */
954 XtSetArg(arg[i], XmNtitle, context->stringParms[0].str); i++;
955 XtSetArg(arg[i], XmNiconName, context->stringParms[0].str); i++;
956 XtSetValues(sw,arg,i) ;
958 case 1: /* change Icon name */
959 XtSetArg(arg[i], XmNiconName, context->stringParms[0].str); i++;
960 XtSetValues(sw,arg,i) ;
962 case 2: /* change Window title */
963 XtSetArg(arg[i], XmNtitle, context->stringParms[0].str); i++;
964 XtSetValues(sw,arg,i) ;
966 case 3: /* change current working directory */
967 tw->term.subprocessCWD = XtRealloc(tw->term.subprocessCWD,
968 strlen((char *) context->stringParms[0].str) + 1);
969 (void) strcpy(tw->term.subprocessCWD,
970 (char *) context->stringParms[0].str);
972 /* These are handled by xterm but not by us.
973 case 46: Change log file to context->stringParms[0]
975 case 50: ** change font to context->stringParms[0]
982 _DtTermTabClear(Widget w) /* TBC CSIpg */
984 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
985 TermBuffer tb = tw->term.tpd->termBuffer ;
986 ParserContext context ;
988 Debug('P', fprintf(stderr,">>In func _DtTermTabClear\n")) ;
989 context = GetParserContext(w) ;
990 STORELASTARG(context) ;
991 type = context->parms[1] ;
993 case 0:(void)_DtTermPrimBufferClearTab(tb,tw->term.tpd->cursorColumn) ;
995 case 3: (void)_DtTermPrimBufferClearAllTabs(tb) ;
1001 _DtTermRequestParam(Widget w) /* DECREQTPARM CSIpx */
1003 ParserContext context ;
1006 Debug('P', fprintf(stderr,">>In func _DtTermRequestParam\n")) ;
1007 context = GetParserContext(w) ;
1008 STORELASTARG(context) ;
1009 row = context->parms[1] ;
1013 /* row (?), 1 no parity, 1 eight bits, 112 xmit 9600 baud,
1014 * 112, receive 9600 baud, 1 clock multiplier (?),
1015 * 0 STP flags (?) These are from xterm file 'charproc.c'.
1017 sprintf(buf,"\033[%d;%d;%d;%d;%d;%d;%dx",row,1,1,112,112,1,0) ;
1018 sendEscSequence(w,buf) ;
1024 _DtTermTabSet(Widget w) /* HTS ESCH */
1026 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
1027 TermBuffer tb = tw->term.tpd->termBuffer ;
1028 Debug('P', fprintf(stderr,">>In func _DtTermTabSet\n")) ;
1029 (void)_DtTermPrimBufferSetTab(tb,tw->term.tpd->cursorColumn) ;
1033 _DtTermSaveCursor(Widget w) /* DECSC ESC7 */
1035 DtTermWidget vtw = (DtTermWidget) w;
1036 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
1037 DtTermBuffer tb = (DtTermBuffer)tw->term.tpd->termBuffer ;
1038 DtTermData vtd = vtw->vt.td;
1040 Debug('P', fprintf(stderr,">>In func _DtTermSaveCursor\n")) ;
1041 vtd->saveCursor.cursorRow = vtw->term.tpd->cursorRow ;
1042 vtd->saveCursor.cursorColumn = vtw->term.tpd->cursorColumn ;
1043 vtd->saveCursor.originMode = vtw->vt.td->originMode ;
1044 /* The following is save at the TermPrim level */
1045 /* vtw->vt.td->saveCursor.wrapMode = */
1046 vtd->saveCursor.enhVideoState = vtd->enhVideoState ;
1047 vtd->saveCursor.enhFieldState = vtd->enhFieldState ;
1048 vtd->saveCursor.enhFgColorState = vtd->enhFgColorState;
1049 vtd->saveCursor.enhBgColorState = vtd->enhBgColorState;
1050 vtd->saveCursor.GL = vtd->GL;
1051 vtd->saveCursor.GR = vtd->GR;
1052 vtd->saveCursor.G0 = vtd->G0;
1053 vtd->saveCursor.G1 = vtd->G1;
1054 vtd->saveCursor.G2 = vtd->G2;
1055 vtd->saveCursor.G3 = vtd->G3;
1056 vtd->saveCursor.singleShiftFont = vtd->singleShiftFont;
1057 vtd->saveCursor.singleShiftPending = vtd->singleShiftPending;
1061 _DtTermRestoreCursor(Widget w) /* DECRC ESC8 */
1063 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
1064 DtTermPrimData tpd = tw->term.tpd;
1065 DtTermWidget vtw = (DtTermWidget) w;
1066 DtTermData vtd = vtw->vt.td;
1068 Debug('P', fprintf(stderr,">>In func _DtTermRestoreCursor\n")) ;
1069 tpd->cursorRow = vtd->saveCursor.cursorRow ;
1070 tpd->cursorColumn = vtd->saveCursor.cursorColumn ;
1071 vtw->vt.td->originMode = vtd->saveCursor.originMode ;
1072 tpd->autoWrapRight = vtd->saveCursor.wrapMode ;
1073 vtd->enhVideoState = vtd->saveCursor.enhVideoState ;
1074 vtd->enhFieldState = vtd->saveCursor.enhFieldState ;
1075 vtd->enhFgColorState = vtd->saveCursor.enhFgColorState;
1076 vtd->enhBgColorState = vtd->saveCursor.enhBgColorState;
1077 vtd->GR = vtd->saveCursor.GR;
1078 vtd->GL = vtd->saveCursor.GL;
1079 vtd->G0 = vtd->saveCursor.G0;
1080 vtd->G1 = vtd->saveCursor.G1;
1081 vtd->G2 = vtd->saveCursor.G2;
1082 vtd->G3 = vtd->saveCursor.G3;
1083 vtd->singleShiftFont = vtd->saveCursor.singleShiftFont;
1084 vtd->singleShiftPending = vtd->saveCursor.singleShiftPending;
1085 (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
1086 tpd->topRow + tpd->cursorRow, tpd->cursorColumn, enhVideo,
1087 vtd->enhVideoState);
1088 (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
1089 tpd->topRow + tpd->cursorRow, tpd->cursorColumn, enhField,
1090 vtd->enhFieldState);
1091 (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
1092 tpd->topRow + tpd->cursorRow, tpd->cursorColumn, enhFont,
1094 (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
1095 tpd->topRow + tpd->cursorRow, tpd->cursorColumn, enhBgColor,
1096 vtd->saveCursor.enhBgColorState);
1097 (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
1098 tpd->topRow + tpd->cursorRow, tpd->cursorColumn, enhFgColor,
1099 vtd->saveCursor.enhFgColorState);
1100 if ( vtd->originMode ) {
1101 if (tpd->cursorRow < tpd->scrollLockTopRow )
1102 tpd->cursorRow = tpd->scrollLockTopRow ;
1103 else if (tpd->cursorRow > tpd->scrollLockBottomRow )
1104 tpd->cursorRow = tpd->scrollLockBottomRow ;
1109 _DtTermAppKeypad(Widget w) /* DECPAM ESC= */
1111 DtTermWidget vtw = (DtTermWidget) w;
1112 Debug('P', fprintf(stderr,">>In func _DtTermAppKeypad\n")) ;
1113 vtw->vt.td->applicationKPMode=True;
1117 _DtTermNormalKeypad(Widget w) /* DECPNM ESC> */
1119 DtTermWidget vtw = (DtTermWidget) w;
1120 Debug('P', fprintf(stderr,">>In func _DtTermNormalKeypad\n")) ;
1121 vtw->vt.td->applicationKPMode=False;
1125 _DtTermS8C1T(Widget w) /* S8C1T ESCG */
1127 DtTermWidget vtw = (DtTermWidget) w;
1128 Debug('P', fprintf(stderr,">>In func _vt8CIT\n")) ;
1129 vtw->vt.td->S8C1TMode=True;
1133 _DtTermS7C1T(Widget w) /* S7C1T ESCF */
1135 DtTermWidget vtw = (DtTermWidget) w;
1136 Debug('P', fprintf(stderr,">>In func _vt8CIT\n")) ;
1137 vtw->vt.td->S8C1TMode=False;
1141 _DtTermSetCompatLevel(Widget w) /* DECSCL CSI p;p"p (last p literal) */
1143 ParserContext context ;
1144 DtTermWidget vtw = (DtTermWidget) w;
1145 Debug('P', fprintf(stderr,">>In func _DtTermSetCompatLevel\n")) ;
1146 context = GetParserContext(w) ;
1147 STORELASTARG(context) ;
1148 vtw->vt.td->compatLevel= 2; /* assume vt200 mode */
1149 switch ( PCOUNT(context) ) {
1150 case 1: switch (context->parms[1]) {
1151 case 61: vtw->vt.td->compatLevel= 1;
1152 vtw->vt.td->S8C1TMode=False;
1154 case 62: vtw->vt.td->S8C1TMode=True;
1158 case 2: switch (context->parms[2]) {
1160 case 2: vtw->vt.td->S8C1TMode=True;
1163 vtw->vt.td->S8C1TMode=False;
1170 _DtTermInvokeG3(Widget w) /* LS3R ESC| */
1172 ParserContext context ;
1174 Debug('P', fprintf(stderr,">>In func _DtTermInvokeG3\n")) ;
1175 context = GetParserContext(w) ;
1179 _DtTermInvokeG2(Widget w) /* LS3R ESC} */
1181 ParserContext context ;
1183 Debug('P', fprintf(stderr,">>In func _DtTermInvokeG2\n")) ;
1184 context = GetParserContext(w) ;
1188 _DtTermScrollUp(Widget w) /* SU CSIpS */
1190 ParserContext context ;
1191 DtTermWidget vtw = (DtTermWidget) w;
1194 Debug('P', fprintf(stderr,">>In func _DtTermScrollUp\n")) ;
1195 #define EXIT_IF_OUTSIDE_SR(w) if((w)->term.tpd->scrollLockTopRow > \
1196 (w)->term.tpd->cursorRow || \
1197 (w)->term.tpd->scrollLockBottomRow < \
1198 (w)->term.tpd->cursorRow) \
1200 EXIT_IF_OUTSIDE_SR(vtw)
1202 context = GetParserContext(w) ;
1203 row = vtw->term.tpd->cursorRow;
1204 col = vtw->term.tpd->cursorColumn;
1205 STORELASTARG(context) ;
1206 if (!context->parms[1])
1207 context->parms[1] = 1;
1208 else if (context->parms[1] > MAXSHORT)
1209 context->parms[1] = MAXSHORT - 100;
1211 /* clip the number of rows to the scroll region... */
1212 if (context->parms[1] > (vtw->term.tpd->scrollLockBottomRow -
1213 vtw->term.tpd->scrollLockTopRow + 1)) {
1214 context->parms[1] = vtw->term.tpd->scrollLockBottomRow -
1215 vtw->term.tpd->scrollLockTopRow + 1;
1218 vtw->term.tpd->cursorRow = TOPMARGIN(vtw) ;
1219 _DtTermFuncDeleteLine(w, context->parms[1], fromParser);
1220 vtw->term.tpd->cursorRow = row;
1221 vtw->term.tpd->cursorColumn = col;
1225 _DtTermScrollDown(Widget w) /* SD CSIpT */
1227 ParserContext context ;
1228 DtTermWidget vtw = (DtTermWidget) w;
1231 Debug('P', fprintf(stderr,">>In func _DtTermScrollDown\n")) ;
1232 EXIT_IF_OUTSIDE_SR(vtw)
1234 context = GetParserContext(w) ;
1235 row = vtw->term.tpd->cursorRow;
1236 col = vtw->term.tpd->cursorColumn ;
1237 STORELASTARG(context) ;
1238 if (!context->parms[1])
1239 context->parms[1] = 1;
1240 else if (context->parms[1] > MAXSHORT)
1241 context->parms[1] = MAXSHORT - 100;
1243 /* clip the number of rows to the scroll region... */
1244 if (context->parms[1] > (vtw->term.tpd->scrollLockBottomRow -
1245 vtw->term.tpd->scrollLockTopRow) + 1) {
1246 context->parms[1] = vtw->term.tpd->scrollLockBottomRow -
1247 vtw->term.tpd->scrollLockTopRow + 1;
1250 vtw->term.tpd->cursorRow = TOPMARGIN(vtw) ;
1251 _DtTermFuncInsertLine(w, context->parms[1], fromParser) ;
1252 vtw->term.tpd->cursorRow = row;
1253 vtw->term.tpd->cursorColumn = col;
1257 _DtTermRestoreModeValues(Widget w) /* xterm - Restore DEC mode values CSI?pr */
1259 ParserContext context ;
1260 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
1261 DtTermWidget vtw = (DtTermWidget)w;
1262 DtTermData vtd = vtw->vt.td;
1264 Debug ('P', fprintf(stderr,">>In func _DtTermPModeReset\n")) ;
1265 context = GetParserContext(w) ;
1266 STORELASTARG(context) ;
1267 cnt = PCOUNT(context) ;
1268 for (i=1;i<=cnt;i++) {
1269 switch ( context->parms[i]) {
1271 case 1: /* Cursor key (Normal/Application) */
1272 vtd->applicationMode = vtd->saveDECMode.applicationMode ;
1274 #ifdef NOT_SUPPORTED
1275 case 2: /* set vt52 mode */
1277 #endif /* NOT_SUPPORTED */
1278 case 3: /* Columns (80/132) */
1279 vtd->col132Mode = vtd->saveDECMode.col132Mode ;
1281 case 4: /* Scroll Mode ( jump/smooth ) */
1282 _DtTermPrimScrollComplete(w, True) ;
1283 vtw->term.jumpScroll = vtd->saveDECMode.jumpScrollMode ;
1285 case 5: /* Screen mode */
1286 vtw->term.reverseVideo = vtd->saveDECMode.inverseVideoMode ;
1288 case 6: /* Origin mode (on/off)*/
1289 vtd->originMode = vtd->saveDECMode.originMode ;
1291 case 7: /* Auto wrap (On/Off) */
1292 vtw->term.tpd->autoWrapRight = vtd->saveDECMode.wrapMode ;
1294 case 8: /* Auto repeat (Off) */
1295 /* implemented in the server */
1297 #ifdef NOT_SUPPORTED
1298 case 18: /* Print form feed (Off) */
1300 case 19: /* Print extent (scrolling region) */
1302 #endif /* NOT_SUPPORTED */
1303 case 25: /* Text cursor enable (Off) */
1304 _DtTermPrimSetCursorVisible(w,
1305 vtd->saveDECMode.cursorVisible);
1309 case 40: /* 80/132 mode (disallow/allow) */
1310 vtw->vt.c132 = vtd->saveDECMode.allow80_132ColMode;
1312 case 41: /* curses fix (off/on) */
1313 vtd->fixCursesMode = vtd->saveDECMode.fixCursesMode;
1315 case 44: /* margin bell (off/on) */
1316 vtw->term.marginBell = vtd->saveDECMode.marginBellMode;
1318 case 45: /* Reverse-wraparound mode */
1319 vtd->reverseWrapMode = vtd->saveDECMode.reverseWrapMode ;
1321 case 46: /* logging (stop/start ) */
1322 if (vtd->saveDECMode.logging) {
1323 vtw->term.logging = True ;
1324 _DtTermPrimStartLog(w);
1326 vtw->term.logging = False ;
1327 _DtTermPrimCloseLog(w) ;
1330 #ifdef NOT_SUPPORTED
1331 case 47: /* screen buffer (normal) */
1333 case 1000: /* don't send mouse x and y */
1335 case 1001: /* don't use hilite mouse tracking */
1337 #endif /* NOT_SUPPORTED */
1343 _DtTermSaveModeValues(Widget w) /* xterm - Save DEC mode values CSI?ps */
1345 ParserContext context ;
1346 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
1347 DtTermWidget vtw = (DtTermWidget)w;
1348 DtTermData vtd = vtw->vt.td;
1350 Debug ('P', fprintf(stderr,">>In func _DtTermPModeReset\n")) ;
1351 context = GetParserContext(w) ;
1352 STORELASTARG(context) ;
1353 cnt = PCOUNT(context) ;
1354 for (i=1;i<=cnt;i++) {
1355 switch ( context->parms[i]) {
1357 case 1: /* Cursor key (Normal/Application) */
1358 vtd->saveDECMode.applicationMode = vtd->applicationMode ;
1360 #ifdef NOT_SUPPORTED
1361 case 2: /* set vt52 mode */
1363 #endif /* NOT_SUPPORTED */
1364 case 3: /* Columns (80/132) */
1365 vtd->saveDECMode.col132Mode = vtd->col132Mode ;
1367 case 4: /* Scroll Mode ( jump/smooth ) */
1368 vtd->saveDECMode.jumpScrollMode = vtw->term.jumpScroll ;
1370 case 5: /* Screen mode */
1371 vtd->saveDECMode.inverseVideoMode = vtw->term.reverseVideo ;
1373 case 6: /* Origin mode (on/off)*/
1374 vtd->saveDECMode.originMode = vtd->originMode ;
1376 case 7: /* Auto wrap (On/Off) */
1377 vtd->saveDECMode.wrapMode = vtw->term.tpd->autoWrapRight ;
1379 case 8: /* Auto repeat (Off) */
1380 /* implemented in the server */
1382 #ifdef NOT_SUPPORTED
1383 case 18: /* Print form feed (Off) */
1385 case 19: /* Print extent (scrolling region) */
1387 #endif /* NOT_SUPPORTED */
1388 case 25: /* Text cursor enable (Off) */
1389 vtd->saveDECMode.cursorVisible =
1390 _DtTermPrimGetCursorVisible(w);
1393 case 40: /* 80/132 mode (disallow/allow) */
1394 vtd->saveDECMode.allow80_132ColMode = vtw->vt.c132;
1396 case 41: /* curses fix (off/on) */
1397 vtd->saveDECMode.fixCursesMode = vtd->fixCursesMode ;
1399 case 44: /* margin bell (off/on) */
1400 vtd->saveDECMode.marginBellMode = vtw->term.marginBell ;
1402 case 45: /* Reverse-wraparound mode */
1403 vtd->saveDECMode.reverseWrapMode = vtd->reverseWrapMode ;
1405 case 46: /* logging (stop/start ) */
1406 vtd->saveDECMode.logging = vtw->term.logging;
1408 #ifdef NOT_SUPPORTED
1409 case 47: /* screen buffer (normal) */
1411 case 1000: /* don't send mouse x and y */
1413 case 1001: /* don't use hilite mouse tracking */
1415 #endif /* NOT_SUPPORTED */
1422 _DtTermAlignTest(Widget w) /* DECALN ESC#8 */
1424 DtTermWidget vtw = (DtTermWidget) w;
1425 int tlrow, blrow, cnt ;
1426 Debug('P', fprintf(stderr,">>In func _DtTermAlignTest\n")) ;
1427 vtw->term.tpd->parserNotInStartState = False ;
1428 tlrow = vtw->term.tpd->scrollLockTopRow ;
1429 blrow = vtw->term.tpd->scrollLockBottomRow ;
1430 vtw->term.tpd->scrollLockTopRow = TOPROW(w) ; ;
1431 vtw->term.tpd->scrollLockBottomRow = BOTTOMROW(vtw) ;
1432 cnt = (BOTTOMROW(vtw)+BASE)*(LASTCOLUMN(vtw)+BASE);
1433 vtw->term.tpd->cursorColumn = FIRSTCOLUMN(w) ;
1434 vtw->term.tpd->cursorRow = TOPROW(w) ;
1435 while(cnt--) _DtTermPrimInsertText(w,(unsigned char *) "E", 1) ;
1436 vtw->term.tpd->scrollLockTopRow = tlrow ;
1437 vtw->term.tpd->scrollLockBottomRow = blrow ;
1438 vtw->term.tpd->cursorRow = CEILING(vtw) ;
1439 vtw->term.tpd->cursorColumn = FIRSTCOLUMN(w) ;
1443 _DtTermInvokeG1(Widget w) /* ESC~ESC */
1445 ParserContext context ;
1447 Debug('P', fprintf(stderr,">>In func _DtTermInvokeG1\n")) ;
1448 context = GetParserContext(w) ;
1452 _DtTermSelEraseInLine(Widget w) /* DECSEL ESC?pK */
1454 DtTermWidget vtw = (DtTermWidget) w;
1455 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
1456 TermBuffer tb = tw->term.tpd->termBuffer ;
1457 DtTermPrimData tpd = tw->term.tpd;
1458 DtTermData td = vtw->vt.td;
1459 ParserContext context ;
1461 int c,col1,col2,col,row ;
1463 DtTermInsertCharMode saveInsertCharMode;
1465 Debug('P', fprintf(stderr,">>In func _DtTermSelEraseInLine\n")) ;
1467 context = GetParserContext(w) ;
1468 STORELASTARG(context) ;
1469 col1 = FIRSTCOLUMN(vtw) ;
1470 col2 = LASTCOLUMN(vtw) ;
1471 switch ( context->parms[1] ) {
1473 col1= tpd->cursorColumn;
1476 col2 = tpd->cursorColumn;
1483 /* save away the current cursor position... */
1484 col = tpd->cursorColumn ;
1485 row = tpd->cursorRow ;
1487 /* save away the current insert mode... */
1488 saveInsertCharMode = vtw->term.tpd->insertCharMode;
1490 /* insert char needs to be off... */
1491 tpd->insertCharMode = DtTERM_INSERT_CHAR_OFF;
1493 tpd->parserNotInStartState = False ;
1497 (void)_DtTermPrimBufferGetEnhancement(tb, tpd->cursorRow,
1498 c, &evalues, &cnt, countAll);
1501 if (evalues[(int)enhField] == FIELD_UNPROTECT) {
1502 (void) _DtTermPrimBufferSetEnhancement(tb, tpd->cursorRow,
1503 c, enhVideo, evalues[(int)enhVideo]);
1504 (void) _DtTermPrimBufferSetEnhancement(tb, tpd->cursorRow,
1505 c, enhFgColor, evalues[(int)enhFgColor]);
1506 (void) _DtTermPrimBufferSetEnhancement(tb, tpd->cursorRow,
1507 c, enhBgColor, evalues[(int)enhBgColor]);
1508 while ((c <= col2) && cnt--) {
1509 tpd->cursorColumn = c;
1510 (void) _DtTermPrimInsertText(w, (unsigned char *) " ", 1);
1518 /* restore the insert char mode... */
1519 tpd->insertCharMode = saveInsertCharMode;
1521 /* restore the cursor position... */
1522 tpd->cursorColumn = col;
1523 tpd->cursorRow = row;
1525 /* restore the current enhancement state... */
1526 (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
1527 tpd->topRow + tpd->cursorRow, tpd->cursorColumn, enhVideo,
1529 (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
1530 tpd->topRow + tpd->cursorRow, tpd->cursorColumn, enhFgColor,
1531 td->enhFgColorState);
1532 (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
1533 tpd->topRow + tpd->cursorRow, tpd->cursorColumn, enhBgColor,
1534 td->enhBgColorState);
1538 _DtTermSelEraseInDisplay(Widget w) /* DECSED ESC?pJ */
1540 DtTermWidget vtw = (DtTermWidget) w;
1541 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
1542 TermBuffer tb = tw->term.tpd->termBuffer ;
1543 ParserContext context ;
1545 int r,col1,col2,row1,row2,col,row ;
1547 Debug('P', fprintf(stderr,">>In func _DtTermSelEraseInDisplay\n")) ;
1549 context = GetParserContext(w) ;
1550 STORELASTARG(context) ;
1551 col1 = FIRSTCOLUMN(vtw) ;
1552 row1 = TOPROW(vtw) ;
1553 col2 = LASTCOLUMN(vtw) ;
1554 row2 = BOTTOMROW(vtw) ;
1555 switch ( context->parms[1] ) {
1556 case 0: col1= vtw->term.tpd->cursorColumn;
1557 row1 = vtw->term.tpd->cursorRow;
1559 case 1: col2 = vtw->term.tpd->cursorColumn;
1560 row2 = vtw->term.tpd->cursorRow;
1565 col = vtw->term.tpd->cursorColumn;
1566 row = vtw->term.tpd->cursorRow;
1567 vtw->term.tpd->cursorColumn = col1 ;
1568 vtw->term.tpd->cursorRow = row1;
1569 context->workingNum = 0 ; /* erase to the end of line */
1570 _DtTermSelEraseInLine(w) ;
1571 context->workingNum = 2 ; /* erase the whole row */
1572 for ( r=row1+1; r<row2; r++) {
1573 vtw->term.tpd->cursorRow = r;
1574 _DtTermSelEraseInLine(w) ;
1576 vtw->term.tpd->cursorColumn = col2 ;
1577 vtw->term.tpd->cursorRow = row2;
1578 context->workingNum = 2 ; /* erase the beginning of the line */
1579 _DtTermSelEraseInLine(w) ;
1580 vtw->term.tpd->cursorColumn = col ;
1581 vtw->term.tpd->cursorRow = row;
1586 _DtTermSingleShiftG2(Widget w) /* SS2 ESCN */
1588 DtTermWidget vtw = (DtTermWidget) w;
1589 DtTermData vtd = vtw->vt.td;
1591 Debug('P', fprintf(stderr,">>In func _DtTermSingleShiftG2\n")) ;
1592 vtd->singleShiftPending = True;
1593 vtd->singleShiftFont = vtd->G2;
1597 _DtTermSingleShiftG3(Widget w) /* SS3 ESCO */
1599 DtTermWidget vtw = (DtTermWidget) w;
1600 DtTermData vtd = vtw->vt.td;
1602 Debug('P', fprintf(stderr,">>In func _DtTermSingleShiftG3\n")) ;
1603 vtd->singleShiftPending = True;
1604 vtd->singleShiftFont = vtd->G3;
1608 _DtTermLoadCharSet(Widget w) /* vt220 DCS - download char set ESCPpST */
1610 /* we're not implementing this */
1613 /*********************************************************************
1614 * The next 3 functions handle the user key string loading
1615 * DCS Pc;Pl | Ky1/st1;ky2/st2;...kyn/stn ST
1618 _DtTermParseUserKeyClear(Widget w) /* vt220 DECUDK clear function keys*/
1620 DtTermWidget vtw = (DtTermWidget) w;
1621 DtTermData vtd = vtw->vt.td;
1622 ParserContext context ;
1623 Debug('P', fprintf(stderr,">>In func _DtTermLoadSoftKey\n")) ;
1624 context = GetParserContext(w) ;
1625 STORELASTARG(context) ;
1626 if ( !vtd->userKeysLocked )
1628 vtd->needToLockUserKeys = False ;
1629 if (context->parms[1] == 0)
1630 _DtTermFunctionKeyClear(w) ;
1631 if (context->parms[0] == 2 && context->parms[2] == 0)
1632 vtd->needToLockUserKeys = True ;
1634 _DtTermClearParam(w) ;
1637 _DtTermParseUserKeyLoad(Widget w) /* vt220 DECUDK load function string */
1639 DtTermWidget vtw = (DtTermWidget) w;
1640 DtTermData vtd = vtw->vt.td;
1641 ParserContext context ;
1642 Debug('P', fprintf(stderr,">>In func _DtTermLoadSoftKey\n")) ;
1643 context = GetParserContext(w) ;
1644 STORELASTARG(context) ;
1645 if ( !vtd->userKeysLocked)
1647 context->stringParms[0].str[context->stringParms[0].length/2] =
1648 (unsigned char)0 ; /* Null terminate */
1649 _DtTermFunctionKeyStringStore(w,context->parms[1],
1650 (char *)context->stringParms[0].str);
1652 _DtTermClearParam(w) ;
1656 _DtTermParseUserKeyLoadLast(Widget w) /* vt220 DECUDK load function string */
1658 DtTermWidget vtw = (DtTermWidget) w;
1659 DtTermData vtd = vtw->vt.td;
1660 _DtTermParseUserKeyLoad(w);
1661 if (vtd->needToLockUserKeys) vtd->userKeysLocked = True ;
1662 vtd->needToLockUserKeys = False ;
1666 _DtTermParseHexDigit(Widget w) /* vt220 DECUDK store hex digit*/
1668 ParserContext context ;
1669 int ci, left_byte, i;
1671 Debug('P', fprintf(stderr,">>In func _DtTermLoadSoftKey\n")) ;
1672 context = GetParserContext(w) ;
1673 if ( (int)context->stringParms[0].length < 2*STR_SIZE-1 ) {
1674 /* fold the hex digits into characters */
1675 i = context->stringParms[0].length ;
1676 cbuf[0] = *context->inputChar ;
1678 sscanf(cbuf,"%x",&ci) ;
1680 left_byte = (i+1)%2 ;
1683 context->stringParms[0].str[i] = c<<4 ;
1685 context->stringParms[0].str[i] |= c & 0x0F ;
1686 context->stringParms[0].length++ ;
1691 _DtTermReset(Widget w) /* RIS ESCc */
1693 ParserContext context ;
1695 Debug('P', fprintf(stderr,">>In func _DtTermReset\n")) ;
1696 context = GetParserContext(w) ;
1697 _DtTermFuncHardReset(w,0 ,fromParser) ;
1701 _DtTermSelectG2(Widget w) /* LS2 ESCn */
1703 DtTermWidget vtw = (DtTermWidget)w ;
1704 DtTermData vtd = vtw->vt.td;
1705 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
1706 DtTermPrimData tpd = tw->term.tpd;
1708 Debug('P', fprintf(stderr,">>In func _DtTermSelectG2\n")) ;
1711 vtd->enhFontState = *vtd->GL;
1712 (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
1713 tpd->topRow + tpd->cursorRow, tpd->cursorColumn,
1714 enhFont, vtd->enhFontState);
1718 _DtTermSelectG3(Widget w) /* LS3 ESCo */
1720 DtTermWidget vtw = (DtTermWidget)w ;
1721 DtTermData vtd = vtw->vt.td;
1722 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
1723 DtTermPrimData tpd = tw->term.tpd;
1725 Debug('P', fprintf(stderr,">>In func _DtTermSelectG3\n")) ;
1727 vtd->enhFontState = *vtd->GL;
1728 (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
1729 tpd->topRow + tpd->cursorRow, tpd->cursorColumn,
1730 enhFont, vtd->enhFontState);
1734 _DtTermParseStatus(Widget w) /* DECID (same as DA) ESCZ */
1736 _DtTermDeviceAttributes(w) ;
1740 _DtTermSetCharEraseMode(Widget w) /* DECSCA ESCp"q */
1742 DtTermWidget vtw = (DtTermWidget) w;
1743 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
1744 DtTermPrimData tpd = tw->term.tpd;
1745 ParserContext context ;
1746 Debug('P', fprintf(stderr,">>In func _DtTermSetCharEraseMode\n")) ;
1747 context = GetParserContext(w) ;
1748 STORELASTARG(context) ;
1749 switch ( context->parms[1] ) {
1750 case 0: /* set back to default which is unprotect */
1753 vtw->vt.td->enhFieldState = FIELD_UNPROTECT;
1754 (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
1755 tpd->topRow + tpd->cursorRow, tpd->cursorColumn,
1756 enhField, vtw->vt.td->enhFieldState);
1759 vtw->vt.td->enhFieldState = FIELD_PROTECT;
1760 (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
1761 tpd->topRow + tpd->cursorRow, tpd->cursorColumn,
1762 enhField, vtw->vt.td->enhFieldState);
1768 _DtTermSingleWide(Widget w) /* DECSWL ESC#5 */
1770 ParserContext context ;
1772 Debug('P', fprintf(stderr,">>In func _DtTermSingleWide\n")) ;
1773 context = GetParserContext(w) ;
1777 _DtTermDoubleWide(Widget w) /* DECDWL ESC#6 */
1779 ParserContext context ;
1781 Debug('P', fprintf(stderr,">>In func _DtTermDoubleWide\n")) ;
1782 context = GetParserContext(w) ;
1786 _DtTermDoubleHigh(Widget w) /* DECWHL ESC#4 */
1788 ParserContext context ;
1790 Debug('P', fprintf(stderr,">>In func _DtTermDoubleHigh\n")) ;
1791 context = GetParserContext(w) ;
1795 _DtTermParseFontG0(Widget w)
1797 DtTermWidget vtw = (DtTermWidget)w ;
1798 DtTermData vtd = vtw->vt.td;
1799 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
1800 DtTermPrimData tpd = tw->term.tpd;
1801 ParserContext context ;
1802 context = GetParserContext(w) ;
1804 Debug('P', fprintf(stderr,">>In func _DtTermParseFontG0\n")) ;
1805 switch (*context->inputChar) {
1807 vtd->G0 = FONT_NORMAL;
1811 vtd->G0 = FONT_LINEDRAW;
1815 vtd->enhFontState = *vtd->GL;
1816 (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
1817 tpd->topRow + tpd->cursorRow, tpd->cursorColumn,
1818 enhFont, vtd->enhFontState);
1822 _DtTermParseFontG1(Widget w)
1824 DtTermWidget vtw = (DtTermWidget)w ;
1825 DtTermData vtd = vtw->vt.td;
1826 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
1827 DtTermPrimData tpd = tw->term.tpd;
1828 ParserContext context ;
1829 context = GetParserContext(w) ;
1831 Debug('P', fprintf(stderr,">>In func _DtTermParseFontG1\n")) ;
1832 switch (*context->inputChar) {
1834 vtd->G1 = FONT_NORMAL;
1838 vtd->G1 = FONT_LINEDRAW;
1842 vtd->enhFontState = *vtd->GL;
1843 (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
1844 tpd->topRow + tpd->cursorRow, tpd->cursorColumn,
1845 enhFont, vtd->enhFontState);
1849 _DtTermParseFontG2(Widget w)
1851 DtTermWidget vtw = (DtTermWidget)w ;
1852 DtTermData vtd = vtw->vt.td;
1853 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
1854 DtTermPrimData tpd = tw->term.tpd;
1855 ParserContext context ;
1856 context = GetParserContext(w) ;
1858 Debug('P', fprintf(stderr,">>In func _DtTermParseFontG1\n")) ;
1859 switch (*context->inputChar) {
1861 vtd->G2 = FONT_NORMAL;
1865 vtd->G2 = FONT_LINEDRAW;
1869 vtd->enhFontState = *vtd->GL;
1870 (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
1871 tpd->topRow + tpd->cursorRow, tpd->cursorColumn,
1872 enhFont, vtd->enhFontState);
1876 _DtTermParseFontG3(Widget w)
1878 DtTermWidget vtw = (DtTermWidget)w ;
1879 DtTermData vtd = vtw->vt.td;
1880 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
1881 DtTermPrimData tpd = tw->term.tpd;
1882 ParserContext context ;
1883 context = GetParserContext(w) ;
1885 Debug('P', fprintf(stderr,">>In func _DtTermParseFontG1\n")) ;
1886 switch (*context->inputChar) {
1888 vtd->G3 = FONT_NORMAL;
1892 vtd->G3 = FONT_LINEDRAW;
1896 vtd->enhFontState = *vtd->GL;
1897 (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
1898 tpd->topRow + tpd->cursorRow, tpd->cursorColumn,
1899 enhFont, vtd->enhFontState);
1903 _DtTermParseFontShift(Widget w) /* Ctrl-E Ctrl-F */
1905 DtTermWidget vtw = (DtTermWidget)w ;
1906 DtTermData vtd = vtw->vt.td;
1907 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
1908 DtTermPrimData tpd = tw->term.tpd;
1909 ParserContext context ;
1910 context = GetParserContext(w) ;
1912 Debug('P', fprintf(stderr,">>In func _DtTermParseFontShift\n")) ;
1913 switch (*context->inputChar) {
1925 vtd->enhFontState = *vtd->GL;
1926 (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
1927 tpd->topRow + tpd->cursorRow, tpd->cursorColumn,
1928 enhFont, vtd->enhFontState);
1932 _DtTermParseTab(Widget w) /* Crtl-I */
1934 DtTermWidget vtw = (DtTermWidget)w ;
1935 Debug('P', fprintf(stderr,">>In func _DtTermParseTab\n")) ;
1936 if (vtw->term.tpd->cursorColumn > LASTCOLUMN(vtw)) {
1937 if (vtw->vt.td->fixCursesMode) {
1938 (void) _DtTermNextLine(w);
1939 (void) _DtTermFuncTab(w, 1, fromParser);
1941 /* we already tabbed to the end of the line, so do nothing... */
1944 (void) _DtTermFuncTab(w, 1, fromParser);
1950 _DtTermParseLF /* LineFeed (LF) or newline (NL) Ctrl-J,
1951 Vertical Tab Ctrl-K, Form Feed (NP) Ctrl-L */
1956 DtTermWidget vtw = (DtTermWidget)w ;
1957 Debug('P', fprintf(stderr,">>In func _vtParseLR\n")) ;
1959 if (vtw->term.tpd->cursorRow == BOTTOMMARGIN(vtw))
1962 ** scroll one line...
1964 (void) _DtTermPrimScrollText(w, 1);
1965 vtw->term.tpd->cursorRow = BOTTOMMARGIN(vtw);
1968 if (!(vtw->term.tpd->cursorRow == BOTTOMROW(vtw))) {
1969 vtw->term.tpd->cursorRow++ ;
1972 (void) _DtTermPrimFillScreenGap(w);
1974 if (vtw->term.tpd->autoLineFeed )
1975 _DtTermPrimParseCR(w);
1979 _DtTermSoftReset /* DECSTR ESC!p */
1984 Debug('P', fprintf(stderr,">>In func _DtTermSoftReset\n")) ;
1985 _DtTermFuncSoftReset(w,0 ,fromParser) ;
1989 _DtTermParseBackspace /* Ctrl-H */
1994 ParserContext context ;
1995 DtTermWidget vtw = (DtTermWidget) w;
1996 int row,col,fcol,cnt ;
1997 Debug('P', fprintf(stderr,">>In func _DtTermParseBackspace\n")) ;
1998 context = GetParserContext(w) ;
1999 fcol = FIRSTCOLUMN(vtw) ;
2000 row = vtw->term.tpd->cursorRow;
2001 col = vtw->term.tpd->cursorColumn;
2004 if (vtw->vt.td->reverseWrapMode) {
2005 if ( --row < TOPROW(vtw)) row = BOTTOMROW(vtw);
2006 if (vtw->vt.td->originMode && row < TOPMARGIN(vtw))
2007 row =BOTTOMMARGIN(vtw);
2008 col = LASTCOLUMN(vtw) ;
2014 vtw->term.tpd->cursorRow = row;
2015 vtw->term.tpd->cursorColumn = col;
2029 Window parentReturn;
2030 Window *childrenReturn;
2031 unsigned int nChildrenReturn;
2037 unsigned int widthReturn;
2038 unsigned int heightReturn;
2039 unsigned int topWidthReturn;
2040 unsigned int topHeightReturn;
2041 unsigned int borderWidthReturn;
2042 unsigned int depthReturn;
2049 if (XmIsMotifWMRunning(w)) {
2050 /* get the window we want to figure the offsets for... */
2051 topWindow = XtWindow(w);
2053 /* and the display involved... */
2054 display = XtDisplay(w);
2056 (void) XQueryTree(display, topWindow, &rootWindow, &parentReturn,
2057 &childrenReturn, &nChildrenReturn);
2058 (void) XFree(childrenReturn);
2060 /* walk up the tree until the parent window is root... */
2061 while (parentReturn != rootWindow) {
2062 topWindow = parentReturn;
2063 (void) XQueryTree(display, topWindow, &rootWindow,
2064 &parentReturn, &childrenReturn, &nChildrenReturn);
2065 (void) XFree(childrenReturn);
2068 /* we now know what our top window is. translate our upper
2069 * left corner relative to its upper left corner...
2071 (void) XTranslateCoordinates(display, XtWindow(w), topWindow,
2072 0, 0, &destXReturn, &destYReturn, &childReturn);
2073 *xOffset = destXReturn;
2074 *yOffset = destYReturn;
2076 /* now that we know the top window, we can figure out the size
2077 * difference between the two windows...
2079 (void) XGetGeometry(display, topWindow, &rootWindow,
2080 &destXReturn, &destYReturn, &topWidthReturn,
2081 &topHeightReturn, &borderWidthReturn, &depthReturn);
2083 (void) XGetGeometry(display, XtWindow(w), &rootWindow,
2084 &destXReturn, &destYReturn, &widthReturn, &heightReturn,
2085 &borderWidthReturn, &depthReturn);
2087 *widthOffset = topWidthReturn - widthReturn;
2088 *heightOffset = topHeightReturn - heightReturn;
2093 _DtTermParseSunMisc /* Misc sun esc seqs */
2098 ParserContext context ;
2099 DtTermWidget vtw = (DtTermWidget) w;
2100 Display *display = XtDisplay(w);
2101 int i, scr_num = XScreenNumberOfScreen(XtScreen(w));
2102 Window win = XtWindow(w);
2105 XWindowChanges values;
2110 Dimension height,width;
2111 char *fmt,*s,*title,*icon;
2117 context = GetParserContext(w) ;
2118 STORELASTARG(context) ;
2120 for (sw = w; !XtIsShell(sw); sw = XtParent(sw));
2121 sh_win = XtWindow(sw) ;
2122 switch (context->parms[1])
2125 XMapWindow(display,sh_win);
2128 XIconifyWindow(display,sh_win,scr_num);
2131 (void) GetWindowOffsets(sw, &xOffset, &yOffset, &widthOffset,
2134 (void) XMoveWindow(display, sh_win,
2135 context->parms[2] + xOffset, context->parms[3] + yOffset);
2137 (void) XtVaSetValues(sw, XmNx, context->parms[2] + xOffset,
2138 XmNy, context->parms[3] + yOffset, NULL);
2141 (void) GetWindowOffsets(sw, &xOffset, &yOffset, &widthOffset,
2143 (void) XtVaSetValues(sw, XmNwidth, context->parms[3] - widthOffset,
2144 XmNheight,context->parms[2] - heightOffset, NULL);
2147 XRaiseWindow(display,sh_win);
2150 XLowerWindow(display,sh_win);
2153 _DtTermPrimFuncRedrawDisplay(w, 1, fromParser);
2156 rows = context->parms[2];
2157 columns = context->parms[3];
2158 (void) XtVaSetValues(w, DtNrows, rows, DtNcolumns, columns, NULL);
2161 if (vtw->term.tpd->windowMapped)
2162 sendEscSequence(w,"\033[1t") ;
2164 sendEscSequence(w,"\033[2t") ;
2167 (void) GetWindowOffsets(sw, &xOffset, &yOffset, &widthOffset,
2169 (void) XtVaGetValues(sw, XtNx, &x, XtNy, &y, NULL);
2170 (void) sprintf(buf, "\033[3;%d;%dt", x - xOffset, y - yOffset);
2171 (void) sendEscSequence(w, buf);
2174 (void) GetWindowOffsets(sw, &xOffset, &yOffset, &widthOffset,
2176 (void) XtVaGetValues(sw, XtNheight, &height, XtNwidth, &width, NULL);
2177 (void) sprintf(buf,"\033[4;%d;%dt", height + heightOffset,
2178 width + widthOffset);
2179 (void) sendEscSequence(w, buf);
2182 (void) XtVaGetValues(w, DtNrows, &rows, DtNcolumns, &columns, NULL);
2183 (void) sprintf(buf, "\033[8;%hd;%hdt", rows, columns);
2184 (void) sendEscSequence(w, buf);
2187 XtVaGetValues(sw,XmNiconName, &icon, NULL);
2188 fmt = "\033]L%s\033\\";
2189 if (strlen(icon) + strlen(fmt) + 1 >= sizeof(buf))
2190 s = XtMalloc(strlen(icon) + strlen(fmt) + 1);
2193 sprintf(s, "%s", fmt);
2194 sendEscSequence(w,s) ;
2195 if (s != buf) XtFree(s);
2198 XtVaGetValues(sw,XmNtitle, &title, NULL);
2199 fmt = "\033]l%s\033\\";
2200 if (strlen(icon) + strlen(fmt) + 1 >= sizeof(buf))
2201 s = XtMalloc(strlen(icon) + strlen(fmt) + 1);
2204 sprintf(s, "%s", fmt);
2205 sendEscSequence(w,s) ;
2206 if (s != buf) XtFree(s);
2212 _DtTermParserSunWindowIcon( Widget w) /* sun set icon label */
2214 ParserContext context ;
2216 context = GetParserContext(w) ;
2217 for (sw = w; !XtIsShell(sw); sw = XtParent(sw));
2218 XtVaSetValues(sw, XmNiconName, context->stringParms[0].str, NULL) ;
2222 _DtTermParserSunWindowTitle /* Sun set title name */
2227 ParserContext context ;
2229 context = GetParserContext(w) ;
2230 for (sw = w; !XtIsShell(sw); sw = XtParent(sw));
2231 XtVaSetValues(sw,XmNtitle, context->stringParms[0].str, NULL) ;
2235 _DtTermParserSunIconFile(Widget w) /* Sun set icon to pixmap in file */
2238 (DtTermBuffer)((DtTermPrimitiveWidget)w)->term.tpd->termBuffer ;
2239 ParserContext context ;
2244 context = GetParserContext(w) ;
2245 for (sw = w; !XtIsShell(sw); sw = XtParent(sw));
2246 XtVaGetValues(sw, XtNforeground, &fg, XtNbackground, &bg, NULL);
2247 icon = XmGetPixmap(XtScreen(sw),(char *)context->stringParms[0].str,fg,bg);
2248 if (icon != XmUNSPECIFIED_PIXMAP)
2249 XtVaSetValues(sw, XmNiconPixmap, icon, NULL);