terminfo.pp 26 KB

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