terminfo.pas 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794
  1. {
  2. $Id$
  3. An interface unit for the terminfo database
  4. Copyright (c) 1997 Balazs Scheidler ([email protected])
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public
  7. License as published by the Free Software Foundation; either
  8. version 2 of the License, or (at your option) any later version.
  9. This library 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. See the GNU
  12. Library General Public License for more details.
  13. You should have received a copy of the GNU Library General Public
  14. License along with this library; if not, write to the Free
  15. Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************}
  17. unit TermInfo;
  18. interface
  19. {$linklib ncurses}
  20. {$linklib c}
  21. {$packrecords c}
  22. const
  23. { boolean values }
  24. auto_left_margin = 0;
  25. auto_right_margin = 1;
  26. no_esc_ctlc = 2;
  27. ceol_standout_glitch = 3;
  28. eat_newline_glitch = 4;
  29. erase_overstrike = 5;
  30. generic_type = 6;
  31. hard_copy = 7;
  32. has_meta_key = 8;
  33. has_status_line = 9;
  34. insert_null_glitch = 10;
  35. memory_above = 11;
  36. memory_below = 12;
  37. move_insert_mode = 13;
  38. move_standout_mode = 14;
  39. over_strike = 15;
  40. status_line_esc_ok = 16;
  41. dest_tabs_magic_smso = 17;
  42. tilde_glitch = 18;
  43. transparent_underline = 19;
  44. xon_xoff = 20;
  45. needs_xon_xoff = 21;
  46. prtr_silent = 22;
  47. hard_cursor = 23;
  48. non_rev_rmcup = 24;
  49. no_pad_char = 25;
  50. non_dest_scroll_region = 26;
  51. can_change = 27;
  52. back_color_erase = 28;
  53. hue_lightness_saturation = 29;
  54. col_addr_glitch = 30;
  55. cr_cancels_micro_mode = 31;
  56. has_print_wheel = 32;
  57. row_addr_glitch = 33;
  58. semi_auto_right_margin = 34;
  59. cpi_changes_res = 35;
  60. lpi_changes_res = 36;
  61. { numbers ... }
  62. columns = 0;
  63. init_tabs = 1;
  64. lines = 2;
  65. lines_of_memory = 3;
  66. magic_cookie_glitch = 4;
  67. padding_baud_rate = 5;
  68. virtual_terminal = 6;
  69. width_status_line = 7;
  70. num_labels = 8;
  71. label_height = 9;
  72. label_width = 10;
  73. max_attributes = 11;
  74. maximum_windows = 12;
  75. max_colors = 13;
  76. max_pairs = 14;
  77. no_color_video = 15;
  78. buffer_capacity = 16;
  79. dot_vert_spacing = 17;
  80. dot_horz_spacing = 18;
  81. max_micro_address = 19;
  82. max_micro_jump = 20;
  83. micro_char_size = 21;
  84. micro_line_size = 22;
  85. number_of_pins = 23;
  86. output_res_char = 24;
  87. output_res_line = 25;
  88. output_res_horz_inch = 26;
  89. output_res_vert_inch = 27;
  90. print_rate = 28;
  91. wide_char_size = 29;
  92. buttons = 30;
  93. bit_image_entwining = 31;
  94. bit_image_type = 32;
  95. { strings }
  96. back_tab = 0;
  97. bell = 1;
  98. carriage_return = 2;
  99. change_scroll_region = 3;
  100. clear_all_tabs = 4;
  101. clear_screen = 5;
  102. clr_eol = 6;
  103. clr_eos = 7;
  104. column_address = 8;
  105. command_character = 9;
  106. cursor_address = 10;
  107. cursor_down = 11;
  108. cursor_home = 12;
  109. cursor_invisible = 13;
  110. cursor_left = 14;
  111. cursor_mem_address = 15;
  112. cursor_normal = 16;
  113. cursor_right = 17;
  114. cursor_to_ll = 18;
  115. cursor_up = 19;
  116. cursor_visible = 20;
  117. delete_character = 21;
  118. delete_line = 22;
  119. dis_status_line = 23;
  120. down_half_line = 24;
  121. enter_alt_charset_mode = 25;
  122. enter_blink_mode = 26;
  123. enter_bold_mode = 27;
  124. enter_ca_mode = 28;
  125. enter_delete_mode = 29;
  126. enter_dim_mode = 30;
  127. enter_insert_mode = 31;
  128. enter_secure_mode = 32;
  129. enter_protected_mode = 33;
  130. enter_reverse_mode = 34;
  131. enter_standout_mode = 35;
  132. enter_underline_mode = 36;
  133. erase_chars = 37;
  134. exit_alt_charset_mode = 38;
  135. exit_attribute_mode = 39;
  136. exit_ca_mode = 40;
  137. exit_delete_mode = 41;
  138. exit_insert_mode = 42;
  139. exit_standout_mode = 43;
  140. exit_underline_mode = 44;
  141. flash_screen = 45;
  142. form_feed = 46;
  143. from_status_line = 47;
  144. init_1string = 48;
  145. init_2string = 49;
  146. init_3string = 50;
  147. init_file = 51;
  148. insert_character = 52;
  149. insert_line = 53;
  150. insert_padding = 54;
  151. key_backspace = 55;
  152. key_catab = 56;
  153. key_clear = 57;
  154. key_ctab = 58;
  155. key_dc = 59;
  156. key_dl = 60;
  157. key_down = 61;
  158. key_eic = 62;
  159. key_eol = 63;
  160. key_eos = 64;
  161. key_f0 = 65;
  162. key_f1 = 66;
  163. key_f10 = 67;
  164. key_f2 = 68;
  165. key_f3 = 69;
  166. key_f4 = 70;
  167. key_f5 = 71;
  168. key_f6 = 72;
  169. key_f7 = 73;
  170. key_f8 = 74;
  171. key_f9 = 75;
  172. key_home = 76;
  173. key_ic = 77;
  174. key_il = 78;
  175. key_left = 79;
  176. key_ll = 80;
  177. key_npage = 81;
  178. key_ppage = 82;
  179. key_right = 83;
  180. key_sf = 84;
  181. key_sr = 85;
  182. key_stab = 86;
  183. key_up = 87;
  184. keypad_local = 88;
  185. keypad_xmit = 89;
  186. lab_f0 = 90;
  187. lab_f1 = 91;
  188. lab_f10 = 92;
  189. lab_f2 = 93;
  190. lab_f3 = 94;
  191. lab_f4 = 95;
  192. lab_f5 = 96;
  193. lab_f6 = 97;
  194. lab_f7 = 98;
  195. lab_f8 = 99;
  196. lab_f9 = 100;
  197. meta_off = 101;
  198. meta_on = 102;
  199. newline = 103;
  200. pad_char = 104;
  201. parm_dch = 105;
  202. parm_delete_line = 106;
  203. parm_down_cursor = 107;
  204. parm_ich = 108;
  205. parm_index = 109;
  206. parm_insert_line = 110;
  207. parm_left_cursor = 111;
  208. parm_right_cursor = 112;
  209. parm_rindex = 113;
  210. parm_up_cursor = 114;
  211. pkey_key = 115;
  212. pkey_local = 116;
  213. pkey_xmit = 117;
  214. print_screen = 118;
  215. prtr_off = 119;
  216. prtr_on = 120;
  217. repeat_char = 121;
  218. reset_1string = 122;
  219. reset_2string = 123;
  220. reset_3string = 124;
  221. reset_file = 125;
  222. restore_cursor = 126;
  223. row_address = 127;
  224. save_cursor = 128;
  225. scroll_forward = 129;
  226. scroll_reverse = 130;
  227. set_attributes = 131;
  228. set_tab = 132;
  229. set_window = 133;
  230. tab = 134;
  231. to_status_line = 135;
  232. underline_char = 136;
  233. up_half_line = 137;
  234. init_prog = 138;
  235. key_a1 = 139;
  236. key_a3 = 140;
  237. key_b2 = 141;
  238. key_c1 = 142;
  239. key_c3 = 143;
  240. prtr_non = 144;
  241. char_padding = 145;
  242. acs_chars = 146;
  243. plab_norm = 147;
  244. key_btab = 148;
  245. enter_xon_mode = 149;
  246. exit_xon_mode = 150;
  247. enter_am_mode = 151;
  248. exit_am_mode = 152;
  249. xon_character = 153;
  250. xoff_character = 154;
  251. ena_acs = 155;
  252. label_on = 156;
  253. label_off = 157;
  254. key_beg = 158;
  255. key_cancel = 159;
  256. key_close = 160;
  257. key_command = 161;
  258. key_copy = 162;
  259. key_create = 163;
  260. key_end = 164;
  261. key_enter = 165;
  262. key_exit = 166;
  263. key_find = 167;
  264. key_help = 168;
  265. key_mark = 169;
  266. key_message = 170;
  267. key_move = 171;
  268. key_next = 172;
  269. key_open = 173;
  270. key_options = 174;
  271. key_previous = 175;
  272. key_print = 176;
  273. key_redo = 177;
  274. key_reference = 178;
  275. key_refresh = 179;
  276. key_replace = 180;
  277. key_restart = 181;
  278. key_resume = 182;
  279. key_save = 183;
  280. key_suspend = 184;
  281. key_undo = 185;
  282. key_sbeg = 186;
  283. key_scancel = 187;
  284. key_scommand = 188;
  285. key_scopy = 189;
  286. key_screate = 190;
  287. key_sdc = 191;
  288. key_sdl = 192;
  289. key_select = 193;
  290. key_send = 194;
  291. key_seol = 195;
  292. key_sexit = 196;
  293. key_sfind = 197;
  294. key_shelp = 198;
  295. key_shome = 199;
  296. key_sic = 200;
  297. key_sleft = 201;
  298. key_smessage = 202;
  299. key_smove = 203;
  300. key_snext = 204;
  301. key_soptions = 205;
  302. key_sprevious = 206;
  303. key_sprint = 207;
  304. key_sredo = 208;
  305. key_sreplace = 209;
  306. key_sright = 210;
  307. key_srsume = 211;
  308. key_ssave = 212;
  309. key_ssuspend = 213;
  310. key_sundo = 214;
  311. req_for_input = 215;
  312. key_f11 = 216;
  313. key_f12 = 217;
  314. key_f13 = 218;
  315. key_f14 = 219;
  316. key_f15 = 220;
  317. key_f16 = 221;
  318. key_f17 = 222;
  319. key_f18 = 223;
  320. key_f19 = 224;
  321. key_f20 = 225;
  322. key_f21 = 226;
  323. key_f22 = 227;
  324. key_f23 = 228;
  325. key_f24 = 229;
  326. key_f25 = 230;
  327. key_f26 = 231;
  328. key_f27 = 232;
  329. key_f28 = 233;
  330. key_f29 = 234;
  331. key_f30 = 235;
  332. key_f31 = 236;
  333. key_f32 = 237;
  334. key_f33 = 238;
  335. key_f34 = 239;
  336. key_f35 = 240;
  337. key_f36 = 241;
  338. key_f37 = 242;
  339. key_f38 = 243;
  340. key_f39 = 244;
  341. key_f40 = 245;
  342. key_f41 = 246;
  343. key_f42 = 247;
  344. key_f43 = 248;
  345. key_f44 = 249;
  346. key_f45 = 250;
  347. key_f46 = 251;
  348. key_f47 = 252;
  349. key_f48 = 253;
  350. key_f49 = 254;
  351. key_f50 = 255;
  352. key_f51 = 256;
  353. key_f52 = 257;
  354. key_f53 = 258;
  355. key_f54 = 259;
  356. key_f55 = 260;
  357. key_f56 = 261;
  358. key_f57 = 262;
  359. key_f58 = 263;
  360. key_f59 = 264;
  361. key_f60 = 265;
  362. key_f61 = 266;
  363. key_f62 = 267;
  364. key_f63 = 268;
  365. clr_bol = 269;
  366. clear_margins = 270;
  367. set_left_margin = 271;
  368. set_right_margin = 272;
  369. label_format = 273;
  370. set_clock = 274;
  371. display_clock = 275;
  372. remove_clock = 276;
  373. create_window = 277;
  374. goto_window = 278;
  375. hangup = 279;
  376. dial_phone = 280;
  377. quick_dial = 281;
  378. tone = 282;
  379. pulse = 283;
  380. flash_hook = 284;
  381. fixed_pause = 285;
  382. wait_tone = 286;
  383. user0 = 287;
  384. user1 = 288;
  385. user2 = 289;
  386. user3 = 290;
  387. user4 = 291;
  388. user5 = 292;
  389. user6 = 293;
  390. user7 = 294;
  391. user8 = 295;
  392. user9 = 296;
  393. orig_pair = 297;
  394. orig_colors = 298;
  395. initialize_color = 299;
  396. initialize_pair = 300;
  397. set_color_pair = 301;
  398. set_foreground = 302;
  399. set_background = 303;
  400. change_char_pitch = 304;
  401. change_line_pitch = 305;
  402. change_res_horz = 306;
  403. change_res_vert = 307;
  404. define_char = 308;
  405. enter_doublewide_mode = 309;
  406. enter_draft_quality = 310;
  407. enter_italics_mode = 311;
  408. enter_leftward_mode = 312;
  409. enter_micro_mode = 313;
  410. enter_near_letter_quality = 314;
  411. enter_normal_quality = 315;
  412. enter_shadow_mode = 316;
  413. enter_subscript_mode = 317;
  414. enter_superscript_mode = 318;
  415. enter_upward_mode = 319;
  416. exit_doublewide_mode = 320;
  417. exit_italics_mode = 321;
  418. exit_leftward_mode = 322;
  419. exit_micro_mode = 323;
  420. exit_shadow_mode = 324;
  421. exit_subscript_mode = 325;
  422. exit_superscript_mode = 326;
  423. exit_upward_mode = 327;
  424. micro_column_address = 328;
  425. micro_down = 329;
  426. micro_left = 330;
  427. micro_right = 331;
  428. micro_row_address = 332;
  429. micro_up = 333;
  430. order_of_pins = 334;
  431. parm_down_micro = 335;
  432. parm_left_micro = 336;
  433. parm_right_micro = 337;
  434. parm_up_micro = 338;
  435. select_char_set = 339;
  436. set_bottom_margin = 340;
  437. set_bottom_margin_parm = 341;
  438. set_left_margin_parm = 342;
  439. set_right_margin_parm = 343;
  440. set_top_margin = 344;
  441. set_top_margin_parm = 345;
  442. start_bit_image = 346;
  443. start_char_set_def = 347;
  444. stop_bit_image = 348;
  445. stop_char_set_def = 349;
  446. subscript_characters = 350;
  447. superscript_characters = 351;
  448. these_cause_cr = 352;
  449. zero_motion = 353;
  450. char_set_names = 354;
  451. key_mouse = 355;
  452. mouse_info = 356;
  453. req_mouse_pos = 357;
  454. get_mouse = 358;
  455. set_a_foreground = 359;
  456. set_a_background = 360;
  457. pkey_plab = 361;
  458. device_type = 362;
  459. code_set_init = 363;
  460. set0_des_seq = 364;
  461. set1_des_seq = 365;
  462. set2_des_seq = 366;
  463. set3_des_seq = 367;
  464. set_lr_margin = 368;
  465. set_tb_margin = 369;
  466. bit_image_repeat = 370;
  467. bit_image_newline = 371;
  468. bit_image_carriage_return = 372;
  469. color_names = 373;
  470. define_bit_image_region = 374;
  471. end_bit_image_region = 375;
  472. set_color_band = 376;
  473. set_page_length = 377;
  474. display_pc_char = 378;
  475. enter_pc_charset_mode = 379;
  476. exit_pc_charset_mode = 380;
  477. enter_scancode_mode = 381;
  478. exit_scancode_mode = 382;
  479. pc_term_options = 383;
  480. scancode_escape = 384;
  481. alt_scancode_esc = 385;
  482. enter_horizontal_hl_mode = 386;
  483. enter_left_hl_mode = 387;
  484. enter_low_hl_mode = 388;
  485. enter_right_hl_mode = 389;
  486. enter_top_hl_mode = 390;
  487. enter_vertical_hl_mode = 391;
  488. { older synonyms for some booleans }
  489. beehive_glitch = no_esc_ctlc;
  490. teleray_glitch = dest_tabs_magic_smso;
  491. micro_col_size = micro_char_size;
  492. { internal }
  493. termcap_init2 = 392;
  494. termcap_reset = 393;
  495. magic_cookie_glitch_ul = 33;
  496. backspaces_with_bs = 37;
  497. crt_no_scrolling = 38;
  498. no_correctly_working_cr = 39;
  499. carriage_return_delay = 34;
  500. new_line_delay = 35;
  501. linefeed_if_not_lf = 394;
  502. backspace_if_not_bs = 395;
  503. gnu_has_meta_key = 40;
  504. linefeed_is_newline = 41;
  505. backspace_delay = 36;
  506. horizontal_tab_delay = 37;
  507. number_of_function_keys = 38;
  508. other_non_function_keys = 396;
  509. arrow_key_map = 397;
  510. has_hardware_tabs = 42;
  511. return_does_clr_eol = 43;
  512. acs_ulcorner = 398;
  513. acs_llcorner = 399;
  514. acs_urcorner = 400;
  515. acs_lrcorner = 401;
  516. acs_ltee = 402;
  517. acs_rtee = 403;
  518. acs_btee = 404;
  519. acs_ttee = 405;
  520. acs_hline = 406;
  521. acs_vline = 407;
  522. acs_plus = 408;
  523. memory_lock = 409;
  524. memory_unlock = 410;
  525. box_chars_1 = 411;
  526. const
  527. NCCS = 32;
  528. BoolCount = 44;
  529. NumCount = 39;
  530. StrCount = 412;
  531. type
  532. TCFlag_t = Longint;
  533. Speed_t = Longint;
  534. TermIOS = record
  535. c_iflag, c_oflag, c_cflag, c_lflag: TCFlag_t;
  536. c_line: Byte;
  537. c_cc: array [0..NCCS-1] of Char;
  538. c_ispeed, c_ospeed: Speed_t;
  539. Pad: word;
  540. end;
  541. TT_BoolArray = array [0..BoolCount - 1] of Boolean;
  542. TT_WordArray = array [0..NumCount - 1] of Word;
  543. TT_PCharArray = array [0..StrCount - 1] of PChar;
  544. TermType4 = record
  545. Term_Names: PChar;
  546. Str_Table: PChar;
  547. Booleans: TT_BoolArray;
  548. Numbers: TT_WordArray;
  549. Strings: TT_PCharArray;
  550. end;
  551. Terminal_ptr4 = ^Terminal4;
  552. Terminal4 = record
  553. TType: TermType4;
  554. FileDes: Word;
  555. Ottyb, Nttyb: Termios;
  556. Pad: longint;
  557. end;
  558. TermType5 = record
  559. Term_Names: PChar;
  560. Str_Table: PChar;
  561. Booleans: ^TT_BoolArray;
  562. Numbers: ^TT_WordArray;
  563. Strings: ^TT_PCharArray;
  564. end;
  565. Terminal_ptr5 = ^Terminal5;
  566. Terminal5 = record
  567. TType: TermType5;
  568. FileDes: Word;
  569. Ottyb, Nttyb: Termios;
  570. Pad: longint;
  571. end;
  572. TerminalCommon_ptr1 = ^TerminalCommon1;
  573. TerminalCommon1 = record
  574. Term_Names: PChar;
  575. Str_Table: PChar;
  576. end;
  577. TerminalCommon_ptr2 = ^TerminalCommon2;
  578. TerminalCommon2 = record
  579. FileDes: Word;
  580. Ottyb, Nttyb: Termios;
  581. Pad: longint;
  582. end;
  583. WriterFunc = function (P: PChar): Longint;
  584. var
  585. cur_term : TerminalCommon_ptr1; external name 'cur_term';
  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;
  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;
  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;
  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. Linux;
  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 := fdWrite(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;
  639. procedure use_env(B: Longint); cdecl; external;
  640. function restartterm(Term: PChar; fd: Longint; var ErrCode: Longint): Longint; cdecl; external;
  641. function setuptermC(Term: PChar; fd: Longint; var ErrCode: Longint): Longint; cdecl; external 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 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.2 2000-10-26 23:08:48 peter
  707. * merged freebsd from fixes
  708. Revision 1.1.2.1 2000/10/25 12:23:20 marco
  709. * Linux dir split up
  710. Revision 1.1.2.3 2000/10/09 16:29:14 pierre
  711. * more linux terminal fixes
  712. Revision 1.1.2.2 2000/08/02 12:30:36 jonas
  713. * improved version check *slightly*
  714. Revision 1.1 2000/07/13 06:29:39 michael
  715. + Initial import
  716. Revision 1.2 2000/06/30 12:28:57 jonas
  717. * fixed termtype structure
  718. Revision 1.1 2000/01/06 01:20:31 peter
  719. * moved out of packages/ back to topdir
  720. Revision 1.1 1999/11/24 23:36:38 peter
  721. * moved to packages dir
  722. Revision 1.3 1999/04/22 14:48:27 peter
  723. * remove asm
  724. Revision 1.2 1998/12/07 12:25:51 peter
  725. * link with ncurses which is more available the curses
  726. Revision 1.1 1998/12/04 12:48:30 peter
  727. * moved some dirs
  728. Revision 1.1 1998/10/26 11:31:47 peter
  729. + inital include files
  730. Revision 1.3 1998/10/26 09:36:26 peter
  731. * fixed cdecl
  732. Revision 1.2 1998/07/29 20:17:47 bazsi
  733. some updates to Video, it now uses terminfo. Some modifications for FreeVision.
  734. Revision 1.1 1998/06/13 12:38:54 bazsi
  735. }