hu_lib.c 17 KB

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