terminfo-0.8.0/.cargo_vcs_info.json0000644000000001360000000000100126640ustar { "git": { "sha1": "d670d6e5b1a8cbee59f9e5185c7cf6f7525eaa9d" }, "path_in_vcs": "" }terminfo-0.8.0/.gitignore000064400000000000000000000000221046102023000134360ustar 00000000000000target Cargo.lock terminfo-0.8.0/.travis.yml000064400000000000000000000000651046102023000135660ustar 00000000000000language: rust rust: - stable - beta - nightly terminfo-0.8.0/Cargo.lock0000644000000147660000000000100106550ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "dirs" version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" dependencies = [ "dirs-sys", ] [[package]] name = "dirs-sys" version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" dependencies = [ "libc", "redox_users", "winapi", ] [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "getrandom" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", "wasi", ] [[package]] name = "libc" version = "0.2.140" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" [[package]] name = "memchr" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "minimal-lexical" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "nom" version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" dependencies = [ "memchr", "minimal-lexical", ] [[package]] name = "phf" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "928c6535de93548188ef63bb7c4036bd415cd8f36ad25af44b9789b2ee72a48c" dependencies = [ "phf_shared", ] [[package]] name = "phf_codegen" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a56ac890c5e3ca598bbdeaa99964edb5b0258a583a9eb6ef4e89fc85d9224770" dependencies = [ "phf_generator", "phf_shared", ] [[package]] name = "phf_generator" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1181c94580fa345f50f19d738aaa39c0ed30a600d95cb2d3e23f94266f14fbf" dependencies = [ "phf_shared", "rand", ] [[package]] name = "phf_shared" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1fb5f6f826b772a8d4c0394209441e7d37cbbb967ae9c7e0e8134365c9ee676" dependencies = [ "siphasher", ] [[package]] name = "proc-macro2" version = "1.0.53" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba466839c78239c09faf015484e5cc04860f88242cff4d03eb038f04b4699b73" dependencies = [ "unicode-ident", ] [[package]] name = "quote" version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" dependencies = [ "proc-macro2", ] [[package]] name = "rand" version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "rand_core", ] [[package]] name = "rand_core" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" [[package]] name = "redox_syscall" version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ "bitflags", ] [[package]] name = "redox_users" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ "getrandom", "redox_syscall", "thiserror", ] [[package]] name = "siphasher" version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" [[package]] name = "syn" version = "2.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bcc02725fd69ab9f26eab07fad303e2497fad6fb9eba4f96c4d1687bdf704ad9" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "terminfo" version = "0.8.0" dependencies = [ "dirs", "fnv", "nom", "phf", "phf_codegen", ] [[package]] name = "thiserror" version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "unicode-ident" version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "winapi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ "winapi-i686-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu", ] [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" terminfo-0.8.0/Cargo.toml0000644000000020550000000000100106640ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" name = "terminfo" version = "0.8.0" authors = ["meh. "] build = "build.rs" description = "Terminal information." readme = "README.md" keywords = [ "terminal", "terminfo", "termcap", "term", ] categories = ["command-line-interface"] license = "WTFPL" repository = "https://github.com/meh/rust-terminfo" [dependencies.dirs] version = "4" [dependencies.fnv] version = "1.0" [dependencies.nom] version = "7" features = ["std"] default-features = false [dependencies.phf] version = "0.11" [build-dependencies.phf_codegen] version = "0.11" terminfo-0.8.0/Cargo.toml.orig000064400000000000000000000007651046102023000143530ustar 00000000000000[package] name = "terminfo" version = "0.8.0" edition = "2021" authors = ["meh. "] license = "WTFPL" description = "Terminal information." repository = "https://github.com/meh/rust-terminfo" keywords = ["terminal", "terminfo", "termcap", "term"] categories = ["command-line-interface"] build = "build.rs" [dependencies] dirs = "4" nom = { version = "7", default-features = false, features = ["std"] } phf = "0.11" fnv = "1.0" [build-dependencies] phf_codegen = "0.11" terminfo-0.8.0/LICENSE000064400000000000000000000007631046102023000124670ustar 00000000000000 DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 Copyleft (ↄ) meh. | http://meh.schizofreni.co Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed. DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. You just DO WHAT THE FUCK YOU WANT TO. terminfo-0.8.0/README.md000064400000000000000000000034011046102023000127310ustar 00000000000000terminfo ======== [![Crates.io](https://img.shields.io/crates/v/terminfo.svg)](https://crates.io/crates/terminfo) [![Crates.io](https://img.shields.io/crates/d/terminfo.svg)](https://crates.io/crates/terminfo) ![WTFPL](http://img.shields.io/badge/license-WTFPL-blue.svg) [![Build Status](https://api.travis-ci.org/meh/rust-terminfo.svg?branch=master)](https://travis-ci.org/meh/rust-terminfo) Terminal capabilities with type-safe getters. Example ------- ```rust extern crate terminfo; use std::io; use terminfo::{Database, capability as cap}; fn main() { let info = Database::from_env().unwrap(); if let Some(cap::MaxColors(n)) = info.get::() { println!("The terminal supports {} colors.", n); } else { println!("The terminal does not support colors, what year is this?"); } if let Some(flash) = info.get::() { flash.expand().to(io::stdout()).unwrap(); } else { println!("FLASH GORDON!"); } info.get::().unwrap().expand().color(2).to(io::stdout()).unwrap(); info.get::().unwrap().expand().color(4).to(io::stdout()).unwrap(); println!("SUP"); info.get::().unwrap().expand().to(io::stdout()).unwrap(); } ``` Packaging and Distributing -------------------------- For all terminals but windows consoles, this library depends on a non-hashed (for now) terminfo database being present. For example, on Debian derivitives, you should depend on ncurses-term; on Arch Linux, you depend on ncurses; and on MinGW, you should depend on mingw32-terminfo. Unfortunately, if you're using a non-windows console on Windows (e.g. MinGW, Cygwin, Git Bash), you'll need to set the TERMINFO environment variable to point to the directory containing the terminfo database. terminfo-0.8.0/build.rs000064400000000000000000000777531046102023000131440ustar 00000000000000extern crate phf_codegen; use std::env; use std::fs::File; use std::io::{BufWriter, Write}; use std::path::Path; #[rustfmt::skip] const BOOLEAN: &'static [&'static str] = &[ "auto_left_margin", "auto_right_margin", "no_esc_ctlc", "ceol_standout_glitch", "eat_newline_glitch", "erase_overstrike", "generic_type", "hard_copy", "has_meta_key", "has_status_line", "insert_null_glitch", "memory_above", "memory_below", "move_insert_mode", "move_standout_mode", "over_strike", "status_line_esc_ok", "dest_tabs_magic_smso", "tilde_glitch", "transparent_underline", "xon_xoff", "needs_xon_xoff", "prtr_silent", "hard_cursor", "non_rev_rmcup", "no_pad_char", "non_dest_scroll_region", "can_change", "back_color_erase", "hue_lightness_saturation", "col_addr_glitch", "cr_cancels_micro_mode", "has_print_wheel", "row_addr_glitch", "semi_auto_right_margin", "cpi_changes_res", "lpi_changes_res", "backspaces_with_bs", "crt_no_scrolling", "no_correctly_working_cr", "gnu_has_meta_key", "linefeed_is_newline", "has_hardware_tabs", "return_does_clr_eol" ]; #[rustfmt::skip] const NUMBER: &'static [&'static str] = &[ "columns", "init_tabs", "lines", "lines_of_memory", "magic_cookie_glitch", "padding_baud_rate", "virtual_terminal", "width_status_line", "num_labels", "label_height", "label_width", "max_attributes", "maximum_windows", "max_colors", "max_pairs", "no_color_video", "buffer_capacity", "dot_vert_spacing", "dot_horz_spacing", "max_micro_address", "max_micro_jump", "micro_col_size", "micro_line_size", "number_of_pins", "output_res_char", "output_res_line", "output_res_horz_inch", "output_res_vert_inch", "print_rate", "wide_char_size", "buttons", "bit_image_entwining", "bit_image_type", "magic_cookie_glitch_ul", "carriage_return_delay", "new_line_delay", "backspace_delay", "horizontal_tab_delay", "number_of_function_keys" ]; #[rustfmt::skip] const STRING: &'static [&'static str] = &[ "back_tab", "bell", "carriage_return", "change_scroll_region", "clear_all_tabs", "clear_screen", "clr_eol", "clr_eos", "column_address", "command_character", "cursor_address", "cursor_down", "cursor_home", "cursor_invisible", "cursor_left", "cursor_mem_address", "cursor_normal", "cursor_right", "cursor_to_ll", "cursor_up", "cursor_visible", "delete_character", "delete_line", "dis_status_line", "down_half_line", "enter_alt_charset_mode", "enter_blink_mode", "enter_bold_mode", "enter_ca_mode", "enter_delete_mode", "enter_dim_mode", "enter_insert_mode", "enter_secure_mode", "enter_protected_mode", "enter_reverse_mode", "enter_standout_mode", "enter_underline_mode", "erase_chars", "exit_alt_charset_mode", "exit_attribute_mode", "exit_ca_mode", "exit_delete_mode", "exit_insert_mode", "exit_standout_mode", "exit_underline_mode", "flash_screen", "form_feed", "from_status_line", "init_1string", "init_2string", "init_3string", "init_file", "insert_character", "insert_line", "insert_padding", "key_backspace", "key_catab", "key_clear", "key_ctab", "key_dc", "key_dl", "key_down", "key_eic", "key_eol", "key_eos", "key_f0", "key_f1", "key_f10", "key_f2", "key_f3", "key_f4", "key_f5", "key_f6", "key_f7", "key_f8", "key_f9", "key_home", "key_ic", "key_il", "key_left", "key_ll", "key_npage", "key_ppage", "key_right", "key_sf", "key_sr", "key_stab", "key_up", "keypad_local", "keypad_xmit", "lab_f0", "lab_f1", "lab_f10", "lab_f2", "lab_f3", "lab_f4", "lab_f5", "lab_f6", "lab_f7", "lab_f8", "lab_f9", "meta_off", "meta_on", "newline", "pad_char", "parm_dch", "parm_delete_line", "parm_down_cursor", "parm_ich", "parm_index", "parm_insert_line", "parm_left_cursor", "parm_right_cursor", "parm_rindex", "parm_up_cursor", "pkey_key", "pkey_local", "pkey_xmit", "print_screen", "prtr_off", "prtr_on", "repeat_char", "reset_1string", "reset_2string", "reset_3string", "reset_file", "restore_cursor", "row_address", "save_cursor", "scroll_forward", "scroll_reverse", "set_attributes", "set_tab", "set_window", "tab", "to_status_line", "underline_char", "up_half_line", "init_prog", "key_a1", "key_a3", "key_b2", "key_c1", "key_c3", "prtr_non", "char_padding", "acs_chars", "plab_norm", "key_btab", "enter_xon_mode", "exit_xon_mode", "enter_am_mode", "exit_am_mode", "xon_character", "xoff_character", "ena_acs", "label_on", "label_off", "key_beg", "key_cancel", "key_close", "key_command", "key_copy", "key_create", "key_end", "key_enter", "key_exit", "key_find", "key_help", "key_mark", "key_message", "key_move", "key_next", "key_open", "key_options", "key_previous", "key_print", "key_redo", "key_reference", "key_refresh", "key_replace", "key_restart", "key_resume", "key_save", "key_suspend", "key_undo", "key_sbeg", "key_scancel", "key_scommand", "key_scopy", "key_screate", "key_sdc", "key_sdl", "key_select", "key_send", "key_seol", "key_sexit", "key_sfind", "key_shelp", "key_shome", "key_sic", "key_sleft", "key_smessage", "key_smove", "key_snext", "key_soptions", "key_sprevious", "key_sprint", "key_sredo", "key_sreplace", "key_sright", "key_srsume", "key_ssave", "key_ssuspend", "key_sundo", "req_for_input", "key_f11", "key_f12", "key_f13", "key_f14", "key_f15", "key_f16", "key_f17", "key_f18", "key_f19", "key_f20", "key_f21", "key_f22", "key_f23", "key_f24", "key_f25", "key_f26", "key_f27", "key_f28", "key_f29", "key_f30", "key_f31", "key_f32", "key_f33", "key_f34", "key_f35", "key_f36", "key_f37", "key_f38", "key_f39", "key_f40", "key_f41", "key_f42", "key_f43", "key_f44", "key_f45", "key_f46", "key_f47", "key_f48", "key_f49", "key_f50", "key_f51", "key_f52", "key_f53", "key_f54", "key_f55", "key_f56", "key_f57", "key_f58", "key_f59", "key_f60", "key_f61", "key_f62", "key_f63", "clr_bol", "clear_margins", "set_left_margin", "set_right_margin", "label_format", "set_clock", "display_clock", "remove_clock", "create_window", "goto_window", "hangup", "dial_phone", "quick_dial", "tone", "pulse", "flash_hook", "fixed_pause", "wait_tone", "user0", "user1", "user2", "user3", "user4", "user5", "user6", "user7", "user8", "user9", "orig_pair", "orig_colors", "initialize_color", "initialize_pair", "set_color_pair", "set_foreground", "set_background", "change_char_pitch", "change_line_pitch", "change_res_horz", "change_res_vert", "define_char", "enter_doublewide_mode", "enter_draft_quality", "enter_italics_mode", "enter_leftward_mode", "enter_micro_mode", "enter_near_letter_quality", "enter_normal_quality", "enter_shadow_mode", "enter_subscript_mode", "enter_superscript_mode", "enter_upward_mode", "exit_doublewide_mode", "exit_italics_mode", "exit_leftward_mode", "exit_micro_mode", "exit_shadow_mode", "exit_subscript_mode", "exit_superscript_mode", "exit_upward_mode", "micro_column_address", "micro_down", "micro_left", "micro_right", "micro_row_address", "micro_up", "order_of_pins", "parm_down_micro", "parm_left_micro", "parm_right_micro", "parm_up_micro", "select_char_set", "set_bottom_margin", "set_bottom_margin_parm", "set_left_margin_parm", "set_right_margin_parm", "set_top_margin", "set_top_margin_parm", "start_bit_image", "start_char_set_def", "stop_bit_image", "stop_char_set_def", "subscript_characters", "superscript_characters", "these_cause_cr", "zero_motion", "char_set_names", "key_mouse", "mouse_info", "req_mouse_pos", "get_mouse", "set_a_foreground", "set_a_background", "pkey_plab", "device_type", "code_set_init", "set0_des_seq", "set1_des_seq", "set2_des_seq", "set3_des_seq", "set_lr_margin", "set_tb_margin", "bit_image_repeat", "bit_image_newline", "bit_image_carriage_return", "color_names", "define_bit_image_region", "end_bit_image_region", "set_color_band", "set_page_length", "display_pc_char", "enter_pc_charset_mode", "exit_pc_charset_mode", "enter_scancode_mode", "exit_scancode_mode", "pc_term_options", "scancode_escape", "alt_scancode_esc", "enter_horizontal_hl_mode", "enter_left_hl_mode", "enter_low_hl_mode", "enter_right_hl_mode", "enter_top_hl_mode", "enter_vertical_hl_mode", "set_a_attributes", "set_pglen_inch", "termcap_init2", "termcap_reset", "linefeed_if_not_lf", "backspace_if_not_bs", "other_non_function_keys", "arrow_key_map", "acs_ulcorner", "acs_llcorner", "acs_urcorner", "acs_lrcorner", "acs_ltee", "acs_rtee", "acs_btee", "acs_ttee", "acs_hline", "acs_vline", "acs_plus", "memory_lock", "memory_unlock", "box_chars_1" ]; const TERMINFO: &'static [(&'static str, &'static str)] = &[ // Boolean names. ("auto_left_margin", "bw"), ("auto_right_margin", "am"), ("back_color_erase", "bce"), ("can_change", "ccc"), ("ceol_standout_glitch", "xhp"), ("col_addr_glitch", "xhpa"), ("cpi_changes_res", "cpix"), ("cr_cancels_micro_mode", "crxm"), ("dest_tabs_magic_smso", "xt"), ("eat_newline_glitch", "xenl"), ("erase_overstrike", "eo"), ("generic_type", "gn"), ("hard_copy", "hc"), ("hard_cursor", "chts"), ("has_meta_key", "km"), ("has_print_wheel", "daisy"), ("has_status_line", "hs"), ("hue_lightness_saturation", "hls"), ("insert_null_glitch", "in"), ("lpi_changes_res", "lpix"), ("memory_above", "da"), ("memory_below", "db"), ("move_insert_mode", "mir"), ("move_standout_mode", "msgr"), ("needs_xon_xoff", "nxon"), ("no_esc_ctlc", "xsb"), ("no_pad_char", "npc"), ("non_dest_scroll_region", "ndscr"), ("non_rev_rmcup", "nrrmc"), ("over_strike", "os"), ("prtr_silent", "mc5i"), ("row_addr_glitch", "xvpa"), ("semi_auto_right_margin", "sam"), ("status_line_esc_ok", "eslok"), ("tilde_glitch", "hz"), ("transparent_underline", "ul"), ("xon_xoff", "xon"), // Number names. ("bit_image_entwining", "bitwin"), ("bit_image_type", "bitype"), ("buffer_capacity", "bufsz"), ("buttons", "btns"), ("columns", "cols"), ("dot_horz_spacing", "spinh"), ("dot_vert_spacing", "spinv"), ("init_tabs", "it"), ("label_height", "lh"), ("label_width", "lw"), ("lines", "lines"), ("lines_of_memory", "lm"), ("max_attributes", "ma"), ("magic_cookie_glitch", "xmc"), ("max_colors", "colors"), ("max_micro_address", "maddr"), ("max_micro_jump", "mjump"), ("max_pairs", "pairs"), ("maximum_windows", "wnum"), ("micro_col_size", "mcs"), ("micro_line_size", "mls"), ("no_color_video", "ncv"), ("num_labels", "nlab"), ("number_of_pins", "npins"), ("output_res_char", "orc"), ("output_res_line", "orl"), ("output_res_horz_inch", "orhi"), ("output_res_vert_inch", "orvi"), ("padding_baud_rate", "pb"), ("print_rate", "cps"), ("virtual_terminal", "vt"), ("wide_char_size", "widcs"), ("width_status_line", "wsl"), // String names. ("acs_chars", "acsc"), ("alt_scancode_esc", "scesa"), ("back_tab", "cbt"), ("bell", "bel"), ("bit_image_carriage_return", "bicr"), ("bit_image_newline", "binel"), ("bit_image_repeat", "birep"), ("carriage_return", "cr"), ("change_char_pitch", "cpi"), ("change_line_pitch", "lpi"), ("change_res_horz", "chr"), ("change_res_vert", "cvr"), ("change_scroll_region", "csr"), ("char_padding", "rmp"), ("char_set_names", "csnm"), ("clear_all_tabs", "tbc"), ("clear_margins", "mgc"), ("clear_screen", "clear"), ("clr_bol", "el1"), ("clr_eol", "el"), ("clr_eos", "ed"), ("code_set_init", "csin"), ("color_names", "colornm"), ("column_address", "hpa"), ("command_character", "cmdch"), ("create_window", "cwin"), ("cursor_address", "cup"), ("cursor_down", "cud1"), ("cursor_home", "home"), ("cursor_invisible", "civis"), ("cursor_left", "cub1"), ("cursor_mem_address", "mrcup"), ("cursor_normal", "cnorm"), ("cursor_right", "cuf1"), ("cursor_to_ll", "ll"), ("cursor_up", "cuu1"), ("cursor_visible", "cvvis"), ("define_bit_image_region", "defbi"), ("define_char", "defc"), ("delete_character", "dch1"), ("delete_line", "dl1"), ("device_type", "devt"), ("dial_phone", "dial"), ("dis_status_line", "dsl"), ("display_clock", "dclk"), ("display_pc_char", "dispc"), ("down_half_line", "hd"), ("ena_acs", "enacs"), ("end_bit_image_region", "endbi"), ("enter_alt_charset_mode", "smacs"), ("enter_am_mode", "smam"), ("enter_blink_mode", "blink"), ("enter_bold_mode", "bold"), ("enter_ca_mode", "smcup"), ("enter_delete_mode", "smdc"), ("enter_dim_mode", "dim"), ("enter_doublewide_mode", "swidm"), ("enter_draft_quality", "sdrfq"), ("enter_horizontal_hl_mode", "ehhlm"), ("enter_insert_mode", "smir"), ("enter_italics_mode", "sitm"), ("enter_left_hl_mode", "elhlm"), ("enter_leftward_mode", "slm"), ("enter_low_hl_mode", "elohlm"), ("enter_micro_mode", "smicm"), ("enter_near_letter_quality", "snlq"), ("enter_normal_quality", "snrmq"), ("enter_pc_charset_mode", "smpch"), ("enter_protected_mode", "prot"), ("enter_reverse_mode", "rev"), ("enter_right_hl_mode", "erhlm"), ("enter_scancode_mode", "smsc"), ("enter_secure_mode", "invis"), ("enter_shadow_mode", "sshm"), ("enter_standout_mode", "smso"), ("enter_subscript_mode", "ssubm"), ("enter_superscript_mode", "ssupm"), ("enter_top_hl_mode", "ethlm"), ("enter_underline_mode", "smul"), ("enter_upward_mode", "sum"), ("enter_vertical_hl_mode", "evhlm"), ("enter_xon_mode", "smxon"), ("erase_chars", "ech"), ("exit_alt_charset_mode", "rmacs"), ("exit_am_mode", "rmam"), ("exit_attribute_mode", "sgr0"), ("exit_ca_mode", "rmcup"), ("exit_delete_mode", "rmdc"), ("exit_doublewide_mode", "rwidm"), ("exit_insert_mode", "rmir"), ("exit_italics_mode", "ritm"), ("exit_leftward_mode", "rlm"), ("exit_micro_mode", "rmicm"), ("exit_pc_charset_mode", "rmpch"), ("exit_scancode_mode", "rmsc"), ("exit_shadow_mode", "rshm"), ("exit_standout_mode", "rmso"), ("exit_subscript_mode", "rsubm"), ("exit_superscript_mode", "rsupm"), ("exit_underline_mode", "rmul"), ("exit_upward_mode", "rum"), ("exit_xon_mode", "rmxon"), ("fixed_pause", "pause"), ("flash_hook", "hook"), ("flash_screen", "flash"), ("form_feed", "ff"), ("from_status_line", "fsl"), ("get_mouse", "getm"), ("goto_window", "wingo"), ("hangup", "hup"), ("init_1string", "is1"), ("init_2string", "is2"), ("init_3string", "is3"), ("init_file", "if"), ("init_prog", "iprog"), ("initialize_color", "initc"), ("initialize_pair", "initp"), ("insert_character", "ich1"), ("insert_line", "il1"), ("insert_padding", "ip"), ("key_a1", "ka1"), ("key_a3", "ka3"), ("key_b2", "kb2"), ("key_backspace", "kbs"), ("key_beg", "kbeg"), ("key_btab", "kcbt"), ("key_c1", "kc1"), ("key_c3", "kc3"), ("key_cancel", "kcan"), ("key_catab", "ktbc"), ("key_clear", "kclr"), ("key_close", "kclo"), ("key_command", "kcmd"), ("key_copy", "kcpy"), ("key_create", "kcrt"), ("key_ctab", "kctab"), ("key_dc", "kdch1"), ("key_dl", "kdl1"), ("key_down", "kcud1"), ("key_eic", "krmir"), ("key_end", "kend"), ("key_enter", "kent"), ("key_eol", "kel"), ("key_eos", "ked"), ("key_exit", "kext"), ("key_f0", "kf0"), ("key_f1", "kf1"), ("key_f62", "kf62"), ("key_f63", "kf63"), ("key_find", "kfnd"), ("key_help", "khlp"), ("key_home", "khome"), ("key_ic", "kich1"), ("key_il", "kil1"), ("key_left", "kcub1"), ("key_ll", "kll"), ("key_mark", "kmrk"), ("key_message", "kmsg"), ("key_mouse", "kmous"), ("key_move", "kmov"), ("key_next", "knxt"), ("key_npage", "knp"), ("key_open", "kopn"), ("key_options", "kopt"), ("key_ppage", "kpp"), ("key_previous", "kprv"), ("key_print", "kprt"), ("key_redo", "krdo"), ("key_reference", "kref"), ("key_refresh", "krfr"), ("key_replace", "krpl"), ("key_restart", "krst"), ("key_resume", "kres"), ("key_right", "kcuf1"), ("key_save", "ksav"), ("key_sbeg", "kBEG"), ("key_scancel", "kCAN"), ("key_scommand", "kCMD"), ("key_scopy", "kCPY"), ("key_screate", "kCRT"), ("key_sdc", "kDC"), ("key_sdl", "kDL"), ("key_select", "kslt"), ("key_send", "kEND"), ("key_seol", "kEOL"), ("key_sexit", "kEXT"), ("key_sf", "kind"), ("key_sfind", "kFND"), ("key_shelp", "kHLP"), ("key_shome", "kHOM"), ("key_sic", "kIC"), ("key_sleft", "kLFT"), ("key_smessage", "kMSG"), ("key_smove", "kMOV"), ("key_snext", "kNXT"), ("key_soptions", "kOPT"), ("key_sprevious", "kPRV"), ("key_sprint", "kPRT"), ("key_sr", "kri"), ("key_sredo", "kRDO"), ("key_sreplace", "kRPL"), ("key_sright", "kRIT"), ("key_srsume", "kRES"), ("key_ssave", "kSAV"), ("key_ssuspend", "kSPD"), ("key_stab", "khts"), ("key_sundo", "kUND"), ("key_suspend", "kspd"), ("key_undo", "kund"), ("key_up", "kcuu1"), ("keypad_local", "rmkx"), ("keypad_xmit", "smkx"), ("lab_f0", "lf0"), ("lab_f1", "lf1"), ("lab_f2", "lf2"), ("lab_f3", "lf3"), ("lab_f4", "lf4"), ("lab_f5", "lf5"), ("lab_f6", "lf6"), ("lab_f7", "lf7"), ("lab_f8", "lf8"), ("lab_f9", "lf9"), ("lab_f10", "lf10"), ("label_format", "fln"), ("label_off", "rmln"), ("label_on", "smln"), ("meta_off", "rmm"), ("meta_on", "smm"), ("micro_column_address", "mhpa"), ("micro_down", "mcud1"), ("micro_left", "mcub1"), ("micro_right", "mcuf1"), ("micro_row_address", "mvpa"), ("micro_up", "mcuu1"), ("mouse_info", "minfo"), ("newline", "nel"), ("order_of_pins", "porder"), ("orig_colors", "oc"), ("orig_pair", "op"), ("pad_char", "pad"), ("parm_dch", "dch"), ("parm_delete_line", "dl"), ("parm_down_cursor", "cud"), ("parm_down_micro", "mcud"), ("parm_ich", "ich"), ("parm_index", "indn"), ("parm_insert_line", "il"), ("parm_left_cursor", "cub"), ("parm_left_micro", "mcub"), ("parm_right_cursor", "cuf"), ("parm_right_micro", "mcuf"), ("parm_rindex", "rin"), ("parm_up_cursor", "cuu"), ("parm_up_micro", "mcuu"), ("pc_term_options", "pctrm"), ("pkey_key", "pfkey"), ("pkey_local", "pfloc"), ("pkey_plab", "pfxl"), ("pkey_xmit", "pfx"), ("plab_norm", "pln"), ("print_screen", "mc0"), ("prtr_non", "mc5p"), ("prtr_off", "mc4"), ("prtr_on", "mc5"), ("pulse", "pulse"), ("quick_dial", "qdial"), ("remove_clock", "rmclk"), ("repeat_char", "rep"), ("req_for_input", "rfi"), ("req_mouse_pos", "reqmp"), ("reset_1string", "rs1"), ("reset_2string", "rs2"), ("reset_3string", "rs3"), ("reset_file", "rf"), ("restore_cursor", "rc"), ("row_address", "vpa"), ("save_cursor", "sc"), ("scancode_escape", "scesc"), ("scroll_forward", "ind"), ("scroll_reverse", "ri"), ("select_char_set", "scs"), ("set0_des_seq", "s0ds"), ("set1_des_seq", "s1ds"), ("set2_des_seq", "s2ds"), ("set3_des_seq", "s3ds"), ("set_a_attributes", "sgr1"), ("set_a_background", "setab"), ("set_a_foreground", "setaf"), ("set_attributes", "sgr"), ("set_background", "setb"), ("set_bottom_margin", "smgb"), ("set_bottom_margin_parm", "smgbp"), ("set_clock", "sclk"), ("set_color_band", "setcolor"), ("set_color_pair", "scp"), ("set_foreground", "setf"), ("set_left_margin", "smgl"), ("set_left_margin_parm", "smglp"), ("set_lr_margin", "smglr"), ("set_page_length", "slines"), ("set_pglen_inch", "slength"), ("set_right_margin", "smgr"), ("set_right_margin_parm", "smgrp"), ("set_tab", "hts"), ("set_tb_margin", "smgtb"), ("set_top_margin", "smgt"), ("set_top_margin_parm", "smgtp"), ("set_window", "wind"), ("start_bit_image", "sbim"), ("start_char_set_def", "scsd"), ("stop_bit_image", "rbim"), ("stop_char_set_def", "rcsd"), ("subscript_characters", "subcs"), ("superscript_characters", "supcs"), ("tab", "ht"), ("these_cause_cr", "docr"), ("to_status_line", "tsl"), ("tone", "tone"), ("user0", "u0"), ("user1", "u1"), ("user2", "u2"), ("user3", "u3"), ("user4", "u4"), ("user5", "u5"), ("user6", "u6"), ("user7", "u7"), ("user8", "u8"), ("user9", "u9"), ("underline_char", "uc"), ("up_half_line", "hu"), ("wait_tone", "wait"), ("xoff_character", "xoffc"), ("xon_character", "xonc"), ("zero_motion", "zerom"), ]; const TERMCAP: &'static [(&'static str, &'static str)] = &[ // Boolean names. ("auto_left_margin", "bw"), ("auto_right_margin", "am"), ("back_color_erase", "ut"), ("can_change", "cc"), ("ceol_standout_glitch", "xs"), ("col_addr_glitch", "YA"), ("cpi_changes_res", "YF"), ("cr_cancels_micro_mode", "YB"), ("dest_tabs_magic_smso", "xt"), ("eat_newline_glitch", "xn"), ("erase_overstrike", "eo"), ("generic_type", "gn"), ("hard_copy", "hc"), ("hard_cursor", "HC"), ("has_meta_key", "km"), ("has_print_wheel", "YC"), ("has_status_line", "hs"), ("hue_lightness_saturation", "hl"), ("insert_null_glitch", "in"), ("lpi_changes_res", "YG"), ("memory_above", "da"), ("memory_below", "db"), ("move_insert_mode", "mi"), ("move_standout_mode", "ms"), ("needs_xon_xoff", "nx"), ("no_esc_ctlc", "xb"), ("no_pad_char", "NP"), ("non_dest_scroll_region", "ND"), ("non_rev_rmcup", "NR"), ("over_strike", "os"), ("prtr_silent", "5i"), ("row_addr_glitch", "YD"), ("semi_auto_right_margin", "YE"), ("status_line_esc_ok", "es"), ("tilde_glitch", "hz"), ("transparent_underline", "ul"), ("xon_xoff", "xo"), // Number names. ("bit_image_entwining", "Yo"), ("bit_image_type", "Yp"), ("buffer_capacity", "Ya"), ("buttons", "BT"), ("columns", "co"), ("dot_horz_spacing", "Yc"), ("dot_vert_spacing", "Yb"), ("init_tabs", "it"), ("label_height", "lh"), ("label_width", "lw"), ("lines", "li"), ("lines_of_memory", "lm"), ("max_attributes", "ma"), ("magic_cookie_glitch", "sg"), ("max_colors", "Co"), ("max_micro_address", "Yd"), ("max_micro_jump", "Ye"), ("max_pairs", "pa"), ("maximum_windows", "MW"), ("micro_col_size", "Yf"), ("micro_line_size", "Yg"), ("no_color_video", "NC"), ("num_labels", "Nl"), ("number_of_pins", "Yh"), ("output_res_char", "Yi"), ("output_res_line", "Yj"), ("output_res_horz_inch", "Yk"), ("output_res_vert_inch", "Yl"), ("padding_baud_rate", "pb"), ("print_rate", "Ym"), ("virtual_terminal", "vt"), ("wide_char_size", "Yn"), ("width_status_line", "ws"), // String names. ("acs_chars", "ac"), ("alt_scancode_esc", "S8"), ("back_tab", "bt"), ("bell", "bl"), ("bit_image_carriage_return", "Yv"), ("bit_image_newline", "Zz"), ("bit_image_repeat", "Xy"), ("carriage_return", "cr"), ("change_char_pitch", "ZA"), ("change_line_pitch", "ZB"), ("change_res_horz", "ZC"), ("change_res_vert", "ZD"), ("change_scroll_region", "cs"), ("char_padding", "rP"), ("char_set_names", "Zy"), ("clear_all_tabs", "ct"), ("clear_margins", "MC"), ("clear_screen", "cl"), ("clr_bol", "cb"), ("clr_eol", "ce"), ("clr_eos", "cd"), ("code_set_init", "ci"), ("color_names", "Yw"), ("column_address", "ch"), ("command_character", "CC"), ("cursor_address", "cm"), ("cursor_down", "do"), ("cursor_home", "ho"), ("cursor_invisible", "vi"), ("cursor_left", "le"), ("cursor_mem_address", "CM"), ("cursor_normal", "ve"), ("cursor_right", "nd"), ("cursor_to_ll", "ll"), ("cursor_up", "up"), ("cursor_visible", "vs"), ("define_bit_image_region", "Yx"), ("define_char", "ZE"), ("delete_character", "dc"), ("delete_line", "dl"), ("device_type", "dv"), ("dial_phone", "DI"), ("dis_status_line", "ds"), ("display_clock", "DK"), ("display_pc_char", "S1"), ("down_half_line", "hd"), ("ena_acs", "eA"), ("end_bit_image_region", "Yy"), ("enter_alt_charset_mode", "as"), ("enter_am_mode", "SA"), ("enter_blink_mode", "mb"), ("enter_bold_mode", "md"), ("enter_ca_mode", "ti"), ("enter_delete_mode", "dm"), ("enter_dim_mode", "mh"), ("enter_doublewide_mode", "ZF"), ("enter_draft_quality", "ZG"), ("enter_insert_mode", "im"), ("enter_italics_mode", "ZH"), ("enter_leftward_mode", "ZI"), ("enter_micro_mode", "ZJ"), ("enter_near_letter_quality", "ZK"), ("enter_normal_quality", "ZL"), ("enter_pc_charset_mode", "S2"), ("enter_protected_mode", "mp"), ("enter_reverse_mode", "mr"), ("enter_scancode_mode", "S4"), ("enter_secure_mode", "mk"), ("enter_shadow_mode", "ZM"), ("enter_standout_mode", "so"), ("enter_subscript_mode", "ZN"), ("enter_superscript_mode", "ZO"), ("enter_underline_mode", "us"), ("enter_upward_mode", "ZP"), ("enter_xon_mode", "SX"), ("erase_chars", "ec"), ("exit_alt_charset_mode", "ae"), ("exit_am_mode", "RA"), ("exit_attribute_mode", "me"), ("exit_ca_mode", "te"), ("exit_delete_mode", "ed"), ("exit_doublewide_mode", "ZQ"), ("exit_insert_mode", "ei"), ("exit_italics_mode", "ZR"), ("exit_leftward_mode", "ZS"), ("exit_micro_mode", "ZT"), ("exit_pc_charset_mode", "S3"), ("exit_scancode_mode", "S5"), ("exit_shadow_mode", "ZU"), ("exit_standout_mode", "se"), ("exit_subscript_mode", "ZV"), ("exit_superscript_mode", "ZW"), ("exit_underline_mode", "ue"), ("exit_upward_mode", "ZX"), ("exit_xon_mode", "RX"), ("fixed_pause", "PA"), ("flash_hook", "fh"), ("flash_screen", "vb"), ("form_feed", "ff"), ("from_status_line", "fs"), ("get_mouse", "Gm"), ("goto_window", "WG"), ("hangup", "HU"), ("init_1string", "i1"), ("init_2string", "is"), ("init_3string", "i3"), ("init_file", "if"), ("init_prog", "iP"), ("initialize_color", "Ic"), ("initialize_pair", "Ip"), ("insert_character", "ic"), ("insert_line", "al"), ("insert_padding", "ip"), ("key_a1", "K1"), ("key_a3", "K3"), ("key_b2", "K2"), ("key_backspace", "kb"), ("key_btab", "kB"), ("key_c1", "K4"), ("key_c3", "K5"), ("key_catab", "ka"), ("key_clear", "kC"), ("key_ctab", "kt"), ("key_dc", "kD"), ("key_dl", "kL"), ("key_down", "kd"), ("key_eic", "kM"), ("key_eol", "kE"), ("key_eos", "kS"), ("key_f0", "k0"), ("key_f1", "k1"), ("key_f62", "Fq"), ("key_f63", "Fr"), ("key_help", "%1"), ("key_home", "kh"), ("key_ic", "kI"), ("key_il", "kA"), ("key_left", "kl"), ("key_ll", "kH"), ("key_mark", "%2"), ("key_message", "%3"), ("key_mouse", "Km"), ("key_move", "%4"), ("key_next", "%5"), ("key_npage", "kN"), ("key_open", "%6"), ("key_options", "%7"), ("key_ppage", "kP"), ("key_previous", "%8"), ("key_print", "%9"), ("key_redo", "%0"), ("key_reference", "&1"), ("key_refresh", "&2"), ("key_replace", "&3"), ("key_restart", "&4"), ("key_resume", "&5"), ("key_right", "kr"), ("key_save", "&6"), ("key_sbeg", "&9"), ("key_scancel", "&0"), ("key_scommand", "*1"), ("key_scopy", "*2"), ("key_screate", "*3"), ("key_sdc", "*4"), ("key_sdl", "*5"), ("key_select", "*6"), ("key_send", "*7"), ("key_seol", "*8"), ("key_sexit", "*9"), ("key_sf", "kF"), ("key_sfind", "*0"), ("key_shelp", "#1"), ("key_shome", "#2"), ("key_sic", "#3"), ("key_sleft", "#4"), ("key_smessage", "%a"), ("key_smove", "%b"), ("key_snext", "%c"), ("key_soptions", "%d"), ("key_sprevious", "%e"), ("key_sprint", "%f"), ("key_sr", "kR"), ("key_sredo", "%g"), ("key_sreplace", "%h"), ("key_sright", "%i"), ("key_srsume", "%j"), ("key_ssave", "!1"), ("key_ssuspend", "!2"), ("key_stab", "kT"), ("key_sundo", "!3"), ("key_suspend", "&7"), ("key_undo", "&8"), ("key_up", "ku"), ("keypad_local", "ke"), ("keypad_xmit", "ks"), ("lab_f0", "l0"), ("lab_f1", "l1"), ("lab_f2", "l2"), ("lab_f3", "l3"), ("lab_f4", "l4"), ("lab_f5", "l5"), ("lab_f6", "l6"), ("lab_f7", "l7"), ("lab_f8", "l8"), ("lab_f9", "l9"), ("lab_f10", "la"), ("label_format", "Lf"), ("label_off", "LF"), ("label_on", "LO"), ("meta_off", "mo"), ("meta_on", "mm"), ("micro_column_address", "ZY"), ("micro_down", "ZZ"), ("micro_left", "Za"), ("micro_right", "Zb"), ("micro_row_address", "Zc"), ("micro_up", "Zd"), ("mouse_info", "Mi"), ("newline", "nw"), ("order_of_pins", "Ze"), ("orig_colors", "oc"), ("orig_pair", "op"), ("pad_char", "pc"), ("parm_dch", "DC"), ("parm_delete_line", "DL"), ("parm_down_cursor", "DO"), ("parm_down_micro", "Zf"), ("parm_ich", "IC"), ("parm_index", "SF"), ("parm_insert_line", "AL"), ("parm_left_cursor", "LE"), ("parm_left_micro", "Zg"), ("parm_right_cursor", "RI"), ("parm_right_micro", "Zh"), ("parm_rindex", "SR"), ("parm_up_cursor", "UP"), ("parm_up_micro", "Zi"), ("pc_term_options", "S6"), ("pkey_key", "pk"), ("pkey_local", "pl"), ("pkey_plab", "xl"), ("pkey_xmit", "px"), ("plab_norm", "pn"), ("print_screen", "ps"), ("prtr_non", "pO"), ("prtr_off", "pf"), ("prtr_on", "po"), ("pulse", "PU"), ("quick_dial", "QD"), ("remove_clock", "RC"), ("repeat_char", "rp"), ("req_for_input", "RF"), ("req_mouse_pos", "RQ"), ("reset_1string", "r1"), ("reset_2string", "r2"), ("reset_3string", "r3"), ("reset_file", "rf"), ("restore_cursor", "rc"), ("row_address", "cv"), ("save_cursor", "sc"), ("scancode_escape", "S7"), ("scroll_forward", "sf"), ("scroll_reverse", "sr"), ("select_char_set", "Zj"), ("set0_des_seq", "s0"), ("set1_des_seq", "s1"), ("set2_des_seq", "s2"), ("set3_des_seq", "s3"), ("set_a_background", "AB"), ("set_a_foreground", "AF"), ("set_attributes", "sa"), ("set_background", "Sb"), ("set_bottom_margin", "Zk"), ("set_bottom_margin_parm", "Zl"), ("set_clock", "SC"), ("set_color_band", "Yz"), ("set_color_pair", "sp"), ("set_foreground", "Sf"), ("set_left_margin", "ML"), ("set_left_margin_parm", "Zm"), ("set_page_length", "YZ"), ("set_pglen_inch", "YI"), ("set_right_margin", "MR"), ("set_right_margin_parm", "Zn"), ("set_tab", "st"), ("set_tb_margin", "MT"), ("set_top_margin", "Zo"), ("set_top_margin_parm", "Zp"), ("set_window", "wi"), ("start_bit_image", "Zq"), ("start_char_set_def", "Zr"), ("stop_bit_image", "Zs"), ("stop_char_set_def", "Zt"), ("subscript_characters", "Zu"), ("superscript_characters", "Zv"), ("tab", "ta"), ("these_cause_cr", "Zw"), ("to_status_line", "ts"), ("tone", "TO"), ("user0", "u0"), ("user1", "u1"), ("user2", "u2"), ("user3", "u3"), ("user4", "u4"), ("user5", "u5"), ("user6", "u6"), ("user7", "u7"), ("user8", "u8"), ("user9", "u9"), ("underline_char", "uc"), ("up_half_line", "hu"), ("wait_tone", "WA"), ("xoff_character", "XF"), ("xon_character", "XN"), ("zero_motion", "Zx"), ]; fn main() { let path = Path::new(&env::var("OUT_DIR").unwrap()).join("names.rs"); let mut file = BufWriter::new(File::create(&path).unwrap()); write!(&mut file, "pub static BOOLEAN: ::phf::Map = ").unwrap(); let mut builder = phf_codegen::Map::new(); for (index, name) in BOOLEAN.iter().enumerate() { builder.entry(index as u16, &format!("\"{}\"", name)); } write!(&mut file, "{}", builder.build()).unwrap(); write!(&mut file, ";\n").unwrap(); let keys = BOOLEAN.iter().map(|n| format!("\"{}\"", n)).collect::>(); write!(&mut file, "pub static BOOLEAN_INDEX: ::phf::Map<&'static str, u16> = ").unwrap(); let mut builder = phf_codegen::Map::<&str>::new(); for (index, name) in keys.iter().enumerate() { builder.entry(name, &index.to_string()); } write!(&mut file, "{}", builder.build()).unwrap(); write!(&mut file, ";\n").unwrap(); write!(&mut file, "pub static NUMBER: ::phf::Map = ").unwrap(); let mut builder = phf_codegen::Map::new(); for (index, name) in NUMBER.iter().enumerate() { builder.entry(index as u16, &format!("\"{}\"", name)); } write!(&mut file, "{}", builder.build()).unwrap(); write!(&mut file, ";\n").unwrap(); let keys = NUMBER.iter().map(|n| format!("\"{}\"", n)).collect::>(); write!(&mut file, "pub static NUMBER_INDEX: ::phf::Map<&'static str, u16> = ").unwrap(); let mut builder = phf_codegen::Map::<&str>::new(); for (index, name) in keys.iter().enumerate() { builder.entry(name, &index.to_string()); } write!(&mut file, "{}", builder.build()).unwrap(); write!(&mut file, ";\n").unwrap(); write!(&mut file, "pub static STRING: ::phf::Map = ").unwrap(); let mut builder = phf_codegen::Map::new(); for (index, name) in STRING.iter().enumerate() { builder.entry(index as u16, &format!("\"{}\"", name)); } write!(&mut file, "{}", builder.build()).unwrap(); write!(&mut file, ";\n").unwrap(); let keys = STRING.iter().map(|n| format!("\"{}\"", n)).collect::>(); write!(&mut file, "pub static STRING_INDEX: ::phf::Map<&'static str, u16> = ").unwrap(); let mut builder = phf_codegen::Map::<&str>::new(); for (index, name) in keys.iter().enumerate() { builder.entry(name, &index.to_string()); } write!(&mut file, "{}", builder.build()).unwrap(); write!(&mut file, ";\n").unwrap(); write!(&mut file, "pub static TERMINFO: ::phf::Map<&'static str, &'static str> = ").unwrap(); let mut builder = phf_codegen::Map::new(); for &(name, value) in TERMINFO { builder.entry(name, &format!("\"{}\"", value)); } write!(&mut file, "{}", builder.build()).unwrap(); write!(&mut file, ";\n").unwrap(); write!(&mut file, "pub static TERMCAP: ::phf::Map<&'static str, &'static str> = ").unwrap(); let mut builder = phf_codegen::Map::new(); for &(name, value) in TERMCAP { builder.entry(name, &format!("\"{}\"", value)); } write!(&mut file, "{}", builder.build()).unwrap(); write!(&mut file, ";\n").unwrap(); write!(&mut file, "pub static ALIASES: ::phf::Map<&'static str, &'static str> = ").unwrap(); let mut builder = phf_codegen::Map::new(); for &(value, name) in TERMINFO { builder.entry(name, &format!("\"{}\"", value)); } for &(value, name) in TERMCAP { if TERMINFO.iter().find(|entry| name == entry.1).is_none() { builder.entry(name, &format!("\"{}\"", value)); } } write!(&mut file, "{}", builder.build()).unwrap(); write!(&mut file, ";\n").unwrap(); } terminfo-0.8.0/examples/parse.rs000064400000000000000000000012441046102023000147530ustar 00000000000000// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE // Version 2, December 2004 // // Copyleft (ↄ) meh. | http://meh.schizofreni.co // // Everyone is permitted to copy and distribute verbatim or modified // copies of this license document, and changing it is allowed as long // as the name is changed. // // DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE // TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION // // 0. You just DO WHAT THE FUCK YOU WANT TO. extern crate terminfo; use std::env; fn main() { println!("{:?}", terminfo::Database::from_path(env::args().nth(1).expect("no file given"))); } terminfo-0.8.0/examples/set_attributes.rs000064400000000000000000000007771046102023000167140ustar 00000000000000extern crate terminfo; use std::io; use terminfo::{capability as cap, Database}; fn main() { let info = Database::from_env().unwrap(); if let Some(set_attributes) = info.get::() { let clear = info.get::().unwrap(); set_attributes.expand().bold(true).underline(true).to(io::stdout()).unwrap(); println!("bold and underline"); clear.expand().to(io::stdout()).unwrap(); } else { println!("The terminal does not support mass-setting attributes"); } } terminfo-0.8.0/examples/simple.rs000064400000000000000000000013741046102023000151360ustar 00000000000000extern crate terminfo; use std::io; use terminfo::{capability as cap, Database}; fn main() { let info = Database::from_env().unwrap(); if let Some(cap::MaxColors(n)) = info.get::() { println!("The terminal supports {} colors.", n); } else { println!("The terminal does not support colors, what year is this?"); } if let Some(flash) = info.get::() { flash.expand().to(io::stdout()).unwrap(); } else { println!("FLASH GORDON!"); } info.get::().unwrap().expand().color(2).to(io::stdout()).unwrap(); info.get::().unwrap().expand().color(4).to(io::stdout()).unwrap(); println!("SUP"); info.get::().unwrap().expand().to(io::stdout()).unwrap(); } terminfo-0.8.0/rustfmt.toml000064400000000000000000000000561046102023000140560ustar 00000000000000hard_tabs = true use_small_heuristics = "Max" terminfo-0.8.0/src/capability.rs000064400000000000000000001011641046102023000147350ustar 00000000000000// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE // Version 2, December 2004 // // Copyleft (ↄ) meh. | http://meh.schizofreni.co // // Everyone is permitted to copy and distribute verbatim or modified // copies of this license document, and changing it is allowed as long // as the name is changed. // // DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE // TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION // // 0. You just DO WHAT THE FUCK YOU WANT TO. //! Standard capabilities. use std::borrow::Cow; use std::io::Write; use crate::error; use crate::expand::{Context, Expand, Parameter}; /// A trait for any object that will represent a terminal capability. pub trait Capability<'a>: Sized { /// Returns the name of the capability in its long form. fn name() -> &'static str; /// Parse the capability from its raw value. fn from(value: Option<&'a Value>) -> Option; /// Convert the capability into its raw value. fn into(self) -> Option; } /// Possible value types for capabilities. #[derive(Eq, PartialEq, Clone, Debug)] pub enum Value { /// A boolean. True, /// A number. Number(i32), /// An ASCII string requiring expansion. String(Vec), } /// Expansion helper struct. #[derive(Debug)] pub struct Expansion<'a, T: 'a + AsRef<[u8]>> { string: &'a T, params: [Parameter; 9], context: Option<&'a mut Context>, } impl<'a, T: AsRef<[u8]>> Expansion<'a, T> { /// Expand using the given context. pub fn with<'c: 'a>(mut self, context: &'c mut Context) -> Self { self.context = Some(context); self } /// Expand to the given output. pub fn to(self, output: W) -> error::Result<()> { self.string.as_ref().expand( output, &self.params, self.context.unwrap_or(&mut Default::default()), ) } /// Expand into a vector. pub fn to_vec(self) -> error::Result> { let mut result = Vec::with_capacity(self.string.as_ref().len()); self.to(&mut result)?; Ok(result) } } macro_rules! from { (number $ty:ty) => { impl From<$ty> for Value { fn from(value: $ty) -> Self { Value::Number(value as i32) } } }; (string ref $ty:ty) => { impl<'a> From<&'a $ty> for Value { fn from(value: &'a $ty) -> Self { Value::String(value.into()) } } }; (string $ty:ty) => { impl From<$ty> for Value { fn from(value: $ty) -> Self { Value::String(value.into()) } } }; } impl From<()> for Value { fn from(_: ()) -> Self { Value::True } } from!(number u8); from!(number i8); from!(number u16); from!(number i16); from!(number u32); from!(number i32); from!(string String); from!(string ref str); from!(string Vec); from!(string ref [u8]); macro_rules! define { (boolean $ident:ident => $capability:expr) => ( #[derive(Eq, PartialEq, Copy, Clone, Debug)] pub struct $ident(pub bool); impl<'a> Capability<'a> for $ident { #[inline] fn name() -> &'static str { $capability } #[inline] fn from(value: Option<&Value>) -> Option { if let Some(&Value::True) = value { Some($ident(true)) } else { Some($ident(false)) } } #[inline] fn into(self) -> Option { if self.0 { Some(Value::True) } else { None } } } impl Into for $ident { fn into(self) -> bool { self.0 } } ); (number $ident:ident => $capability:expr) => ( #[derive(Eq, PartialEq, Copy, Clone, Debug)] pub struct $ident(pub i32); impl<'a> Capability<'a> for $ident { #[inline] fn name() -> &'static str { $capability } #[inline] fn from(value: Option<&Value>) -> Option { if let Some(&Value::Number(value)) = value { Some($ident(value)) } else { None } } #[inline] fn into(self) -> Option { Some(Value::Number(self.0)) } } impl Into for $ident { fn into(self) -> i32 { self.0 } } ); (string define $ident:ident => $capability:expr) => ( #[derive(Eq, PartialEq, Clone, Debug)] pub struct $ident<'a>(Cow<'a, [u8]>); impl<'a> Capability<'a> for $ident<'a> { #[inline] fn name() -> &'static str { $capability } #[inline] fn from(value: Option<&'a Value>) -> Option<$ident<'a>> { if let Some(&Value::String(ref value)) = value { Some($ident(Cow::Borrowed(value))) } else { None } } #[inline] fn into(self) -> Option { Some(Value::String(match self.0 { Cow::Borrowed(value) => value.into(), Cow::Owned(value) => value })) } } impl<'a, T: AsRef<&'a [u8]>> From for $ident<'a> { #[inline] fn from(value: T) -> Self { $ident(Cow::Borrowed(value.as_ref())) } } impl<'a> AsRef<[u8]> for $ident<'a> { #[inline] fn as_ref(&self) -> &[u8] { &self.0 } } impl<'a> $ident<'a> { /// Begin expanding the capability. #[inline] pub fn expand(&self) -> Expansion<$ident> { Expansion { string: self, params: Default::default(), context: None, } } } ); (string $ident:ident => $capability:expr) => ( define!(string define $ident => $capability); impl<'a> Expansion<'a, $ident<'a>> { /// Pass all expansion parameters at once. #[inline] pub fn parameters(self) -> Self { self } } ); (string $ident:ident => $capability:expr; $($rest:tt)+) => ( define!(string define $ident => $capability); define!(string parameters $ident; $($rest)+); define!(string builder $ident; 0, $($rest)+, ); ); (string parameters $ident:ident; $($name:ident : $ty:ty),+) => ( impl<'a> Expansion<'a, $ident<'a>> { /// Pass all expansion parameters at once. #[allow(unused_assignments)] #[inline] pub fn parameters(mut self, $($name: $ty),*) -> Self { let mut index = 0; $({ self.params[index] = $name.into(); index += 1; })*; self } } ); (string builder $ident:ident; $index:expr, ) => (); (string builder $ident:ident; $index:expr, $name:ident : u8, $($rest:tt)*) => ( define!(string builder direct $ident; $index, $name : u8); define!(string builder $ident; $index + 1, $($rest)*); ); (string builder $ident:ident; $index:expr, $name:ident : i8, $($rest:tt)*) => ( define!(string builder direct $ident; $index, $name : i8); define!(string builder $ident; $index + 1, $($rest)*); ); (string builder $ident:ident; $index:expr, $name:ident : u16, $($rest:tt)*) => ( define!(string builder direct $ident; $index, $name : u16); define!(string builder $ident; $index + 1, $($rest)*); ); (string builder $ident:ident; $index:expr, $name:ident : i16 $($rest:tt)*) => ( define!(string builder direct $ident; $index, $name : i16); define!(string builder $ident; $index + 1, $($rest)*); ); (string builder $ident:ident; $index:expr, $name:ident : u32, $($rest:tt)*) => ( define!(string builder direct $ident; $index, $name : u32); define!(string builder $ident; $index + 1, $($rest)*); ); (string builder $ident:ident; $index:expr, $name:ident : i32, $($rest:tt)*) => ( define!(string builder direct $ident; $index, $name : i32); define!(string builder $ident; $index + 1, $($rest)*); ); (string builder $ident:ident; $index:expr, $name:ident : $ty:ty, $($rest:tt)*) => ( define!(string builder into $ident; $index, $name : $ty); define!(string builder $ident; $index + 1, $($rest)*); ); (string builder direct $ident:ident; $index:expr, $name:ident : $ty:ty) => ( impl<'a> Expansion<'a, $ident<'a>> { /// Set the given parameter. #[inline] pub fn $name(mut self, value: $ty) -> Self { self.params[$index] = value.into(); self } } ); (string builder into $ident:ident; $index:expr, $name:ident : $ty:ty) => ( impl<'a> Expansion<'a, $ident<'a>> { /// Set the given parameter. #[inline] pub fn $name>(mut self, value: T) -> Self { self.params[$index] = value.into().into(); self } } ); } define!(boolean AutoLeftMargin => "auto_left_margin"); define!(boolean AutoRightMargin => "auto_right_margin"); define!(boolean NoEscCtlc => "no_esc_ctlc"); define!(boolean CeolStandoutGlitch => "ceol_standout_glitch"); define!(boolean EatNewlineGlitch => "eat_newline_glitch"); define!(boolean EraseOverstrike => "erase_overstrike"); define!(boolean GenericType => "generic_type"); define!(boolean HardCopy => "hard_copy"); define!(boolean HasMetaKey => "has_meta_key"); define!(boolean HasStatusLine => "has_status_line"); define!(boolean InsertNullGlitch => "insert_null_glitch"); define!(boolean MemoryAbove => "memory_above"); define!(boolean MemoryBelow => "memory_below"); define!(boolean MoveInsertMode => "move_insert_mode"); define!(boolean MoveStandoutMode => "move_standout_mode"); define!(boolean OverStrike => "over_strike"); define!(boolean StatusLineEscOk => "status_line_esc_ok"); define!(boolean DestTabsMagicSmso => "dest_tabs_magic_smso"); define!(boolean TildeGlitch => "tilde_glitch"); define!(boolean TransparentUnderline => "transparent_underline"); define!(boolean XonXoff => "xon_xoff"); define!(boolean NeedsXonXoff => "needs_xon_xoff"); define!(boolean PrtrSilent => "prtr_silent"); define!(boolean HardCursor => "hard_cursor"); define!(boolean NonRevRmcup => "non_rev_rmcup"); define!(boolean NoPadChar => "no_pad_char"); define!(boolean NonDestScrollRegion => "non_dest_scroll_region"); define!(boolean CanChange => "can_change"); define!(boolean BackColorErase => "back_color_erase"); define!(boolean HueLightnessSaturation => "hue_lightness_saturation"); define!(boolean ColAddrGlitch => "col_addr_glitch"); define!(boolean CrCancelsMicroMode => "cr_cancels_micro_mode"); define!(boolean HasPrintWheel => "has_print_wheel"); define!(boolean RowAddrGlitch => "row_addr_glitch"); define!(boolean SemiAutoRightMargin => "semi_auto_right_margin"); define!(boolean CpiChangesRes => "cpi_changes_res"); define!(boolean LpiChangesRes => "lpi_changes_res"); define!(boolean BackspacesWithBs => "backspaces_with_bs"); define!(boolean CrtNoScrolling => "crt_no_scrolling"); define!(boolean NoCorrectlyWorkingCr => "no_correctly_working_cr"); define!(boolean GnuHasMetaKey => "gnu_has_meta_key"); define!(boolean LinefeedIsNewline => "linefeed_is_newline"); define!(boolean HasHardwareTabs => "has_hardware_tabs"); define!(boolean ReturnDoesClrEol => "return_does_clr_eol"); define!(number Columns => "columns"); define!(number InitTabs => "init_tabs"); define!(number Lines => "lines"); define!(number LinesOfMemory => "lines_of_memory"); define!(number MagicCookieGlitch => "magic_cookie_glitch"); define!(number PaddingBaudRate => "padding_baud_rate"); define!(number VirtualTerminal => "virtual_terminal"); define!(number WidthStatusLine => "width_status_line"); define!(number NumLabels => "num_labels"); define!(number LabelHeight => "label_height"); define!(number LabelWidth => "label_width"); define!(number MaxAttributes => "max_attributes"); define!(number MaximumWindows => "maximum_windows"); define!(number MaxColors => "max_colors"); define!(number MaxPairs => "max_pairs"); define!(number NoColorVideo => "no_color_video"); define!(number BufferCapacity => "buffer_capacity"); define!(number DotVertSpacing => "dot_vert_spacing"); define!(number DotHorzSpacing => "dot_horz_spacing"); define!(number MaxMicroAddress => "max_micro_address"); define!(number MaxMicroJump => "max_micro_jump"); define!(number MicroColSize => "micro_col_size"); define!(number MicroLineSize => "micro_line_size"); define!(number NumberOfPins => "number_of_pins"); define!(number OutputResChar => "output_res_char"); define!(number OutputResLine => "output_res_line"); define!(number OutputResHorzInch => "output_res_horz_inch"); define!(number OutputResVertInch => "output_res_vert_inch"); define!(number PrintRate => "print_rate"); define!(number WideCharSize => "wide_char_size"); define!(number Buttons => "buttons"); define!(number BitImageEntwining => "bit_image_entwining"); define!(number BitImageType => "bit_image_type"); define!(number MagicCookieGlitchUl => "magic_cookie_glitch_ul"); define!(number CarriageReturnDelay => "carriage_return_delay"); define!(number NewLineDelay => "new_line_delay"); define!(number BackspaceDelay => "backspace_delay"); define!(number HorizontalTabDelay => "horizontal_tab_delay"); define!(number NumberOfFunctionKeys => "number_of_function_keys"); define!(string BackTab => "back_tab"); define!(string Bell => "bell"); define!(string CarriageReturn => "carriage_return"); define!(string ClearAllTabs => "clear_all_tabs"); define!(string ClearScreen => "clear_screen"); define!(string ClrEol => "clr_eol"); define!(string ClrEos => "clr_eos"); define!(string CommandCharacter => "command_character"); define!(string CursorDown => "cursor_down"); define!(string CursorHome => "cursor_home"); define!(string CursorInvisible => "cursor_invisible"); define!(string CursorLeft => "cursor_left"); define!(string CursorMemAddress => "cursor_mem_address"); define!(string CursorNormal => "cursor_normal"); define!(string CursorRight => "cursor_right"); define!(string CursorToLl => "cursor_to_ll"); define!(string CursorUp => "cursor_up"); define!(string CursorVisible => "cursor_visible"); define!(string DeleteCharacter => "delete_character"); define!(string DeleteLine => "delete_line"); define!(string DisStatusLine => "dis_status_line"); define!(string DownHalfLine => "down_half_line"); define!(string EnterAltCharsetMode => "enter_alt_charset_mode"); define!(string EnterBlinkMode => "enter_blink_mode"); define!(string EnterBoldMode => "enter_bold_mode"); define!(string EnterCaMode => "enter_ca_mode"); define!(string EnterDeleteMode => "enter_delete_mode"); define!(string EnterDimMode => "enter_dim_mode"); define!(string EnterInsertMode => "enter_insert_mode"); define!(string EnterSecureMode => "enter_secure_mode"); define!(string EnterProtectedMode => "enter_protected_mode"); define!(string EnterReverseMode => "enter_reverse_mode"); define!(string EnterStandoutMode => "enter_standout_mode"); define!(string EnterUnderlineMode => "enter_underline_mode"); define!(string ExitAltCharsetMode => "exit_alt_charset_mode"); define!(string ExitAttributeMode => "exit_attribute_mode"); define!(string ExitCaMode => "exit_ca_mode"); define!(string ExitDeleteMode => "exit_delete_mode"); define!(string ExitInsertMode => "exit_insert_mode"); define!(string ExitStandoutMode => "exit_standout_mode"); define!(string ExitUnderlineMode => "exit_underline_mode"); define!(string FlashScreen => "flash_screen"); define!(string FormFeed => "form_feed"); define!(string FromStatusLine => "from_status_line"); define!(string Init1String => "init_1string"); define!(string Init2String => "init_2string"); define!(string Init3String => "init_3string"); define!(string InitFile => "init_file"); define!(string InsertCharacter => "insert_character"); define!(string InsertLine => "insert_line"); define!(string InsertPadding => "insert_padding"); define!(string KeyBackspace => "key_backspace"); define!(string KeyCATab => "key_catab"); define!(string KeyClear => "key_clear"); define!(string KeyCTab => "key_ctab"); define!(string KeyDc => "key_dc"); define!(string KeyDl => "key_dl"); define!(string KeyDown => "key_down"); define!(string KeyEic => "key_eic"); define!(string KeyEol => "key_eol"); define!(string KeyEos => "key_eos"); define!(string KeyF0 => "key_f0"); define!(string KeyF1 => "key_f1"); define!(string KeyF10 => "key_f10"); define!(string KeyF2 => "key_f2"); define!(string KeyF3 => "key_f3"); define!(string KeyF4 => "key_f4"); define!(string KeyF5 => "key_f5"); define!(string KeyF6 => "key_f6"); define!(string KeyF7 => "key_f7"); define!(string KeyF8 => "key_f8"); define!(string KeyF9 => "key_f9"); define!(string KeyHome => "key_home"); define!(string KeyIc => "key_ic"); define!(string KeyIl => "key_il"); define!(string KeyLeft => "key_left"); define!(string KeyLl => "key_ll"); define!(string KeyNPage => "key_npage"); define!(string KeyPPage => "key_ppage"); define!(string KeyRight => "key_right"); define!(string KeySf => "key_sf"); define!(string KeySr => "key_sr"); define!(string KeySTab => "key_stab"); define!(string KeyUp => "key_up"); define!(string KeypadLocal => "keypad_local"); define!(string KeypadXmit => "keypad_xmit"); define!(string LabF0 => "lab_f0"); define!(string LabF1 => "lab_f1"); define!(string LabF10 => "lab_f10"); define!(string LabF2 => "lab_f2"); define!(string LabF3 => "lab_f3"); define!(string LabF4 => "lab_f4"); define!(string LabF5 => "lab_f5"); define!(string LabF6 => "lab_f6"); define!(string LabF7 => "lab_f7"); define!(string LabF8 => "lab_f8"); define!(string LabF9 => "lab_f9"); define!(string MetaOff => "meta_off"); define!(string MetaOn => "meta_on"); define!(string Newline => "newline"); define!(string PadChar => "pad_char"); define!(string PKeyKey => "pkey_key"); define!(string PKeyLocal => "pkey_local"); define!(string PKeyXmit => "pkey_xmit"); define!(string PrintScreen => "print_screen"); define!(string PrtrOff => "prtr_off"); define!(string PrtrOn => "prtr_on"); define!(string RepeatChar => "repeat_char"); define!(string Reset1String => "reset_1string"); define!(string Reset2String => "reset_2string"); define!(string Reset3String => "reset_3string"); define!(string ResetFile => "reset_file"); define!(string RestoreCursor => "restore_cursor"); define!(string SaveCursor => "save_cursor"); define!(string ScrollForward => "scroll_forward"); define!(string ScrollReverse => "scroll_reverse"); define!(string SetTab => "set_tab"); define!(string SetWindow => "set_window"); define!(string Tab => "tab"); define!(string ToStatusLine => "to_status_line"); define!(string UnderlineChar => "underline_char"); define!(string UpHalfLine => "up_half_line"); define!(string InitProg => "init_prog"); define!(string KeyA1 => "key_a1"); define!(string KeyA3 => "key_a3"); define!(string KeyB2 => "key_b2"); define!(string KeyC1 => "key_c1"); define!(string KeyC3 => "key_c3"); define!(string PrtrNon => "prtr_non"); define!(string CharPadding => "char_padding"); define!(string AcsChars => "acs_chars"); define!(string PlabNorm => "plab_norm"); define!(string KeyBTab => "key_btab"); define!(string EnterXonMode => "enter_xon_mode"); define!(string ExitXonMode => "exit_xon_mode"); define!(string EnterAmMode => "enter_am_mode"); define!(string ExitAmMode => "exit_am_mode"); define!(string XonCharacter => "xon_character"); define!(string XoffCharacter => "xoff_character"); define!(string EnaAcs => "ena_acs"); define!(string LabelOn => "label_on"); define!(string LabelOff => "label_off"); define!(string KeyBeg => "key_beg"); define!(string KeyCancel => "key_cancel"); define!(string KeyClose => "key_close"); define!(string KeyCommand => "key_command"); define!(string KeyCopy => "key_copy"); define!(string KeyCreate => "key_create"); define!(string KeyEnd => "key_end"); define!(string KeyEnter => "key_enter"); define!(string KeyExit => "key_exit"); define!(string KeyFind => "key_find"); define!(string KeyHelp => "key_help"); define!(string KeyMark => "key_mark"); define!(string KeyMessage => "key_message"); define!(string KeyMove => "key_move"); define!(string KeyNext => "key_next"); define!(string KeyOpen => "key_open"); define!(string KeyOptions => "key_options"); define!(string KeyPrevious => "key_previous"); define!(string KeyPrint => "key_print"); define!(string KeyRedo => "key_redo"); define!(string KeyReference => "key_reference"); define!(string KeyRefresh => "key_refresh"); define!(string KeyReplace => "key_replace"); define!(string KeyRestart => "key_restart"); define!(string KeyResume => "key_resume"); define!(string KeySave => "key_save"); define!(string KeySuspend => "key_suspend"); define!(string KeyUndo => "key_undo"); define!(string KeySBeg => "key_sbeg"); define!(string KeySCancel => "key_scancel"); define!(string KeySCommand => "key_scommand"); define!(string KeySCopy => "key_scopy"); define!(string KeySCreate => "key_screate"); define!(string KeySDc => "key_sdc"); define!(string KeySDl => "key_sdl"); define!(string KeySelect => "key_select"); define!(string KeySEnd => "key_send"); define!(string KeySEol => "key_seol"); define!(string KeySExit => "key_sexit"); define!(string KeySFind => "key_sfind"); define!(string KeySHelp => "key_shelp"); define!(string KeySHome => "key_shome"); define!(string KeySIc => "key_sic"); define!(string KeySLeft => "key_sleft"); define!(string KeySMessage => "key_smessage"); define!(string KeySMove => "key_smove"); define!(string KeySNext => "key_snext"); define!(string KeySOptions => "key_soptions"); define!(string KeySPrevious => "key_sprevious"); define!(string KeySPrint => "key_sprint"); define!(string KeySRedo => "key_sredo"); define!(string KeySReplace => "key_sreplace"); define!(string KeySRight => "key_sright"); define!(string KeySRsume => "key_srsume"); define!(string KeySSave => "key_ssave"); define!(string KeySSuspend => "key_ssuspend"); define!(string KeySUndo => "key_sundo"); define!(string ReqForInput => "req_for_input"); define!(string KeyF11 => "key_f11"); define!(string KeyF12 => "key_f12"); define!(string KeyF13 => "key_f13"); define!(string KeyF14 => "key_f14"); define!(string KeyF15 => "key_f15"); define!(string KeyF16 => "key_f16"); define!(string KeyF17 => "key_f17"); define!(string KeyF18 => "key_f18"); define!(string KeyF19 => "key_f19"); define!(string KeyF20 => "key_f20"); define!(string KeyF21 => "key_f21"); define!(string KeyF22 => "key_f22"); define!(string KeyF23 => "key_f23"); define!(string KeyF24 => "key_f24"); define!(string KeyF25 => "key_f25"); define!(string KeyF26 => "key_f26"); define!(string KeyF27 => "key_f27"); define!(string KeyF28 => "key_f28"); define!(string KeyF29 => "key_f29"); define!(string KeyF30 => "key_f30"); define!(string KeyF31 => "key_f31"); define!(string KeyF32 => "key_f32"); define!(string KeyF33 => "key_f33"); define!(string KeyF34 => "key_f34"); define!(string KeyF35 => "key_f35"); define!(string KeyF36 => "key_f36"); define!(string KeyF37 => "key_f37"); define!(string KeyF38 => "key_f38"); define!(string KeyF39 => "key_f39"); define!(string KeyF40 => "key_f40"); define!(string KeyF41 => "key_f41"); define!(string KeyF42 => "key_f42"); define!(string KeyF43 => "key_f43"); define!(string KeyF44 => "key_f44"); define!(string KeyF45 => "key_f45"); define!(string KeyF46 => "key_f46"); define!(string KeyF47 => "key_f47"); define!(string KeyF48 => "key_f48"); define!(string KeyF49 => "key_f49"); define!(string KeyF50 => "key_f50"); define!(string KeyF51 => "key_f51"); define!(string KeyF52 => "key_f52"); define!(string KeyF53 => "key_f53"); define!(string KeyF54 => "key_f54"); define!(string KeyF55 => "key_f55"); define!(string KeyF56 => "key_f56"); define!(string KeyF57 => "key_f57"); define!(string KeyF58 => "key_f58"); define!(string KeyF59 => "key_f59"); define!(string KeyF60 => "key_f60"); define!(string KeyF61 => "key_f61"); define!(string KeyF62 => "key_f62"); define!(string KeyF63 => "key_f63"); define!(string ClrBol => "clr_bol"); define!(string ClearMargins => "clear_margins"); define!(string SetLeftMargin => "set_left_margin"); define!(string SetRightMargin => "set_right_margin"); define!(string LabelFormat => "label_format"); define!(string SetClock => "set_clock"); define!(string DisplayClock => "display_clock"); define!(string RemoveClock => "remove_clock"); define!(string CreateWindow => "create_window"); define!(string GotoWindow => "goto_window"); define!(string Hangup => "hangup"); define!(string DialPhone => "dial_phone"); define!(string QuickDial => "quick_dial"); define!(string Tone => "tone"); define!(string Pulse => "pulse"); define!(string FlashHook => "flash_hook"); define!(string FixedPause => "fixed_pause"); define!(string WaitTone => "wait_tone"); define!(string User0 => "user0"); define!(string User1 => "user1"); define!(string User2 => "user2"); define!(string User3 => "user3"); define!(string User4 => "user4"); define!(string User5 => "user5"); define!(string User6 => "user6"); define!(string User7 => "user7"); define!(string User8 => "user8"); define!(string User9 => "user9"); define!(string OrigPair => "orig_pair"); define!(string OrigColors => "orig_colors"); define!(string InitializeColor => "initialize_color"); define!(string InitializePair => "initialize_pair"); define!(string SetColorPair => "set_color_pair"); define!(string ChangeCharPitch => "change_char_pitch"); define!(string ChangeLinePitch => "change_line_pitch"); define!(string ChangeResHorz => "change_res_horz"); define!(string ChangeResVert => "change_res_vert"); define!(string DefineChar => "define_char"); define!(string EnterDoublewideMode => "enter_doublewide_mode"); define!(string EnterDraftQuality => "enter_draft_quality"); define!(string EnterItalicsMode => "enter_italics_mode"); define!(string EnterLeftwardMode => "enter_leftward_mode"); define!(string EnterMicroMode => "enter_micro_mode"); define!(string EnterNearLetterQuality => "enter_near_letter_quality"); define!(string EnterNormalQuality => "enter_normal_quality"); define!(string EnterShadowMode => "enter_shadow_mode"); define!(string EnterSubscriptMode => "enter_subscript_mode"); define!(string EnterSuperscriptMode => "enter_superscript_mode"); define!(string EnterUpwardMode => "enter_upward_mode"); define!(string ExitDoublewideMode => "exit_doublewide_mode"); define!(string ExitItalicsMode => "exit_italics_mode"); define!(string ExitLeftwardMode => "exit_leftward_mode"); define!(string ExitMicroMode => "exit_micro_mode"); define!(string ExitShadowMode => "exit_shadow_mode"); define!(string ExitSubscriptMode => "exit_subscript_mode"); define!(string ExitSuperscriptMode => "exit_superscript_mode"); define!(string ExitUpwardMode => "exit_upward_mode"); define!(string MicroColumnAddress => "micro_column_address"); define!(string MicroDown => "micro_down"); define!(string MicroLeft => "micro_left"); define!(string MicroRight => "micro_right"); define!(string MicroRowAddress => "micro_row_address"); define!(string MicroUp => "micro_up"); define!(string OrderOfPins => "order_of_pins"); define!(string SelectCharSet => "select_char_set"); define!(string SetBottomMargin => "set_bottom_margin"); define!(string SetBottomMarginParm => "set_bottom_margin_parm"); define!(string SetLeftMarginParm => "set_left_margin_parm"); define!(string SetRightMarginParm => "set_right_margin_parm"); define!(string SetTopMargin => "set_top_margin"); define!(string SetTopMarginParm => "set_top_margin_parm"); define!(string StartBitImage => "start_bit_image"); define!(string StartCharSetDef => "start_char_set_def"); define!(string StopBitImage => "stop_bit_image"); define!(string StopCharSetDef => "stop_char_set_def"); define!(string SubscriptCharacters => "subscript_characters"); define!(string SuperscriptCharacters => "superscript_characters"); define!(string TheseCauseCr => "these_cause_cr"); define!(string ZeroMotion => "zero_motion"); define!(string CharSetNames => "char_set_names"); define!(string KeyMouse => "key_mouse"); define!(string MouseInfo => "mouse_info"); define!(string ReqMousePos => "req_mouse_pos"); define!(string GetMouse => "get_mouse"); define!(string PkeyPlab => "pkey_plab"); define!(string DeviceType => "device_type"); define!(string CodeSetInit => "code_set_init"); define!(string Set0DesSeq => "set0_des_seq"); define!(string Set1DesSeq => "set1_des_seq"); define!(string Set2DesSeq => "set2_des_seq"); define!(string Set3DesSeq => "set3_des_seq"); define!(string SetLrMargin => "set_lr_margin"); define!(string SetTbMargin => "set_tb_margin"); define!(string BitImageRepeat => "bit_image_repeat"); define!(string BitImageNewline => "bit_image_newline"); define!(string BitImageCarriageReturn => "bit_image_carriage_return"); define!(string ColorNames => "color_names"); define!(string DefineBitImageRegion => "define_bit_image_region"); define!(string EndBitImageRegion => "end_bit_image_region"); define!(string SetColorBand => "set_color_band"); define!(string SetPageLength => "set_page_length"); define!(string DisplayPcChar => "display_pc_char"); define!(string EnterPcCharsetMode => "enter_pc_charset_mode"); define!(string ExitPcCharsetMode => "exit_pc_charset_mode"); define!(string EnterScancodeMode => "enter_scancode_mode"); define!(string ExitScancodeMode => "exit_scancode_mode"); define!(string PcTermOptions => "pc_term_options"); define!(string ScancodeEscape => "scancode_escape"); define!(string AltScancodeEsc => "alt_scancode_esc"); define!(string EnterHorizontalHlMode => "enter_horizontal_hl_mode"); define!(string EnterLeftHlMode => "enter_left_hl_mode"); define!(string EnterLowHlMode => "enter_low_hl_mode"); define!(string EnterRightHlMode => "enter_right_hl_mode"); define!(string EnterTopHlMode => "enter_top_hl_mode"); define!(string EnterVerticalHlMode => "enter_vertical_hl_mode"); define!(string SetAAttributes => "set_a_attributes"); define!(string SetPglenInch => "set_pglen_inch"); define!(string TermcapInit2 => "termcap_init2"); define!(string TermcapReset => "termcap_reset"); define!(string LinefeedIfNotLf => "linefeed_if_not_lf"); define!(string BackspaceIfNotBs => "backspace_if_not_bs"); define!(string OtherNonFunctionKeys => "other_non_function_keys"); define!(string ArrowKeyMap => "arrow_key_map"); define!(string AcsULcorner => "acs_ulcorner"); define!(string AcsLLcorner => "acs_llcorner"); define!(string AcsURcorner => "acs_urcorner"); define!(string AcsLRcorner => "acs_lrcorner"); define!(string AcsLTee => "acs_ltee"); define!(string AcsRTee => "acs_rtee"); define!(string AcsBTee => "acs_btee"); define!(string AcsTTee => "acs_ttee"); define!(string AcsHLine => "acs_hline"); define!(string AcsVLine => "acs_vline"); define!(string AcsPlus => "acs_plus"); define!(string MemoryLock => "memory_lock"); define!(string MemoryUnlock => "memory_unlock"); define!(string BoxChars1 => "box_chars_1"); define!(string ChangeScrollRegion => "change_scroll_region"; top: u32, bottom: u32); define!(string ColumnAddress => "column_address"; x: u32); define!(string CursorAddress => "cursor_address"; y: u32, x: u32); define!(string EraseChars => "erase_chars"; count: u32); define!(string ParmDch => "parm_dch"; count: u32); define!(string ParmDeleteLine => "parm_delete_line"; count: u32); define!(string ParmDownCursor => "parm_down_cursor"; count: u32); define!(string ParmIch => "parm_ich"; count: u32); define!(string ParmIndex => "parm_index"; count: u32); define!(string ParmInsertLine => "parm_insert_line"; count: u32); define!(string ParmLeftCursor => "parm_left_cursor"; count: u32); define!(string ParmRightCursor => "parm_right_cursor"; count: u32); define!(string ParmRindex => "parm_rindex"; count: u32); define!(string ParmUpCursor => "parm_up_cursor"; count: u32); define!(string ParmDownMicro => "parm_down_micro"; count: u32); define!(string ParmLeftMicro => "parm_left_micro"; count: u32); define!(string ParmRightMicro => "parm_right_micro"; count: u32); define!(string ParmUpMicro => "parm_up_micro"; count: u32); define!(string RowAddress => "row_address"; y: u32); define!(string SetAttributes => "set_attributes"; standout: bool, underline: bool, reverse: bool, blink: bool, dim: bool, bold: bool, invisible: bool, protected: bool, alt_charset: bool); define!(string SetAForeground => "set_a_foreground"; color: u8); define!(string SetABackground => "set_a_background"; color: u8); define!(string SetForeground => "set_foreground"; color: u8); define!(string SetBackground => "set_background"; color: u8); // Extended capabilities from screen. define!(boolean XTermTitle => "XT"); define!(boolean BrightAttribute => "AX"); define!(boolean XTermMouse => "XM"); // Extended capabilities from tmux. define!(boolean TrueColor => "Tc"); define!(string SetClipboard => "Ms"; selection: String, content: Vec); define!(string SetCursorStyle => "Ss"; kind: u8); define!(string ResetCursorStyle => "Se"); // True color extended capabilities from vim. define!(string SetTrueColorForeground => "8f"; r: u8, g: u8, b: u8); define!(string SetTrueColorBackground => "8b"; r: u8, g: u8, b: u8); define!(string ResetCursorColor => "Cr"); define!(string SetCursorColor => "Cs"; color: String); #[cfg(test)] mod test { use super::*; use crate::Database; #[test] fn cursor_address() { assert_eq!( b"\x1B[3;5H".to_vec(), Database::from_path("tests/cancer-256color") .unwrap() .get::() .unwrap() .expand() .parameters(2, 4) .to_vec() .unwrap() ); assert_eq!( b"\x1B[3;5H".to_vec(), Database::from_path("tests/cancer-256color") .unwrap() .get::() .unwrap() .expand() .x(4) .y(2) .to_vec() .unwrap() ); assert_eq!( b"\x1B[38;2;50;100;150m".to_vec(), Database::from_path("tests/cancer-256color") .unwrap() .get::() .unwrap() .expand() .r(50) .g(100) .b(150) .to_vec() .unwrap() ); assert_eq!( b"\x1B]clipboard:set:PRIMARY:hue\x07".to_vec(), Database::from_path("tests/cancer-256color") .unwrap() .get::() .unwrap() .expand() .selection("PRIMARY") .content("hue") .to_vec() .unwrap() ); } } terminfo-0.8.0/src/database.rs000064400000000000000000000151721046102023000143630ustar 00000000000000// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE // Version 2, December 2004 // // Copyleft (ↄ) meh. | http://meh.schizofreni.co // // Everyone is permitted to copy and distribute verbatim or modified // copies of this license document, and changing it is allowed as long // as the name is changed. // // DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE // TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION // // 0. You just DO WHAT THE FUCK YOU WANT TO. use dirs; use fnv::FnvHasher; use std::collections::HashMap; use std::env; use std::fs::{self, File}; use std::hash::BuildHasherDefault; use std::io::Read; use std::path::{Path, PathBuf}; use crate::capability::{Capability, Value}; use crate::error::{self, Error}; use crate::names; use crate::parser::compiled; /// A capability database. #[derive(Eq, PartialEq, Clone, Debug)] pub struct Database { name: String, aliases: Vec, description: String, inner: HashMap>, } /// Builder for a new `Database`. #[derive(Default, Debug)] pub struct Builder { name: Option, aliases: Vec, description: Option, inner: HashMap>, } impl Builder { /// Build the database. pub fn build(self) -> Result { Ok(Database { name: self.name.ok_or(())?, aliases: self.aliases, description: self.description.ok_or(())?, inner: self.inner, }) } /// Set the terminal name. pub fn name>(&mut self, name: T) -> &mut Self { self.name = Some(name.into()); self } /// Set the terminal aliases. pub fn aliases(&mut self, iter: I) -> &mut Self where T: Into, I: IntoIterator, { self.aliases = iter.into_iter().map(|a| a.into()).collect(); self } /// Set the terminal description. pub fn description>(&mut self, description: T) -> &mut Self { self.description = Some(description.into()); self } /// Set a capability. /// /// ## Example /// /// ``` /// use terminfo::{Database, capability as cap}; /// /// let mut info = Database::new(); /// info.name("foo"); /// info.description("foo terminal"); /// /// // Set the amount of available colors. /// info.set(cap::MaxColors(16)); /// /// info.build().unwrap(); /// ``` pub fn set<'a, C: Capability<'a>>(&'a mut self, value: C) -> &mut Self { if !self.inner.contains_key(C::name()) { if let Some(value) = C::into(value) { self.inner.insert(C::name().into(), value); } } self } /// Set a raw capability. /// /// ## Example /// /// ``` /// use terminfo::{Database, capability as cap}; /// /// let mut info = Database::new(); /// info.name("foo"); /// info.description("foo terminal"); /// /// // Set the amount of available colors. /// info.raw("colors", 16); /// /// info.build().unwrap(); /// ``` pub fn raw, V: Into>(&mut self, name: S, value: V) -> &mut Self { let name = name.as_ref(); let name = names::ALIASES.get(name).map(|s| *s).unwrap_or(name); if !self.inner.contains_key(name) { self.inner.insert(name.into(), value.into()); } self } } impl Database { /// Create a new empty database. pub fn new() -> Builder { Builder::default() } /// Load a database from the current environment. pub fn from_env() -> error::Result { if let Ok(name) = env::var("TERM") { Self::from_name(name) } else { Err(Error::NotFound) } } /// Load a database for the given name. pub fn from_name>(name: N) -> error::Result { let name = name.as_ref(); let first = name.chars().next().ok_or(Error::NotFound)?; // See https://manpages.debian.org/buster/ncurses-bin/terminfo.5.en.html#Fetching_Compiled_Descriptions let mut search = Vec::::new(); if let Some(dir) = env::var_os("TERMINFO") { search.push(dir.into()); } else { if let Some(mut home) = dirs::home_dir() { home.push(".terminfo"); search.push(home.into()); } } if let Ok(dirs) = env::var("TERMINFO_DIRS") { for dir in dirs.split(':') { search.push(dir.into()); } } // handle non-FHS systems like Termux if let Ok(prefix) = env::var("PREFIX") { let path = Path::new(&prefix); search.push(path.join("etc/terminfo")); search.push(path.join("lib/terminfo")); search.push(path.join("share/terminfo")); } search.push("/etc/terminfo".into()); search.push("/lib/terminfo".into()); search.push("/usr/share/terminfo".into()); search.push("/boot/system/data/terminfo".into()); for path in search { if fs::metadata(&path).is_err() { continue; } // Check standard location. { let mut path = path.clone(); path.push(first.to_string()); path.push(name); if fs::metadata(&path).is_ok() { return Self::from_path(path); } } // Check non-standard location. { let mut path = path.clone(); path.push(format!("{:x}", first as usize)); path.push(name); if fs::metadata(&path).is_ok() { return Self::from_path(path); } } } Err(Error::NotFound) } /// Load a database from the given path. pub fn from_path>(path: P) -> error::Result { let mut file = File::open(path)?; let mut buffer = Vec::new(); file.read_to_end(&mut buffer)?; Self::from_buffer(buffer) } /// Load a database from a buffer. pub fn from_buffer>(buffer: T) -> error::Result { if let Ok((_, database)) = compiled::parse(buffer.as_ref()) { Ok(database.into()) } else { Err(Error::Parse) } } /// The terminal name. pub fn name(&self) -> &str { &self.name } /// The terminal aliases. pub fn aliases(&self) -> &[String] { &self.aliases } /// The terminal description. pub fn description(&self) -> &str { &self.description } /// Get a capability. /// /// ## Example /// /// ``` /// use terminfo::{Database, capability as cap}; /// /// let info = Database::from_env().unwrap(); /// let colors: i32 = info.get::().unwrap().into(); /// ``` pub fn get<'a, C: Capability<'a>>(&'a self) -> Option { C::from(self.inner.get(C::name())) } /// Get a capability by name. /// /// ## Note /// /// This interface only makes sense for extended capabilities since they /// don't have standardized types. /// /// ## Example /// /// ``` /// use terminfo::Database; /// /// let info = Database::from_env().unwrap(); /// let truecolor = info.raw("Tc").is_some(); /// ``` pub fn raw>(&self, name: S) -> Option<&Value> { let name = name.as_ref(); let name = names::ALIASES.get(name).map(|s| *s).unwrap_or(name); self.inner.get(name) } } terminfo-0.8.0/src/error.rs000064400000000000000000000034631046102023000137500ustar 00000000000000// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE // Version 2, December 2004 // // Copyleft (ↄ) meh. | http://meh.schizofreni.co // // Everyone is permitted to copy and distribute verbatim or modified // copies of this license document, and changing it is allowed as long // as the name is changed. // // DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE // TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION // // 0. You just DO WHAT THE FUCK YOU WANT TO. use std::error; use std::fmt; use std::io; #[derive(Debug)] pub enum Error { /// IO error. Io(io::Error), /// Database not found. NotFound, /// Parsing error. Parse, /// Expansion error. Expand(Expand), } #[derive(Eq, PartialEq, Copy, Clone, Debug)] pub enum Expand { /// The expansion string is invalid. Invalid, /// There was a type mismatch while expanding. TypeMismatch, /// The stack underflowed while expanding. StackUnderflow, } pub type Result = ::std::result::Result; impl From for Error { fn from(value: io::Error) -> Self { Error::Io(value) } } impl From for Error { fn from(value: Expand) -> Self { Error::Expand(value) } } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> ::std::result::Result<(), fmt::Error> { match *self { Error::Io(ref err) => err.fmt(f), Error::NotFound => f.write_str(&"Capability database not found."), Error::Parse => f.write_str("Failed to parse capability database."), Error::Expand(ref err) => match *err { Expand::Invalid => f.write_str("The expansion string is invalid."), Expand::StackUnderflow => f.write_str("Not enough elements on the stack."), Expand::TypeMismatch => f.write_str("Type mismatch."), }, } } } impl error::Error for Error {} terminfo-0.8.0/src/expand.rs000064400000000000000000000312241046102023000140720ustar 00000000000000// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE // Version 2, December 2004 // // Copyleft (ↄ) meh. | http://meh.schizofreni.co // // Everyone is permitted to copy and distribute verbatim or modified // copies of this license document, and changing it is allowed as long // as the name is changed. // // DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE // TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION // // 0. You just DO WHAT THE FUCK YOU WANT TO. use std::char; use std::io::{BufWriter, Write}; use crate::error; use crate::parser::expansion::*; /// Trait for items that can be expanded. pub trait Expand { fn expand( &self, output: W, parameters: &[Parameter], context: &mut Context, ) -> error::Result<()>; } /// An expansion parameter. #[derive(Eq, PartialEq, Clone, Debug)] pub enum Parameter { /// A number. Number(i32), /// An ASCII string. String(Vec), } impl Default for Parameter { fn default() -> Self { Parameter::Number(0) } } macro_rules! from { (number $ty:ty) => { impl From<$ty> for Parameter { fn from(value: $ty) -> Self { Parameter::Number(value as i32) } } }; (string ref $ty:ty) => { impl<'a> From<&'a $ty> for Parameter { fn from(value: &'a $ty) -> Self { Parameter::String(value.into()) } } }; (string $ty:ty) => { impl From<$ty> for Parameter { fn from(value: $ty) -> Self { Parameter::String(value.into()) } } }; } from!(number bool); from!(number u8); from!(number i8); from!(number u16); from!(number i16); from!(number u32); from!(number i32); from!(string String); from!(string ref str); from!(string Vec); from!(string ref [u8]); /// The expansion context. /// /// The same context should be passed around through every expansion for the /// same `Database`. #[derive(Eq, PartialEq, Default, Debug)] pub struct Context { pub fixed: [Parameter; 26], pub dynamic: [Parameter; 26], } /// Expand a parametrized string. /// /// ## Examples /// /// Write the expansion to `stdout`. /// /// ``` /// # #[macro_use] extern crate terminfo; /// /// use terminfo::{Database, capability as cap}; /// use std::io; /// /// # fn main() { /// /// let info = Database::from_env().unwrap(); /// /// // Move the cursor to X: 20, Y: 30 /// expand!(io::stdout(), info.get::().unwrap().as_ref(); 20, 30).unwrap(); /// /// # } /// ``` /// /// Load the expansion for later usage. /// /// ``` /// # #[macro_use] extern crate terminfo; /// /// use terminfo::{Database, capability as cap}; /// use std::io; /// /// # fn main() { /// /// let info = Database::from_env().unwrap(); /// /// // Set foreground color to red. /// let red = expand!(info.get::().unwrap().as_ref(); 1).unwrap(); /// let on_blue = expand!(info.get::().unwrap().as_ref(); 4).unwrap(); /// /// # } /// ``` #[macro_export] macro_rules! expand { ($value:expr) => ( $crate::expand!($value;) ); ($value:expr => $context:expr) => ( $crate::expand!($value => $context;) ); ($value:expr; $($item:expr),*) => ( $crate::expand!($value => &mut ::std::default::Default::default(); $($item),*) ); ($value:expr => $context:expr; $($item:expr),*) => ({ let mut output = ::std::vec::Vec::new(); $crate::expand!(&mut output, $value => $context; $($item),*).map(|()| output) }); ($output:expr, $value:expr) => ( $crate::expand!($output, $value;) ); ($output:expr, $value:expr => $context:expr) => ( $crate::expand!($output, $value => $context;) ); ($output:expr, $value:expr; $($item:expr),*) => ( $crate::expand!($output, $value => &mut ::std::default::Default::default(); $($item),*) ); ($output:expr, $value:expr => $context:expr; $($item:expr),*) => ({ use $crate::Expand; $value.expand($output, &[$($item.into()),*], $context) }) } impl Expand for [u8] { fn expand( &self, output: W, parameters: &[Parameter], context: &mut Context, ) -> error::Result<()> { let mut output = BufWriter::new(output); let mut input = self; let mut params: [Parameter; 9] = Default::default(); let mut stack = Vec::new(); let mut conditional = false; let mut incremented = false; for (dest, source) in params.iter_mut().zip(parameters.iter()) { *dest = source.clone(); } macro_rules! next { () => { match parse(input) { Ok((rest, item)) => { input = rest; item } Err(_) => return Err(error::Expand::Invalid.into()), } }; } 'main: while !input.is_empty() { match next!() { Item::Conditional(Conditional::If) => { conditional = true; } Item::Conditional(Conditional::End) if conditional => { conditional = false; } Item::Conditional(Conditional::Then) if conditional => match stack.pop() { Some(Parameter::Number(0)) => { let mut level = 0; while !input.is_empty() { match next!() { Item::Conditional(Conditional::End) | Item::Conditional(Conditional::Else) if level == 0 => { continue 'main } Item::Conditional(Conditional::If) => level += 1, Item::Conditional(Conditional::End) => level -= 1, _ => (), } } return Err(error::Expand::Invalid.into()); } Some(_) => (), None => return Err(error::Expand::StackUnderflow.into()), }, Item::Conditional(Conditional::Else) if conditional => { let mut level = 0; while !input.is_empty() { match next!() { Item::Conditional(Conditional::End) if level == 0 => continue 'main, Item::Conditional(Conditional::If) => level += 1, Item::Conditional(Conditional::End) => level -= 1, _ => (), } } return Err(error::Expand::Invalid.into()); } Item::Conditional(..) => return Err(error::Expand::Invalid.into()), Item::String(value) => output.write_all(value)?, Item::Constant(Constant::Character(ch)) => { stack.push(Parameter::Number(ch as i32)); } Item::Constant(Constant::Integer(value)) => { stack.push(Parameter::Number(value)); } Item::Variable(Variable::Length) => match stack.pop() { Some(Parameter::String(ref value)) => { stack.push(Parameter::Number(value.len() as i32)); } Some(_) => { return Err(error::Expand::TypeMismatch.into()); } None => { return Err(error::Expand::StackUnderflow.into()); } }, Item::Variable(Variable::Push(index)) => { stack.push(params[index as usize].clone()); } Item::Variable(Variable::Set(dynamic, index)) => { if let Some(value) = stack.pop() { if dynamic { context.dynamic[index as usize] = value.clone(); } else { context.fixed[index as usize] = value.clone(); } } else { return Err(error::Expand::StackUnderflow.into()); } } Item::Variable(Variable::Get(dynamic, index)) => { if dynamic { stack.push(context.dynamic[index as usize].clone()); } else { stack.push(context.fixed[index as usize].clone()); } } Item::Operation(Operation::Increment) if !incremented => { incremented = true; if let (&Parameter::Number(x), &Parameter::Number(y)) = (¶ms[0], ¶ms[1]) { params[0] = Parameter::Number(x + 1); params[1] = Parameter::Number(y + 1); } else { return Err(error::Expand::TypeMismatch.into()); } } Item::Operation(Operation::Increment) => (), Item::Operation(Operation::Binary(operation)) => match (stack.pop(), stack.pop()) { (Some(Parameter::Number(y)), Some(Parameter::Number(x))) => { stack.push(Parameter::Number(match operation { Binary::Add => x + y, Binary::Subtract => x - y, Binary::Multiply => x * y, Binary::Divide => { if y != 0 { x / y } else { 0 } } Binary::Remainder => { if y != 0 { x % y } else { 0 } } Binary::AND => x & y, Binary::OR => x | y, Binary::XOR => x ^ y, Binary::And => (x != 0 && y != 0) as i32, Binary::Or => (x != 0 || y != 0) as i32, Binary::Equal => (x == y) as i32, Binary::Greater => (x > y) as i32, Binary::Lesser => (x < y) as i32, })) } (Some(_), Some(_)) => return Err(error::Expand::TypeMismatch.into()), _ => return Err(error::Expand::StackUnderflow.into()), }, Item::Operation(Operation::Unary(operation)) => match stack.pop() { Some(Parameter::Number(x)) => stack.push(Parameter::Number(match operation { Unary::Not => (x != 0) as i32, Unary::NOT => !x, })), Some(_) => return Err(error::Expand::TypeMismatch.into()), _ => return Err(error::Expand::StackUnderflow.into()), }, Item::Print(p) => { /// Calculate the length of a formatted number. fn length(value: i32, p: &Print) -> usize { let digits = match p.format { Format::Dec => (value as f32).abs().log(10.0).floor() as usize + 1, Format::Oct => (value as f32).abs().log(8.0).floor() as usize + 1, Format::Hex | Format::HEX => { (value as f32).abs().log(16.0).floor() as usize + 1 } _ => unreachable!(), }; let mut length = digits; // Add the minimum number of digits. if p.flags.precision > digits { length += p.flags.precision - digits; } // Add the sign if present. if p.format == Format::Dec && (value < 0 || p.flags.sign) { length += 1; } // Add the alternate representation. if p.flags.alternate { match p.format { Format::Hex | Format::HEX => length += 2, Format::Oct => length += 1, _ => (), } } length } macro_rules! w { ($value:expr) => ( output.write_all($value)? ); ($($item:tt)*) => ( write!(output, $($item)*)? ); } macro_rules! f { (by $length:expr) => ( for _ in 0 .. p.flags.width - $length { output.write_all(if p.flags.space { b" " } else { b"0" })?; } ); (before by $length:expr) => ( if !p.flags.left && p.flags.width > $length { f!(by $length); } ); (after by $length:expr) => ( if p.flags.left && p.flags.width > $length { f!(by $length); } ); (before $value:expr) => ( f!(before by length($value, &p)); ); (after $value:expr) => ( f!(after by length($value, &p)); ); } match (p.format, stack.pop()) { (Format::Str, Some(Parameter::String(ref value))) => { let mut value = &value[..]; if p.flags.precision > 0 && p.flags.precision < value.len() { value = &value[..p.flags.precision]; } f!(before by value.len()); w!(value); f!(after by value.len()); } (Format::Chr, Some(Parameter::Number(value))) => { w!("{}", value as u8 as char) } (Format::Uni, Some(Parameter::Number(value))) => w!( "{}", char::from_u32(value as u32).ok_or(error::Expand::TypeMismatch)? ), (Format::Dec, Some(Parameter::Number(value))) => { f!(before value); if p.flags.sign && value >= 0 { w!(b"+"); } w!("{:.1$}", value, p.flags.precision); f!(after value); } (Format::Oct, Some(Parameter::Number(value))) => { f!(before value); if p.flags.alternate { w!(b"0"); } w!("{:.1$o}", value, p.flags.precision); f!(after value); } (Format::Hex, Some(Parameter::Number(value))) => { f!(before value); if p.flags.alternate { w!(b"0x"); } w!("{:.1$x}", value, p.flags.precision); f!(after value); } (Format::HEX, Some(Parameter::Number(value))) => { f!(before value); if p.flags.alternate { w!(b"0X"); } w!("{:.1$X}", value, p.flags.precision); f!(after value); } (_, Some(_)) => return Err(error::Expand::TypeMismatch.into()), (_, None) => return Err(error::Expand::StackUnderflow.into()), } } } } Ok(()) } } #[cfg(test)] mod test { #[test] fn test_basic_setabf() { assert_eq!(b"\\E[48;5;1m".to_vec(), expand!(b"\\E[48;5;%p1%dm"; 1).unwrap()); } #[test] fn print() { assert_eq!(b"0001".to_vec(), expand!(b"%p1%4d"; 1).unwrap()); assert_eq!(b"10".to_vec(), expand!(b"%p1%o"; 8).unwrap()); } #[test] fn conditional() { assert_eq!(b"1".to_vec(), expand!(b"%?%p1%t1%e2%;"; 1).unwrap()); assert_eq!(b"2".to_vec(), expand!(b"%?%p1%t1%e2%;"; 0).unwrap()); assert_eq!(b"3".to_vec(), expand!(b"%?%p1%t%e%p2%t2%e%p3%t3%;"; 0, 0, 1).unwrap()); } } terminfo-0.8.0/src/lib.rs000064400000000000000000000021001046102023000133500ustar 00000000000000// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE // Version 2, December 2004 // // Copyleft (ↄ) meh. | http://meh.schizofreni.co // // Everyone is permitted to copy and distribute verbatim or modified // copies of this license document, and changing it is allowed as long // as the name is changed. // // DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE // TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION // // 0. You just DO WHAT THE FUCK YOU WANT TO. #[cfg(doctest)] #[doc = include_str!("../README.md")] extern {} extern crate fnv; extern crate nom; extern crate phf; mod error; pub use crate::error::{Error, Result}; /// Parsers for various formats. pub mod parser; /// String capability expansion. #[macro_use] pub mod expand; pub use crate::expand::Expand; /// Standard terminal capabilities. pub mod capability; pub use crate::capability::{Capability, Value}; mod database; pub use crate::database::Database; /// Constants to deal with name differences across terminfo and termcap. pub mod names; terminfo-0.8.0/src/names.rs000064400000000000000000000011031046102023000137070ustar 00000000000000// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE // Version 2, December 2004 // // Copyleft (ↄ) meh. | http://meh.schizofreni.co // // Everyone is permitted to copy and distribute verbatim or modified // copies of this license document, and changing it is allowed as long // as the name is changed. // // DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE // TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION // // 0. You just DO WHAT THE FUCK YOU WANT TO. include!(concat!(env!("OUT_DIR"), "/names.rs")); terminfo-0.8.0/src/parser/compiled.rs000064400000000000000000000165441046102023000157130ustar 00000000000000// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE // Version 2, December 2004 // // Copyleft (ↄ) meh. | http://meh.schizofreni.co // // Everyone is permitted to copy and distribute verbatim or modified // copies of this license document, and changing it is allowed as long // as the name is changed. // // DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE // TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION // // 0. You just DO WHAT THE FUCK YOU WANT TO. use nom::branch::alt; use nom::bytes::streaming::{tag, take, take_until}; use nom::combinator::{complete, cond, map, map_opt, map_parser, opt}; use nom::multi::count; use nom::number::streaming::{le_i16, le_i32}; use nom::IResult; use std::str; use crate::capability::Value; use crate::names; #[derive(Eq, PartialEq, Clone, Debug)] pub struct Database<'a> { names: &'a [u8], standard: Standard<'a>, extended: Option>, } impl<'a> Into for Database<'a> { fn into(self) -> crate::Database { let mut names = self .names .split(|&c| c == b'|') .map(|s| unsafe { str::from_utf8_unchecked(s) }) .map(|s| s.trim()) .collect::>(); let mut database = crate::Database::new(); database.name(names.remove(0)).description(names.pop().unwrap()).aliases(names); for (index, _) in self.standard.booleans.iter().enumerate().filter(|&(_, &value)| value) { if let Some(&name) = names::BOOLEAN.get(&(index as u16)) { database.raw(name, Value::True); } } for (index, &value) in self.standard.numbers.iter().enumerate().filter(|&(_, &n)| n >= 0) { if let Some(&name) = names::NUMBER.get(&(index as u16)) { database.raw(name, Value::Number(value)); } } for (index, &offset) in self.standard.strings.iter().enumerate().filter(|&(_, &n)| n >= 0) { if let Some(&name) = names::STRING.get(&(index as u16)) { let string = &self.standard.table[offset as usize..]; let edge = string.iter().position(|&c| c == 0).unwrap(); database.raw(name, Value::String(Vec::from(&string[..edge]))); } } if let Some(extended) = self.extended { let names = extended .table .split(|&c| c == 0) .skip(extended.strings.iter().cloned().filter(|&n| n >= 0).count()) .map(|s| unsafe { str::from_utf8_unchecked(s) }) .collect::>(); for (index, _) in extended.booleans.iter().enumerate().filter(|&(_, &value)| value) { database.raw(names[index], Value::True); } for (index, &value) in extended.numbers.iter().enumerate().filter(|&(_, &n)| n >= 0) { database.raw(names[extended.booleans.len() + index], Value::Number(value)); } for (index, &offset) in extended.strings.iter().enumerate().filter(|&(_, &n)| n >= 0) { let string = &extended.table[offset as usize..]; let edge = string.iter().position(|&c| c == 0).unwrap(); database.raw( names[extended.booleans.len() + extended.numbers.len() + index], Value::String(Vec::from(&string[..edge])), ); } } database.build().unwrap() } } #[derive(Eq, PartialEq, Clone, Debug)] pub struct Standard<'a> { booleans: Vec, numbers: Vec, strings: Vec, table: &'a [u8], } #[derive(Eq, PartialEq, Clone, Debug)] pub struct Extended<'a> { booleans: Vec, numbers: Vec, strings: Vec, names: Vec, table: &'a [u8], } fn bit_size(magic: &[u8]) -> usize { match magic[1] { 0x01 => 16, 0x02 => 32, _ => unreachable!("unknown magic number"), } } pub fn parse(input: &[u8]) -> IResult<&[u8], Database> { let (input, magic) = alt((tag([0x1A, 0x01]), tag([0x1E, 0x02])))(input)?; let (input, name_size) = size(input)?; let (input, bool_count) = size(input)?; let (input, num_count) = size(input)?; let (input, string_count) = size(input)?; let (input, table_size) = size(input)?; let (input, names) = map_parser(take(name_size), take_until("\x00"))(input)?; let (input, booleans) = count(boolean, bool_count)(input)?; let (input, _) = cond((name_size + bool_count) % 2 != 0, take(1_usize))(input)?; let (input, numbers) = count(|input| capability(input, bit_size(magic)), num_count)(input)?; let (input, strings) = count(|input| capability(input, 16), string_count)(input)?; let (input, table) = take(table_size)(input)?; let (input, extended) = opt(complete(|input| { let (input, _) = cond(table_size % 2 != 0, take(1_usize))(input)?; let (input, ext_bool_count) = size(input)?; let (input, ext_num_count) = size(input)?; let (input, ext_string_count) = size(input)?; let (input, _ext_offset_count) = size(input)?; let (input, ext_table_size) = size(input)?; let (input, booleans) = count(boolean, ext_bool_count)(input)?; let (input, _) = cond(ext_bool_count % 2 != 0, take(1_usize))(input)?; let (input, numbers) = count(|input| capability(input, bit_size(magic)), ext_num_count)(input)?; let (input, strings) = count(|input| capability(input, 16), ext_string_count)(input)?; let (input, names) = count( |input| capability(input, 16), ext_bool_count + ext_num_count + ext_string_count, )(input)?; let (input, table) = take(ext_table_size)(input)?; Ok(( input, Extended { booleans: booleans, numbers: numbers, strings: strings, names: names, table: table, }, )) }))(input)?; Ok(( input, Database { names: names, standard: Standard { booleans: booleans, numbers: numbers, strings: strings, table: table, }, extended: extended, }, )) } fn boolean(input: &[u8]) -> IResult<&[u8], bool> { alt((map(tag([0]), |_| false), map(tag([1]), |_| true)))(input) } fn size(input: &[u8]) -> IResult<&[u8], usize> { map_opt(le_i16, |n| match n { -1 => Some(0), n if n >= 0 => Some(n as usize), _ => None, })(input) } fn capability(input: &[u8], bits: usize) -> IResult<&[u8], i32> { alt(( map_opt( cond(bits == 16, map_opt(le_i16, |n| if n >= -2 { Some(n as i32) } else { None })), |o| o, ), map_opt(cond(bits == 32, map_opt(le_i32, |n| if n >= -2 { Some(n) } else { None })), |o| o), ))(input) } #[cfg(test)] mod test { use super::*; use crate::capability as cap; use std::fs::File; use std::io::Read; use std::path::Path; fn load, F: FnOnce(crate::Database)>(path: P, f: F) { let mut file = File::open(path).unwrap(); let mut buffer = Vec::new(); file.read_to_end(&mut buffer).unwrap(); f(parse(&buffer).unwrap().1.into()) } #[test] fn name() { load("tests/cancer-256color", |db| assert_eq!("cancer-256color", db.name())); } #[test] fn aliases() { load("tests/st-256color", |db| assert_eq!(vec!["stterm-256color"], db.aliases())); } #[test] fn description() { load("tests/cancer-256color", |db| { assert_eq!("terminal cancer with 256 colors", db.description()) }); } #[test] fn standard() { load("tests/st-256color", |db| { assert_eq!(Some(cap::Columns(80)), db.get::()); assert_eq!(Some(cap::AutoRightMargin(true)), db.get::()); assert_eq!(Some(cap::AutoLeftMargin(false)), db.get::()); }); } #[test] fn extended() { load("tests/cancer-256color", |db| { assert_eq!(Some(&cap::Value::True), db.raw("Ts")); assert_eq!(Some(&cap::Value::True), db.raw("AX")); assert_eq!(Some(&cap::Value::String(b"\x1B[2 q".to_vec())), db.raw("Se")); }); } #[test] fn bigger_numbers() { load("tests/xterm-256color", |db| assert_eq!("xterm-256color", db.name())); } } terminfo-0.8.0/src/parser/expansion.rs000064400000000000000000000222661046102023000161210ustar 00000000000000// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE // Version 2, December 2004 // // Copyleft (ↄ) meh. | http://meh.schizofreni.co // // Everyone is permitted to copy and distribute verbatim or modified // copies of this license document, and changing it is allowed as long // as the name is changed. // // DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE // TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION // // 0. You just DO WHAT THE FUCK YOU WANT TO. use crate::parser::util::number; use nom::branch::alt; use nom::bytes::complete; use nom::bytes::streaming::{tag, take, take_while}; use nom::character::is_digit; use nom::character::streaming::one_of; use nom::combinator::{map, opt, value}; use nom::error::{make_error, ErrorKind}; use nom::IResult; #[derive(Eq, PartialEq, Copy, Clone, Debug)] pub enum Item<'a> { String(&'a [u8]), Constant(Constant), Variable(Variable), Operation(Operation), Conditional(Conditional), Print(Print), } #[derive(Eq, PartialEq, Copy, Clone, Debug)] pub enum Constant { Character(u8), Integer(i32), } #[derive(Eq, PartialEq, Copy, Clone, Debug)] pub enum Variable { Length, Push(u8), Set(bool, u8), Get(bool, u8), } #[derive(Eq, PartialEq, Copy, Clone, Debug)] pub enum Operation { Increment, Unary(Unary), Binary(Binary), } #[derive(Eq, PartialEq, Copy, Clone, Debug)] pub enum Unary { Not, NOT, } #[derive(Eq, PartialEq, Copy, Clone, Debug)] pub enum Binary { Add, Subtract, Multiply, Divide, Remainder, AND, OR, XOR, And, Or, Equal, Greater, Lesser, } #[derive(Eq, PartialEq, Copy, Clone, Debug)] pub enum Conditional { If, Then, Else, End, } #[derive(Eq, PartialEq, Copy, Clone, Debug)] pub struct Print { pub flags: Flags, pub format: Format, } #[derive(Eq, PartialEq, Copy, Clone, Debug)] pub enum Format { Chr, Uni, Str, Dec, Oct, Hex, HEX, } #[derive(Eq, PartialEq, Copy, Clone, Default, Debug)] pub struct Flags { pub width: usize, pub precision: usize, pub alternate: bool, pub left: bool, pub sign: bool, pub space: bool, } pub fn parse(input: &[u8]) -> IResult<&[u8], Item> { alt((expansion, string))(input) } fn string(input: &[u8]) -> IResult<&[u8], Item> { map(complete::take_till(|b| b == b'%'), |s| Item::String(s))(input) } fn expansion(input: &[u8]) -> IResult<&[u8], Item> { let (input, _) = tag("%")(input)?; let (input, item) = alt((percent, constant, variable, operation, conditional, print))(input)?; Ok((input, item)) } fn percent(input: &[u8]) -> IResult<&[u8], Item> { value(Item::String(b"%"), tag("%"))(input) } fn constant(input: &[u8]) -> IResult<&[u8], Item> { alt((constant_char, constant_integer))(input) } fn constant_char(input: &[u8]) -> IResult<&[u8], Item> { let (input, _) = tag("'")(input)?; let (input, ch) = take(1_usize)(input)?; let (input, _) = tag("'")(input)?; Ok((input, Item::Constant(Constant::Character(ch[0])))) } fn constant_integer(input: &[u8]) -> IResult<&[u8], Item> { let (input, _) = tag("{")(input)?; let (input, digit) = take_while(is_digit)(input)?; let (input, _) = tag("}")(input)?; Ok((input, Item::Constant(Constant::Integer(number(digit))))) } fn variable(input: &[u8]) -> IResult<&[u8], Item> { let (input, c) = take(1_usize)(input)?; match c { b"l" => Ok((input, Item::Variable(Variable::Length))), b"p" => map(one_of("123456789"), |n| Item::Variable(Variable::Push(n as u8 - b'1')))(input), b"P" => alt(( map(one_of("abcdefghijklmnopqrstuvwxyz"), |n| { Item::Variable(Variable::Set(true, n as u8 - b'a')) }), map(one_of("ABCDEFGHIJKLMNOPQRSTUVWXYZ"), |n| { Item::Variable(Variable::Set(false, n as u8 - b'A')) }), ))(input), b"g" => alt(( map(one_of("abcdefghijklmnopqrstuvwxyz"), |n| { Item::Variable(Variable::Get(true, n as u8 - b'a')) }), map(one_of("ABCDEFGHIJKLMNOPQRSTUVWXYZ"), |n| { Item::Variable(Variable::Get(false, n as u8 - b'A')) }), ))(input), _ => Err(nom::Err::Error(make_error(input, ErrorKind::Switch))), } } fn operation(input: &[u8]) -> IResult<&[u8], Item> { let (input, c) = take(1_usize)(input)?; match c { b"+" => Ok((input, Item::Operation(Operation::Binary(Binary::Add)))), b"-" => Ok((input, Item::Operation(Operation::Binary(Binary::Subtract)))), b"*" => Ok((input, Item::Operation(Operation::Binary(Binary::Multiply)))), b"/" => Ok((input, Item::Operation(Operation::Binary(Binary::Divide)))), b"m" => Ok((input, Item::Operation(Operation::Binary(Binary::Remainder)))), b"i" => Ok((input, Item::Operation(Operation::Increment))), b"&" => Ok((input, Item::Operation(Operation::Binary(Binary::AND)))), b"|" => Ok((input, Item::Operation(Operation::Binary(Binary::OR)))), b"^" => Ok((input, Item::Operation(Operation::Binary(Binary::XOR)))), b"~" => Ok((input, Item::Operation(Operation::Unary(Unary::NOT)))), b"A" => Ok((input, Item::Operation(Operation::Binary(Binary::And)))), b"O" => Ok((input, Item::Operation(Operation::Binary(Binary::Or)))), b"!" => Ok((input, Item::Operation(Operation::Unary(Unary::Not)))), b"=" => Ok((input, Item::Operation(Operation::Binary(Binary::Equal)))), b">" => Ok((input, Item::Operation(Operation::Binary(Binary::Greater)))), b"<" => Ok((input, Item::Operation(Operation::Binary(Binary::Lesser)))), _ => Err(nom::Err::Error(make_error(input, ErrorKind::Switch))), } } fn conditional(input: &[u8]) -> IResult<&[u8], Item> { let (input, c) = take(1_usize)(input)?; match c { b"?" => Ok((input, Item::Conditional(Conditional::If))), b"t" => Ok((input, Item::Conditional(Conditional::Then))), b"e" => Ok((input, Item::Conditional(Conditional::Else))), b";" => Ok((input, Item::Conditional(Conditional::End))), _ => Err(nom::Err::Error(make_error(input, ErrorKind::Switch))), } } fn print(input: &[u8]) -> IResult<&[u8], Item> { let (input, _) = opt(tag(":"))(input)?; let (input, flags) = take_while(is_flag)(input)?; let (input, width) = opt(take_while(is_digit))(input)?; let (input, precision) = opt(|input| { let (input, _) = tag(".")(input)?; let (input, amount) = take_while(is_digit)(input)?; Ok((input, amount)) })(input)?; let (input, format) = one_of("doxXsc")(input)?; Ok(( input, Item::Print(Print { flags: Flags { width: number(width.unwrap_or(b"0")) as usize, precision: number(precision.unwrap_or(b"0")) as usize, alternate: flags.contains(&b'#'), left: flags.contains(&b'-'), sign: flags.contains(&b'+'), space: flags.contains(&b' '), }, format: match format { 'd' => Format::Dec, 'o' => Format::Oct, 'x' => Format::Hex, 'X' => Format::HEX, 's' => Format::Str, 'c' => Format::Chr, 'u' => Format::Uni, _ => unreachable!(), }, }), )) } fn is_flag(i: u8) -> bool { i == b' ' || i == b'-' || i == b'+' || i == b'#' } #[cfg(test)] mod test { use super::*; macro_rules! test { ($string:expr => $($item:tt)*) => ( assert_eq!(Item::$($item)*, parse($string).unwrap().1); ) } #[test] fn string() { test!(b"foobar" => String(b"foobar")); } #[test] fn percent() { test!(b"%%" => String(b"%")); } #[test] fn constant() { test!(b"%{24}" => Constant(Constant::Integer(24))); test!(b"%'a'" => Constant(Constant::Character(b'a'))); } #[test] fn variable() { test!(b"%l" => Variable(Variable::Length)); test!(b"%p1" => Variable(Variable::Push(0))); test!(b"%Pa" => Variable(Variable::Set(true, 0))); test!(b"%PA" => Variable(Variable::Set(false, 0))); test!(b"%ga" => Variable(Variable::Get(true, 0))); test!(b"%gA" => Variable(Variable::Get(false, 0))); } #[test] fn operation() { test!(b"%i" => Operation(Operation::Increment)); test!(b"%+" => Operation(Operation::Binary(Binary::Add))); test!(b"%-" => Operation(Operation::Binary(Binary::Subtract))); test!(b"%*" => Operation(Operation::Binary(Binary::Multiply))); test!(b"%/" => Operation(Operation::Binary(Binary::Divide))); test!(b"%m" => Operation(Operation::Binary(Binary::Remainder))); test!(b"%&" => Operation(Operation::Binary(Binary::AND))); test!(b"%|" => Operation(Operation::Binary(Binary::OR))); test!(b"%^" => Operation(Operation::Binary(Binary::XOR))); test!(b"%~" => Operation(Operation::Unary(Unary::NOT))); test!(b"%A" => Operation(Operation::Binary(Binary::And))); test!(b"%O" => Operation(Operation::Binary(Binary::Or))); test!(b"%!" => Operation(Operation::Unary(Unary::Not))); test!(b"%=" => Operation(Operation::Binary(Binary::Equal))); test!(b"%>" => Operation(Operation::Binary(Binary::Greater))); test!(b"%<" => Operation(Operation::Binary(Binary::Lesser))); } #[test] fn conditional() { test!(b"%?" => Conditional(Conditional::If)); test!(b"%t" => Conditional(Conditional::Then)); test!(b"%e" => Conditional(Conditional::Else)); test!(b"%;" => Conditional(Conditional::End)); } #[test] fn print() { test!(b"%s" => Print(Print { flags: Default::default(), format: Format::Str })); test!(b"% 30s" => Print(Print { flags: Flags { width: 30, space: true, .. Default::default() }, format: Format::Str })); test!(b"%:-3.4d" => Print(Print { flags: Flags { width: 3, precision: 4, left: true, .. Default::default() }, format: Format::Dec })); } } terminfo-0.8.0/src/parser/mod.rs000064400000000000000000000011371046102023000146660ustar 00000000000000// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE // Version 2, December 2004 // // Copyleft (ↄ) meh. | http://meh.schizofreni.co // // Everyone is permitted to copy and distribute verbatim or modified // copies of this license document, and changing it is allowed as long // as the name is changed. // // DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE // TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION // // 0. You just DO WHAT THE FUCK YOU WANT TO. #[macro_use] mod util; pub mod compiled; pub mod expansion; pub mod source; terminfo-0.8.0/src/parser/source.rs000064400000000000000000000104121046102023000154030ustar 00000000000000// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE // Version 2, December 2004 // // Copyleft (ↄ) meh. | http://meh.schizofreni.co // // Everyone is permitted to copy and distribute verbatim or modified // copies of this license document, and changing it is allowed as long // as the name is changed. // // DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE // TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION // // 0. You just DO WHAT THE FUCK YOU WANT TO. use crate::parser::util::unescape; use crate::parser::util::{end, is_eol, is_ws, ws}; use crate::parser::util::{is_printable_no_comma, is_printable_no_control, is_printable_no_pipe}; use nom::branch::alt; use nom::bytes::streaming::{tag, take, take_until, take_while}; use nom::character::{is_digit, streaming::line_ending as eol}; use nom::combinator::{complete, map, map_res, opt}; use nom::error::{make_error, ErrorKind}; use nom::sequence::terminated; use nom::IResult; use std::borrow::Cow; use std::str; #[derive(Eq, PartialEq, Clone, Debug)] pub enum Item<'a> { Comment(&'a str), Definition { name: &'a str, aliases: Vec<&'a str>, description: &'a str }, True(&'a str), Number(&'a str, i16), String(&'a str, Cow<'a, [u8]>), Disable(&'a str), } pub fn parse(input: &[u8]) -> IResult<&[u8], Item> { alt((comment, definition, disable, entry))(input) } fn comment(input: &[u8]) -> IResult<&[u8], Item> { let (input, _) = tag("#")(input)?; let (input, content) = map_res(terminated(take_until("\n"), tag("\n")), str::from_utf8)(input)?; let (input, _) = opt(complete(take_while(is_eol)))(input)?; Ok((input, Item::Comment(content.trim()))) } fn definition(input: &[u8]) -> IResult<&[u8], Item> { let (input, name) = map(take_while(is_printable_no_pipe), |n| unsafe { str::from_utf8_unchecked(n) })(input)?; let (input, _) = tag("|")(input)?; let (input, content) = map(take_while(is_printable_no_comma), |n| unsafe { str::from_utf8_unchecked(n) })(input)?; let (input, _) = tag(",")(input)?; let (input, _) = take_while(is_ws)(input)?; let (input, _) = eol(input)?; let (input, _) = opt(complete(take_while(is_eol)))(input)?; Ok((input, { let mut aliases = content.split(|c| c == '|').map(|n| n.trim()).collect::>(); Item::Definition { name: name, description: aliases.pop().unwrap(), aliases: aliases } })) } fn disable(input: &[u8]) -> IResult<&[u8], Item> { let (input, _) = ws(input)?; let (input, _) = take_while(is_ws)(input)?; let (input, _) = tag("@")(input)?; let (input, name) = map(take_while(is_printable_no_control), |n| unsafe { str::from_utf8_unchecked(n) })( input, )?; let (input, _) = tag(",")(input)?; let (input, _) = take_while(is_ws)(input)?; let (input, _) = end(input)?; let (input, _) = opt(complete(take_while(is_eol)))(input)?; Ok((input, Item::Disable(name))) } fn entry(input: &[u8]) -> IResult<&[u8], Item> { let (input, _) = ws(input)?; let (input, _) = take_while(is_ws)(input)?; let (input, name) = map(take_while(is_printable_no_control), |n| unsafe { str::from_utf8_unchecked(n) })( input, )?; let (input, c) = take(1_usize)(input)?; let (input, value) = match c { b"," => (input, Item::True(name)), b"#" => { let (input, value) = map(take_while(is_digit), |n| unsafe { str::from_utf8_unchecked(n) })(input)?; let (input, _) = tag(",")(input)?; (input, Item::Number(name, value.parse().unwrap())) } b"=" => { let (input, value) = take_while(is_printable_no_comma)(input)?; let (input, _) = tag(",")(input)?; (input, Item::String(name, unescape(value))) } _ => Err(nom::Err::Error(make_error(input, ErrorKind::Switch)))?, }; let (input, _) = take_while(is_ws)(input)?; let (input, _) = end(input)?; let (input, _) = opt(complete(take_while(is_eol)))(input)?; Ok((input, value)) } #[cfg(test)] mod test { use super::*; use std::fs::File; use std::io::Read; #[test] fn parsing() { let mut file = File::open("tests/xterm.terminfo").unwrap(); let mut buffer = Vec::new(); file.read_to_end(&mut buffer).unwrap(); let mut input = &buffer[..]; while !input.is_empty() { match parse(input) { Ok((rest, _)) => input = rest, Err(::nom::Err::Incomplete(_)) => panic!("incomplete"), Err(err) => panic!("parsing: {:?}", err), } } } } terminfo-0.8.0/src/parser/util.rs000064400000000000000000000133001046102023000150570ustar 00000000000000// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE // Version 2, December 2004 // // Copyleft (ↄ) meh. | http://meh.schizofreni.co // // Everyone is permitted to copy and distribute verbatim or modified // copies of this license document, and changing it is allowed as long // as the name is changed. // // DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE // TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION // // 0. You just DO WHAT THE FUCK YOU WANT TO. use nom::branch::alt; use nom::character::streaming::char; use nom::character::{is_digit, streaming::line_ending as eol}; use nom::combinator::eof; use nom::IResult; use std::borrow::Cow; use std::str; use std::u8; const NONE: u8 = 0b000000; const PRINT: u8 = 0b000001; const SPACE: u8 = 0b000010; const CONTROL: u8 = 0b000100; const PIPE: u8 = 0b001000; const COMMA: u8 = 0b010000; const EOL: u8 = 0b100000; // Ugly table of DOOM, gotta run and gun. #[rustfmt::skip] static ASCII: [u8; 256] = [ NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, SPACE, EOL, NONE, NONE, EOL, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, PRINT | SPACE, PRINT, PRINT, PRINT | CONTROL, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT | COMMA | CONTROL, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT | CONTROL, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT | PIPE, PRINT, PRINT, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, ]; #[inline(always)] pub fn is_ws(ch: u8) -> bool { unsafe { ASCII.get_unchecked(ch as usize) & SPACE == SPACE } } #[inline(always)] pub fn is_eol(ch: u8) -> bool { unsafe { ASCII.get_unchecked(ch as usize) & EOL == EOL } } #[inline(always)] pub fn is_printable_no_pipe(ch: u8) -> bool { unsafe { ASCII.get_unchecked(ch as usize) & (PRINT | PIPE) == PRINT } } #[inline(always)] pub fn is_printable_no_comma(ch: u8) -> bool { unsafe { ASCII.get_unchecked(ch as usize) & (PRINT | COMMA) == PRINT } } #[inline(always)] pub fn is_printable_no_control(ch: u8) -> bool { unsafe { ASCII.get_unchecked(ch as usize) & (PRINT | CONTROL) == PRINT } } pub fn ws(input: &[u8]) -> IResult<&[u8], char> { alt((char(' '), char('\t')))(input) } pub fn end(input: &[u8]) -> IResult<&[u8], &[u8]> { alt((eof, eol))(input) } #[inline] pub fn number(i: &[u8]) -> i32 { let mut n: i32 = 0; for &ch in i { let d = (ch as i32).wrapping_sub(b'0' as i32); if d <= 9 { n = n.saturating_mul(10).saturating_add(d); } } n } pub fn unescape(i: &[u8]) -> Cow<[u8]> { fn escape>(output: &mut Vec, iter: &mut I) { match iter.next() { None => (), Some(b'a') => output.push(0x07), Some(b'b') => output.push(0x08), Some(b'E') | Some(b'e') => output.push(0x1B), Some(b'f') => output.push(0x0C), Some(b'l') | Some(b'n') => output.push(b'\n'), Some(b'r') => output.push(b'\r'), Some(b's') => output.push(b' '), Some(b't') => output.push(b'\t'), Some(b'^') => output.push(b'^'), Some(b'\\') => output.push(b'\\'), Some(b',') => output.push(b','), Some(b':') => output.push(b':'), Some(b'0') => output.push(0x00), Some(a) if is_digit(a) => match (iter.next(), iter.next()) { (Some(b), Some(c)) if is_digit(b) && is_digit(c) => { if let Ok(number) = u8::from_str_radix(unsafe { str::from_utf8_unchecked(&[a, b, c]) }, 8) { output.push(number); } else { output.extend(&[a, b, c]); } } (Some(b), None) => output.extend(&[b'\\', a, b]), (None, None) => output.extend(&[b'\\', a]), _ => unreachable!(), }, Some(ch) => output.extend(&[b'\\', ch]), } } fn control>(output: &mut Vec, iter: &mut I) { match iter.next() { None => (), Some(ch) if ch >= b'A' && ch <= b'Z' => output.push(ch - b'A' + 1), Some(ch) if ch >= b'a' && ch <= b'z' => output.push(ch - b'a' + 1), Some(ch) => output.extend(&[b'^', ch]), } } let mut chars = i.iter().cloned(); let mut offset = 0; while let Some(ch) = chars.next() { if ch == b'\\' || ch == b'^' { let mut output = (&i[..offset]).to_vec(); match ch { b'\\' => escape(&mut output, &mut chars), b'^' => control(&mut output, &mut chars), _ => unreachable!(), } while let Some(ch) = chars.next() { match ch { b'\\' => escape(&mut output, &mut chars), b'^' => control(&mut output, &mut chars), ch => output.push(ch), } } return Cow::Owned(output); } offset += 1; } Cow::Borrowed(i) } terminfo-0.8.0/tests/cancer+secret000064400000000000000000000004111046102023000152510ustar 00000000000000cancer+secret| secret features4CVsy ![48;2;%p1%d;%p2%d;%p3%dm[38;2;%p1%d;%p2%d;%p3%dm]cursor:bg:-]cursor:bg:%p1%s]clipboard:set:%p1%s:%p2%s[2 q[%p1%d qAXTcTsXMXT8b8fCrCsMsSeSsterminfo-0.8.0/tests/cancer-256color000064400000000000000000000047071046102023000153550ustar 000000000000001ncancer-256color| terminal cancer with 256 colorsP&*.9JLPWY`dhosw{  %+17=BGNRW\`gnrz/2=@BE  ")07>EKQX_fmu} %-5=EMU]elsz N [%i%p1%d;%p2%dr[%i%p1%dG[%i%p1%d;%p2%dH [?25l[?25h[?25h(0[%p1%dX(B(B[?5h[?5l[@[3;5~[3~[3;2~OB[2;2~OP[21~OQOROS[15~[17~[18~[19~[20~[7~[2~[2;5~OD[6~[5~OCOA[?1l>[?1h=[%p1%dP[%p1%dM[%p1%dB[%p1%d@[%p1%dS[%p1%dL[%p1%dD[%p1%dC[%p1%dT[%p1%dA>[?7h[?7h[?1;3;4;6l>[?1000l[?25h8[%i%p1%dd7 M%?%p9%t(0%e(B%;[0%?%p6%t;1%;%?%p5%t;2%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;mH OwOyOuOqOs``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~[?7h[?7l)0[8~OM[3;2~[2;2~[6;2~[5;2~[23~[24~[15;2~[17;2~[18;2~[19;2~[20;2~[21;2~[23;2~[24;2~[15;5~[17;5~[18;5~[19;5~[20;5~[21;5~[23;5~[24;5~[15;6~[17;6~[18;6~[19;6~[20;6~[21;6~[23;6~[24;6~[15;3~[17;3~[18;3~[19;3~[20;3~[21;3~[23;3~[24;3~[%i%d;%dR[?1;2c[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m(B(04CVsy ![48;2;%p1%d;%p2%d;%p3%dm[38;2;%p1%d;%p2%d;%p3%dm]cursor:bg:-]cursor:bg:%p1%s]clipboard:set:%p1%s:%p2%s[2 q[%p1%d qAXTcTsXMXT8b8fCrCsMsSeSsterminfo-0.8.0/tests/st-256color000064400000000000000000000043621046102023000145450ustar 000000000000007ist-256color|stterm-256color|simpleterm with 256 colorsP&*.9JLPWYfjnuy}  $*.26<BHNTY^einsw~  Y\^chmqv{ !)19AIQYahov}  '.5=EMU]emu|!` [%i%p1%d;%p2%dr[%i%p1%dG[%i%p1%d;%p2%dH [?25l[?12l[?25h[?25h(0[?1049h[%p1%dX(B[?1049l[?5h[?5l>[?1034l[3;5~[3~[3;2~OB[2;2~OP[21~OQOROS[15~[17~[18~[19~[20~[1~[2~[2;5~OD[6~[5~OCOA[?1l>[?1h=[%p1%dP[%p1%dM[%p1%dB[%p1%d@[%p1%dS[%p1%dL[%p1%dD[%p1%dC[%p1%dAc>[?1034l8[%i%p1%dd7 M%?%p9%t(0%e(B%;[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;mH ]0;[1~[5~Ou[4~[6~``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~)0[4~OM[3;2~[2;2~[6;2~[5;2~[23~[24~[15;2~[17;2~[18;2~[19;2~[20;2~[21;2~[23;2~[24;2~[15;5~[17;5~[18;5~[19;5~[20;5~[21;5~[23;5~[24;5~[15;6~[17;6~[18;6~[19;6~[20;6~[21;6~[23;6~[24;6~[15;3~[17;3~[18;3~[19;3~[20;3~[21;3~[23;3~[24;3~[%i%d;%dR[?1;2c]4;%p1%d;rgb:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;mterminfo-0.8.0/tests/xterm-256color000064400000000000000000000072011046102023000152510ustar 00000000000000%&xterm-256color|xterm with 256 colorsP&*.9JLPWYfjnx|$(,26:>DJPV\`einsw~ '0BEPSUX  '.5<CIOV]dks{#+3;CKS[cjqx nsy} [%i%p1%d;%p2%dr[%i%p1%dG[%i%p1%d;%p2%dH [?25l[?12l[?25h[?12;25h(0[?1049h[%p1%dX(B(B[?1049l[?5h$<100/>[?5l[!p[?3;4l>[3~OBOP[21~OQOROS[15~[17~[18~[19~[20~OH[2~OD[6~[5~OCOA[?1l>[?1h=[?1034l[?1034h[%p1%dP[%p1%dM[%p1%dB[%p1%d@[%p1%dS[%p1%dL[%p1%dD[%p1%dC[%p1%dT[%p1%dA%p1%c[%p2%{1}%-%dbc]104[!p[?3;4l>8[%i%p1%dd7 M%?%p9%t(0%e(B%;[0%?%p6%t;1%;%?%p5%t;2%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;mH OE``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~[?7h[?7lOFOM[3;2~[2;2~[6;2~[5;2~[23~[24~[15;2~[17;2~[18;2~[19;2~[20;2~[21;2~[23;2~[24;2~[15;5~[17;5~[18;5~[19;5~[20;5~[21;5~[23;5~[24;5~[15;6~[17;6~[18;6~[19;6~[20;6~[21;6~[23;6~[24;6~[15;3~[17;3~[18;3~[19;3~[20;3~[21;3~[23;3~[24;3~[%i%d;%dR[?%[;0123456789]c]104]4;%p1%d;rgb:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\[<[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;mlmIs*0:Zahov} %,3:AHOV]dkry !$'*06;@EJOSX]bglrx~ !'-39?EINSX]bfjnrw|]112]12;%p1%s]52;%p1%s;%p2%s[2 q[%p1%d q[?1006;1000%?%p1%{1}%=%th%el%;[3;3~[3;4~[3;5~[3;6~[3;7~[2;3~[2;4~[2;5~[2;6~[2;7~[6;3~[6;4~[6;5~[6;6~[6;7~[5;3~[5;4~[5;5~[5;6~[5;7~[<%p1%d;%p2%d;%p3%d;%?%p4%tM%em%;AXG0XTU8CrCsE0E3MsS0SeSsTSXMgrbomgsbomkDC3kDC4kDC5kDC6kDC7kDNkDN3kDN4kDN5kDN6kDN7kEND3kEND4kEND5kEND6kEND7kEND8kHOM3kHOM4kHOM5kHOM6kHOM7kHOM8kIC3kIC4kIC5kIC6kIC7kLFT3kLFT4kLFT5kLFT6kLFT7kNXT3kNXT4kNXT5kNXT6kNXT7kPRV3kPRV4kPRV5kPRV6kPRV7kRIT3kRIT4kRIT5kRIT6kRIT7kUPkUP3kUP4kUP5kUP6kUP7ka2kb1kb3kc2rmxxsmxxxmterminfo-0.8.0/tests/xterm.terminfo000064400000000000000000001245141046102023000155310ustar 00000000000000# $XTermId: terminfo,v 1.161 2012/09/05 00:24:08 tom Exp $ # # Updates/notes/new entries (e.g., xterm-8bit, xterm-16color, xterm-256color) # - Thomas E. Dickey # #------------------------------------------------------------------------------ # Copyright 1996-2011,2012 by Thomas E. Dickey # # All Rights Reserved # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name(s) of the above copyright # holders shall not be used in advertising or otherwise to promote the # sale, use or other dealings in this Software without prior written # authorization. #------------------------------------------------------------------------------ # # Special Capabilities: # -------------------- # ich has a corresponding capability that inserts a single blank. We could # have used ich1=\E[@, which works with ncurses, but that is not standard # behavior. If it is set, then SVr4 vi (e.g., Solaris 2.6) emits both # smir/rmir and ich1. # meml locks memory above the cursor; memu unlocks (ala HP terminals). This # is not recognized by some older (e.g., SVr3) tic programs, but none # do more than warn about it. Ignore the warning. # smcup clears memory before switching to the alternate screen. The older # (deprecated) \E[?47h did not do this, requiring applications to # embed a \E[2J in the rmcup string. However, that behavior cannot # be disabled via titeInhibit, making that resource not function as # intended on systems with terminfo. # rs2/is2 are shorter with XFree86 xterm because it supports DECSTR. We # use the shorter sequence for compatibility with the termcap, which # is trimmed to keep it shorter than 1023 characters. It (escape \E[!p) # replaces these in the conventional vt100 reset-string: # \E7 - save cursor (fixes origin-mode side-effect) # \E[r - reset scrolling margins # \E[m - reset SGR (including color) # \E[?7h - reset wraparound mode (DECAWM) # \E[?1l - reset application cursor keys (DECCKM) # \E[?6l - reset origin mode (DECOM) # \E8 - restore cursor # DECSTR is recognized by XFree86 xterm even in vt52 mode. # # Editing Keypad: # -------------- # XFree86 xterm emulates vt220 if the decTerminalID resource is set to 200 or # higher. Otherwise it emulates a vt100 or vt52 depending on the value of the # resource. When emulating a vt220, we support the editing keypad. Sun and PC # keyboards have an editing keypad which is similar to the vt220: # # VT220 editing keypad # ---------------------------- # Find Insert Remove # Select Prev Next # ---------------------------- # # Sun/PC editing keypad # ---------------------------- # Insert Home PageUp # Delete End PageDn # ---------------------------- # # If the sunKeyboard resource is true, we map it this way (adjusting the values # of Home, End and Delete): # VT220 Sun/PC # ---------------------------- # Find Home # Select End # Insert Insert # Remove Delete # Prev PageUp # Next PageDn # ---------------------------- # # Note that all of the keys on the editing keypad transmit escape sequences. A # vt220 does this only when in vt220 mode; when emulating a vt100 the editing # keypad is inactive. # # Alternative keycodes: # -------------------- # Several of the function keys have alternative names, depending on the type of # host which your xterm is connected to. DEC (i.e., the VMS system) uses F15 # as the HELP key, F16 as the DO key. Unix applications generally do not do # this. Curses applications in particular, assign a unique keycode to each # capability string. These terminal descriptions do not have conflicting # definitions, to ensure that Unix curses applications use a consistent set of # keycodes. To get a VMS-bias, make these substitutions: # 1. change khome to kfnd # 2. change kend to kslt # The original xterm-r6 entry does in fact have a VMS bias. # # Some legacy applications using the termcap emulation may expect kll where # we have specified kend. # # Function keys with modifiers (Sun/PC): # ------------------------------------- # Shift-Fx - kf{12+x} # Control-Fx - kf{24+x} # Shift-Control-Fx - kf{36+x} # # The terminfo defines some special keys which are documented as "shifted", # e.g., kDC is shifted-delete-character. # # Note however, that even though the terminfo says a key might be sent, there # may be conflicts which prevent this. For example, it is common to use # shifted pageup and pagedown for window manager functions. The default # translation for xterm since X11R4 has overridden shifted Insert, Select, # PageUp and PageDown, which correspond to terminfo kIC, kEND, kPRV and kNXT # respectively. # xterm-new|modern xterm terminal emulator, npc, indn=\E[%p1%dS, kb2=\EOE, kcbt=\E[Z, kent=\EOM, rin=\E[%p1%dT, use=xterm+pcfkeys, use=xterm+tmux, use=xterm-basic, # # Encode modifiers using parameters (see "Xterm Control Sequences" ctlseqs.ms). # Note that this is unrelated to PCTERM. # # Some names are extensions allowed by ncurses, e.g., # kDN, kDN5, kDN6, kLFT5, kLFT6, kRIT5, kRIT6, kUP, kUP5, kUP6 # # The uppercase names are made up, since there are no standards that apply. # If they were limited to two characters, they could in principle be translated # to termcap. However, termcap sizes are limited to 1023 bytes, so there is # little point in ensuring that extended key names can be translated to # termcap. A terminfo file can be up to 4096 bytes; using all extended keys # that xterm can generate would in fact exceed that limit. # # The numbers correspond to the modifier parameters documented in Xterm # Control Sequences: # # 2 Shift # 3 Alt # 4 Shift + Alt # 5 Control # 6 Shift + Control # 7 Alt + Control # 8 Shift + Alt + Control # # X/Open Curses defines some shift combinations, which are also used here # where applicable. Since it does define some shift combinations, no number # (2) is used for suffixing the made-up names. Some combinations are not # useful, e.g., they may reboot your computer, or they may require too many # fingers. I stopped at modifier 7, just to keep things simple -TD # # XTerm resources: # --------------- # The xterm+pcfn, xterm+pcf0, xterm+pcf1, xterm+pcf2 and xterm+pcf3 fragments # correspond to default resource settings for xterm on a 104-key PC keyboard # with 12 function-keys: # # *sunKeyboard:false # *oldXtermFKeys:false # *modifyCursorKeys:2 # *modifyFunctionKeys:2 # *ctrlFKeys:10 # # The key numbers are computed based on the modifiers: # # kf1-kf12 are F1-F12 # kf13-kf24 are shift F1-F12 # kf25-kf36 are control F1-F12 # kf37-kf48 are control+shift F1-F12 # kf49-kf60 are alt F1-F12 # kf61-kf63 are shift-alt F1-F3 # # Note that ncurses would allow definition of kf64 and beyond, if there were # an application that required it. # xterm+pcfkeys|fragment for PC-style keys, use=xterm+app, use=xterm+pcf2, use=xterm+pce2, use=xterm+pcc2, # This chunk is based on suggestions by Ailin Nemui and Nicholas Marriott, who # asked for some of xterm's advanced features to be added to its terminfo # entry. It defines extended capabilities not found in standard terminfo or # termcap. These are useful in tmux, for instance, hence the name. # # One caveat in adding extended capabilities in ncurses is that if the names # are longer than two characters, then they will not be visible through the # termcap interface. # # Ms modifies the selection/clipboard. Its parameters are # p1 = the storage unit (clipboard, selection or cut buffer) # p2 = the base64-encoded clipboard content. # # Ss is used to set the cursor style as described by the DECSCUSR # function to a block or underline. # Se resets the cursor style to the terminal power-on default. # # Cs and Ce set and reset the cursor colour. xterm+tmux|advanced xterm features used in tmux, Cr=\E]112\007, Cs=\E]12;%p1%s\007, Ms=\E]52;%p1%s;%p2%s\007, Se=\E[2 q, Ss=\E[%p1%d q, # # The ctrlFKeys resource is only relevant to the xterm+pcfn and xterm+pcfN # entries, since the modifyFunctionKeys resource overrides ctrlFKeys when it is # positive. A different choice of ctrlFKeys would give a different set of # function-key strings. xterm+pcfn|fragment with modifyFunctionKeys:-1 and ctrlFKeys:10, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\EOQ, kf20=\E[34~, kf21=\E[42~, kf22=\E[43~, kf23=\E[44~, kf24=\E[45~, kf25=\E[46~, kf26=\E[47~, kf27=\E[48~, kf28=\E[49~, kf29=\E[50~, kf3=\EOR, kf30=\E[51~, kf31=\E[52~, kf32=\E[53~, kf33=\E[54~, kf34=\E[55~, kf35=\E[56~, kf36=\E[57~, kf37=\E[58~, kf38=\E[59~, kf39=\E[60~, kf4=\EOS, kf40=\E[61~, kf41=\E[62~, kf42=\E[63~, kf43=\E[64~, kf44=\E[65~, kf45=\E[66~, kf46=\E[67~, kf47=\E[68~, kf48=\E[69~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, # Changing ctrlFKeys to 12 would let us number the keys using just shift- and # control- modifiers: # kf1-kf12 are F1-F12 # kf13-kf24 are shift F1-F12 # kf25-kf36 are control F1-F12 # kf37-kf48 are control+shift F1-F12 xterm+pcfN|fragment with modifyFunctionKeys:-1 and ctrlFKeys:12, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\EOQ, kf20=\E[34~, kf21=\E[42~, kf22=\E[43~, kf23=\E[44~, kf24=\E[45~, kf25=\E[46~, kf26=\E[47~, kf27=\E[48~, kf28=\E[49~, kf29=\E[50~, kf3=\EOR, kf30=\E[51~, kf31=\E[52~, kf32=\E[53~, kf33=\E[54~, kf34=\E[55~, kf35=\E[56~, kf36=\E[57~, kf37=\E[58~, kf38=\E[59~, kf39=\E[60~, kf4=\EOS, kf40=\E[61~, kf41=\E[62~, kf42=\E[63~, kf43=\E[64~, kf44=\E[65~, kf45=\E[66~, kf46=\E[67~, kf47=\E[68~, kf48=\E[69~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, xterm+pcf0|fragment with modifyFunctionKeys:0, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\EO2P, kf14=\EO2Q, kf15=\EO2R, kf16=\EO2S, kf17=\E[15;2~, kf18=\E[17;2~, kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~, kf21=\E[20;2~, kf22=\E[21;2~, kf23=\E[23;2~, kf24=\E[24;2~, kf25=\EO5P, kf26=\EO5Q, kf27=\EO5R, kf28=\EO5S, kf29=\E[15;5~, kf3=\EOR, kf30=\E[17;5~, kf31=\E[18;5~, kf32=\E[19;5~, kf33=\E[20;5~, kf34=\E[21;5~, kf35=\E[23;5~, kf36=\E[24;5~, kf37=\EO6P, kf38=\EO6Q, kf39=\EO6R, kf4=\EOS, kf40=\EO6S, kf41=\E[15;6~, kf42=\E[17;6~, kf43=\E[18;6~, kf44=\E[19;6~, kf45=\E[20;6~, kf46=\E[21;6~, kf47=\E[23;6~, kf48=\E[24;6~, kf49=\EO3P, kf5=\E[15~, kf50=\EO3Q, kf51=\EO3R, kf52=\EO3S, kf53=\E[15;3~, kf54=\E[17;3~, kf55=\E[18;3~, kf56=\E[19;3~, kf57=\E[20;3~, kf58=\E[21;3~, kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~, kf61=\EO4P, kf62=\EO4Q, kf63=\EO4R, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, # This is almost the same as xterm+pcf2 because the unmodified keys all happen # to have a pattern that forces the modifier to the same position. xterm+pcf1|fragment with modifyFunctionKeys:1, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[2P, kf14=\E[2Q, kf15=\E[2R, kf16=\E[2S, kf17=\E[15;2~, kf18=\E[17;2~, kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~, kf21=\E[20;2~, kf22=\E[21;2~, kf23=\E[23;2~, kf24=\E[24;2~, kf25=\E[5P, kf26=\E[5Q, kf27=\E[5R, kf28=\E[5S, kf29=\E[15;5~, kf3=\EOR, kf30=\E[17;5~, kf31=\E[18;5~, kf32=\E[19;5~, kf33=\E[20;5~, kf34=\E[21;5~, kf35=\E[23;5~, kf36=\E[24;5~, kf37=\E[6P, kf38=\E[6Q, kf39=\E[6R, kf4=\EOS, kf40=\E[6S, kf41=\E[15;6~, kf42=\E[17;6~, kf43=\E[18;6~, kf44=\E[19;6~, kf45=\E[20;6~, kf46=\E[21;6~, kf47=\E[23;6~, kf48=\E[24;6~, kf49=\E[3P, kf5=\E[15~, kf50=\E[3Q, kf51=\E[3R, kf52=\E[3S, kf53=\E[15;3~, kf54=\E[17;3~, kf55=\E[18;3~, kf56=\E[19;3~, kf57=\E[20;3~, kf58=\E[21;3~, kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~, kf61=\E[4P, kf62=\E[4Q, kf63=\E[4R, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, xterm+pcf2|fragment with modifyFunctionKeys:2, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[1;2P, kf14=\E[1;2Q, kf15=\E[1;2R, kf16=\E[1;2S, kf17=\E[15;2~, kf18=\E[17;2~, kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~, kf21=\E[20;2~, kf22=\E[21;2~, kf23=\E[23;2~, kf24=\E[24;2~, kf25=\E[1;5P, kf26=\E[1;5Q, kf27=\E[1;5R, kf28=\E[1;5S, kf29=\E[15;5~, kf3=\EOR, kf30=\E[17;5~, kf31=\E[18;5~, kf32=\E[19;5~, kf33=\E[20;5~, kf34=\E[21;5~, kf35=\E[23;5~, kf36=\E[24;5~, kf37=\E[1;6P, kf38=\E[1;6Q, kf39=\E[1;6R, kf4=\EOS, kf40=\E[1;6S, kf41=\E[15;6~, kf42=\E[17;6~, kf43=\E[18;6~, kf44=\E[19;6~, kf45=\E[20;6~, kf46=\E[21;6~, kf47=\E[23;6~, kf48=\E[24;6~, kf49=\E[1;3P, kf5=\E[15~, kf50=\E[1;3Q, kf51=\E[1;3R, kf52=\E[1;3S, kf53=\E[15;3~, kf54=\E[17;3~, kf55=\E[18;3~, kf56=\E[19;3~, kf57=\E[20;3~, kf58=\E[21;3~, kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~, kf61=\E[1;4P, kf62=\E[1;4Q, kf63=\E[1;4R, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, xterm+pcf3|fragment with modifyFunctionKeys:3, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[>1;2P, kf14=\E[>1;2Q, kf15=\E[>1;2R, kf16=\E[>1;2S, kf17=\E[>15;2~, kf18=\E[>17;2~, kf19=\E[>18;2~, kf2=\EOQ, kf20=\E[>19;2~, kf21=\E[>20;2~, kf22=\E[>21;2~, kf23=\E[>23;2~, kf24=\E[>24;2~, kf25=\E[>1;5P, kf26=\E[>1;5Q, kf27=\E[>1;5R, kf28=\E[>1;5S, kf29=\E[>15;5~, kf3=\EOR, kf30=\E[>17;5~, kf31=\E[>18;5~, kf32=\E[>19;5~, kf33=\E[>20;5~, kf34=\E[>21;5~, kf35=\E[>23;5~, kf36=\E[>24;5~, kf37=\E[>1;6P, kf38=\E[>1;6Q, kf39=\E[>1;6R, kf4=\EOS, kf40=\E[>1;6S, kf41=\E[>15;6~, kf42=\E[>17;6~, kf43=\E[>18;6~, kf44=\E[>19;6~, kf45=\E[>20;6~, kf46=\E[>21;6~, kf47=\E[>23;6~, kf48=\E[>24;6~, kf49=\E[>1;3P, kf5=\E[15~, kf50=\E[>1;3Q, kf51=\E[>1;3R, kf52=\E[>1;3S, kf53=\E[>15;3~, kf54=\E[>17;3~, kf55=\E[>18;3~, kf56=\E[>19;3~, kf57=\E[>20;3~, kf58=\E[>21;3~, kf59=\E[>23;3~, kf6=\E[17~, kf60=\E[>24;3~, kf61=\E[>1;4P, kf62=\E[>1;4Q, kf63=\E[>1;4R, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, # # The "PC-style" modifier scheme was introduced in xterm patch #94 (1999/3/27) # and revised in patch #167 (2002/8/24). # # The original assignments from patch #94 for cursor-keys had some technical # issues: # # A parameter for a function-key to represent a modifier is just more # bits. But for a cursor-key it may change the behavior of the # application. For instance, emacs decodes the first parameter of a # cursor-key as a repeat count. # # A parameterized string should (really) not begin with SS3 (\EO). # Rather, CSI (\E[) should be used. # # For these reasons, the original assignments were deprecated. For # compatibility reasons, they are still available as a setting of xterm's # modifyCursorKeys resource. These fragments list the modified cursor-keys # that might apply to xterm+pcfkeys with different values of that resource. xterm+pcc3|fragment with modifyCursorKeys:3, kLFT=\E[>1;2D, kRIT=\E[>1;2C, kind=\E[>1;2B, kri=\E[>1;2A, kDN=\E[>1;2B, kDN3=\E[>1;3B, kDN4=\E[>1;4B, kDN5=\E[>1;5B, kDN6=\E[>1;6B, kDN7=\E[>1;7B, kLFT3=\E[>1;3D, kLFT4=\E[>1;4D, kLFT5=\E[>1;5D, kLFT6=\E[>1;6D, kLFT7=\E[>1;7D, kRIT3=\E[>1;3C, kRIT4=\E[>1;4C, kRIT5=\E[>1;5C, kRIT6=\E[>1;6C, kRIT7=\E[>1;7C, kUP=\E[>1;2A, kUP3=\E[>1;3A, kUP4=\E[>1;4A, kUP5=\E[>1;5A, kUP6=\E[>1;6A, kUP7=\E[>1;7A, xterm+pcc2|fragment with modifyCursorKeys:2, kLFT=\E[1;2D, kRIT=\E[1;2C, kind=\E[1;2B, kri=\E[1;2A, kDN=\E[1;2B, kDN3=\E[1;3B, kDN4=\E[1;4B, kDN5=\E[1;5B, kDN6=\E[1;6B, kDN7=\E[1;7B, kLFT3=\E[1;3D, kLFT4=\E[1;4D, kLFT5=\E[1;5D, kLFT6=\E[1;6D, kLFT7=\E[1;7D, kRIT3=\E[1;3C, kRIT4=\E[1;4C, kRIT5=\E[1;5C, kRIT6=\E[1;6C, kRIT7=\E[1;7C, kUP=\E[1;2A, kUP3=\E[1;3A, kUP4=\E[1;4A, kUP5=\E[1;5A, kUP6=\E[1;6A, kUP7=\E[1;7A, xterm+pcc1|fragment with modifyCursorKeys:1, kLFT=\E[2D, kRIT=\E[2C, kind=\E[2B, kri=\E[2A, kDN=\E[2B, kDN3=\E[3B, kDN4=\E[4B, kDN5=\E[5B, kDN6=\E[6B, kDN7=\E[7B, kLFT3=\E[3D, kLFT4=\E[4D, kLFT5=\E[5D, kLFT6=\E[6D, kLFT7=\E[7D, kRIT3=\E[3C, kRIT4=\E[4C, kRIT5=\E[5C, kRIT6=\E[6C, kRIT7=\E[7C, kUP=\E[2A, kUP3=\E[3A, kUP4=\E[4A, kUP5=\E[5A, kUP6=\E[6A, kUP7=\E[7A, xterm+pcc0|fragment with modifyCursorKeys:0, kLFT=\EO2D, kRIT=\EO2C, kind=\EO2B, kri=\EO2A, kDN=\EO2B, kDN3=\EO3B, kDN4=\EO4B, kDN5=\EO5B, kDN6=\EO6B, kDN7=\EO7B, kLFT3=\EO3D, kLFT4=\EO4D, kLFT5=\EO5D, kLFT6=\EO6D, kLFT7=\EO7D, kRIT3=\EO3C, kRIT4=\EO4C, kRIT5=\EO5C, kRIT6=\EO6C, kRIT7=\EO7C, kUP=\EO2A, kUP3=\EO3A, kUP4=\EO4A, kUP5=\EO5A, kUP6=\EO6A, kUP7=\EO7A, # The home/end keys on the editing keypad are also treated as cursor keys. xterm+pce3|fragment with modifyCursorKeys:3, kDC=\E[>3;2~, kEND=\E[>1;2F, kHOM=\E[>1;2H, kIC=\E[>2;2~, kNXT=\E[>6;2~, kPRV=\E[>5;2~, kDC3=\E[>3;3~, kDC4=\E[>3;4~, kDC5=\E[>3;5~, kDC6=\E[>3;6~, kDC7=\E[>3;7~, kEND3=\E[>1;3F, kEND4=\E[>1;4F, kEND5=\E[>1;5F, kEND6=\E[>1;6F, kEND7=\E[>1;7F, kHOM3=\E[>1;3H, kHOM4=\E[>1;4H, kHOM5=\E[>1;5H, kHOM6=\E[>1;6H, kHOM7=\E[>1;7H, kIC3=\E[>2;3~, kIC4=\E[>2;4~, kIC5=\E[>2;5~, kIC6=\E[>2;6~, kIC7=\E[>2;7~, kNXT3=\E[>6;3~, kNXT4=\E[>6;4~, kNXT5=\E[>6;5~, kNXT6=\E[>6;6~, kNXT7=\E[>6;7~, kPRV3=\E[>5;3~, kPRV4=\E[>5;4~, kPRV5=\E[>5;5~, kPRV6=\E[>5;6~, kPRV7=\E[>5;7~, use=xterm+pce0, xterm+pce2|fragment with modifyCursorKeys:2, kDC=\E[3;2~, kEND=\E[1;2F, kHOM=\E[1;2H, kIC=\E[2;2~, kNXT=\E[6;2~, kPRV=\E[5;2~, kDC3=\E[3;3~, kDC4=\E[3;4~, kDC5=\E[3;5~, kDC6=\E[3;6~, kDC7=\E[3;7~, kEND3=\E[1;3F, kEND4=\E[1;4F, kEND5=\E[1;5F, kEND6=\E[1;6F, kEND7=\E[1;7F, kHOM3=\E[1;3H, kHOM4=\E[1;4H, kHOM5=\E[1;5H, kHOM6=\E[1;6H, kHOM7=\E[1;7H, kIC3=\E[2;3~, kIC4=\E[2;4~, kIC5=\E[2;5~, kIC6=\E[2;6~, kIC7=\E[2;7~, kNXT3=\E[6;3~, kNXT4=\E[6;4~, kNXT5=\E[6;5~, kNXT6=\E[6;6~, kNXT7=\E[6;7~, kPRV3=\E[5;3~, kPRV4=\E[5;4~, kPRV5=\E[5;5~, kPRV6=\E[5;6~, kPRV7=\E[5;7~, use=xterm+pce0, xterm+pce1|fragment with modifyCursorKeys:1, kDC=\E[3;2~, kEND=\E[2F, kHOM=\E[2H, kIC=\E[2;2~, kNXT=\E[6;2~, kPRV=\E[5;2~, kDC3=\E[3;3~, kDC4=\E[3;4~, kDC5=\E[3;5~, kDC6=\E[3;6~, kDC7=\E[3;7~, kEND3=\E[3F, kEND4=\E[4F, kEND5=\E[5F, kEND6=\E[6F, kEND7=\E[7F, kHOM3=\E[3H, kHOM4=\E[4H, kHOM5=\E[5H, kHOM6=\E[6H, kHOM7=\E[7H, kIC3=\E[2;3~, kIC4=\E[2;4~, kIC5=\E[2;5~, kIC6=\E[2;6~, kIC7=\E[2;7~, kNXT3=\E[6;3~, kNXT4=\E[6;4~, kNXT5=\E[6;5~, kNXT6=\E[6;6~, kNXT7=\E[6;7~, kPRV3=\E[5;3~, kPRV4=\E[5;4~, kPRV5=\E[5;5~, kPRV6=\E[5;6~, kPRV7=\E[5;7~, use=xterm+pce0, xterm+pce0|fragment with modifyCursorKeys:0, kDC=\E[3;2~, kEND=\EO2F, kHOM=\EO2H, kIC=\E[2;2~, kNXT=\E[6;2~, kPRV=\E[5;2~, kDC3=\E[3;3~, kDC4=\E[3;4~, kDC5=\E[3;5~, kDC6=\E[3;6~, kDC7=\E[3;7~, kEND3=\EO3F, kEND4=\EO4F, kEND5=\EO5F, kEND6=\EO6F, kEND7=\EO7F, kHOM3=\EO3H, kHOM4=\EO4H, kHOM5=\EO5H, kHOM6=\EO6H, kHOM7=\EO7H, kIC3=\E[2;3~, kIC4=\E[2;4~, kIC5=\E[2;5~, kIC6=\E[2;6~, kIC7=\E[2;7~, kNXT3=\E[6;3~, kNXT4=\E[6;4~, kNXT5=\E[6;5~, kNXT6=\E[6;6~, kNXT7=\E[6;7~, kPRV3=\E[5;3~, kPRV4=\E[5;4~, kPRV5=\E[5;5~, kPRV6=\E[5;6~, kPRV7=\E[5;7~, use=xterm+edit, # # This chunk is used for building the VT220/Sun/PC keyboard variants. xterm-basic|modern xterm terminal emulator - common, OTbs, am, bce, km, mc5i, mir, msgr, xenl, AX, XT, colors#8, cols#80, it#8, lines#24, pairs#64, acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l, clear=\E[H\E[2J, cnorm=\E[?12l\E[?25h, cr=^M, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, cvvis=\E[?12;25h, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, flash=\E[?5h$<100/>\E[?5l, home=\E[H, hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=^J, invis=\E[8m, is2=\E[!p\E[?3;4l\E[4l\E>, kmous=\E[M, mc0=\E[i, mc4=\E[4i, mc5=\E[5i, meml=\El, memu=\Em, op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM, rmacs=\E(B, rmam=\E[?7l, rmcup=\E[?1049l, rmir=\E[4l, rmkx=\E[?1l\E>, rmm=\E[?1034l, rmso=\E[27m, rmul=\E[24m, rs1=\Ec, rs2=\E[!p\E[?3;4l\E[4l\E>, sc=\E7, setab=\E[4%p1%dm, setaf=\E[3%p1%dm, setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m, setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m, sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m, sgr0=\E(B\E[m, smacs=\E(0, smam=\E[?7h, smcup=\E[?1049h, smir=\E[4h, smkx=\E[?1h\E=, smm=\E[?1034h, smso=\E[7m, smul=\E[4m, tbc=\E[3g, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?1;2c, u9=\E[c, vpa=\E[%i%p1%dd, E3=\E[3;J, use=xterm+kbs, # # The xterm-new description has all of the features, but is not completely # compatible with vt220. If you are using a Sun or PC keyboard, set the # sunKeyboard resource to true: # + maps the editing keypad # + interprets control-function-key as a second array of keys, so a # 12-fkey keyboard can support vt220's 20-fkeys. # + maps numeric keypad "+" to ",". # + uses DEC-style control sequences for the application keypad. # # Some packagers modify xterm's resource definitions to provide extra function # keys by using the shift-modifier in the translations resource. However, that # interferes with the DECUDK functionality. # xterm-vt220|xterm emulating vt220, ka1=\EOw, ka3=\EOy, kb2=\EOu, kc1=\EOq, kc3=\EOs, kcbt=\E[Z, kend=\E[4~, kent=\EOM, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\EOQ, kf20=\E[34~, kf3=\EOR, kf4=\EOS, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\E[1~, kich1=\E[2~, knp=\E[6~, kpp=\E[5~, ka2=\EOx, kb1=\EOt, kb3=\EOv, kc2=\EOr, use=xterm+app, use=xterm+edit, use=xterm-basic, # xterm-vt52|xterm emulating dec vt52, cols#80, it#8, lines#24, acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, bel=^G, clear=\EH\EJ, cr=^M, cub1=\ED, cud1=\EB, cuf1=\EC, cup=\EY%p1%' '%+%c%p2%' '%+%c, cuu1=\EA, ed=\EJ, el=\EK, home=\EH, ht=^I, ind=^J, kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA, nel=^M^J, ri=\EI, rmacs=\EG, smacs=\EF, use=xterm+kbs, # # Sun does not number the function keys this way in their sparse termcap; their # terminal descriptions ignore the keypads. kb(7M) states that there are codes # reserved for 64 function keys, 16 each in left, right, top and bottom. Each # keyboard type has a different number of function keys in different # arrangements. Using xkeycaps for reference: # # Type 3: left 10, top 9, right 15 # ------ # kf1-kf9 are XK_F1-XK_F9 # There is no kf10 on this keyboard type. # kf11-kf20 are keysyms XK_L1 through XK_L10. # kf31-kf45 are keysyms XK_R1 through XK_R15. # # However, X's keysymdef.h is hard-coded to make # XK_L1==XK_F11 and # XK_R1==XK_F21, # by someone who was unfamiliar with terminal types other than Sun's. So # xterm uses the internal X keysymbols, but the terminfo entry uses the Sun # numbering scheme. # # Type 4: left 11, top 12, right 15 # ------ # The left-keypad contains an unnumbered Help-key. # The right-keypad also contains NumLock, Ins, Del, Enter, + and - keys which # do not appear to be part of the R-sequence. # # Type 5: left 9, top 12, right (more than one keypad) # ------ # These keyboards do not use the same naming convention, look like a hybrid of # the type 4 and IBM keyboards. # # XTerm resources: # --------------- # Set the modifyFunctionKeys resource to negative (-1) to make it simple to # enter the higher function-key values using shift- and control-modifiers. # xterm-sun|xterm with sun function keys, kb2=\E[218z, kcpy=\E[197z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kdch1=\E[3z, kend=\E[220z, kent=\EOM, kf1=\E[224z, kf10=\E[233z, kf11=\E[192z, kf12=\E[193z, kf13=\E[194z, kf14=\E[195z, kf15=\E[196z, kf17=\E[198z, kf18=\E[199z, kf19=\E[200z, kf2=\E[225z, kf20=\E[201z, kf3=\E[226z, kf31=\E[208z, kf32=\E[209z, kf33=\E[210z, kf34=\E[211z, kf35=\E[212z, kf36=\E[213z, kf38=\E[215z, kf4=\E[227z, kf40=\E[217z, kf42=\E[219z, kf44=\E[221z, kf45=\E[222z, kf46=\E[234z, kf47=\E[235z, kf5=\E[228z, kf6=\E[229z, kf7=\E[230z, kf8=\E[231z, kf9=\E[232z, kfnd=\E[200z, khlp=\E[196z, khome=\E[214z, kich1=\E[2z, knp=\E[222z, kpp=\E[216z, kund=\E[195z, use=xterm-basic, # xterm-hp|xterm with hpterm function keys, kclr=\EJ, kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA, kdch1=\EP, kend=\EF, kf1=\Ep, kf2=\Eq, kf3=\Er, kf4=\Es, kf5=\Et, kf6=\Eu, kf7=\Ev, kf8=\Ew, khome=\Eh, kich1=\EQ, knp=\ES, kpp=\ET, use=xterm-basic, # # scoterm implements 48 function-keys using shift- and control-modifiers to # multiple 12 function-keys. X has a hard-coded limit of 35 function-keys, # but xterm can represent larger values. # # XTerm resources: # --------------- # Set the modifyFunctionKeys resource to negative (-1) to make it simple to # enter the higher function-key values using shift- and control-modifiers. # # Also, set ctrlFKeys resource to 12 (the default is 10) to make xterm see 48 # function-keys on a keyboard with 12 function-keys and 4 control/shift # modifier combinations. # xterm-sco|xterm with SCO function keys, kbeg=\E[E, kdch1=\177, kf1=\E[M, kf10=\E[V, kf11=\E[W, kf12=\E[X, kf13=\E[Y, kf14=\E[Z, kf15=\E[a, kf16=\E[b, kf17=\E[c, kf18=\E[d, kf19=\E[e, kf2=\E[N, kf20=\E[f, kf21=\E[g, kf22=\E[h, kf23=\E[i, kf24=\E[j, kf25=\E[k, kf26=\E[l, kf27=\E[m, kf28=\E[n, kf29=\E[o, kf3=\E[O, kf30=\E[p, kf31=\E[q, kf32=\E[r, kf33=\E[s, kf34=\E[t, kf35=\E[u, kf36=\E[v, kf37=\E[w, kf38=\E[x, kf39=\E[y, kf4=\E[P, kf40=\E[z, kf41=\E[@, kf42=\E[[, kf43=\E[\\, kf44=\E[], kf45=\E[\^, kf46=\E[_, kf47=\E[`, kf48=\E[{, kf5=\E[Q, kf6=\E[R, kf7=\E[S, kf8=\E[T, kf9=\E[U, kich1=\E[L, kmous=\E[>M, knp=\E[G, kpp=\E[I, use=xterm+noapp, use=xterm-basic, # # Other variants (these are all very old entries, from X11R5): xterm-24|xterms|vs100|xterm terminal emulator (X Window System), lines#24, use=xterm-old, xterm-65|xterm with tall window 65x80 (X Window System), lines#65, use=xterm-old, xterm-bold|xterm with bold instead of underline (X Window System), sgr=%?%p9%t\016%e\017%;B\E[0%?%p6%t;1%;%?%p2%t;1%;%?%p1%p3%|%t;7%;m, smso=\E[7m, smul=\E[1m, use=xterm-old, xterm-boldso|xterm with bold for standout (X Window System), rmso=\E[m, smso=\E[1m, use=xterm-old, xterm-mono|monochrome xterm, bce@, colors@, ncv@, pairs@, op@, setab@, setaf@, setb@, setf@, sgr@, use=xterm-old, # # VTxxx terminals are usually set up so that full-screen applications will use # the cursor application mode strings. This is good for full-screen # applications, including legacy applications which may have hard-coded # behavior, but bad for interactive shells (e.g., tcsh, bash) which use arrow # keys to scroll through a history of command strings. # # To see the difference between normal/application modes, consider this example: # + In normal (non-application) mode, the terminal transmits a down-arrow # as \E[C, which happens to echo as a down-arrow. # + In application mode the terminal transmits \EOC, which echoes as C. # That is because the \EO is the SS3 control, which says to use the # character from the G3 character set for the next cell. # # One example of hard-coded behavior would be for applications written to work # with VT52 and VT100 terminals. If the application's parser ignores 'O' and # '?' characters after the escape, then the cursor and keypad strings for the # two terminals are the same. (Indeed, one of the first curses applications # which I used did something like this to cover "ANSI" terminals -TD). # # To make this work (leaving the cursor keys in normal mode), we have to adjust # the terminal initialization sequences: # # smkx/rmkx set/reset the cursor and keypad application modes. We retain # the latter (otherwise many applications fail). # # smcup/rmcup set/restore cursor-addressing mode for full-screen # applications. For xterm, this normally means the alternate # screen, which is not compatible with interactive shells. Some # programs are "smart" and disable these. # xterm-noapp|xterm with cursor keys in normal mode, rmcup@, rmkx=\E>, smcup@, smkx=\E=, use=xterm+noapp, use=xterm, xterm+noapp|fragment with cursor keys in normal mode, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, use=xterm+noapp+pc, xterm+app|fragment with cursor keys in application mode, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, use=xterm+app+pc, xterm+noapp+pc|fragment for noapp pc-style home/end, kend=\E[F, khome=\E[H, xterm+app+pc|fragment for app pc-style home/end, kend=\EOF, khome=\EOH, xterm+edit|fragment for 6-key editing-keypad, kdch1=\E[3~, kich1=\E[2~, knp=\E[6~, kpp=\E[5~, use=xterm+pc+edit, xterm+decedit|fragment for vt220 6-key editing-keypad, kdch1=\E[3~, kich1=\E[2~, knp=\E[6~, kpp=\E[5~, use=xterm+vt+edit, xterm+pc+edit|fragment for pc-style editing keypad, kend=\E[4~, khome=\E[1~, xterm+vt+edit|fragment for vt220-style editing keypad, kfnd=\E[1~, kslt=\E[4~, # # This should work for the commonly used "color xterm" variations (XFree86 # xterm, color_xterm, nxterm, rxvt). Note that it does not set 'bce', so for # XFree86 and and rxvt, some applications that use colors will be less # efficient, and in a few special cases (with "smart" optimization) the wrong # color will be painted in spots. xterm-color|generic "ANSI" color xterm (X Window System), colors#8, ncv@, pairs#64, op=\E[m, setab=\E[4%p1%dm, setaf=\E[3%p1%dm, use=xterm-r6, # # vi may work better with this entry, because vi # doesn't use insert mode much xterm-ic|xterm-vi|xterm with insert character instead of insert mode, mir@, ich=\E[%p1%d@, ich1=\E[@, rmir@, smir@, use=xterm, # # This is used only for testing (it's not relevant to DEC VTxxx terminals, but # to ncurses). xterm-xmc|xterm with magic-cookie glitch, xmc#1, use=xterm-new, # # This one also is primarily for testing ncurses; while the ISO 6429 defines # the REP control, none of the DEC VTxxx terminals (VT52 through VT420) support # it. xterm-rep|xterm with repeat-character control, rep=%p1%c\E[%p2%{1}%-%db, use=xterm-new, # # This is mainly for testing xterm; the real VT220 will not let you switch # character sets without first altering the keyboard language in the setup # screen. Some emulators allow this anyway. (Note that these strings are # normally used only for printers). The parameter to csnm and scs is the same # in both cases: the keyboard language parameter returned by CSI ? 2 6 n. xterm-nrc|xterm with VT220 national replacement character sets, csnm=%?%p1%{1}%=%tNorth American%e%p1%{2}%=%tBritish%e%p1%{3}%=%tFlemish%e%p1%{4}%=%tFrench Canadian%e%p1%{5}%=%tDanish%e%p1%{6}%=%tFinnish%e%p1%{7}%=%tGerman%e%p1%{8}%=%tDutch%e%p1%{9}%=%tItalian%e%p1%{10}%=%tSwiss (French)%e%p1%{11}%=%tSwiss (German)%e%p1%{12}%=%tSwedish%e%p1%{13}%=%tNorwegian%e%p1%{14}%=%tFrench/Belgian%e%p1%{15}%=%tSpanish%;, scs=%?%p1%{1}%=%t\E(B%e%p1%{2}%=%t\E(A%e%p1%{3}%=%t\E(R%e%p1%{4}%=%t\E(9%e%p1%{5}%=%t\E(E%e%p1%{6}%=%t\E(5%e%p1%{7}%=%t\E(K%e%p1%{8}%=%t\E(4%e%p1%{9}%=%t\E(Y%e%p1%{10}%=%t\E(=%e%p1%{11}%=%t\E(=%e%p1%{12}%=%t\E(7%e%p1%{13}%=%t\E(E%e%p1%{14}%=%t\E(R%e%p1%{15}%=%t\E(Z%;, use=xterm-new, # # Foreground 0-15 maps (with toggles) into 30-37 & 90-97 # Background 0-15 maps (with toggles) into 40-47 & 100-107 # # Originally I suppressed setaf/setab, since ANSI specifies only 8 colors, but # Stephen Marley persuaded me to allow the "ANSI" color controls to extend to # 16 colors. (Note that ncurses 4.2 uses setf/setb from this description; # however 5.0 selects either according to their availability). - T.Dickey # # SVr4 curses does not use more than 8 colors anyway, so using 16 colors is # either for terminfo-level applications or via ncurses. xterm-16color|xterm with 16 colors, colors#16, pairs#256, setab=\E[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm, setaf=\E[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm, setb=%p1%{8}%/%{6}%*%{4}%+\E[%d%p1%{8}%m%Pa%?%ga%{1}%=%t4%e%ga%{3}%=%t6%e%ga%{4}%=%t1%e%ga%{6}%=%t3%e%ga%d%;m, setf=%p1%{8}%/%{6}%*%{3}%+\E[%d%p1%{8}%m%Pa%?%ga%{1}%=%t4%e%ga%{3}%=%t6%e%ga%{4}%=%t1%e%ga%{6}%=%t3%e%ga%d%;m, use=xterm+256color, use=xterm-new, # # This uses RGB values 0..1000 # # 256 colors should give 65536 pairs, but terminfo stores numbers in a signed # short. Most people will not notice problems with only 32767 pairs. xterm+256color|xterm 256-color feature, ccc, colors#256, pairs#32767, initc=\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\, setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m, setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m, setb@, setf@, xterm-256color|xterm with 256 colors, use=xterm+256color, use=xterm-new, xterm-88color|xterm with 88 colors, colors#88, pairs#7744, use=xterm-256color, # # This is an 8-bit version of xterm, which emulates DEC vt220 with ANSI color. # To use it, your decTerminalID resource must be set to 200 or above, and the # sunKeyboard resource set to true. # # HTS \E H \210 # RI \E M \215 # SS3 \E O \217 # CSI \E [ \233 # xterm-8bit|xterm terminal emulator with 8-bit controls (X Window System), OTbs, am, bce, km, mc5i, mir, msgr, npc, xenl, AX, colors#8, cols#80, it#8, lines#24, pairs#64, acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, bel=^G, blink=\2335m, bold=\2331m, cbt=\233Z, civis=\233?25l, clear=\233H\2332J, cnorm=\233?25l\233?25h, cr=^M, csr=\233%i%p1%d;%p2%dr, cub=\233%p1%dD, cub1=^H, cud=\233%p1%dB, cud1=^J, cuf=\233%p1%dC, cuf1=\233C, cup=\233%i%p1%d;%p2%dH, cuu=\233%p1%dA, cuu1=\233A, cvvis=\233?12;25h, dch=\233%p1%dP, dch1=\233P, dl=\233%p1%dM, dl1=\233M, ech=\233%p1%dX, ed=\233J, el=\233K, el1=\2331K, flash=\233?5h$<100/>\233?5l, home=\233H, hpa=\233%i%p1%dG, ht=^I, hts=\210, ich=\233%p1%d@, il=\233%p1%dL, il1=\233L, ind=^J, invis=\2338m, is2=\E[62"p\E G\233m\233?7h\E>\E7\233?1;3;4;6l\2334l\233r\E8, ka1=\217w, ka3=\217u, kb2=\217y, kbeg=\217E, kc1=\217q, kc3=\217s, kcbt=\233Z, kcub1=\217D, kcud1=\217B, kcuf1=\217C, kcuu1=\217A, kdch1=\2333~, kend=\2334~, kent=\217M, kf1=\23311~, kf10=\23321~, kf11=\23323~, kf12=\23324~, kf13=\23325~, kf14=\23326~, kf15=\23328~, kf16=\23329~, kf17=\23331~, kf18=\23332~, kf19=\23333~, kf2=\23312~, kf20=\23334~, kf3=\23313~, kf4=\23314~, kf5=\23315~, kf6=\23317~, kf7=\23318~, kf8=\23319~, kf9=\23320~, khome=\2331~, kich1=\2332~, kmous=\233M, knp=\2336~, kpp=\2335~, mc0=\233i, mc4=\2334i, mc5=\2335i, meml=\El, memu=\Em, op=\23339;49m, rc=\E8, rev=\2337m, ri=\215, rmacs=\E(B, rmam=\233?7l, rmcup=\233?1049l, rmir=\2334l, rmkx=\233?1l\E>, rmso=\23327m, rmul=\23324m, rs1=\Ec, rs2=\E[62"p\E G\233m\233?7h\E>\E7\233?1;3;4;6l\2334l\233r\E8, sc=\E7, setab=\2334%p1%dm, setaf=\2333%p1%dm, setb=\2334%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m, setf=\2333%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m, sgr=\2330%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%?%p9%t\E(0%e\E(B%;, sgr0=\2330m\E(B, smacs=\E(0, smam=\233?7h, smcup=\233?1049h, smir=\2334h, smkx=\233?1h\E=, smso=\2337m, smul=\2334m, tbc=\2333g, u6=\233[%i%d;%dR, u7=\E[6n, u8=\233[?1;2c, u9=\E[c, vpa=\233%i%p1%dd, use=xterm+kbs, # xterm-xf86-v44|xterm terminal emulator (XFree86 4.4 Window System), OTbs, am, bce, km, mc5i, mir, msgr, npc, xenl, AX, XT, colors#8, cols#80, it#8, lines#24, pairs#64, acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l, clear=\E[H\E[2J, cnorm=\E[?12l\E[?25h, cr=^M, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, cvvis=\E[?12;25h, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E(B\E)0, flash=\E[?5h$<100/>\E[?5l, home=\E[H, hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=^J, indn=\E[%p1%dS, invis=\E[8m, is2=\E[!p\E[?3;4l\E[4l\E>, kDC=\E[3;2~, kEND=\E[1;2F, kHOM=\E[1;2H, kIC=\E[2;2~, kLFT=\E[1;2D, kNXT=\E[6;2~, kPRV=\E[5;2~, kRIT=\E[1;2C, kb2=\EOE, kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kdch1=\E[3~, kend=\EOF, kent=\EOM, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\EO2P, kf14=\EO2Q, kf15=\EO2R, kf16=\EO2S, kf17=\E[15;2~, kf18=\E[17;2~, kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~, kf21=\E[20;2~, kf22=\E[21;2~, kf23=\E[23;2~, kf24=\E[24;2~, kf25=\EO5P, kf26=\EO5Q, kf27=\EO5R, kf28=\EO5S, kf29=\E[15;5~, kf3=\EOR, kf30=\E[17;5~, kf31=\E[18;5~, kf32=\E[19;5~, kf33=\E[20;5~, kf34=\E[21;5~, kf35=\E[23;5~, kf36=\E[24;5~, kf37=\EO6P, kf38=\EO6Q, kf39=\EO6R, kf4=\EOS, kf40=\EO6S, kf41=\E[15;6~, kf42=\E[17;6~, kf43=\E[18;6~, kf44=\E[19;6~, kf45=\E[20;6~, kf46=\E[21;6~, kf47=\E[23;6~, kf48=\E[24;6~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\EOH, kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~, mc0=\E[i, mc4=\E[4i, mc5=\E[5i, meml=\El, memu=\Em, op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM, rin=\E[%p1%dT, rmacs=^O, rmam=\E[?7l, rmcup=\E[?1049l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[27m, rmul=\E[24m, rs1=\Ec, rs2=\E[!p\E[?3;4l\E[4l\E>, sc=\E7, setab=\E[4%p1%dm, setaf=\E[3%p1%dm, setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m, setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m, sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%?%p9%t\016%e\017%;, sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smcup=\E[?1049h, smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?1;2c, u9=\E[c, vpa=\E[%i%p1%dd, ka2=\EOx, kb1=\EOt, kb3=\EOv, kc2=\EOr, use=xterm+kbs, xterm-xfree86|xterm terminal emulator (XFree86 4.4 Window System), use=xterm-xf86-v44, # # Compatible with the R6 xterm, with the following changes: # + added acsc (perhaps some versions of tic assume the standard vt100 # alternate character set) # + added u6, u7, u8, u9 strings for Daniel Weaver's tack program. # + added kmous string for ncurses. # + added khome/kend strings (which conflict with kfnd/kslt, see note). xterm-r6|xterm X11R6 version, OTbs, am, km, mir, msgr, xenl, cols#80, it#8, lines#24, acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, bel=^G, bold=\E[1m, clear=\E[H\E[2J, cr=^M, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, enacs=\E)0, home=\E[H, ht=^I, hts=\EH, il=\E[%p1%dL, il1=\E[L, ind=^J, is2=\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kdch1=\E[3~, kf1=\E[11~, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\E[12~, kf20=\E[34~, kf3=\E[13~, kf4=\E[14~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, kmous=\E[M, meml=\El, memu=\Em, rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O, rmcup=\E[2J\E[?47l\E8, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m, rs2=\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8, sc=\E7, sgr0=\E[m, smacs=^N, smcup=\E7\E[?47h, smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?1;2c, u9=\E[c, use=xterm+kbs, use=xterm+decedit, xterm-old|antique xterm version, use=xterm-r6, # # Compatible with the R5 xterm, with the following changes: # + changed 'blink=@', to 'blink@' (the former meant that "@" would start # a blink, the latter that it is not supported). # + changed kf1 through kf4 to correspond with actual usage. Though X # supports keypad symbols for PF1 to PF4, and xterm interprets these # correctly, the F1 to F4 codes are commonly (but incorrectly) used. # + moved reset string from rs1 to rs2, to correlate better with termcap. # + make khome consistent with other entries. # + use rmul/smul, rmir/smir from termcap, but not rmcup/smcup because # not everyone wants the alternate screen. # + added u6, u7, u8, u9 strings for Daniel Weaver's tack program. # + added kmous string for ncurses. xterm-r5|xterm R5 version, OTbs, am, km, msgr, xenl, cols#80, it#8, lines#24, bel=^G, bold=\E[1m, clear=\E[H\E[2J, cr=^M, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL, il1=\E[L, ind=^J, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kdch1=\E[3~, kdl1=\E[31~, kel=\E[8~, kend=\E[4~, kf0=\EOq, kf1=\E[11~, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf2=\E[12~, kf3=\E[13~, kf4=\E[14~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\E[1~, kich1=\E[2~, kil1=\E[30~, kmous=\E[M, knp=\E[6~, kpp=\E[5~, rc=\E8, rev=\E[7m, ri=\EM, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m, rs2=\E>\E[?1;3;4;5;6l\E[4l\E[?7h\E[m\E[r\E[2J\E[H, sc=\E7, sgr=\E[%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1%;m, sgr0=\E[m, smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?1;2c, u9=\E[c, use=xterm+kbs, # # # Customization begins here. # # This is the only entry which you should have to customize, since "xterm" # is widely used for a variety of incompatible terminal emulations including # color_xterm and rxvt. xterm|X11 terminal emulator, use=xterm-new, # use=xterm-r6, # This fragment is for people who cannot agree on what the backspace key # should send. xterm+kbs|fragment for backspace key, kbs=^H,