hu_lib.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
  1. /* Emacs style mode select -*- C++ -*-
  2. *-----------------------------------------------------------------------------
  3. *
  4. *
  5. * PrBoom: a Doom port merged with LxDoom and LSDLDoom
  6. * based on BOOM, a modified and improved DOOM engine
  7. * Copyright (C) 1999 by
  8. * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
  9. * Copyright (C) 1999-2000 by
  10. * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
  11. * Copyright 2005, 2006 by
  12. * Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License
  16. * as published by the Free Software Foundation; either version 2
  17. * of the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  27. * 02111-1307, USA.
  28. *
  29. * DESCRIPTION: heads-up text and input code
  30. *
  31. *-----------------------------------------------------------------------------
  32. */
  33. #include "doomdef.h"
  34. #include "doomstat.h"
  35. #include "v_video.h"
  36. #include "m_swap.h"
  37. #include "hu_lib.h"
  38. #include "hu_stuff.h"
  39. #include "r_main.h"
  40. #include "r_draw.h"
  41. // boolean : whether the screen is always erased
  42. #define noterased viewwindowx
  43. extern int key_backspace; // phares
  44. extern int key_enter; // phares
  45. ////////////////////////////////////////////////////////
  46. //
  47. // Basic text line widget
  48. //
  49. ////////////////////////////////////////////////////////
  50. //
  51. // HUlib_clearTextLine()
  52. //
  53. // Blank the internal text line in a hu_textline_t widget
  54. //
  55. // Passed a hu_textline_t, returns nothing
  56. //
  57. void HUlib_clearTextLine(hu_textline_t* t)
  58. {
  59. t->linelen = // killough 1/23 98: support multiple lines
  60. t->len = 0;
  61. t->l[0] = 0;
  62. t->needsupdate = true;
  63. }
  64. //
  65. // HUlib_initTextLine()
  66. //
  67. // Initialize a hu_textline_t widget. Set the position, font, start char
  68. // of the font, and color range to be used.
  69. //
  70. // Passed a hu_textline_t, and the values used to initialize
  71. // Returns nothing
  72. //
  73. void HUlib_initTextLine(hu_textline_t* t, int x, int y,
  74. const patchnum_t* f, int sc, int cm )
  75. //jff 2/16/98 add color range parameter
  76. {
  77. t->x = x;
  78. t->y = y;
  79. t->f = f;
  80. t->sc = sc;
  81. t->cm = cm;
  82. HUlib_clearTextLine(t);
  83. }
  84. //
  85. // HUlib_addCharToTextLine()
  86. //
  87. // Adds a character at the end of the text line in a hu_textline_t widget
  88. //
  89. // Passed the hu_textline_t and the char to add
  90. // Returns false if already at length limit, true if the character added
  91. //
  92. boolean HUlib_addCharToTextLine
  93. ( hu_textline_t* t,
  94. char ch )
  95. {
  96. // killough 1/23/98 -- support multiple lines
  97. if (t->linelen == HU_MAXLINELENGTH)
  98. return false;
  99. else
  100. {
  101. t->linelen++;
  102. if (ch == '\n')
  103. t->linelen=0;
  104. t->l[t->len++] = ch;
  105. t->l[t->len] = 0;
  106. t->needsupdate = 4;
  107. return true;
  108. }
  109. }
  110. //
  111. // HUlib_delCharFromTextLine()
  112. //
  113. // Deletes a character at the end of the text line in a hu_textline_t widget
  114. //
  115. // Passed the hu_textline_t
  116. // Returns false if already empty, true if the character deleted
  117. //
  118. static boolean HUlib_delCharFromTextLine(hu_textline_t* t)
  119. {
  120. if (!t->len) return false;
  121. else
  122. {
  123. t->l[--t->len] = 0;
  124. t->needsupdate = 4;
  125. return true;
  126. }
  127. }
  128. //
  129. // HUlib_drawTextLine()
  130. //
  131. // Draws a hu_textline_t widget
  132. //
  133. // Passed the hu_textline_t and flag whether to draw a cursor
  134. // Returns nothing
  135. //
  136. void HUlib_drawTextLine
  137. ( hu_textline_t* l,
  138. boolean drawcursor )
  139. {
  140. int i;
  141. int w;
  142. int x;
  143. unsigned char c;
  144. int oc = l->cm; //jff 2/17/98 remember default color
  145. int y = l->y; // killough 1/18/98 -- support multiple lines
  146. // draw the new stuff
  147. x = l->x;
  148. for (i=0;i<l->len;i++)
  149. {
  150. c = toupper(l->l[i]); //jff insure were not getting a cheap toupper conv.
  151. if (c=='\n') // killough 1/18/98 -- support multiple lines
  152. x=0,y+=8;
  153. else if (c=='\t') // killough 1/23/98 -- support tab stops
  154. x=x-x%80+80;
  155. else if (c=='\x1b') //jff 2/17/98 escape code for color change
  156. { //jff 3/26/98 changed to actual escape char
  157. if (++i<l->len)
  158. if (l->l[i]>='0' && l->l[i]<='9')
  159. l->cm = l->l[i]-'0';
  160. }
  161. else if (c != ' ' && c >= l->sc && c <= 127)
  162. {
  163. w = l->f[c - l->sc].width;
  164. if (x+w > BASE_WIDTH)
  165. break;
  166. // killough 1/18/98 -- support multiple lines:
  167. // CPhipps - patch drawing updated
  168. V_DrawNumPatch(x, y, FG, l->f[c - l->sc].lumpnum, l->cm, VPT_TRANS | VPT_STRETCH);
  169. x += w;
  170. }
  171. else
  172. {
  173. x += 4;
  174. if (x >= BASE_WIDTH)
  175. break;
  176. }
  177. }
  178. l->cm = oc; //jff 2/17/98 restore original color
  179. // draw the cursor if requested
  180. if (drawcursor && x + l->f['_' - l->sc].width <= BASE_WIDTH)
  181. {
  182. // killough 1/18/98 -- support multiple lines
  183. // CPhipps - patch drawing updated
  184. V_DrawNumPatch(x, y, FG, l->f['_' - l->sc].lumpnum, CR_DEFAULT, VPT_NONE | VPT_STRETCH);
  185. }
  186. }
  187. //
  188. // HUlib_eraseTextLine()
  189. //
  190. // Erases a hu_textline_t widget when screen border is behind text
  191. // Sorta called by HU_Erase and just better darn get things straight
  192. //
  193. // Passed the hu_textline_t
  194. // Returns nothing
  195. //
  196. void HUlib_eraseTextLine(hu_textline_t* l)
  197. {
  198. int lh;
  199. int y;
  200. // Only erases when NOT in automap and the screen is reduced,
  201. // and the text must either need updating or refreshing
  202. // (because of a recent change back from the automap)
  203. if (!(automapmode & am_active) && viewwindowx && l->needsupdate)
  204. {
  205. lh = l->f[0].height + 1;
  206. for (y=l->y; y<l->y+lh ; y++)
  207. {
  208. if (y < viewwindowy || y >= viewwindowy + viewheight)
  209. R_VideoErase(0, y, SCREENWIDTH); // erase entire line
  210. else
  211. {
  212. // erase left border
  213. R_VideoErase(0, y, viewwindowx);
  214. // erase right border
  215. R_VideoErase(viewwindowx + viewwidth, y, viewwindowx);
  216. }
  217. }
  218. }
  219. if (l->needsupdate) l->needsupdate--;
  220. }
  221. ////////////////////////////////////////////////////////
  222. //
  223. // Player message widget (up to 4 lines of text)
  224. //
  225. ////////////////////////////////////////////////////////
  226. //
  227. // HUlib_initSText()
  228. //
  229. // Initialize a hu_stext_t widget. Set the position, number of lines, font,
  230. // start char of the font, and color range to be used, and whether enabled.
  231. //
  232. // Passed a hu_stext_t, and the values used to initialize
  233. // Returns nothing
  234. //
  235. void HUlib_initSText
  236. ( hu_stext_t* s,
  237. int x,
  238. int y,
  239. int h,
  240. const patchnum_t* font,
  241. int startchar,
  242. int cm, //jff 2/16/98 add color range parameter
  243. boolean* on )
  244. {
  245. int i;
  246. s->h = h;
  247. s->on = on;
  248. s->laston = true;
  249. s->cl = 0;
  250. for (i=0;i<h;i++)
  251. HUlib_initTextLine
  252. (
  253. &s->l[i],
  254. x,
  255. y - i*(font[0].height+1),
  256. font,
  257. startchar,
  258. cm
  259. );
  260. }
  261. //
  262. // HUlib_addLineToSText()
  263. //
  264. // Adds a blank line to a hu_stext_t widget
  265. //
  266. // Passed a hu_stext_t
  267. // Returns nothing
  268. //
  269. static void HUlib_addLineToSText(hu_stext_t* s)
  270. {
  271. int i;
  272. // add a clear line
  273. if (++s->cl == s->h)
  274. s->cl = 0;
  275. HUlib_clearTextLine(&s->l[s->cl]);
  276. // everything needs updating
  277. for (i=0 ; i<s->h ; i++)
  278. s->l[i].needsupdate = 4;
  279. }
  280. //
  281. // HUlib_addMessageToSText()
  282. //
  283. // Adds a message line with prefix to a hu_stext_t widget
  284. //
  285. // Passed a hu_stext_t, the prefix string, and a message string
  286. // Returns nothing
  287. //
  288. void HUlib_addMessageToSText(hu_stext_t* s, const char* prefix, const char* msg)
  289. {
  290. HUlib_addLineToSText(s);
  291. if (prefix)
  292. while (*prefix)
  293. HUlib_addCharToTextLine(&s->l[s->cl], *(prefix++));
  294. while (*msg)
  295. HUlib_addCharToTextLine(&s->l[s->cl], *(msg++));
  296. }
  297. //
  298. // HUlib_drawSText()
  299. //
  300. // Displays a hu_stext_t widget
  301. //
  302. // Passed a hu_stext_t
  303. // Returns nothing
  304. //
  305. void HUlib_drawSText(hu_stext_t* s)
  306. {
  307. int i, idx;
  308. hu_textline_t *l;
  309. if (!*s->on)
  310. return; // if not on, don't draw
  311. // draw everything
  312. for (i=0 ; i<s->h ; i++)
  313. {
  314. idx = s->cl - i;
  315. if (idx < 0)
  316. idx += s->h; // handle queue of lines
  317. l = &s->l[idx];
  318. // need a decision made here on whether to skip the draw
  319. HUlib_drawTextLine(l, false); // no cursor, please
  320. }
  321. }
  322. //
  323. // HUlib_eraseSText()
  324. //
  325. // Erases a hu_stext_t widget, when the screen is not fullsize
  326. //
  327. // Passed a hu_stext_t
  328. // Returns nothing
  329. //
  330. void HUlib_eraseSText(hu_stext_t* s)
  331. {
  332. int i;
  333. for (i=0 ; i<s->h ; i++)
  334. {
  335. if (s->laston && !*s->on)
  336. s->l[i].needsupdate = 4;
  337. HUlib_eraseTextLine(&s->l[i]);
  338. }
  339. s->laston = *s->on;
  340. }
  341. ////////////////////////////////////////////////////////
  342. //
  343. // Scrolling message review widget
  344. //
  345. // jff added 2/26/98
  346. //
  347. ////////////////////////////////////////////////////////
  348. //
  349. // HUlib_initMText()
  350. //
  351. // Initialize a hu_mtext_t widget. Set the position, width, number of lines,
  352. // font, start char of the font, color range, background font, and whether
  353. // enabled.
  354. //
  355. // Passed a hu_mtext_t, and the values used to initialize
  356. // Returns nothing
  357. //
  358. void HUlib_initMText(hu_mtext_t *m, int x, int y, int w, int h,
  359. const patchnum_t* font, int startchar, int cm,
  360. const patchnum_t* bgfont, boolean *on)
  361. {
  362. int i;
  363. m->nl = 0;
  364. m->nr = 0;
  365. m->cl = -1; //jff 4/28/98 prepare for pre-increment
  366. m->x = x;
  367. m->y = y;
  368. m->w = w;
  369. m->h = h;
  370. m->bg = bgfont;
  371. m->on = on;
  372. for (i=0;i<HU_MAXMESSAGES;i++)
  373. {
  374. HUlib_initTextLine
  375. (
  376. &m->l[i],
  377. x,
  378. y + (hud_list_bgon? i+1 : i)*HU_REFRESHSPACING,
  379. font,
  380. startchar,
  381. cm
  382. );
  383. }
  384. }
  385. //
  386. // HUlib_addLineToMText()
  387. //
  388. // Adds a blank line to a hu_mtext_t widget
  389. //
  390. // Passed a hu_mtext_t
  391. // Returns nothing
  392. //
  393. static void HUlib_addLineToMText(hu_mtext_t* m)
  394. {
  395. // add a clear line
  396. if (++m->cl == hud_msg_lines)
  397. m->cl = 0;
  398. HUlib_clearTextLine(&m->l[m->cl]);
  399. if (m->nl<hud_msg_lines)
  400. m->nl++;
  401. // needs updating
  402. m->l[m->cl].needsupdate = 4;
  403. }
  404. //
  405. // HUlib_addMessageToMText()
  406. //
  407. // Adds a message line with prefix to a hu_mtext_t widget
  408. //
  409. // Passed a hu_mtext_t, the prefix string, and a message string
  410. // Returns nothing
  411. //
  412. void HUlib_addMessageToMText(hu_mtext_t* m, const char* prefix, const char* msg)
  413. {
  414. HUlib_addLineToMText(m);
  415. if (prefix)
  416. while (*prefix)
  417. HUlib_addCharToTextLine(&m->l[m->cl], *(prefix++));
  418. while (*msg)
  419. HUlib_addCharToTextLine(&m->l[m->cl], *(msg++));
  420. }
  421. //
  422. // HUlib_drawMBg()
  423. //
  424. // Draws a background box which the message display review widget can
  425. // display over
  426. //
  427. // Passed position, width, height, and the background patches
  428. // Returns nothing
  429. //
  430. void HUlib_drawMBg
  431. ( int x,
  432. int y,
  433. int w,
  434. int h,
  435. const patchnum_t* bgp
  436. )
  437. {
  438. int xs = bgp[0].width;
  439. int ys = bgp[0].height;
  440. int i,j;
  441. // CPhipps - patch drawing updated
  442. // top rows
  443. V_DrawNumPatch(x, y, FG, bgp[0].lumpnum, CR_DEFAULT, VPT_STRETCH); // ul
  444. for (j=x+xs;j<x+w-xs;j+=xs) // uc
  445. V_DrawNumPatch(j, y, FG, bgp[1].lumpnum, CR_DEFAULT, VPT_STRETCH);
  446. V_DrawNumPatch(j, y, FG, bgp[2].lumpnum, CR_DEFAULT, VPT_STRETCH); // ur
  447. // middle rows
  448. for (i=y+ys;i<y+h-ys;i+=ys)
  449. {
  450. V_DrawNumPatch(x, i, FG, bgp[3].lumpnum, CR_DEFAULT, VPT_STRETCH); // cl
  451. for (j=x+xs;j<x+w-xs;j+=xs) // cc
  452. V_DrawNumPatch(j, i, FG, bgp[4].lumpnum, CR_DEFAULT, VPT_STRETCH);
  453. V_DrawNumPatch(j, i, FG, bgp[5].lumpnum, CR_DEFAULT, VPT_STRETCH); // cr
  454. }
  455. // bottom row
  456. V_DrawNumPatch(x, i, FG, bgp[6].lumpnum, CR_DEFAULT, VPT_STRETCH); // ll
  457. for (j=x+xs;j<x+w-xs;j+=xs) // lc
  458. V_DrawNumPatch(j, i, FG, bgp[7].lumpnum, CR_DEFAULT, VPT_STRETCH);
  459. V_DrawNumPatch(j, i, FG, bgp[8].lumpnum, CR_DEFAULT, VPT_STRETCH); // lr
  460. }
  461. //
  462. // HUlib_drawMText()
  463. //
  464. // Displays a hu_mtext_t widget
  465. //
  466. // Passed a hu_mtext_t
  467. // Returns nothing
  468. //
  469. void HUlib_drawMText(hu_mtext_t* m)
  470. {
  471. int i, idx, y;
  472. hu_textline_t *l;
  473. if (!*m->on)
  474. return; // if not on, don't draw
  475. // draw everything
  476. if (hud_list_bgon)
  477. HUlib_drawMBg(m->x,m->y,m->w,m->h,m->bg);
  478. y = m->y + HU_REFRESHSPACING;
  479. for (i=0 ; i<m->nl ; i++)
  480. {
  481. idx = m->cl - i;
  482. if (idx < 0)
  483. idx += m->nl; // handle queue of lines
  484. l = &m->l[idx];
  485. if (hud_list_bgon)
  486. {
  487. l->x = m->x + 4;
  488. l->y = m->y + (i+1)*HU_REFRESHSPACING;
  489. }
  490. else
  491. {
  492. l->x = m->x;
  493. l->y = m->y + i*HU_REFRESHSPACING;
  494. }
  495. // need a decision made here on whether to skip the draw
  496. HUlib_drawTextLine(l, false); // no cursor, please
  497. }
  498. }
  499. //
  500. // HUlib_eraseMBg()
  501. //
  502. // Erases background behind hu_mtext_t widget, when the screen is not fullsize
  503. //
  504. // Passed a hu_mtext_t
  505. // Returns nothing
  506. //
  507. static void HUlib_eraseMBg(hu_mtext_t* m)
  508. {
  509. int lh;
  510. int y;
  511. // Only erases when NOT in automap and the screen is reduced,
  512. // and the text must either need updating or refreshing
  513. // (because of a recent change back from the automap)
  514. if (!(automapmode & am_active) && viewwindowx)
  515. {
  516. lh = m->l[0].f[0].height + 1;
  517. for (y=m->y; y<m->y+lh*(hud_msg_lines+2) ; y++)
  518. {
  519. if (y < viewwindowy || y >= viewwindowy + viewheight)
  520. R_VideoErase(0, y, SCREENWIDTH); // erase entire line
  521. else
  522. {
  523. // erase left border
  524. R_VideoErase(0, y, viewwindowx);
  525. // erase right border
  526. R_VideoErase(viewwindowx + viewwidth, y, viewwindowx);
  527. }
  528. }
  529. }
  530. }
  531. //
  532. // HUlib_eraseMText()
  533. //
  534. // Erases a hu_mtext_t widget, when the screen is not fullsize
  535. //
  536. // Passed a hu_mtext_t
  537. // Returns nothing
  538. //
  539. void HUlib_eraseMText(hu_mtext_t* m)
  540. {
  541. int i;
  542. if (hud_list_bgon)
  543. HUlib_eraseMBg(m);
  544. for (i=0 ; i< m->nl ; i++)
  545. {
  546. m->l[i].needsupdate = 4;
  547. HUlib_eraseTextLine(&m->l[i]);
  548. }
  549. }
  550. ////////////////////////////////////////////////////////
  551. //
  552. // Interactive text entry widget
  553. //
  554. ////////////////////////////////////////////////////////
  555. //
  556. // HUlib_initIText()
  557. //
  558. // Initialize a hu_itext_t widget. Set the position, font,
  559. // start char of the font, color range, and whether enabled.
  560. //
  561. // Passed a hu_itext_t, and the values used to initialize
  562. // Returns nothing
  563. //
  564. void HUlib_initIText
  565. ( hu_itext_t* it,
  566. int x,
  567. int y,
  568. const patchnum_t* font,
  569. int startchar,
  570. int cm, //jff 2/16/98 add color range parameter
  571. boolean* on )
  572. {
  573. it->lm = 0; // default left margin is start of text
  574. it->on = on;
  575. it->laston = true;
  576. HUlib_initTextLine(&it->l, x, y, font, startchar, cm);
  577. }
  578. // The following deletion routines adhere to the left margin restriction
  579. //
  580. // HUlib_delCharFromIText()
  581. //
  582. // Deletes a character at the end of the text line in a hu_itext_t widget
  583. //
  584. // Passed the hu_itext_t
  585. // Returns nothing
  586. //
  587. static void HUlib_delCharFromIText(hu_itext_t* it)
  588. {
  589. if (it->l.len != it->lm)
  590. HUlib_delCharFromTextLine(&it->l);
  591. }
  592. //
  593. // HUlib_eraseLineFromIText()
  594. //
  595. // Deletes all characters from a hu_itext_t widget
  596. //
  597. // Passed the hu_itext_t
  598. // Returns nothing
  599. //
  600. #ifndef IPHONE
  601. static void HUlib_eraseLineFromIText(hu_itext_t* it)
  602. {
  603. while (it->lm != it->l.len)
  604. HUlib_delCharFromTextLine(&it->l);
  605. }
  606. #endif
  607. //
  608. // HUlib_resetIText()
  609. //
  610. // Deletes all characters from a hu_itext_t widget
  611. // Resets left margin as well
  612. //
  613. // Passed the hu_itext_t
  614. // Returns nothing
  615. //
  616. void HUlib_resetIText(hu_itext_t* it)
  617. {
  618. it->lm = 0;
  619. HUlib_clearTextLine(&it->l);
  620. }
  621. //
  622. // HUlib_addPrefixToIText()
  623. //
  624. // Adds a prefix string passed to a hu_itext_t widget
  625. // Sets left margin to length of string added
  626. //
  627. // Passed the hu_itext_t and the prefix string
  628. // Returns nothing
  629. //
  630. void HUlib_addPrefixToIText
  631. ( hu_itext_t* it,
  632. char* str )
  633. {
  634. while (*str)
  635. HUlib_addCharToTextLine(&it->l, *(str++));
  636. it->lm = it->l.len;
  637. }
  638. //
  639. // HUlib_keyInIText()
  640. //
  641. // Wrapper function for handling general keyed input.
  642. //
  643. // Passed the hu_itext_t and the char input
  644. // Returns true if it ate the key
  645. //
  646. boolean HUlib_keyInIText
  647. ( hu_itext_t* it,
  648. unsigned char ch )
  649. {
  650. if (ch >= ' ' && ch <= '_')
  651. HUlib_addCharToTextLine(&it->l, (char) ch);
  652. else if (ch == key_backspace) // phares
  653. HUlib_delCharFromIText(it);
  654. else if (ch != key_enter) // phares
  655. return false; // did not eat key
  656. return true; // ate the key
  657. }
  658. //
  659. // HUlib_drawIText()
  660. //
  661. // Displays a hu_itext_t widget
  662. //
  663. // Passed the hu_itext_t
  664. // Returns nothing
  665. //
  666. void HUlib_drawIText(hu_itext_t* it)
  667. {
  668. hu_textline_t *l = &it->l;
  669. if (!*it->on)
  670. return;
  671. HUlib_drawTextLine(l, true); // draw the line w/ cursor
  672. }
  673. //
  674. // HUlib_eraseIText()
  675. //
  676. // Erases a hu_itext_t widget when the screen is not fullsize
  677. //
  678. // Passed the hu_itext_t
  679. // Returns nothing
  680. //
  681. void HUlib_eraseIText(hu_itext_t* it)
  682. {
  683. if (it->laston && !*it->on)
  684. it->l.needsupdate = 4;
  685. HUlib_eraseTextLine(&it->l);
  686. it->laston = *it->on;
  687. }