config.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789
  1. /******************************************************************************
  2. * This file is part of TinTin++ *
  3. * *
  4. * Copyright 2004-2019 Igor van den Hoven *
  5. * *
  6. * TinTin++ is free software; you can redistribute it and/or modify *
  7. * it under the terms of the GNU General Public License as published by *
  8. * the Free Software Foundation; either version 3 of the License, or *
  9. * (at your option) any later version. *
  10. * *
  11. * This program is distributed in the hope that it will be useful, *
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  14. * GNU General Public License for more details. *
  15. * *
  16. * *
  17. * You should have received a copy of the GNU General Public License *
  18. * along with TinTin++. If not, see https://www.gnu.org/licenses. *
  19. ******************************************************************************/
  20. /******************************************************************************
  21. * file: config.c - funtions related tintin++ configuration *
  22. * (T)he K(I)cki(N) (T)ickin D(I)kumud Clie(N)t *
  23. * coded by Igor van den Hoven 2004 *
  24. ******************************************************************************/
  25. #include "tintin.h"
  26. DO_COMMAND(do_configure)
  27. {
  28. char arg1[BUFFER_SIZE], arg2[BUFFER_SIZE];
  29. struct listnode *node;
  30. int index;
  31. arg = get_arg_in_braces(ses, arg, arg1, GET_ONE);
  32. arg = sub_arg_in_braces(ses, arg, arg2, GET_ONE, SUB_VAR|SUB_FUN);
  33. if (*arg1 == 0)
  34. {
  35. tintin_header(ses, " CONFIGURATIONS ");
  36. for (index = 0 ; *config_table[index].name != 0 ; index++)
  37. {
  38. node = search_node_list(ses->list[LIST_CONFIG], config_table[index].name);
  39. if (node)
  40. {
  41. tintin_printf2(ses, "[%-14s] [%8s] %s",
  42. node->arg1,
  43. node->arg2,
  44. strcmp(node->arg2, "ON") == 0 ? config_table[index].msg_on : config_table[index].msg_off);
  45. }
  46. }
  47. tintin_header(ses, "");
  48. }
  49. else
  50. {
  51. for (index = 0 ; *config_table[index].name != 0 ; index++)
  52. {
  53. if (is_abbrev(arg1, config_table[index].name))
  54. {
  55. if (config_table[index].config(ses, arg2, index) != NULL)
  56. {
  57. node = search_node_list(ses->list[LIST_CONFIG], config_table[index].name);
  58. if (node)
  59. {
  60. show_message(ses, LIST_CONFIG, "#CONFIG {%s} HAS BEEN SET TO {%s}.", config_table[index].name, node->arg2);
  61. }
  62. }
  63. return ses;
  64. }
  65. }
  66. show_error(ses, LIST_CONFIG, "#ERROR: #CONFIG {%s} IS NOT A VALID OPTION.", capitalize(arg1));
  67. }
  68. return ses;
  69. }
  70. DO_CONFIG(config_speedwalk)
  71. {
  72. if (!strcasecmp(arg, "ON"))
  73. {
  74. SET_BIT(ses->flags, SES_FLAG_SPEEDWALK);
  75. }
  76. else if (!strcasecmp(arg, "OFF"))
  77. {
  78. DEL_BIT(ses->flags, SES_FLAG_SPEEDWALK);
  79. }
  80. else
  81. {
  82. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  83. return NULL;
  84. }
  85. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  86. return ses;
  87. }
  88. DO_CONFIG(config_verbatim)
  89. {
  90. if (!strcasecmp(arg, "ON"))
  91. {
  92. SET_BIT(ses->flags, SES_FLAG_VERBATIM);
  93. }
  94. else if (!strcasecmp(arg, "OFF"))
  95. {
  96. DEL_BIT(ses->flags, SES_FLAG_VERBATIM);
  97. }
  98. else
  99. {
  100. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  101. return NULL;
  102. }
  103. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  104. return ses;
  105. }
  106. DO_CONFIG(config_repeatenter)
  107. {
  108. if (!strcasecmp(arg, "ON"))
  109. {
  110. SET_BIT(ses->flags, SES_FLAG_REPEATENTER);
  111. }
  112. else if (!strcasecmp(arg, "OFF"))
  113. {
  114. DEL_BIT(ses->flags, SES_FLAG_REPEATENTER);
  115. }
  116. else
  117. {
  118. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  119. return NULL;
  120. }
  121. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  122. return ses;
  123. }
  124. DO_CONFIG(config_commandcolor)
  125. {
  126. char buf[BUFFER_SIZE];
  127. substitute(ses, arg, buf, SUB_COL);
  128. RESTRING(ses->cmd_color, buf);
  129. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, arg, "", "");
  130. return ses;
  131. }
  132. DO_CONFIG(config_commandecho)
  133. {
  134. if (!strcasecmp(arg, "ON"))
  135. {
  136. SET_BIT(ses->flags, SES_FLAG_ECHOCOMMAND);
  137. }
  138. else if (!strcasecmp(arg, "OFF"))
  139. {
  140. DEL_BIT(ses->flags, SES_FLAG_ECHOCOMMAND);
  141. }
  142. else
  143. {
  144. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  145. return NULL;
  146. }
  147. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  148. return ses;
  149. }
  150. DO_CONFIG(config_verbose)
  151. {
  152. if (!strcasecmp(arg, "ON"))
  153. {
  154. SET_BIT(ses->flags, SES_FLAG_VERBOSE);
  155. }
  156. else if (!strcasecmp(arg, "OFF"))
  157. {
  158. DEL_BIT(ses->flags, SES_FLAG_VERBOSE);
  159. }
  160. else
  161. {
  162. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  163. return NULL;
  164. }
  165. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  166. return ses;
  167. }
  168. DO_CONFIG(config_wordwrap)
  169. {
  170. if (!strcasecmp(arg, "ON"))
  171. {
  172. ses->wrap = -1;
  173. }
  174. else if (!strcasecmp(arg, "OFF"))
  175. {
  176. ses->wrap = 0;
  177. }
  178. else if (is_number(arg))
  179. {
  180. if (atoi(arg) < 1 || atoi(arg) > 10000)
  181. {
  182. show_error(ses, LIST_CONFIG, "#ERROR: #CONFIG BUFFER: PROVIDE A NUMBER BETWEEN 1 and 10000");
  183. return NULL;
  184. }
  185. ses->wrap = atoi(arg);
  186. }
  187. else
  188. {
  189. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF|NUMBER>", config_table[index].name);
  190. return NULL;
  191. }
  192. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  193. SET_BIT(gtd->flags, TINTIN_FLAG_RESETBUFFER);
  194. return ses;
  195. }
  196. DO_CONFIG(config_logmode)
  197. {
  198. if (!strcasecmp(arg, "HTML"))
  199. {
  200. SET_BIT(ses->logmode, LOG_FLAG_HTML);
  201. DEL_BIT(ses->logmode, LOG_FLAG_PLAIN);
  202. DEL_BIT(ses->logmode, LOG_FLAG_RAW);
  203. }
  204. else if (!strcasecmp(arg, "PLAIN"))
  205. {
  206. DEL_BIT(ses->logmode, LOG_FLAG_HTML);
  207. SET_BIT(ses->logmode, LOG_FLAG_PLAIN);
  208. DEL_BIT(ses->logmode, LOG_FLAG_RAW);
  209. }
  210. else if (!strcasecmp(arg, "RAW"))
  211. {
  212. DEL_BIT(ses->logmode, LOG_FLAG_HTML);
  213. DEL_BIT(ses->logmode, LOG_FLAG_PLAIN);
  214. SET_BIT(ses->logmode, LOG_FLAG_RAW);
  215. }
  216. else
  217. {
  218. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG LOG <HTML|PLAIN|RAW>");
  219. return NULL;
  220. }
  221. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  222. return ses;
  223. }
  224. DO_CONFIG(config_buffersize)
  225. {
  226. if (!is_number(arg))
  227. {
  228. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {BUFFER SIZE} <NUMBER>");
  229. return NULL;
  230. }
  231. if (atoi(arg) < 100 || atoi(arg) > 999999)
  232. {
  233. show_error(ses, LIST_CONFIG, "#ERROR: #CONFIG BUFFER: PROVIDE A NUMBER BETWEEN 100 and 999999");
  234. return NULL;
  235. }
  236. init_buffer(ses, atoi(arg));
  237. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  238. return ses;
  239. }
  240. DO_CONFIG(config_scrolllock)
  241. {
  242. if (!strcasecmp(arg, "ON"))
  243. {
  244. SET_BIT(ses->flags, SES_FLAG_SCROLLLOCK);
  245. }
  246. else if (!strcasecmp(arg, "OFF"))
  247. {
  248. DEL_BIT(ses->flags, SES_FLAG_SCROLLLOCK);
  249. }
  250. else
  251. {
  252. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  253. return NULL;
  254. }
  255. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  256. return ses;
  257. }
  258. DO_CONFIG(config_connectretry)
  259. {
  260. if (!is_number(arg))
  261. {
  262. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {CONNECT RETRY} <NUMBER>");
  263. return NULL;
  264. }
  265. gts->connect_retry = atoll(arg) * 1000000LL;
  266. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  267. return ses;
  268. }
  269. DO_CONFIG(config_packetpatch)
  270. {
  271. if (is_abbrev("AUTO", arg))
  272. {
  273. gts->check_output = 0;
  274. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, "AUTO", "", "");
  275. SET_BIT(ses->flags, SES_FLAG_AUTOPATCH);
  276. return ses;
  277. }
  278. if (!is_number(arg))
  279. {
  280. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {PACKET PATCH} <NUMBER>");
  281. return NULL;
  282. }
  283. if (atof(arg) < 0 || atof(arg) > 10)
  284. {
  285. show_error(ses, LIST_CONFIG, "#ERROR: #CONFIG PACKET PATCH: PROVIDE A NUMBER BETWEEN 0.00 and 10.00");
  286. return NULL;
  287. }
  288. DEL_BIT(ses->flags, SES_FLAG_AUTOPATCH);
  289. gts->check_output = (unsigned long long) (tintoi(arg) * 1000000ULL);
  290. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  291. return ses;
  292. }
  293. DO_CONFIG(config_historysize)
  294. {
  295. if (!is_number(arg))
  296. {
  297. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {HISTORY SIZE} <NUMBER>");
  298. }
  299. if (atoi(arg) < 0 || atoi(arg) > 9999)
  300. {
  301. show_error(ses, LIST_CONFIG, "#ERROR: #CONFIG HISTORY: PROVIDE A NUMBER BETWEEN 0 and 9999");
  302. return NULL;
  303. }
  304. gtd->history_size = atoi(arg);
  305. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  306. return ses;
  307. }
  308. DO_CONFIG(config_tintinchar)
  309. {
  310. gtd->tintin_char = arg[0];
  311. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, arg, "", "");
  312. return ses;
  313. }
  314. DO_CONFIG(config_verbatimchar)
  315. {
  316. gtd->verbatim_char = arg[0];
  317. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, arg, "", "");
  318. return ses;
  319. }
  320. DO_CONFIG(config_repeatchar)
  321. {
  322. gtd->repeat_char = arg[0];
  323. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, arg, "", "");
  324. return ses;
  325. }
  326. DO_CONFIG(config_debugtelnet)
  327. {
  328. if (!strcasecmp(arg, "ON"))
  329. {
  330. SET_BIT(ses->telopts, TELOPT_FLAG_DEBUG);
  331. }
  332. else if (!strcasecmp(arg, "OFF"))
  333. {
  334. DEL_BIT(ses->telopts, TELOPT_FLAG_DEBUG);
  335. }
  336. else
  337. {
  338. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  339. return NULL;
  340. }
  341. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  342. return ses;
  343. }
  344. DO_CONFIG(config_telnet)
  345. {
  346. if (!strcasecmp(arg, "ON"))
  347. {
  348. DEL_BIT(ses->telopts, TELOPT_FLAG_DEBUG);
  349. SET_BIT(ses->flags, SES_FLAG_TELNET);
  350. }
  351. else if (!strcasecmp(arg, "OFF"))
  352. {
  353. DEL_BIT(ses->telopts, TELOPT_FLAG_DEBUG);
  354. DEL_BIT(ses->flags, SES_FLAG_TELNET);
  355. }
  356. else if (!strcasecmp(arg, "DEBUG"))
  357. {
  358. SET_BIT(ses->telopts, TELOPT_FLAG_DEBUG);
  359. SET_BIT(ses->flags, SES_FLAG_TELNET);
  360. }
  361. else
  362. {
  363. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF|DEBUG>", config_table[index].name);
  364. return NULL;
  365. }
  366. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  367. return ses;
  368. }
  369. DO_CONFIG(config_convertmeta)
  370. {
  371. if (!strcasecmp(arg, "ON"))
  372. {
  373. SET_BIT(ses->flags, SES_FLAG_CONVERTMETA);
  374. }
  375. else if (!strcasecmp(arg, "OFF"))
  376. {
  377. DEL_BIT(ses->flags, SES_FLAG_CONVERTMETA);
  378. }
  379. else
  380. {
  381. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  382. return NULL;
  383. }
  384. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  385. return ses;
  386. }
  387. DO_CONFIG(config_loglevel)
  388. {
  389. if (!strcasecmp(arg, "LOW"))
  390. {
  391. SET_BIT(ses->logmode, LOG_FLAG_LOW);
  392. }
  393. else if (!strcasecmp(arg, "HIGH"))
  394. {
  395. DEL_BIT(ses->logmode, LOG_FLAG_LOW);
  396. }
  397. else
  398. {
  399. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <LOW|HIGH>", config_table[index].name);
  400. return NULL;
  401. }
  402. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  403. return ses;
  404. }
  405. DO_CONFIG(config_colorpatch)
  406. {
  407. if (!strcasecmp(arg, "ON"))
  408. {
  409. SET_BIT(ses->flags, SES_FLAG_COLORPATCH);
  410. }
  411. else if (!strcasecmp(arg, "OFF"))
  412. {
  413. DEL_BIT(ses->flags, SES_FLAG_COLORPATCH);
  414. }
  415. else
  416. {
  417. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  418. return NULL;
  419. }
  420. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  421. return ses;
  422. }
  423. DO_CONFIG(config_mccp)
  424. {
  425. if (!strcasecmp(arg, "ON"))
  426. {
  427. SET_BIT(ses->flags, SES_FLAG_MCCP);
  428. }
  429. else if (!strcasecmp(arg, "OFF"))
  430. {
  431. DEL_BIT(ses->flags, SES_FLAG_MCCP);
  432. }
  433. else
  434. {
  435. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  436. return NULL;
  437. }
  438. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  439. return ses;
  440. }
  441. DO_CONFIG(config_autotab)
  442. {
  443. if (!is_number(arg))
  444. {
  445. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {AUTO TAB} <NUMBER>");
  446. return NULL;
  447. }
  448. if (atoi(arg) < 1 || atoi(arg) > 999999)
  449. {
  450. show_error(ses, LIST_CONFIG, "#ERROR: #CONFIG BUFFER: PROVIDE A NUMBER BETWEEN 1 and 999999");
  451. return NULL;
  452. }
  453. ses->auto_tab = atoi(arg);
  454. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  455. return ses;
  456. }
  457. DO_CONFIG(config_charset)
  458. {
  459. if (!strcasecmp(arg, "AUTO"))
  460. {
  461. if (strcasestr(gtd->lang, "UTF-8"))
  462. {
  463. strcpy(arg, "UTF-8");
  464. }
  465. else if (strcasestr(gtd->lang, "BIG-5"))
  466. {
  467. strcpy(arg, "BIG-5");
  468. }
  469. else
  470. {
  471. strcpy(arg, "ASCII");
  472. }
  473. }
  474. if (!strcasecmp(arg, "BIG5"))
  475. {
  476. DEL_BIT(ses->flags, SES_FLAG_CHARSETS);
  477. SET_BIT(ses->flags, SES_FLAG_BIG5);
  478. }
  479. else if (!strcasecmp(arg, "BIG-5"))
  480. {
  481. DEL_BIT(ses->flags, SES_FLAG_CHARSETS);
  482. SET_BIT(ses->flags, SES_FLAG_BIG5);
  483. }
  484. else if (!strcasecmp(arg, "UTF-8"))
  485. {
  486. DEL_BIT(ses->flags, SES_FLAG_CHARSETS);
  487. SET_BIT(ses->flags, SES_FLAG_UTF8);
  488. }
  489. else if (!strcasecmp(arg, "ASCII"))
  490. {
  491. DEL_BIT(ses->flags, SES_FLAG_CHARSETS);
  492. }
  493. else if (!strcasecmp(arg, "BIG2UTF"))
  494. {
  495. DEL_BIT(ses->flags, SES_FLAG_CHARSETS);
  496. SET_BIT(ses->flags, SES_FLAG_UTF8|SES_FLAG_BIG5TOUTF8);
  497. }
  498. else if (!strcasecmp(arg, "FANSI"))
  499. {
  500. DEL_BIT(ses->flags, SES_FLAG_CHARSETS);
  501. SET_BIT(ses->flags, SES_FLAG_UTF8|SES_FLAG_FANSITOUTF8);
  502. }
  503. else if (!strcasecmp(arg, "KOI2UTF"))
  504. {
  505. DEL_BIT(ses->flags, SES_FLAG_CHARSETS);
  506. SET_BIT(ses->flags, SES_FLAG_UTF8|SES_FLAG_KOI8TOUTF8);
  507. }
  508. else
  509. {
  510. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <AUTO|ASCII|BIG-5|FANSI|UTF-8|BIG2UTF|KOI2UTF>", config_table[index].name);
  511. return NULL;
  512. }
  513. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  514. return ses;
  515. }
  516. DO_CONFIG(config_colormode)
  517. {
  518. if (!strcasecmp(arg, "AUTO"))
  519. {
  520. if (strcasestr(gtd->term, "truecolor"))
  521. {
  522. strcpy(arg, "TRUE");
  523. }
  524. else if (!strcasecmp(gtd->term, "xterm") || strcasestr(gtd->term, "256color"))
  525. {
  526. strcpy(arg, "256");
  527. }
  528. else
  529. {
  530. strcpy(arg, "ANSI");
  531. }
  532. }
  533. if (!strcasecmp(arg, "NONE"))
  534. {
  535. strcpy(arg, "NONE");
  536. DEL_BIT(ses->flags, SES_FLAG_ANSICOLOR|SES_FLAG_256COLOR|SES_FLAG_TRUECOLOR);
  537. }
  538. else if (!strcasecmp(arg, "ANSI"))
  539. {
  540. strcpy(arg, "ANSI");
  541. SET_BIT(ses->flags, SES_FLAG_ANSICOLOR);
  542. DEL_BIT(ses->flags, SES_FLAG_256COLOR|SES_FLAG_TRUECOLOR);
  543. }
  544. else if (!strcasecmp(arg, "256"))
  545. {
  546. SET_BIT(ses->flags, SES_FLAG_ANSICOLOR|SES_FLAG_256COLOR);
  547. DEL_BIT(ses->flags, SES_FLAG_TRUECOLOR);
  548. }
  549. else if (!strcasecmp(arg, "TRUE"))
  550. {
  551. strcpy(arg, "TRUE");
  552. SET_BIT(ses->flags, SES_FLAG_ANSICOLOR|SES_FLAG_256COLOR|SES_FLAG_TRUECOLOR);
  553. }
  554. else
  555. {
  556. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <AUTO|NONE|ANSI|256|TRUE>", config_table[index].name);
  557. return NULL;
  558. }
  559. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, arg, "", "");
  560. return ses;
  561. }
  562. DO_CONFIG(config_screenreader)
  563. {
  564. if (!strcasecmp(arg, "ON"))
  565. {
  566. SET_BIT(ses->flags, SES_FLAG_SCREENREADER);
  567. }
  568. else if (!strcasecmp(arg, "OFF"))
  569. {
  570. DEL_BIT(ses->flags, SES_FLAG_SCREENREADER);
  571. }
  572. else
  573. {
  574. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  575. return NULL;
  576. }
  577. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  578. return ses;
  579. }
  580. DO_CONFIG(config_inheritance)
  581. {
  582. if (!strcasecmp(arg, "ON"))
  583. {
  584. SET_BIT(gtd->flags, TINTIN_FLAG_INHERITANCE);
  585. }
  586. else if (!strcasecmp(arg, "OFF"))
  587. {
  588. DEL_BIT(gtd->flags, TINTIN_FLAG_INHERITANCE);
  589. }
  590. else
  591. {
  592. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  593. return NULL;
  594. }
  595. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  596. return ses;
  597. }
  598. DO_CONFIG(config_randomseed)
  599. {
  600. if (!strcasecmp(arg, "AUTO"))
  601. {
  602. strcpy(arg, "AUTO");
  603. seed_rand(ses, utime());
  604. }
  605. else if (is_number(arg))
  606. {
  607. seed_rand(ses, get_number(ses, arg));
  608. }
  609. else
  610. {
  611. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <AUTO|NUMBER>", config_table[index].name);
  612. return NULL;
  613. }
  614. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, arg, "", "");
  615. return ses;
  616. }
  617. DO_CONFIG(config_mousetracking)
  618. {
  619. if (!strcasecmp(arg, "ON"))
  620. {
  621. SET_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING);
  622. printf("\e[?1000h\e[?1002h\e[?1004h\e[?1006h");
  623. }
  624. else if (!strcasecmp(arg, "OFF"))
  625. {
  626. DEL_BIT(gtd->flags, TINTIN_FLAG_MOUSETRACKING);
  627. printf("\e[?1000l\e[?1002l\e[?1004l\e[?1006l");
  628. }
  629. else
  630. {
  631. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  632. return NULL;
  633. }
  634. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  635. return ses;
  636. }
  637. DO_CONFIG(config_childlock)
  638. {
  639. if (!strcasecmp(arg, "ON"))
  640. {
  641. SET_BIT(gtd->flags, TINTIN_FLAG_CHILDLOCK);
  642. }
  643. else if (!strcasecmp(arg, "OFF"))
  644. {
  645. DEL_BIT(gtd->flags, TINTIN_FLAG_CHILDLOCK);
  646. }
  647. else
  648. {
  649. show_error(ses, LIST_CONFIG, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
  650. return NULL;
  651. }
  652. update_node_list(ses->list[LIST_CONFIG], config_table[index].name, capitalize(arg), "", "");
  653. return ses;
  654. }