TermParse.c 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  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)
  10. * any later version.
  11. *
  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
  16. * details.
  17. *
  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
  22. */
  23. /* *
  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. *
  31. */
  32. #include <wctype.h>
  33. #include "TermHeader.h"
  34. #include "TermPrimDebug.h"
  35. #include "TermPrimP.h"
  36. #include "TermPrimI.h"
  37. #include "TermP.h"
  38. #include "TermPrimData.h"
  39. #include "TermData.h"
  40. #include "TermPrimBuffer.h"
  41. #include "TermPrimParserP.h"
  42. #include "TermFunction.h"
  43. #include "TermBuffer.h"
  44. #include "TermFunctionKey.h"
  45. #include "TermParseTableP.h"
  46. #include "TermBufferP.h"
  47. #include "TermPrimUtil.h"
  48. #include "TermPrimParseTable.h"
  49. #if defined(CSRG_BASED)
  50. #define MAXSHORT SHRT_MAX
  51. #else
  52. #include <values.h>
  53. #endif
  54. /*****************************************************************************/
  55. #define NPARAM 16
  56. #define PCOUNT(c) ((c)->parms[0])
  57. #define BASE 1 /* row and column count base 0 or 1 */
  58. /*********************************************************************
  59. * Macros for handling cursor constraints - return values in coordinate
  60. * system for Term widget (base 0) BASE which is 1 reflects the Vt base
  61. *
  62. * These defines need to account of for Origin mode eventually TMH */
  63. #define TOPROW(w) (1-BASE)
  64. #define TOPMARGIN(w) ((w)->term.tpd->scrollLockTopRow-(1-BASE))
  65. #define BOTTOMMARGIN(w) ((w)->term.tpd->scrollLockBottomRow-(1-BASE))
  66. #define BOTTOMROW(w) ((w)->term.rows-BASE)
  67. /* FIRSTCOLUMN(w) ABS(BASE-1) */
  68. #define FIRSTCOLUMN(w) 0
  69. #define LASTCOLUMN(w) ((w)->term.columns-BASE)
  70. #define FLOOR(w) ((w)->vt.td->originMode?(w)->term.tpd->scrollLockBottomRow:\
  71. BOTTOMROW(w))
  72. #define CEILING(w) ((w)->vt.td->originMode?(w)->term.tpd->scrollLockTopRow:\
  73. TOPROW(w))
  74. #define KILLWRAP(w) if((w)->term.tpd->cursorColumn>LASTCOLUMN(w)) \
  75. (w)->term.tpd->cursorColumn=LASTCOLUMN(w)
  76. #define STORELASTARG(c) (c)->parms[PCOUNT(c)]=(c)->workingNum
  77. /******************************************************************
  78. * Upon entering a parse routine the parameter count is contained
  79. * in context->parms[0].
  80. *
  81. * The last parmameter parsed is in context->workingNum
  82. * Next to last parmameter is in {context->parms[0]==1?context->workingNum:
  83. * context->parms[context->param[0]-1]}
  84. * .
  85. * .
  86. *
  87. * First parameter is in context->parms[1]
  88. *
  89. * In some of the parse routines, the default case of too many parameters
  90. * needs to be handled like Vt (silently use the first n parameters)
  91. * Vt has a max of 16 numeric parameters; The rest fall off the end
  92. * silently.
  93. *******************************************************************/
  94. void
  95. _DtTermClearParam(Widget w)
  96. {
  97. ParserContext context ;
  98. context = GetParserContext(w) ;
  99. PCOUNT(context)=0 ;
  100. _DtTermPrimParserClearParm(w) ;
  101. _DtTermPrimParserClrStrParm(w) ;
  102. }
  103. void
  104. _DtTermEnterNum(Widget w)
  105. {
  106. ParserContext context ;
  107. context = GetParserContext(w) ;
  108. _DtTermPrimParserEnterNum(w) ;
  109. if (!PCOUNT(context)) PCOUNT(context)++ ; /* increment for first number ONLY*/
  110. }
  111. void
  112. _DtTermParsePushNum(Widget w)
  113. {
  114. ParserContext context ;
  115. context = GetParserContext(w) ;
  116. /* parmN(w,PCOUNT(c)) ; Should use this but not global */
  117. if ( context->workingNumIsDefault != True) { /* did we actually parse a num*/
  118. _DtTermPrimParserNumParmPush(w,PCOUNT(context)) ;
  119. }
  120. else {
  121. if (!PCOUNT(context)) PCOUNT(context)++ ;/* increment for first number ONLY*/
  122. }
  123. if ( ++PCOUNT(context)>NPARAM ) {
  124. Debug('P',fprintf(stderr,">>Too many parameters\n")) ;
  125. return ;
  126. }
  127. }
  128. void
  129. _DtTermSaveChar(Widget w)
  130. {
  131. DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
  132. ParserContext context ;
  133. wchar_t c;
  134. context = GetParserContext(w) ;
  135. mbtowc(&c,(char *)context->inputChar,MB_CUR_MAX);
  136. if ( context->stringParms[0].length < STR_SIZE && iswprint(c) ) {
  137. strncpy( (
  138. (char *)&context->stringParms[0].str[context->stringParms[0].length]),
  139. (char *)context->inputChar, context->inputCharLen) ;
  140. context->stringParms[0].length += context->inputCharLen ;
  141. }
  142. }
  143. void
  144. _DtTermPrintState(Widget w)
  145. {
  146. ParserContext context ;
  147. context = GetParserContext(w) ;
  148. /* fprintf(stderr,"Warning: Not a valid escape sequence\n") ;*/
  149. context->stateTable = _DtTermStateStart ;
  150. _DtTermClearParam(w) ;
  151. }
  152. /* a utility for checking for S8C1TMode */
  153. static void
  154. sendEscSequence(Widget w, char *transmitString)
  155. {
  156. DtTermWidget tw = (DtTermWidget)w;
  157. DtTermData td = tw->vt.td;
  158. if ( td->S8C1TMode ) {
  159. char *cbuf =malloc(strlen(transmitString)+1);
  160. strcpy(cbuf,transmitString) ;
  161. cbuf[1] = 0x9B ;
  162. (void) _DtTermPrimSendInput(w, (unsigned char *) (cbuf+1),
  163. strlen(cbuf+1));
  164. free(cbuf) ;
  165. }
  166. else {
  167. (void) _DtTermPrimSendInput(w, (unsigned char *) transmitString,
  168. strlen(transmitString));
  169. }
  170. }
  171. void
  172. _DtTermDeviceStatus(Widget w) /* DSR CSI?pn */
  173. {
  174. DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
  175. DtTermData vtd = ((DtTermWidget)w)->vt.td;
  176. ParserContext context ;
  177. char buf[100] ;
  178. int col,cnt ;
  179. Debug('P', fprintf(stderr,">>In func _DtTermDeviceStatus\n")) ;
  180. context = GetParserContext(w) ;
  181. STORELASTARG(context) ;
  182. switch ( context->parms[1] ) {
  183. case 15: /* printer status - we don't have one */
  184. sendEscSequence(w,"\033[?13n") ;
  185. break;
  186. case 25: /* User defined keys locked? */
  187. if ( vtd->userKeysLocked )
  188. sendEscSequence(w,"\033[?21n") ;
  189. else
  190. sendEscSequence(w,"\033[?20n") ;
  191. break;
  192. case 26: /* keyboard status - always send North American */
  193. sendEscSequence(w,"\033[?27;1n") ;
  194. break;
  195. }
  196. }
  197. void
  198. _DtTermDeviceStatusAnsi(Widget w) /* DSR CSIpn */
  199. {
  200. DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
  201. DtTermData vtd = ((DtTermWidget)w)->vt.td;
  202. ParserContext context ;
  203. char buf[100] ;
  204. int row,col,cnt ;
  205. Debug('P', fprintf(stderr,">>In func _DtTermDeviceStatus\n")) ;
  206. context = GetParserContext(w) ;
  207. STORELASTARG(context) ;
  208. switch ( context->parms[1] ) {
  209. case 5: /* as far as I know, all's well... So send OK */
  210. sendEscSequence(w,"\033[0n") ;
  211. break;
  212. case 6:
  213. /* cursor could be past last row (for autowrap) */
  214. if ((col=tw->term.tpd->cursorColumn)>LASTCOLUMN(tw))
  215. col=LASTCOLUMN(tw) ;
  216. row = tw->term.tpd->cursorRow+BASE ;
  217. if (vtd->originMode==True) row -= TOPMARGIN(tw) ;
  218. sprintf(buf,"\033[%d;%dR",row , col+BASE) ;
  219. sendEscSequence(w,buf) ;
  220. break ;
  221. }
  222. }
  223. void
  224. _DtTermPModeSet(Widget w) /* DECSET CSI?ph */
  225. {
  226. ParserContext context ;
  227. DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
  228. DtTermWidget vtw = (DtTermWidget)w;
  229. int i,cnt ;
  230. Debug('P', fprintf(stderr,">>In func _DtTermPModeSet\n")) ;
  231. context = GetParserContext(w) ;
  232. STORELASTARG(context) ;
  233. cnt = PCOUNT(context) ;
  234. for (i=1;i<=cnt;i++) {
  235. switch ( context->parms[i]) {
  236. /* from vt220 */
  237. case 1: /* Cursor key (Application) */
  238. vtw->vt.td->applicationMode=True;
  239. break;
  240. /* case 2: can't return from vt52 mode */
  241. case 3: /* Column (132) */
  242. if ( vtw->vt.c132 ) { /* xterm allow 132 mode */
  243. (void) _DtTermFuncClearBuffer(w, 0, fromParser);
  244. vtw->term.tpd->cursorRow = TOPROW(vtw) ;
  245. vtw->term.tpd->cursorColumn = FIRSTCOLUMN(vtw) ;
  246. vtw->term.tpd->scrollLockTopRow = TOPROW(vtw);
  247. vtw->term.tpd->scrollLockBottomRow = BOTTOMROW(vtw) ;
  248. XtVaSetValues(w, DtNcolumns, 132, NULL) ;
  249. vtw->vt.td->col132Mode = True ;
  250. }
  251. break;
  252. case 4: /* Scroll (smooth) */
  253. _DtTermPrimScrollComplete(w, True) ;
  254. vtw->term.jumpScroll = False ;
  255. break;
  256. case 5: /* Screen (Reverse) */
  257. /*DKS: this is just to test out the functionality... */
  258. vtw->term.reverseVideo = True;
  259. /* clear the window to force refresh... */
  260. (void) XClearArea(XtDisplay(w), XtWindow(w),
  261. 0, 0, 0, 0, True);
  262. break;
  263. case 6: /* Origin mode (On) */
  264. vtw->vt.td->originMode=True;
  265. _DtTermPrimCursorMove(w, TOPMARGIN(vtw), 0);
  266. break;
  267. case 7: /* Auto wrap (On) */
  268. vtw->term.tpd->autoWrapRight=True ;
  269. break;
  270. /* case 8: ** Auto repeat (On)
  271. * ** This is handled by the X server
  272. * break;
  273. *
  274. * case 18: ** Print form feed (On)
  275. * break;
  276. * case 19: ** Print extent (full screen)
  277. * break;
  278. */
  279. case 25: /* Text cursor enable (On) */
  280. (void) _DtTermPrimSetCursorVisible(w, True);
  281. break;
  282. /* from xterm */
  283. case 40: /* 80/132 mode (allow) */
  284. vtw->vt.c132 = True ;
  285. break;
  286. case 41: /* curses fix */
  287. vtw->vt.td->fixCursesMode = True ;
  288. break;
  289. case 44: /* margin bell (on) */
  290. vtw->term.marginBell = True ;
  291. break;
  292. case 45: /* Reverse-wraparound mode */
  293. vtw->vt.td->reverseWrapMode=True;
  294. break;
  295. case 46: /* logging (start) */
  296. vtw->term.logging = True ;
  297. _DtTermPrimStartLog(w);
  298. break;
  299. /* case 47: ** screen buffer (alternate)
  300. * break;
  301. * case 1000: ** Send mouse x and y
  302. * break;
  303. * case 1001: ** Use hilite mouse tracking
  304. * break;
  305. */
  306. }
  307. }
  308. }
  309. void
  310. _DtTermPModeReset(Widget w) /* DECRST CSI?pl */
  311. {
  312. ParserContext context ;
  313. DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
  314. DtTermWidget vtw = (DtTermWidget)w;
  315. int i,cnt ;
  316. Debug ('P', fprintf(stderr,">>In func _DtTermPModeReset\n")) ;
  317. context = GetParserContext(w) ;
  318. STORELASTARG(context) ;
  319. cnt = PCOUNT(context) ;
  320. for (i=1;i<=cnt;i++) {
  321. switch ( context->parms[i]) {
  322. /* from vt220 */
  323. case 1: /* Cursor key (Normal) */
  324. vtw->vt.td->applicationMode=False;
  325. break;
  326. /* case 2: ** set vt52 mode */
  327. case 3: /* Column (80) */
  328. if (vtw->vt.c132) { /* allow 132 mode */
  329. (void) _DtTermFuncClearBuffer(w, 0, fromParser);
  330. vtw->term.tpd->cursorRow = TOPROW(vtw) ;
  331. vtw->term.tpd->cursorColumn = FIRSTCOLUMN(vtw) ;
  332. vtw->term.tpd->scrollLockTopRow = TOPROW(vtw);
  333. vtw->term.tpd->scrollLockBottomRow = BOTTOMROW(vtw) ;
  334. XtVaSetValues(w, DtNcolumns, 80, NULL) ;
  335. vtw->vt.td->col132Mode = False ;
  336. }
  337. break;
  338. case 4: /* Scroll (jump) */
  339. _DtTermPrimScrollComplete(w, True) ;
  340. vtw->term.jumpScroll = True ;
  341. break;
  342. case 5: /* Screen (normal ) */
  343. /*DKS: this is just to test out the functionality... */
  344. vtw->term.reverseVideo = False;
  345. /* clear the window to force refresh... */
  346. (void) XClearArea(XtDisplay(w), XtWindow(w),
  347. 0, 0, 0, 0, True);
  348. break;
  349. case 6: /* Normal cursor (not Origin mode) */
  350. vtw->vt.td->originMode=False;
  351. _DtTermPrimCursorMove(w, 0, 0);
  352. break;
  353. case 7: /* Auto wrap (Off) */
  354. vtw->term.tpd->autoWrapRight=False;
  355. break;
  356. /* case 8: ** Auto repeat (Off)
  357. * ** implemented in the server
  358. * break;
  359. * case 18: ** Print form feed (Off)
  360. * break;
  361. * case 19: ** Print extent (scrolling region)
  362. * break;
  363. */
  364. case 25: /* Text cursor enable (Off) */
  365. (void) _DtTermPrimSetCursorVisible(w, False);
  366. break;
  367. /* from xterm */
  368. case 40: /* 80/132 mode (disallow) */
  369. vtw->vt.c132 = False;
  370. break;
  371. case 41: /* curses fix */
  372. vtw->vt.td->fixCursesMode = False;
  373. break;
  374. case 44: /* margin bell (off) */
  375. vtw->term.marginBell = False ;
  376. break;
  377. case 45: /* Reverse-wraparound mode */
  378. vtw->vt.td->reverseWrapMode=False;
  379. break;
  380. case 46: /* logging (stop ) */
  381. vtw->term.logging = False ;
  382. _DtTermPrimCloseLog(w) ;
  383. break;
  384. /* case 47: ** screen buffer (normal)
  385. * break;
  386. * case 1000: ** don't send mouse x and y
  387. * break;
  388. * case 1001: ** don't use hilite mouse tracking
  389. * break;
  390. */
  391. }
  392. }
  393. }
  394. void
  395. _DtTermSetMode(Widget w) /* SM CSIph */
  396. {
  397. ParserContext context ;
  398. DtTermWidget vtw = (DtTermWidget)w ;
  399. int i,cnt ;
  400. Debug('P', fprintf(stderr,">>In func _DtTermSetMode\n")) ;
  401. context = GetParserContext(w) ;
  402. STORELASTARG(context) ;
  403. cnt = PCOUNT(context) ;
  404. for (i=1;i<=cnt;i++) {
  405. switch ( context->parms[i]) {
  406. case 2: /* KAM Keyboard Action (locked) */
  407. vtw->term.tpd->keyboardLocked.escape=True ;
  408. (void) _DtTermPrimInvokeStatusChangeCallback(w);
  409. break;
  410. case 4: /* Insert mode */
  411. _DtTermPrimInsertCharUpdate(w, DtTERM_INSERT_CHAR_ON) ;
  412. break;
  413. case 12: /* SRM Send/Receive (Off) */
  414. vtw->term.tpd->halfDuplex = False;
  415. break;
  416. case 20: /* Line feed/newline (new line) */
  417. vtw->term.tpd->autoLineFeed=True ;
  418. break;
  419. }
  420. }
  421. }
  422. void
  423. _DtTermResetMode(Widget w) /* RM CSIpl */
  424. {
  425. ParserContext context ;
  426. DtTermWidget vtw = (DtTermWidget)w ;
  427. int i,cnt ;
  428. Debug('P', fprintf(stderr,">>In func _DtTermResetMode\n")) ;
  429. context = GetParserContext(w) ;
  430. STORELASTARG(context) ;
  431. cnt = PCOUNT(context) ;
  432. for (i=1;i<=cnt;i++) {
  433. switch ( context->parms[i]) {
  434. case 2: /* KAM Keyboard Action (unlocked) */
  435. vtw->term.tpd->keyboardLocked.escape=False;
  436. (void) _DtTermPrimInvokeStatusChangeCallback(w);
  437. break;
  438. case 4: /* Replace mode */
  439. _DtTermPrimInsertCharUpdate(w, DtTERM_INSERT_CHAR_OFF) ;
  440. break;
  441. case 12: /* SRM Send/Receive (On) */
  442. vtw->term.tpd->halfDuplex = True;
  443. break;
  444. case 20: /* Line feed/newline (line feed) */
  445. vtw->term.tpd->autoLineFeed=False ;
  446. break;
  447. }
  448. }
  449. }
  450. void
  451. _DtTermCursorPos(Widget w) /* CUP CSIp;pH */
  452. {
  453. ParserContext context ;
  454. DtTermWidget vtw = (DtTermWidget) w;
  455. int row, col;
  456. Debug( 'P', fprintf(stderr,">>In func _DtTermCursorPos\n")) ;
  457. context = GetParserContext(w) ;
  458. STORELASTARG(context) ;
  459. row = context->parms[1] ;
  460. col = context->parms[2] ;
  461. if (row)row-=BASE ;
  462. if (col)col-=BASE ;
  463. if (vtw->vt.td->originMode) row += vtw->term.tpd->scrollLockTopRow ;
  464. if (row > FLOOR(vtw)) row = FLOOR(vtw) ;
  465. if (col > LASTCOLUMN(vtw)) col = LASTCOLUMN(vtw) ;
  466. vtw->term.tpd->cursorRow = row ;
  467. vtw->term.tpd->cursorColumn = col ;
  468. }
  469. void
  470. _DtTermEraseDisplay(Widget w) /* ED CSIpJ */
  471. {
  472. int cnt ;
  473. DtTermWidget vtw = (DtTermWidget) w;
  474. ParserContext context ;
  475. DtEraseMode eraseMode;
  476. int row, col;
  477. Debug('P', fprintf(stderr,">>In func _DtTermEraseDisplay\n")) ;
  478. context = GetParserContext(w) ;
  479. KILLWRAP(vtw) ;
  480. STORELASTARG(context) ;
  481. row = vtw->term.tpd->cursorRow;
  482. col = vtw->term.tpd->cursorColumn ;
  483. /*
  484. ** pick the correct erase mode...
  485. */
  486. switch (context->parms[1])
  487. {
  488. case 0:
  489. eraseMode = eraseToEOB;
  490. break;
  491. case 1:
  492. eraseMode = eraseFromRow0Col0;
  493. break;
  494. case 2:
  495. eraseMode = eraseBuffer;
  496. break ;
  497. default:
  498. return;
  499. }
  500. _DtTermFuncEraseInDisplay(w, (int)eraseMode, fromParser);
  501. vtw->term.tpd->cursorRow = row;
  502. vtw->term.tpd->cursorColumn = col;
  503. }
  504. void
  505. _DtTermEraseChars(Widget w) /* ECH CSIpX */
  506. {
  507. ParserContext context ;
  508. DtTermWidget vtw = (DtTermWidget) w;
  509. int col,cnt ;
  510. Debug('P', fprintf(stderr,">>In func _DtTermEraseChars\n")) ;
  511. KILLWRAP(vtw) ;
  512. context = GetParserContext(w) ;
  513. col = vtw->term.tpd->cursorColumn ;
  514. STORELASTARG(context) ;
  515. cnt = context->parms[1] ;
  516. if (!(cnt))cnt=1;
  517. else
  518. if ( cnt > LASTCOLUMN(vtw)-col+1 ) cnt = LASTCOLUMN(vtw)-col+1 ;
  519. _DtTermFuncEraseCharacter(w, cnt, fromParser);
  520. }
  521. void
  522. _DtTermInsertChars(Widget w) /* ICH CSIp@ */
  523. {
  524. DtTermWidget vtw = (DtTermWidget) w;
  525. ParserContext context ;
  526. int row, col, cnt ;
  527. DtTermInsertCharMode saveInsertCharMode;
  528. Debug('P', fprintf(stderr,">>In func _DtTermInsertChars\n")) ;
  529. KILLWRAP(vtw) ;
  530. context = GetParserContext(w) ;
  531. vtw->term.tpd->parserNotInStartState = False ;
  532. row = vtw->term.tpd->cursorRow ;
  533. col = vtw->term.tpd->cursorColumn ;
  534. STORELASTARG(context) ;
  535. cnt = context->parms[1] ;
  536. if (!cnt)
  537. cnt++;
  538. else
  539. if (cnt > LASTCOLUMN(vtw) - col + 1)
  540. cnt = LASTCOLUMN(vtw) - col + 1;
  541. /* save away the insert char mode... */
  542. saveInsertCharMode = vtw->term.tpd->insertCharMode;
  543. /* turn on insert char mode. We don't want to invoke any status
  544. * change callbacks, so we will justs set it directly...
  545. */
  546. vtw->term.tpd->insertCharMode = DtTERM_INSERT_CHAR_ON;
  547. /* insert blanks... */
  548. while (cnt--)
  549. (void) _DtTermPrimInsertText(w,(unsigned char *) " ", 1) ;
  550. /* restore the insert char mode... */
  551. vtw->term.tpd->insertCharMode = saveInsertCharMode;
  552. _DtTermPrimCursorMove(w,row,col) ;
  553. }
  554. void
  555. _DtTermCursorUp(Widget w) /* CUU CISpA */
  556. {
  557. ParserContext context ;
  558. DtTermWidget vtw = (DtTermWidget) w;
  559. int row, tmargin, cnt;
  560. Debug('P', fprintf(stderr,">>In func _DtTermCursorUp\n")) ;
  561. context = GetParserContext(w) ;
  562. KILLWRAP(vtw) ;
  563. tmargin = TOPMARGIN(vtw) ;
  564. STORELASTARG(context) ;
  565. cnt = context->parms[1] ;
  566. if (!(cnt))cnt=1;
  567. else if (cnt>MAXSHORT) cnt=MAXSHORT-100;
  568. row = vtw->term.tpd->cursorRow-cnt;
  569. /* are we about the top margin and did we actually cross it? */
  570. /* This handles the case top margin == top row */
  571. if (row < tmargin && row+cnt >= tmargin) row = tmargin;
  572. _DtTermPrimCursorMove(w, row, vtw->term.tpd->cursorColumn) ;
  573. }
  574. void
  575. _DtTermCursorDown(Widget w) /* CUD CISpB */
  576. {
  577. ParserContext context ;
  578. DtTermWidget vtw = (DtTermWidget) w;
  579. int bmargin, row, cnt, brow ;
  580. Debug('P', fprintf(stderr,">>In func _DtTermCursorDown\n")) ;
  581. context = GetParserContext(w) ;
  582. KILLWRAP(vtw) ;
  583. bmargin = BOTTOMMARGIN(vtw) ;
  584. brow = BOTTOMROW(vtw) ;
  585. STORELASTARG(context) ;
  586. cnt = context->parms[1] ;
  587. if (!(cnt))cnt=1;
  588. row = vtw->term.tpd->cursorRow+cnt;
  589. /* are we below bottom margin and did we actually cross it? */
  590. /* NOTE that this also handles the case when bmargin == brow */
  591. if (row > bmargin && row-cnt <= bmargin) row = bmargin;
  592. /* did we start below bottom margin and cross bottom row? */
  593. if (row > brow && bmargin < brow ) row = brow;
  594. _DtTermPrimCursorMove(w, row, vtw->term.tpd->cursorColumn) ;
  595. }
  596. void
  597. _DtTermCursorForward(Widget w) /* CUF CISpC */
  598. {
  599. ParserContext context ;
  600. DtTermWidget vtw = (DtTermWidget) w;
  601. int col,lcol,cnt ;
  602. Debug('P', fprintf(stderr,">>In func _DtTermCursorForward\n")) ;
  603. context = GetParserContext(w) ;
  604. KILLWRAP(vtw) ;
  605. lcol = LASTCOLUMN(vtw) ;
  606. STORELASTARG(context) ;
  607. cnt = context->parms[1] ;
  608. if (!cnt) cnt=1;
  609. col = vtw->term.tpd->cursorColumn+cnt;
  610. if (col>lcol) col=lcol;
  611. _DtTermPrimCursorMove(w,vtw->term.tpd->cursorRow,col);
  612. }
  613. void
  614. _DtTermCursorBack(Widget w) /* CUB CISpD */
  615. {
  616. ParserContext context ;
  617. DtTermWidget vtw = (DtTermWidget) w;
  618. int i,k,j,row,col,cnt ;
  619. Debug('P', fprintf(stderr,">>In func _DtTermCursorBack\n")) ;
  620. KILLWRAP(vtw) ;
  621. context = GetParserContext(w) ;
  622. STORELASTARG(context) ;
  623. cnt = context->parms[1] ;
  624. row = vtw->term.tpd->cursorRow;
  625. col = vtw->term.tpd->cursorColumn;
  626. if (!cnt) cnt=1;
  627. if ((col -= cnt) < 0) {
  628. if(vtw->vt.td->reverseWrapMode && vtw->term.tpd->autoWrapRight) {
  629. int lastrow = BOTTOMROW(vtw);
  630. if (vtw->vt.td->originMode) {
  631. row-=TOPMARGIN(vtw) ;
  632. lastrow = BOTTOMMARGIN(vtw)-TOPMARGIN(vtw);
  633. }
  634. if((i = (j = LASTCOLUMN(vtw) + 1) * row + col) < 0) {
  635. k = j * (lastrow + 1);
  636. i += ((-i) / k + 1) * k;
  637. }
  638. row = i / j;
  639. if (vtw->vt.td->originMode) row+=TOPMARGIN(vtw);
  640. col = i % j;
  641. } else
  642. col = 0;
  643. }
  644. _DtTermPrimCursorMove(w,row,col);
  645. }
  646. void
  647. _DtTermCursorToLineUp(Widget w) /* CPL CSIpF */
  648. {
  649. DtTermWidget vtw = (DtTermWidget) w;
  650. Debug('P', fprintf(stderr,">>In func _DtTermCursorToLineUp\n")) ;
  651. KILLWRAP(vtw) ;
  652. vtw->term.tpd->cursorColumn = FIRSTCOLUMN(vtw) ;
  653. _DtTermCursorUp(w) ;
  654. }
  655. void
  656. _DtTermCursorToCol(Widget w) /* CHA CSIpG */
  657. {
  658. DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
  659. ParserContext context ;
  660. context = GetParserContext(w) ;
  661. STORELASTARG(context) ;
  662. if (!context->parms[1] ) context->parms[1]=1;
  663. if (context->parms[1]>tw->term.columns) context->parms[1]=tw->term.columns;
  664. tw->term.tpd->cursorColumn = context->parms[1] - BASE ;
  665. }
  666. void
  667. _DtTermEraseInLine(Widget w) /* EL ESC[pK */
  668. {
  669. DtTermWidget vtw = (DtTermWidget) w;
  670. ParserContext context ;
  671. DtEraseMode eraseMode;
  672. Debug('P', fprintf(stderr,">>In func _DtTermEraseInLine\n")) ;
  673. KILLWRAP(vtw) ;
  674. context = GetParserContext(w) ;
  675. STORELASTARG(context) ;
  676. /*
  677. ** pick the correct erase mode...
  678. */
  679. switch ( context->parms[1] )
  680. {
  681. case 0:
  682. eraseMode = eraseToEOL;
  683. break;
  684. case 1:
  685. eraseMode = eraseFromCol0;
  686. break;
  687. case 2:
  688. eraseMode = eraseLine;
  689. break;
  690. default:
  691. return;
  692. }
  693. _DtTermFuncEraseInLine(w, (int)eraseMode, fromParser);
  694. }
  695. void
  696. _DtTermInsertLines(Widget w) /* IL CSIpL */
  697. {
  698. DtTermWidget vtw = (DtTermWidget) w;
  699. ParserContext context ;
  700. int lines , cnt ;
  701. Debug('P', fprintf(stderr,">>In func _DtTermInsertLines\n")) ;
  702. if ( vtw->term.tpd->cursorRow < TOPMARGIN(vtw) ||
  703. vtw->term.tpd->cursorRow > BOTTOMMARGIN(vtw) )/*outside scrolling region*/
  704. return ;
  705. context = GetParserContext(w) ;
  706. KILLWRAP((DtTermWidget)w) ;
  707. STORELASTARG(context) ;
  708. cnt=context->parms[1];
  709. if (!cnt)cnt++;
  710. lines = BOTTOMMARGIN(vtw) - vtw->term.tpd->cursorRow + 1;
  711. if (cnt > lines) cnt=lines ;
  712. _DtTermFuncInsertLine(w,cnt,fromParser) ;
  713. }
  714. void
  715. _DtTermDeleteLines(Widget w) /* DL CSIpM */
  716. {
  717. DtTermWidget vtw = (DtTermWidget) w;
  718. ParserContext context ;
  719. int cnt ;
  720. Debug('P', fprintf(stderr,">>In func _DtTermDeleteLines\n")) ;
  721. if ( vtw->term.tpd->cursorRow < TOPMARGIN(vtw) ||
  722. vtw->term.tpd->cursorRow > BOTTOMMARGIN(vtw) ) /* outside scrolling region*/
  723. return ;
  724. KILLWRAP((DtTermWidget)w) ;
  725. context = GetParserContext(w) ;
  726. STORELASTARG(context) ;
  727. cnt = context->parms[1];
  728. if(!cnt)cnt++;
  729. _DtTermFuncDeleteLine(w,cnt,fromParser) ;
  730. }
  731. void
  732. _DtTermDeleteChars(Widget w) /* DCH CSIpP */
  733. {
  734. ParserContext context ;
  735. DtTermWidget vtw = (DtTermWidget) w;
  736. int cnt ;
  737. Debug('P', fprintf(stderr,">>In func _DtTermDeleteChars\n")) ;
  738. KILLWRAP(vtw) ;
  739. context = GetParserContext(w) ;
  740. STORELASTARG(context) ;
  741. cnt= context->parms[1];
  742. if (!cnt) cnt++;
  743. else if (cnt>MAXSHORT) cnt=MAXSHORT-100;
  744. _DtTermFuncDeleteChar(w,cnt,fromParser) ;
  745. }
  746. void
  747. _DtTermNextLine(Widget w) /* NEL ESCE */
  748. {
  749. DtTermWidget vtw = (DtTermWidget) w;
  750. int brow;
  751. Debug('P', fprintf(stderr,">>In func _DtTermNextLine\n")) ;
  752. vtw->term.tpd->cursorColumn = FIRSTCOLUMN(vtw) ;
  753. _DtTermIndex(w) ; /* use IND */
  754. }
  755. void
  756. _DtTermReverseIndex(Widget w) /* RI ESCM */
  757. {
  758. DtTermWidget vtw = (DtTermWidget) w;
  759. int tmargin, trow, col;
  760. Debug('P', fprintf(stderr,">>In func _DtTermReverseIndex\n")) ;
  761. KILLWRAP(vtw) ;
  762. trow = TOPROW(vtw) ;
  763. tmargin = TOPMARGIN(vtw) ;
  764. col = vtw->term.tpd->cursorColumn ;
  765. if ( vtw->term.tpd->cursorRow == tmargin) {
  766. _DtTermFuncInsertLine(w,1,fromParser) ;
  767. /* _DtTermFuncInsertLine sets column to first column */
  768. vtw->term.tpd->cursorColumn = col ;
  769. }
  770. else if (vtw->term.tpd->cursorRow > trow){
  771. vtw->term.tpd->cursorRow-- ;
  772. }
  773. }
  774. void
  775. _DtTermIndex(Widget w) /* IND ESCD */
  776. {
  777. DtTermWidget vtw = (DtTermWidget) w;
  778. int bmargin, brow ;
  779. Debug('P', fprintf(stderr,">>In func _DtTermIndex\n")) ;
  780. KILLWRAP(vtw) ;
  781. brow = BOTTOMROW(vtw) ;
  782. bmargin = BOTTOMMARGIN(vtw) ;
  783. if ( vtw->term.tpd->cursorRow == bmargin) {
  784. (void) _DtTermPrimScrollText(w, 1);
  785. }
  786. else if (vtw->term.tpd->cursorRow < brow){
  787. vtw->term.tpd->cursorRow++ ;
  788. }
  789. (void) _DtTermPrimFillScreenGap(w);
  790. }
  791. void
  792. _DtTermScrollingRegion(Widget w) /* DECSTBM CSIp;pr */
  793. {
  794. DtTermWidget vtw = (DtTermWidget)w ;
  795. ParserContext context ;
  796. int row1,row2 ;
  797. Debug('P', fprintf(stderr,">>In func _DtTermScrollingRegion\n")) ;
  798. context = GetParserContext(w) ;
  799. STORELASTARG(context) ;
  800. row1 = context->parms[1] ;
  801. row2 = context->parms[2] ;
  802. if (!row1) row1 = 1 ;
  803. if (!row2 || row2>vtw->term.rows) row2 = vtw->term.rows ;
  804. row1-=BASE ;
  805. row2-=BASE ;
  806. if ( row1 < row2 ) {
  807. if ( row1 == TOPROW(vtw) && row2 == BOTTOMROW(vtw))
  808. vtw->term.tpd->memoryLockMode=SCROLL_LOCKoff ;
  809. else
  810. vtw->term.tpd->memoryLockMode=SCROLL_LOCKon ;
  811. vtw->term.tpd->scrollLockTopRow = row1 ;
  812. vtw->term.tpd->scrollLockBottomRow = row2 ;
  813. if (vtw->vt.td->originMode) _DtTermPrimCursorMove(w,row1,0) ;
  814. else _DtTermPrimCursorMove(w,0,0) ;
  815. }
  816. }
  817. void
  818. _DtTermCharAttributes(Widget w) /* SGR CSIpm */
  819. {
  820. ParserContext context ;
  821. int i,cnt ;
  822. Debug('P', fprintf(stderr,">>In func _DtTermCharAttributes\n")) ;
  823. context = GetParserContext(w) ;
  824. STORELASTARG(context) ;
  825. if(PCOUNT(context)) {
  826. for (cnt=1; cnt <= PCOUNT(context); cnt++)
  827. _DtTermVideoEnhancement(w,context->parms[cnt]) ;
  828. }
  829. else
  830. _DtTermVideoEnhancement(w,0) ;
  831. }
  832. void
  833. _DtTermDeviceAttributes(Widget w) /* DA CSIpc */
  834. {
  835. DtTermWidget vtw = (DtTermWidget) w;
  836. ParserContext context ;
  837. int cnt ;
  838. char buf[50];
  839. Debug('P', fprintf(stderr,">>In func _DtTermDeviceAttributes\n")) ;
  840. context = GetParserContext(w) ;
  841. STORELASTARG(context) ;
  842. switch(context->parms[1]) {
  843. case 0:
  844. switch(vtw->vt.td->terminalId ) {
  845. case 100:
  846. sprintf(buf,"\033[?%d;%dc",1,2) ;
  847. break;
  848. case 101:
  849. sprintf(buf,"\033[?%d;%dc",1,0) ;
  850. break;
  851. case 102:
  852. sprintf(buf,"\033[?%dc",6) ;
  853. break;
  854. case 220:
  855. /* class 2 terminal (62), 132 columns (1), printer port (2),
  856. * selective erase (6), DRCS (7), UDK (8),
  857. * national replacement char sets
  858. */
  859. sprintf(buf,"\033[?%d;%d;%d;%d;%d;%d;%dc",62,1,2,6,7,8,9) ;
  860. break;
  861. }
  862. sendEscSequence(w,buf) ;
  863. break;
  864. }
  865. }
  866. void
  867. _DtTermChangeTextParam(Widget w) /* xterm CSIp;pcCtrl-G */
  868. {
  869. ParserContext context ;
  870. DtTermWidget tw = (DtTermWidget) w;
  871. Widget sw;
  872. int i ;
  873. Arg arg[5];
  874. Debug('P', fprintf(stderr,">>In func _DtTermChangeTextParam\n")) ;
  875. context = GetParserContext(w) ;
  876. i=0;
  877. for (sw = w; !XtIsShell(sw); sw = XtParent(sw));
  878. /*
  879. * context->parms[1] is inited to 0, so if no numeric param was entered,
  880. * we default appropriately to case 0.
  881. */
  882. switch(context->parms[1]) {
  883. case 0: /* change Icon name and Window title */
  884. XtSetArg(arg[i], XmNtitle, context->stringParms[0].str); i++;
  885. XtSetArg(arg[i], XmNiconName, context->stringParms[0].str); i++;
  886. XtSetValues(sw,arg,i) ;
  887. break;
  888. case 1: /* change Icon name */
  889. XtSetArg(arg[i], XmNiconName, context->stringParms[0].str); i++;
  890. XtSetValues(sw,arg,i) ;
  891. break;
  892. case 2: /* change Window title */
  893. XtSetArg(arg[i], XmNtitle, context->stringParms[0].str); i++;
  894. XtSetValues(sw,arg,i) ;
  895. break;
  896. case 3: /* change current working directory */
  897. tw->term.subprocessCWD = XtRealloc(tw->term.subprocessCWD,
  898. strlen((char *) context->stringParms[0].str) + 1);
  899. (void) strcpy(tw->term.subprocessCWD,
  900. (char *) context->stringParms[0].str);
  901. break;
  902. /* These are handled by xterm but not by us.
  903. case 46: Change log file to context->stringParms[0]
  904. break;
  905. case 50: ** change font to context->stringParms[0]
  906. break;
  907. */
  908. }
  909. }
  910. void
  911. _DtTermTabClear(Widget w) /* TBC CSIpg */
  912. {
  913. DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
  914. TermBuffer tb = tw->term.tpd->termBuffer ;
  915. ParserContext context ;
  916. int type ;
  917. Debug('P', fprintf(stderr,">>In func _DtTermTabClear\n")) ;
  918. context = GetParserContext(w) ;
  919. STORELASTARG(context) ;
  920. type = context->parms[1] ;
  921. switch ( type ) {
  922. case 0:(void)_DtTermPrimBufferClearTab(tb,tw->term.tpd->cursorColumn) ;
  923. break ;
  924. case 3: (void)_DtTermPrimBufferClearAllTabs(tb) ;
  925. break ;
  926. }
  927. }
  928. void
  929. _DtTermRequestParam(Widget w) /* DECREQTPARM CSIpx */
  930. {
  931. ParserContext context ;
  932. int row ;
  933. char buf[100];
  934. Debug('P', fprintf(stderr,">>In func _DtTermRequestParam\n")) ;
  935. context = GetParserContext(w) ;
  936. STORELASTARG(context) ;
  937. row = context->parms[1] ;
  938. if ( row < 2) {
  939. row += 2;
  940. /* row (?), 1 no parity, 1 eight bits, 112 xmit 9600 baud,
  941. * 112, receive 9600 baud, 1 clock multiplier (?),
  942. * 0 STP flags (?) These are from xterm file 'charproc.c'.
  943. */
  944. sprintf(buf,"\033[%d;%d;%d;%d;%d;%d;%dx",row,1,1,112,112,1,0) ;
  945. sendEscSequence(w,buf) ;
  946. }
  947. }
  948. void
  949. _DtTermTabSet(Widget w) /* HTS ESCH */
  950. {
  951. DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
  952. TermBuffer tb = tw->term.tpd->termBuffer ;
  953. Debug('P', fprintf(stderr,">>In func _DtTermTabSet\n")) ;
  954. (void)_DtTermPrimBufferSetTab(tb,tw->term.tpd->cursorColumn) ;
  955. }
  956. void
  957. _DtTermSaveCursor(Widget w) /* DECSC ESC7 */
  958. {
  959. DtTermWidget vtw = (DtTermWidget) w;
  960. DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
  961. DtTermData vtd = vtw->vt.td;
  962. Debug('P', fprintf(stderr,">>In func _DtTermSaveCursor\n")) ;
  963. vtd->saveCursor.cursorRow = vtw->term.tpd->cursorRow ;
  964. vtd->saveCursor.cursorColumn = vtw->term.tpd->cursorColumn ;
  965. vtd->saveCursor.originMode = vtw->vt.td->originMode ;
  966. /* The following is save at the TermPrim level */
  967. /* vtw->vt.td->saveCursor.wrapMode = */
  968. vtd->saveCursor.enhVideoState = vtd->enhVideoState ;
  969. vtd->saveCursor.enhFieldState = vtd->enhFieldState ;
  970. vtd->saveCursor.enhFgColorState = vtd->enhFgColorState;
  971. vtd->saveCursor.enhBgColorState = vtd->enhBgColorState;
  972. vtd->saveCursor.GL = vtd->GL;
  973. vtd->saveCursor.GR = vtd->GR;
  974. vtd->saveCursor.G0 = vtd->G0;
  975. vtd->saveCursor.G1 = vtd->G1;
  976. vtd->saveCursor.G2 = vtd->G2;
  977. vtd->saveCursor.G3 = vtd->G3;
  978. vtd->saveCursor.singleShiftFont = vtd->singleShiftFont;
  979. vtd->saveCursor.singleShiftPending = vtd->singleShiftPending;
  980. }
  981. void
  982. _DtTermRestoreCursor(Widget w) /* DECRC ESC8 */
  983. {
  984. DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
  985. DtTermPrimData tpd = tw->term.tpd;
  986. DtTermWidget vtw = (DtTermWidget) w;
  987. DtTermData vtd = vtw->vt.td;
  988. Debug('P', fprintf(stderr,">>In func _DtTermRestoreCursor\n")) ;
  989. tpd->cursorRow = vtd->saveCursor.cursorRow ;
  990. tpd->cursorColumn = vtd->saveCursor.cursorColumn ;
  991. vtw->vt.td->originMode = vtd->saveCursor.originMode ;
  992. tpd->autoWrapRight = vtd->saveCursor.wrapMode ;
  993. vtd->enhVideoState = vtd->saveCursor.enhVideoState ;
  994. vtd->enhFieldState = vtd->saveCursor.enhFieldState ;
  995. vtd->enhFgColorState = vtd->saveCursor.enhFgColorState;
  996. vtd->enhBgColorState = vtd->saveCursor.enhBgColorState;
  997. vtd->GR = vtd->saveCursor.GR;
  998. vtd->GL = vtd->saveCursor.GL;
  999. vtd->G0 = vtd->saveCursor.G0;
  1000. vtd->G1 = vtd->saveCursor.G1;
  1001. vtd->G2 = vtd->saveCursor.G2;
  1002. vtd->G3 = vtd->saveCursor.G3;
  1003. vtd->singleShiftFont = vtd->saveCursor.singleShiftFont;
  1004. vtd->singleShiftPending = vtd->saveCursor.singleShiftPending;
  1005. (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
  1006. tpd->topRow + tpd->cursorRow, tpd->cursorColumn, enhVideo,
  1007. vtd->enhVideoState);
  1008. (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
  1009. tpd->topRow + tpd->cursorRow, tpd->cursorColumn, enhField,
  1010. vtd->enhFieldState);
  1011. (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
  1012. tpd->topRow + tpd->cursorRow, tpd->cursorColumn, enhFont,
  1013. *(vtd->GL));
  1014. (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
  1015. tpd->topRow + tpd->cursorRow, tpd->cursorColumn, enhBgColor,
  1016. vtd->saveCursor.enhBgColorState);
  1017. (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
  1018. tpd->topRow + tpd->cursorRow, tpd->cursorColumn, enhFgColor,
  1019. vtd->saveCursor.enhFgColorState);
  1020. if ( vtd->originMode ) {
  1021. if (tpd->cursorRow < tpd->scrollLockTopRow )
  1022. tpd->cursorRow = tpd->scrollLockTopRow ;
  1023. else if (tpd->cursorRow > tpd->scrollLockBottomRow )
  1024. tpd->cursorRow = tpd->scrollLockBottomRow ;
  1025. }
  1026. }
  1027. void
  1028. _DtTermAppKeypad(Widget w) /* DECPAM ESC= */
  1029. {
  1030. DtTermWidget vtw = (DtTermWidget) w;
  1031. Debug('P', fprintf(stderr,">>In func _DtTermAppKeypad\n")) ;
  1032. vtw->vt.td->applicationKPMode=True;
  1033. }
  1034. void
  1035. _DtTermNormalKeypad(Widget w) /* DECPNM ESC> */
  1036. {
  1037. DtTermWidget vtw = (DtTermWidget) w;
  1038. Debug('P', fprintf(stderr,">>In func _DtTermNormalKeypad\n")) ;
  1039. vtw->vt.td->applicationKPMode=False;
  1040. }
  1041. void
  1042. _DtTermS8C1T(Widget w) /* S8C1T ESCG */
  1043. {
  1044. DtTermWidget vtw = (DtTermWidget) w;
  1045. Debug('P', fprintf(stderr,">>In func _vt8CIT\n")) ;
  1046. vtw->vt.td->S8C1TMode=True;
  1047. }
  1048. void
  1049. _DtTermS7C1T(Widget w) /* S7C1T ESCF */
  1050. {
  1051. DtTermWidget vtw = (DtTermWidget) w;
  1052. Debug('P', fprintf(stderr,">>In func _vt8CIT\n")) ;
  1053. vtw->vt.td->S8C1TMode=False;
  1054. }
  1055. void
  1056. _DtTermSetCompatLevel(Widget w) /* DECSCL CSI p;p"p (last p literal) */
  1057. {
  1058. ParserContext context ;
  1059. DtTermWidget vtw = (DtTermWidget) w;
  1060. Debug('P', fprintf(stderr,">>In func _DtTermSetCompatLevel\n")) ;
  1061. context = GetParserContext(w) ;
  1062. STORELASTARG(context) ;
  1063. vtw->vt.td->compatLevel= 2; /* assume vt200 mode */
  1064. switch ( PCOUNT(context) ) {
  1065. case 1: switch (context->parms[1]) {
  1066. case 61: vtw->vt.td->compatLevel= 1;
  1067. vtw->vt.td->S8C1TMode=False;
  1068. break;
  1069. case 62: vtw->vt.td->S8C1TMode=True;
  1070. break;
  1071. }
  1072. break;
  1073. case 2: switch (context->parms[2]) {
  1074. case 0:
  1075. case 2: vtw->vt.td->S8C1TMode=True;
  1076. break;
  1077. case 1:
  1078. vtw->vt.td->S8C1TMode=False;
  1079. break;
  1080. }
  1081. }
  1082. }
  1083. void
  1084. _DtTermInvokeG3(Widget w) /* LS3R ESC| */
  1085. {
  1086. Debug('P', fprintf(stderr,">>In func _DtTermInvokeG3\n")) ;
  1087. }
  1088. void
  1089. _DtTermInvokeG2(Widget w) /* LS3R ESC} */
  1090. {
  1091. Debug('P', fprintf(stderr,">>In func _DtTermInvokeG2\n")) ;
  1092. }
  1093. void
  1094. _DtTermScrollUp(Widget w) /* SU CSIpS */
  1095. {
  1096. ParserContext context ;
  1097. DtTermWidget vtw = (DtTermWidget) w;
  1098. int row,col,cnt ;
  1099. Debug('P', fprintf(stderr,">>In func _DtTermScrollUp\n")) ;
  1100. #define EXIT_IF_OUTSIDE_SR(w) if((w)->term.tpd->scrollLockTopRow > \
  1101. (w)->term.tpd->cursorRow || \
  1102. (w)->term.tpd->scrollLockBottomRow < \
  1103. (w)->term.tpd->cursorRow) \
  1104. return;
  1105. EXIT_IF_OUTSIDE_SR(vtw)
  1106. KILLWRAP(vtw) ;
  1107. context = GetParserContext(w) ;
  1108. row = vtw->term.tpd->cursorRow;
  1109. col = vtw->term.tpd->cursorColumn;
  1110. STORELASTARG(context) ;
  1111. if (!context->parms[1])
  1112. context->parms[1] = 1;
  1113. else if (context->parms[1] > MAXSHORT)
  1114. context->parms[1] = MAXSHORT - 100;
  1115. /* clip the number of rows to the scroll region... */
  1116. if (context->parms[1] > (vtw->term.tpd->scrollLockBottomRow -
  1117. vtw->term.tpd->scrollLockTopRow + 1)) {
  1118. context->parms[1] = vtw->term.tpd->scrollLockBottomRow -
  1119. vtw->term.tpd->scrollLockTopRow + 1;
  1120. }
  1121. vtw->term.tpd->cursorRow = TOPMARGIN(vtw) ;
  1122. _DtTermFuncDeleteLine(w, context->parms[1], fromParser);
  1123. vtw->term.tpd->cursorRow = row;
  1124. vtw->term.tpd->cursorColumn = col;
  1125. }
  1126. void
  1127. _DtTermScrollDown(Widget w) /* SD CSIpT */
  1128. {
  1129. ParserContext context ;
  1130. DtTermWidget vtw = (DtTermWidget) w;
  1131. int row,col,cnt ;
  1132. Debug('P', fprintf(stderr,">>In func _DtTermScrollDown\n")) ;
  1133. EXIT_IF_OUTSIDE_SR(vtw)
  1134. KILLWRAP(vtw) ;
  1135. context = GetParserContext(w) ;
  1136. row = vtw->term.tpd->cursorRow;
  1137. col = vtw->term.tpd->cursorColumn ;
  1138. STORELASTARG(context) ;
  1139. if (!context->parms[1])
  1140. context->parms[1] = 1;
  1141. else if (context->parms[1] > MAXSHORT)
  1142. context->parms[1] = MAXSHORT - 100;
  1143. /* clip the number of rows to the scroll region... */
  1144. if (context->parms[1] > (vtw->term.tpd->scrollLockBottomRow -
  1145. vtw->term.tpd->scrollLockTopRow) + 1) {
  1146. context->parms[1] = vtw->term.tpd->scrollLockBottomRow -
  1147. vtw->term.tpd->scrollLockTopRow + 1;
  1148. }
  1149. vtw->term.tpd->cursorRow = TOPMARGIN(vtw) ;
  1150. _DtTermFuncInsertLine(w, context->parms[1], fromParser) ;
  1151. vtw->term.tpd->cursorRow = row;
  1152. vtw->term.tpd->cursorColumn = col;
  1153. }
  1154. void
  1155. _DtTermRestoreModeValues(Widget w) /* xterm - Restore DEC mode values CSI?pr */
  1156. {
  1157. ParserContext context ;
  1158. DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
  1159. DtTermWidget vtw = (DtTermWidget)w;
  1160. DtTermData vtd = vtw->vt.td;
  1161. int i,cnt ;
  1162. Debug ('P', fprintf(stderr,">>In func _DtTermPModeReset\n")) ;
  1163. context = GetParserContext(w) ;
  1164. STORELASTARG(context) ;
  1165. cnt = PCOUNT(context) ;
  1166. for (i=1;i<=cnt;i++) {
  1167. switch ( context->parms[i]) {
  1168. /* from vt220 */
  1169. case 1: /* Cursor key (Normal/Application) */
  1170. vtd->applicationMode = vtd->saveDECMode.applicationMode ;
  1171. break;
  1172. #ifdef NOT_SUPPORTED
  1173. case 2: /* set vt52 mode */
  1174. break;
  1175. #endif /* NOT_SUPPORTED */
  1176. case 3: /* Columns (80/132) */
  1177. vtd->col132Mode = vtd->saveDECMode.col132Mode ;
  1178. break;
  1179. case 4: /* Scroll Mode ( jump/smooth ) */
  1180. _DtTermPrimScrollComplete(w, True) ;
  1181. vtw->term.jumpScroll = vtd->saveDECMode.jumpScrollMode ;
  1182. break;
  1183. case 5: /* Screen mode */
  1184. vtw->term.reverseVideo = vtd->saveDECMode.inverseVideoMode ;
  1185. break;
  1186. case 6: /* Origin mode (on/off)*/
  1187. vtd->originMode = vtd->saveDECMode.originMode ;
  1188. break;
  1189. case 7: /* Auto wrap (On/Off) */
  1190. vtw->term.tpd->autoWrapRight = vtd->saveDECMode.wrapMode ;
  1191. break;
  1192. case 8: /* Auto repeat (Off) */
  1193. /* implemented in the server */
  1194. break;
  1195. #ifdef NOT_SUPPORTED
  1196. case 18: /* Print form feed (Off) */
  1197. break;
  1198. case 19: /* Print extent (scrolling region) */
  1199. break;
  1200. #endif /* NOT_SUPPORTED */
  1201. case 25: /* Text cursor enable (Off) */
  1202. _DtTermPrimSetCursorVisible(w,
  1203. vtd->saveDECMode.cursorVisible);
  1204. break;
  1205. /* from xterm */
  1206. case 40: /* 80/132 mode (disallow/allow) */
  1207. vtw->vt.c132 = vtd->saveDECMode.allow80_132ColMode;
  1208. break;
  1209. case 41: /* curses fix (off/on) */
  1210. vtd->fixCursesMode = vtd->saveDECMode.fixCursesMode;
  1211. break;
  1212. case 44: /* margin bell (off/on) */
  1213. vtw->term.marginBell = vtd->saveDECMode.marginBellMode;
  1214. break;
  1215. case 45: /* Reverse-wraparound mode */
  1216. vtd->reverseWrapMode = vtd->saveDECMode.reverseWrapMode ;
  1217. break;
  1218. case 46: /* logging (stop/start ) */
  1219. if (vtd->saveDECMode.logging) {
  1220. vtw->term.logging = True ;
  1221. _DtTermPrimStartLog(w);
  1222. } else {
  1223. vtw->term.logging = False ;
  1224. _DtTermPrimCloseLog(w) ;
  1225. }
  1226. break;
  1227. #ifdef NOT_SUPPORTED
  1228. case 47: /* screen buffer (normal) */
  1229. break;
  1230. case 1000: /* don't send mouse x and y */
  1231. break;
  1232. case 1001: /* don't use hilite mouse tracking */
  1233. break;
  1234. #endif /* NOT_SUPPORTED */
  1235. }
  1236. }
  1237. }
  1238. void
  1239. _DtTermSaveModeValues(Widget w) /* xterm - Save DEC mode values CSI?ps */
  1240. {
  1241. ParserContext context ;
  1242. DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
  1243. DtTermWidget vtw = (DtTermWidget)w;
  1244. DtTermData vtd = vtw->vt.td;
  1245. int i,cnt ;
  1246. Debug ('P', fprintf(stderr,">>In func _DtTermPModeReset\n")) ;
  1247. context = GetParserContext(w) ;
  1248. STORELASTARG(context) ;
  1249. cnt = PCOUNT(context) ;
  1250. for (i=1;i<=cnt;i++) {
  1251. switch ( context->parms[i]) {
  1252. /* from vt220 */
  1253. case 1: /* Cursor key (Normal/Application) */
  1254. vtd->saveDECMode.applicationMode = vtd->applicationMode ;
  1255. break;
  1256. #ifdef NOT_SUPPORTED
  1257. case 2: /* set vt52 mode */
  1258. break;
  1259. #endif /* NOT_SUPPORTED */
  1260. case 3: /* Columns (80/132) */
  1261. vtd->saveDECMode.col132Mode = vtd->col132Mode ;
  1262. break;
  1263. case 4: /* Scroll Mode ( jump/smooth ) */
  1264. vtd->saveDECMode.jumpScrollMode = vtw->term.jumpScroll ;
  1265. break;
  1266. case 5: /* Screen mode */
  1267. vtd->saveDECMode.inverseVideoMode = vtw->term.reverseVideo ;
  1268. break;
  1269. case 6: /* Origin mode (on/off)*/
  1270. vtd->saveDECMode.originMode = vtd->originMode ;
  1271. break;
  1272. case 7: /* Auto wrap (On/Off) */
  1273. vtd->saveDECMode.wrapMode = vtw->term.tpd->autoWrapRight ;
  1274. break;
  1275. case 8: /* Auto repeat (Off) */
  1276. /* implemented in the server */
  1277. break;
  1278. #ifdef NOT_SUPPORTED
  1279. case 18: /* Print form feed (Off) */
  1280. break;
  1281. case 19: /* Print extent (scrolling region) */
  1282. break;
  1283. #endif /* NOT_SUPPORTED */
  1284. case 25: /* Text cursor enable (Off) */
  1285. vtd->saveDECMode.cursorVisible =
  1286. _DtTermPrimGetCursorVisible(w);
  1287. break;
  1288. /* from xterm */
  1289. case 40: /* 80/132 mode (disallow/allow) */
  1290. vtd->saveDECMode.allow80_132ColMode = vtw->vt.c132;
  1291. break;
  1292. case 41: /* curses fix (off/on) */
  1293. vtd->saveDECMode.fixCursesMode = vtd->fixCursesMode ;
  1294. break;
  1295. case 44: /* margin bell (off/on) */
  1296. vtd->saveDECMode.marginBellMode = vtw->term.marginBell ;
  1297. break;
  1298. case 45: /* Reverse-wraparound mode */
  1299. vtd->saveDECMode.reverseWrapMode = vtd->reverseWrapMode ;
  1300. break;
  1301. case 46: /* logging (stop/start ) */
  1302. vtd->saveDECMode.logging = vtw->term.logging;
  1303. break;
  1304. #ifdef NOT_SUPPORTED
  1305. case 47: /* screen buffer (normal) */
  1306. break;
  1307. case 1000: /* don't send mouse x and y */
  1308. break;
  1309. case 1001: /* don't use hilite mouse tracking */
  1310. break;
  1311. #endif /* NOT_SUPPORTED */
  1312. }
  1313. }
  1314. }
  1315. void
  1316. _DtTermAlignTest(Widget w) /* DECALN ESC#8 */
  1317. {
  1318. DtTermWidget vtw = (DtTermWidget) w;
  1319. int tlrow, blrow, cnt ;
  1320. Debug('P', fprintf(stderr,">>In func _DtTermAlignTest\n")) ;
  1321. vtw->term.tpd->parserNotInStartState = False ;
  1322. tlrow = vtw->term.tpd->scrollLockTopRow ;
  1323. blrow = vtw->term.tpd->scrollLockBottomRow ;
  1324. vtw->term.tpd->scrollLockTopRow = TOPROW(w) ; ;
  1325. vtw->term.tpd->scrollLockBottomRow = BOTTOMROW(vtw) ;
  1326. cnt = (BOTTOMROW(vtw)+BASE)*(LASTCOLUMN(vtw)+BASE);
  1327. vtw->term.tpd->cursorColumn = FIRSTCOLUMN(w) ;
  1328. vtw->term.tpd->cursorRow = TOPROW(w) ;
  1329. while(cnt--) _DtTermPrimInsertText(w,(unsigned char *) "E", 1) ;
  1330. vtw->term.tpd->scrollLockTopRow = tlrow ;
  1331. vtw->term.tpd->scrollLockBottomRow = blrow ;
  1332. vtw->term.tpd->cursorRow = CEILING(vtw) ;
  1333. vtw->term.tpd->cursorColumn = FIRSTCOLUMN(w) ;
  1334. }
  1335. void
  1336. _DtTermInvokeG1(Widget w) /* ESC~ESC */
  1337. {
  1338. Debug('P', fprintf(stderr,">>In func _DtTermInvokeG1\n")) ;
  1339. }
  1340. void
  1341. _DtTermSelEraseInLine(Widget w) /* DECSEL ESC?pK */
  1342. {
  1343. DtTermWidget vtw = (DtTermWidget) w;
  1344. DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
  1345. TermBuffer tb = tw->term.tpd->termBuffer ;
  1346. DtTermPrimData tpd = tw->term.tpd;
  1347. DtTermData td = vtw->vt.td;
  1348. ParserContext context ;
  1349. enhValues evalues;
  1350. int c,col1,col2,col,row ;
  1351. short cnt ;
  1352. DtTermInsertCharMode saveInsertCharMode;
  1353. Debug('P', fprintf(stderr,">>In func _DtTermSelEraseInLine\n")) ;
  1354. KILLWRAP(vtw) ;
  1355. context = GetParserContext(w) ;
  1356. STORELASTARG(context) ;
  1357. col1 = FIRSTCOLUMN(vtw) ;
  1358. col2 = LASTCOLUMN(vtw) ;
  1359. switch ( context->parms[1] ) {
  1360. case 0:
  1361. col1= tpd->cursorColumn;
  1362. break;
  1363. case 1:
  1364. col2 = tpd->cursorColumn;
  1365. break;
  1366. case 2:
  1367. break ;
  1368. default:
  1369. return ;
  1370. }
  1371. /* save away the current cursor position... */
  1372. col = tpd->cursorColumn ;
  1373. row = tpd->cursorRow ;
  1374. /* save away the current insert mode... */
  1375. saveInsertCharMode = vtw->term.tpd->insertCharMode;
  1376. /* insert char needs to be off... */
  1377. tpd->insertCharMode = DtTERM_INSERT_CHAR_OFF;
  1378. tpd->parserNotInStartState = False ;
  1379. c = col1;
  1380. while (c <= col2) {
  1381. (void)_DtTermPrimBufferGetEnhancement(tb, tpd->cursorRow,
  1382. c, &evalues, &cnt, countAll);
  1383. if (!cnt)
  1384. break ;
  1385. if (evalues[(int)enhField] == FIELD_UNPROTECT) {
  1386. (void) _DtTermPrimBufferSetEnhancement(tb, tpd->cursorRow,
  1387. c, enhVideo, evalues[(int)enhVideo]);
  1388. (void) _DtTermPrimBufferSetEnhancement(tb, tpd->cursorRow,
  1389. c, enhFgColor, evalues[(int)enhFgColor]);
  1390. (void) _DtTermPrimBufferSetEnhancement(tb, tpd->cursorRow,
  1391. c, enhBgColor, evalues[(int)enhBgColor]);
  1392. while ((c <= col2) && cnt--) {
  1393. tpd->cursorColumn = c;
  1394. (void) _DtTermPrimInsertText(w, (unsigned char *) " ", 1);
  1395. c++;
  1396. }
  1397. } else {
  1398. c += cnt;
  1399. }
  1400. }
  1401. /* restore the insert char mode... */
  1402. tpd->insertCharMode = saveInsertCharMode;
  1403. /* restore the cursor position... */
  1404. tpd->cursorColumn = col;
  1405. tpd->cursorRow = row;
  1406. /* restore the current enhancement state... */
  1407. (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
  1408. tpd->topRow + tpd->cursorRow, tpd->cursorColumn, enhVideo,
  1409. td->enhVideoState);
  1410. (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
  1411. tpd->topRow + tpd->cursorRow, tpd->cursorColumn, enhFgColor,
  1412. td->enhFgColorState);
  1413. (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
  1414. tpd->topRow + tpd->cursorRow, tpd->cursorColumn, enhBgColor,
  1415. td->enhBgColorState);
  1416. }
  1417. void
  1418. _DtTermSelEraseInDisplay(Widget w) /* DECSED ESC?pJ */
  1419. {
  1420. DtTermWidget vtw = (DtTermWidget) w;
  1421. DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
  1422. ParserContext context ;
  1423. enhValues evalues;
  1424. int r,col1,col2,row1,row2,col,row ;
  1425. int cnt ;
  1426. Debug('P', fprintf(stderr,">>In func _DtTermSelEraseInDisplay\n")) ;
  1427. KILLWRAP(vtw) ;
  1428. context = GetParserContext(w) ;
  1429. STORELASTARG(context) ;
  1430. col1 = FIRSTCOLUMN(vtw) ;
  1431. row1 = TOPROW(vtw) ;
  1432. col2 = LASTCOLUMN(vtw) ;
  1433. row2 = BOTTOMROW(vtw) ;
  1434. switch ( context->parms[1] ) {
  1435. case 0: col1= vtw->term.tpd->cursorColumn;
  1436. row1 = vtw->term.tpd->cursorRow;
  1437. break;
  1438. case 1: col2 = vtw->term.tpd->cursorColumn;
  1439. row2 = vtw->term.tpd->cursorRow;
  1440. break;
  1441. case 2: break ;
  1442. default: return ;
  1443. }
  1444. col = vtw->term.tpd->cursorColumn;
  1445. row = vtw->term.tpd->cursorRow;
  1446. vtw->term.tpd->cursorColumn = col1 ;
  1447. vtw->term.tpd->cursorRow = row1;
  1448. context->workingNum = 0 ; /* erase to the end of line */
  1449. _DtTermSelEraseInLine(w) ;
  1450. context->workingNum = 2 ; /* erase the whole row */
  1451. for ( r=row1+1; r<row2; r++) {
  1452. vtw->term.tpd->cursorRow = r;
  1453. _DtTermSelEraseInLine(w) ;
  1454. }
  1455. vtw->term.tpd->cursorColumn = col2 ;
  1456. vtw->term.tpd->cursorRow = row2;
  1457. context->workingNum = 2 ; /* erase the beginning of the line */
  1458. _DtTermSelEraseInLine(w) ;
  1459. vtw->term.tpd->cursorColumn = col ;
  1460. vtw->term.tpd->cursorRow = row;
  1461. }
  1462. void
  1463. _DtTermSingleShiftG2(Widget w) /* SS2 ESCN */
  1464. {
  1465. DtTermWidget vtw = (DtTermWidget) w;
  1466. DtTermData vtd = vtw->vt.td;
  1467. Debug('P', fprintf(stderr,">>In func _DtTermSingleShiftG2\n")) ;
  1468. vtd->singleShiftPending = True;
  1469. vtd->singleShiftFont = vtd->G2;
  1470. }
  1471. void
  1472. _DtTermSingleShiftG3(Widget w) /* SS3 ESCO */
  1473. {
  1474. DtTermWidget vtw = (DtTermWidget) w;
  1475. DtTermData vtd = vtw->vt.td;
  1476. Debug('P', fprintf(stderr,">>In func _DtTermSingleShiftG3\n")) ;
  1477. vtd->singleShiftPending = True;
  1478. vtd->singleShiftFont = vtd->G3;
  1479. }
  1480. void
  1481. _DtTermLoadCharSet(Widget w) /* vt220 DCS - download char set ESCPpST */
  1482. {
  1483. /* we're not implementing this */
  1484. }
  1485. /*********************************************************************
  1486. * The next 3 functions handle the user key string loading
  1487. * DCS Pc;Pl | Ky1/st1;ky2/st2;...kyn/stn ST
  1488. */
  1489. void
  1490. _DtTermParseUserKeyClear(Widget w) /* vt220 DECUDK clear function keys*/
  1491. {
  1492. DtTermWidget vtw = (DtTermWidget) w;
  1493. DtTermData vtd = vtw->vt.td;
  1494. ParserContext context ;
  1495. Debug('P', fprintf(stderr,">>In func _DtTermLoadSoftKey\n")) ;
  1496. context = GetParserContext(w) ;
  1497. STORELASTARG(context) ;
  1498. if ( !vtd->userKeysLocked )
  1499. {
  1500. vtd->needToLockUserKeys = False ;
  1501. if (context->parms[1] == 0)
  1502. _DtTermFunctionKeyClear(w) ;
  1503. if (context->parms[0] == 2 && context->parms[2] == 0)
  1504. vtd->needToLockUserKeys = True ;
  1505. }
  1506. _DtTermClearParam(w) ;
  1507. }
  1508. void
  1509. _DtTermParseUserKeyLoad(Widget w) /* vt220 DECUDK load function string */
  1510. {
  1511. DtTermWidget vtw = (DtTermWidget) w;
  1512. DtTermData vtd = vtw->vt.td;
  1513. ParserContext context ;
  1514. Debug('P', fprintf(stderr,">>In func _DtTermLoadSoftKey\n")) ;
  1515. context = GetParserContext(w) ;
  1516. STORELASTARG(context) ;
  1517. if ( !vtd->userKeysLocked)
  1518. {
  1519. context->stringParms[0].str[context->stringParms[0].length/2] =
  1520. (unsigned char)0 ; /* Null terminate */
  1521. _DtTermFunctionKeyStringStore(w,context->parms[1],
  1522. (char *)context->stringParms[0].str);
  1523. }
  1524. _DtTermClearParam(w) ;
  1525. }
  1526. void
  1527. _DtTermParseUserKeyLoadLast(Widget w) /* vt220 DECUDK load function string */
  1528. {
  1529. DtTermWidget vtw = (DtTermWidget) w;
  1530. DtTermData vtd = vtw->vt.td;
  1531. _DtTermParseUserKeyLoad(w);
  1532. if (vtd->needToLockUserKeys) vtd->userKeysLocked = True ;
  1533. vtd->needToLockUserKeys = False ;
  1534. }
  1535. void
  1536. _DtTermParseHexDigit(Widget w) /* vt220 DECUDK store hex digit*/
  1537. {
  1538. ParserContext context ;
  1539. int ci, left_byte, i;
  1540. char c, cbuf[2] ;
  1541. Debug('P', fprintf(stderr,">>In func _DtTermLoadSoftKey\n")) ;
  1542. context = GetParserContext(w) ;
  1543. if ( (int)context->stringParms[0].length < 2*STR_SIZE-1 ) {
  1544. /* fold the hex digits into characters */
  1545. i = context->stringParms[0].length ;
  1546. cbuf[0] = *context->inputChar ;
  1547. cbuf[1] = (char)0 ;
  1548. sscanf(cbuf,"%x",&ci) ;
  1549. c = (char)ci ;
  1550. left_byte = (i+1)%2 ;
  1551. i /= 2 ;
  1552. if ( left_byte )
  1553. context->stringParms[0].str[i] = c<<4 ;
  1554. else
  1555. context->stringParms[0].str[i] |= c & 0x0F ;
  1556. context->stringParms[0].length++ ;
  1557. }
  1558. }
  1559. void
  1560. _DtTermReset(Widget w) /* RIS ESCc */
  1561. {
  1562. Debug('P', fprintf(stderr,">>In func _DtTermReset\n")) ;
  1563. _DtTermFuncHardReset(w,0 ,fromParser) ;
  1564. }
  1565. void
  1566. _DtTermSelectG2(Widget w) /* LS2 ESCn */
  1567. {
  1568. DtTermWidget vtw = (DtTermWidget)w ;
  1569. DtTermData vtd = vtw->vt.td;
  1570. DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
  1571. DtTermPrimData tpd = tw->term.tpd;
  1572. Debug('P', fprintf(stderr,">>In func _DtTermSelectG2\n")) ;
  1573. vtd->GL = &vtd->G2;
  1574. vtd->enhFontState = *vtd->GL;
  1575. (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
  1576. tpd->topRow + tpd->cursorRow, tpd->cursorColumn,
  1577. enhFont, vtd->enhFontState);
  1578. }
  1579. void
  1580. _DtTermSelectG3(Widget w) /* LS3 ESCo */
  1581. {
  1582. DtTermWidget vtw = (DtTermWidget)w ;
  1583. DtTermData vtd = vtw->vt.td;
  1584. DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
  1585. DtTermPrimData tpd = tw->term.tpd;
  1586. Debug('P', fprintf(stderr,">>In func _DtTermSelectG3\n")) ;
  1587. vtd->GL = &vtd->G3;
  1588. vtd->enhFontState = *vtd->GL;
  1589. (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
  1590. tpd->topRow + tpd->cursorRow, tpd->cursorColumn,
  1591. enhFont, vtd->enhFontState);
  1592. }
  1593. void
  1594. _DtTermParseStatus(Widget w) /* DECID (same as DA) ESCZ */
  1595. {
  1596. _DtTermDeviceAttributes(w) ;
  1597. }
  1598. void
  1599. _DtTermSetCharEraseMode(Widget w) /* DECSCA ESCp"q */
  1600. {
  1601. DtTermWidget vtw = (DtTermWidget) w;
  1602. DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
  1603. DtTermPrimData tpd = tw->term.tpd;
  1604. ParserContext context ;
  1605. Debug('P', fprintf(stderr,">>In func _DtTermSetCharEraseMode\n")) ;
  1606. context = GetParserContext(w) ;
  1607. STORELASTARG(context) ;
  1608. switch ( context->parms[1] ) {
  1609. case 0: /* set back to default which is unprotect */
  1610. /* fall through */
  1611. case 2:
  1612. vtw->vt.td->enhFieldState = FIELD_UNPROTECT;
  1613. (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
  1614. tpd->topRow + tpd->cursorRow, tpd->cursorColumn,
  1615. enhField, vtw->vt.td->enhFieldState);
  1616. break;
  1617. case 1:
  1618. vtw->vt.td->enhFieldState = FIELD_PROTECT;
  1619. (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
  1620. tpd->topRow + tpd->cursorRow, tpd->cursorColumn,
  1621. enhField, vtw->vt.td->enhFieldState);
  1622. break;
  1623. }
  1624. }
  1625. void
  1626. _DtTermSingleWide(Widget w) /* DECSWL ESC#5 */
  1627. {
  1628. Debug('P', fprintf(stderr,">>In func _DtTermSingleWide\n")) ;
  1629. }
  1630. void
  1631. _DtTermDoubleWide(Widget w) /* DECDWL ESC#6 */
  1632. {
  1633. Debug('P', fprintf(stderr,">>In func _DtTermDoubleWide\n")) ;
  1634. }
  1635. void
  1636. _DtTermDoubleHigh(Widget w) /* DECWHL ESC#4 */
  1637. {
  1638. Debug('P', fprintf(stderr,">>In func _DtTermDoubleHigh\n")) ;
  1639. }
  1640. void
  1641. _DtTermParseFontG0(Widget w)
  1642. {
  1643. DtTermWidget vtw = (DtTermWidget)w ;
  1644. DtTermData vtd = vtw->vt.td;
  1645. DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
  1646. DtTermPrimData tpd = tw->term.tpd;
  1647. ParserContext context ;
  1648. context = GetParserContext(w) ;
  1649. Debug('P', fprintf(stderr,">>In func _DtTermParseFontG0\n")) ;
  1650. switch (*context->inputChar) {
  1651. case 'B':
  1652. vtd->G0 = FONT_NORMAL;
  1653. break;
  1654. case '0':
  1655. vtd->G0 = FONT_LINEDRAW;
  1656. break;
  1657. }
  1658. vtd->enhFontState = *vtd->GL;
  1659. (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
  1660. tpd->topRow + tpd->cursorRow, tpd->cursorColumn,
  1661. enhFont, vtd->enhFontState);
  1662. }
  1663. void
  1664. _DtTermParseFontG1(Widget w)
  1665. {
  1666. DtTermWidget vtw = (DtTermWidget)w ;
  1667. DtTermData vtd = vtw->vt.td;
  1668. DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
  1669. DtTermPrimData tpd = tw->term.tpd;
  1670. ParserContext context ;
  1671. context = GetParserContext(w) ;
  1672. Debug('P', fprintf(stderr,">>In func _DtTermParseFontG1\n")) ;
  1673. switch (*context->inputChar) {
  1674. case 'B':
  1675. vtd->G1 = FONT_NORMAL;
  1676. break;
  1677. case '0':
  1678. vtd->G1 = FONT_LINEDRAW;
  1679. break;
  1680. }
  1681. vtd->enhFontState = *vtd->GL;
  1682. (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
  1683. tpd->topRow + tpd->cursorRow, tpd->cursorColumn,
  1684. enhFont, vtd->enhFontState);
  1685. }
  1686. void
  1687. _DtTermParseFontG2(Widget w)
  1688. {
  1689. DtTermWidget vtw = (DtTermWidget)w ;
  1690. DtTermData vtd = vtw->vt.td;
  1691. DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
  1692. DtTermPrimData tpd = tw->term.tpd;
  1693. ParserContext context ;
  1694. context = GetParserContext(w) ;
  1695. Debug('P', fprintf(stderr,">>In func _DtTermParseFontG1\n")) ;
  1696. switch (*context->inputChar) {
  1697. case 'B':
  1698. vtd->G2 = FONT_NORMAL;
  1699. break;
  1700. case '0':
  1701. vtd->G2 = FONT_LINEDRAW;
  1702. break;
  1703. }
  1704. vtd->enhFontState = *vtd->GL;
  1705. (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
  1706. tpd->topRow + tpd->cursorRow, tpd->cursorColumn,
  1707. enhFont, vtd->enhFontState);
  1708. }
  1709. void
  1710. _DtTermParseFontG3(Widget w)
  1711. {
  1712. DtTermWidget vtw = (DtTermWidget)w ;
  1713. DtTermData vtd = vtw->vt.td;
  1714. DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
  1715. DtTermPrimData tpd = tw->term.tpd;
  1716. ParserContext context ;
  1717. context = GetParserContext(w) ;
  1718. Debug('P', fprintf(stderr,">>In func _DtTermParseFontG1\n")) ;
  1719. switch (*context->inputChar) {
  1720. case 'B':
  1721. vtd->G3 = FONT_NORMAL;
  1722. break;
  1723. case '0':
  1724. vtd->G3 = FONT_LINEDRAW;
  1725. break;
  1726. }
  1727. vtd->enhFontState = *vtd->GL;
  1728. (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
  1729. tpd->topRow + tpd->cursorRow, tpd->cursorColumn,
  1730. enhFont, vtd->enhFontState);
  1731. }
  1732. void
  1733. _DtTermParseFontShift(Widget w) /* Ctrl-E Ctrl-F */
  1734. {
  1735. DtTermWidget vtw = (DtTermWidget)w ;
  1736. DtTermData vtd = vtw->vt.td;
  1737. DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
  1738. DtTermPrimData tpd = tw->term.tpd;
  1739. ParserContext context ;
  1740. context = GetParserContext(w) ;
  1741. Debug('P', fprintf(stderr,">>In func _DtTermParseFontShift\n")) ;
  1742. switch (*context->inputChar) {
  1743. case 'O' & 0x1f:
  1744. /* SHIFT OUT */
  1745. vtd->GL = &vtd->G0;
  1746. break;
  1747. case 'N' & 0x1f:
  1748. /* SHIFT OUT */
  1749. vtd->GL = &vtd->G1;
  1750. break;
  1751. }
  1752. vtd->enhFontState = *vtd->GL;
  1753. (void)_DtTermPrimBufferSetEnhancement(tpd->termBuffer,
  1754. tpd->topRow + tpd->cursorRow, tpd->cursorColumn,
  1755. enhFont, vtd->enhFontState);
  1756. }
  1757. void
  1758. _DtTermParseTab(Widget w) /* Crtl-I */
  1759. {
  1760. DtTermWidget vtw = (DtTermWidget)w ;
  1761. Debug('P', fprintf(stderr,">>In func _DtTermParseTab\n")) ;
  1762. if (vtw->term.tpd->cursorColumn > LASTCOLUMN(vtw)) {
  1763. if (vtw->vt.td->fixCursesMode) {
  1764. (void) _DtTermNextLine(w);
  1765. (void) _DtTermFuncTab(w, 1, fromParser);
  1766. } else {
  1767. /* we already tabbed to the end of the line, so do nothing... */
  1768. }
  1769. } else {
  1770. (void) _DtTermFuncTab(w, 1, fromParser);
  1771. }
  1772. return;
  1773. }
  1774. void
  1775. _DtTermParseLF /* LineFeed (LF) or newline (NL) Ctrl-J,
  1776. Vertical Tab Ctrl-K, Form Feed (NP) Ctrl-L */
  1777. (
  1778. Widget w
  1779. )
  1780. {
  1781. DtTermWidget vtw = (DtTermWidget)w ;
  1782. Debug('P', fprintf(stderr,">>In func _vtParseLR\n")) ;
  1783. KILLWRAP(vtw) ;
  1784. if (vtw->term.tpd->cursorRow == BOTTOMMARGIN(vtw))
  1785. {
  1786. /*
  1787. ** scroll one line...
  1788. */
  1789. (void) _DtTermPrimScrollText(w, 1);
  1790. vtw->term.tpd->cursorRow = BOTTOMMARGIN(vtw);
  1791. }
  1792. else {
  1793. if (!(vtw->term.tpd->cursorRow == BOTTOMROW(vtw))) {
  1794. vtw->term.tpd->cursorRow++ ;
  1795. }
  1796. }
  1797. (void) _DtTermPrimFillScreenGap(w);
  1798. if (vtw->term.tpd->autoLineFeed )
  1799. _DtTermPrimParseCR(w);
  1800. }
  1801. void
  1802. _DtTermSoftReset /* DECSTR ESC!p */
  1803. (
  1804. Widget w
  1805. )
  1806. {
  1807. Debug('P', fprintf(stderr,">>In func _DtTermSoftReset\n")) ;
  1808. _DtTermFuncSoftReset(w,0 ,fromParser) ;
  1809. }
  1810. void
  1811. _DtTermParseBackspace /* Ctrl-H */
  1812. (
  1813. Widget w
  1814. )
  1815. {
  1816. DtTermWidget vtw = (DtTermWidget) w;
  1817. int row,col,fcol,cnt ;
  1818. Debug('P', fprintf(stderr,">>In func _DtTermParseBackspace\n")) ;
  1819. fcol = FIRSTCOLUMN(vtw) ;
  1820. row = vtw->term.tpd->cursorRow;
  1821. col = vtw->term.tpd->cursorColumn;
  1822. (void) col--;
  1823. if (col<fcol) {
  1824. if (vtw->vt.td->reverseWrapMode) {
  1825. if ( --row < TOPROW(vtw)) row = BOTTOMROW(vtw);
  1826. if (vtw->vt.td->originMode && row < TOPMARGIN(vtw))
  1827. row =BOTTOMMARGIN(vtw);
  1828. col = LASTCOLUMN(vtw) ;
  1829. }
  1830. else {
  1831. col=fcol;
  1832. }
  1833. }
  1834. vtw->term.tpd->cursorRow = row;
  1835. vtw->term.tpd->cursorColumn = col;
  1836. }
  1837. static void
  1838. GetWindowOffsets
  1839. (
  1840. Widget w,
  1841. int *xOffset,
  1842. int *yOffset,
  1843. int *widthOffset,
  1844. int *heightOffset
  1845. )
  1846. {
  1847. Display *display;
  1848. Window parentReturn;
  1849. Window *childrenReturn;
  1850. unsigned int nChildrenReturn;
  1851. Window rootWindow;
  1852. Window topWindow;
  1853. Window childReturn;
  1854. int destXReturn;
  1855. int destYReturn;
  1856. unsigned int widthReturn;
  1857. unsigned int heightReturn;
  1858. unsigned int topWidthReturn;
  1859. unsigned int topHeightReturn;
  1860. unsigned int borderWidthReturn;
  1861. unsigned int depthReturn;
  1862. *xOffset = 0;
  1863. *yOffset = 0;
  1864. *widthOffset = 0;
  1865. *heightOffset = 0;
  1866. if (XmIsMotifWMRunning(w)) {
  1867. /* get the window we want to figure the offsets for... */
  1868. topWindow = XtWindow(w);
  1869. /* and the display involved... */
  1870. display = XtDisplay(w);
  1871. (void) XQueryTree(display, topWindow, &rootWindow, &parentReturn,
  1872. &childrenReturn, &nChildrenReturn);
  1873. (void) XFree(childrenReturn);
  1874. /* walk up the tree until the parent window is root... */
  1875. while (parentReturn != rootWindow) {
  1876. topWindow = parentReturn;
  1877. (void) XQueryTree(display, topWindow, &rootWindow,
  1878. &parentReturn, &childrenReturn, &nChildrenReturn);
  1879. (void) XFree(childrenReturn);
  1880. }
  1881. /* we now know what our top window is. translate our upper
  1882. * left corner relative to its upper left corner...
  1883. */
  1884. (void) XTranslateCoordinates(display, XtWindow(w), topWindow,
  1885. 0, 0, &destXReturn, &destYReturn, &childReturn);
  1886. *xOffset = destXReturn;
  1887. *yOffset = destYReturn;
  1888. /* now that we know the top window, we can figure out the size
  1889. * difference between the two windows...
  1890. */
  1891. (void) XGetGeometry(display, topWindow, &rootWindow,
  1892. &destXReturn, &destYReturn, &topWidthReturn,
  1893. &topHeightReturn, &borderWidthReturn, &depthReturn);
  1894. (void) XGetGeometry(display, XtWindow(w), &rootWindow,
  1895. &destXReturn, &destYReturn, &widthReturn, &heightReturn,
  1896. &borderWidthReturn, &depthReturn);
  1897. *widthOffset = topWidthReturn - widthReturn;
  1898. *heightOffset = topHeightReturn - heightReturn;
  1899. }
  1900. }
  1901. void
  1902. _DtTermParseSunMisc /* Misc sun esc seqs */
  1903. (
  1904. Widget w
  1905. )
  1906. {
  1907. ParserContext context ;
  1908. DtTermWidget vtw = (DtTermWidget) w;
  1909. Display *display = XtDisplay(w);
  1910. int i, scr_num = XScreenNumberOfScreen(XtScreen(w));
  1911. Window sh_win;
  1912. Widget sw;
  1913. XWindowChanges values;
  1914. Arg arg[5];
  1915. char buf[BUFSIZ];
  1916. Position x,y;
  1917. short rows,columns;
  1918. Dimension height,width;
  1919. char *fmt,*s,*title,*icon;
  1920. int xOffset;
  1921. int yOffset;
  1922. int widthOffset;
  1923. int heightOffset;
  1924. context = GetParserContext(w) ;
  1925. STORELASTARG(context) ;
  1926. for (sw = w; !XtIsShell(sw); sw = XtParent(sw));
  1927. sh_win = XtWindow(sw) ;
  1928. switch (context->parms[1])
  1929. {
  1930. case 1:
  1931. XMapWindow(display,sh_win);
  1932. break;
  1933. case 2:
  1934. XIconifyWindow(display,sh_win,scr_num);
  1935. break;
  1936. case 3:
  1937. (void) GetWindowOffsets(sw, &xOffset, &yOffset, &widthOffset,
  1938. &heightOffset);
  1939. /* DKS
  1940. (void) XMoveWindow(display, sh_win,
  1941. context->parms[2] + xOffset, context->parms[3] + yOffset);
  1942. DKS */
  1943. (void) XtVaSetValues(sw, XmNx, context->parms[2] + xOffset,
  1944. XmNy, context->parms[3] + yOffset, NULL);
  1945. break ;
  1946. case 4:
  1947. (void) GetWindowOffsets(sw, &xOffset, &yOffset, &widthOffset,
  1948. &heightOffset);
  1949. (void) XtVaSetValues(sw, XmNwidth, context->parms[3] - widthOffset,
  1950. XmNheight,context->parms[2] - heightOffset, NULL);
  1951. break ;
  1952. case 5:
  1953. XRaiseWindow(display,sh_win);
  1954. break ;
  1955. case 6:
  1956. XLowerWindow(display,sh_win);
  1957. break ;
  1958. case 7:
  1959. _DtTermPrimFuncRedrawDisplay(w, 1, fromParser);
  1960. break ;
  1961. case 8:
  1962. rows = context->parms[2];
  1963. columns = context->parms[3];
  1964. (void) XtVaSetValues(w, DtNrows, rows, DtNcolumns, columns, NULL);
  1965. break ;
  1966. case 11:
  1967. if (vtw->term.tpd->windowMapped)
  1968. sendEscSequence(w,"\033[1t") ;
  1969. else
  1970. sendEscSequence(w,"\033[2t") ;
  1971. break ;
  1972. case 13:
  1973. (void) GetWindowOffsets(sw, &xOffset, &yOffset, &widthOffset,
  1974. &heightOffset);
  1975. (void) XtVaGetValues(sw, XtNx, &x, XtNy, &y, NULL);
  1976. (void) sprintf(buf, "\033[3;%d;%dt", x - xOffset, y - yOffset);
  1977. (void) sendEscSequence(w, buf);
  1978. break;
  1979. case 14:
  1980. (void) GetWindowOffsets(sw, &xOffset, &yOffset, &widthOffset,
  1981. &heightOffset);
  1982. (void) XtVaGetValues(sw, XtNheight, &height, XtNwidth, &width, NULL);
  1983. (void) sprintf(buf,"\033[4;%d;%dt", height + heightOffset,
  1984. width + widthOffset);
  1985. (void) sendEscSequence(w, buf);
  1986. break;
  1987. case 18:
  1988. (void) XtVaGetValues(w, DtNrows, &rows, DtNcolumns, &columns, NULL);
  1989. (void) sprintf(buf, "\033[8;%hd;%hdt", rows, columns);
  1990. (void) sendEscSequence(w, buf);
  1991. break;
  1992. case 20:
  1993. XtVaGetValues(sw,XmNiconName, &icon, NULL);
  1994. fmt = "\033]L%s\033\\";
  1995. if (strlen(icon) + strlen(fmt) + 1 >= sizeof(buf))
  1996. s = XtMalloc(strlen(icon) + strlen(fmt) + 1);
  1997. else
  1998. s = buf;
  1999. sprintf(s, fmt, icon);
  2000. sendEscSequence(w,s) ;
  2001. if (s != buf) XtFree(s);
  2002. break ;
  2003. case 21:
  2004. XtVaGetValues(sw,XmNtitle, &title, NULL);
  2005. fmt = "\033]l%s\033\\";
  2006. if (strlen(title) + strlen(fmt) + 1 >= sizeof(buf))
  2007. s = XtMalloc(strlen(title) + strlen(fmt) + 1);
  2008. else
  2009. s = buf;
  2010. sprintf(s, fmt, title);
  2011. sendEscSequence(w,s) ;
  2012. if (s != buf) XtFree(s);
  2013. break ;
  2014. }
  2015. }
  2016. void
  2017. _DtTermParserSunWindowIcon( Widget w) /* sun set icon label */
  2018. {
  2019. ParserContext context ;
  2020. Widget sw;
  2021. context = GetParserContext(w) ;
  2022. for (sw = w; !XtIsShell(sw); sw = XtParent(sw));
  2023. XtVaSetValues(sw, XmNiconName, context->stringParms[0].str, NULL) ;
  2024. }
  2025. void
  2026. _DtTermParserSunWindowTitle /* Sun set title name */
  2027. (
  2028. Widget w
  2029. )
  2030. {
  2031. ParserContext context ;
  2032. Widget sw;
  2033. context = GetParserContext(w) ;
  2034. for (sw = w; !XtIsShell(sw); sw = XtParent(sw));
  2035. XtVaSetValues(sw,XmNtitle, context->stringParms[0].str, NULL) ;
  2036. }
  2037. void
  2038. _DtTermParserSunIconFile(Widget w) /* Sun set icon to pixmap in file */
  2039. {
  2040. ParserContext context ;
  2041. int fg, bg;
  2042. Widget sw;
  2043. Pixmap icon;
  2044. context = GetParserContext(w) ;
  2045. for (sw = w; !XtIsShell(sw); sw = XtParent(sw));
  2046. XtVaGetValues(sw, XtNforeground, &fg, XtNbackground, &bg, NULL);
  2047. icon = XmGetPixmap(XtScreen(sw),(char *)context->stringParms[0].str,fg,bg);
  2048. if (icon != XmUNSPECIFIED_PIXMAP)
  2049. XtVaSetValues(sw, XmNiconPixmap, icon, NULL);
  2050. }