Term.c 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057
  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. extern char _DtTermPullInTermWhatString[];
  33. static char *termWhatString = _DtTermPullInTermWhatString;
  34. #include "TermHeader.h"
  35. #include "TermPrimDebug.h"
  36. #include "TermP.h"
  37. #include "TermPrimAction.h"
  38. #include "TermData.h"
  39. #include "TermBufferP.h"
  40. #include "TermAction.h"
  41. #include "TermParseTable.h"
  42. #include "TermPrimLineFontP.h"
  43. #include "TermLineData.h"
  44. #include "TermColor.h"
  45. #include "TermFunctionKey.h"
  46. #include "TermPrimRenderLineDraw.h"
  47. #include "TermPrimMessageCatI.h"
  48. #include "TermPrimSelectP.h"
  49. static int TextInsertProc(Widget w, unsigned char *buffer, int length);
  50. static void Resize(Widget w);
  51. static void ClassInitialize(void);
  52. static void ClassPartInitialize(WidgetClass wc);
  53. static void Initialize(Widget rw, Widget nw, Arg *args, Cardinal *num_args);
  54. static Boolean SetValues(Widget cw, Widget rw, Widget nw, ArgList args,
  55. Cardinal *num_args);
  56. static void Realize(Widget w, XtValueMask *p_valueMask,
  57. XSetWindowAttributes *attributes);
  58. static void Destroy(Widget w);
  59. static void InitializeVerticalScrollBar(Widget w, Boolean initCallbacks);
  60. static void VerticalScrollBarCallback(Widget w, XtPointer client_data,
  61. XtPointer call_data);
  62. static void StatusChangeNotify(Widget w, unsigned long mask);
  63. static void PositionUpdate(Widget w, short row, short column);
  64. static void GetAutoWrap(
  65. Widget wid,
  66. int offset,
  67. XtArgVal *value) ;
  68. static XmImportOperator SetAutoWrap(
  69. Widget wid,
  70. int offset,
  71. XtArgVal *value) ;
  72. static void GetReverseWrap(
  73. Widget wid,
  74. int offset,
  75. XtArgVal *value) ;
  76. static XmImportOperator SetReverseWrap(
  77. Widget wid,
  78. int offset,
  79. XtArgVal *value) ;
  80. static void GetAppCursorMode(
  81. Widget wid,
  82. int offset,
  83. XtArgVal *value );
  84. static XmImportOperator SetAppCursorMode(
  85. Widget wid,
  86. int offset,
  87. XtArgVal *value );
  88. static void GetAppKeypadMode(
  89. Widget wid,
  90. int offset,
  91. XtArgVal *value );
  92. static XmImportOperator SetAppKeypadMode(
  93. Widget wid,
  94. int offset,
  95. XtArgVal *value );
  96. /* action list for class: Term... */
  97. static XtActionsRec actionsList[] = {
  98. {"beginning-of-buffer", _DtTermActionBeginningOfBuffer},
  99. {"vt-break", _DtTermActionBreak},
  100. {"end-of-buffer", _DtTermActionEndOfBuffer},
  101. {"vt-function-key-execute", _DtTermActionFunctionKeyExecute},
  102. {"hard-reset", _DtTermActionHardReset},
  103. {"insert-line", _DtTermActionInsertLine},
  104. {"keypad-key-execute", _DtTermActionKeypadKeyExecute},
  105. {"move-cursor", _DtTermActionMoveCursor},
  106. {"scroll", _DtTermActionScroll},
  107. {"soft-reset", _DtTermActionSoftReset},
  108. {"tab", _DtTermActionTab},
  109. {"vt-edit-key", _DtTermActionEditKeyExecute},
  110. {"process-press", _DtTermPrimSelect2ButtonMouse},
  111. };
  112. /* the resource list for Term... */
  113. static XtResource resources[] =
  114. {
  115. {
  116. DtNsunFunctionKeys, DtCSunFunctionKeys, XmRBoolean, sizeof(Boolean),
  117. XtOffsetOf(struct _DtTermRec, vt.sunFunctionKeys),
  118. XtRImmediate, (XtPointer) False
  119. },
  120. {
  121. DtNautoWrap, DtCAutoWrap, XmRBoolean, sizeof(Boolean),
  122. XtOffsetOf(struct _DtTermRec, vt.autoWrap),
  123. XtRImmediate, (XtPointer) True
  124. },
  125. {
  126. DtNreverseWrap, DtCReverseWrap, XmRBoolean, sizeof(Boolean),
  127. XtOffsetOf(struct _DtTermRec, vt.reverseWrap),
  128. XtRImmediate, (XtPointer) False
  129. },
  130. {
  131. DtNemulationId, DtCEmulationId, XmRString, sizeof(char *),
  132. XtOffsetOf( struct _DtTermPrimitiveRec, term.emulationId),
  133. XtRImmediate, (XtPointer) "DtTermWidget"
  134. },
  135. {
  136. DtNtermId, DtCTermId, XmRString, sizeof(char *),
  137. XtOffsetOf( struct _DtTermPrimitiveRec, term.termId),
  138. XtRImmediate, (XtPointer) "vt220"
  139. },
  140. {
  141. DtNtermName, DtCTermName, XmRString, sizeof(char *),
  142. XtOffsetOf( struct _DtTermPrimitiveRec, term.termName),
  143. XtRImmediate, (XtPointer) "dtterm"
  144. },
  145. {
  146. DtNc132, DtCC132, XmRBoolean, sizeof(Boolean),
  147. XtOffsetOf(struct _DtTermRec, vt.c132),
  148. XtRImmediate, (XtPointer) False
  149. },
  150. {
  151. DtNappCursorDefault, DtCAppCursorDefault, XmRBoolean, sizeof(Boolean),
  152. XtOffsetOf(struct _DtTermRec, vt.appCursorMode),
  153. XtRImmediate, (XtPointer) False
  154. },
  155. {
  156. DtNappKeypadDefault, DtCAppKeypadDefault, XmRBoolean, sizeof(Boolean),
  157. XtOffsetOf(struct _DtTermRec, vt.appKeypadMode),
  158. XtRImmediate, (XtPointer) False
  159. },
  160. #ifdef DKS
  161. {
  162. DtNstickyPrevCursor, DtCStickyCursor, XmRBoolean,
  163. sizeof(Boolean),
  164. XtOffsetOf(struct _DtTermRec, vt.stickyPrevCursor),
  165. XtRImmediate, (XtPointer) False
  166. },
  167. {
  168. DtNstickyNextCursor, DtCStickyCursor, XmRBoolean,
  169. sizeof(Boolean),
  170. XtOffsetOf(struct _DtTermRec, vt.stickyNextCursor),
  171. XtRImmediate, (XtPointer) False
  172. },
  173. {
  174. DtNstatusChangeCallback, DtCCallback, XmRCallback,
  175. sizeof(XtCallbackList),
  176. XtOffsetOf( struct _DtTermRec, vt.statusChangeCallback),
  177. XmRPointer, (XtPointer) NULL
  178. },
  179. {
  180. DtNverticalScrollBar, DtCVerticalScrollBar, XmRWidget, sizeof(Widget),
  181. XtOffsetOf( struct _DtTermRec, vt.verticalScrollBar),
  182. XmRImmediate, (XtPointer) NULL
  183. },
  184. #endif /* DKS */
  185. };
  186. /****************
  187. *
  188. * Synthetic resources for those ugly wart variables...
  189. *
  190. ****************/
  191. static XmSyntheticResource GetResources[] =
  192. {
  193. { DtNautoWrap,
  194. sizeof (Boolean),
  195. XtOffsetOf(struct _DtTermRec, vt.autoWrap),
  196. GetAutoWrap,
  197. SetAutoWrap },
  198. { DtNreverseWrap,
  199. sizeof (Boolean),
  200. XtOffsetOf(struct _DtTermRec, vt.reverseWrap),
  201. GetReverseWrap,
  202. SetReverseWrap },
  203. { DtNappCursorDefault,
  204. sizeof (Boolean),
  205. XtOffsetOf(struct _DtTermRec, vt.appCursorMode),
  206. GetAppCursorMode,
  207. SetAppCursorMode },
  208. { DtNappKeypadDefault,
  209. sizeof (Boolean),
  210. XtOffsetOf(struct _DtTermRec, vt.appKeypadMode),
  211. GetAppKeypadMode,
  212. SetAppKeypadMode },
  213. };
  214. /*
  215. * Goofy debug'ed code by HP.
  216. * IBM's JP kbd accepts Shift+KP_Multiply as a valid key sequence.
  217. * I don't know why HP added non-exposed(internal) Xt's action ???
  218. * Anyway, remove KP_Multiply entry from defaultTranslations[]
  219. */
  220. static char defaultTranslations[] = "\
  221. :<Key>osfCancel: process-cancel()\n\
  222. :<Key>osfCopy: copy-clipboard()\n\
  223. :<Key>osfCut: copy-clipboard()\n\
  224. :<Key>osfPaste: paste-clipboard()\n\
  225. :<Key>osfBeginLine: beginning-of-buffer()\n\
  226. <Key>Home: beginning-of-buffer()\n\
  227. :<Key>osfEndLine: end-of-buffer()\n\
  228. <Key>End: end-of-buffer()\n\
  229. Shift<Key>osfUp: scroll(1,line)\n\
  230. Shift<Key>Up: scroll(1,line)\n\
  231. Shift<Key>osfDown: scroll(-1,line)\n\
  232. Shift<Key>Down: scroll(-1,line)\n\
  233. :<Key>osfUp: move-cursor(up)\n\
  234. <Key>Up: move-cursor(up)\n\
  235. :<Key>osfDown: move-cursor(down)\n\
  236. <Key>Down: move-cursor(down)\n\
  237. :<Key>osfLeft: move-cursor(backward)\n\
  238. <Key>Left: move-cursor(backward)\n\
  239. :<Key>osfRight: move-cursor(forward)\n\
  240. <Key>Right: move-cursor(forward)\n\
  241. <Key>Find: vt-edit-key(find)\n\
  242. :<Key>osfInsert: vt-edit-key(insert)\n\
  243. <Key>Insert: vt-edit-key(insert)\n\
  244. :<Key>osfDelete: vt-edit-key(delete)\n\
  245. :<Key>Delete: vt-edit-key(delete)\n\
  246. :<Key>osfSelect: vt-edit-key(select)\n\
  247. <Key>Select: vt-edit-key(select)\n\
  248. :~Shift<Key>osfPageUp: vt-edit-key(prior)\n\
  249. ~Shift<Key>Prior: vt-edit-key(prior)\n\
  250. :~Shift<Key>osfPageDown: vt-edit-key(next)\n\
  251. ~Shift<Key>Next: vt-edit-key(next)\n\
  252. <Key>Help: vt-edit-key(help)\n\
  253. <Key>Menu: vt-edit-key(do)\n\
  254. :<Key>osfPageUp: scroll(-1,page)\n\
  255. <Key>Prior: scroll(-1,page)\n\
  256. :<Key>osfPageDown: scroll(1,page)\n\
  257. <Key>Next: scroll(1,page)\n\
  258. Mod1<Key>Break: soft-reset()\n\
  259. Shift<Key>Break: hard-reset()\n\
  260. ~Shift ~Mod1<Key>Break: vt-break(long)\n\
  261. Ctrl<Key>Cancel: stop(long)\n\
  262. ~Ctrl<Key>Cancel: stop()\n\
  263. ~Shift<Key>Tab: tab()\n\
  264. <Key>osfActivate: keypad-key-execute(enter)\n\
  265. <Key>KP_Space: keypad-key-execute(space)\n\
  266. <Key>KP_Tab: keypad-key-execute(tab)\n\
  267. <Key>KP_Enter: keypad-key-execute(enter)\n\
  268. <Key>KP_F1: keypad-key-execute(f1)\n\
  269. <Key>KP_F2: keypad-key-execute(f2)\n\
  270. <Key>KP_F3: keypad-key-execute(f3)\n\
  271. <Key>KP_F4: keypad-key-execute(f4)\n\
  272. <Key>KP_Equal: keypad-key-execute(equal)\n\
  273. <Key>KP_Multiply: keypad-key-execute(multiply)\n\
  274. <Key>KP_Add: keypad-key-execute(add)\n\
  275. <Key>KP_Separator: keypad-key-execute(separator)\n\
  276. <Key>KP_Subtract: keypad-key-execute(subtract)\n\
  277. <Key>KP_Decimal: keypad-key-execute(decimal)\n\
  278. <Key>KP_Divide: keypad-key-execute(divide)\n\
  279. !Mod1<Key>KP_0: insert()\n\
  280. !Mod1<Key>KP_1: insert()\n\
  281. !Mod1<Key>KP_2: insert()\n\
  282. !Mod1<Key>KP_3: insert()\n\
  283. !Mod1<Key>KP_4: insert()\n\
  284. !Mod1<Key>KP_5: insert()\n\
  285. !Mod1<Key>KP_6: insert()\n\
  286. !Mod1<Key>KP_7: insert()\n\
  287. !Mod1<Key>KP_8: insert()\n\
  288. !Mod1<Key>KP_9: insert()\n\
  289. <Key>KP_0: keypad-key-execute(0)\n\
  290. <Key>KP_1: keypad-key-execute(1)\n\
  291. <Key>KP_2: keypad-key-execute(2)\n\
  292. <Key>KP_3: keypad-key-execute(3)\n\
  293. <Key>KP_4: keypad-key-execute(4)\n\
  294. <Key>KP_5: keypad-key-execute(5)\n\
  295. <Key>KP_6: keypad-key-execute(6)\n\
  296. <Key>KP_7: keypad-key-execute(7)\n\
  297. <Key>KP_8: keypad-key-execute(8)\n\
  298. <Key>KP_9: keypad-key-execute(9)\n\
  299. Shift<Key>F1: vt-function-key-execute(1, UDK)\n\
  300. Shift<Key>F2: vt-function-key-execute(2, UDK)\n\
  301. Shift<Key>F3: vt-function-key-execute(3, UDK)\n\
  302. Shift<Key>F4: vt-function-key-execute(4, UDK)\n\
  303. Shift<Key>F5: vt-function-key-execute(5, UDK)\n\
  304. Shift<Key>F6: vt-function-key-execute(6, UDK)\n\
  305. Shift<Key>F7: vt-function-key-execute(7, UDK)\n\
  306. Shift<Key>F8: vt-function-key-execute(8, UDK)\n\
  307. Shift<Key>F9: vt-function-key-execute(9, UDK)\n\
  308. Shift<Key>F10: vt-function-key-execute(10, UDK)\n\
  309. Shift<Key>F11: vt-function-key-execute(11, UDK)\n\
  310. Shift<Key>F12: vt-function-key-execute(12, UDK)\n\
  311. Shift<Key>F13: vt-function-key-execute(13, UDK)\n\
  312. Shift<Key>F14: vt-function-key-execute(14, UDK)\n\
  313. Shift<Key>F15: vt-function-key-execute(15, UDK)\n\
  314. Shift<Key>F16: vt-function-key-execute(16, UDK)\n\
  315. Shift<Key>F17: vt-function-key-execute(17, UDK)\n\
  316. Shift<Key>F18: vt-function-key-execute(18, UDK)\n\
  317. Shift<Key>F19: vt-function-key-execute(19, UDK)\n\
  318. Shift<Key>F20: vt-function-key-execute(20, UDK)\n\
  319. Shift<Key>F21: vt-function-key-execute(21, UDK)\n\
  320. Shift<Key>F22: vt-function-key-execute(22, UDK)\n\
  321. Shift<Key>F23: vt-function-key-execute(23, UDK)\n\
  322. Shift<Key>F24: vt-function-key-execute(24, UDK)\n\
  323. Shift<Key>F25: vt-function-key-execute(25, UDK)\n\
  324. Shift<Key>F26: vt-function-key-execute(26, UDK)\n\
  325. Shift<Key>F27: vt-function-key-execute(27, UDK)\n\
  326. Shift<Key>F28: vt-function-key-execute(28, UDK)\n\
  327. Shift<Key>F29: vt-function-key-execute(29, UDK)\n\
  328. Shift<Key>F30: vt-function-key-execute(30, UDK)\n\
  329. Shift<Key>F31: vt-function-key-execute(31, UDK)\n\
  330. Shift<Key>F32: vt-function-key-execute(32, UDK)\n\
  331. Shift<Key>F33: vt-function-key-execute(33, UDK)\n\
  332. Shift<Key>F34: vt-function-key-execute(34, UDK)\n\
  333. Shift<Key>F35: vt-function-key-execute(35, UDK)\n\
  334. ~Shift<Key>F1: vt-function-key-execute(1, function)\n\
  335. ~Shift<Key>F2: vt-function-key-execute(2, function)\n\
  336. ~Shift<Key>F3: vt-function-key-execute(3, function)\n\
  337. ~Shift<Key>F4: vt-function-key-execute(4, function)\n\
  338. ~Shift<Key>F5: vt-function-key-execute(5, function)\n\
  339. ~Shift<Key>F6: vt-function-key-execute(6, function)\n\
  340. ~Shift<Key>F7: vt-function-key-execute(7, function)\n\
  341. ~Shift<Key>F8: vt-function-key-execute(8, function)\n\
  342. ~Shift<Key>F9: vt-function-key-execute(9, function)\n\
  343. ~Shift<Key>F10: vt-function-key-execute(10, function)\n\
  344. ~Shift<Key>F11: vt-function-key-execute(11, function)\n\
  345. ~Shift<Key>F12: vt-function-key-execute(12, function)\n\
  346. ~Shift<Key>F13: vt-function-key-execute(13, function)\n\
  347. ~Shift<Key>F14: vt-function-key-execute(14, function)\n\
  348. ~Shift<Key>F15: vt-function-key-execute(15, function)\n\
  349. ~Shift<Key>F16: vt-function-key-execute(16, function)\n\
  350. ~Shift<Key>F17: vt-function-key-execute(17, function)\n\
  351. ~Shift<Key>F18: vt-function-key-execute(18, function)\n\
  352. ~Shift<Key>F19: vt-function-key-execute(19, function)\n\
  353. ~Shift<Key>F20: vt-function-key-execute(20, function)\n\
  354. ~Shift<Key>F21: vt-function-key-execute(21, function)\n\
  355. ~Shift<Key>F22: vt-function-key-execute(22, function)\n\
  356. ~Shift<Key>F23: vt-function-key-execute(23, function)\n\
  357. ~Shift<Key>F24: vt-function-key-execute(24, function)\n\
  358. ~Shift<Key>F25: vt-function-key-execute(25, function)\n\
  359. ~Shift<Key>F26: vt-function-key-execute(26, function)\n\
  360. ~Shift<Key>F27: vt-function-key-execute(27, function)\n\
  361. ~Shift<Key>F28: vt-function-key-execute(28, function)\n\
  362. ~Shift<Key>F29: vt-function-key-execute(29, function)\n\
  363. ~Shift<Key>F30: vt-function-key-execute(30, function)\n\
  364. ~Shift<Key>F31: vt-function-key-execute(31, function)\n\
  365. ~Shift<Key>F32: vt-function-key-execute(32, function)\n\
  366. ~Shift<Key>F33: vt-function-key-execute(33, function)\n\
  367. ~Shift<Key>F34: vt-function-key-execute(34, function)\n\
  368. ~Shift<Key>F35: vt-function-key-execute(35, function)\n\
  369. <KeyRelease>: key-release()\n\
  370. <KeyPress>: insert()\n\
  371. ~Shift~Ctrl<Btn1Down>: grab-focus()\n\
  372. Shift~Ctrl<Btn1Down>: extend-start()\n\
  373. ~Ctrl<Btn1Motion>: select-adjust()\n\
  374. ~Ctrl<Btn1Up>: extend-end()\n\
  375. ~Shift<Btn2Down>: process-bdrag()\n\
  376. ~Shift<Btn2Up>: copy-to()\n\
  377. ~Shift ~Ctrl <Btn4Up>: scroll(-1,line)\n\
  378. ~Shift ~Ctrl <Btn5Up>: scroll(1,line)\n\
  379. Shift ~Ctrl <Btn4Up>: scroll(-3,line)\n\
  380. Shift ~Ctrl <Btn5Up>: scroll(3,line)\n\
  381. Ctrl ~Shift <Btn4Up>: scroll(-1,page)\n\
  382. Ctrl ~Shift <Btn5Up>: scroll(1,page)\n\
  383. <EnterWindow>: enter()\n\
  384. <LeaveWindow>: leave()\n\
  385. <FocusIn>: focus-in()\n\
  386. <FocusOut>: focus-out()\n\
  387. ";
  388. /* global class record for instances of class: Vt
  389. */
  390. externaldef(vtclassrec) DtTermClassRec dtTermClassRec =
  391. {
  392. /* core class record */
  393. {
  394. /* superclass */ (WidgetClass) &dtTermPrimitiveClassRec,
  395. /* class_name */ "DtTerm",
  396. /* widget_size */ sizeof(DtTermRec),
  397. /* class_initialize */ ClassInitialize,
  398. /* class_part_init */ ClassPartInitialize,
  399. /* class_inited */ FALSE,
  400. /* initialize */ Initialize,
  401. /* initialize_hook */ (XtArgsProc) NULL,
  402. /* realize */ XtInheritRealize,
  403. /* actions */ actionsList,
  404. /* num_actions */ XtNumber(actionsList),
  405. /* resources */ resources,
  406. /* num_resources */ XtNumber(resources),
  407. /* xrm_class */ NULLQUARK,
  408. /* compress_motion */ TRUE,
  409. /* compress_exposure */ FALSE,
  410. /* compress_enterlv */ TRUE,
  411. /* visible_interest */ TRUE,
  412. /* destroy */ Destroy,
  413. /* resize */ XtInheritResize, /* Resize */
  414. /* expose */ XtInheritExpose,
  415. /* set_values */ SetValues,
  416. /* set_values_hook */ (XtArgsFunc) NULL,
  417. /* set_values_almost */ XtInheritSetValuesAlmost,
  418. /* get_values_hook */ (XtArgsProc) NULL,
  419. /* accept_focus */ (XtAcceptFocusProc) NULL,
  420. /* version */ XtVersion,
  421. /* callback_private */ (XtPointer) NULL,
  422. /* tm_table */ defaultTranslations,
  423. /* query_geometry */ (XtGeometryHandler) NULL,
  424. /* display_accelerator */ (XtStringProc) NULL,
  425. /* extension */ (XtPointer) NULL,
  426. },
  427. /* primitive class rec */
  428. {
  429. /* Primitive border_highlight */ XmInheritWidgetProc,
  430. /* Primitive border_unhighlight */ XmInheritWidgetProc,
  431. /* translations */ "" /*NULL*/ /*XtInheritTranslations*/,
  432. /* arm_and_activate */ NULL,
  433. /* get resources */ (XmSyntheticResource *) GetResources,
  434. /* num get_resources */ XtNumber(GetResources),
  435. /* extension */ (XtPointer) NULL,
  436. },
  437. /* term class record */
  438. {
  439. /* parser_start_state */ &_DtTermStateStart,
  440. /* use_history_buffer */ True,
  441. /* allow_scroll_below_buffer */ False,
  442. /* wrap_right_after_insert */ False,
  443. /* buffer_create_proc */ _DtTermBufferCreateBuffer,
  444. /* buffer_free_proc */ _DtTermBufferFreeBuffer,
  445. /* term_insert_proc */ TextInsertProc,
  446. /* sizeOfBuffer */ (short) sizeof(DtTermBufferRec),
  447. /* sizeOfLine */ (short) sizeof(DtTermLineRec),
  448. /* sizeOfEnh */ (short) sizeof(DtTermEnhPart),
  449. },
  450. /* vt class record */
  451. {
  452. 0
  453. }
  454. };
  455. externaldef(vtwidgetclass) WidgetClass dtTermWidgetClass =
  456. (WidgetClass)&dtTermClassRec;
  457. /* Class Initialize...
  458. */
  459. static void
  460. ClassInitialize(void)
  461. {
  462. return;
  463. }
  464. static void
  465. ClassPartInitialize(WidgetClass w_class)
  466. {
  467. }
  468. /*
  469. ** Initialize the modes to their default values...
  470. */
  471. static void
  472. initializeModes
  473. (
  474. DtTermData td
  475. )
  476. {
  477. td->applicationMode = False; /* Normal mode */
  478. td->applicationKPMode= False; /* Normal mode */
  479. td->tpd->transmitFunctions = True; /* ALWAYS true for ANSI */
  480. td->originMode = False; /* true when origin mode is active */
  481. td->S8C1TMode = False; /* use 7 bit c1 codes */
  482. td->enhFieldState = FIELD_UNPROTECT; /* Vt selective erase mode */
  483. td->fixCursesMode = False; /* xterm fix curses */
  484. td->userKeysLocked = False; /* are User Defined Keys locked? */
  485. td->needToLockUserKeys = False; /* Parser state */
  486. td->saveCursor.cursorRow = 0; /* init for Save Cursor (Esc 7) */
  487. td->saveCursor.cursorColumn = 0; /* init for Save Cursor (Esc 7) */
  488. td->saveCursor.originMode = False; /* init for Save Cursor (Esc 7) */
  489. td->saveCursor.wrapMode = True; /* init for Save Cursor (Esc 7) */
  490. td->saveCursor.enhVideoState = 0; /* init for Save Cursor (Esc 7) */
  491. td->saveCursor.enhFieldState = FIELD_UNPROTECT;
  492. td->saveCursor.enhFgColorState = 0;
  493. td->saveCursor.enhBgColorState = 0; /* init for Save Cursor (Esc 7) */
  494. td->saveCursor.GL = td->GL; /* init for Save Cursor (Esc 7) */
  495. td->saveCursor.GR = td->GR; /* init for Save Cursor (Esc 7) */
  496. td->saveCursor.G0 = td->G0; /* init for Save Cursor (Esc 7) */
  497. td->saveCursor.G1 = td->G1; /* init for Save Cursor (Esc 7) */
  498. td->saveCursor.G2 = td->G2; /* init for Save Cursor (Esc 7) */
  499. td->saveCursor.G3 = td->G3; /* init for Save Cursor (Esc 7) */
  500. td->saveCursor.singleShiftFont = td->singleShiftFont;
  501. td->saveCursor.singleShiftPending = td->singleShiftPending;
  502. td->saveDECMode.allow80_132ColMode = False;
  503. td->saveDECMode.col132Mode = False;
  504. td->saveDECMode.applicationMode = False;
  505. td->saveDECMode.applicationKPMode = False;
  506. td->saveDECMode.originMode = False;
  507. td->saveDECMode.wrapMode = False;
  508. td->saveDECMode.jumpScrollMode = True;
  509. td->saveDECMode.inverseVideoMode = False;
  510. td->saveDECMode.fixCursesMode = False;
  511. td->saveDECMode.reverseWrapMode = False;
  512. td->saveDECMode.marginBellMode = False;
  513. td->saveDECMode.cursorVisible = True;
  514. td->saveDECMode.logging = False;
  515. }
  516. unsigned char
  517. _DtTermGetRenderFontIndex(Widget w, int id)
  518. {
  519. DtTermWidget tw = (DtTermWidget) w;
  520. DtTermData td = tw->vt.td;
  521. int i;
  522. /* search for the index that matches this id... */
  523. for (i = 0; i < (sizeof(td->renderFonts) / sizeof(td->renderFonts[0]));
  524. i++) {
  525. if (td->renderFonts[i].id == id) {
  526. return(i);
  527. }
  528. }
  529. /* default to base if not found... */
  530. return(0);
  531. }
  532. /*ARGSUSED*/
  533. static void
  534. Initialize(Widget ref_w, Widget w, Arg *args, Cardinal *num_args)
  535. {
  536. DtTermPrimitiveWidget tpw = (DtTermPrimitiveWidget) w;
  537. DtTermWidget tw = (DtTermWidget) w;
  538. DtTermData td;
  539. int i;
  540. Debug('T', timeStamp("Term Initialize() starting"));
  541. /* initialize...
  542. */
  543. /* malloc Vt dataspace... */
  544. tw->vt.td =
  545. (DtTermData) XtMalloc(sizeof(DtTermDataRec));
  546. td = tw->vt.td;
  547. /* clear malloc'ed memory... */
  548. (void) memset(td, '\0', sizeof(DtTermDataRec));
  549. /* stick a pointer to the DtTermPrimData struct in our DtTermData... */
  550. td->tpd = tw->term.tpd;
  551. /* set up our fonts...
  552. */
  553. for (i = 0; i < (sizeof(td->renderFonts) / sizeof(td->renderFonts[0]));
  554. i++) {
  555. td->renderFonts[i].termFont = (TermFont) 0;
  556. td->renderFonts[i].id = -1;
  557. }
  558. td->renderFonts[0].termFont = td->tpd->defaultTermFont;
  559. td->renderFonts[0].id = 'B';
  560. td->baseFontIndex = 0;
  561. /* allocate a line drawing font... */
  562. td->renderFonts[1].termFont =
  563. _DtTermPrimRenderLineDrawCreate(w, /* Widget */
  564. _DtTermGlyphs, /* glyphInfo */
  565. _DtTermNumGlyphs, /* numGlyphs */
  566. tw->term.widthInc, /* width */
  567. tw->term.ascent, /* ascent */
  568. tw->term.heightInc - tw->term.ascent);
  569. /* descent */
  570. td->renderFonts[1].id = '0';
  571. td->altFontIndex = 1;
  572. td->renderFonts[2].termFont = td->tpd->defaultBoldTermFont;
  573. td->G0 = RENDER_FONT_NORMAL;
  574. td->G1 = RENDER_FONT_LINEDRAW; /* DKS!!! change this */
  575. td->G2 = RENDER_FONT_NORMAL;
  576. td->G3 = RENDER_FONT_NORMAL;
  577. td->GL = &td->G0;
  578. td->GR = &td->G0;
  579. td->singleShiftFont = RENDER_FONT_NORMAL;
  580. td->singleShiftPending = False;
  581. _DtTermFunctionKeyInit(w);
  582. /*
  583. ** Initialize modes...
  584. */
  585. initializeModes(td);
  586. tpw->term.tpd->autoWrapRight = tw->vt.autoWrap ;
  587. tw->vt.td->reverseWrapMode = tw->vt.reverseWrap ;
  588. /* Initialize color...
  589. */
  590. (void) _DtTermColorInit(w);
  591. if ( !strcmp(tpw->term.termId,"vt100")) td->terminalId = 100 ;
  592. else if ( !strcmp(tpw->term.termId,"vt101")) td->terminalId = 101 ;
  593. else if ( !strcmp(tpw->term.termId,"vt102")) td->terminalId = 102 ;
  594. else td->terminalId = 220 ; /* vt200 */
  595. if ( td->terminalId < 200 ) td->compatLevel = 1;
  596. else td->compatLevel = 2;
  597. _DtTermPrimSelectInitBtnEvents(w) ; /* set button events */
  598. Debug('T', timeStamp("Term Initialize() finished"));
  599. return;
  600. }
  601. #ifdef DKS
  602. static void
  603. InitializeVerticalScrollBar(Widget w, Boolean initCallbacks)
  604. {
  605. DtTermWidget tw = (DtTermWidget) w;
  606. Arg arglist[20];
  607. int i;
  608. if (initCallbacks) {
  609. /* set up the scrollbar callbacks... */
  610. (void) XtAddCallback(tw->vt.verticalScrollBar, XmNdragCallback,
  611. VerticalScrollBarCallback, (XtPointer) w);
  612. (void) XtAddCallback(tw->vt.verticalScrollBar,
  613. XmNvalueChangedCallback, VerticalScrollBarCallback,
  614. (XtPointer) w);
  615. }
  616. if (!tw->vt.td) {
  617. /* no termBuffer yet, we set anything yet... */
  618. return;
  619. }
  620. /* update the scrollbar... */
  621. if (tw->vt.verticalScrollBar) {
  622. tw->vt.verticalScrollBarMaximum =
  623. (tw->term.tpd->lastUsedRow - tw->term.tpd->memoryLockRow) +
  624. (tw->term.tpd->term.rows - tw->term.tpd->memoryLockRow);
  625. tw->vt.verticalScrollBarSliderSize =
  626. tw->term.rows - tw->term.tpd->memoryLockRow;
  627. tw->vt.verticalScrollBarPageIncrement =
  628. tw->term.rows - tw->term.tpd->memoryLockRow;
  629. tw->vt.verticalScrollBarValue = tw->term.tpd->topRow;
  630. i = 0;
  631. (void) XtSetArg(arglist[i], XmNincrement, 1); i++;
  632. (void) XtSetArg(arglist[i], XmNminimum, 0); i++;
  633. (void) XtSetArg(arglist[i], XmNmaximum,
  634. tw->term.verticalScrollBarMaximum); i++;
  635. (void) XtSetArg(arglist[i], XmNpageIncrement,
  636. tw->term.verticalScrollBarPageIncrement); i++;
  637. (void) XtSetArg(arglist[i], XmNsliderSize,
  638. tw->term.verticalScrollBarSliderSize); i++;
  639. (void) XtSetArg(arglist[i], XmNvalue, tw->term.verticalScrollBarValue);
  640. i++;
  641. (void) XtSetValues(tw->term.verticalScrollBar, arglist, i);
  642. }
  643. }
  644. #endif /* DKS */
  645. static void
  646. Resize(Widget w)
  647. {
  648. DtTermWidget tw = (DtTermWidget) w;
  649. /* let our superclass (the Term Widget) perform the resize... */
  650. tw->core.widget_class->core_class.superclass->core_class.resize(w);
  651. #ifdef DKS
  652. /* and update the scrollbar... */
  653. (void) InitializeVerticalScrollBar(w, False);
  654. #endif /* DKS */
  655. }
  656. /***************************************************************************
  657. * *
  658. * Import and Export functions for those resources that can't really be *
  659. * accessed through the widget DS. *
  660. * *
  661. ***************************************************************************/
  662. /* ARGSUSED */
  663. static void
  664. GetAutoWrap(
  665. Widget wid,
  666. int offset,
  667. XtArgVal *value )
  668. {
  669. DtTermWidget tw = (DtTermWidget) wid ;
  670. (*value) = (XtArgVal) tw->term.tpd->autoWrapRight;
  671. }
  672. /* ARGSUSED */
  673. static XmImportOperator
  674. SetAutoWrap(
  675. Widget wid,
  676. int offset,
  677. XtArgVal *value )
  678. {
  679. DtTermWidget tw = (DtTermWidget) wid ;
  680. tw->term.tpd->autoWrapRight = (* (int *) value);
  681. /* return (XmSYNTHETIC_LOAD);*/
  682. return (XmSYNTHETIC_NONE);
  683. }
  684. /* ARGSUSED */
  685. static void
  686. GetReverseWrap(
  687. Widget wid,
  688. int offset,
  689. XtArgVal *value )
  690. {
  691. DtTermWidget tw = (DtTermWidget) wid ;
  692. (*value) = (XtArgVal) tw->vt.td->reverseWrapMode;;
  693. }
  694. /* ARGSUSED */
  695. static XmImportOperator
  696. SetReverseWrap(
  697. Widget wid,
  698. int offset,
  699. XtArgVal *value )
  700. {
  701. DtTermWidget tw = (DtTermWidget) wid ;
  702. tw->vt.td->reverseWrapMode = (* (int *) value);
  703. /* return (XmSYNTHETIC_LOAD);*/
  704. return (XmSYNTHETIC_NONE);
  705. }
  706. /* ARGSUSED */
  707. static void
  708. GetAppCursorMode(
  709. Widget wid,
  710. int offset,
  711. XtArgVal *value )
  712. {
  713. DtTermWidget tw = (DtTermWidget) wid ;
  714. (*value) = (XtArgVal) tw->vt.td->applicationMode;;
  715. }
  716. /* ARGSUSED */
  717. static XmImportOperator
  718. SetAppCursorMode(
  719. Widget wid,
  720. int offset,
  721. XtArgVal *value )
  722. {
  723. DtTermWidget tw = (DtTermWidget) wid ;
  724. tw->vt.td->applicationMode = (* (int *) value);
  725. return (XmSYNTHETIC_NONE);
  726. }
  727. /* ARGSUSED */
  728. static void
  729. GetAppKeypadMode(
  730. Widget wid,
  731. int offset,
  732. XtArgVal *value )
  733. {
  734. DtTermWidget tw = (DtTermWidget) wid ;
  735. (*value) = (XtArgVal) tw->vt.td->applicationKPMode;;
  736. }
  737. /* ARGSUSED */
  738. static XmImportOperator
  739. SetAppKeypadMode(
  740. Widget wid,
  741. int offset,
  742. XtArgVal *value )
  743. {
  744. DtTermWidget tw = (DtTermWidget) wid ;
  745. tw->vt.td->applicationKPMode = (* (int *) value);
  746. return (XmSYNTHETIC_NONE);
  747. }
  748. /* SetValues...
  749. */
  750. /*ARGSUSED*/
  751. static Boolean
  752. SetValues(Widget cur_w, Widget ref_w, Widget w, ArgList args,
  753. Cardinal *num_args)
  754. {
  755. DtTermWidget cur_tw = (DtTermWidget) cur_w;
  756. DtTermWidget tw = (DtTermWidget) w;
  757. Boolean flag = False; /* return value... */
  758. #ifdef DKS
  759. /* DKS: this needs to be done later...
  760. */
  761. if (cur_tw->vt.verticalScrollBar != tw->vt.verticalScrollBar) {
  762. if (tw->vt.verticalScrollBar) {
  763. /* set up the scrollbar values and callbacks... */
  764. (void) InitializeVerticalScrollBar(w, True);
  765. }
  766. }
  767. #endif /* DKS */
  768. if (tw->term.fontList != cur_tw->term.fontList) {
  769. /* the font has been changed... */
  770. XmFontList fontList;
  771. XFontSet fontSet;
  772. XFontStruct *font;
  773. /* replace the base font...
  774. */
  775. tw->vt.td->renderFonts[0].termFont = tw->term.tpd->termFont;
  776. /* replace the linedraw font...
  777. */
  778. /* release the old font... */
  779. (void) _DtTermPrimDestroyFont(w, tw->vt.td->renderFonts[1].termFont);
  780. /* replace the font... */
  781. tw->vt.td->renderFonts[1].termFont =
  782. _DtTermPrimRenderLineDrawCreate(w,
  783. _DtTermGlyphs,
  784. _DtTermNumGlyphs,
  785. tw->term.widthInc,
  786. tw->term.ascent,
  787. tw->term.heightInc - tw->term.ascent);
  788. /* replace the bold font. If the base font is the default, then
  789. * use the default bold font that we generated. Else, null it out
  790. * and we will fake by overstriking...
  791. */
  792. if (tw->vt.td->renderFonts[0].termFont ==
  793. tw->vt.td->tpd->defaultTermFont) {
  794. tw->vt.td->renderFonts[2].termFont =
  795. tw->vt.td->tpd->defaultBoldTermFont;
  796. } else {
  797. tw->vt.td->renderFonts[2].termFont = (TermFont) 0;
  798. }
  799. flag = True;
  800. }
  801. return(flag);
  802. }
  803. /* Destroy...
  804. */
  805. static void
  806. Destroy(Widget w)
  807. {
  808. DtTermWidget tw = (DtTermWidget) w;
  809. /* remove the DtTermData structure contents, followed by the structure...
  810. */
  811. if (tw->vt.td) {
  812. /* free up any fonts we allocated for this widget... */
  813. /* don't free the others because they're done in TermPrim Destroy()*/
  814. (void) _DtTermPrimDestroyFont(w, tw->vt.td->renderFonts[1].termFont);
  815. /* free up any color cells that we allocated for this widget... */
  816. (void) _DtTermColorDestroy(w);
  817. /* free up our function key related resources... */
  818. (void) _DtTermFunctionKeyClear(w);
  819. /*
  820. ** free up the block mode stuff...
  821. _vtBlockModeDestroy(td->blockModeInfo);
  822. td->blockModeInfo = (BlockModeInfo) 0;
  823. */
  824. /* free up the DtTermData structure... */
  825. (void) XtFree((char *) tw->vt.td);
  826. tw->vt.td = (DtTermData) 0;
  827. }
  828. }
  829. #ifdef DKS
  830. static void
  831. StatusChangeNotify(Widget w, unsigned long mask)
  832. {
  833. DtTermWidget tw = (DtTermWidget) w;
  834. struct termData *tpd = tw->term.tpd;
  835. struct vtData *td = tw->vt.td;
  836. TermVtCallbackStruct cb;
  837. if (!tw->vt.statusChangeCallback) {
  838. /* no callback, nothing to do... */
  839. return;
  840. }
  841. /*****************************************************************
  842. * Caps Lock
  843. */
  844. if (mask & TermSTATUS_CHANGE_NOTIFY_CAPS_LOCK) {
  845. (void) memset(&cb, '\0', sizeof(cb));
  846. cb.reason = DtTermCR_CAPS_LOCK_CHANGE;
  847. cb.capsLock = tpd->capsLock;
  848. (void) XtCallCallbackList(w,
  849. tw->vt.statusChangeCallback, (XtPointer) &cb);
  850. }
  851. /*****************************************************************
  852. * Insert Char Mode
  853. */
  854. if (mask & TermSTATUS_CHANGE_NOTIFY_INSERT_MODE) {
  855. (void) memset(&cb, '\0', sizeof(cb));
  856. cb.reason = DtTermCR_INSERT_MODE_CHANGE;
  857. cb.insertCharMode = tpd->insertCharMode;
  858. (void) XtCallCallbackList(w,
  859. tw->vt.statusChangeCallback, (XtPointer) &cb);
  860. }
  861. /*****************************************************************
  862. * Stop
  863. */
  864. if (mask & TermSTATUS_CHANGE_NOTIFY_STOP) {
  865. (void) memset(&cb, '\0', sizeof(cb));
  866. cb.reason = DtTermCR_STOP_CHANGE;
  867. cb.stop = tpd->stop;
  868. (void) XtCallCallbackList(w,
  869. tw->vt.statusChangeCallback, (XtPointer) &cb);
  870. }
  871. }
  872. static void PositionUpdate(Widget w, short row, short column)
  873. {
  874. DtTermWidget tw = (DtTermWidget) w;
  875. struct termData *tpd = tw->term.tpd;
  876. struct vtData *td = tw->vt.td;
  877. TermVtCallbackStruct cb;
  878. if (!tw->vt.statusChangeCallback) {
  879. /* no callback, nothing to do... */
  880. return;
  881. }
  882. cb.reason = DtTermCR_CURSOR_MOTION;
  883. cb.cursorColumn = tpd->cursorColumn;
  884. cb.cursorRow = tpd->cursorRow = tpd->topRow;
  885. (void) XtCallCallbackList(w,
  886. tw->vt.statusChangeCallback, (XtPointer) &cb);
  887. }
  888. #endif /* DKS */
  889. Widget
  890. DtCreateTerm(Widget parent, char *name, ArgList arglist, Cardinal argcount)
  891. {
  892. Widget w;
  893. _DtTermWidgetToAppContext(parent);
  894. _DtTermAppLock(app);
  895. Debug('T', timeStamp("DtCreateTerm() starting"));
  896. w = XtCreateWidget(name, dtTermWidgetClass, parent, arglist, argcount);
  897. Debug('T', timeStamp("DtCreateTerm() finished"));
  898. _DtTermAppUnlock(app);
  899. return(w);
  900. }
  901. #ifdef DKS
  902. static void VerticalScrollBarCallback(Widget wid, XtPointer client_data,
  903. XtPointer call_data)
  904. {
  905. DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) client_data;
  906. struct termData *tpd = tw->term.tpd;
  907. XmScrollBarCallbackStruct *cb = (XmScrollBarCallbackStruct *) call_data;
  908. (void) _DtTermPrimScrollTextTo((Widget) tw, cb->value);
  909. /* we need to complete the scroll or it won't happen... */
  910. (void) _DtTermPrimScrollComplete((Widget) tw, True);
  911. if (cb->reason != XmCR_DRAG) {
  912. _DtTermPrimCursorOn((Widget) tw);
  913. }
  914. }
  915. #endif /* DKS */
  916. static int
  917. TextInsertProc
  918. (
  919. Widget w,
  920. unsigned char *buffer,
  921. int length
  922. )
  923. {
  924. DtTermWidget tw = (DtTermWidget) w;
  925. DtTermPrimData tpd = tw->term.tpd;
  926. DtTermData td = tw->vt.td;
  927. int partialLen = 0;
  928. int holdFont;
  929. if (td->singleShiftPending) {
  930. /* save away the active GL font... */
  931. holdFont = *td->GL;
  932. /* make it the single shift font... */
  933. *td->GL = td->singleShiftFont;
  934. (void) _DtTermPrimBufferSetEnhancement(tpd->termBuffer,
  935. tpd->topRow + tpd->cursorRow, tpd->cursorColumn,
  936. enhFont, *td->GL);
  937. /* insert the first character... */
  938. partialLen = _DtTermPrimInsertText(w, buffer, 1);
  939. /* restore the active GL font... */
  940. *td->GL = holdFont;
  941. (void) _DtTermPrimBufferSetEnhancement(tpd->termBuffer,
  942. tpd->topRow + tpd->cursorRow, tpd->cursorColumn,
  943. enhFont, *td->GL);
  944. if (partialLen == 1) {
  945. /* successful insert...
  946. */
  947. /* clear the pending flag... */
  948. td->singleShiftPending = False;
  949. /* skip over the character... */
  950. (void) buffer++;
  951. (void) length--;
  952. } else {
  953. return(partialLen);
  954. }
  955. }
  956. if (length > 0) {
  957. partialLen += _DtTermPrimInsertText(w, buffer, length);
  958. }
  959. return(partialLen);
  960. }