terminfo.pp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by Florian Klaempfl
  4. member of the Free Pascal development team
  5. TermInfo interface unit for linux
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. unit TermInfo;
  13. interface
  14. {$ifndef symobi}
  15. {$linklib ncurses}
  16. {$linklib c}
  17. {$endif}
  18. {$packrecords c}
  19. const curseslib = 'ncurses';
  20. const
  21. { boolean values }
  22. auto_left_margin = 0;
  23. auto_right_margin = 1;
  24. no_esc_ctlc = 2;
  25. ceol_standout_glitch = 3;
  26. eat_newline_glitch = 4;
  27. erase_overstrike = 5;
  28. generic_type = 6;
  29. hard_copy = 7;
  30. has_meta_key = 8;
  31. has_status_line = 9;
  32. insert_null_glitch = 10;
  33. memory_above = 11;
  34. memory_below = 12;
  35. move_insert_mode = 13;
  36. move_standout_mode = 14;
  37. over_strike = 15;
  38. status_line_esc_ok = 16;
  39. dest_tabs_magic_smso = 17;
  40. tilde_glitch = 18;
  41. transparent_underline = 19;
  42. xon_xoff = 20;
  43. needs_xon_xoff = 21;
  44. prtr_silent = 22;
  45. hard_cursor = 23;
  46. non_rev_rmcup = 24;
  47. no_pad_char = 25;
  48. non_dest_scroll_region = 26;
  49. can_change = 27;
  50. back_color_erase = 28;
  51. hue_lightness_saturation = 29;
  52. col_addr_glitch = 30;
  53. cr_cancels_micro_mode = 31;
  54. has_print_wheel = 32;
  55. row_addr_glitch = 33;
  56. semi_auto_right_margin = 34;
  57. cpi_changes_res = 35;
  58. lpi_changes_res = 36;
  59. { numbers ... }
  60. columns = 0;
  61. init_tabs = 1;
  62. lines = 2;
  63. lines_of_memory = 3;
  64. magic_cookie_glitch = 4;
  65. padding_baud_rate = 5;
  66. virtual_terminal = 6;
  67. width_status_line = 7;
  68. num_labels = 8;
  69. label_height = 9;
  70. label_width = 10;
  71. max_attributes = 11;
  72. maximum_windows = 12;
  73. max_colors = 13;
  74. max_pairs = 14;
  75. no_color_video = 15;
  76. buffer_capacity = 16;
  77. dot_vert_spacing = 17;
  78. dot_horz_spacing = 18;
  79. max_micro_address = 19;
  80. max_micro_jump = 20;
  81. micro_char_size = 21;
  82. micro_line_size = 22;
  83. number_of_pins = 23;
  84. output_res_char = 24;
  85. output_res_line = 25;
  86. output_res_horz_inch = 26;
  87. output_res_vert_inch = 27;
  88. print_rate = 28;
  89. wide_char_size = 29;
  90. buttons = 30;
  91. bit_image_entwining = 31;
  92. bit_image_type = 32;
  93. { strings }
  94. back_tab = 0;
  95. bell = 1;
  96. carriage_return = 2;
  97. change_scroll_region = 3;
  98. clear_all_tabs = 4;
  99. clear_screen = 5;
  100. clr_eol = 6;
  101. clr_eos = 7;
  102. column_address = 8;
  103. command_character = 9;
  104. cursor_address = 10;
  105. cursor_down = 11;
  106. cursor_home = 12;
  107. cursor_invisible = 13;
  108. cursor_left = 14;
  109. cursor_mem_address = 15;
  110. cursor_normal = 16;
  111. cursor_right = 17;
  112. cursor_to_ll = 18;
  113. cursor_up = 19;
  114. cursor_visible = 20;
  115. delete_character = 21;
  116. delete_line = 22;
  117. dis_status_line = 23;
  118. down_half_line = 24;
  119. enter_alt_charset_mode = 25;
  120. enter_blink_mode = 26;
  121. enter_bold_mode = 27;
  122. enter_ca_mode = 28;
  123. enter_delete_mode = 29;
  124. enter_dim_mode = 30;
  125. enter_insert_mode = 31;
  126. enter_secure_mode = 32;
  127. enter_protected_mode = 33;
  128. enter_reverse_mode = 34;
  129. enter_standout_mode = 35;
  130. enter_underline_mode = 36;
  131. erase_chars = 37;
  132. exit_alt_charset_mode = 38;
  133. exit_attribute_mode = 39;
  134. exit_ca_mode = 40;
  135. exit_delete_mode = 41;
  136. exit_insert_mode = 42;
  137. exit_standout_mode = 43;
  138. exit_underline_mode = 44;
  139. flash_screen = 45;
  140. form_feed = 46;
  141. from_status_line = 47;
  142. init_1string = 48;
  143. init_2string = 49;
  144. init_3string = 50;
  145. init_file = 51;
  146. insert_character = 52;
  147. insert_line = 53;
  148. insert_padding = 54;
  149. key_backspace = 55;
  150. key_catab = 56;
  151. key_clear = 57;
  152. key_ctab = 58;
  153. key_dc = 59;
  154. key_dl = 60;
  155. key_down = 61;
  156. key_eic = 62;
  157. key_eol = 63;
  158. key_eos = 64;
  159. key_f0 = 65;
  160. key_f1 = 66;
  161. key_f10 = 67;
  162. key_f2 = 68;
  163. key_f3 = 69;
  164. key_f4 = 70;
  165. key_f5 = 71;
  166. key_f6 = 72;
  167. key_f7 = 73;
  168. key_f8 = 74;
  169. key_f9 = 75;
  170. key_home = 76;
  171. key_ic = 77;
  172. key_il = 78;
  173. key_left = 79;
  174. key_ll = 80;
  175. key_npage = 81;
  176. key_ppage = 82;
  177. key_right = 83;
  178. key_sf = 84;
  179. key_sr = 85;
  180. key_stab = 86;
  181. key_up = 87;
  182. keypad_local = 88;
  183. keypad_xmit = 89;
  184. lab_f0 = 90;
  185. lab_f1 = 91;
  186. lab_f10 = 92;
  187. lab_f2 = 93;
  188. lab_f3 = 94;
  189. lab_f4 = 95;
  190. lab_f5 = 96;
  191. lab_f6 = 97;
  192. lab_f7 = 98;
  193. lab_f8 = 99;
  194. lab_f9 = 100;
  195. meta_off = 101;
  196. meta_on = 102;
  197. newline = 103;
  198. pad_char = 104;
  199. parm_dch = 105;
  200. parm_delete_line = 106;
  201. parm_down_cursor = 107;
  202. parm_ich = 108;
  203. parm_index = 109;
  204. parm_insert_line = 110;
  205. parm_left_cursor = 111;
  206. parm_right_cursor = 112;
  207. parm_rindex = 113;
  208. parm_up_cursor = 114;
  209. pkey_key = 115;
  210. pkey_local = 116;
  211. pkey_xmit = 117;
  212. print_screen = 118;
  213. prtr_off = 119;
  214. prtr_on = 120;
  215. repeat_char = 121;
  216. reset_1string = 122;
  217. reset_2string = 123;
  218. reset_3string = 124;
  219. reset_file = 125;
  220. restore_cursor = 126;
  221. row_address = 127;
  222. save_cursor = 128;
  223. scroll_forward = 129;
  224. scroll_reverse = 130;
  225. set_attributes = 131;
  226. set_tab = 132;
  227. set_window = 133;
  228. tab = 134;
  229. to_status_line = 135;
  230. underline_char = 136;
  231. up_half_line = 137;
  232. init_prog = 138;
  233. key_a1 = 139;
  234. key_a3 = 140;
  235. key_b2 = 141;
  236. key_c1 = 142;
  237. key_c3 = 143;
  238. prtr_non = 144;
  239. char_padding = 145;
  240. acs_chars = 146;
  241. plab_norm = 147;
  242. key_btab = 148;
  243. enter_xon_mode = 149;
  244. exit_xon_mode = 150;
  245. enter_am_mode = 151;
  246. exit_am_mode = 152;
  247. xon_character = 153;
  248. xoff_character = 154;
  249. ena_acs = 155;
  250. label_on = 156;
  251. label_off = 157;
  252. key_beg = 158;
  253. key_cancel = 159;
  254. key_close = 160;
  255. key_command = 161;
  256. key_copy = 162;
  257. key_create = 163;
  258. key_end = 164;
  259. key_enter = 165;
  260. key_exit = 166;
  261. key_find = 167;
  262. key_help = 168;
  263. key_mark = 169;
  264. key_message = 170;
  265. key_move = 171;
  266. key_next = 172;
  267. key_open = 173;
  268. key_options = 174;
  269. key_previous = 175;
  270. key_print = 176;
  271. key_redo = 177;
  272. key_reference = 178;
  273. key_refresh = 179;
  274. key_replace = 180;
  275. key_restart = 181;
  276. key_resume = 182;
  277. key_save = 183;
  278. key_suspend = 184;
  279. key_undo = 185;
  280. key_sbeg = 186;
  281. key_scancel = 187;
  282. key_scommand = 188;
  283. key_scopy = 189;
  284. key_screate = 190;
  285. key_sdc = 191;
  286. key_sdl = 192;
  287. key_select = 193;
  288. key_send = 194;
  289. key_seol = 195;
  290. key_sexit = 196;
  291. key_sfind = 197;
  292. key_shelp = 198;
  293. key_shome = 199;
  294. key_sic = 200;
  295. key_sleft = 201;
  296. key_smessage = 202;
  297. key_smove = 203;
  298. key_snext = 204;
  299. key_soptions = 205;
  300. key_sprevious = 206;
  301. key_sprint = 207;
  302. key_sredo = 208;
  303. key_sreplace = 209;
  304. key_sright = 210;
  305. key_srsume = 211;
  306. key_ssave = 212;
  307. key_ssuspend = 213;
  308. key_sundo = 214;
  309. req_for_input = 215;
  310. key_f11 = 216;
  311. key_f12 = 217;
  312. key_f13 = 218;
  313. key_f14 = 219;
  314. key_f15 = 220;
  315. key_f16 = 221;
  316. key_f17 = 222;
  317. key_f18 = 223;
  318. key_f19 = 224;
  319. key_f20 = 225;
  320. key_f21 = 226;
  321. key_f22 = 227;
  322. key_f23 = 228;
  323. key_f24 = 229;
  324. key_f25 = 230;
  325. key_f26 = 231;
  326. key_f27 = 232;
  327. key_f28 = 233;
  328. key_f29 = 234;
  329. key_f30 = 235;
  330. key_f31 = 236;
  331. key_f32 = 237;
  332. key_f33 = 238;
  333. key_f34 = 239;
  334. key_f35 = 240;
  335. key_f36 = 241;
  336. key_f37 = 242;
  337. key_f38 = 243;
  338. key_f39 = 244;
  339. key_f40 = 245;
  340. key_f41 = 246;
  341. key_f42 = 247;
  342. key_f43 = 248;
  343. key_f44 = 249;
  344. key_f45 = 250;
  345. key_f46 = 251;
  346. key_f47 = 252;
  347. key_f48 = 253;
  348. key_f49 = 254;
  349. key_f50 = 255;
  350. key_f51 = 256;
  351. key_f52 = 257;
  352. key_f53 = 258;
  353. key_f54 = 259;
  354. key_f55 = 260;
  355. key_f56 = 261;
  356. key_f57 = 262;
  357. key_f58 = 263;
  358. key_f59 = 264;
  359. key_f60 = 265;
  360. key_f61 = 266;
  361. key_f62 = 267;
  362. key_f63 = 268;
  363. clr_bol = 269;
  364. clear_margins = 270;
  365. set_left_margin = 271;
  366. set_right_margin = 272;
  367. label_format = 273;
  368. set_clock = 274;
  369. display_clock = 275;
  370. remove_clock = 276;
  371. create_window = 277;
  372. goto_window = 278;
  373. hangup = 279;
  374. dial_phone = 280;
  375. quick_dial = 281;
  376. tone = 282;
  377. pulse = 283;
  378. flash_hook = 284;
  379. fixed_pause = 285;
  380. wait_tone = 286;
  381. user0 = 287;
  382. user1 = 288;
  383. user2 = 289;
  384. user3 = 290;
  385. user4 = 291;
  386. user5 = 292;
  387. user6 = 293;
  388. user7 = 294;
  389. user8 = 295;
  390. user9 = 296;
  391. orig_pair = 297;
  392. orig_colors = 298;
  393. initialize_color = 299;
  394. initialize_pair = 300;
  395. set_color_pair = 301;
  396. set_foreground = 302;
  397. set_background = 303;
  398. change_char_pitch = 304;
  399. change_line_pitch = 305;
  400. change_res_horz = 306;
  401. change_res_vert = 307;
  402. define_char = 308;
  403. enter_doublewide_mode = 309;
  404. enter_draft_quality = 310;
  405. enter_italics_mode = 311;
  406. enter_leftward_mode = 312;
  407. enter_micro_mode = 313;
  408. enter_near_letter_quality = 314;
  409. enter_normal_quality = 315;
  410. enter_shadow_mode = 316;
  411. enter_subscript_mode = 317;
  412. enter_superscript_mode = 318;
  413. enter_upward_mode = 319;
  414. exit_doublewide_mode = 320;
  415. exit_italics_mode = 321;
  416. exit_leftward_mode = 322;
  417. exit_micro_mode = 323;
  418. exit_shadow_mode = 324;
  419. exit_subscript_mode = 325;
  420. exit_superscript_mode = 326;
  421. exit_upward_mode = 327;
  422. micro_column_address = 328;
  423. micro_down = 329;
  424. micro_left = 330;
  425. micro_right = 331;
  426. micro_row_address = 332;
  427. micro_up = 333;
  428. order_of_pins = 334;
  429. parm_down_micro = 335;
  430. parm_left_micro = 336;
  431. parm_right_micro = 337;
  432. parm_up_micro = 338;
  433. select_char_set = 339;
  434. set_bottom_margin = 340;
  435. set_bottom_margin_parm = 341;
  436. set_left_margin_parm = 342;
  437. set_right_margin_parm = 343;
  438. set_top_margin = 344;
  439. set_top_margin_parm = 345;
  440. start_bit_image = 346;
  441. start_char_set_def = 347;
  442. stop_bit_image = 348;
  443. stop_char_set_def = 349;
  444. subscript_characters = 350;
  445. superscript_characters = 351;
  446. these_cause_cr = 352;
  447. zero_motion = 353;
  448. char_set_names = 354;
  449. key_mouse = 355;
  450. mouse_info = 356;
  451. req_mouse_pos = 357;
  452. get_mouse = 358;
  453. set_a_foreground = 359;
  454. set_a_background = 360;
  455. pkey_plab = 361;
  456. device_type = 362;
  457. code_set_init = 363;
  458. set0_des_seq = 364;
  459. set1_des_seq = 365;
  460. set2_des_seq = 366;
  461. set3_des_seq = 367;
  462. set_lr_margin = 368;
  463. set_tb_margin = 369;
  464. bit_image_repeat = 370;
  465. bit_image_newline = 371;
  466. bit_image_carriage_return = 372;
  467. color_names = 373;
  468. define_bit_image_region = 374;
  469. end_bit_image_region = 375;
  470. set_color_band = 376;
  471. set_page_length = 377;
  472. display_pc_char = 378;
  473. enter_pc_charset_mode = 379;
  474. exit_pc_charset_mode = 380;
  475. enter_scancode_mode = 381;
  476. exit_scancode_mode = 382;
  477. pc_term_options = 383;
  478. scancode_escape = 384;
  479. alt_scancode_esc = 385;
  480. enter_horizontal_hl_mode = 386;
  481. enter_left_hl_mode = 387;
  482. enter_low_hl_mode = 388;
  483. enter_right_hl_mode = 389;
  484. enter_top_hl_mode = 390;
  485. enter_vertical_hl_mode = 391;
  486. { older synonyms for some booleans }
  487. beehive_glitch = no_esc_ctlc;
  488. teleray_glitch = dest_tabs_magic_smso;
  489. micro_col_size = micro_char_size;
  490. { internal }
  491. termcap_init2 = 392;
  492. termcap_reset = 393;
  493. magic_cookie_glitch_ul = 33;
  494. backspaces_with_bs = 37;
  495. crt_no_scrolling = 38;
  496. no_correctly_working_cr = 39;
  497. carriage_return_delay = 34;
  498. new_line_delay = 35;
  499. linefeed_if_not_lf = 394;
  500. backspace_if_not_bs = 395;
  501. gnu_has_meta_key = 40;
  502. linefeed_is_newline = 41;
  503. backspace_delay = 36;
  504. horizontal_tab_delay = 37;
  505. number_of_function_keys = 38;
  506. other_non_function_keys = 396;
  507. arrow_key_map = 397;
  508. has_hardware_tabs = 42;
  509. return_does_clr_eol = 43;
  510. acs_ulcorner = 398;
  511. acs_llcorner = 399;
  512. acs_urcorner = 400;
  513. acs_lrcorner = 401;
  514. acs_ltee = 402;
  515. acs_rtee = 403;
  516. acs_btee = 404;
  517. acs_ttee = 405;
  518. acs_hline = 406;
  519. acs_vline = 407;
  520. acs_plus = 408;
  521. memory_lock = 409;
  522. memory_unlock = 410;
  523. box_chars_1 = 411;
  524. const
  525. NCCS = 32;
  526. BoolCount = 44;
  527. NumCount = 39;
  528. StrCount = 412;
  529. type
  530. TCFlag_t = Longint;
  531. Speed_t = Longint;
  532. TermIOS = record
  533. c_iflag, c_oflag, c_cflag, c_lflag: TCFlag_t;
  534. c_line: Byte;
  535. c_cc: array [0..NCCS-1] of Char;
  536. c_ispeed, c_ospeed: Speed_t;
  537. Pad: word;
  538. end;
  539. TT_BoolArray = array [0..BoolCount - 1] of Boolean;
  540. TT_WordArray = array [0..NumCount - 1] of Word;
  541. TT_PCharArray = array [0..StrCount - 1] of PChar;
  542. TermType4 = record
  543. Term_Names: PChar;
  544. Str_Table: PChar;
  545. Booleans: TT_BoolArray;
  546. Numbers: TT_WordArray;
  547. Strings: TT_PCharArray;
  548. end;
  549. Terminal_ptr4 = ^Terminal4;
  550. Terminal4 = record
  551. TType: TermType4;
  552. FileDes: Word;
  553. Ottyb, Nttyb: Termios;
  554. Pad: longint;
  555. end;
  556. TermType5 = record
  557. Term_Names: PChar;
  558. Str_Table: PChar;
  559. Booleans: ^TT_BoolArray;
  560. Numbers: ^TT_WordArray;
  561. Strings: ^TT_PCharArray;
  562. end;
  563. Terminal_ptr5 = ^Terminal5;
  564. Terminal5 = record
  565. TType: TermType5;
  566. FileDes: Word;
  567. Ottyb, Nttyb: Termios;
  568. Pad: longint;
  569. end;
  570. TerminalCommon_ptr1 = ^TerminalCommon1;
  571. TerminalCommon1 = record
  572. Term_Names: PChar;
  573. Str_Table: PChar;
  574. end;
  575. TerminalCommon_ptr2 = ^TerminalCommon2;
  576. TerminalCommon2 = record
  577. FileDes: Word;
  578. Ottyb, Nttyb: Termios;
  579. Pad: longint;
  580. end;
  581. WriterFunc = function (P: PChar): Longint;
  582. var
  583. {$ifndef darwin}
  584. cur_term : TerminalCommon_ptr1; cvar; external;
  585. {$else darwin}
  586. cur_term : TerminalCommon_ptr1; external curseslib name 'cur_term';
  587. {$endif darwin}
  588. cur_term_booleans: ^TT_BoolArray;
  589. cur_term_numbers: ^TT_WordArray;
  590. cur_term_strings: ^TT_PCharArray;
  591. cur_term_common: TerminalCommon_ptr2;
  592. const
  593. cur_term_valid : boolean = false;
  594. { Note: the following two procedures expect a pointer to a full terminfo }
  595. { structure, not just to the common parts. However, since this structure }
  596. { differs for different versions of ncurses,it's impossible to give a }
  597. { general declaration here which is correct (JM) }
  598. function set_curterm(term: TerminalCommon_ptr1): TerminalCommon_ptr1;cdecl; external curseslib name 'set_curterm';
  599. function del_curterm(term: TerminalCommon_ptr1): Longint;
  600. { sets whether to use environment variables for LINES and COLUMNS }
  601. procedure use_env(B: Longint); cdecl; external curseslib name 'use_env';
  602. function putp(Ndx: Longint): Longint;
  603. { this function must be called before any terminal properties are accessed }
  604. function setupterm(Term: PChar; fd: Longint; var ErrCode: Longint): Longint;
  605. { reinitialize lib }
  606. function restartterm(Term: PChar; fd: Longint; var ErrCode: Longint): Longint; cdecl; external curseslib name 'restartterm';
  607. {function tgetent(P1, P2: PChar): Longint;
  608. function tgetflag(P: PChar): Longint;
  609. function tgetnum(P: PChar): Longint;
  610. function tgoto(P: PChar; L1, L2: Longint): PChar;
  611. function tgetstr(P: PChar; var R: PChar): PChar;
  612. function tigetflag(P: PChar): Longint;
  613. function tigetnum(P: PChar): Longint;
  614. function tigetstr(P: PChar): PChar;
  615. function tparm(P: PChar, ...): PChar;
  616. function tparam(const char *, char *, int, ...): PChar;}
  617. function tputs(Ndx: Word; L1: Longint; F: WriterFunc): Longint;
  618. implementation
  619. uses
  620. baseUnix;
  621. function putp(Ndx: Longint): Longint;
  622. var
  623. P: PChar;
  624. begin
  625. if not assigned(cur_term) then
  626. RunError(219);
  627. P := cur_term_strings^[Ndx];
  628. putp := fpWrite(cur_term_common^.filedes, P^, StrLen(P));
  629. end;
  630. function tputs(Ndx: Word; L1: Longint; F: WriterFunc): Longint;
  631. var
  632. P: PChar;
  633. begin
  634. if not assigned(cur_term) then
  635. RunError(219);
  636. { L1 := L1; why was this here ?? PM }
  637. P := cur_term_strings^[Ndx];
  638. tputs := F(P);
  639. end;
  640. //function set_curterm(term: TerminalCommon_ptr1): TerminalCommon_ptr1; cdecl; external curseslib;
  641. // function restartterm(Term: PChar; fd: Longint; var ErrCode: Longint): Longint; cdecl; external curseslib;
  642. function setuptermC(Term: PChar; fd: Longint; var ErrCode: Longint): Longint; cdecl; external curseslib name 'setupterm';
  643. function setupterm(Term: PChar; fd: Longint; var ErrCode: Longint): Longint;
  644. var
  645. versioncheck: longint;
  646. begin
  647. setupterm := setuptermC(term,fd,errcode);
  648. if not assigned(cur_term) then
  649. exit;
  650. cur_term_valid := true;
  651. versioncheck := 0;
  652. repeat
  653. if (Terminal_ptr4(cur_term)^.ttype.Booleans[versioncheck] in [false,true]) then
  654. inc(versioncheck)
  655. else versioncheck := -1;
  656. until (versioncheck = BoolCount) or
  657. (versioncheck = -1);
  658. if versioncheck = BoolCount then
  659. { version 4.x }
  660. begin
  661. cur_term_booleans := @Terminal_ptr4(cur_term)^.ttype.Booleans;
  662. cur_term_numbers := @Terminal_ptr4(cur_term)^.ttype.Numbers;
  663. cur_term_strings := @Terminal_ptr4(cur_term)^.ttype.Strings;
  664. cur_term_common := pointer(@Terminal_ptr4(cur_term)^.FileDes);
  665. end
  666. else
  667. { assume 5.x or higher }
  668. begin
  669. cur_term_booleans := Terminal_ptr5(cur_term)^.ttype.Booleans;
  670. cur_term_numbers := Terminal_ptr5(cur_term)^.ttype.Numbers;
  671. cur_term_strings := Terminal_ptr5(cur_term)^.ttype.Strings;
  672. cur_term_common := pointer(@Terminal_ptr5(cur_term)^.FileDes);
  673. end;
  674. end;
  675. function del_curtermC(term: TerminalCommon_ptr1): Longint; cdecl; external curseslib name 'del_curterm';
  676. function del_curterm(term: TerminalCommon_ptr1): Longint;
  677. var
  678. reset_cur_term : boolean;
  679. begin
  680. if term=cur_term then
  681. begin
  682. cur_term_booleans := nil;
  683. cur_term_numbers := nil;
  684. cur_term_strings := nil;
  685. cur_term_common := nil;
  686. reset_cur_term := true;
  687. end
  688. else
  689. reset_cur_term := false;
  690. del_curterm := del_curtermC(term);
  691. if reset_cur_term then
  692. cur_term_valid := false;
  693. end;
  694. {function tgetent(P1, P2: PChar): Longint; cdecl; external;
  695. function tgetflag(P: PChar): Longint; cdecl; external;
  696. function tgetnum(P: PChar): Longint; cdecl; external;
  697. function tgoto(P: PChar; L1, L2: Longint): PChar; cdecl; external;
  698. function tgetstr(P: PChar; var R: PChar): PChar; cdecl; external;
  699. function tigetflag(P: PChar): Longint; cdecl; external;
  700. function tigetnum(P: PChar): Longint; cdecl; external;
  701. function tigetstr(P: PChar): PChar; cdecl; external;
  702. function tparm(P: PChar; ...): PChar; cdecl; external;
  703. function tparam(const char *, char *, int, ...): PChar; cdecl; external;}
  704. end.