2
0

terminfo.pp 26 KB

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