diff options
author | Kim Jin Su <item4_hun@hotmail.com> | 2015-11-22 00:41:39 +0900 |
---|---|---|
committer | Kim Jin Su <item4_hun@hotmail.com> | 2015-11-22 00:41:39 +0900 |
commit | 99e94cd4f9479f57f879ceae12a2c8f7d4970770 (patch) | |
tree | 5a65a031903ae2825895663c5d0e8aef4f77ac80 /tests | |
parent | 472821f0835924275521cd910e281085a75a7440 (diff) | |
download | pygments-99e94cd4f9479f57f879ceae12a2c8f7d4970770.tar.gz |
merge
Diffstat (limited to 'tests')
26 files changed, 5566 insertions, 58 deletions
diff --git a/tests/examplefiles/abnf_example1.abnf b/tests/examplefiles/abnf_example1.abnf new file mode 100644 index 00000000..5cd9cd25 --- /dev/null +++ b/tests/examplefiles/abnf_example1.abnf @@ -0,0 +1,22 @@ +; This examples from WikiPedia <https://en.wikipedia.org/wiki/Augmented_Backus%E2%80%93Naur_Form>. + + postal-address = name-part street zip-part + + name-part = *(personal-part SP) last-name [SP suffix] CRLF + name-part =/ personal-part CRLF + + personal-part = first-name / (initial ".") + first-name = *ALPHA + initial = ALPHA + last-name = *ALPHA + suffix = ("Jr." / "Sr." / 1*("I" / "V" / "X")) + + street = [apt SP] house-num SP street-name CRLF + apt = 1*4DIGIT + house-num = 1*8(DIGIT / ALPHA) + street-name = 1*VCHAR + + zip-part = town-name "," SP state 1*2SP zip-code CRLF + town-name = 1*(ALPHA / SP) + state = 2ALPHA + zip-code = 5DIGIT ["-" 4DIGIT] diff --git a/tests/examplefiles/abnf_example2.abnf b/tests/examplefiles/abnf_example2.abnf new file mode 100644 index 00000000..8781adfb --- /dev/null +++ b/tests/examplefiles/abnf_example2.abnf @@ -0,0 +1,9 @@ +crlf = %d13.10 + +command = "command string" + +char-line = %x0D.0A *(%x20-7E) %x0D.0A + +without-ws-and-ctl = %d1-8 / %d11 / %d12 / %d14-31 / %d127 + +three-blank-lines = %x0D.0A.0D.0A.0D.0A diff --git a/tests/examplefiles/bnf_example1.bnf b/tests/examplefiles/bnf_example1.bnf new file mode 100644 index 00000000..fe041a6e --- /dev/null +++ b/tests/examplefiles/bnf_example1.bnf @@ -0,0 +1,15 @@ +; This examples from WikiPedia <https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form>. + + <postal-address> ::= <name-part> <street-address> <zip-part> + + <name-part> ::= <personal-part> <last-name> <opt-suffix-part> <EOL> + | <personal-part> <name-part> + + <personal-part> ::= <initial> "." | <first-name> + + <street-address> ::= <house-num> <street-name> <opt-apt-num> <EOL> + + <zip-part> ::= <town-name> "," <state-code> <ZIP-code> <EOL> + + <opt-suffix-part> ::= "Sr." | "Jr." | <roman-numeral> | "" + <opt-apt-num> ::= <apt-num> | "" diff --git a/tests/examplefiles/demo.thrift b/tests/examplefiles/demo.thrift new file mode 100644 index 00000000..e50544d5 --- /dev/null +++ b/tests/examplefiles/demo.thrift @@ -0,0 +1,14 @@ +/* comment */ +/** doc comment */ + +namespace cpp shared // inline comment + +struct Foo1 { + 1: i32 key + 2: string value +} + +service Foo2 { + Foo1 bar(1: i32 key) +} + diff --git a/tests/examplefiles/example.bc b/tests/examplefiles/example.bc new file mode 100644 index 00000000..6604cd31 --- /dev/null +++ b/tests/examplefiles/example.bc @@ -0,0 +1,53 @@ +/* + * Calculate the Greatest Common Divisor of a and b. + */ +define gcd(a, b) { + auto tmp; + + /* + * Euclidean algorithm + */ + while (b != 0) { + tmp = a % b; + a = b; + b = tmp; + } + return a; +} +"gcd(225, 150) = " ; gcd(225, 150) + +/* assign operators */ +a = 10 +a += 1 +a++ +++a +a-- +--a +a += 5 +a -= 5 +a *= 2 +a /= 3 +a ^= 2 +a %= 2 + +/* comparison */ +if (a > 2) { +} +if (a >= 2) { +} +if (a == 2) { +} +if (a != 2) { +} +if (a <= 2) { +} +if (a < 2) { +} + +a /* /*/ * 2 /* == a * 2 */ +a //* /*/ 1.5 /* == a / 1.5 */ +a /*/*/ * 3 /* == a * 3 */ +a * 3 /**/ * 4 /* == a * 3 * 4 */ +a / 3 //*//*/ .4 /* == a / 3 / 0.4 */ +a / 3 //*//*/ 1.3 /* == a / 3 / 1.4 */ +a / 3 /*//*// 1.3 /* == a / 3 / 1.4 */ diff --git a/tests/examplefiles/example.ts b/tests/examplefiles/example.ts index 545c6cf5..760e2543 100644 --- a/tests/examplefiles/example.ts +++ b/tests/examplefiles/example.ts @@ -21,6 +21,17 @@ class Horse extends Animal { } } +@View({ + templateUrl: "app/components/LoginForm.html", + directives: [FORM_DIRECTIVES, NgIf] +}) +@Component({ + selector: "login-form" +}) +class LoginForm { + +} + var sam = new Snake("Sammy the Python") var tom: Animal = new Horse("Tommy the Palomino") diff --git a/tests/examplefiles/ezhil_primefactors.n b/tests/examplefiles/ezhil_primefactors.n new file mode 100644 index 00000000..13390611 --- /dev/null +++ b/tests/examplefiles/ezhil_primefactors.n @@ -0,0 +1,152 @@ +# (C) முத்தையா அண்ணாமலை 2013 +# (A) என். சொக்கன் +# எழில் தமிழ் நிரலாக்க மொழி உதாரணம் +# Muthu A granted permission for this to be included under the BSD license +# https://bitbucket.org/birkenfeld/pygments-main/pull-requests/443/ezhil-language-lexer-for-pygments/diff + +## Prime Factors Example +## பகா எண் கூறுகளைக் கண்டறியும் உதாரணம் + +## இது நிரல் தரப்பட்ட எண்ணின் பகாஎண் கூறுகளைக் கண்டறியும் + +நிரல்பாகம் பகாஎண்ணா(எண்1) + + ## இது நிரல்பாகம் தரப்பட்ட எண் பகு எண்ணா அல்லது பகா எண்ணா என்று கண்டறிந்து சொல்லும் + ## பகுஎண் என்றால் 0 திரும்பத் தரப்படும் + ## பகாஎண் என்றால் 1 திரும்பத் தரப்படும் + + @(எண்1 < 0) ஆனால் + + ## எதிர்மறை எண்களை நேராக்குதல் + + எண்1 = எண்1 * (-1) + + முடி + + @(எண்1 < 2) ஆனால் + + ## பூஜ்ஜியம், ஒன்று ஆகியவை பகா எண்கள் அல்ல + + பின்கொடு 0 + + முடி + + @(எண்1 == 2) ஆனால் + + ## இரண்டு என்ற எண் ஒரு பகா எண் + + பின்கொடு 1 + + முடி + + மீதம் = எண்1%2 + + @(மீதம் == 0) ஆனால் + + ## இரட்டைப்படை எண், ஆகவே, இது பகா எண் அல்ல + + பின்கொடு 0 + + முடி + + எண்1வர்க்கமூலம் = எண்1^0.5 + + @(எண்2 = 3, எண்2 <= எண்1வர்க்கமூலம், எண்2 = எண்2 + 2) ஆக + + மீதம்1 = எண்1%எண்2 + + @(மீதம்1 == 0) ஆனால் + + ## ஏதேனும் ஓர் எண்ணால் முழுமையாக வகுபட்டுவிட்டது, ஆகவே அது பகா எண் அல்ல + + பின்கொடு 0 + + முடி + + முடி + + பின்கொடு 1 + +முடி + +நிரல்பாகம் பகுத்தெடு(எண்1) + + ## இது எண் தரப்பட்ட எண்ணின் பகா எண் கூறுகளைக் கண்டறிந்து பட்டியல் இடும் + + கூறுகள் = பட்டியல்() + + @(எண்1 < 0) ஆனால் + + ## எதிர்மறை எண்களை நேராக்குதல் + + எண்1 = எண்1 * (-1) + + முடி + + @(எண்1 <= 1) ஆனால் + + ## ஒன்று அல்லது அதற்குக் குறைவான எண்களுக்குப் பகா எண் விகிதம் கண்டறியமுடியாது + + பின்கொடு கூறுகள் + + முடி + + @(பகாஎண்ணா(எண்1) == 1) ஆனால் + + ## தரப்பட்ட எண்ணே பகா எண்ணாக அமைந்துவிட்டால், அதற்கு அதுவே பகாஎண் கூறு ஆகும் + + பின்இணை(கூறுகள், எண்1) + பின்கொடு கூறுகள் + + முடி + + தாற்காலிகஎண் = எண்1 + + எண்2 = 2 + + @(எண்2 <= தாற்காலிகஎண்) வரை + + விடை1 = பகாஎண்ணா(எண்2) + மீண்டும்தொடங்கு = 0 + + @(விடை1 == 1) ஆனால் + + விடை2 = தாற்காலிகஎண்%எண்2 + + @(விடை2 == 0) ஆனால் + + ## பகா எண்ணால் முழுமையாக வகுபட்டுள்ளது, அதனைப் பட்டியலில் இணைக்கிறோம் + + பின்இணை(கூறுகள், எண்2) + தாற்காலிகஎண் = தாற்காலிகஎண்/எண்2 + + ## மீண்டும் இரண்டில் தொடங்கி இதே கணக்கிடுதலைத் தொடரவேண்டும் + + எண்2 = 2 + மீண்டும்தொடங்கு = 1 + + முடி + + முடி + + @(மீண்டும்தொடங்கு == 0) ஆனால் + + ## அடுத்த எண்ணைத் தேர்ந்தெடுத்துக் கணக்கிடுதலைத் தொடரவேண்டும் + + எண்2 = எண்2 + 1 + + முடி + + முடி + + பின்கொடு கூறுகள் + +முடி + +அ = int(உள்ளீடு("உங்களுக்குப் பிடித்த ஓர் எண்ணைத் தாருங்கள்: ")) + +பகாஎண்கூறுகள் = பட்டியல்() + +பகாஎண்கூறுகள் = பகுத்தெடு(அ) + +பதிப்பி "நீங்கள் தந்த எண்ணின் பகா எண் கூறுகள் இவை: ", பகாஎண்கூறுகள் diff --git a/tests/examplefiles/hexdump_debugexe b/tests/examplefiles/hexdump_debugexe new file mode 100644 index 00000000..31fefdb7 --- /dev/null +++ b/tests/examplefiles/hexdump_debugexe @@ -0,0 +1,309 @@ +0000:0000 2F 2F 20 43 72 65 61 74-65 64 20 62 79 20 4C 69 // Created by Li +0000:0010 6F 6E 65 6C 6C 6F 20 4C-75 6E 65 73 75 20 61 6E onello Lunesu an +0000:0020 64 20 70 6C 61 63 65 64-20 69 6E 20 74 68 65 20 d placed in the +0000:0030 70 75 62 6C 69 63 20 64-6F 6D 61 69 6E 2E 0A 2F public domain.◙/ +0000:0040 2F 20 54 68 69 73 20 66-69 6C 65 20 68 61 73 20 / This file has +0000:0050 62 65 65 6E 20 6D 6F 64-69 66 69 65 64 20 66 72 been modified fr +0000:0060 6F 6D 20 69 74 73 20 6F-72 69 67 69 6E 61 6C 20 om its original +0000:0070 76 65 72 73 69 6F 6E 2E-0A 2F 2F 20 49 74 20 68 version.◙// It h +0000:0080 61 73 20 62 65 65 6E 20-66 6F 72 6D 61 74 74 65 as been formatte +0000:0090 64 20 74 6F 20 66 69 74-20 79 6F 75 72 20 73 63 d to fit your sc +0000:00A0 72 65 65 6E 2E 0A 6D 6F-64 75 6C 65 20 70 68 6F reen.◙module pho +0000:00B0 6E 65 6E 6F 3B 20 20 20-20 20 2F 2F 20 6F 70 74 neno; // opt +0000:00C0 69 6F 6E 61 6C 0A 69 6D-70 6F 72 74 20 73 74 64 ional◙import std +0000:00D0 2E 73 74 64 69 6F 3B 20-20 20 2F 2F 20 77 72 69 .stdio; // wri +0000:00E0 74 65 66 6C 6E 20 20 20-20 20 0A 69 6D 70 6F 72 tefln ◙impor +0000:00F0 74 20 73 74 64 2E 63 74-79 70 65 3B 20 20 20 2F t std.ctype; / +0000:0100 2F 20 69 73 64 69 67 69-74 20 20 20 20 20 0A 69 / isdigit ◙i +0000:0110 6D 70 6F 72 74 20 73 74-64 2E 73 74 72 65 61 6D mport std.stream +0000:0120 3B 20 20 2F 2F 20 42 75-66 66 65 72 65 64 46 69 ; // BufferedFi +0000:0130 6C 65 0A 0A 2F 2F 20 4A-75 73 74 20 66 6F 72 20 le◙◙// Just for +0000:0140 72 65 61 64 61 62 69 6C-69 74 79 20 28 69 6D 61 readability (ima +0000:0150 67 69 6E 65 20 63 68 61-72 5B 5D 5B 5D 5B 63 68 gine char[][][ch +0000:0160 61 72 5B 5D 5D 29 20 20-20 20 0A 61 6C 69 61 73 ar[]]) ◙alias +0000:0170 20 63 68 61 72 5B 5D 20-73 74 72 69 6E 67 3B 0A char[] string;◙ +0000:0180 61 6C 69 61 73 20 73 74-72 69 6E 67 5B 5D 20 73 alias string[] s +0000:0190 74 72 69 6E 67 61 72 72-61 79 3B 0A 0A 2F 2F 2F tringarray;◙◙/// +0000:01A0 20 53 74 72 69 70 73 20-6E 6F 6E 2D 64 69 67 69 Strips non-digi +0000:01B0 74 20 63 68 61 72 61 63-74 65 72 73 20 66 72 6F t characters fro +0000:01C0 6D 20 74 68 65 20 73 74-72 69 6E 67 20 28 43 4F m the string (CO +0000:01D0 57 29 0A 73 74 72 69 6E-67 20 73 74 72 69 70 4E W)◙string stripN +0000:01E0 6F 6E 44 69 67 69 74 28-20 69 6E 20 73 74 72 69 onDigit( in stri +0000:01F0 6E 67 20 6C 69 6E 65 20-29 20 0A 7B 0A 20 20 20 ng line ) ◙{◙ +0000:0200 20 73 74 72 69 6E 67 20-72 65 74 3B 0A 20 20 20 string ret;◙ +0000:0210 20 66 6F 72 65 61 63 68-28 75 69 6E 74 20 69 2C foreach(uint i, +0000:0220 20 63 3B 20 6C 69 6E 65-29 20 7B 0A 20 20 20 20 c; line) {◙ +0000:0230 20 20 20 20 2F 2F 20 45-72 72 6F 72 3A 20 73 74 // Error: st +0000:0240 64 2E 63 74 79 70 65 2E-69 73 64 69 67 69 74 20 d.ctype.isdigit +0000:0250 61 74 20 43 3A 5C 64 6D-64 5C 73 72 63 5C 70 68 at C:\dmd\src\ph +0000:0260 6F 62 6F 73 5C 73 74 64-5C 63 74 79 70 65 2E 64 obos\std\ctype.d +0000:0270 28 33 37 29 20 0A 20 20-20 20 20 20 20 20 2F 2F (37) ◙ // +0000:0280 20 63 6F 6E 66 6C 69 63-74 73 20 77 69 74 68 20 conflicts with +0000:0290 73 74 64 2E 73 74 72 65-61 6D 2E 69 73 64 69 67 std.stream.isdig +0000:02A0 69 74 20 61 74 20 43 3A-5C 64 6D 64 5C 73 72 63 it at C:\dmd\src +0000:02B0 5C 70 68 6F 62 6F 73 5C-73 74 64 5C 73 74 72 65 \phobos\std\stre +0000:02C0 61 6D 2E 64 28 32 39 32-34 29 0A 20 20 20 20 20 am.d(2924)◙ +0000:02D0 20 20 20 69 66 20 28 21-73 74 64 2E 63 74 79 70 if (!std.ctyp +0000:02E0 65 2E 69 73 64 69 67 69-74 28 63 29 29 20 7B 0A e.isdigit(c)) {◙ +0000:02F0 20 20 20 20 20 20 20 20-20 20 20 20 69 66 20 28 if ( +0000:0300 21 72 65 74 29 0A 20 20-20 20 20 20 20 20 20 20 !ret)◙ +0000:0310 20 20 20 20 20 20 72 65-74 20 3D 20 6C 69 6E 65 ret = line +0000:0320 5B 30 2E 2E 69 5D 3B 20-20 20 20 0A 20 20 20 20 [0..i]; ◙ +0000:0330 20 20 20 20 7D 20 20 20-20 0A 20 20 20 20 20 20 } ◙ +0000:0340 20 20 65 6C 73 65 20 69-66 20 28 72 65 74 29 0A else if (ret)◙ +0000:0350 20 20 20 20 20 20 20 20-20 20 20 20 72 65 74 20 ret +0000:0360 7E 3D 20 63 3B 20 20 20-20 0A 20 20 20 20 7D 20 ~= c; ◙ } +0000:0370 20 20 20 0A 20 20 20 20-72 65 74 75 72 6E 20 72 ◙ return r +0000:0380 65 74 3F 72 65 74 3A 6C-69 6E 65 3B 0A 7D 0A 0A et?ret:line;◙}◙◙ +0000:0390 75 6E 69 74 74 65 73 74-20 7B 0A 20 20 20 20 61 unittest {◙ a +0000:03A0 73 73 65 72 74 28 20 73-74 72 69 70 4E 6F 6E 44 ssert( stripNonD +0000:03B0 69 67 69 74 28 22 61 73-64 66 22 29 20 3D 3D 20 igit("asdf") == +0000:03C0 22 22 20 20 29 3B 0A 20-20 20 20 61 73 73 65 72 "" );◙ asser +0000:03D0 74 28 20 73 74 72 69 70-4E 6F 6E 44 69 67 69 74 t( stripNonDigit +0000:03E0 28 22 5C 27 31 33 2D 3D-32 20 34 6B 6F 70 22 29 ("\'13-=2 4kop") +0000:03F0 20 3D 3D 20 20 22 31 33-32 34 22 20 20 29 3B 0A == "1324" );◙ +0000:0400 7D 0A 0A 2F 2F 2F 20 43-6F 6E 76 65 72 74 73 20 }◙◙/// Converts +0000:0410 61 20 77 6F 72 64 20 69-6E 74 6F 20 61 20 6E 75 a word into a nu +0000:0420 6D 62 65 72 2C 20 69 67-6E 6F 72 69 6E 67 20 61 mber, ignoring a +0000:0430 6C 6C 20 6E 6F 6E 20 61-6C 70 68 61 20 63 68 61 ll non alpha cha +0000:0440 72 61 63 74 65 72 73 20-20 0A 73 74 72 69 6E 67 racters ◙string +0000:0450 20 77 6F 72 64 54 6F 4E-75 6D 28 20 69 6E 20 73 wordToNum( in s +0000:0460 74 72 69 6E 67 20 77 6F-72 64 20 29 0A 7B 0A 2F tring word )◙{◙/ +0000:0470 2F 20 74 72 61 6E 73 6C-61 74 69 6F 6E 20 74 61 / translation ta +0000:0480 62 6C 65 20 66 6F 72 20-74 68 65 20 74 61 73 6B ble for the task +0000:0490 20 61 74 20 68 61 6E 64-0A 63 6F 6E 73 74 20 63 at hand◙const c +0000:04A0 68 61 72 5B 32 35 36 5D-20 54 52 41 4E 53 4C 41 har[256] TRANSLA +0000:04B0 54 45 20 3D 20 20 20 20-0A 20 20 20 20 22 20 20 TE = ◙ " +0000:04C0 20 20 20 20 20 20 20 20-20 20 20 20 20 20 20 20 +0000:04D0 20 20 20 20 20 20 20 20-20 20 20 20 20 20 22 20 " +0000:04E0 20 2F 2F 20 30 20 20 20-0A 20 20 20 20 22 20 20 // 0 ◙ " +0000:04F0 20 20 20 20 20 20 20 20-20 20 20 20 20 20 30 31 01 +0000:0500 32 33 34 35 36 37 38 39-20 20 20 20 20 20 22 20 23456789 " +0000:0510 20 2F 2F 20 33 32 20 20-20 20 20 0A 20 20 20 20 // 32 ◙ +0000:0520 22 20 35 37 36 33 30 34-39 39 36 31 37 38 35 31 " 57630499617851 +0000:0530 38 38 31 32 33 34 37 36-32 32 33 39 20 20 20 20 881234762239 +0000:0540 20 22 20 20 2F 2F 20 36-34 20 20 20 0A 20 20 20 " // 64 ◙ +0000:0550 20 22 20 35 37 36 33 30-34 39 39 36 31 37 38 35 " 5763049961785 +0000:0560 31 38 38 31 32 33 34 37-36 32 32 33 39 20 20 20 1881234762239 +0000:0570 20 20 22 0A 20 20 20 20-22 20 20 20 20 20 20 20 "◙ " +0000:0580 20 20 20 20 20 20 20 20-20 20 20 20 20 20 20 20 +0000:0590 20 20 20 20 20 20 20 20-20 22 0A 20 20 20 20 22 "◙ " +0000:05A0 20 20 20 20 20 20 20 20-20 20 20 20 20 20 20 20 +0000:05B0 20 20 20 20 20 20 20 20-20 20 20 20 20 20 20 20 +0000:05C0 22 0A 20 20 20 20 22 20-20 20 20 20 20 20 20 20 "◙ " +0000:05D0 20 20 20 20 20 20 20 20-20 20 20 20 20 20 20 20 +0000:05E0 20 20 20 20 20 20 20 22-20 20 20 20 0A 20 20 20 " ◙ +0000:05F0 20 22 20 20 20 20 20 20-20 20 20 20 20 20 20 20 " +0000:0600 20 20 20 20 20 20 20 20-20 20 20 20 20 20 20 20 +0000:0610 20 20 22 3B 0A 20 20 20-20 73 74 72 69 6E 67 20 ";◙ string +0000:0620 72 65 74 3B 0A 20 20 20-20 66 6F 72 65 61 63 68 ret;◙ foreach +0000:0630 28 63 3B 20 63 61 73 74-28 75 62 79 74 65 5B 5D (c; cast(ubyte[] +0000:0640 29 77 6F 72 64 29 0A 20-20 20 20 20 20 20 20 69 )word)◙ i +0000:0650 66 20 28 54 52 41 4E 53-4C 41 54 45 5B 63 5D 20 f (TRANSLATE[c] +0000:0660 21 3D 20 27 20 27 29 0A-20 20 20 20 20 20 20 20 != ' ')◙ +0000:0670 20 20 20 20 72 65 74 20-7E 3D 20 54 52 41 4E 53 ret ~= TRANS +0000:0680 4C 41 54 45 5B 63 5D 3B-0A 20 20 20 20 72 65 74 LATE[c];◙ ret +0000:0690 75 72 6E 20 72 65 74 3B-0A 7D 0A 0A 75 6E 69 74 urn ret;◙}◙◙unit +0000:06A0 74 65 73 74 20 7B 0A 20-2F 2F 20 54 65 73 74 20 test {◙ // Test +0000:06B0 77 6F 72 64 54 6F 4E 75-6D 20 75 73 69 6E 67 20 wordToNum using +0000:06C0 74 68 65 20 74 61 62 6C-65 20 66 72 6F 6D 20 74 the table from t +0000:06D0 68 65 20 74 61 73 6B 20-64 65 73 63 72 69 70 74 he task descript +0000:06E0 69 6F 6E 2E 0A 20 61 73-73 65 72 74 28 20 22 30 ion.◙ assert( "0 +0000:06F0 31 31 31 32 32 32 33 33-33 34 34 35 35 36 36 36 1112223334455666 +0000:0700 37 37 37 38 38 38 39 39-39 22 20 3D 3D 0A 20 20 777888999" ==◙ +0000:0710 20 77 6F 72 64 54 6F 4E-75 6D 28 22 45 20 7C 20 wordToNum("E | +0000:0720 4A 20 4E 20 51 20 7C 20-52 20 57 20 58 20 7C 20 J N Q | R W X | +0000:0730 44 20 53 20 59 20 7C 20-46 20 54 20 7C 20 41 20 D S Y | F T | A +0000:0740 4D 20 7C 20 43 20 49 20-56 20 7C 20 42 20 4B 20 M | C I V | B K +0000:0750 55 20 7C 20 4C 20 4F 20-50 20 7C 20 47 20 48 20 U | L O P | G H +0000:0760 5A 22 29 29 3B 0A 20 61-73 73 65 72 74 28 20 22 Z"));◙ assert( " +0000:0770 30 31 31 31 32 32 32 33-33 33 34 34 35 35 36 36 0111222333445566 +0000:0780 36 37 37 37 38 38 38 39-39 39 22 20 3D 3D 20 0A 6777888999" == ◙ +0000:0790 20 20 20 77 6F 72 64 54-6F 4E 75 6D 28 22 65 20 wordToNum("e +0000:07A0 7C 20 6A 20 6E 20 71 20-7C 20 72 20 77 20 78 20 | j n q | r w x +0000:07B0 7C 20 64 20 73 20 79 20-7C 20 66 20 74 20 7C 20 | d s y | f t | +0000:07C0 61 20 6D 20 7C 20 63 20-69 20 76 20 7C 20 62 20 a m | c i v | b +0000:07D0 6B 20 75 20 7C 20 6C 20-6F 20 70 20 7C 20 67 20 k u | l o p | g +0000:07E0 68 20 7A 22 29 29 3B 0A-20 61 73 73 65 72 74 28 h z"));◙ assert( +0000:07F0 20 22 30 31 32 33 34 35-36 37 38 39 22 20 3D 3D "0123456789" == +0000:0800 20 0A 20 20 20 77 6F 72-64 54 6F 4E 75 6D 28 22 ◙ wordToNum(" +0000:0810 30 20 7C 20 20 20 31 20-20 20 7C 20 20 20 32 20 0 | 1 | 2 +0000:0820 20 20 7C 20 20 20 33 20-20 20 7C 20 20 34 20 20 | 3 | 4 +0000:0830 7C 20 20 35 20 20 7C 20-20 20 36 20 20 20 7C 20 | 5 | 6 | +0000:0840 20 20 37 20 20 20 7C 20-20 20 38 20 20 20 7C 20 7 | 8 | +0000:0850 20 20 39 22 29 29 3B 0A-7D 0A 0A 76 6F 69 64 20 9"));◙}◙◙void +0000:0860 6D 61 69 6E 28 20 73 74-72 69 6E 67 5B 5D 20 61 main( string[] a +0000:0870 72 67 73 20 29 0A 7B 0A-20 20 20 20 2F 2F 20 54 rgs )◙{◙ // T +0000:0880 68 69 73 20 61 73 73 6F-63 69 61 74 69 76 65 20 his associative +0000:0890 61 72 72 61 79 20 6D 61-70 73 20 61 20 6E 75 6D array maps a num +0000:08A0 62 65 72 20 74 6F 20 61-6E 20 61 72 72 61 79 20 ber to an array +0000:08B0 6F 66 20 77 6F 72 64 73-2E 20 20 20 20 0A 20 20 of words. ◙ +0000:08C0 20 20 73 74 72 69 6E 67-61 72 72 61 79 5B 73 74 stringarray[st +0000:08D0 72 69 6E 67 5D 20 20 20-20 6E 75 6D 32 77 6F 72 ring] num2wor +0000:08E0 64 73 3B 0A 0A 20 20 20-20 66 6F 72 65 61 63 68 ds;◙◙ foreach +0000:08F0 28 73 74 72 69 6E 67 20-77 6F 72 64 3B 20 6E 65 (string word; ne +0000:0900 77 20 42 75 66 66 65 72-65 64 46 69 6C 65 28 22 w BufferedFile(" +0000:0910 64 69 63 74 69 6F 6E 61-72 79 2E 74 78 74 22 20 dictionary.txt" +0000:0920 29 20 29 0A 20 20 20 20-20 20 20 20 6E 75 6D 32 ) )◙ num2 +0000:0930 77 6F 72 64 73 5B 20 77-6F 72 64 54 6F 4E 75 6D words[ wordToNum +0000:0940 28 77 6F 72 64 29 20 5D-20 7E 3D 20 77 6F 72 64 (word) ] ~= word +0000:0950 2E 64 75 70 3B 20 20 20-20 20 20 20 20 2F 2F 20 .dup; // +0000:0960 6D 75 73 74 20 64 75 70-0A 0A 20 20 20 20 2F 2F must dup◙◙ // +0000:0970 2F 20 46 69 6E 64 73 20-61 6C 6C 20 61 6C 74 65 / Finds all alte +0000:0980 72 6E 61 74 69 76 65 73-20 66 6F 72 20 74 68 65 rnatives for the +0000:0990 20 67 69 76 65 6E 20 6E-75 6D 62 65 72 0A 20 20 given number◙ +0000:09A0 20 20 2F 2F 2F 20 28 73-68 6F 75 6C 64 20 68 61 /// (should ha +0000:09B0 76 65 20 62 65 65 6E 20-73 74 72 69 70 70 65 64 ve been stripped +0000:09C0 20 66 72 6F 6D 20 6E 6F-6E 2D 64 69 67 69 74 20 from non-digit +0000:09D0 63 68 61 72 61 63 74 65-72 73 29 0A 20 20 20 20 characters)◙ +0000:09E0 73 74 72 69 6E 67 61 72-72 61 79 20 5F 46 69 6E stringarray _Fin +0000:09F0 64 57 6F 72 64 73 28 20-73 74 72 69 6E 67 20 6E dWords( string n +0000:0A00 75 6D 62 65 72 73 2C 20-62 6F 6F 6C 20 64 69 67 umbers, bool dig +0000:0A10 69 74 6F 6B 20 29 0A 20-20 20 20 69 6E 20 7B 0A itok )◙ in {◙ +0000:0A20 20 20 20 20 20 20 20 20-61 73 73 65 72 74 28 6E assert(n +0000:0A30 75 6D 62 65 72 73 2E 6C-65 6E 67 74 68 20 3E 20 umbers.length > +0000:0A40 20 30 29 3B 20 20 20 20-0A 20 20 20 20 7D 20 20 0); ◙ } +0000:0A50 20 20 0A 20 20 20 20 6F-75 74 28 72 65 73 75 6C ◙ out(resul +0000:0A60 74 29 20 7B 0A 20 20 20-20 20 20 20 20 66 6F 72 t) {◙ for +0000:0A70 65 61 63 68 20 28 61 3B-20 72 65 73 75 6C 74 29 each (a; result) +0000:0A80 0A 20 20 20 20 20 20 20-20 20 20 20 20 61 73 73 ◙ ass +0000:0A90 65 72 74 28 20 77 6F 72-64 54 6F 4E 75 6D 28 61 ert( wordToNum(a +0000:0AA0 29 20 3D 3D 20 6E 75 6D-62 65 72 73 20 29 3B 0A ) == numbers );◙ +0000:0AB0 20 20 20 20 7D 20 20 20-20 0A 20 20 20 20 62 6F } ◙ bo +0000:0AC0 64 79 20 7B 0A 20 20 20-20 20 20 20 20 73 74 72 dy {◙ str +0000:0AD0 69 6E 67 61 72 72 61 79-20 72 65 74 3B 0A 20 20 ingarray ret;◙ +0000:0AE0 20 20 20 20 20 20 62 6F-6F 6C 20 66 6F 75 6E 64 bool found +0000:0AF0 77 6F 72 64 20 3D 20 66-61 6C 73 65 3B 0A 20 20 word = false;◙ +0000:0B00 20 20 20 20 20 20 66 6F-72 20 28 75 69 6E 74 20 for (uint +0000:0B10 74 3D 31 3B 20 74 3C 3D-6E 75 6D 62 65 72 73 2E t=1; t<=numbers. +0000:0B20 6C 65 6E 67 74 68 3B 20-2B 2B 74 29 20 7B 0A 20 length; ++t) {◙ +0000:0B30 20 20 20 20 20 20 20 20-20 20 20 61 75 74 6F 20 auto +0000:0B40 61 6C 74 65 72 6E 61 74-69 76 65 73 20 3D 20 6E alternatives = n +0000:0B50 75 6D 62 65 72 73 5B 30-2E 2E 74 5D 20 69 6E 20 umbers[0..t] in +0000:0B60 6E 75 6D 32 77 6F 72 64-73 3B 0A 20 20 20 20 20 num2words;◙ +0000:0B70 20 20 20 20 20 20 20 69-66 20 28 21 61 6C 74 65 if (!alte +0000:0B80 72 6E 61 74 69 76 65 73-29 0A 20 20 20 20 20 20 rnatives)◙ +0000:0B90 20 20 20 20 20 20 20 20-20 20 63 6F 6E 74 69 6E contin +0000:0BA0 75 65 3B 0A 20 20 20 20-20 20 20 20 20 20 20 20 ue;◙ +0000:0BB0 66 6F 75 6E 64 77 6F 72-64 20 3D 20 74 72 75 65 foundword = true +0000:0BC0 3B 0A 20 20 20 20 20 20-20 20 20 20 20 20 69 66 ;◙ if +0000:0BD0 20 28 6E 75 6D 62 65 72-73 2E 6C 65 6E 67 74 68 (numbers.length +0000:0BE0 20 3E 20 20 74 29 20 7B-0A 20 20 20 20 20 20 20 > t) {◙ +0000:0BF0 20 20 20 20 20 20 20 20-20 2F 2F 20 43 6F 6D 62 // Comb +0000:0C00 69 6E 65 20 61 6C 6C 20-63 75 72 72 65 6E 74 20 ine all current +0000:0C10 61 6C 74 65 72 6E 61 74-69 76 65 73 20 77 69 74 alternatives wit +0000:0C20 68 20 61 6C 6C 20 61 6C-74 65 72 6E 61 74 69 76 h all alternativ +0000:0C30 65 73 20 20 20 20 20 0A-20 20 20 20 20 20 20 20 es ◙ +0000:0C40 20 20 20 20 20 20 20 20-2F 2F 20 6F 66 20 74 68 // of th +0000:0C50 65 20 72 65 73 74 20 28-6E 65 78 74 20 70 69 65 e rest (next pie +0000:0C60 63 65 20 63 61 6E 20 73-74 61 72 74 20 77 69 74 ce can start wit +0000:0C70 68 20 61 20 64 69 67 69-74 29 20 20 20 20 20 20 h a digit) +0000:0C80 20 20 20 20 20 20 20 20-0A 20 20 20 20 20 20 20 ◙ +0000:0C90 20 20 20 20 20 20 20 20-20 66 6F 72 65 61 63 68 foreach +0000:0CA0 20 28 61 32 3B 20 5F 46-69 6E 64 57 6F 72 64 73 (a2; _FindWords +0000:0CB0 28 20 6E 75 6D 62 65 72-73 5B 74 2E 2E 24 5D 2C ( numbers[t..$], +0000:0CC0 20 74 72 75 65 20 20 20-20 20 29 20 29 0A 20 20 true ) )◙ +0000:0CD0 20 20 20 20 20 20 20 20-20 20 20 20 20 20 20 20 +0000:0CE0 20 20 66 6F 72 65 61 63-68 28 61 31 3B 20 2A 61 foreach(a1; *a +0000:0CF0 6C 74 65 72 6E 61 74 69-76 65 73 29 0A 20 20 20 lternatives)◙ +0000:0D00 20 20 20 20 20 20 20 20-20 20 20 20 20 20 20 20 +0000:0D10 20 20 20 20 72 65 74 20-7E 3D 20 61 31 20 7E 20 ret ~= a1 ~ +0000:0D20 22 20 22 20 7E 20 61 32-3B 0A 20 20 20 20 20 20 " " ~ a2;◙ +0000:0D30 20 20 20 20 20 20 7D 0A-20 20 20 20 20 20 20 20 }◙ +0000:0D40 20 20 20 20 65 6C 73 65-20 20 20 20 0A 20 20 20 else ◙ +0000:0D50 20 20 20 20 20 20 20 20-20 20 20 20 20 72 65 74 ret +0000:0D60 20 7E 3D 20 2A 61 6C 74-65 72 6E 61 74 69 76 65 ~= *alternative +0000:0D70 73 3B 20 20 20 20 2F 2F-20 61 70 70 65 6E 64 20 s; // append +0000:0D80 74 68 65 73 65 20 61 6C-74 65 72 6E 61 74 69 76 these alternativ +0000:0D90 65 73 0A 20 20 20 20 20-20 20 20 7D 0A 20 20 20 es◙ }◙ +0000:0DA0 20 20 20 20 20 2F 2F 20-54 72 79 20 74 6F 20 6B // Try to k +0000:0DB0 65 65 70 20 31 20 64 69-67 69 74 2C 20 6F 6E 6C eep 1 digit, onl +0000:0DC0 79 20 69 66 20 77 65 27-72 65 20 61 6C 6C 6F 77 y if we're allow +0000:0DD0 65 64 20 61 6E 64 20 6E-6F 20 6F 74 68 65 72 0A ed and no other◙ +0000:0DE0 20 20 20 20 20 20 20 20-2F 2F 20 61 6C 74 65 72 // alter +0000:0DF0 6E 61 74 69 76 65 73 20-77 65 72 65 20 66 6F 75 natives were fou +0000:0E00 6E 64 0A 20 20 20 20 20-20 20 20 2F 2F 20 54 65 nd◙ // Te +0000:0E10 73 74 69 6E 67 20 22 72-65 74 2E 6C 65 6E 67 74 sting "ret.lengt +0000:0E20 68 22 20 6D 61 6B 65 73-20 6D 6F 72 65 20 73 65 h" makes more se +0000:0E30 6E 73 65 20 74 68 61 6E-20 74 65 73 74 69 6E 67 nse than testing +0000:0E40 20 22 66 6F 75 6E 64 77-6F 72 64 22 2C 0A 20 20 "foundword",◙ +0000:0E50 20 20 20 20 20 20 2F 2F-20 62 75 74 20 74 68 65 // but the +0000:0E60 20 6F 74 68 65 72 20 69-6D 70 6C 65 6D 65 6E 74 other implement +0000:0E70 61 74 69 6F 6E 73 20 73-65 65 6D 20 74 6F 20 64 ations seem to d +0000:0E80 6F 20 6A 75 73 74 20 74-68 69 73 2E 0A 20 20 20 o just this.◙ +0000:0E90 20 20 20 20 20 69 66 20-28 64 69 67 69 74 6F 6B if (digitok +0000:0EA0 20 26 26 20 21 66 6F 75-6E 64 77 6F 72 64 29 20 && !foundword) +0000:0EB0 7B 20 2F 2F 72 65 74 2E-6C 65 6E 67 74 68 20 3D { //ret.length = +0000:0EC0 3D 20 30 20 20 0A 20 20-20 20 20 20 20 20 20 20 = 0 ◙ +0000:0ED0 20 20 69 66 28 6E 75 6D-62 65 72 73 2E 6C 65 6E if(numbers.len +0000:0EE0 67 74 68 20 3E 20 20 31-29 20 7B 0A 20 20 20 20 gth > 1) {◙ +0000:0EF0 20 20 20 20 20 20 20 20-20 20 20 20 2F 2F 20 43 // C +0000:0F00 6F 6D 62 69 6E 65 20 31-20 64 69 67 69 74 20 77 ombine 1 digit w +0000:0F10 69 74 68 20 61 6C 6C 20-61 6C 74 65 6E 61 74 69 ith all altenati +0000:0F20 76 65 73 20 66 72 6F 6D-20 74 68 65 20 72 65 73 ves from the res +0000:0F30 74 20 20 20 20 0A 20 20-20 20 20 20 20 20 20 20 t ◙ +0000:0F40 20 20 20 20 20 20 2F 2F-20 28 6E 65 78 74 20 70 // (next p +0000:0F50 69 65 63 65 20 63 61 6E-20 6E 6F 74 20 73 74 61 iece can not sta +0000:0F60 72 74 20 77 69 74 68 20-61 20 64 69 67 69 74 29 rt with a digit) +0000:0F70 20 20 20 20 20 20 20 20-20 20 0A 20 20 20 20 20 ◙ +0000:0F80 20 20 20 20 20 20 20 20-20 20 20 66 6F 72 65 61 forea +0000:0F90 63 68 20 28 61 3B 20 5F-46 69 6E 64 57 6F 72 64 ch (a; _FindWord +0000:0FA0 73 28 20 6E 75 6D 62 65-72 73 5B 31 2E 2E 24 5D s( numbers[1..$] +0000:0FB0 2C 20 66 61 6C 73 65 20-29 20 29 0A 20 20 20 20 , false ) )◙ +0000:0FC0 20 20 20 20 20 20 20 20-20 20 20 20 20 20 20 20 +0000:0FD0 72 65 74 20 7E 3D 20 6E-75 6D 62 65 72 73 5B 30 ret ~= numbers[0 +0000:0FE0 2E 2E 31 5D 20 7E 20 22-20 22 20 7E 20 61 3B 0A ..1] ~ " " ~ a;◙ +0000:0FF0 20 20 20 20 20 20 20 20-20 20 20 20 7D 20 20 20 } +0000:1000 20 0A 20 20 20 20 20 20-20 20 20 20 20 20 65 6C ◙ el +0000:1010 73 65 20 20 20 20 0A 20-20 20 20 20 20 20 20 20 se ◙ +0000:1020 20 20 20 20 20 20 20 72-65 74 20 7E 3D 20 6E 75 ret ~= nu +0000:1030 6D 62 65 72 73 5B 30 2E-2E 31 5D 3B 20 20 20 20 mbers[0..1]; +0000:1040 2F 2F 20 6A 75 73 74 20-61 70 70 65 6E 64 20 74 // just append t +0000:1050 68 69 73 20 64 69 67 69-74 20 20 20 20 20 20 20 his digit +0000:1060 20 20 20 20 20 20 0A 20-20 20 20 20 20 20 20 7D ◙ } +0000:1070 20 20 20 20 0A 20 20 20-20 20 20 20 20 72 65 74 ◙ ret +0000:1080 75 72 6E 20 72 65 74 3B-0A 20 20 20 20 7D 0A 0A urn ret;◙ }◙◙ +0000:1090 20 20 20 20 2F 2F 2F 20-28 54 68 69 73 20 66 75 /// (This fu +0000:10A0 6E 63 74 69 6F 6E 20 77-61 73 20 69 6E 6C 69 6E nction was inlin +0000:10B0 65 64 20 69 6E 20 74 68-65 20 6F 72 69 67 69 6E ed in the origin +0000:10C0 61 6C 20 70 72 6F 67 72-61 6D 29 20 0A 20 20 20 al program) ◙ +0000:10D0 20 2F 2F 2F 20 46 69 6E-64 73 20 61 6C 6C 20 61 /// Finds all a +0000:10E0 6C 74 65 72 6E 61 74 69-76 65 73 20 66 6F 72 20 lternatives for +0000:10F0 74 68 65 20 67 69 76 65-6E 20 70 68 6F 6E 65 20 the given phone +0000:1100 6E 75 6D 62 65 72 20 0A-20 20 20 20 2F 2F 2F 20 number ◙ /// +0000:1110 52 65 74 75 72 6E 73 3A-20 61 72 72 61 79 20 6F Returns: array o +0000:1120 66 20 73 74 72 69 6E 67-73 20 0A 20 20 20 20 73 f strings ◙ s +0000:1130 74 72 69 6E 67 61 72 72-61 79 20 46 69 6E 64 57 tringarray FindW +0000:1140 6F 72 64 73 28 20 73 74-72 69 6E 67 20 70 68 6F ords( string pho +0000:1150 6E 65 5F 6E 75 6D 62 65-72 20 29 0A 20 20 20 20 ne_number )◙ +0000:1160 7B 0A 20 20 20 20 20 20-20 20 69 66 20 28 21 70 {◙ if (!p +0000:1170 68 6F 6E 65 5F 6E 75 6D-62 65 72 2E 6C 65 6E 67 hone_number.leng +0000:1180 74 68 29 0A 20 20 20 20-20 20 20 20 20 20 20 20 th)◙ +0000:1190 72 65 74 75 72 6E 20 6E-75 6C 6C 3B 0A 20 20 20 return null;◙ +0000:11A0 20 20 20 20 20 2F 2F 20-53 74 72 69 70 20 74 68 // Strip th +0000:11B0 65 20 6E 6F 6E 2D 64 69-67 69 74 20 63 68 61 72 e non-digit char +0000:11C0 61 63 74 65 72 73 20 66-72 6F 6D 20 74 68 65 20 acters from the +0000:11D0 70 68 6F 6E 65 20 6E 75-6D 62 65 72 2C 20 61 6E phone number, an +0000:11E0 64 0A 20 20 20 20 20 20-20 20 2F 2F 20 70 61 73 d◙ // pas +0000:11F0 73 20 69 74 20 74 6F 20-74 68 65 20 72 65 63 75 s it to the recu +0000:1200 72 73 69 76 65 20 66 75-6E 63 74 69 6F 6E 20 28 rsive function ( +0000:1210 6C 65 61 64 69 6E 67 20-64 69 67 69 74 20 69 73 leading digit is +0000:1220 20 61 6C 6C 6F 77 65 64-29 0A 20 20 20 20 20 20 allowed)◙ +0000:1230 20 20 72 65 74 75 72 6E-20 5F 46 69 6E 64 57 6F return _FindWo +0000:1240 72 64 73 28 20 73 74 72-69 70 4E 6F 6E 44 69 67 rds( stripNonDig +0000:1250 69 74 28 70 68 6F 6E 65-5F 6E 75 6D 62 65 72 29 it(phone_number) +0000:1260 2C 20 74 72 75 65 20 29-3B 20 20 20 20 0A 20 20 , true ); ◙ +0000:1270 20 20 7D 20 20 20 20 0A-20 20 20 20 0A 20 20 20 } ◙ ◙ +0000:1280 20 2F 2F 20 52 65 61 64-20 74 68 65 20 70 68 6F // Read the pho +0000:1290 6E 65 20 6E 75 6D 62 65-72 73 20 20 20 20 20 0A ne numbers ◙ +0000:12A0 20 20 20 20 66 6F 72 65-61 63 68 28 73 74 72 69 foreach(stri +0000:12B0 6E 67 20 70 68 6F 6E 65-3B 20 6E 65 77 20 42 75 ng phone; new Bu +0000:12C0 66 66 65 72 65 64 46 69-6C 65 28 22 69 6E 70 75 fferedFile("inpu +0000:12D0 74 2E 74 78 74 22 20 20-20 29 20 29 0A 20 20 20 t.txt" ) )◙ +0000:12E0 20 20 20 20 20 66 6F 72-65 61 63 68 28 61 6C 74 foreach(alt +0000:12F0 65 72 6E 61 74 69 76 65-3B 20 46 69 6E 64 57 6F ernative; FindWo +0000:1300 72 64 73 28 20 70 68 6F-6E 65 20 29 20 29 0A 20 rds( phone ) )◙ +0000:1310 20 20 20 20 20 20 20 20-20 20 20 77 72 69 74 65 write +0000:1320 66 6C 6E 28 70 68 6F 6E-65 2C 20 22 3A 20 22 2C fln(phone, ": ", +0000:1330 20 61 6C 74 65 72 6E 61-74 69 76 65 20 29 3B 0A alternative );◙ +0000:1340 7D 0A 0A }◙◙ diff --git a/tests/examplefiles/hexdump_hd b/tests/examplefiles/hexdump_hd new file mode 100644 index 00000000..4af46fcb --- /dev/null +++ b/tests/examplefiles/hexdump_hd @@ -0,0 +1,310 @@ +00000000 2f 2f 20 43 72 65 61 74 65 64 20 62 79 20 4c 69 |// Created by Li| +00000010 6f 6e 65 6c 6c 6f 20 4c 75 6e 65 73 75 20 61 6e |onello Lunesu an| +00000020 64 20 70 6c 61 63 65 64 20 69 6e 20 74 68 65 20 |d placed in the | +00000030 70 75 62 6c 69 63 20 64 6f 6d 61 69 6e 2e 0a 2f |public domain../| +00000040 2f 20 54 68 69 73 20 66 69 6c 65 20 68 61 73 20 |/ This file has | +00000050 62 65 65 6e 20 6d 6f 64 69 66 69 65 64 20 66 72 |been modified fr| +00000060 6f 6d 20 69 74 73 20 6f 72 69 67 69 6e 61 6c 20 |om its original | +00000070 76 65 72 73 69 6f 6e 2e 0a 2f 2f 20 49 74 20 68 |version..// It h| +00000080 61 73 20 62 65 65 6e 20 66 6f 72 6d 61 74 74 65 |as been formatte| +00000090 64 20 74 6f 20 66 69 74 20 79 6f 75 72 20 73 63 |d to fit your sc| +000000a0 72 65 65 6e 2e 0a 6d 6f 64 75 6c 65 20 70 68 6f |reen..module pho| +000000b0 6e 65 6e 6f 3b 20 20 20 20 20 2f 2f 20 6f 70 74 |neno; // opt| +000000c0 69 6f 6e 61 6c 0a 69 6d 70 6f 72 74 20 73 74 64 |ional.import std| +000000d0 2e 73 74 64 69 6f 3b 20 20 20 2f 2f 20 77 72 69 |.stdio; // wri| +000000e0 74 65 66 6c 6e 20 20 20 20 20 0a 69 6d 70 6f 72 |tefln .impor| +000000f0 74 20 73 74 64 2e 63 74 79 70 65 3b 20 20 20 2f |t std.ctype; /| +00000100 2f 20 69 73 64 69 67 69 74 20 20 20 20 20 0a 69 |/ isdigit .i| +00000110 6d 70 6f 72 74 20 73 74 64 2e 73 74 72 65 61 6d |mport std.stream| +00000120 3b 20 20 2f 2f 20 42 75 66 66 65 72 65 64 46 69 |; // BufferedFi| +00000130 6c 65 0a 0a 2f 2f 20 4a 75 73 74 20 66 6f 72 20 |le..// Just for | +00000140 72 65 61 64 61 62 69 6c 69 74 79 20 28 69 6d 61 |readability (ima| +00000150 67 69 6e 65 20 63 68 61 72 5b 5d 5b 5d 5b 63 68 |gine char[][][ch| +00000160 61 72 5b 5d 5d 29 20 20 20 20 0a 61 6c 69 61 73 |ar[]]) .alias| +00000170 20 63 68 61 72 5b 5d 20 73 74 72 69 6e 67 3b 0a | char[] string;.| +00000180 61 6c 69 61 73 20 73 74 72 69 6e 67 5b 5d 20 73 |alias string[] s| +00000190 74 72 69 6e 67 61 72 72 61 79 3b 0a 0a 2f 2f 2f |tringarray;..///| +000001a0 20 53 74 72 69 70 73 20 6e 6f 6e 2d 64 69 67 69 | Strips non-digi| +000001b0 74 20 63 68 61 72 61 63 74 65 72 73 20 66 72 6f |t characters fro| +000001c0 6d 20 74 68 65 20 73 74 72 69 6e 67 20 28 43 4f |m the string (CO| +000001d0 57 29 0a 73 74 72 69 6e 67 20 73 74 72 69 70 4e |W).string stripN| +000001e0 6f 6e 44 69 67 69 74 28 20 69 6e 20 73 74 72 69 |onDigit( in stri| +000001f0 6e 67 20 6c 69 6e 65 20 29 20 0a 7b 0a 20 20 20 |ng line ) .{. | +00000200 20 73 74 72 69 6e 67 20 72 65 74 3b 0a 20 20 20 | string ret;. | +00000210 20 66 6f 72 65 61 63 68 28 75 69 6e 74 20 69 2c | foreach(uint i,| +00000220 20 63 3b 20 6c 69 6e 65 29 20 7b 0a 20 20 20 20 | c; line) {. | +00000230 20 20 20 20 2f 2f 20 45 72 72 6f 72 3a 20 73 74 | // Error: st| +00000240 64 2e 63 74 79 70 65 2e 69 73 64 69 67 69 74 20 |d.ctype.isdigit | +00000250 61 74 20 43 3a 5c 64 6d 64 5c 73 72 63 5c 70 68 |at C:\dmd\src\ph| +00000260 6f 62 6f 73 5c 73 74 64 5c 63 74 79 70 65 2e 64 |obos\std\ctype.d| +00000270 28 33 37 29 20 0a 20 20 20 20 20 20 20 20 2f 2f |(37) . //| +00000280 20 63 6f 6e 66 6c 69 63 74 73 20 77 69 74 68 20 | conflicts with | +00000290 73 74 64 2e 73 74 72 65 61 6d 2e 69 73 64 69 67 |std.stream.isdig| +000002a0 69 74 20 61 74 20 43 3a 5c 64 6d 64 5c 73 72 63 |it at C:\dmd\src| +000002b0 5c 70 68 6f 62 6f 73 5c 73 74 64 5c 73 74 72 65 |\phobos\std\stre| +000002c0 61 6d 2e 64 28 32 39 32 34 29 0a 20 20 20 20 20 |am.d(2924). | +000002d0 20 20 20 69 66 20 28 21 73 74 64 2e 63 74 79 70 | if (!std.ctyp| +000002e0 65 2e 69 73 64 69 67 69 74 28 63 29 29 20 7b 0a |e.isdigit(c)) {.| +000002f0 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 | if (| +00000300 21 72 65 74 29 0a 20 20 20 20 20 20 20 20 20 20 |!ret). | +00000310 20 20 20 20 20 20 72 65 74 20 3d 20 6c 69 6e 65 | ret = line| +00000320 5b 30 2e 2e 69 5d 3b 20 20 20 20 0a 20 20 20 20 |[0..i]; . | +00000330 20 20 20 20 7d 20 20 20 20 0a 20 20 20 20 20 20 | } . | +00000340 20 20 65 6c 73 65 20 69 66 20 28 72 65 74 29 0a | else if (ret).| +00000350 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 20 | ret | +00000360 7e 3d 20 63 3b 20 20 20 20 0a 20 20 20 20 7d 20 |~= c; . } | +00000370 20 20 20 0a 20 20 20 20 72 65 74 75 72 6e 20 72 | . return r| +00000380 65 74 3f 72 65 74 3a 6c 69 6e 65 3b 0a 7d 0a 0a |et?ret:line;.}..| +00000390 75 6e 69 74 74 65 73 74 20 7b 0a 20 20 20 20 61 |unittest {. a| +000003a0 73 73 65 72 74 28 20 73 74 72 69 70 4e 6f 6e 44 |ssert( stripNonD| +000003b0 69 67 69 74 28 22 61 73 64 66 22 29 20 3d 3d 20 |igit("asdf") == | +000003c0 22 22 20 20 29 3b 0a 20 20 20 20 61 73 73 65 72 |"" );. asser| +000003d0 74 28 20 73 74 72 69 70 4e 6f 6e 44 69 67 69 74 |t( stripNonDigit| +000003e0 28 22 5c 27 31 33 2d 3d 32 20 34 6b 6f 70 22 29 |("\'13-=2 4kop")| +000003f0 20 3d 3d 20 20 22 31 33 32 34 22 20 20 29 3b 0a | == "1324" );.| +00000400 7d 0a 0a 2f 2f 2f 20 43 6f 6e 76 65 72 74 73 20 |}../// Converts | +00000410 61 20 77 6f 72 64 20 69 6e 74 6f 20 61 20 6e 75 |a word into a nu| +00000420 6d 62 65 72 2c 20 69 67 6e 6f 72 69 6e 67 20 61 |mber, ignoring a| +00000430 6c 6c 20 6e 6f 6e 20 61 6c 70 68 61 20 63 68 61 |ll non alpha cha| +00000440 72 61 63 74 65 72 73 20 20 0a 73 74 72 69 6e 67 |racters .string| +00000450 20 77 6f 72 64 54 6f 4e 75 6d 28 20 69 6e 20 73 | wordToNum( in s| +00000460 74 72 69 6e 67 20 77 6f 72 64 20 29 0a 7b 0a 2f |tring word ).{./| +00000470 2f 20 74 72 61 6e 73 6c 61 74 69 6f 6e 20 74 61 |/ translation ta| +00000480 62 6c 65 20 66 6f 72 20 74 68 65 20 74 61 73 6b |ble for the task| +00000490 20 61 74 20 68 61 6e 64 0a 63 6f 6e 73 74 20 63 | at hand.const c| +000004a0 68 61 72 5b 32 35 36 5d 20 54 52 41 4e 53 4c 41 |har[256] TRANSLA| +000004b0 54 45 20 3d 20 20 20 20 0a 20 20 20 20 22 20 20 |TE = . " | +000004c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | +000004d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 22 20 | " | +000004e0 20 2f 2f 20 30 20 20 20 0a 20 20 20 20 22 20 20 | // 0 . " | +000004f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 30 31 | 01| +00000500 32 33 34 35 36 37 38 39 20 20 20 20 20 20 22 20 |23456789 " | +00000510 20 2f 2f 20 33 32 20 20 20 20 20 0a 20 20 20 20 | // 32 . | +00000520 22 20 35 37 36 33 30 34 39 39 36 31 37 38 35 31 |" 57630499617851| +00000530 38 38 31 32 33 34 37 36 32 32 33 39 20 20 20 20 |881234762239 | +00000540 20 22 20 20 2f 2f 20 36 34 20 20 20 0a 20 20 20 | " // 64 . | +00000550 20 22 20 35 37 36 33 30 34 39 39 36 31 37 38 35 | " 5763049961785| +00000560 31 38 38 31 32 33 34 37 36 32 32 33 39 20 20 20 |1881234762239 | +00000570 20 20 22 0a 20 20 20 20 22 20 20 20 20 20 20 20 | ". " | +00000580 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | +00000590 20 20 20 20 20 20 20 20 20 22 0a 20 20 20 20 22 | ". "| +000005a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | +* +000005c0 22 0a 20 20 20 20 22 20 20 20 20 20 20 20 20 20 |". " | +000005d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | +000005e0 20 20 20 20 20 20 20 22 20 20 20 20 0a 20 20 20 | " . | +000005f0 20 22 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | " | +00000600 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | +00000610 20 20 22 3b 0a 20 20 20 20 73 74 72 69 6e 67 20 | ";. string | +00000620 72 65 74 3b 0a 20 20 20 20 66 6f 72 65 61 63 68 |ret;. foreach| +00000630 28 63 3b 20 63 61 73 74 28 75 62 79 74 65 5b 5d |(c; cast(ubyte[]| +00000640 29 77 6f 72 64 29 0a 20 20 20 20 20 20 20 20 69 |)word). i| +00000650 66 20 28 54 52 41 4e 53 4c 41 54 45 5b 63 5d 20 |f (TRANSLATE[c] | +00000660 21 3d 20 27 20 27 29 0a 20 20 20 20 20 20 20 20 |!= ' '). | +00000670 20 20 20 20 72 65 74 20 7e 3d 20 54 52 41 4e 53 | ret ~= TRANS| +00000680 4c 41 54 45 5b 63 5d 3b 0a 20 20 20 20 72 65 74 |LATE[c];. ret| +00000690 75 72 6e 20 72 65 74 3b 0a 7d 0a 0a 75 6e 69 74 |urn ret;.}..unit| +000006a0 74 65 73 74 20 7b 0a 20 2f 2f 20 54 65 73 74 20 |test {. // Test | +000006b0 77 6f 72 64 54 6f 4e 75 6d 20 75 73 69 6e 67 20 |wordToNum using | +000006c0 74 68 65 20 74 61 62 6c 65 20 66 72 6f 6d 20 74 |the table from t| +000006d0 68 65 20 74 61 73 6b 20 64 65 73 63 72 69 70 74 |he task descript| +000006e0 69 6f 6e 2e 0a 20 61 73 73 65 72 74 28 20 22 30 |ion.. assert( "0| +000006f0 31 31 31 32 32 32 33 33 33 34 34 35 35 36 36 36 |1112223334455666| +00000700 37 37 37 38 38 38 39 39 39 22 20 3d 3d 0a 20 20 |777888999" ==. | +00000710 20 77 6f 72 64 54 6f 4e 75 6d 28 22 45 20 7c 20 | wordToNum("E | | +00000720 4a 20 4e 20 51 20 7c 20 52 20 57 20 58 20 7c 20 |J N Q | R W X | | +00000730 44 20 53 20 59 20 7c 20 46 20 54 20 7c 20 41 20 |D S Y | F T | A | +00000740 4d 20 7c 20 43 20 49 20 56 20 7c 20 42 20 4b 20 |M | C I V | B K | +00000750 55 20 7c 20 4c 20 4f 20 50 20 7c 20 47 20 48 20 |U | L O P | G H | +00000760 5a 22 29 29 3b 0a 20 61 73 73 65 72 74 28 20 22 |Z"));. assert( "| +00000770 30 31 31 31 32 32 32 33 33 33 34 34 35 35 36 36 |0111222333445566| +00000780 36 37 37 37 38 38 38 39 39 39 22 20 3d 3d 20 0a |6777888999" == .| +00000790 20 20 20 77 6f 72 64 54 6f 4e 75 6d 28 22 65 20 | wordToNum("e | +000007a0 7c 20 6a 20 6e 20 71 20 7c 20 72 20 77 20 78 20 || j n q | r w x | +000007b0 7c 20 64 20 73 20 79 20 7c 20 66 20 74 20 7c 20 || d s y | f t | | +000007c0 61 20 6d 20 7c 20 63 20 69 20 76 20 7c 20 62 20 |a m | c i v | b | +000007d0 6b 20 75 20 7c 20 6c 20 6f 20 70 20 7c 20 67 20 |k u | l o p | g | +000007e0 68 20 7a 22 29 29 3b 0a 20 61 73 73 65 72 74 28 |h z"));. assert(| +000007f0 20 22 30 31 32 33 34 35 36 37 38 39 22 20 3d 3d | "0123456789" ==| +00000800 20 0a 20 20 20 77 6f 72 64 54 6f 4e 75 6d 28 22 | . wordToNum("| +00000810 30 20 7c 20 20 20 31 20 20 20 7c 20 20 20 32 20 |0 | 1 | 2 | +00000820 20 20 7c 20 20 20 33 20 20 20 7c 20 20 34 20 20 | | 3 | 4 | +00000830 7c 20 20 35 20 20 7c 20 20 20 36 20 20 20 7c 20 || 5 | 6 | | +00000840 20 20 37 20 20 20 7c 20 20 20 38 20 20 20 7c 20 | 7 | 8 | | +00000850 20 20 39 22 29 29 3b 0a 7d 0a 0a 76 6f 69 64 20 | 9"));.}..void | +00000860 6d 61 69 6e 28 20 73 74 72 69 6e 67 5b 5d 20 61 |main( string[] a| +00000870 72 67 73 20 29 0a 7b 0a 20 20 20 20 2f 2f 20 54 |rgs ).{. // T| +00000880 68 69 73 20 61 73 73 6f 63 69 61 74 69 76 65 20 |his associative | +00000890 61 72 72 61 79 20 6d 61 70 73 20 61 20 6e 75 6d |array maps a num| +000008a0 62 65 72 20 74 6f 20 61 6e 20 61 72 72 61 79 20 |ber to an array | +000008b0 6f 66 20 77 6f 72 64 73 2e 20 20 20 20 0a 20 20 |of words. . | +000008c0 20 20 73 74 72 69 6e 67 61 72 72 61 79 5b 73 74 | stringarray[st| +000008d0 72 69 6e 67 5d 20 20 20 20 6e 75 6d 32 77 6f 72 |ring] num2wor| +000008e0 64 73 3b 0a 0a 20 20 20 20 66 6f 72 65 61 63 68 |ds;.. foreach| +000008f0 28 73 74 72 69 6e 67 20 77 6f 72 64 3b 20 6e 65 |(string word; ne| +00000900 77 20 42 75 66 66 65 72 65 64 46 69 6c 65 28 22 |w BufferedFile("| +00000910 64 69 63 74 69 6f 6e 61 72 79 2e 74 78 74 22 20 |dictionary.txt" | +00000920 29 20 29 0a 20 20 20 20 20 20 20 20 6e 75 6d 32 |) ). num2| +00000930 77 6f 72 64 73 5b 20 77 6f 72 64 54 6f 4e 75 6d |words[ wordToNum| +00000940 28 77 6f 72 64 29 20 5d 20 7e 3d 20 77 6f 72 64 |(word) ] ~= word| +00000950 2e 64 75 70 3b 20 20 20 20 20 20 20 20 2f 2f 20 |.dup; // | +00000960 6d 75 73 74 20 64 75 70 0a 0a 20 20 20 20 2f 2f |must dup.. //| +00000970 2f 20 46 69 6e 64 73 20 61 6c 6c 20 61 6c 74 65 |/ Finds all alte| +00000980 72 6e 61 74 69 76 65 73 20 66 6f 72 20 74 68 65 |rnatives for the| +00000990 20 67 69 76 65 6e 20 6e 75 6d 62 65 72 0a 20 20 | given number. | +000009a0 20 20 2f 2f 2f 20 28 73 68 6f 75 6c 64 20 68 61 | /// (should ha| +000009b0 76 65 20 62 65 65 6e 20 73 74 72 69 70 70 65 64 |ve been stripped| +000009c0 20 66 72 6f 6d 20 6e 6f 6e 2d 64 69 67 69 74 20 | from non-digit | +000009d0 63 68 61 72 61 63 74 65 72 73 29 0a 20 20 20 20 |characters). | +000009e0 73 74 72 69 6e 67 61 72 72 61 79 20 5f 46 69 6e |stringarray _Fin| +000009f0 64 57 6f 72 64 73 28 20 73 74 72 69 6e 67 20 6e |dWords( string n| +00000a00 75 6d 62 65 72 73 2c 20 62 6f 6f 6c 20 64 69 67 |umbers, bool dig| +00000a10 69 74 6f 6b 20 29 0a 20 20 20 20 69 6e 20 7b 0a |itok ). in {.| +00000a20 20 20 20 20 20 20 20 20 61 73 73 65 72 74 28 6e | assert(n| +00000a30 75 6d 62 65 72 73 2e 6c 65 6e 67 74 68 20 3e 20 |umbers.length > | +00000a40 20 30 29 3b 20 20 20 20 0a 20 20 20 20 7d 20 20 | 0); . } | +00000a50 20 20 0a 20 20 20 20 6f 75 74 28 72 65 73 75 6c | . out(resul| +00000a60 74 29 20 7b 0a 20 20 20 20 20 20 20 20 66 6f 72 |t) {. for| +00000a70 65 61 63 68 20 28 61 3b 20 72 65 73 75 6c 74 29 |each (a; result)| +00000a80 0a 20 20 20 20 20 20 20 20 20 20 20 20 61 73 73 |. ass| +00000a90 65 72 74 28 20 77 6f 72 64 54 6f 4e 75 6d 28 61 |ert( wordToNum(a| +00000aa0 29 20 3d 3d 20 6e 75 6d 62 65 72 73 20 29 3b 0a |) == numbers );.| +00000ab0 20 20 20 20 7d 20 20 20 20 0a 20 20 20 20 62 6f | } . bo| +00000ac0 64 79 20 7b 0a 20 20 20 20 20 20 20 20 73 74 72 |dy {. str| +00000ad0 69 6e 67 61 72 72 61 79 20 72 65 74 3b 0a 20 20 |ingarray ret;. | +00000ae0 20 20 20 20 20 20 62 6f 6f 6c 20 66 6f 75 6e 64 | bool found| +00000af0 77 6f 72 64 20 3d 20 66 61 6c 73 65 3b 0a 20 20 |word = false;. | +00000b00 20 20 20 20 20 20 66 6f 72 20 28 75 69 6e 74 20 | for (uint | +00000b10 74 3d 31 3b 20 74 3c 3d 6e 75 6d 62 65 72 73 2e |t=1; t<=numbers.| +00000b20 6c 65 6e 67 74 68 3b 20 2b 2b 74 29 20 7b 0a 20 |length; ++t) {. | +00000b30 20 20 20 20 20 20 20 20 20 20 20 61 75 74 6f 20 | auto | +00000b40 61 6c 74 65 72 6e 61 74 69 76 65 73 20 3d 20 6e |alternatives = n| +00000b50 75 6d 62 65 72 73 5b 30 2e 2e 74 5d 20 69 6e 20 |umbers[0..t] in | +00000b60 6e 75 6d 32 77 6f 72 64 73 3b 0a 20 20 20 20 20 |num2words;. | +00000b70 20 20 20 20 20 20 20 69 66 20 28 21 61 6c 74 65 | if (!alte| +00000b80 72 6e 61 74 69 76 65 73 29 0a 20 20 20 20 20 20 |rnatives). | +00000b90 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e | contin| +00000ba0 75 65 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 |ue;. | +00000bb0 66 6f 75 6e 64 77 6f 72 64 20 3d 20 74 72 75 65 |foundword = true| +00000bc0 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 |;. if| +00000bd0 20 28 6e 75 6d 62 65 72 73 2e 6c 65 6e 67 74 68 | (numbers.length| +00000be0 20 3e 20 20 74 29 20 7b 0a 20 20 20 20 20 20 20 | > t) {. | +00000bf0 20 20 20 20 20 20 20 20 20 2f 2f 20 43 6f 6d 62 | // Comb| +00000c00 69 6e 65 20 61 6c 6c 20 63 75 72 72 65 6e 74 20 |ine all current | +00000c10 61 6c 74 65 72 6e 61 74 69 76 65 73 20 77 69 74 |alternatives wit| +00000c20 68 20 61 6c 6c 20 61 6c 74 65 72 6e 61 74 69 76 |h all alternativ| +00000c30 65 73 20 20 20 20 20 0a 20 20 20 20 20 20 20 20 |es . | +00000c40 20 20 20 20 20 20 20 20 2f 2f 20 6f 66 20 74 68 | // of th| +00000c50 65 20 72 65 73 74 20 28 6e 65 78 74 20 70 69 65 |e rest (next pie| +00000c60 63 65 20 63 61 6e 20 73 74 61 72 74 20 77 69 74 |ce can start wit| +00000c70 68 20 61 20 64 69 67 69 74 29 20 20 20 20 20 20 |h a digit) | +00000c80 20 20 20 20 20 20 20 20 0a 20 20 20 20 20 20 20 | . | +00000c90 20 20 20 20 20 20 20 20 20 66 6f 72 65 61 63 68 | foreach| +00000ca0 20 28 61 32 3b 20 5f 46 69 6e 64 57 6f 72 64 73 | (a2; _FindWords| +00000cb0 28 20 6e 75 6d 62 65 72 73 5b 74 2e 2e 24 5d 2c |( numbers[t..$],| +00000cc0 20 74 72 75 65 20 20 20 20 20 29 20 29 0a 20 20 | true ) ). | +00000cd0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | +00000ce0 20 20 66 6f 72 65 61 63 68 28 61 31 3b 20 2a 61 | foreach(a1; *a| +00000cf0 6c 74 65 72 6e 61 74 69 76 65 73 29 0a 20 20 20 |lternatives). | +00000d00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | +00000d10 20 20 20 20 72 65 74 20 7e 3d 20 61 31 20 7e 20 | ret ~= a1 ~ | +00000d20 22 20 22 20 7e 20 61 32 3b 0a 20 20 20 20 20 20 |" " ~ a2;. | +00000d30 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 20 20 | }. | +00000d40 20 20 20 20 65 6c 73 65 20 20 20 20 0a 20 20 20 | else . | +00000d50 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 | ret| +00000d60 20 7e 3d 20 2a 61 6c 74 65 72 6e 61 74 69 76 65 | ~= *alternative| +00000d70 73 3b 20 20 20 20 2f 2f 20 61 70 70 65 6e 64 20 |s; // append | +00000d80 74 68 65 73 65 20 61 6c 74 65 72 6e 61 74 69 76 |these alternativ| +00000d90 65 73 0a 20 20 20 20 20 20 20 20 7d 0a 20 20 20 |es. }. | +00000da0 20 20 20 20 20 2f 2f 20 54 72 79 20 74 6f 20 6b | // Try to k| +00000db0 65 65 70 20 31 20 64 69 67 69 74 2c 20 6f 6e 6c |eep 1 digit, onl| +00000dc0 79 20 69 66 20 77 65 27 72 65 20 61 6c 6c 6f 77 |y if we're allow| +00000dd0 65 64 20 61 6e 64 20 6e 6f 20 6f 74 68 65 72 0a |ed and no other.| +00000de0 20 20 20 20 20 20 20 20 2f 2f 20 61 6c 74 65 72 | // alter| +00000df0 6e 61 74 69 76 65 73 20 77 65 72 65 20 66 6f 75 |natives were fou| +00000e00 6e 64 0a 20 20 20 20 20 20 20 20 2f 2f 20 54 65 |nd. // Te| +00000e10 73 74 69 6e 67 20 22 72 65 74 2e 6c 65 6e 67 74 |sting "ret.lengt| +00000e20 68 22 20 6d 61 6b 65 73 20 6d 6f 72 65 20 73 65 |h" makes more se| +00000e30 6e 73 65 20 74 68 61 6e 20 74 65 73 74 69 6e 67 |nse than testing| +00000e40 20 22 66 6f 75 6e 64 77 6f 72 64 22 2c 0a 20 20 | "foundword",. | +00000e50 20 20 20 20 20 20 2f 2f 20 62 75 74 20 74 68 65 | // but the| +00000e60 20 6f 74 68 65 72 20 69 6d 70 6c 65 6d 65 6e 74 | other implement| +00000e70 61 74 69 6f 6e 73 20 73 65 65 6d 20 74 6f 20 64 |ations seem to d| +00000e80 6f 20 6a 75 73 74 20 74 68 69 73 2e 0a 20 20 20 |o just this.. | +00000e90 20 20 20 20 20 69 66 20 28 64 69 67 69 74 6f 6b | if (digitok| +00000ea0 20 26 26 20 21 66 6f 75 6e 64 77 6f 72 64 29 20 | && !foundword) | +00000eb0 7b 20 2f 2f 72 65 74 2e 6c 65 6e 67 74 68 20 3d |{ //ret.length =| +00000ec0 3d 20 30 20 20 0a 20 20 20 20 20 20 20 20 20 20 |= 0 . | +00000ed0 20 20 69 66 28 6e 75 6d 62 65 72 73 2e 6c 65 6e | if(numbers.len| +00000ee0 67 74 68 20 3e 20 20 31 29 20 7b 0a 20 20 20 20 |gth > 1) {. | +00000ef0 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 43 | // C| +00000f00 6f 6d 62 69 6e 65 20 31 20 64 69 67 69 74 20 77 |ombine 1 digit w| +00000f10 69 74 68 20 61 6c 6c 20 61 6c 74 65 6e 61 74 69 |ith all altenati| +00000f20 76 65 73 20 66 72 6f 6d 20 74 68 65 20 72 65 73 |ves from the res| +00000f30 74 20 20 20 20 0a 20 20 20 20 20 20 20 20 20 20 |t . | +00000f40 20 20 20 20 20 20 2f 2f 20 28 6e 65 78 74 20 70 | // (next p| +00000f50 69 65 63 65 20 63 61 6e 20 6e 6f 74 20 73 74 61 |iece can not sta| +00000f60 72 74 20 77 69 74 68 20 61 20 64 69 67 69 74 29 |rt with a digit)| +00000f70 20 20 20 20 20 20 20 20 20 20 0a 20 20 20 20 20 | . | +00000f80 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 65 61 | forea| +00000f90 63 68 20 28 61 3b 20 5f 46 69 6e 64 57 6f 72 64 |ch (a; _FindWord| +00000fa0 73 28 20 6e 75 6d 62 65 72 73 5b 31 2e 2e 24 5d |s( numbers[1..$]| +00000fb0 2c 20 66 61 6c 73 65 20 29 20 29 0a 20 20 20 20 |, false ) ). | +00000fc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | +00000fd0 72 65 74 20 7e 3d 20 6e 75 6d 62 65 72 73 5b 30 |ret ~= numbers[0| +00000fe0 2e 2e 31 5d 20 7e 20 22 20 22 20 7e 20 61 3b 0a |..1] ~ " " ~ a;.| +00000ff0 20 20 20 20 20 20 20 20 20 20 20 20 7d 20 20 20 | } | +00001000 20 0a 20 20 20 20 20 20 20 20 20 20 20 20 65 6c | . el| +00001010 73 65 20 20 20 20 0a 20 20 20 20 20 20 20 20 20 |se . | +00001020 20 20 20 20 20 20 20 72 65 74 20 7e 3d 20 6e 75 | ret ~= nu| +00001030 6d 62 65 72 73 5b 30 2e 2e 31 5d 3b 20 20 20 20 |mbers[0..1]; | +00001040 2f 2f 20 6a 75 73 74 20 61 70 70 65 6e 64 20 74 |// just append t| +00001050 68 69 73 20 64 69 67 69 74 20 20 20 20 20 20 20 |his digit | +00001060 20 20 20 20 20 20 0a 20 20 20 20 20 20 20 20 7d | . }| +00001070 20 20 20 20 0a 20 20 20 20 20 20 20 20 72 65 74 | . ret| +00001080 75 72 6e 20 72 65 74 3b 0a 20 20 20 20 7d 0a 0a |urn ret;. }..| +00001090 20 20 20 20 2f 2f 2f 20 28 54 68 69 73 20 66 75 | /// (This fu| +000010a0 6e 63 74 69 6f 6e 20 77 61 73 20 69 6e 6c 69 6e |nction was inlin| +000010b0 65 64 20 69 6e 20 74 68 65 20 6f 72 69 67 69 6e |ed in the origin| +000010c0 61 6c 20 70 72 6f 67 72 61 6d 29 20 0a 20 20 20 |al program) . | +000010d0 20 2f 2f 2f 20 46 69 6e 64 73 20 61 6c 6c 20 61 | /// Finds all a| +000010e0 6c 74 65 72 6e 61 74 69 76 65 73 20 66 6f 72 20 |lternatives for | +000010f0 74 68 65 20 67 69 76 65 6e 20 70 68 6f 6e 65 20 |the given phone | +00001100 6e 75 6d 62 65 72 20 0a 20 20 20 20 2f 2f 2f 20 |number . /// | +00001110 52 65 74 75 72 6e 73 3a 20 61 72 72 61 79 20 6f |Returns: array o| +00001120 66 20 73 74 72 69 6e 67 73 20 0a 20 20 20 20 73 |f strings . s| +00001130 74 72 69 6e 67 61 72 72 61 79 20 46 69 6e 64 57 |tringarray FindW| +00001140 6f 72 64 73 28 20 73 74 72 69 6e 67 20 70 68 6f |ords( string pho| +00001150 6e 65 5f 6e 75 6d 62 65 72 20 29 0a 20 20 20 20 |ne_number ). | +00001160 7b 0a 20 20 20 20 20 20 20 20 69 66 20 28 21 70 |{. if (!p| +00001170 68 6f 6e 65 5f 6e 75 6d 62 65 72 2e 6c 65 6e 67 |hone_number.leng| +00001180 74 68 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 |th). | +00001190 72 65 74 75 72 6e 20 6e 75 6c 6c 3b 0a 20 20 20 |return null;. | +000011a0 20 20 20 20 20 2f 2f 20 53 74 72 69 70 20 74 68 | // Strip th| +000011b0 65 20 6e 6f 6e 2d 64 69 67 69 74 20 63 68 61 72 |e non-digit char| +000011c0 61 63 74 65 72 73 20 66 72 6f 6d 20 74 68 65 20 |acters from the | +000011d0 70 68 6f 6e 65 20 6e 75 6d 62 65 72 2c 20 61 6e |phone number, an| +000011e0 64 0a 20 20 20 20 20 20 20 20 2f 2f 20 70 61 73 |d. // pas| +000011f0 73 20 69 74 20 74 6f 20 74 68 65 20 72 65 63 75 |s it to the recu| +00001200 72 73 69 76 65 20 66 75 6e 63 74 69 6f 6e 20 28 |rsive function (| +00001210 6c 65 61 64 69 6e 67 20 64 69 67 69 74 20 69 73 |leading digit is| +00001220 20 61 6c 6c 6f 77 65 64 29 0a 20 20 20 20 20 20 | allowed). | +00001230 20 20 72 65 74 75 72 6e 20 5f 46 69 6e 64 57 6f | return _FindWo| +00001240 72 64 73 28 20 73 74 72 69 70 4e 6f 6e 44 69 67 |rds( stripNonDig| +00001250 69 74 28 70 68 6f 6e 65 5f 6e 75 6d 62 65 72 29 |it(phone_number)| +00001260 2c 20 74 72 75 65 20 29 3b 20 20 20 20 0a 20 20 |, true ); . | +00001270 20 20 7d 20 20 20 20 0a 20 20 20 20 0a 20 20 20 | } . . | +00001280 20 2f 2f 20 52 65 61 64 20 74 68 65 20 70 68 6f | // Read the pho| +00001290 6e 65 20 6e 75 6d 62 65 72 73 20 20 20 20 20 0a |ne numbers .| +000012a0 20 20 20 20 66 6f 72 65 61 63 68 28 73 74 72 69 | foreach(stri| +000012b0 6e 67 20 70 68 6f 6e 65 3b 20 6e 65 77 20 42 75 |ng phone; new Bu| +000012c0 66 66 65 72 65 64 46 69 6c 65 28 22 69 6e 70 75 |fferedFile("inpu| +000012d0 74 2e 74 78 74 22 20 20 20 29 20 29 0a 20 20 20 |t.txt" ) ). | +000012e0 20 20 20 20 20 66 6f 72 65 61 63 68 28 61 6c 74 | foreach(alt| +000012f0 65 72 6e 61 74 69 76 65 3b 20 46 69 6e 64 57 6f |ernative; FindWo| +00001300 72 64 73 28 20 70 68 6f 6e 65 20 29 20 29 0a 20 |rds( phone ) ). | +00001310 20 20 20 20 20 20 20 20 20 20 20 77 72 69 74 65 | write| +00001320 66 6c 6e 28 70 68 6f 6e 65 2c 20 22 3a 20 22 2c |fln(phone, ": ",| +00001330 20 61 6c 74 65 72 6e 61 74 69 76 65 20 29 3b 0a | alternative );.| +00001340 7d 0a 0a |}..| +00001343 diff --git a/tests/examplefiles/hexdump_hexcat b/tests/examplefiles/hexdump_hexcat new file mode 100644 index 00000000..522074cf --- /dev/null +++ b/tests/examplefiles/hexdump_hexcat @@ -0,0 +1,247 @@ +00000000 2F 2F 20 43 72 65 61 74 65 64 20 62 79 20 4C 69 6F 6E 65 6C //.Created.by.Lionel +00000014 6C 6F 20 4C 75 6E 65 73 75 20 61 6E 64 20 70 6C 61 63 65 64 lo.Lunesu.and.placed +00000028 20 69 6E 20 74 68 65 20 70 75 62 6C 69 63 20 64 6F 6D 61 69 .in.the.public.domai +0000003C 6E 2E 0A 2F 2F 20 54 68 69 73 20 66 69 6C 65 20 68 61 73 20 n..//.This.file.has. +00000050 62 65 65 6E 20 6D 6F 64 69 66 69 65 64 20 66 72 6F 6D 20 69 been.modified.from.i +00000064 74 73 20 6F 72 69 67 69 6E 61 6C 20 76 65 72 73 69 6F 6E 2E ts.original.version. +00000078 0A 2F 2F 20 49 74 20 68 61 73 20 62 65 65 6E 20 66 6F 72 6D .//.It.has.been.form +0000008C 61 74 74 65 64 20 74 6F 20 66 69 74 20 79 6F 75 72 20 73 63 atted.to.fit.your.sc +000000A0 72 65 65 6E 2E 0A 6D 6F 64 75 6C 65 20 70 68 6F 6E 65 6E 6F reen..module.phoneno +000000B4 3B 20 20 20 20 20 2F 2F 20 6F 70 74 69 6F 6E 61 6C 0A 69 6D ;.....//.optional.im +000000C8 70 6F 72 74 20 73 74 64 2E 73 74 64 69 6F 3B 20 20 20 2F 2F port.std.stdio;...// +000000DC 20 77 72 69 74 65 66 6C 6E 20 20 20 20 20 0A 69 6D 70 6F 72 .writefln......impor +000000F0 74 20 73 74 64 2E 63 74 79 70 65 3B 20 20 20 2F 2F 20 69 73 t.std.ctype;...//.is +00000104 64 69 67 69 74 20 20 20 20 20 0A 69 6D 70 6F 72 74 20 73 74 digit......import.st +00000118 64 2E 73 74 72 65 61 6D 3B 20 20 2F 2F 20 42 75 66 66 65 72 d.stream;..//.Buffer +0000012C 65 64 46 69 6C 65 0A 0A 2F 2F 20 4A 75 73 74 20 66 6F 72 20 edFile..//.Just.for. +00000140 72 65 61 64 61 62 69 6C 69 74 79 20 28 69 6D 61 67 69 6E 65 readability.(imagine +00000154 20 63 68 61 72 5B 5D 5B 5D 5B 63 68 61 72 5B 5D 5D 29 20 20 .char[][][char[]]).. +00000168 20 20 0A 61 6C 69 61 73 20 63 68 61 72 5B 5D 20 73 74 72 69 ...alias.char[].stri +0000017C 6E 67 3B 0A 61 6C 69 61 73 20 73 74 72 69 6E 67 5B 5D 20 73 ng;.alias.string[].s +00000190 74 72 69 6E 67 61 72 72 61 79 3B 0A 0A 2F 2F 2F 20 53 74 72 tringarray;..///.Str +000001A4 69 70 73 20 6E 6F 6E 2D 64 69 67 69 74 20 63 68 61 72 61 63 ips.non-digit.charac +000001B8 74 65 72 73 20 66 72 6F 6D 20 74 68 65 20 73 74 72 69 6E 67 ters.from.the.string +000001CC 20 28 43 4F 57 29 0A 73 74 72 69 6E 67 20 73 74 72 69 70 4E .(COW).string.stripN +000001E0 6F 6E 44 69 67 69 74 28 20 69 6E 20 73 74 72 69 6E 67 20 6C onDigit(.in.string.l +000001F4 69 6E 65 20 29 20 0A 7B 0A 20 20 20 20 73 74 72 69 6E 67 20 ine.)..{.....string. +00000208 72 65 74 3B 0A 20 20 20 20 66 6F 72 65 61 63 68 28 75 69 6E ret;.....foreach(uin +0000021C 74 20 69 2C 20 63 3B 20 6C 69 6E 65 29 20 7B 0A 20 20 20 20 t.i,.c;.line).{..... +00000230 20 20 20 20 2F 2F 20 45 72 72 6F 72 3A 20 73 74 64 2E 63 74 ....//.Error:.std.ct +00000244 79 70 65 2E 69 73 64 69 67 69 74 20 61 74 20 43 3A 5C 64 6D ype.isdigit.at.C:\dm +00000258 64 5C 73 72 63 5C 70 68 6F 62 6F 73 5C 73 74 64 5C 63 74 79 d\src\phobos\std\cty +0000026C 70 65 2E 64 28 33 37 29 20 0A 20 20 20 20 20 20 20 20 2F 2F pe.d(37)..........// +00000280 20 63 6F 6E 66 6C 69 63 74 73 20 77 69 74 68 20 73 74 64 2E .conflicts.with.std. +00000294 73 74 72 65 61 6D 2E 69 73 64 69 67 69 74 20 61 74 20 43 3A stream.isdigit.at.C: +000002A8 5C 64 6D 64 5C 73 72 63 5C 70 68 6F 62 6F 73 5C 73 74 64 5C \dmd\src\phobos\std\ +000002BC 73 74 72 65 61 6D 2E 64 28 32 39 32 34 29 0A 20 20 20 20 20 stream.d(2924)...... +000002D0 20 20 20 69 66 20 28 21 73 74 64 2E 63 74 79 70 65 2E 69 73 ...if.(!std.ctype.is +000002E4 64 69 67 69 74 28 63 29 29 20 7B 0A 20 20 20 20 20 20 20 20 digit(c)).{......... +000002F8 20 20 20 20 69 66 20 28 21 72 65 74 29 0A 20 20 20 20 20 20 ....if.(!ret)....... +0000030C 20 20 20 20 20 20 20 20 20 20 72 65 74 20 3D 20 6C 69 6E 65 ..........ret.=.line +00000320 5B 30 2E 2E 69 5D 3B 20 20 20 20 0A 20 20 20 20 20 20 20 20 [0..i];............. +00000334 7D 20 20 20 20 0A 20 20 20 20 20 20 20 20 65 6C 73 65 20 69 }.............else.i +00000348 66 20 28 72 65 74 29 0A 20 20 20 20 20 20 20 20 20 20 20 20 f.(ret)............. +0000035C 72 65 74 20 7E 3D 20 63 3B 20 20 20 20 0A 20 20 20 20 7D 20 ret.~=.c;.........}. +00000370 20 20 20 0A 20 20 20 20 72 65 74 75 72 6E 20 72 65 74 3F 72 ........return.ret?r +00000384 65 74 3A 6C 69 6E 65 3B 0A 7D 0A 0A 75 6E 69 74 74 65 73 74 et:line;.}..unittest +00000398 20 7B 0A 20 20 20 20 61 73 73 65 72 74 28 20 73 74 72 69 70 .{.....assert(.strip +000003AC 4E 6F 6E 44 69 67 69 74 28 22 61 73 64 66 22 29 20 3D 3D 20 NonDigit("asdf").==. +000003C0 22 22 20 20 29 3B 0A 20 20 20 20 61 73 73 65 72 74 28 20 73 ""..);.....assert(.s +000003D4 74 72 69 70 4E 6F 6E 44 69 67 69 74 28 22 5C 27 31 33 2D 3D tripNonDigit("\'13-= +000003E8 32 20 34 6B 6F 70 22 29 20 3D 3D 20 20 22 31 33 32 34 22 20 2.4kop").==.."1324". +000003FC 20 29 3B 0A 7D 0A 0A 2F 2F 2F 20 43 6F 6E 76 65 72 74 73 20 .);.}..///.Converts. +00000410 61 20 77 6F 72 64 20 69 6E 74 6F 20 61 20 6E 75 6D 62 65 72 a.word.into.a.number +00000424 2C 20 69 67 6E 6F 72 69 6E 67 20 61 6C 6C 20 6E 6F 6E 20 61 ,.ignoring.all.non.a +00000438 6C 70 68 61 20 63 68 61 72 61 63 74 65 72 73 20 20 0A 73 74 lpha.characters...st +0000044C 72 69 6E 67 20 77 6F 72 64 54 6F 4E 75 6D 28 20 69 6E 20 73 ring.wordToNum(.in.s +00000460 74 72 69 6E 67 20 77 6F 72 64 20 29 0A 7B 0A 2F 2F 20 74 72 tring.word.).{.//.tr +00000474 61 6E 73 6C 61 74 69 6F 6E 20 74 61 62 6C 65 20 66 6F 72 20 anslation.table.for. +00000488 74 68 65 20 74 61 73 6B 20 61 74 20 68 61 6E 64 0A 63 6F 6E the.task.at.hand.con +0000049C 73 74 20 63 68 61 72 5B 32 35 36 5D 20 54 52 41 4E 53 4C 41 st.char[256].TRANSLA +000004B0 54 45 20 3D 20 20 20 20 0A 20 20 20 20 22 20 20 20 20 20 20 TE.=........."...... +000004C4 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .................... +000004D8 20 20 20 20 20 20 22 20 20 2F 2F 20 30 20 20 20 0A 20 20 20 ......"..//.0....... +000004EC 20 22 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 30 31 ."................01 +00000500 32 33 34 35 36 37 38 39 20 20 20 20 20 20 22 20 20 2F 2F 20 23456789......"..//. +00000514 33 32 20 20 20 20 20 0A 20 20 20 20 22 20 35 37 36 33 30 34 32..........".576304 +00000528 39 39 36 31 37 38 35 31 38 38 31 32 33 34 37 36 32 32 33 39 99617851881234762239 +0000053C 20 20 20 20 20 22 20 20 2F 2F 20 36 34 20 20 20 0A 20 20 20 ....."..//.64....... +00000550 20 22 20 35 37 36 33 30 34 39 39 36 31 37 38 35 31 38 38 31 .".57630499617851881 +00000564 32 33 34 37 36 32 32 33 39 20 20 20 20 20 22 0A 20 20 20 20 234762239....."..... +00000578 22 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 "................... +0000058C 20 20 20 20 20 20 20 20 20 20 20 20 20 22 0A 20 20 20 20 22 ............."....." +000005A0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .................... +000005B4 20 20 20 20 20 20 20 20 20 20 20 20 22 0A 20 20 20 20 22 20 ............".....". +000005C8 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .................... +000005DC 20 20 20 20 20 20 20 20 20 20 20 22 20 20 20 20 0A 20 20 20 ..........."........ +000005F0 20 22 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .".................. +00000604 20 20 20 20 20 20 20 20 20 20 20 20 20 20 22 3B 0A 20 20 20 ..............";.... +00000618 20 73 74 72 69 6E 67 20 72 65 74 3B 0A 20 20 20 20 66 6F 72 .string.ret;.....for +0000062C 65 61 63 68 28 63 3B 20 63 61 73 74 28 75 62 79 74 65 5B 5D each(c;.cast(ubyte[] +00000640 29 77 6F 72 64 29 0A 20 20 20 20 20 20 20 20 69 66 20 28 54 )word).........if.(T +00000654 52 41 4E 53 4C 41 54 45 5B 63 5D 20 21 3D 20 27 20 27 29 0A RANSLATE[c].!=.'.'). +00000668 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 20 7E 3D 20 54 ............ret.~=.T +0000067C 52 41 4E 53 4C 41 54 45 5B 63 5D 3B 0A 20 20 20 20 72 65 74 RANSLATE[c];.....ret +00000690 75 72 6E 20 72 65 74 3B 0A 7D 0A 0A 75 6E 69 74 74 65 73 74 urn.ret;.}..unittest +000006A4 20 7B 0A 20 2F 2F 20 54 65 73 74 20 77 6F 72 64 54 6F 4E 75 .{..//.Test.wordToNu +000006B8 6D 20 75 73 69 6E 67 20 74 68 65 20 74 61 62 6C 65 20 66 72 m.using.the.table.fr +000006CC 6F 6D 20 74 68 65 20 74 61 73 6B 20 64 65 73 63 72 69 70 74 om.the.task.descript +000006E0 69 6F 6E 2E 0A 20 61 73 73 65 72 74 28 20 22 30 31 31 31 32 ion...assert(."01112 +000006F4 32 32 33 33 33 34 34 35 35 36 36 36 37 37 37 38 38 38 39 39 22333445566677788899 +00000708 39 22 20 3D 3D 0A 20 20 20 77 6F 72 64 54 6F 4E 75 6D 28 22 9".==....wordToNum(" +0000071C 45 20 7C 20 4A 20 4E 20 51 20 7C 20 52 20 57 20 58 20 7C 20 E.|.J.N.Q.|.R.W.X.|. +00000730 44 20 53 20 59 20 7C 20 46 20 54 20 7C 20 41 20 4D 20 7C 20 D.S.Y.|.F.T.|.A.M.|. +00000744 43 20 49 20 56 20 7C 20 42 20 4B 20 55 20 7C 20 4C 20 4F 20 C.I.V.|.B.K.U.|.L.O. +00000758 50 20 7C 20 47 20 48 20 5A 22 29 29 3B 0A 20 61 73 73 65 72 P.|.G.H.Z"));..asser +0000076C 74 28 20 22 30 31 31 31 32 32 32 33 33 33 34 34 35 35 36 36 t(."0111222333445566 +00000780 36 37 37 37 38 38 38 39 39 39 22 20 3D 3D 20 0A 20 20 20 77 6777888999".==.....w +00000794 6F 72 64 54 6F 4E 75 6D 28 22 65 20 7C 20 6A 20 6E 20 71 20 ordToNum("e.|.j.n.q. +000007A8 7C 20 72 20 77 20 78 20 7C 20 64 20 73 20 79 20 7C 20 66 20 |.r.w.x.|.d.s.y.|.f. +000007BC 74 20 7C 20 61 20 6D 20 7C 20 63 20 69 20 76 20 7C 20 62 20 t.|.a.m.|.c.i.v.|.b. +000007D0 6B 20 75 20 7C 20 6C 20 6F 20 70 20 7C 20 67 20 68 20 7A 22 k.u.|.l.o.p.|.g.h.z" +000007E4 29 29 3B 0A 20 61 73 73 65 72 74 28 20 22 30 31 32 33 34 35 ));..assert(."012345 +000007F8 36 37 38 39 22 20 3D 3D 20 0A 20 20 20 77 6F 72 64 54 6F 4E 6789".==.....wordToN +0000080C 75 6D 28 22 30 20 7C 20 20 20 31 20 20 20 7C 20 20 20 32 20 um("0.|...1...|...2. +00000820 20 20 7C 20 20 20 33 20 20 20 7C 20 20 34 20 20 7C 20 20 35 ..|...3...|..4..|..5 +00000834 20 20 7C 20 20 20 36 20 20 20 7C 20 20 20 37 20 20 20 7C 20 ..|...6...|...7...|. +00000848 20 20 38 20 20 20 7C 20 20 20 39 22 29 29 3B 0A 7D 0A 0A 76 ..8...|...9"));.}..v +0000085C 6F 69 64 20 6D 61 69 6E 28 20 73 74 72 69 6E 67 5B 5D 20 61 oid.main(.string[].a +00000870 72 67 73 20 29 0A 7B 0A 20 20 20 20 2F 2F 20 54 68 69 73 20 rgs.).{.....//.This. +00000884 61 73 73 6F 63 69 61 74 69 76 65 20 61 72 72 61 79 20 6D 61 associative.array.ma +00000898 70 73 20 61 20 6E 75 6D 62 65 72 20 74 6F 20 61 6E 20 61 72 ps.a.number.to.an.ar +000008AC 72 61 79 20 6F 66 20 77 6F 72 64 73 2E 20 20 20 20 0A 20 20 ray.of.words........ +000008C0 20 20 73 74 72 69 6E 67 61 72 72 61 79 5B 73 74 72 69 6E 67 ..stringarray[string +000008D4 5D 20 20 20 20 6E 75 6D 32 77 6F 72 64 73 3B 0A 0A 20 20 20 ]....num2words;..... +000008E8 20 66 6F 72 65 61 63 68 28 73 74 72 69 6E 67 20 77 6F 72 64 .foreach(string.word +000008FC 3B 20 6E 65 77 20 42 75 66 66 65 72 65 64 46 69 6C 65 28 22 ;.new.BufferedFile(" +00000910 64 69 63 74 69 6F 6E 61 72 79 2E 74 78 74 22 20 29 20 29 0A dictionary.txt".).). +00000924 20 20 20 20 20 20 20 20 6E 75 6D 32 77 6F 72 64 73 5B 20 77 ........num2words[.w +00000938 6F 72 64 54 6F 4E 75 6D 28 77 6F 72 64 29 20 5D 20 7E 3D 20 ordToNum(word).].~=. +0000094C 77 6F 72 64 2E 64 75 70 3B 20 20 20 20 20 20 20 20 2F 2F 20 word.dup;........//. +00000960 6D 75 73 74 20 64 75 70 0A 0A 20 20 20 20 2F 2F 2F 20 46 69 must.dup......///.Fi +00000974 6E 64 73 20 61 6C 6C 20 61 6C 74 65 72 6E 61 74 69 76 65 73 nds.all.alternatives +00000988 20 66 6F 72 20 74 68 65 20 67 69 76 65 6E 20 6E 75 6D 62 65 .for.the.given.numbe +0000099C 72 0A 20 20 20 20 2F 2F 2F 20 28 73 68 6F 75 6C 64 20 68 61 r.....///.(should.ha +000009B0 76 65 20 62 65 65 6E 20 73 74 72 69 70 70 65 64 20 66 72 6F ve.been.stripped.fro +000009C4 6D 20 6E 6F 6E 2D 64 69 67 69 74 20 63 68 61 72 61 63 74 65 m.non-digit.characte +000009D8 72 73 29 0A 20 20 20 20 73 74 72 69 6E 67 61 72 72 61 79 20 rs).....stringarray. +000009EC 5F 46 69 6E 64 57 6F 72 64 73 28 20 73 74 72 69 6E 67 20 6E _FindWords(.string.n +00000A00 75 6D 62 65 72 73 2C 20 62 6F 6F 6C 20 64 69 67 69 74 6F 6B umbers,.bool.digitok +00000A14 20 29 0A 20 20 20 20 69 6E 20 7B 0A 20 20 20 20 20 20 20 20 .).....in.{......... +00000A28 61 73 73 65 72 74 28 6E 75 6D 62 65 72 73 2E 6C 65 6E 67 74 assert(numbers.lengt +00000A3C 68 20 3E 20 20 30 29 3B 20 20 20 20 0A 20 20 20 20 7D 20 20 h.>..0);.........}.. +00000A50 20 20 0A 20 20 20 20 6F 75 74 28 72 65 73 75 6C 74 29 20 7B .......out(result).{ +00000A64 0A 20 20 20 20 20 20 20 20 66 6F 72 65 61 63 68 20 28 61 3B .........foreach.(a; +00000A78 20 72 65 73 75 6C 74 29 0A 20 20 20 20 20 20 20 20 20 20 20 .result)............ +00000A8C 20 61 73 73 65 72 74 28 20 77 6F 72 64 54 6F 4E 75 6D 28 61 .assert(.wordToNum(a +00000AA0 29 20 3D 3D 20 6E 75 6D 62 65 72 73 20 29 3B 0A 20 20 20 20 ).==.numbers.);..... +00000AB4 7D 20 20 20 20 0A 20 20 20 20 62 6F 64 79 20 7B 0A 20 20 20 }.........body.{.... +00000AC8 20 20 20 20 20 73 74 72 69 6E 67 61 72 72 61 79 20 72 65 74 .....stringarray.ret +00000ADC 3B 0A 20 20 20 20 20 20 20 20 62 6F 6F 6C 20 66 6F 75 6E 64 ;.........bool.found +00000AF0 77 6F 72 64 20 3D 20 66 61 6C 73 65 3B 0A 20 20 20 20 20 20 word.=.false;....... +00000B04 20 20 66 6F 72 20 28 75 69 6E 74 20 74 3D 31 3B 20 74 3C 3D ..for.(uint.t=1;.t<= +00000B18 6E 75 6D 62 65 72 73 2E 6C 65 6E 67 74 68 3B 20 2B 2B 74 29 numbers.length;.++t) +00000B2C 20 7B 0A 20 20 20 20 20 20 20 20 20 20 20 20 61 75 74 6F 20 .{.............auto. +00000B40 61 6C 74 65 72 6E 61 74 69 76 65 73 20 3D 20 6E 75 6D 62 65 alternatives.=.numbe +00000B54 72 73 5B 30 2E 2E 74 5D 20 69 6E 20 6E 75 6D 32 77 6F 72 64 rs[0..t].in.num2word +00000B68 73 3B 0A 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 21 s;.............if.(! +00000B7C 61 6C 74 65 72 6E 61 74 69 76 65 73 29 0A 20 20 20 20 20 20 alternatives)....... +00000B90 20 20 20 20 20 20 20 20 20 20 63 6F 6E 74 69 6E 75 65 3B 0A ..........continue;. +00000BA4 20 20 20 20 20 20 20 20 20 20 20 20 66 6F 75 6E 64 77 6F 72 ............foundwor +00000BB8 64 20 3D 20 74 72 75 65 3B 0A 20 20 20 20 20 20 20 20 20 20 d.=.true;........... +00000BCC 20 20 69 66 20 28 6E 75 6D 62 65 72 73 2E 6C 65 6E 67 74 68 ..if.(numbers.length +00000BE0 20 3E 20 20 74 29 20 7B 0A 20 20 20 20 20 20 20 20 20 20 20 .>..t).{............ +00000BF4 20 20 20 20 20 2F 2F 20 43 6F 6D 62 69 6E 65 20 61 6C 6C 20 .....//.Combine.all. +00000C08 63 75 72 72 65 6E 74 20 61 6C 74 65 72 6E 61 74 69 76 65 73 current.alternatives +00000C1C 20 77 69 74 68 20 61 6C 6C 20 61 6C 74 65 72 6E 61 74 69 76 .with.all.alternativ +00000C30 65 73 20 20 20 20 20 0A 20 20 20 20 20 20 20 20 20 20 20 20 es.................. +00000C44 20 20 20 20 2F 2F 20 6F 66 20 74 68 65 20 72 65 73 74 20 28 ....//.of.the.rest.( +00000C58 6E 65 78 74 20 70 69 65 63 65 20 63 61 6E 20 73 74 61 72 74 next.piece.can.start +00000C6C 20 77 69 74 68 20 61 20 64 69 67 69 74 29 20 20 20 20 20 20 .with.a.digit)...... +00000C80 20 20 20 20 20 20 20 20 0A 20 20 20 20 20 20 20 20 20 20 20 .................... +00000C94 20 20 20 20 20 66 6F 72 65 61 63 68 20 28 61 32 3B 20 5F 46 .....foreach.(a2;._F +00000CA8 69 6E 64 57 6F 72 64 73 28 20 6E 75 6D 62 65 72 73 5B 74 2E indWords(.numbers[t. +00000CBC 2E 24 5D 2C 20 74 72 75 65 20 20 20 20 20 29 20 29 0A 20 20 .$],.true.....).)... +00000CD0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 66 6F ..................fo +00000CE4 72 65 61 63 68 28 61 31 3B 20 2A 61 6C 74 65 72 6E 61 74 69 reach(a1;.*alternati +00000CF8 76 65 73 29 0A 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ves)................ +00000D0C 20 20 20 20 20 20 20 20 72 65 74 20 7E 3D 20 61 31 20 7E 20 ........ret.~=.a1.~. +00000D20 22 20 22 20 7E 20 61 32 3B 0A 20 20 20 20 20 20 20 20 20 20 ".".~.a2;........... +00000D34 20 20 7D 0A 20 20 20 20 20 20 20 20 20 20 20 20 65 6C 73 65 ..}.............else +00000D48 20 20 20 20 0A 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .................... +00000D5C 20 72 65 74 20 7E 3D 20 2A 61 6C 74 65 72 6E 61 74 69 76 65 .ret.~=.*alternative +00000D70 73 3B 20 20 20 20 2F 2F 20 61 70 70 65 6E 64 20 74 68 65 73 s;....//.append.thes +00000D84 65 20 61 6C 74 65 72 6E 61 74 69 76 65 73 0A 20 20 20 20 20 e.alternatives...... +00000D98 20 20 20 7D 0A 20 20 20 20 20 20 20 20 2F 2F 20 54 72 79 20 ...}.........//.Try. +00000DAC 74 6F 20 6B 65 65 70 20 31 20 64 69 67 69 74 2C 20 6F 6E 6C to.keep.1.digit,.onl +00000DC0 79 20 69 66 20 77 65 27 72 65 20 61 6C 6C 6F 77 65 64 20 61 y.if.we're.allowed.a +00000DD4 6E 64 20 6E 6F 20 6F 74 68 65 72 0A 20 20 20 20 20 20 20 20 nd.no.other......... +00000DE8 2F 2F 20 61 6C 74 65 72 6E 61 74 69 76 65 73 20 77 65 72 65 //.alternatives.were +00000DFC 20 66 6F 75 6E 64 0A 20 20 20 20 20 20 20 20 2F 2F 20 54 65 .found.........//.Te +00000E10 73 74 69 6E 67 20 22 72 65 74 2E 6C 65 6E 67 74 68 22 20 6D sting."ret.length".m +00000E24 61 6B 65 73 20 6D 6F 72 65 20 73 65 6E 73 65 20 74 68 61 6E akes.more.sense.than +00000E38 20 74 65 73 74 69 6E 67 20 22 66 6F 75 6E 64 77 6F 72 64 22 .testing."foundword" +00000E4C 2C 0A 20 20 20 20 20 20 20 20 2F 2F 20 62 75 74 20 74 68 65 ,.........//.but.the +00000E60 20 6F 74 68 65 72 20 69 6D 70 6C 65 6D 65 6E 74 61 74 69 6F .other.implementatio +00000E74 6E 73 20 73 65 65 6D 20 74 6F 20 64 6F 20 6A 75 73 74 20 74 ns.seem.to.do.just.t +00000E88 68 69 73 2E 0A 20 20 20 20 20 20 20 20 69 66 20 28 64 69 67 his..........if.(dig +00000E9C 69 74 6F 6B 20 26 26 20 21 66 6F 75 6E 64 77 6F 72 64 29 20 itok.&&.!foundword). +00000EB0 7B 20 2F 2F 72 65 74 2E 6C 65 6E 67 74 68 20 3D 3D 20 30 20 {.//ret.length.==.0. +00000EC4 20 0A 20 20 20 20 20 20 20 20 20 20 20 20 69 66 28 6E 75 6D ..............if(num +00000ED8 62 65 72 73 2E 6C 65 6E 67 74 68 20 3E 20 20 31 29 20 7B 0A bers.length.>..1).{. +00000EEC 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2F 2F 20 43 ................//.C +00000F00 6F 6D 62 69 6E 65 20 31 20 64 69 67 69 74 20 77 69 74 68 20 ombine.1.digit.with. +00000F14 61 6C 6C 20 61 6C 74 65 6E 61 74 69 76 65 73 20 66 72 6F 6D all.altenatives.from +00000F28 20 74 68 65 20 72 65 73 74 20 20 20 20 0A 20 20 20 20 20 20 .the.rest........... +00000F3C 20 20 20 20 20 20 20 20 20 20 2F 2F 20 28 6E 65 78 74 20 70 ..........//.(next.p +00000F50 69 65 63 65 20 63 61 6E 20 6E 6F 74 20 73 74 61 72 74 20 77 iece.can.not.start.w +00000F64 69 74 68 20 61 20 64 69 67 69 74 29 20 20 20 20 20 20 20 20 ith.a.digit)........ +00000F78 20 20 0A 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 66 ...................f +00000F8C 6F 72 65 61 63 68 20 28 61 3B 20 5F 46 69 6E 64 57 6F 72 64 oreach.(a;._FindWord +00000FA0 73 28 20 6E 75 6D 62 65 72 73 5B 31 2E 2E 24 5D 2C 20 66 61 s(.numbers[1..$],.fa +00000FB4 6C 73 65 20 29 20 29 0A 20 20 20 20 20 20 20 20 20 20 20 20 lse.).)............. +00000FC8 20 20 20 20 20 20 20 20 72 65 74 20 7E 3D 20 6E 75 6D 62 65 ........ret.~=.numbe +00000FDC 72 73 5B 30 2E 2E 31 5D 20 7E 20 22 20 22 20 7E 20 61 3B 0A rs[0..1].~.".".~.a;. +00000FF0 20 20 20 20 20 20 20 20 20 20 20 20 7D 20 20 20 20 0A 20 20 ............}....... +00001004 20 20 20 20 20 20 20 20 20 20 65 6C 73 65 20 20 20 20 0A 20 ..........else...... +00001018 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 20 7E ...............ret.~ +0000102C 3D 20 6E 75 6D 62 65 72 73 5B 30 2E 2E 31 5D 3B 20 20 20 20 =.numbers[0..1];.... +00001040 2F 2F 20 6A 75 73 74 20 61 70 70 65 6E 64 20 74 68 69 73 20 //.just.append.this. +00001054 64 69 67 69 74 20 20 20 20 20 20 20 20 20 20 20 20 20 0A 20 digit............... +00001068 20 20 20 20 20 20 20 7D 20 20 20 20 0A 20 20 20 20 20 20 20 .......}............ +0000107C 20 72 65 74 75 72 6E 20 72 65 74 3B 0A 20 20 20 20 7D 0A 0A .return.ret;.....}.. +00001090 20 20 20 20 2F 2F 2F 20 28 54 68 69 73 20 66 75 6E 63 74 69 ....///.(This.functi +000010A4 6F 6E 20 77 61 73 20 69 6E 6C 69 6E 65 64 20 69 6E 20 74 68 on.was.inlined.in.th +000010B8 65 20 6F 72 69 67 69 6E 61 6C 20 70 72 6F 67 72 61 6D 29 20 e.original.program). +000010CC 0A 20 20 20 20 2F 2F 2F 20 46 69 6E 64 73 20 61 6C 6C 20 61 .....///.Finds.all.a +000010E0 6C 74 65 72 6E 61 74 69 76 65 73 20 66 6F 72 20 74 68 65 20 lternatives.for.the. +000010F4 67 69 76 65 6E 20 70 68 6F 6E 65 20 6E 75 6D 62 65 72 20 0A given.phone.number.. +00001108 20 20 20 20 2F 2F 2F 20 52 65 74 75 72 6E 73 3A 20 61 72 72 ....///.Returns:.arr +0000111C 61 79 20 6F 66 20 73 74 72 69 6E 67 73 20 0A 20 20 20 20 73 ay.of.strings......s +00001130 74 72 69 6E 67 61 72 72 61 79 20 46 69 6E 64 57 6F 72 64 73 tringarray.FindWords +00001144 28 20 73 74 72 69 6E 67 20 70 68 6F 6E 65 5F 6E 75 6D 62 65 (.string.phone_numbe +00001158 72 20 29 0A 20 20 20 20 7B 0A 20 20 20 20 20 20 20 20 69 66 r.).....{.........if +0000116C 20 28 21 70 68 6F 6E 65 5F 6E 75 6D 62 65 72 2E 6C 65 6E 67 .(!phone_number.leng +00001180 74 68 29 0A 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 th).............retu +00001194 72 6E 20 6E 75 6C 6C 3B 0A 20 20 20 20 20 20 20 20 2F 2F 20 rn.null;.........//. +000011A8 53 74 72 69 70 20 74 68 65 20 6E 6F 6E 2D 64 69 67 69 74 20 Strip.the.non-digit. +000011BC 63 68 61 72 61 63 74 65 72 73 20 66 72 6F 6D 20 74 68 65 20 characters.from.the. +000011D0 70 68 6F 6E 65 20 6E 75 6D 62 65 72 2C 20 61 6E 64 0A 20 20 phone.number,.and... +000011E4 20 20 20 20 20 20 2F 2F 20 70 61 73 73 20 69 74 20 74 6F 20 ......//.pass.it.to. +000011F8 74 68 65 20 72 65 63 75 72 73 69 76 65 20 66 75 6E 63 74 69 the.recursive.functi +0000120C 6F 6E 20 28 6C 65 61 64 69 6E 67 20 64 69 67 69 74 20 69 73 on.(leading.digit.is +00001220 20 61 6C 6C 6F 77 65 64 29 0A 20 20 20 20 20 20 20 20 72 65 .allowed).........re +00001234 74 75 72 6E 20 5F 46 69 6E 64 57 6F 72 64 73 28 20 73 74 72 turn._FindWords(.str +00001248 69 70 4E 6F 6E 44 69 67 69 74 28 70 68 6F 6E 65 5F 6E 75 6D ipNonDigit(phone_num +0000125C 62 65 72 29 2C 20 74 72 75 65 20 29 3B 20 20 20 20 0A 20 20 ber),.true.);....... +00001270 20 20 7D 20 20 20 20 0A 20 20 20 20 0A 20 20 20 20 2F 2F 20 ..}..............//. +00001284 52 65 61 64 20 74 68 65 20 70 68 6F 6E 65 20 6E 75 6D 62 65 Read.the.phone.numbe +00001298 72 73 20 20 20 20 20 0A 20 20 20 20 66 6F 72 65 61 63 68 28 rs..........foreach( +000012AC 73 74 72 69 6E 67 20 70 68 6F 6E 65 3B 20 6E 65 77 20 42 75 string.phone;.new.Bu +000012C0 66 66 65 72 65 64 46 69 6C 65 28 22 69 6E 70 75 74 2E 74 78 fferedFile("input.tx +000012D4 74 22 20 20 20 29 20 29 0A 20 20 20 20 20 20 20 20 66 6F 72 t"...).).........for +000012E8 65 61 63 68 28 61 6C 74 65 72 6E 61 74 69 76 65 3B 20 46 69 each(alternative;.Fi +000012FC 6E 64 57 6F 72 64 73 28 20 70 68 6F 6E 65 20 29 20 29 0A 20 ndWords(.phone.).).. +00001310 20 20 20 20 20 20 20 20 20 20 20 77 72 69 74 65 66 6C 6E 28 ...........writefln( +00001324 70 68 6F 6E 65 2C 20 22 3A 20 22 2C 20 61 6C 74 65 72 6E 61 phone,.":.",.alterna +00001338 74 69 76 65 20 29 3B 0A 7D 0A 0A tive.);.}.. diff --git a/tests/examplefiles/hexdump_hexdump b/tests/examplefiles/hexdump_hexdump new file mode 100644 index 00000000..06c2e861 --- /dev/null +++ b/tests/examplefiles/hexdump_hexdump @@ -0,0 +1,310 @@ +0000000 2f2f 4320 6572 7461 6465 6220 2079 694c +0000010 6e6f 6c65 6f6c 4c20 6e75 7365 2075 6e61 +0000020 2064 6c70 6361 6465 6920 206e 6874 2065 +0000030 7570 6c62 6369 6420 6d6f 6961 2e6e 2f0a +0000040 202f 6854 7369 6620 6c69 2065 6168 2073 +0000050 6562 6e65 6d20 646f 6669 6569 2064 7266 +0000060 6d6f 6920 7374 6f20 6972 6967 616e 206c +0000070 6576 7372 6f69 2e6e 2f0a 202f 7449 6820 +0000080 7361 6220 6565 206e 6f66 6d72 7461 6574 +0000090 2064 6f74 6620 7469 7920 756f 2072 6373 +00000a0 6572 6e65 0a2e 6f6d 7564 656c 7020 6f68 +00000b0 656e 6f6e 203b 2020 2020 2f2f 6f20 7470 +00000c0 6f69 616e 0a6c 6d69 6f70 7472 7320 6474 +00000d0 732e 6474 6f69 203b 2020 2f2f 7720 6972 +00000e0 6574 6c66 206e 2020 2020 690a 706d 726f +00000f0 2074 7473 2e64 7463 7079 3b65 2020 2f20 +0000100 202f 7369 6964 6967 2074 2020 2020 690a +0000110 706d 726f 2074 7473 2e64 7473 6572 6d61 +0000120 203b 2f20 202f 7542 6666 7265 6465 6946 +0000130 656c 0a0a 2f2f 4a20 7375 2074 6f66 2072 +0000140 6572 6461 6261 6c69 7469 2079 6928 616d +0000150 6967 656e 6320 6168 5b72 5b5d 5b5d 6863 +0000160 7261 5d5b 295d 2020 2020 610a 696c 7361 +0000170 6320 6168 5b72 205d 7473 6972 676e 0a3b +0000180 6c61 6169 2073 7473 6972 676e 5d5b 7320 +0000190 7274 6e69 6167 7272 7961 0a3b 2f0a 2f2f +00001a0 5320 7274 7069 2073 6f6e 2d6e 6964 6967 +00001b0 2074 6863 7261 6361 6574 7372 6620 6f72 +00001c0 206d 6874 2065 7473 6972 676e 2820 4f43 +00001d0 2957 730a 7274 6e69 2067 7473 6972 4e70 +00001e0 6e6f 6944 6967 2874 6920 206e 7473 6972 +00001f0 676e 6c20 6e69 2065 2029 7b0a 200a 2020 +0000200 7320 7274 6e69 2067 6572 3b74 200a 2020 +0000210 6620 726f 6165 6863 7528 6e69 2074 2c69 +0000220 6320 203b 696c 656e 2029 0a7b 2020 2020 +0000230 2020 2020 2f2f 4520 7272 726f 203a 7473 +0000240 2e64 7463 7079 2e65 7369 6964 6967 2074 +0000250 7461 4320 5c3a 6d64 5c64 7273 5c63 6870 +0000260 626f 736f 735c 6474 635c 7974 6570 642e +0000270 3328 2937 0a20 2020 2020 2020 2020 2f2f +0000280 6320 6e6f 6c66 6369 7374 7720 7469 2068 +0000290 7473 2e64 7473 6572 6d61 692e 6473 6769 +00002a0 7469 6120 2074 3a43 645c 646d 735c 6372 +00002b0 705c 6f68 6f62 5c73 7473 5c64 7473 6572 +00002c0 6d61 642e 3228 3239 2934 200a 2020 2020 +00002d0 2020 6920 2066 2128 7473 2e64 7463 7079 +00002e0 2e65 7369 6964 6967 2874 2963 2029 0a7b +00002f0 2020 2020 2020 2020 2020 2020 6669 2820 +0000300 7221 7465 0a29 2020 2020 2020 2020 2020 +0000310 2020 2020 2020 6572 2074 203d 696c 656e +0000320 305b 2e2e 5d69 203b 2020 0a20 2020 2020 +0000330 2020 2020 207d 2020 0a20 2020 2020 2020 +0000340 2020 6c65 6573 6920 2066 7228 7465 0a29 +0000350 2020 2020 2020 2020 2020 2020 6572 2074 +0000360 3d7e 6320 203b 2020 0a20 2020 2020 207d +0000370 2020 0a20 2020 2020 6572 7574 6e72 7220 +0000380 7465 723f 7465 6c3a 6e69 3b65 7d0a 0a0a +0000390 6e75 7469 6574 7473 7b20 200a 2020 6120 +00003a0 7373 7265 2874 7320 7274 7069 6f4e 446e +00003b0 6769 7469 2228 7361 6664 2922 3d20 203d +00003c0 2222 2020 3b29 200a 2020 6120 7373 7265 +00003d0 2874 7320 7274 7069 6f4e 446e 6769 7469 +00003e0 2228 275c 3331 3d2d 2032 6b34 706f 2922 +00003f0 3d20 203d 2220 3331 3432 2022 2920 0a3b +0000400 0a7d 2f0a 2f2f 4320 6e6f 6576 7472 2073 +0000410 2061 6f77 6472 6920 746e 206f 2061 756e +0000420 626d 7265 202c 6769 6f6e 6972 676e 6120 +0000430 6c6c 6e20 6e6f 6120 706c 6168 6320 6168 +0000440 6172 7463 7265 2073 0a20 7473 6972 676e +0000450 7720 726f 5464 4e6f 6d75 2028 6e69 7320 +0000460 7274 6e69 2067 6f77 6472 2920 7b0a 2f0a +0000470 202f 7274 6e61 6c73 7461 6f69 206e 6174 +0000480 6c62 2065 6f66 2072 6874 2065 6174 6b73 +0000490 6120 2074 6168 646e 630a 6e6f 7473 6320 +00004a0 6168 5b72 3532 5d36 5420 4152 534e 414c +00004b0 4554 3d20 2020 2020 200a 2020 2220 2020 +00004c0 2020 2020 2020 2020 2020 2020 2020 2020 +00004d0 2020 2020 2020 2020 2020 2020 2020 2022 +00004e0 2f20 202f 2030 2020 200a 2020 2220 2020 +00004f0 2020 2020 2020 2020 2020 2020 2020 3130 +0000500 3332 3534 3736 3938 2020 2020 2020 2022 +0000510 2f20 202f 3233 2020 2020 0a20 2020 2020 +0000520 2022 3735 3336 3430 3939 3136 3837 3135 +0000530 3838 3231 3433 3637 3232 3933 2020 2020 +0000540 2220 2020 2f2f 3620 2034 2020 200a 2020 +0000550 2220 3520 3637 3033 3934 3639 3731 3538 +0000560 3831 3138 3332 3734 3236 3332 2039 2020 +0000570 2020 0a22 2020 2020 2022 2020 2020 2020 +0000580 2020 2020 2020 2020 2020 2020 2020 2020 +0000590 2020 2020 2020 2020 2220 200a 2020 2220 +00005a0 2020 2020 2020 2020 2020 2020 2020 2020 +* +00005c0 0a22 2020 2020 2022 2020 2020 2020 2020 +00005d0 2020 2020 2020 2020 2020 2020 2020 2020 +00005e0 2020 2020 2020 2220 2020 2020 200a 2020 +00005f0 2220 2020 2020 2020 2020 2020 2020 2020 +0000600 2020 2020 2020 2020 2020 2020 2020 2020 +0000610 2020 3b22 200a 2020 7320 7274 6e69 2067 +0000620 6572 3b74 200a 2020 6620 726f 6165 6863 +0000630 6328 203b 6163 7473 7528 7962 6574 5d5b +0000640 7729 726f 2964 200a 2020 2020 2020 6920 +0000650 2066 5428 4152 534e 414c 4554 635b 205d +0000660 3d21 2720 2720 0a29 2020 2020 2020 2020 +0000670 2020 2020 6572 2074 3d7e 5420 4152 534e +0000680 414c 4554 635b 3b5d 200a 2020 7220 7465 +0000690 7275 206e 6572 3b74 7d0a 0a0a 6e75 7469 +00006a0 6574 7473 7b20 200a 2f2f 5420 7365 2074 +00006b0 6f77 6472 6f54 754e 206d 7375 6e69 2067 +00006c0 6874 2065 6174 6c62 2065 7266 6d6f 7420 +00006d0 6568 7420 7361 206b 6564 6373 6972 7470 +00006e0 6f69 2e6e 200a 7361 6573 7472 2028 3022 +00006f0 3131 3231 3232 3333 3433 3534 3635 3636 +0000700 3737 3837 3838 3939 2239 3d20 0a3d 2020 +0000710 7720 726f 5464 4e6f 6d75 2228 2045 207c +0000720 204a 204e 2051 207c 2052 2057 2058 207c +0000730 2044 2053 2059 207c 2046 2054 207c 2041 +0000740 204d 207c 2043 2049 2056 207c 2042 204b +0000750 2055 207c 204c 204f 2050 207c 2047 2048 +0000760 225a 2929 0a3b 6120 7373 7265 2874 2220 +0000770 3130 3131 3232 3332 3333 3434 3535 3636 +0000780 3736 3737 3838 3938 3939 2022 3d3d 0a20 +0000790 2020 7720 726f 5464 4e6f 6d75 2228 2065 +00007a0 207c 206a 206e 2071 207c 2072 2077 2078 +00007b0 207c 2064 2073 2079 207c 2066 2074 207c +00007c0 2061 206d 207c 2063 2069 2076 207c 2062 +00007d0 206b 2075 207c 206c 206f 2070 207c 2067 +00007e0 2068 227a 2929 0a3b 6120 7373 7265 2874 +00007f0 2220 3130 3332 3534 3736 3938 2022 3d3d +0000800 0a20 2020 7720 726f 5464 4e6f 6d75 2228 +0000810 2030 207c 2020 2031 2020 207c 2020 2032 +0000820 2020 207c 2020 2033 2020 207c 3420 2020 +0000830 207c 3520 2020 207c 2020 2036 2020 207c +0000840 2020 2037 2020 207c 2020 2038 2020 207c +0000850 2020 2239 2929 0a3b 0a7d 760a 696f 2064 +0000860 616d 6e69 2028 7473 6972 676e 5d5b 6120 +0000870 6772 2073 0a29 0a7b 2020 2020 2f2f 5420 +0000880 6968 2073 7361 6f73 6963 7461 7669 2065 +0000890 7261 6172 2079 616d 7370 6120 6e20 6d75 +00008a0 6562 2072 6f74 6120 206e 7261 6172 2079 +00008b0 666f 7720 726f 7364 202e 2020 0a20 2020 +00008c0 2020 7473 6972 676e 7261 6172 5b79 7473 +00008d0 6972 676e 205d 2020 6e20 6d75 7732 726f +00008e0 7364 0a3b 200a 2020 6620 726f 6165 6863 +00008f0 7328 7274 6e69 2067 6f77 6472 203b 656e +0000900 2077 7542 6666 7265 6465 6946 656c 2228 +0000910 6964 7463 6f69 616e 7972 742e 7478 2022 +0000920 2029 0a29 2020 2020 2020 2020 756e 326d +0000930 6f77 6472 5b73 7720 726f 5464 4e6f 6d75 +0000940 7728 726f 2964 5d20 7e20 203d 6f77 6472 +0000950 642e 7075 203b 2020 2020 2020 2f20 202f +0000960 756d 7473 6420 7075 0a0a 2020 2020 2f2f +0000970 202f 6946 646e 2073 6c61 206c 6c61 6574 +0000980 6e72 7461 7669 7365 6620 726f 7420 6568 +0000990 6720 7669 6e65 6e20 6d75 6562 0a72 2020 +00009a0 2020 2f2f 202f 7328 6f68 6c75 2064 6168 +00009b0 6576 6220 6565 206e 7473 6972 7070 6465 +00009c0 6620 6f72 206d 6f6e 2d6e 6964 6967 2074 +00009d0 6863 7261 6361 6574 7372 0a29 2020 2020 +00009e0 7473 6972 676e 7261 6172 2079 465f 6e69 +00009f0 5764 726f 7364 2028 7473 6972 676e 6e20 +0000a00 6d75 6562 7372 202c 6f62 6c6f 6420 6769 +0000a10 7469 6b6f 2920 200a 2020 6920 206e 0a7b +0000a20 2020 2020 2020 2020 7361 6573 7472 6e28 +0000a30 6d75 6562 7372 6c2e 6e65 7467 2068 203e +0000a40 3020 3b29 2020 2020 200a 2020 7d20 2020 +0000a50 2020 200a 2020 6f20 7475 7228 7365 6c75 +0000a60 2974 7b20 200a 2020 2020 2020 6620 726f +0000a70 6165 6863 2820 3b61 7220 7365 6c75 2974 +0000a80 200a 2020 2020 2020 2020 2020 6120 7373 +0000a90 7265 2874 7720 726f 5464 4e6f 6d75 6128 +0000aa0 2029 3d3d 6e20 6d75 6562 7372 2920 0a3b +0000ab0 2020 2020 207d 2020 0a20 2020 2020 6f62 +0000ac0 7964 7b20 200a 2020 2020 2020 7320 7274 +0000ad0 6e69 6167 7272 7961 7220 7465 0a3b 2020 +0000ae0 2020 2020 2020 6f62 6c6f 6620 756f 646e +0000af0 6f77 6472 3d20 6620 6c61 6573 0a3b 2020 +0000b00 2020 2020 2020 6f66 2072 7528 6e69 2074 +0000b10 3d74 3b31 7420 3d3c 756e 626d 7265 2e73 +0000b20 656c 676e 6874 203b 2b2b 2974 7b20 200a +0000b30 2020 2020 2020 2020 2020 6120 7475 206f +0000b40 6c61 6574 6e72 7461 7669 7365 3d20 6e20 +0000b50 6d75 6562 7372 305b 2e2e 5d74 6920 206e +0000b60 756e 326d 6f77 6472 3b73 200a 2020 2020 +0000b70 2020 2020 2020 6920 2066 2128 6c61 6574 +0000b80 6e72 7461 7669 7365 0a29 2020 2020 2020 +0000b90 2020 2020 2020 2020 2020 6f63 746e 6e69 +0000ba0 6575 0a3b 2020 2020 2020 2020 2020 2020 +0000bb0 6f66 6e75 7764 726f 2064 203d 7274 6575 +0000bc0 0a3b 2020 2020 2020 2020 2020 2020 6669 +0000bd0 2820 756e 626d 7265 2e73 656c 676e 6874 +0000be0 3e20 2020 2974 7b20 200a 2020 2020 2020 +0000bf0 2020 2020 2020 2020 2f20 202f 6f43 626d +0000c00 6e69 2065 6c61 206c 7563 7272 6e65 2074 +0000c10 6c61 6574 6e72 7461 7669 7365 7720 7469 +0000c20 2068 6c61 206c 6c61 6574 6e72 7461 7669 +0000c30 7365 2020 2020 0a20 2020 2020 2020 2020 +0000c40 2020 2020 2020 2020 2f2f 6f20 2066 6874 +0000c50 2065 6572 7473 2820 656e 7478 7020 6569 +0000c60 6563 6320 6e61 7320 6174 7472 7720 7469 +0000c70 2068 2061 6964 6967 2974 2020 2020 2020 +0000c80 2020 2020 2020 2020 200a 2020 2020 2020 +0000c90 2020 2020 2020 2020 6620 726f 6165 6863 +0000ca0 2820 3261 203b 465f 6e69 5764 726f 7364 +0000cb0 2028 756e 626d 7265 5b73 2e74 242e 2c5d +0000cc0 7420 7572 2065 2020 2020 2029 0a29 2020 +0000cd0 2020 2020 2020 2020 2020 2020 2020 2020 +0000ce0 2020 6f66 6572 6361 2868 3161 203b 612a +0000cf0 746c 7265 616e 6974 6576 2973 200a 2020 +0000d00 2020 2020 2020 2020 2020 2020 2020 2020 +0000d10 2020 2020 6572 2074 3d7e 6120 2031 207e +0000d20 2022 2022 207e 3261 0a3b 2020 2020 2020 +0000d30 2020 2020 2020 0a7d 2020 2020 2020 2020 +0000d40 2020 2020 6c65 6573 2020 2020 200a 2020 +0000d50 2020 2020 2020 2020 2020 2020 7220 7465 +0000d60 7e20 203d 612a 746c 7265 616e 6974 6576 +0000d70 3b73 2020 2020 2f2f 6120 7070 6e65 2064 +0000d80 6874 7365 2065 6c61 6574 6e72 7461 7669 +0000d90 7365 200a 2020 2020 2020 7d20 200a 2020 +0000da0 2020 2020 2f20 202f 7254 2079 6f74 6b20 +0000db0 6565 2070 2031 6964 6967 2c74 6f20 6c6e +0000dc0 2079 6669 7720 2765 6572 6120 6c6c 776f +0000dd0 6465 6120 646e 6e20 206f 746f 6568 0a72 +0000de0 2020 2020 2020 2020 2f2f 6120 746c 7265 +0000df0 616e 6974 6576 2073 6577 6572 6620 756f +0000e00 646e 200a 2020 2020 2020 2f20 202f 6554 +0000e10 7473 6e69 2067 7222 7465 6c2e 6e65 7467 +0000e20 2268 6d20 6b61 7365 6d20 726f 2065 6573 +0000e30 736e 2065 6874 6e61 7420 7365 6974 676e +0000e40 2220 6f66 6e75 7764 726f 2264 0a2c 2020 +0000e50 2020 2020 2020 2f2f 6220 7475 7420 6568 +0000e60 6f20 6874 7265 6920 706d 656c 656d 746e +0000e70 7461 6f69 736e 7320 6565 206d 6f74 6420 +0000e80 206f 756a 7473 7420 6968 2e73 200a 2020 +0000e90 2020 2020 6920 2066 6428 6769 7469 6b6f +0000ea0 2620 2026 6621 756f 646e 6f77 6472 2029 +0000eb0 207b 2f2f 6572 2e74 656c 676e 6874 3d20 +0000ec0 203d 2030 0a20 2020 2020 2020 2020 2020 +0000ed0 2020 6669 6e28 6d75 6562 7372 6c2e 6e65 +0000ee0 7467 2068 203e 3120 2029 0a7b 2020 2020 +0000ef0 2020 2020 2020 2020 2020 2020 2f2f 4320 +0000f00 6d6f 6962 656e 3120 6420 6769 7469 7720 +0000f10 7469 2068 6c61 206c 6c61 6574 616e 6974 +0000f20 6576 2073 7266 6d6f 7420 6568 7220 7365 +0000f30 2074 2020 0a20 2020 2020 2020 2020 2020 +0000f40 2020 2020 2020 2f2f 2820 656e 7478 7020 +0000f50 6569 6563 6320 6e61 6e20 746f 7320 6174 +0000f60 7472 7720 7469 2068 2061 6964 6967 2974 +0000f70 2020 2020 2020 2020 2020 200a 2020 2020 +0000f80 2020 2020 2020 2020 2020 6620 726f 6165 +0000f90 6863 2820 3b61 5f20 6946 646e 6f57 6472 +0000fa0 2873 6e20 6d75 6562 7372 315b 2e2e 5d24 +0000fb0 202c 6166 736c 2065 2029 0a29 2020 2020 +0000fc0 2020 2020 2020 2020 2020 2020 2020 2020 +0000fd0 6572 2074 3d7e 6e20 6d75 6562 7372 305b +0000fe0 2e2e 5d31 7e20 2220 2220 7e20 6120 0a3b +0000ff0 2020 2020 2020 2020 2020 2020 207d 2020 +0001000 0a20 2020 2020 2020 2020 2020 2020 6c65 +0001010 6573 2020 2020 200a 2020 2020 2020 2020 +0001020 2020 2020 2020 7220 7465 7e20 203d 756e +0001030 626d 7265 5b73 2e30 312e 3b5d 2020 2020 +0001040 2f2f 6a20 7375 2074 7061 6570 646e 7420 +0001050 6968 2073 6964 6967 2074 2020 2020 2020 +0001060 2020 2020 2020 200a 2020 2020 2020 7d20 +0001070 2020 2020 200a 2020 2020 2020 7220 7465 +0001080 7275 206e 6572 3b74 200a 2020 7d20 0a0a +0001090 2020 2020 2f2f 202f 5428 6968 2073 7566 +00010a0 636e 6974 6e6f 7720 7361 6920 6c6e 6e69 +00010b0 6465 6920 206e 6874 2065 726f 6769 6e69 +00010c0 6c61 7020 6f72 7267 6d61 2029 200a 2020 +00010d0 2f20 2f2f 4620 6e69 7364 6120 6c6c 6120 +00010e0 746c 7265 616e 6974 6576 2073 6f66 2072 +00010f0 6874 2065 6967 6576 206e 6870 6e6f 2065 +0001100 756e 626d 7265 0a20 2020 2020 2f2f 202f +0001110 6552 7574 6e72 3a73 6120 7272 7961 6f20 +0001120 2066 7473 6972 676e 2073 200a 2020 7320 +0001130 7274 6e69 6167 7272 7961 4620 6e69 5764 +0001140 726f 7364 2028 7473 6972 676e 7020 6f68 +0001150 656e 6e5f 6d75 6562 2072 0a29 2020 2020 +0001160 0a7b 2020 2020 2020 2020 6669 2820 7021 +0001170 6f68 656e 6e5f 6d75 6562 2e72 656c 676e +0001180 6874 0a29 2020 2020 2020 2020 2020 2020 +0001190 6572 7574 6e72 6e20 6c75 3b6c 200a 2020 +00011a0 2020 2020 2f20 202f 7453 6972 2070 6874 +00011b0 2065 6f6e 2d6e 6964 6967 2074 6863 7261 +00011c0 6361 6574 7372 6620 6f72 206d 6874 2065 +00011d0 6870 6e6f 2065 756e 626d 7265 202c 6e61 +00011e0 0a64 2020 2020 2020 2020 2f2f 7020 7361 +00011f0 2073 7469 7420 206f 6874 2065 6572 7563 +0001200 7372 7669 2065 7566 636e 6974 6e6f 2820 +0001210 656c 6461 6e69 2067 6964 6967 2074 7369 +0001220 6120 6c6c 776f 6465 0a29 2020 2020 2020 +0001230 2020 6572 7574 6e72 5f20 6946 646e 6f57 +0001240 6472 2873 7320 7274 7069 6f4e 446e 6769 +0001250 7469 7028 6f68 656e 6e5f 6d75 6562 2972 +0001260 202c 7274 6575 2920 203b 2020 0a20 2020 +0001270 2020 207d 2020 0a20 2020 2020 200a 2020 +0001280 2f20 202f 6552 6461 7420 6568 7020 6f68 +0001290 656e 6e20 6d75 6562 7372 2020 2020 0a20 +00012a0 2020 2020 6f66 6572 6361 2868 7473 6972 +00012b0 676e 7020 6f68 656e 203b 656e 2077 7542 +00012c0 6666 7265 6465 6946 656c 2228 6e69 7570 +00012d0 2e74 7874 2274 2020 2920 2920 200a 2020 +00012e0 2020 2020 6620 726f 6165 6863 6128 746c +00012f0 7265 616e 6974 6576 203b 6946 646e 6f57 +0001300 6472 2873 7020 6f68 656e 2920 2920 200a +0001310 2020 2020 2020 2020 2020 7720 6972 6574 +0001320 6c66 286e 6870 6e6f 2c65 2220 203a 2c22 +0001330 6120 746c 7265 616e 6974 6576 2920 0a3b +0001340 0a7d 000a +0001343 diff --git a/tests/examplefiles/hexdump_od b/tests/examplefiles/hexdump_od new file mode 100644 index 00000000..a407aef0 --- /dev/null +++ b/tests/examplefiles/hexdump_od @@ -0,0 +1,310 @@ +0000000 2f 2f 20 43 72 65 61 74 65 64 20 62 79 20 4c 69 >// Created by Li< +0000020 6f 6e 65 6c 6c 6f 20 4c 75 6e 65 73 75 20 61 6e >onello Lunesu an< +0000040 64 20 70 6c 61 63 65 64 20 69 6e 20 74 68 65 20 >d placed in the < +0000060 70 75 62 6c 69 63 20 64 6f 6d 61 69 6e 2e 0a 2f >public domain../< +0000100 2f 20 54 68 69 73 20 66 69 6c 65 20 68 61 73 20 >/ This file has < +0000120 62 65 65 6e 20 6d 6f 64 69 66 69 65 64 20 66 72 >been modified fr< +0000140 6f 6d 20 69 74 73 20 6f 72 69 67 69 6e 61 6c 20 >om its original < +0000160 76 65 72 73 69 6f 6e 2e 0a 2f 2f 20 49 74 20 68 >version..// It h< +0000200 61 73 20 62 65 65 6e 20 66 6f 72 6d 61 74 74 65 >as been formatte< +0000220 64 20 74 6f 20 66 69 74 20 79 6f 75 72 20 73 63 >d to fit your sc< +0000240 72 65 65 6e 2e 0a 6d 6f 64 75 6c 65 20 70 68 6f >reen..module pho< +0000260 6e 65 6e 6f 3b 20 20 20 20 20 2f 2f 20 6f 70 74 >neno; // opt< +0000300 69 6f 6e 61 6c 0a 69 6d 70 6f 72 74 20 73 74 64 >ional.import std< +0000320 2e 73 74 64 69 6f 3b 20 20 20 2f 2f 20 77 72 69 >.stdio; // wri< +0000340 74 65 66 6c 6e 20 20 20 20 20 0a 69 6d 70 6f 72 >tefln .impor< +0000360 74 20 73 74 64 2e 63 74 79 70 65 3b 20 20 20 2f >t std.ctype; /< +0000400 2f 20 69 73 64 69 67 69 74 20 20 20 20 20 0a 69 >/ isdigit .i< +0000420 6d 70 6f 72 74 20 73 74 64 2e 73 74 72 65 61 6d >mport std.stream< +0000440 3b 20 20 2f 2f 20 42 75 66 66 65 72 65 64 46 69 >; // BufferedFi< +0000460 6c 65 0a 0a 2f 2f 20 4a 75 73 74 20 66 6f 72 20 >le..// Just for < +0000500 72 65 61 64 61 62 69 6c 69 74 79 20 28 69 6d 61 >readability (ima< +0000520 67 69 6e 65 20 63 68 61 72 5b 5d 5b 5d 5b 63 68 >gine char[][][ch< +0000540 61 72 5b 5d 5d 29 20 20 20 20 0a 61 6c 69 61 73 >ar[]]) .alias< +0000560 20 63 68 61 72 5b 5d 20 73 74 72 69 6e 67 3b 0a > char[] string;.< +0000600 61 6c 69 61 73 20 73 74 72 69 6e 67 5b 5d 20 73 >alias string[] s< +0000620 74 72 69 6e 67 61 72 72 61 79 3b 0a 0a 2f 2f 2f >tringarray;..///< +0000640 20 53 74 72 69 70 73 20 6e 6f 6e 2d 64 69 67 69 > Strips non-digi< +0000660 74 20 63 68 61 72 61 63 74 65 72 73 20 66 72 6f >t characters fro< +0000700 6d 20 74 68 65 20 73 74 72 69 6e 67 20 28 43 4f >m the string (CO< +0000720 57 29 0a 73 74 72 69 6e 67 20 73 74 72 69 70 4e >W).string stripN< +0000740 6f 6e 44 69 67 69 74 28 20 69 6e 20 73 74 72 69 >onDigit( in stri< +0000760 6e 67 20 6c 69 6e 65 20 29 20 0a 7b 0a 20 20 20 >ng line ) .{. < +0001000 20 73 74 72 69 6e 67 20 72 65 74 3b 0a 20 20 20 > string ret;. < +0001020 20 66 6f 72 65 61 63 68 28 75 69 6e 74 20 69 2c > foreach(uint i,< +0001040 20 63 3b 20 6c 69 6e 65 29 20 7b 0a 20 20 20 20 > c; line) {. < +0001060 20 20 20 20 2f 2f 20 45 72 72 6f 72 3a 20 73 74 > // Error: st< +0001100 64 2e 63 74 79 70 65 2e 69 73 64 69 67 69 74 20 >d.ctype.isdigit < +0001120 61 74 20 43 3a 5c 64 6d 64 5c 73 72 63 5c 70 68 >at C:\dmd\src\ph< +0001140 6f 62 6f 73 5c 73 74 64 5c 63 74 79 70 65 2e 64 >obos\std\ctype.d< +0001160 28 33 37 29 20 0a 20 20 20 20 20 20 20 20 2f 2f >(37) . //< +0001200 20 63 6f 6e 66 6c 69 63 74 73 20 77 69 74 68 20 > conflicts with < +0001220 73 74 64 2e 73 74 72 65 61 6d 2e 69 73 64 69 67 >std.stream.isdig< +0001240 69 74 20 61 74 20 43 3a 5c 64 6d 64 5c 73 72 63 >it at C:\dmd\src< +0001260 5c 70 68 6f 62 6f 73 5c 73 74 64 5c 73 74 72 65 >\phobos\std\stre< +0001300 61 6d 2e 64 28 32 39 32 34 29 0a 20 20 20 20 20 >am.d(2924). < +0001320 20 20 20 69 66 20 28 21 73 74 64 2e 63 74 79 70 > if (!std.ctyp< +0001340 65 2e 69 73 64 69 67 69 74 28 63 29 29 20 7b 0a >e.isdigit(c)) {.< +0001360 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 > if (< +0001400 21 72 65 74 29 0a 20 20 20 20 20 20 20 20 20 20 >!ret). < +0001420 20 20 20 20 20 20 72 65 74 20 3d 20 6c 69 6e 65 > ret = line< +0001440 5b 30 2e 2e 69 5d 3b 20 20 20 20 0a 20 20 20 20 >[0..i]; . < +0001460 20 20 20 20 7d 20 20 20 20 0a 20 20 20 20 20 20 > } . < +0001500 20 20 65 6c 73 65 20 69 66 20 28 72 65 74 29 0a > else if (ret).< +0001520 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 20 > ret < +0001540 7e 3d 20 63 3b 20 20 20 20 0a 20 20 20 20 7d 20 >~= c; . } < +0001560 20 20 20 0a 20 20 20 20 72 65 74 75 72 6e 20 72 > . return r< +0001600 65 74 3f 72 65 74 3a 6c 69 6e 65 3b 0a 7d 0a 0a >et?ret:line;.}..< +0001620 75 6e 69 74 74 65 73 74 20 7b 0a 20 20 20 20 61 >unittest {. a< +0001640 73 73 65 72 74 28 20 73 74 72 69 70 4e 6f 6e 44 >ssert( stripNonD< +0001660 69 67 69 74 28 22 61 73 64 66 22 29 20 3d 3d 20 >igit("asdf") == < +0001700 22 22 20 20 29 3b 0a 20 20 20 20 61 73 73 65 72 >"" );. asser< +0001720 74 28 20 73 74 72 69 70 4e 6f 6e 44 69 67 69 74 >t( stripNonDigit< +0001740 28 22 5c 27 31 33 2d 3d 32 20 34 6b 6f 70 22 29 >("\'13-=2 4kop")< +0001760 20 3d 3d 20 20 22 31 33 32 34 22 20 20 29 3b 0a > == "1324" );.< +0002000 7d 0a 0a 2f 2f 2f 20 43 6f 6e 76 65 72 74 73 20 >}../// Converts < +0002020 61 20 77 6f 72 64 20 69 6e 74 6f 20 61 20 6e 75 >a word into a nu< +0002040 6d 62 65 72 2c 20 69 67 6e 6f 72 69 6e 67 20 61 >mber, ignoring a< +0002060 6c 6c 20 6e 6f 6e 20 61 6c 70 68 61 20 63 68 61 >ll non alpha cha< +0002100 72 61 63 74 65 72 73 20 20 0a 73 74 72 69 6e 67 >racters .string< +0002120 20 77 6f 72 64 54 6f 4e 75 6d 28 20 69 6e 20 73 > wordToNum( in s< +0002140 74 72 69 6e 67 20 77 6f 72 64 20 29 0a 7b 0a 2f >tring word ).{./< +0002160 2f 20 74 72 61 6e 73 6c 61 74 69 6f 6e 20 74 61 >/ translation ta< +0002200 62 6c 65 20 66 6f 72 20 74 68 65 20 74 61 73 6b >ble for the task< +0002220 20 61 74 20 68 61 6e 64 0a 63 6f 6e 73 74 20 63 > at hand.const c< +0002240 68 61 72 5b 32 35 36 5d 20 54 52 41 4e 53 4c 41 >har[256] TRANSLA< +0002260 54 45 20 3d 20 20 20 20 0a 20 20 20 20 22 20 20 >TE = . " < +0002300 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 > < +0002320 20 20 20 20 20 20 20 20 20 20 20 20 20 20 22 20 > " < +0002340 20 2f 2f 20 30 20 20 20 0a 20 20 20 20 22 20 20 > // 0 . " < +0002360 20 20 20 20 20 20 20 20 20 20 20 20 20 20 30 31 > 01< +0002400 32 33 34 35 36 37 38 39 20 20 20 20 20 20 22 20 >23456789 " < +0002420 20 2f 2f 20 33 32 20 20 20 20 20 0a 20 20 20 20 > // 32 . < +0002440 22 20 35 37 36 33 30 34 39 39 36 31 37 38 35 31 >" 57630499617851< +0002460 38 38 31 32 33 34 37 36 32 32 33 39 20 20 20 20 >881234762239 < +0002500 20 22 20 20 2f 2f 20 36 34 20 20 20 0a 20 20 20 > " // 64 . < +0002520 20 22 20 35 37 36 33 30 34 39 39 36 31 37 38 35 > " 5763049961785< +0002540 31 38 38 31 32 33 34 37 36 32 32 33 39 20 20 20 >1881234762239 < +0002560 20 20 22 0a 20 20 20 20 22 20 20 20 20 20 20 20 > ". " < +0002600 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 > < +0002620 20 20 20 20 20 20 20 20 20 22 0a 20 20 20 20 22 > ". "< +0002640 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 > < +* +0002700 22 0a 20 20 20 20 22 20 20 20 20 20 20 20 20 20 >". " < +0002720 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 > < +0002740 20 20 20 20 20 20 20 22 20 20 20 20 0a 20 20 20 > " . < +0002760 20 22 20 20 20 20 20 20 20 20 20 20 20 20 20 20 > " < +0003000 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 > < +0003020 20 20 22 3b 0a 20 20 20 20 73 74 72 69 6e 67 20 > ";. string < +0003040 72 65 74 3b 0a 20 20 20 20 66 6f 72 65 61 63 68 >ret;. foreach< +0003060 28 63 3b 20 63 61 73 74 28 75 62 79 74 65 5b 5d >(c; cast(ubyte[]< +0003100 29 77 6f 72 64 29 0a 20 20 20 20 20 20 20 20 69 >)word). i< +0003120 66 20 28 54 52 41 4e 53 4c 41 54 45 5b 63 5d 20 >f (TRANSLATE[c] < +0003140 21 3d 20 27 20 27 29 0a 20 20 20 20 20 20 20 20 >!= ' '). < +0003160 20 20 20 20 72 65 74 20 7e 3d 20 54 52 41 4e 53 > ret ~= TRANS< +0003200 4c 41 54 45 5b 63 5d 3b 0a 20 20 20 20 72 65 74 >LATE[c];. ret< +0003220 75 72 6e 20 72 65 74 3b 0a 7d 0a 0a 75 6e 69 74 >urn ret;.}..unit< +0003240 74 65 73 74 20 7b 0a 20 2f 2f 20 54 65 73 74 20 >test {. // Test < +0003260 77 6f 72 64 54 6f 4e 75 6d 20 75 73 69 6e 67 20 >wordToNum using < +0003300 74 68 65 20 74 61 62 6c 65 20 66 72 6f 6d 20 74 >the table from t< +0003320 68 65 20 74 61 73 6b 20 64 65 73 63 72 69 70 74 >he task descript< +0003340 69 6f 6e 2e 0a 20 61 73 73 65 72 74 28 20 22 30 >ion.. assert( "0< +0003360 31 31 31 32 32 32 33 33 33 34 34 35 35 36 36 36 >1112223334455666< +0003400 37 37 37 38 38 38 39 39 39 22 20 3d 3d 0a 20 20 >777888999" ==. < +0003420 20 77 6f 72 64 54 6f 4e 75 6d 28 22 45 20 7c 20 > wordToNum("E | < +0003440 4a 20 4e 20 51 20 7c 20 52 20 57 20 58 20 7c 20 >J N Q | R W X | < +0003460 44 20 53 20 59 20 7c 20 46 20 54 20 7c 20 41 20 >D S Y | F T | A < +0003500 4d 20 7c 20 43 20 49 20 56 20 7c 20 42 20 4b 20 >M | C I V | B K < +0003520 55 20 7c 20 4c 20 4f 20 50 20 7c 20 47 20 48 20 >U | L O P | G H < +0003540 5a 22 29 29 3b 0a 20 61 73 73 65 72 74 28 20 22 >Z"));. assert( "< +0003560 30 31 31 31 32 32 32 33 33 33 34 34 35 35 36 36 >0111222333445566< +0003600 36 37 37 37 38 38 38 39 39 39 22 20 3d 3d 20 0a >6777888999" == .< +0003620 20 20 20 77 6f 72 64 54 6f 4e 75 6d 28 22 65 20 > wordToNum("e < +0003640 7c 20 6a 20 6e 20 71 20 7c 20 72 20 77 20 78 20 >| j n q | r w x < +0003660 7c 20 64 20 73 20 79 20 7c 20 66 20 74 20 7c 20 >| d s y | f t | < +0003700 61 20 6d 20 7c 20 63 20 69 20 76 20 7c 20 62 20 >a m | c i v | b < +0003720 6b 20 75 20 7c 20 6c 20 6f 20 70 20 7c 20 67 20 >k u | l o p | g < +0003740 68 20 7a 22 29 29 3b 0a 20 61 73 73 65 72 74 28 >h z"));. assert(< +0003760 20 22 30 31 32 33 34 35 36 37 38 39 22 20 3d 3d > "0123456789" ==< +0004000 20 0a 20 20 20 77 6f 72 64 54 6f 4e 75 6d 28 22 > . wordToNum("< +0004020 30 20 7c 20 20 20 31 20 20 20 7c 20 20 20 32 20 >0 | 1 | 2 < +0004040 20 20 7c 20 20 20 33 20 20 20 7c 20 20 34 20 20 > | 3 | 4 < +0004060 7c 20 20 35 20 20 7c 20 20 20 36 20 20 20 7c 20 >| 5 | 6 | < +0004100 20 20 37 20 20 20 7c 20 20 20 38 20 20 20 7c 20 > 7 | 8 | < +0004120 20 20 39 22 29 29 3b 0a 7d 0a 0a 76 6f 69 64 20 > 9"));.}..void < +0004140 6d 61 69 6e 28 20 73 74 72 69 6e 67 5b 5d 20 61 >main( string[] a< +0004160 72 67 73 20 29 0a 7b 0a 20 20 20 20 2f 2f 20 54 >rgs ).{. // T< +0004200 68 69 73 20 61 73 73 6f 63 69 61 74 69 76 65 20 >his associative < +0004220 61 72 72 61 79 20 6d 61 70 73 20 61 20 6e 75 6d >array maps a num< +0004240 62 65 72 20 74 6f 20 61 6e 20 61 72 72 61 79 20 >ber to an array < +0004260 6f 66 20 77 6f 72 64 73 2e 20 20 20 20 0a 20 20 >of words. . < +0004300 20 20 73 74 72 69 6e 67 61 72 72 61 79 5b 73 74 > stringarray[st< +0004320 72 69 6e 67 5d 20 20 20 20 6e 75 6d 32 77 6f 72 >ring] num2wor< +0004340 64 73 3b 0a 0a 20 20 20 20 66 6f 72 65 61 63 68 >ds;.. foreach< +0004360 28 73 74 72 69 6e 67 20 77 6f 72 64 3b 20 6e 65 >(string word; ne< +0004400 77 20 42 75 66 66 65 72 65 64 46 69 6c 65 28 22 >w BufferedFile("< +0004420 64 69 63 74 69 6f 6e 61 72 79 2e 74 78 74 22 20 >dictionary.txt" < +0004440 29 20 29 0a 20 20 20 20 20 20 20 20 6e 75 6d 32 >) ). num2< +0004460 77 6f 72 64 73 5b 20 77 6f 72 64 54 6f 4e 75 6d >words[ wordToNum< +0004500 28 77 6f 72 64 29 20 5d 20 7e 3d 20 77 6f 72 64 >(word) ] ~= word< +0004520 2e 64 75 70 3b 20 20 20 20 20 20 20 20 2f 2f 20 >.dup; // < +0004540 6d 75 73 74 20 64 75 70 0a 0a 20 20 20 20 2f 2f >must dup.. //< +0004560 2f 20 46 69 6e 64 73 20 61 6c 6c 20 61 6c 74 65 >/ Finds all alte< +0004600 72 6e 61 74 69 76 65 73 20 66 6f 72 20 74 68 65 >rnatives for the< +0004620 20 67 69 76 65 6e 20 6e 75 6d 62 65 72 0a 20 20 > given number. < +0004640 20 20 2f 2f 2f 20 28 73 68 6f 75 6c 64 20 68 61 > /// (should ha< +0004660 76 65 20 62 65 65 6e 20 73 74 72 69 70 70 65 64 >ve been stripped< +0004700 20 66 72 6f 6d 20 6e 6f 6e 2d 64 69 67 69 74 20 > from non-digit < +0004720 63 68 61 72 61 63 74 65 72 73 29 0a 20 20 20 20 >characters). < +0004740 73 74 72 69 6e 67 61 72 72 61 79 20 5f 46 69 6e >stringarray _Fin< +0004760 64 57 6f 72 64 73 28 20 73 74 72 69 6e 67 20 6e >dWords( string n< +0005000 75 6d 62 65 72 73 2c 20 62 6f 6f 6c 20 64 69 67 >umbers, bool dig< +0005020 69 74 6f 6b 20 29 0a 20 20 20 20 69 6e 20 7b 0a >itok ). in {.< +0005040 20 20 20 20 20 20 20 20 61 73 73 65 72 74 28 6e > assert(n< +0005060 75 6d 62 65 72 73 2e 6c 65 6e 67 74 68 20 3e 20 >umbers.length > < +0005100 20 30 29 3b 20 20 20 20 0a 20 20 20 20 7d 20 20 > 0); . } < +0005120 20 20 0a 20 20 20 20 6f 75 74 28 72 65 73 75 6c > . out(resul< +0005140 74 29 20 7b 0a 20 20 20 20 20 20 20 20 66 6f 72 >t) {. for< +0005160 65 61 63 68 20 28 61 3b 20 72 65 73 75 6c 74 29 >each (a; result)< +0005200 0a 20 20 20 20 20 20 20 20 20 20 20 20 61 73 73 >. ass< +0005220 65 72 74 28 20 77 6f 72 64 54 6f 4e 75 6d 28 61 >ert( wordToNum(a< +0005240 29 20 3d 3d 20 6e 75 6d 62 65 72 73 20 29 3b 0a >) == numbers );.< +0005260 20 20 20 20 7d 20 20 20 20 0a 20 20 20 20 62 6f > } . bo< +0005300 64 79 20 7b 0a 20 20 20 20 20 20 20 20 73 74 72 >dy {. str< +0005320 69 6e 67 61 72 72 61 79 20 72 65 74 3b 0a 20 20 >ingarray ret;. < +0005340 20 20 20 20 20 20 62 6f 6f 6c 20 66 6f 75 6e 64 > bool found< +0005360 77 6f 72 64 20 3d 20 66 61 6c 73 65 3b 0a 20 20 >word = false;. < +0005400 20 20 20 20 20 20 66 6f 72 20 28 75 69 6e 74 20 > for (uint < +0005420 74 3d 31 3b 20 74 3c 3d 6e 75 6d 62 65 72 73 2e >t=1; t<=numbers.< +0005440 6c 65 6e 67 74 68 3b 20 2b 2b 74 29 20 7b 0a 20 >length; ++t) {. < +0005460 20 20 20 20 20 20 20 20 20 20 20 61 75 74 6f 20 > auto < +0005500 61 6c 74 65 72 6e 61 74 69 76 65 73 20 3d 20 6e >alternatives = n< +0005520 75 6d 62 65 72 73 5b 30 2e 2e 74 5d 20 69 6e 20 >umbers[0..t] in < +0005540 6e 75 6d 32 77 6f 72 64 73 3b 0a 20 20 20 20 20 >num2words;. < +0005560 20 20 20 20 20 20 20 69 66 20 28 21 61 6c 74 65 > if (!alte< +0005600 72 6e 61 74 69 76 65 73 29 0a 20 20 20 20 20 20 >rnatives). < +0005620 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e > contin< +0005640 75 65 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 >ue;. < +0005660 66 6f 75 6e 64 77 6f 72 64 20 3d 20 74 72 75 65 >foundword = true< +0005700 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 >;. if< +0005720 20 28 6e 75 6d 62 65 72 73 2e 6c 65 6e 67 74 68 > (numbers.length< +0005740 20 3e 20 20 74 29 20 7b 0a 20 20 20 20 20 20 20 > > t) {. < +0005760 20 20 20 20 20 20 20 20 20 2f 2f 20 43 6f 6d 62 > // Comb< +0006000 69 6e 65 20 61 6c 6c 20 63 75 72 72 65 6e 74 20 >ine all current < +0006020 61 6c 74 65 72 6e 61 74 69 76 65 73 20 77 69 74 >alternatives wit< +0006040 68 20 61 6c 6c 20 61 6c 74 65 72 6e 61 74 69 76 >h all alternativ< +0006060 65 73 20 20 20 20 20 0a 20 20 20 20 20 20 20 20 >es . < +0006100 20 20 20 20 20 20 20 20 2f 2f 20 6f 66 20 74 68 > // of th< +0006120 65 20 72 65 73 74 20 28 6e 65 78 74 20 70 69 65 >e rest (next pie< +0006140 63 65 20 63 61 6e 20 73 74 61 72 74 20 77 69 74 >ce can start wit< +0006160 68 20 61 20 64 69 67 69 74 29 20 20 20 20 20 20 >h a digit) < +0006200 20 20 20 20 20 20 20 20 0a 20 20 20 20 20 20 20 > . < +0006220 20 20 20 20 20 20 20 20 20 66 6f 72 65 61 63 68 > foreach< +0006240 20 28 61 32 3b 20 5f 46 69 6e 64 57 6f 72 64 73 > (a2; _FindWords< +0006260 28 20 6e 75 6d 62 65 72 73 5b 74 2e 2e 24 5d 2c >( numbers[t..$],< +0006300 20 74 72 75 65 20 20 20 20 20 29 20 29 0a 20 20 > true ) ). < +0006320 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 > < +0006340 20 20 66 6f 72 65 61 63 68 28 61 31 3b 20 2a 61 > foreach(a1; *a< +0006360 6c 74 65 72 6e 61 74 69 76 65 73 29 0a 20 20 20 >lternatives). < +0006400 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 > < +0006420 20 20 20 20 72 65 74 20 7e 3d 20 61 31 20 7e 20 > ret ~= a1 ~ < +0006440 22 20 22 20 7e 20 61 32 3b 0a 20 20 20 20 20 20 >" " ~ a2;. < +0006460 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 20 20 > }. < +0006500 20 20 20 20 65 6c 73 65 20 20 20 20 0a 20 20 20 > else . < +0006520 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 > ret< +0006540 20 7e 3d 20 2a 61 6c 74 65 72 6e 61 74 69 76 65 > ~= *alternative< +0006560 73 3b 20 20 20 20 2f 2f 20 61 70 70 65 6e 64 20 >s; // append < +0006600 74 68 65 73 65 20 61 6c 74 65 72 6e 61 74 69 76 >these alternativ< +0006620 65 73 0a 20 20 20 20 20 20 20 20 7d 0a 20 20 20 >es. }. < +0006640 20 20 20 20 20 2f 2f 20 54 72 79 20 74 6f 20 6b > // Try to k< +0006660 65 65 70 20 31 20 64 69 67 69 74 2c 20 6f 6e 6c >eep 1 digit, onl< +0006700 79 20 69 66 20 77 65 27 72 65 20 61 6c 6c 6f 77 >y if we're allow< +0006720 65 64 20 61 6e 64 20 6e 6f 20 6f 74 68 65 72 0a >ed and no other.< +0006740 20 20 20 20 20 20 20 20 2f 2f 20 61 6c 74 65 72 > // alter< +0006760 6e 61 74 69 76 65 73 20 77 65 72 65 20 66 6f 75 >natives were fou< +0007000 6e 64 0a 20 20 20 20 20 20 20 20 2f 2f 20 54 65 >nd. // Te< +0007020 73 74 69 6e 67 20 22 72 65 74 2e 6c 65 6e 67 74 >sting "ret.lengt< +0007040 68 22 20 6d 61 6b 65 73 20 6d 6f 72 65 20 73 65 >h" makes more se< +0007060 6e 73 65 20 74 68 61 6e 20 74 65 73 74 69 6e 67 >nse than testing< +0007100 20 22 66 6f 75 6e 64 77 6f 72 64 22 2c 0a 20 20 > "foundword",. < +0007120 20 20 20 20 20 20 2f 2f 20 62 75 74 20 74 68 65 > // but the< +0007140 20 6f 74 68 65 72 20 69 6d 70 6c 65 6d 65 6e 74 > other implement< +0007160 61 74 69 6f 6e 73 20 73 65 65 6d 20 74 6f 20 64 >ations seem to d< +0007200 6f 20 6a 75 73 74 20 74 68 69 73 2e 0a 20 20 20 >o just this.. < +0007220 20 20 20 20 20 69 66 20 28 64 69 67 69 74 6f 6b > if (digitok< +0007240 20 26 26 20 21 66 6f 75 6e 64 77 6f 72 64 29 20 > && !foundword) < +0007260 7b 20 2f 2f 72 65 74 2e 6c 65 6e 67 74 68 20 3d >{ //ret.length =< +0007300 3d 20 30 20 20 0a 20 20 20 20 20 20 20 20 20 20 >= 0 . < +0007320 20 20 69 66 28 6e 75 6d 62 65 72 73 2e 6c 65 6e > if(numbers.len< +0007340 67 74 68 20 3e 20 20 31 29 20 7b 0a 20 20 20 20 >gth > 1) {. < +0007360 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 43 > // C< +0007400 6f 6d 62 69 6e 65 20 31 20 64 69 67 69 74 20 77 >ombine 1 digit w< +0007420 69 74 68 20 61 6c 6c 20 61 6c 74 65 6e 61 74 69 >ith all altenati< +0007440 76 65 73 20 66 72 6f 6d 20 74 68 65 20 72 65 73 >ves from the res< +0007460 74 20 20 20 20 0a 20 20 20 20 20 20 20 20 20 20 >t . < +0007500 20 20 20 20 20 20 2f 2f 20 28 6e 65 78 74 20 70 > // (next p< +0007520 69 65 63 65 20 63 61 6e 20 6e 6f 74 20 73 74 61 >iece can not sta< +0007540 72 74 20 77 69 74 68 20 61 20 64 69 67 69 74 29 >rt with a digit)< +0007560 20 20 20 20 20 20 20 20 20 20 0a 20 20 20 20 20 > . < +0007600 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 65 61 > forea< +0007620 63 68 20 28 61 3b 20 5f 46 69 6e 64 57 6f 72 64 >ch (a; _FindWord< +0007640 73 28 20 6e 75 6d 62 65 72 73 5b 31 2e 2e 24 5d >s( numbers[1..$]< +0007660 2c 20 66 61 6c 73 65 20 29 20 29 0a 20 20 20 20 >, false ) ). < +0007700 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 > < +0007720 72 65 74 20 7e 3d 20 6e 75 6d 62 65 72 73 5b 30 >ret ~= numbers[0< +0007740 2e 2e 31 5d 20 7e 20 22 20 22 20 7e 20 61 3b 0a >..1] ~ " " ~ a;.< +0007760 20 20 20 20 20 20 20 20 20 20 20 20 7d 20 20 20 > } < +0010000 20 0a 20 20 20 20 20 20 20 20 20 20 20 20 65 6c > . el< +0010020 73 65 20 20 20 20 0a 20 20 20 20 20 20 20 20 20 >se . < +0010040 20 20 20 20 20 20 20 72 65 74 20 7e 3d 20 6e 75 > ret ~= nu< +0010060 6d 62 65 72 73 5b 30 2e 2e 31 5d 3b 20 20 20 20 >mbers[0..1]; < +0010100 2f 2f 20 6a 75 73 74 20 61 70 70 65 6e 64 20 74 >// just append t< +0010120 68 69 73 20 64 69 67 69 74 20 20 20 20 20 20 20 >his digit < +0010140 20 20 20 20 20 20 0a 20 20 20 20 20 20 20 20 7d > . }< +0010160 20 20 20 20 0a 20 20 20 20 20 20 20 20 72 65 74 > . ret< +0010200 75 72 6e 20 72 65 74 3b 0a 20 20 20 20 7d 0a 0a >urn ret;. }..< +0010220 20 20 20 20 2f 2f 2f 20 28 54 68 69 73 20 66 75 > /// (This fu< +0010240 6e 63 74 69 6f 6e 20 77 61 73 20 69 6e 6c 69 6e >nction was inlin< +0010260 65 64 20 69 6e 20 74 68 65 20 6f 72 69 67 69 6e >ed in the origin< +0010300 61 6c 20 70 72 6f 67 72 61 6d 29 20 0a 20 20 20 >al program) . < +0010320 20 2f 2f 2f 20 46 69 6e 64 73 20 61 6c 6c 20 61 > /// Finds all a< +0010340 6c 74 65 72 6e 61 74 69 76 65 73 20 66 6f 72 20 >lternatives for < +0010360 74 68 65 20 67 69 76 65 6e 20 70 68 6f 6e 65 20 >the given phone < +0010400 6e 75 6d 62 65 72 20 0a 20 20 20 20 2f 2f 2f 20 >number . /// < +0010420 52 65 74 75 72 6e 73 3a 20 61 72 72 61 79 20 6f >Returns: array o< +0010440 66 20 73 74 72 69 6e 67 73 20 0a 20 20 20 20 73 >f strings . s< +0010460 74 72 69 6e 67 61 72 72 61 79 20 46 69 6e 64 57 >tringarray FindW< +0010500 6f 72 64 73 28 20 73 74 72 69 6e 67 20 70 68 6f >ords( string pho< +0010520 6e 65 5f 6e 75 6d 62 65 72 20 29 0a 20 20 20 20 >ne_number ). < +0010540 7b 0a 20 20 20 20 20 20 20 20 69 66 20 28 21 70 >{. if (!p< +0010560 68 6f 6e 65 5f 6e 75 6d 62 65 72 2e 6c 65 6e 67 >hone_number.leng< +0010600 74 68 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 >th). < +0010620 72 65 74 75 72 6e 20 6e 75 6c 6c 3b 0a 20 20 20 >return null;. < +0010640 20 20 20 20 20 2f 2f 20 53 74 72 69 70 20 74 68 > // Strip th< +0010660 65 20 6e 6f 6e 2d 64 69 67 69 74 20 63 68 61 72 >e non-digit char< +0010700 61 63 74 65 72 73 20 66 72 6f 6d 20 74 68 65 20 >acters from the < +0010720 70 68 6f 6e 65 20 6e 75 6d 62 65 72 2c 20 61 6e >phone number, an< +0010740 64 0a 20 20 20 20 20 20 20 20 2f 2f 20 70 61 73 >d. // pas< +0010760 73 20 69 74 20 74 6f 20 74 68 65 20 72 65 63 75 >s it to the recu< +0011000 72 73 69 76 65 20 66 75 6e 63 74 69 6f 6e 20 28 >rsive function (< +0011020 6c 65 61 64 69 6e 67 20 64 69 67 69 74 20 69 73 >leading digit is< +0011040 20 61 6c 6c 6f 77 65 64 29 0a 20 20 20 20 20 20 > allowed). < +0011060 20 20 72 65 74 75 72 6e 20 5f 46 69 6e 64 57 6f > return _FindWo< +0011100 72 64 73 28 20 73 74 72 69 70 4e 6f 6e 44 69 67 >rds( stripNonDig< +0011120 69 74 28 70 68 6f 6e 65 5f 6e 75 6d 62 65 72 29 >it(phone_number)< +0011140 2c 20 74 72 75 65 20 29 3b 20 20 20 20 0a 20 20 >, true ); . < +0011160 20 20 7d 20 20 20 20 0a 20 20 20 20 0a 20 20 20 > } . . < +0011200 20 2f 2f 20 52 65 61 64 20 74 68 65 20 70 68 6f > // Read the pho< +0011220 6e 65 20 6e 75 6d 62 65 72 73 20 20 20 20 20 0a >ne numbers .< +0011240 20 20 20 20 66 6f 72 65 61 63 68 28 73 74 72 69 > foreach(stri< +0011260 6e 67 20 70 68 6f 6e 65 3b 20 6e 65 77 20 42 75 >ng phone; new Bu< +0011300 66 66 65 72 65 64 46 69 6c 65 28 22 69 6e 70 75 >fferedFile("inpu< +0011320 74 2e 74 78 74 22 20 20 20 29 20 29 0a 20 20 20 >t.txt" ) ). < +0011340 20 20 20 20 20 66 6f 72 65 61 63 68 28 61 6c 74 > foreach(alt< +0011360 65 72 6e 61 74 69 76 65 3b 20 46 69 6e 64 57 6f >ernative; FindWo< +0011400 72 64 73 28 20 70 68 6f 6e 65 20 29 20 29 0a 20 >rds( phone ) ). < +0011420 20 20 20 20 20 20 20 20 20 20 20 77 72 69 74 65 > write< +0011440 66 6c 6e 28 70 68 6f 6e 65 2c 20 22 3a 20 22 2c >fln(phone, ": ",< +0011460 20 61 6c 74 65 72 6e 61 74 69 76 65 20 29 3b 0a > alternative );.< +0011500 7d 0a 0a >}..< +0011503 diff --git a/tests/examplefiles/hexdump_xxd b/tests/examplefiles/hexdump_xxd new file mode 100644 index 00000000..33a8a6e1 --- /dev/null +++ b/tests/examplefiles/hexdump_xxd @@ -0,0 +1,309 @@ +0000000: 2f2f 2043 7265 6174 6564 2062 7920 4c69 // Created by Li +0000010: 6f6e 656c 6c6f 204c 756e 6573 7520 616e onello Lunesu an +0000020: 6420 706c 6163 6564 2069 6e20 7468 6520 d placed in the +0000030: 7075 626c 6963 2064 6f6d 6169 6e2e 0a2f public domain../ +0000040: 2f20 5468 6973 2066 696c 6520 6861 7320 / This file has +0000050: 6265 656e 206d 6f64 6966 6965 6420 6672 been modified fr +0000060: 6f6d 2069 7473 206f 7269 6769 6e61 6c20 om its original +0000070: 7665 7273 696f 6e2e 0a2f 2f20 4974 2068 version..// It h +0000080: 6173 2062 6565 6e20 666f 726d 6174 7465 as been formatte +0000090: 6420 746f 2066 6974 2079 6f75 7220 7363 d to fit your sc +00000a0: 7265 656e 2e0a 6d6f 6475 6c65 2070 686f reen..module pho +00000b0: 6e65 6e6f 3b20 2020 2020 2f2f 206f 7074 neno; // opt +00000c0: 696f 6e61 6c0a 696d 706f 7274 2073 7464 ional.import std +00000d0: 2e73 7464 696f 3b20 2020 2f2f 2077 7269 .stdio; // wri +00000e0: 7465 666c 6e20 2020 2020 0a69 6d70 6f72 tefln .impor +00000f0: 7420 7374 642e 6374 7970 653b 2020 202f t std.ctype; / +0000100: 2f20 6973 6469 6769 7420 2020 2020 0a69 / isdigit .i +0000110: 6d70 6f72 7420 7374 642e 7374 7265 616d mport std.stream +0000120: 3b20 202f 2f20 4275 6666 6572 6564 4669 ; // BufferedFi +0000130: 6c65 0a0a 2f2f 204a 7573 7420 666f 7220 le..// Just for +0000140: 7265 6164 6162 696c 6974 7920 2869 6d61 readability (ima +0000150: 6769 6e65 2063 6861 725b 5d5b 5d5b 6368 gine char[][][ch +0000160: 6172 5b5d 5d29 2020 2020 0a61 6c69 6173 ar[]]) .alias +0000170: 2063 6861 725b 5d20 7374 7269 6e67 3b0a char[] string;. +0000180: 616c 6961 7320 7374 7269 6e67 5b5d 2073 alias string[] s +0000190: 7472 696e 6761 7272 6179 3b0a 0a2f 2f2f tringarray;../// +00001a0: 2053 7472 6970 7320 6e6f 6e2d 6469 6769 Strips non-digi +00001b0: 7420 6368 6172 6163 7465 7273 2066 726f t characters fro +00001c0: 6d20 7468 6520 7374 7269 6e67 2028 434f m the string (CO +00001d0: 5729 0a73 7472 696e 6720 7374 7269 704e W).string stripN +00001e0: 6f6e 4469 6769 7428 2069 6e20 7374 7269 onDigit( in stri +00001f0: 6e67 206c 696e 6520 2920 0a7b 0a20 2020 ng line ) .{. +0000200: 2073 7472 696e 6720 7265 743b 0a20 2020 string ret;. +0000210: 2066 6f72 6561 6368 2875 696e 7420 692c foreach(uint i, +0000220: 2063 3b20 6c69 6e65 2920 7b0a 2020 2020 c; line) {. +0000230: 2020 2020 2f2f 2045 7272 6f72 3a20 7374 // Error: st +0000240: 642e 6374 7970 652e 6973 6469 6769 7420 d.ctype.isdigit +0000250: 6174 2043 3a5c 646d 645c 7372 635c 7068 at C:\dmd\src\ph +0000260: 6f62 6f73 5c73 7464 5c63 7479 7065 2e64 obos\std\ctype.d +0000270: 2833 3729 200a 2020 2020 2020 2020 2f2f (37) . // +0000280: 2063 6f6e 666c 6963 7473 2077 6974 6820 conflicts with +0000290: 7374 642e 7374 7265 616d 2e69 7364 6967 std.stream.isdig +00002a0: 6974 2061 7420 433a 5c64 6d64 5c73 7263 it at C:\dmd\src +00002b0: 5c70 686f 626f 735c 7374 645c 7374 7265 \phobos\std\stre +00002c0: 616d 2e64 2832 3932 3429 0a20 2020 2020 am.d(2924). +00002d0: 2020 2069 6620 2821 7374 642e 6374 7970 if (!std.ctyp +00002e0: 652e 6973 6469 6769 7428 6329 2920 7b0a e.isdigit(c)) {. +00002f0: 2020 2020 2020 2020 2020 2020 6966 2028 if ( +0000300: 2172 6574 290a 2020 2020 2020 2020 2020 !ret). +0000310: 2020 2020 2020 7265 7420 3d20 6c69 6e65 ret = line +0000320: 5b30 2e2e 695d 3b20 2020 200a 2020 2020 [0..i]; . +0000330: 2020 2020 7d20 2020 200a 2020 2020 2020 } . +0000340: 2020 656c 7365 2069 6620 2872 6574 290a else if (ret). +0000350: 2020 2020 2020 2020 2020 2020 7265 7420 ret +0000360: 7e3d 2063 3b20 2020 200a 2020 2020 7d20 ~= c; . } +0000370: 2020 200a 2020 2020 7265 7475 726e 2072 . return r +0000380: 6574 3f72 6574 3a6c 696e 653b 0a7d 0a0a et?ret:line;.}.. +0000390: 756e 6974 7465 7374 207b 0a20 2020 2061 unittest {. a +00003a0: 7373 6572 7428 2073 7472 6970 4e6f 6e44 ssert( stripNonD +00003b0: 6967 6974 2822 6173 6466 2229 203d 3d20 igit("asdf") == +00003c0: 2222 2020 293b 0a20 2020 2061 7373 6572 "" );. asser +00003d0: 7428 2073 7472 6970 4e6f 6e44 6967 6974 t( stripNonDigit +00003e0: 2822 5c27 3133 2d3d 3220 346b 6f70 2229 ("\'13-=2 4kop") +00003f0: 203d 3d20 2022 3133 3234 2220 2029 3b0a == "1324" );. +0000400: 7d0a 0a2f 2f2f 2043 6f6e 7665 7274 7320 }../// Converts +0000410: 6120 776f 7264 2069 6e74 6f20 6120 6e75 a word into a nu +0000420: 6d62 6572 2c20 6967 6e6f 7269 6e67 2061 mber, ignoring a +0000430: 6c6c 206e 6f6e 2061 6c70 6861 2063 6861 ll non alpha cha +0000440: 7261 6374 6572 7320 200a 7374 7269 6e67 racters .string +0000450: 2077 6f72 6454 6f4e 756d 2820 696e 2073 wordToNum( in s +0000460: 7472 696e 6720 776f 7264 2029 0a7b 0a2f tring word ).{./ +0000470: 2f20 7472 616e 736c 6174 696f 6e20 7461 / translation ta +0000480: 626c 6520 666f 7220 7468 6520 7461 736b ble for the task +0000490: 2061 7420 6861 6e64 0a63 6f6e 7374 2063 at hand.const c +00004a0: 6861 725b 3235 365d 2054 5241 4e53 4c41 har[256] TRANSLA +00004b0: 5445 203d 2020 2020 0a20 2020 2022 2020 TE = . " +00004c0: 2020 2020 2020 2020 2020 2020 2020 2020 +00004d0: 2020 2020 2020 2020 2020 2020 2020 2220 " +00004e0: 202f 2f20 3020 2020 0a20 2020 2022 2020 // 0 . " +00004f0: 2020 2020 2020 2020 2020 2020 2020 3031 01 +0000500: 3233 3435 3637 3839 2020 2020 2020 2220 23456789 " +0000510: 202f 2f20 3332 2020 2020 200a 2020 2020 // 32 . +0000520: 2220 3537 3633 3034 3939 3631 3738 3531 " 57630499617851 +0000530: 3838 3132 3334 3736 3232 3339 2020 2020 881234762239 +0000540: 2022 2020 2f2f 2036 3420 2020 0a20 2020 " // 64 . +0000550: 2022 2035 3736 3330 3439 3936 3137 3835 " 5763049961785 +0000560: 3138 3831 3233 3437 3632 3233 3920 2020 1881234762239 +0000570: 2020 220a 2020 2020 2220 2020 2020 2020 ". " +0000580: 2020 2020 2020 2020 2020 2020 2020 2020 +0000590: 2020 2020 2020 2020 2022 0a20 2020 2022 ". " +00005a0: 2020 2020 2020 2020 2020 2020 2020 2020 +00005b0: 2020 2020 2020 2020 2020 2020 2020 2020 +00005c0: 220a 2020 2020 2220 2020 2020 2020 2020 ". " +00005d0: 2020 2020 2020 2020 2020 2020 2020 2020 +00005e0: 2020 2020 2020 2022 2020 2020 0a20 2020 " . +00005f0: 2022 2020 2020 2020 2020 2020 2020 2020 " +0000600: 2020 2020 2020 2020 2020 2020 2020 2020 +0000610: 2020 223b 0a20 2020 2073 7472 696e 6720 ";. string +0000620: 7265 743b 0a20 2020 2066 6f72 6561 6368 ret;. foreach +0000630: 2863 3b20 6361 7374 2875 6279 7465 5b5d (c; cast(ubyte[] +0000640: 2977 6f72 6429 0a20 2020 2020 2020 2069 )word). i +0000650: 6620 2854 5241 4e53 4c41 5445 5b63 5d20 f (TRANSLATE[c] +0000660: 213d 2027 2027 290a 2020 2020 2020 2020 != ' '). +0000670: 2020 2020 7265 7420 7e3d 2054 5241 4e53 ret ~= TRANS +0000680: 4c41 5445 5b63 5d3b 0a20 2020 2072 6574 LATE[c];. ret +0000690: 7572 6e20 7265 743b 0a7d 0a0a 756e 6974 urn ret;.}..unit +00006a0: 7465 7374 207b 0a20 2f2f 2054 6573 7420 test {. // Test +00006b0: 776f 7264 546f 4e75 6d20 7573 696e 6720 wordToNum using +00006c0: 7468 6520 7461 626c 6520 6672 6f6d 2074 the table from t +00006d0: 6865 2074 6173 6b20 6465 7363 7269 7074 he task descript +00006e0: 696f 6e2e 0a20 6173 7365 7274 2820 2230 ion.. assert( "0 +00006f0: 3131 3132 3232 3333 3334 3435 3536 3636 1112223334455666 +0000700: 3737 3738 3838 3939 3922 203d 3d0a 2020 777888999" ==. +0000710: 2077 6f72 6454 6f4e 756d 2822 4520 7c20 wordToNum("E | +0000720: 4a20 4e20 5120 7c20 5220 5720 5820 7c20 J N Q | R W X | +0000730: 4420 5320 5920 7c20 4620 5420 7c20 4120 D S Y | F T | A +0000740: 4d20 7c20 4320 4920 5620 7c20 4220 4b20 M | C I V | B K +0000750: 5520 7c20 4c20 4f20 5020 7c20 4720 4820 U | L O P | G H +0000760: 5a22 2929 3b0a 2061 7373 6572 7428 2022 Z"));. assert( " +0000770: 3031 3131 3232 3233 3333 3434 3535 3636 0111222333445566 +0000780: 3637 3737 3838 3839 3939 2220 3d3d 200a 6777888999" == . +0000790: 2020 2077 6f72 6454 6f4e 756d 2822 6520 wordToNum("e +00007a0: 7c20 6a20 6e20 7120 7c20 7220 7720 7820 | j n q | r w x +00007b0: 7c20 6420 7320 7920 7c20 6620 7420 7c20 | d s y | f t | +00007c0: 6120 6d20 7c20 6320 6920 7620 7c20 6220 a m | c i v | b +00007d0: 6b20 7520 7c20 6c20 6f20 7020 7c20 6720 k u | l o p | g +00007e0: 6820 7a22 2929 3b0a 2061 7373 6572 7428 h z"));. assert( +00007f0: 2022 3031 3233 3435 3637 3839 2220 3d3d "0123456789" == +0000800: 200a 2020 2077 6f72 6454 6f4e 756d 2822 . wordToNum(" +0000810: 3020 7c20 2020 3120 2020 7c20 2020 3220 0 | 1 | 2 +0000820: 2020 7c20 2020 3320 2020 7c20 2034 2020 | 3 | 4 +0000830: 7c20 2035 2020 7c20 2020 3620 2020 7c20 | 5 | 6 | +0000840: 2020 3720 2020 7c20 2020 3820 2020 7c20 7 | 8 | +0000850: 2020 3922 2929 3b0a 7d0a 0a76 6f69 6420 9"));.}..void +0000860: 6d61 696e 2820 7374 7269 6e67 5b5d 2061 main( string[] a +0000870: 7267 7320 290a 7b0a 2020 2020 2f2f 2054 rgs ).{. // T +0000880: 6869 7320 6173 736f 6369 6174 6976 6520 his associative +0000890: 6172 7261 7920 6d61 7073 2061 206e 756d array maps a num +00008a0: 6265 7220 746f 2061 6e20 6172 7261 7920 ber to an array +00008b0: 6f66 2077 6f72 6473 2e20 2020 200a 2020 of words. . +00008c0: 2020 7374 7269 6e67 6172 7261 795b 7374 stringarray[st +00008d0: 7269 6e67 5d20 2020 206e 756d 3277 6f72 ring] num2wor +00008e0: 6473 3b0a 0a20 2020 2066 6f72 6561 6368 ds;.. foreach +00008f0: 2873 7472 696e 6720 776f 7264 3b20 6e65 (string word; ne +0000900: 7720 4275 6666 6572 6564 4669 6c65 2822 w BufferedFile(" +0000910: 6469 6374 696f 6e61 7279 2e74 7874 2220 dictionary.txt" +0000920: 2920 290a 2020 2020 2020 2020 6e75 6d32 ) ). num2 +0000930: 776f 7264 735b 2077 6f72 6454 6f4e 756d words[ wordToNum +0000940: 2877 6f72 6429 205d 207e 3d20 776f 7264 (word) ] ~= word +0000950: 2e64 7570 3b20 2020 2020 2020 202f 2f20 .dup; // +0000960: 6d75 7374 2064 7570 0a0a 2020 2020 2f2f must dup.. // +0000970: 2f20 4669 6e64 7320 616c 6c20 616c 7465 / Finds all alte +0000980: 726e 6174 6976 6573 2066 6f72 2074 6865 rnatives for the +0000990: 2067 6976 656e 206e 756d 6265 720a 2020 given number. +00009a0: 2020 2f2f 2f20 2873 686f 756c 6420 6861 /// (should ha +00009b0: 7665 2062 6565 6e20 7374 7269 7070 6564 ve been stripped +00009c0: 2066 726f 6d20 6e6f 6e2d 6469 6769 7420 from non-digit +00009d0: 6368 6172 6163 7465 7273 290a 2020 2020 characters). +00009e0: 7374 7269 6e67 6172 7261 7920 5f46 696e stringarray _Fin +00009f0: 6457 6f72 6473 2820 7374 7269 6e67 206e dWords( string n +0000a00: 756d 6265 7273 2c20 626f 6f6c 2064 6967 umbers, bool dig +0000a10: 6974 6f6b 2029 0a20 2020 2069 6e20 7b0a itok ). in {. +0000a20: 2020 2020 2020 2020 6173 7365 7274 286e assert(n +0000a30: 756d 6265 7273 2e6c 656e 6774 6820 3e20 umbers.length > +0000a40: 2030 293b 2020 2020 0a20 2020 207d 2020 0); . } +0000a50: 2020 0a20 2020 206f 7574 2872 6573 756c . out(resul +0000a60: 7429 207b 0a20 2020 2020 2020 2066 6f72 t) {. for +0000a70: 6561 6368 2028 613b 2072 6573 756c 7429 each (a; result) +0000a80: 0a20 2020 2020 2020 2020 2020 2061 7373 . ass +0000a90: 6572 7428 2077 6f72 6454 6f4e 756d 2861 ert( wordToNum(a +0000aa0: 2920 3d3d 206e 756d 6265 7273 2029 3b0a ) == numbers );. +0000ab0: 2020 2020 7d20 2020 200a 2020 2020 626f } . bo +0000ac0: 6479 207b 0a20 2020 2020 2020 2073 7472 dy {. str +0000ad0: 696e 6761 7272 6179 2072 6574 3b0a 2020 ingarray ret;. +0000ae0: 2020 2020 2020 626f 6f6c 2066 6f75 6e64 bool found +0000af0: 776f 7264 203d 2066 616c 7365 3b0a 2020 word = false;. +0000b00: 2020 2020 2020 666f 7220 2875 696e 7420 for (uint +0000b10: 743d 313b 2074 3c3d 6e75 6d62 6572 732e t=1; t<=numbers. +0000b20: 6c65 6e67 7468 3b20 2b2b 7429 207b 0a20 length; ++t) {. +0000b30: 2020 2020 2020 2020 2020 2061 7574 6f20 auto +0000b40: 616c 7465 726e 6174 6976 6573 203d 206e alternatives = n +0000b50: 756d 6265 7273 5b30 2e2e 745d 2069 6e20 umbers[0..t] in +0000b60: 6e75 6d32 776f 7264 733b 0a20 2020 2020 num2words;. +0000b70: 2020 2020 2020 2069 6620 2821 616c 7465 if (!alte +0000b80: 726e 6174 6976 6573 290a 2020 2020 2020 rnatives). +0000b90: 2020 2020 2020 2020 2020 636f 6e74 696e contin +0000ba0: 7565 3b0a 2020 2020 2020 2020 2020 2020 ue;. +0000bb0: 666f 756e 6477 6f72 6420 3d20 7472 7565 foundword = true +0000bc0: 3b0a 2020 2020 2020 2020 2020 2020 6966 ;. if +0000bd0: 2028 6e75 6d62 6572 732e 6c65 6e67 7468 (numbers.length +0000be0: 203e 2020 7429 207b 0a20 2020 2020 2020 > t) {. +0000bf0: 2020 2020 2020 2020 202f 2f20 436f 6d62 // Comb +0000c00: 696e 6520 616c 6c20 6375 7272 656e 7420 ine all current +0000c10: 616c 7465 726e 6174 6976 6573 2077 6974 alternatives wit +0000c20: 6820 616c 6c20 616c 7465 726e 6174 6976 h all alternativ +0000c30: 6573 2020 2020 200a 2020 2020 2020 2020 es . +0000c40: 2020 2020 2020 2020 2f2f 206f 6620 7468 // of th +0000c50: 6520 7265 7374 2028 6e65 7874 2070 6965 e rest (next pie +0000c60: 6365 2063 616e 2073 7461 7274 2077 6974 ce can start wit +0000c70: 6820 6120 6469 6769 7429 2020 2020 2020 h a digit) +0000c80: 2020 2020 2020 2020 0a20 2020 2020 2020 . +0000c90: 2020 2020 2020 2020 2066 6f72 6561 6368 foreach +0000ca0: 2028 6132 3b20 5f46 696e 6457 6f72 6473 (a2; _FindWords +0000cb0: 2820 6e75 6d62 6572 735b 742e 2e24 5d2c ( numbers[t..$], +0000cc0: 2074 7275 6520 2020 2020 2920 290a 2020 true ) ). +0000cd0: 2020 2020 2020 2020 2020 2020 2020 2020 +0000ce0: 2020 666f 7265 6163 6828 6131 3b20 2a61 foreach(a1; *a +0000cf0: 6c74 6572 6e61 7469 7665 7329 0a20 2020 lternatives). +0000d00: 2020 2020 2020 2020 2020 2020 2020 2020 +0000d10: 2020 2020 7265 7420 7e3d 2061 3120 7e20 ret ~= a1 ~ +0000d20: 2220 2220 7e20 6132 3b0a 2020 2020 2020 " " ~ a2;. +0000d30: 2020 2020 2020 7d0a 2020 2020 2020 2020 }. +0000d40: 2020 2020 656c 7365 2020 2020 0a20 2020 else . +0000d50: 2020 2020 2020 2020 2020 2020 2072 6574 ret +0000d60: 207e 3d20 2a61 6c74 6572 6e61 7469 7665 ~= *alternative +0000d70: 733b 2020 2020 2f2f 2061 7070 656e 6420 s; // append +0000d80: 7468 6573 6520 616c 7465 726e 6174 6976 these alternativ +0000d90: 6573 0a20 2020 2020 2020 207d 0a20 2020 es. }. +0000da0: 2020 2020 202f 2f20 5472 7920 746f 206b // Try to k +0000db0: 6565 7020 3120 6469 6769 742c 206f 6e6c eep 1 digit, onl +0000dc0: 7920 6966 2077 6527 7265 2061 6c6c 6f77 y if we're allow +0000dd0: 6564 2061 6e64 206e 6f20 6f74 6865 720a ed and no other. +0000de0: 2020 2020 2020 2020 2f2f 2061 6c74 6572 // alter +0000df0: 6e61 7469 7665 7320 7765 7265 2066 6f75 natives were fou +0000e00: 6e64 0a20 2020 2020 2020 202f 2f20 5465 nd. // Te +0000e10: 7374 696e 6720 2272 6574 2e6c 656e 6774 sting "ret.lengt +0000e20: 6822 206d 616b 6573 206d 6f72 6520 7365 h" makes more se +0000e30: 6e73 6520 7468 616e 2074 6573 7469 6e67 nse than testing +0000e40: 2022 666f 756e 6477 6f72 6422 2c0a 2020 "foundword",. +0000e50: 2020 2020 2020 2f2f 2062 7574 2074 6865 // but the +0000e60: 206f 7468 6572 2069 6d70 6c65 6d65 6e74 other implement +0000e70: 6174 696f 6e73 2073 6565 6d20 746f 2064 ations seem to d +0000e80: 6f20 6a75 7374 2074 6869 732e 0a20 2020 o just this.. +0000e90: 2020 2020 2069 6620 2864 6967 6974 6f6b if (digitok +0000ea0: 2026 2620 2166 6f75 6e64 776f 7264 2920 && !foundword) +0000eb0: 7b20 2f2f 7265 742e 6c65 6e67 7468 203d { //ret.length = +0000ec0: 3d20 3020 200a 2020 2020 2020 2020 2020 = 0 . +0000ed0: 2020 6966 286e 756d 6265 7273 2e6c 656e if(numbers.len +0000ee0: 6774 6820 3e20 2031 2920 7b0a 2020 2020 gth > 1) {. +0000ef0: 2020 2020 2020 2020 2020 2020 2f2f 2043 // C +0000f00: 6f6d 6269 6e65 2031 2064 6967 6974 2077 ombine 1 digit w +0000f10: 6974 6820 616c 6c20 616c 7465 6e61 7469 ith all altenati +0000f20: 7665 7320 6672 6f6d 2074 6865 2072 6573 ves from the res +0000f30: 7420 2020 200a 2020 2020 2020 2020 2020 t . +0000f40: 2020 2020 2020 2f2f 2028 6e65 7874 2070 // (next p +0000f50: 6965 6365 2063 616e 206e 6f74 2073 7461 iece can not sta +0000f60: 7274 2077 6974 6820 6120 6469 6769 7429 rt with a digit) +0000f70: 2020 2020 2020 2020 2020 0a20 2020 2020 . +0000f80: 2020 2020 2020 2020 2020 2066 6f72 6561 forea +0000f90: 6368 2028 613b 205f 4669 6e64 576f 7264 ch (a; _FindWord +0000fa0: 7328 206e 756d 6265 7273 5b31 2e2e 245d s( numbers[1..$] +0000fb0: 2c20 6661 6c73 6520 2920 290a 2020 2020 , false ) ). +0000fc0: 2020 2020 2020 2020 2020 2020 2020 2020 +0000fd0: 7265 7420 7e3d 206e 756d 6265 7273 5b30 ret ~= numbers[0 +0000fe0: 2e2e 315d 207e 2022 2022 207e 2061 3b0a ..1] ~ " " ~ a;. +0000ff0: 2020 2020 2020 2020 2020 2020 7d20 2020 } +0001000: 200a 2020 2020 2020 2020 2020 2020 656c . el +0001010: 7365 2020 2020 0a20 2020 2020 2020 2020 se . +0001020: 2020 2020 2020 2072 6574 207e 3d20 6e75 ret ~= nu +0001030: 6d62 6572 735b 302e 2e31 5d3b 2020 2020 mbers[0..1]; +0001040: 2f2f 206a 7573 7420 6170 7065 6e64 2074 // just append t +0001050: 6869 7320 6469 6769 7420 2020 2020 2020 his digit +0001060: 2020 2020 2020 0a20 2020 2020 2020 207d . } +0001070: 2020 2020 0a20 2020 2020 2020 2072 6574 . ret +0001080: 7572 6e20 7265 743b 0a20 2020 207d 0a0a urn ret;. }.. +0001090: 2020 2020 2f2f 2f20 2854 6869 7320 6675 /// (This fu +00010a0: 6e63 7469 6f6e 2077 6173 2069 6e6c 696e nction was inlin +00010b0: 6564 2069 6e20 7468 6520 6f72 6967 696e ed in the origin +00010c0: 616c 2070 726f 6772 616d 2920 0a20 2020 al program) . +00010d0: 202f 2f2f 2046 696e 6473 2061 6c6c 2061 /// Finds all a +00010e0: 6c74 6572 6e61 7469 7665 7320 666f 7220 lternatives for +00010f0: 7468 6520 6769 7665 6e20 7068 6f6e 6520 the given phone +0001100: 6e75 6d62 6572 200a 2020 2020 2f2f 2f20 number . /// +0001110: 5265 7475 726e 733a 2061 7272 6179 206f Returns: array o +0001120: 6620 7374 7269 6e67 7320 0a20 2020 2073 f strings . s +0001130: 7472 696e 6761 7272 6179 2046 696e 6457 tringarray FindW +0001140: 6f72 6473 2820 7374 7269 6e67 2070 686f ords( string pho +0001150: 6e65 5f6e 756d 6265 7220 290a 2020 2020 ne_number ). +0001160: 7b0a 2020 2020 2020 2020 6966 2028 2170 {. if (!p +0001170: 686f 6e65 5f6e 756d 6265 722e 6c65 6e67 hone_number.leng +0001180: 7468 290a 2020 2020 2020 2020 2020 2020 th). +0001190: 7265 7475 726e 206e 756c 6c3b 0a20 2020 return null;. +00011a0: 2020 2020 202f 2f20 5374 7269 7020 7468 // Strip th +00011b0: 6520 6e6f 6e2d 6469 6769 7420 6368 6172 e non-digit char +00011c0: 6163 7465 7273 2066 726f 6d20 7468 6520 acters from the +00011d0: 7068 6f6e 6520 6e75 6d62 6572 2c20 616e phone number, an +00011e0: 640a 2020 2020 2020 2020 2f2f 2070 6173 d. // pas +00011f0: 7320 6974 2074 6f20 7468 6520 7265 6375 s it to the recu +0001200: 7273 6976 6520 6675 6e63 7469 6f6e 2028 rsive function ( +0001210: 6c65 6164 696e 6720 6469 6769 7420 6973 leading digit is +0001220: 2061 6c6c 6f77 6564 290a 2020 2020 2020 allowed). +0001230: 2020 7265 7475 726e 205f 4669 6e64 576f return _FindWo +0001240: 7264 7328 2073 7472 6970 4e6f 6e44 6967 rds( stripNonDig +0001250: 6974 2870 686f 6e65 5f6e 756d 6265 7229 it(phone_number) +0001260: 2c20 7472 7565 2029 3b20 2020 200a 2020 , true ); . +0001270: 2020 7d20 2020 200a 2020 2020 0a20 2020 } . . +0001280: 202f 2f20 5265 6164 2074 6865 2070 686f // Read the pho +0001290: 6e65 206e 756d 6265 7273 2020 2020 200a ne numbers . +00012a0: 2020 2020 666f 7265 6163 6828 7374 7269 foreach(stri +00012b0: 6e67 2070 686f 6e65 3b20 6e65 7720 4275 ng phone; new Bu +00012c0: 6666 6572 6564 4669 6c65 2822 696e 7075 fferedFile("inpu +00012d0: 742e 7478 7422 2020 2029 2029 0a20 2020 t.txt" ) ). +00012e0: 2020 2020 2066 6f72 6561 6368 2861 6c74 foreach(alt +00012f0: 6572 6e61 7469 7665 3b20 4669 6e64 576f ernative; FindWo +0001300: 7264 7328 2070 686f 6e65 2029 2029 0a20 rds( phone ) ). +0001310: 2020 2020 2020 2020 2020 2077 7269 7465 write +0001320: 666c 6e28 7068 6f6e 652c 2022 3a20 222c fln(phone, ": ", +0001330: 2061 6c74 6572 6e61 7469 7665 2029 3b0a alternative );. +0001340: 7d0a 0a }.. diff --git a/tests/examplefiles/noexcept.cpp b/tests/examplefiles/noexcept.cpp new file mode 100644 index 00000000..f83e50db --- /dev/null +++ b/tests/examplefiles/noexcept.cpp @@ -0,0 +1,8 @@ +void* operator new (std::size_t size); +void* operator new (std::size_t size, const std::nothrow_t& nothrow_value) noexcept; +void* operator new (std::size_t size, const std::nothrow_t& nothrow_value)noexcept; +void* operator new (std::size_t size, const std::nothrow_t& nothrow_value); +void* operator new (std::size_t size); +void* operator new (std::size_t size) noexcept; +void* operator new (std::size_t size)noexcept; + diff --git a/tests/examplefiles/pacman.conf b/tests/examplefiles/pacman.conf new file mode 100644 index 00000000..78dbf5e1 --- /dev/null +++ b/tests/examplefiles/pacman.conf @@ -0,0 +1,49 @@ +# +# /etc/pacman.conf +# +# This example file has no relation to `pacman.ijs` +# but is of configuration of Arch Linux's package manager `pacman`. +# + +# +# GENERAL OPTIONS +# +[options] +RootDir = /opt/local/site-private +#DBPath = /var/lib/pacman/ +#CacheDir = /var/cache/pacman/pkg/ +LogFile = /opt/local/site-private/var/log/pacman.log +#GPGDir = /etc/pacman.d/gnupg/ +HoldPkg = pacman +#XferCommand = /usr/bin/curl -C - -f %u > %o +XferCommand = /usr/local/bin/wget --passive-ftp -c -O %o %u +#CleanMethod = KeepInstalled +#UseDelta = 0.7 +Architecture = auto + +#IgnorePkg = +#IgnoreGroup = + +NoUpgrade = etc/passwd etc/group etc/shadow +NoUpgrade = etc/fstab +#NoExtract = + +#UseSyslog +Color +#TotalDownload +CheckSpace +#VerbosePkgLists + +#SigLevel = Never +SigLevel = Required DatabaseOptional +LocalFileSigLevel = Optional +RemoteFileSigLevel = Required + +Server = ftp://ftp9.yaphatchpotchgen.net/$repo/os/$arch + +[fubar32] +Include = /etc/pacman.d/mirrorlist.fubar32 # comment is allowed here + +#[custom] +#SigLevel = Optional TrustAll +#Server = file:///home/custompkgs diff --git a/tests/examplefiles/pkgconfig_example.pc b/tests/examplefiles/pkgconfig_example.pc new file mode 100644 index 00000000..2a59204e --- /dev/null +++ b/tests/examplefiles/pkgconfig_example.pc @@ -0,0 +1,18 @@ +# This is for a fictional package `yet another portable hatchpotch generator'. +prefix=/usr/local/opt/site/private # define variable `prefix` +exec_prefix=${prefix} # using variable reference +libdir=${exec_prefix}/lib +includedir=${prefix}/include +just_for_test=$${this is not a part of variable reference} # escape with `$$` + +Name: YAPHatchPotchGen +Description: Yet Another Portable HatchPotch GENerator. +Version: 352.9.3 +URL: http://www9.yaphatchpotchgen.net # Don't access. +Requires: piyohogelib-9.0 = 9.5.3 +Requires.private: nyorolib-3.0 = 3.0.9 +Conflicts: apiyohoge <= 8.3 +Libs: -L${libdir} -lyaphatchpotchgen-352.9 # using variable reference +Libs.private: -ll -ly +Cflags: -I${includedir}/piyohogelib-9.0 -I${libdir}/yaphatchpotchgen/include + diff --git a/tests/examplefiles/pycon_ctrlc_traceback b/tests/examplefiles/pycon_ctrlc_traceback new file mode 100644 index 00000000..4998fd9c --- /dev/null +++ b/tests/examplefiles/pycon_ctrlc_traceback @@ -0,0 +1,118 @@ +x = r""" +>>> import os +>>> print os +<module 'os' from '/file/path.py'> +>>> for x in range(10): +... y = x + 2 +... print(x) +... if x > 5: +... raise Exception +... +0 +1 +2 +3 +4 +5 +6 +Traceback (most recent call last): + File "<stdin>", line 5, in <module> +Exception +>>> +>>> while True: +... pass +... +^CTraceback (most recent call last): + File "<stdin>", line 1, in <module> +KeyboardInterrupt + +>>> class A(Exception):pass +... +>>> class B(Exception):pass +... +>>> try: +... try: +... raise A('first') +... finally: +... raise B('second') +... except A as c: +... print(c) +... +Traceback (most recent call last): + File "<stdin>", line 3, in <module> +__main__.A: first + +During handling of the above exception, another exception occurred: + +Traceback (most recent call last): + File "<stdin>", line 5, in <module> +__main__.B: second + +>>> x = + File "<stdin>", line 1 + x = + ^ +SyntaxError: invalid syntax +>>> + +>>> x = 3 +>>> with 5 as y: +... print(x + y) +... +8 + +# TODO +#>>> raise ValueError('multi\n line\ndetail') +#Traceback (most recent call last): +#........ +#ValueError: multi +# line +#detail + +>>> raise ValueError('multi\n line\ndetail') +Traceback (most recent call last): + .123 +ValueError: multi + line +detail + +>>> raise ValueError('multi\n line\ndetail') +Traceback (most recent call last): + ... +ValueError: multi + line +detail + +>>> raise ValueError('multi\n line\ndetail') +Traceback (most recent call last): + .... +ValueError: multi + line +detail + +>>> raise ValueError('multi\n line\ndetail') +Traceback (most recent call last): + .... +ValueError: multi + line +detail + +>>> raise ValueError('multi\n line\ndetail') +Traceback (most recent call last): + ... +ValueError: multi + line +detail + +>>> raise Exception +Traceback (most recent call last): + File "<stdin>", line 1, in <module> +Exception +>>> import somemodule +>>> somemodule.blah() +Traceback (most recent call last): + File "<stdin>", line 1, in <module> + File "/path/to/stuff/somemodule/blah.py", line 658, in blah + raise Exception('Hi.') +Exception: Hi. + diff --git a/tests/examplefiles/sample.qvto b/tests/examplefiles/sample.qvto new file mode 100644 index 00000000..6241ee23 --- /dev/null +++ b/tests/examplefiles/sample.qvto @@ -0,0 +1,4 @@ +transformation Foo(uml: SimpleUML, + rdbms : SimpleRDBMS) { +} +/* comment */ diff --git a/tests/examplefiles/simple.camkes b/tests/examplefiles/simple.camkes new file mode 100644 index 00000000..43e11732 --- /dev/null +++ b/tests/examplefiles/simple.camkes @@ -0,0 +1,38 @@ +/* + * Example input for CAmkES lexer. + */ + +import <std_connector.camkes>; + +// A single-line comment. + +import "components/Client/Client.camkes"; +import "components/Echo/Echo.camkes"; + +component Foo { + include "proc_defn.h"; + control; + dataport Buf my_port; +} + +#ifdef BAR_AVAILABLE + component Bar { + provides CharAccess ca; + } +#endif + + #define HASH_DEF_WITH_LEADING_SPACE + +assembly { /* Another multiline comment. */ + composition { + component Echo echo; + component Client client; + + connection seL4RPC simple(from client.s, to echo.s); + } + + configuration { + echo.dma_pool = 4096; + } +} + diff --git a/tests/examplefiles/termcap b/tests/examplefiles/termcap new file mode 100644 index 00000000..e20adaba --- /dev/null +++ b/tests/examplefiles/termcap @@ -0,0 +1,1340 @@ +######## This example from excerpt of <http://www.catb.org/esr/terminfo/>: +# +# Version 11.0.1 +# $Date: 2000/03/02 15:51:11 $ +# termcap syntax +# + +######## ANSI, UNIX CONSOLE, AND SPECIAL TYPES +# +# This section describes terminal classes and brands that are still +# quite common. +# + +#### Specials +# +# Special "terminals". These are used to label tty lines when you don't +# know what kind of terminal is on it. The characteristics of an unknown +# terminal are the lowest common denominator - they look about like a ti 700. +# + +dumb|80-column dumb tty:\ + :am:\ + :co#80:\ + :bl=^G:cr=^M:do=^J:sf=^J: +unknown|unknown terminal type:\ + :gn:tc=dumb: +lpr|printer|line printer:\ + :bs:hc:os:\ + :co#132:li#66:\ + :bl=^G:cr=^M:do=^J:ff=^L:le=^H:sf=^J: +glasstty|classic glass tty interpreting ASCII control characters:\ + :am:bs:\ + :co#80:\ + :bl=^G:cl=^L:cr=^M:do=^J:kd=^J:kl=^H:le=^H:nw=^M^J:ta=^I: +vanilla:\ + :bs:\ + :bl=^G:cr=^M:do=^J:sf=^J: + +#### ANSI.SYS/ISO 6429/ECMA-48 Capabilities +# +# See the end-of-file comment for more on these. +# + +# ANSI capabilities are broken up into pieces, so that a terminal +# implementing some ANSI subset can use many of them. +ansi+local1:\ + :do=\E[B:le=\E[D:nd=\E[C:up=\E[A: +ansi+local:\ + :DO=\E[%dB:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:tc=ansi+local1: +ansi+tabs:\ + :bt=\E[Z:ct=\E[2g:st=\EH:ta=^I: +ansi+inittabs:\ + :it#8:tc=ansi+tabs: +ansi+erase:\ + :cd=\E[J:ce=\E[K:cl=\E[H\E[J: +ansi+rca:\ + :ch=\E[%+^AG:cv=\E[%+^Ad: +ansi+cup:\ + :cm=\E[%i%d;%dH:ho=\E[H: +ansi+rep:\ + :..rp=%p1%c\E[%p2%{1}%-%db: +ansi+idl1:\ + :al=\E[L:dl=\E[M: +ansi+idl:\ + :AL=\E[%dL:DL=\E[%dM:tc=ansi+idl1: +ansi+idc:\ + :IC=\E[%d@:dc=\E[P:ei=\E6:ic=\E[@:im=\E6: +ansi+arrows:\ + :kb=^H:kd=\E[B:kh=\E[H:kl=\E[D:kr=\E[C:ku=\E[A: +ansi+sgr|ansi graphic renditions:\ + :mb=\E[5m:me=\E[0m:mk=\E[8m:mr=\E[7m: +ansi+sgrso|ansi standout only:\ + :se=\E[m:so=\E[7m: +ansi+sgrul|ansi underline only:\ + :ue=\E[m:us=\E[4m: +ansi+sgrbold|ansi graphic renditions; assuming terminal has bold; not dim:\ + :md=\E[1m:\ + :..sa=\E[%?%p1%t7;%;%?%p2%t4;%;%?%p3%t7;%;%?%p4%t5;%;%?%p6%t1;%;m:tc=ansi+sgr:tc=ansi+sgrso:tc=ansi+sgrul: +ansi+sgrdim|ansi graphic renditions; assuming terminal has dim; not bold:\ + :mh=\E[2m:\ + :..sa=\E[%?%p1%t7;%;%?%p2%t4;%;%?%p3%t7;%;%?%p4%t5;%;%?%p5%t2;%;m:tc=ansi+sgr:tc=ansi+sgrso:tc=ansi+sgrul: +ansi+pp|ansi printer port:\ + :pf=\E[4i:po=\E[5i:ps=\E[0i: +ansi+csr|ansi scroll-region plus cursor save & restore:\ + :cs=\E[%i%d;%dr:rc=\E8:sc=\E7: + +# The IBM PC alternate character set. Plug this into any Intel console entry. +# We use \E[11m for rmacs rather than \E[12m so the <acsc> string can use the +# ROM graphics for control characters such as the diamond, up- and down-arrow. +# This works with the System V, Linux, and BSDI consoles. It's a safe bet this +# will work with any Intel console, they all seem to have inherited \E[11m +# from the ANSI.SYS de-facto standard. +klone+acs|alternate character set for ansi.sys displays:\ + :ac=+\020\054\021-\030.^Y0\333`\004a\261f\370g\361h\260j\331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u\264v\301w\302x\263y\363z\362{\343|\330}\234~\376:\ + :ae=\E[10m:as=\E[11m: + +# Highlight controls corresponding to the ANSI.SYS standard. Most +# console drivers for Intel boxes obey these. Makes the same assumption +# about \E[11m as klone+acs. True ANSI/ECMA-48 would have :se=\E[27m:, +# :ue=\E[24m:, but this isn't a documented feature of ANSI.SYS. +klone+sgr|attribute control for ansi.sys displays:\ + :S2=\E[11m:S3=\E[10m:mb=\E[5m:md=\E[1m:me=\E[0;10m:\ + :mk=\E[8m:mr=\E[7m:\ + :..sa=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;m:\ + :se=\E[m:so=\E[7m:ue=\E[m:us=\E[4m:\ + :tc=klone+acs: + +# Highlight controls corresponding to the ANSI.SYS standard. *All* +# console drivers for Intel boxes obey these. Does not assume \E[11m will +# work; uses \E[12m instead, which is pretty bulletproof but loses you the ACS +# diamond and arrow characters under curses. +klone+sgr-dumb|attribute control for ansi.sys displays (no ESC [ 11 m):\ + :as=\E[12m:mb=\E[5m:md=\E[1m:me=\E[0;10m:mk=\E[8m:\ + :mr=\E[7m:\ + :..sa=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;12%;m:\ + :se=\E[m:so=\E[7m:ue=\E[m:us=\E[4m:\ + :tc=klone+acs: + +# KOI8-R (RFC1489) acs (alternate character set) +# From: Qing Long <qinglong@Bolizm.ihep.su>, 24 Feb 1996. +klone+koi8acs|alternate character set for ansi.sys displays with KOI8 charset:\ + :ac=+\020\054\021-\036.^_0\215`\004a\237f\234g\232h\222i\220j\205k\203l\202m\204n\212o\213p\216q\0r\217s\214t\206u\207v\210w\211x\201y\230z\231{\267|\274}L~\225:\ + :ae=\E[10m:as=\E[11m: + +# ANSI.SYS color control. The setab/setaf caps depend on the coincidence +# between SVr4/XPG4's color numbers and ANSI.SYS attributes. Here are longer +# but equivalent strings that don't rely on that coincidence: +# 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, +# The DOS 5 manual asserts that these sequences meet the ISO 6429 standard. +# They match a subset of ECMA-48. +klone+color|color control for ansi.sys and ISO6429-compatible displays:\ + :Co#8:NC#3:pa#64:\ + :AB=\E[4%p1%dm:AF=\E[3%p1%dm:op=\E[37;40m: + +# This is better than klone+color, it doesn't assume white-on-black as the +# default color pair, but many `ANSI' terminals don't grok the <op> cap. +ecma+color|color control for ECMA-48-compatible terminals:\ + :Co#8:NC#3:pa#64:\ + :AB=\E[4%p1%dm:AF=\E[3%p1%dm:op=\E[39;49m: + +# Attribute control for ECMA-48-compatible terminals +ecma+sgr|attribute capabilities for true ECMA-48 terminals:\ + :se=\E[27m:ue=\E[24m:\ + :tc=klone+sgr: + +# For comparison, here are all the capabilities implied by the Intel +# Binary Compatibility Standard (level 2) that fit within terminfo. +# For more detail on this rather pathetic standard, see the comments +# near the end of this file. +ibcs2|Intel Binary Compatibility Standard prescriptions:\ + :AL=\E[%dL:DC=\E[%dP:DO=\E[%dB:IC=\E[%d@:LE=\E[%dD:\ + :RA=\E[?7l:RI=\E[%dC:S1=\E=%p1%dg:SA=\E[?7h:SF=\E[%dS:\ + :SR=\E[%dT:UP=\E[%dA:bt=\E[Z:ch=\E[%i%dG:cl=\Ec:\ + :cm=\E[%i%d;%dH:ct=\E[g:cv=\E[%i%dd:ec=\E[%dX:ei=:im=:\ + :rc=\E7:sc=\E7:st=\EH: + +#### ANSI/ECMA-48 terminals and terminal emulators +# +# See near the end of this file for details on ANSI conformance. +# Don't mess with these entries! Lots of other entries depend on them! +# +# This section lists entries in a least-capable to most-capable order. +# if you're in doubt about what `ANSI' matches yours, try them in that +# order and back off from the first that breaks. + +# ansi-mr is for ANSI terminals with ONLY relative cursor addressing +# and more than one page of memory. It uses local motions instead of +# direct cursor addressing, and makes almost no assumptions. It does +# assume auto margins, no padding and/or xon/xoff, and a 24x80 screen. +ansi-mr|mem rel cup ansi:\ + :am:xo:\ + :co#80:li#24:tc=vanilla:tc=ansi+erase:tc=ansi+local1: + +# ansi-mini is a bare minimum ANSI terminal. This should work on anything, but +# beware of screen size problems and memory relative cursor addressing. +ansi-mini|minimum ansi standard terminal:\ + :am:xo:\ + :co#80:li#24:tc=vanilla:tc=ansi+cup:tc=ansi+erase: + +# ansi-mtabs adds relative addressing and minimal tab support +ansi-mtabs|any ansi terminal with pessimistic assumptions:\ + :it#8:\ + :ta=^I:tc=ansi+local1:tc=ansi-mini: + +# ANSI X3.64 from emory!mlhhh (Hugh Hansard) via BRL +# +# The following is an entry for the full ANSI 3.64 (1977). It lacks +# padding, but most terminals using the standard are "fast" enough +# not to require any -- even at 9600 bps. If you encounter problems, +# try including the padding specifications. +# +# Note: the :as: and :ae: specifications are not implemented here, for +# the available termcap documentation does not make clear WHICH alternate +# character set to specify. ANSI 3.64 seems to make allowances for several. +# Please make the appropriate adjustments to fit your needs -- that is +# if you will be using alternate character sets. +# +# There are very few terminals running the full ANSI 3.64 standard, +# so I could only test this entry on one verified terminal (Visual 102). +# I would appreciate the results on other terminals sent to me. +# +# Please report comments, changes, and problems to: +# +# U.S. MAIL: Hugh Hansard +# Box: 22830 +# Emory University +# Atlanta, GA. 30322. +# +# USENET {akgua,msdc,sb1,sb6,gatech}!emory!mlhhh. +# +# (Added vt100 :rc:,:sc: to quiet a tic warning --esr) +ansi77|ansi 3.64 standard 1977 version:\ + :am:bs:mi:\ + :co#80:it#8:li#24:\ + :al=5*\E[L:bl=^G:cd=\E[J:ce=\E[K:cl=\E[;H\E[2J:\ + :cm=\E[%i%d;%dH:cr=^M:cs=\E[%i%d;%dr:dc=\E[P:dl=5*\E[M:\ + :do=\E[B:ei=\E[4l:ho=\E[H:im=\E[4h:k1=\EOP:k2=\EOR:k4=\EOS:\ + :kb=^H:kd=\E[B:kh=\E[H:kl=\E[D:kr=\E[C:ku=\E[A:le=^H:\ + :nd=\E[C:nw=^M\ED:rc=\E8:sc=\E7:se=\E[m:sf=\ED:so=\E[7m:\ + :sr=\EM:ta=^I:ue=\E[m:up=\E[A:us=\E[4m: + +# Procomm and some other ANSI emulations don't recognize all of the ANSI- +# standard capabilities. This entry deletes :UP:, :RI:, :DO:, :LE:, and +# <vpa>/<hpa> capabilities, forcing curses to use repetitions of :up:, +# :nd:, :do: and :le:. Also deleted :IC: and :ic:, as QModem up to +# 5.03 doesn't recognize these. Finally, we delete :rp: and :sr:, which seem +# to confuse many emulators. On the other hand, we can count on these programs +# doing :ae:/:as:/:sa:. Older versions of this entry featured +# <invis=\E[9m>, but <invis=\E[8m> now seems to be more common under +# ANSI.SYS influence. +# From: Eric S. Raymond <esr@snark.thyrsus.com> Oct 30 1995 +pcansi-m|pcansi-mono|ibm-pc terminal programs claiming to be ansi (mono mode):\ + :am:bs:mi:ms:\ + :co#80:it#8:li#24:\ + :al=\E[L:bl=^G:bt=\E[Z:cd=\E[J:ce=\E[K:cl=\E[H\E[J:\ + :cm=\E[%i%d;%dH:cr=^M:ct=\E[2g:dc=\E[P:dl=\E[M:do=\E[B:\ + :ho=\E[H:kb=^H:kd=\E[B:kh=\E[H:kl=\E[D:kr=\E[C:ku=\E[A:\ + :le=\E[D:nd=\E[C:sf=^J:st=\EH:ta=^I:up=\E[A:\ + :tc=klone+sgr-dumb: +pcansi-25-m|pcansi25m|ibm-pc terminal programs with 25 lines (mono mode):\ + :li#25:tc=pcansi-m: +pcansi-33-m|pcansi33m|ibm-pc terminal programs with 33 lines (mono mode):\ + :li#33:tc=pcansi-m: +pcansi-43-m|ansi43m|ibm-pc terminal programs with 43 lines (mono mode):\ + :li#43:tc=pcansi-m: +# The color versions. All PC emulators do color... +pcansi|ibm-pc terminal programs claiming to be ansi:\ + :tc=klone+color:tc=pcansi-m: +pcansi-25|pcansi25|ibm-pc terminal programs with 25 lines:\ + :li#25:tc=pcansi: +pcansi-33|pcansi33|ibm-pc terminal programs with 33 lines:\ + :li#33:tc=pcansi: +pcansi-43|pcansi43|ibm-pc terminal programs with 43 lines:\ + :li#43:tc=pcansi: + +# ansi-m -- full ANSI X3.64 with ANSI.SYS-compatible attributes, no color. +# If you want pound signs rather than dollars, replace `B' with `A' +# in the <s0ds>, <s1ds>, <s2ds>, and <s3ds> capabilities. +# From: Eric S. Raymond <esr@snark.thyrsus.com> Nov 6 1995 +ansi-m|ansi-mono|ANSI X3.64-1979 terminal with ANSI.SYS compatible attributes:\ + :5i:\ + :AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:IC=\E[%d@:\ + :LE=\E[%dD:RI=\E[%dC:SF=\E[%dS:SR=\E[%dT:UP=\E[%dA:\ + :cb=\E[1K:ch=\E[%i%dG:ct=\E[2g:cv=\E[%i%dd:ec=\E[%dX:ei=:\ + :im=:kB=\E[Z:kI=\E[L:kb=^H:kd=\E[B:kl=\E[D:kr=\E[C:ku=\E[A:\ + :nw=\r\E[S:pf=\E[4i:po=\E[5i:..rp=%p1%c\E[%p2%{1}%-%db:\ + :s0=\E(B:s1=\E)B:s2=\E*B:s3=\E+B:ta=\E[I:\ + :tc=pcansi-m: + +# ansi -- this terminfo expresses the largest subset of X3.64 that will fit in +# standard terminfo. Assumes ANSI.SYS-compatible attributes and color. +# From: Eric S. Raymond <esr@snark.thyrsus.com> Nov 6 1995 +ansi|ansi/pc-term compatible with color:\ + :u6=\E[%i%d;%dR:u7=\E[6n:..u8=\E[?%[;0123456789]c:\ + :u9=\E[c:\ + :tc=ecma+color:tc=klone+sgr:tc=ansi-m: + +# ansi-generic is a vanilla ANSI terminal. This is assumed to implement +# all the normal ANSI stuff with no extensions. It assumes +# insert/delete line/char is there, so it won't work with +# vt100 clones. It assumes video attributes for bold, blink, +# underline, and reverse, which won't matter much if the terminal +# can't do some of those. Padding is assumed to be zero, which +# shouldn't hurt since xon/xoff is assumed. +ansi-generic|generic ansi standard terminal:\ + :am:xo:\ + :co#80:li#24:tc=vanilla:tc=ansi+csr:tc=ansi+cup:\ + :tc=ansi+rca:tc=ansi+erase:tc=ansi+tabs:tc=ansi+local:\ + :tc=ansi+idc:tc=ansi+idl:tc=ansi+rep:tc=ansi+sgrbold:\ + :tc=ansi+arrows: + +#### Linux consoles +# + +# This entry is good for the 1.2.13 or later version of the Linux console. +# +# *************************************************************************** +# * * +# * WARNING: * +# * Linuxes come with a default keyboard mapping kcbt=^I. This entry, in * +# * response to user requests, assumes kcbt=\E[Z, the ANSI/ECMA reverse-tab * +# * character. Here are the keymap replacement lines that will set this up: * +# * * +# keycode 15 = Tab Tab +# alt keycode 15 = Meta_Tab +# shift keycode 15 = F26 +# string F26 ="\033[Z" +# * * +# * This has to use a key slot which is unfortunate (any unused one will * +# * do, F26 is the higher-numbered one). The change ought to be built * +# * into the kernel tables. * +# * * +# *************************************************************************** +# +# The 1.3.x kernels add color-change capabilities; if yours doesn't have this +# and it matters, turn off <ccc>. The %02x escape used to implement this is +# not back-portable to SV curses and not supported in ncurses versions before +# 1.9.9. All linux kernels since 1.2.13 (at least) set the screen size +# themselves; this entry assumes that capability. +# +# This entry is good for the 1.2.13 or later version of the Linux console. +# +# *************************************************************************** +# * * +# * WARNING: * +# * Linuxes come with a default keyboard mapping kcbt=^I. This entry, in * +# * response to user requests, assumes kcbt=\E[Z, the ANSI/ECMA reverse-tab * +# * character. Here are the keymap replacement lines that will set this up: * +# * * +# keycode 15 = Tab Tab +# alt keycode 15 = Meta_Tab +# shift keycode 15 = F26 +# string F26 ="\033[Z" +# * * +# * This has to use a key slot which is unfortunate (any unused one will * +# * do, F26 is the higher-numbered one). The change ought to be built * +# * into the kernel tables. * +# * * +# *************************************************************************** +# +# The 1.3.x kernels add color-change capabilities; if yours doesn't have this +# and it matters, turn off <ccc>. The %02x escape used to implement this is +# not back-portable to SV curses and not supported in ncurses versions before +# 1.9.9. All linux kernels since 1.2.13 (at least) set the screen size +# themselves; this entry assumes that capability. +# +# The 2.2.x kernels add a private mode that sets the cursor type; use that to +# get a block cursor for cvvis. +# reported by Frank Heckenbach <frank@g-n-u.de>. +# (untranslatable capabilities removed to fit entry within 1023 bytes) +# (sgr removed to fit entry within 1023 bytes) +# (terminfo-only capabilities suppressed to fit entry within 1023 bytes) +linux|linux console:\ + :am:eo:mi:ms:xn:xo:\ + :it#8:\ + :AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:IC=\E[%d@:K2=\E[G:al=\E[L:\ + :bl=^G:cd=\E[J:ce=\E[K:cl=\E[H\E[J:cm=\E[%i%d;%dH:cr=^M:\ + :cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:do=^J:ec=\E[%dX:\ + :ei=\E[4l:ho=\E[H:ic=\E[@:im=\E[4h:k1=\E[[A:k2=\E[[B:\ + :k3=\E[[C:k4=\E[[D:k5=\E[[E:k6=\E[17~:k7=\E[18~:k8=\E[19~:\ + :k9=\E[20~:kD=\E[3~:kI=\E[2~:kN=\E[6~:kP=\E[5~:kb=\177:\ + :kd=\E[B:kh=\E[1~:kl=\E[D:kr=\E[C:ku=\E[A:le=^H:mh=\E[2m:\ + :mr=\E[7m:nd=\E[C:nw=^M^J:rc=\E8:sc=\E7:se=\E[27m:sf=^J:\ + :sr=\EM:st=\EH:ta=^I:ue=\E[24m:up=\E[A:us=\E[4m:\ + :vb=200\E[?5h\E[?5l:ve=\E[?25h\E[?0c:vi=\E[?25l\E[?1c:\ + :vs=\E[?25h\E[?8c:\ + :tc=klone+sgr:tc=ecma+color: +linux-m|Linux console no color:\ + :Co@:pa@:\ + :AB@:AF@:Sb@:Sf@:tc=linux: +linux-c-nc|linux console 1.3.x hack for ncurses only:\ + :cc:\ + :..Ic=\E]P%p1%x%p2%{255}%*%{1000}%/%02x%p3%{255}%*%{1000}%/%02x%p4%{255}%*%{1000}%/%02x:\ + :oc=\E]R:\ + :tc=linux: +# From: Dennis Henriksen <opus@osrl.dk>, 9 July 1996 +linux-c|linux console 1.3.6+ with private palette for each virtual console:\ + :cc:\ + :Co#8:pa#64:\ + :..Ic=\E]P%?%p1%{9}%>%t%p1%{10}%-%'a'%+%c%e%p1%d%;%p2%{255}%&%Pr%gr%{16}%/%Px%?%gx%{9}%>%t%gx%{10}%-%'A'%+%c%e%gx%d%;%gr%{15}%&%Px%?%gx%{9}%>%t%gx%{10}%-%'A'%+%c%e%gx%d%;%p3%{255}%&%Pr%gr%{16}%/%Px%?%gx%{9}%>%t%gx%{10}%-%'A'%+%c%e%gx%d%;%gr%{15}%&%Px%?%gx%{9}%>%t%gx%{10}%-%'A'%+%c%e%gx%d%;%p4%{255}%&%Pr%gr%{16}%/%Px%?%gx%{9}%>%t%gx%{10}%-%'A'%+%c%e%gx%d%;%gr%{15}%&%Px%?%gx%{9}%>%t%gx%{10}%-%'A'%+%c%e%gx%d%;:\ + :oc=\E]R:\ + :tc=linux: + +# See the note on ICH/ICH1 VERSUS RMIR/SMIR near the end of file +linux-nic|linux with ich/ich1 suppressed for non-curses programs:\ + :IC@:ei=:ic@:im=:\ + :tc=linux: + +# This assumes you have used setfont(8) to load one of the Linux koi8-r fonts. +# acsc entry from Pavel Roskin" <pavel@absolute.spb.su>, 29 Sep 1997. +linux-koi8|linux with koi8 alternate character set:\ + :ac=+\020\054\021-\030.^Y0\215`\004a\221f\234g\237h\220i\276j\205k\203l\202m\204n\212o~p\0q\0r\0s_t\206u\207v\211w\210x\201y\230z\231{\267|\274~\224:tc=linux:\ + :tc=klone+koi8acs: + +# Another entry for KOI8-r with Qing Long's acsc. +# (which one better complies with the standard?) +linux-koi8r|linux with koi8-r alternate character set:\ + :tc=linux:tc=klone+koi8acs: + +# Entry for the latin1 and latin2 fonts +linux-lat|linux with latin1 or latin2 alternate character set:\ + :ac=+\020\054\021-\030.^Y0\333`\004a\013f\370g\361h\260i\316j\211k\214l\206m\203n\305o~p\304q\212r\304s_t\207u\215v\301w\302x\205y\363z\362{\343|\330}\234~\376:\ + :tc=linux: + +#### NetBSD consoles +# +# pcvt termcap database entries (corresponding to release 3.31) +# Author's last edit-date: [Fri Sep 15 20:29:10 1995] +# +# (For the terminfo master file, I translated these into terminfo syntax. +# Then I dropped all the pseudo-HP entries. we don't want and can't use +# the :Xs: flag. Then I split :is: into a size-independent :i1: and a +# size-dependent :is:. Finally, I added <rmam>/<smam> -- esr) + +# NOTE: :ic: has been taken out of this entry. for reference, it should +# be <ich1=\E[@>. For discussion, see ICH/ICH1 VERSUS RMIR/SMIR below. +# (esr: added :vi: and :ve: to resolve NetBSD Problem Report #4583) +pcvtXX|pcvt vt200 emulator (DEC VT220):\ + :am:km:mi:ms:xn:\ + :it#8:vt#3:\ + :AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:IC=\E[%d@:\ + :LE=\E[%dD:RA=\E[?7l:RI=\E[%dC:SA=\E[?7h:SF=\E[%dS:\ + :SR=\E[%dT:UP=\E[%dA:\ + :ac=++\054\054--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz~~:\ + :ae=\E(B:al=\E[L:as=\E(0:bl=^G:cb=\E[1K:cd=\E[J:ce=\E[K:\ + :cl=\E[H\E[J:cm=\E[%i%d;%dH:cr=^M:cs=\E[%i%d;%dr:\ + :ct=\E[3g:dc=\E[P:dl=\E[M:do=\E[B:ei=\E[4l:ho=\E[H:\ + :i1=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h:im=\E[4h:\ + :k1=\E[17~:k2=\E[18~:k3=\E[19~:k4=\E[20~:k5=\E[21~:\ + :k6=\E[23~:k7=\E[24~:k8=\E[25~:kD=\E[3~:kH=\E[4~:kI=\E[2~:\ + :kN=\E[6~:kP=\E[5~:kb=\177:kd=\EOB:ke=\E[?1l\E>:kh=\E[1~:\ + :kl=\EOD:kr=\EOC:ks=\E[?1h\E=:ku=\EOA:le=^H:mb=\E[5m:\ + :md=\E[1m:me=\E[m:mr=\E[7m:nd=\E[C:nw=\EE:\ + :r1=\Ec\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h:rc=\E8:\ + :rf=/usr/share/tabset/vt100:sc=\E7:se=\E[27m:sf=\ED:\ + :so=\E[7m:sr=\EM:st=\EH:ta=^I:ue=\E[24m:up=\E[A:us=\E[4m:\ + :ve=\E[?25h:vi=\E[?25l: + +# NetBSD/FreeBSD vt220 terminal emulator console (pc keyboard & monitor) +# termcap entries for pure VT220-Emulation and 25, 28, 35, 40, 43 and +# 50 lines entries; 80 columns +pcvt25|dec vt220 emulation with 25 lines:\ + :co#80:li#25:\ + :is=\E[1;25r\E[25;1H:tc=pcvtXX: +pcvt28|dec vt220 emulation with 28 lines:\ + :co#80:li#28:\ + :is=\E[1;28r\E[28;1H:tc=pcvtXX: +pcvt35|dec vt220 emulation with 35 lines:\ + :co#80:li#35:\ + :is=\E[1;35r\E[35;1H:tc=pcvtXX: +pcvt40|dec vt220 emulation with 40 lines:\ + :co#80:li#40:\ + :is=\E[1;40r\E[40;1H:tc=pcvtXX: +pcvt43|dec vt220 emulation with 43 lines:\ + :co#80:li#43:\ + :is=\E[1;43r\E[43;1H:tc=pcvtXX: +pcvt50|dec vt220 emulation with 50 lines:\ + :co#80:li#50:\ + :is=\E[1;50r\E[50;1H:tc=pcvtXX: + +# NetBSD/FreeBSD vt220 terminal emulator console (pc keyboard & monitor) +# termcap entries for pure VT220-Emulation and 25, 28, 35, 40, 43 and +# 50 lines entries; 132 columns +pcvt25w|dec vt220 emulation with 25 lines and 132 cols:\ + :co#132:li#25:\ + :is=\E[1;25r\E[25;1H:tc=pcvtXX: +pcvt28w|dec vt220 emulation with 28 lines and 132 cols:\ + :co#132:li#28:\ + :is=\E[1;28r\E[28;1H:tc=pcvtXX: +pcvt35w|dec vt220 emulation with 35 lines and 132 cols:\ + :co#132:li#35:\ + :is=\E[1;35r\E[35;1H:tc=pcvtXX: +pcvt40w|dec vt220 emulation with 40 lines and 132 cols:\ + :co#132:li#40:\ + :is=\E[1;40r\E[40;1H:tc=pcvtXX: +pcvt43w|dec vt220 emulation with 43 lines and 132 cols:\ + :co#132:li#43:\ + :is=\E[1;43r\E[43;1H:tc=pcvtXX: +pcvt50w|dec vt220 emulation with 50 lines and 132 cols:\ + :co#132:li#50:\ + :is=\E[1;50r\E[50;1H:tc=pcvtXX: + +# Terminfo entries to enable the use of the ncurses library in colour on a +# NetBSD-arm32 console (only tested on a RiscPC). +# Created by Dave Millen <dmill@globalnet.co.uk> 22.07.98 +# modified codes for setf/setb to setaf/setab, then to klone+color, corrected +# typo in invis - TD +arm100|arm100-am|Arm(RiscPC) ncurses compatible (for 640x480):\ + :am:ms:ut:xn:xo:\ + :co#80:it#8:li#30:\ + :@8=\E[M:DO=\E[%dB:K1=\E[q:K2=\E[r:K3=\E[s:K4=\E[p:K5=\E[n:\ + :LE=\E[%dD:RA=\E[?7l:RI=\E[%dC:SA=\E[?7h:UP=\E[%dA:\ + :ac=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~:\ + :ae=^O:as=^N:bl=^G:cb=\E[1K:cd=\E[J:ce=\E[K:cl=\E[H\E[J:\ + :cm=\E[%i%d;%dH:cr=^M:cs=\E[%i%d;%dr:ct=\E[3g:do=^J:\ + :eA=\E(B\E)0:ho=\E[H:k0=\E[y:k1=\E[P:k2=\E[Q:k3=\E[R:\ + :k4=\E[S:k5=\E[t:k6=\E[u:k7=\E[v:k8=\E[l:k9=\E[w:k;=\E[x:\ + :kb=^H:kd=\E[B:ke=\E[?1l\E>:kl=\E[D:kr=\E[C:ks=\E[?1h\E=:\ + :ku=\E[A:le=^H:mb=\E[5m:md=\E[1m:me=\E[m\017:mk=\E[8m:\ + :mr=\E[6m:nd=\E[C:r2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h:\ + :rc=\E8:\ + :..sa=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;:\ + :sc=\E7:se=\E[m:sf=^J:so=\E[7m:sr=\EM:st=\EH:ta=^I:ue=\E[m:\ + :up=\E[A:us=\E[4m:\ + :tc=ecma+sgr:tc=klone+color: +arm100-w|arm100-wam|Arm(RiscPC) ncurses compatible (for 1024x768):\ + :co#132:li#50:tc=arm100: + +# NetBSD/x68k console vt200 emulator. This port runs on a 68K machine +# manufactured by Sharp for the Japenese market. +# From Minoura Makoto <minoura@netlaputa.or.jp>, 12 May 1996 +x68k|x68k-ite|NetBSD/x68k ITE:\ + :co#96:li#32:\ + :%1=\E[28~:kC=\E[9~:tc=vt220: + +# <tv@pobox.com>: +# Entry for the DNARD OpenFirmware console, close to ANSI but not quite. +# +# (still unfinished, but good enough so far.) +ofcons:\ + :bw:\ + :co#80:li#30:\ + :AL=\233%dL:DC=\233%dP:DL=\233%dM:DO=\233%dB:IC=\233%d@:\ + :LE=\233%dD:RI=\233%dC:UP=\233%dA:al=\233L:bl=^G:cd=\233J:\ + :ce=\233K:cl=^L:cm=\233%i%d;%dH:cr=^M:dc=\233P:dl=\233M:\ + :do=\233B:ei=:ic=\233@:im=:k1=\2330P:k2=\2330Q:k3=\2330W:\ + :k4=\2330x:k5=\2330t:k6=\2330u:k7=\2330q:k8=\2330r:\ + :k9=\2330p:k;=\2330M:kD=\233P:kN=\233/:kP=\233?:kb=^H:\ + :kd=\233B:kl=\233D:kr=\233C:ku=\233A:le=\233D:mb=\2337;2m:\ + :md=\2331m:me=\2330m:mh=\2332m:mk=\2338m:mr=\2337m:\ + :nd=\233C:nw=^M^J:se=\2330m:sf=^J:ta=^I:ue=\2330m:up=\233A:\ + :vb=^G: + +# NetBSD "wscons" emulator in vt220 mode +# These are micro-minimal and probably need to be redone for real +# after the manner of the pcvt entries. +wsvt25|NetBSD wscons in 25 line DEC VT220 mode:\ + :co#80:li#25:tc=vt220: + +wsvt25m|NetBSD wscons in 25 line DEC VT220 mode with Meta:\ + :km:\ + :co#80:li#25:tc=vt220: + +# `rasterconsole' provided by 4.4BSD, NetBSD and OpenBSD on SPARC, and +# DECstation/pmax. +rcons|BSD rasterconsole:\ + :tc=sun-il: +# Color version of above. Color currenly only provided by NetBSD. +rcons-color|BSD rasterconsole with ANSI color:\ + :ut:\ + :Co#8:pa#64:\ + :AB=\E[4%dm:AF=\E[3%dm:op=\E[m:tc=rcons: + +#### FreeBSD console entries +# +# From: Andrey Chernov <ache@astral.msk.su> 29 Mar 1996 +# Andrey Chernov maintains the FreeBSD termcap distributions. +# +# Note: Users of FreeBSD 2.1.0 and older versions must either upgrade +# or comment out the :cb: capability in the console entry. +# +# Alexander Lukyanov reports: +# I have seen FreeBSD-2.1.5R... The old el1 bug changed, but it is still there. +# Now el1 clears not only to the line beginning, but also a large chunk +# of previous line. But there is another bug - ech does not work at all. +# + +# for syscons +# common entry without semigraphics +# Bug: The <op> capability resets attributes. +# Bug? The ech and el1 attributes appear to move the cursor in some cases; for +# instance el1 does if the cursor is moved to the right margin first. Removed +# by T.Dickey 97/5/3 (ech=\E[%p1%dX, el1=\E[1K) +# +# Setting colors turns off reverse; we cannot guarantee order, so use ncv. +# Note that this disables standout with color. +cons25w|ansiw|ansi80x25-raw|freebsd console (25-line raw mode):\ + :NP:am:bw:eo:ms:ut:\ + :Co#8:NC#21:co#80:it#8:li#25:pa#64:\ + :@7=\E[F:AB=\E[4%p1%dm:AF=\E[3%p1%dm:AL=\E[%dL:DC=\E[%dP:\ + :DL=\E[%dM:DO=\E[%dB:F1=\E[W:F2=\E[X:IC=\E[%d@:K2=\E[E:\ + :LE=\E[%dD:RI=\E[%dC:SF=\E[%dS:SR=\E[%dT:UP=\E[%dA:\ + :al=\E[L:bl=^G:bt=\E[Z:cd=\E[J:ce=\E[K:ch=\E[%i%d`:\ + :cl=\E[H\E[J:cm=\E[%i%d;%dH:cr=^M:cv=\E[%i%dd:dc=\E[P:\ + :dl=\E[M:do=\E[B:ei=:ho=\E[H:ic=\E[@:im=:k1=\E[M:k2=\E[N:\ + :k3=\E[O:k4=\E[P:k5=\E[Q:k6=\E[R:k7=\E[S:k8=\E[T:k9=\E[U:\ + :k;=\E[V:kB=\E[Z:kD=\177:kI=\E[L:kN=\E[G:kP=\E[I:kb=^H:\ + :kd=\E[B:kh=\E[H:kl=\E[D:kr=\E[C:ku=\E[A:le=^H:mb=\E[5m:\ + :md=\E[1m:me=\E[m:mh=\E[30;1m:mr=\E[7m:nd=\E[C:nw=\E[E:\ + :op=\E[x:r1=\E[x\E[m\Ec:se=\E[m:sf=\E[S:so=\E[7m:sr=\E[T:\ + :ta=^I:up=\E[A:ve=\E[=0C:vs=\E[=1C: +cons25|ansis|ansi80x25|freebsd console (25-line ansi mode):\ + :ac=-\030.^Y0\333`\004a\260f\370g\361h\261i\025j\331k\277l\332m\300n\305q\304t\303u\264v\301w\302x\263y\363z\362~\371:\ + :tc=cons25w: +cons25-m|ansis-mono|ansi80x25-mono|freebsd console (25-line mono ansi mode):\ + :Co@:pa@:\ + :AB@:AF@:md@:mh@:op@:ue=\E[m:us=\E[4m:tc=cons25: +cons30|ansi80x30|freebsd console (30-line ansi mode):\ + :li#30:tc=cons25: +cons30-m|ansi80x30-mono|freebsd console (30-line mono ansi mode):\ + :li#30:tc=cons25-m: +cons43|ansi80x43|freebsd console (43-line ansi mode):\ + :li#43:tc=cons25: +cons43-m|ansi80x43-mono|freebsd console (43-line mono ansi mode):\ + :li#43:tc=cons25-m: +cons50|ansil|ansi80x50|freebsd console (50-line ansi mode):\ + :li#50:tc=cons25: +cons50-m|ansil-mono|ansi80x50-mono|freebsd console (50-line mono ansi mode):\ + :li#50:tc=cons25-m: +cons60|ansi80x60|freebsd console (60-line ansi mode):\ + :li#60:tc=cons25: +cons60-m|ansi80x60-mono|freebsd console (60-line mono ansi mode):\ + :li#60:tc=cons25-m: +cons25r|pc3r|ibmpc3r|cons25-koi8-r|freebsd console w/koi8-r cyrillic:\ + :ac=-\030.^Y0\215`\004a\220f\234h\221i\025j\205k\203l\202m\204n\212q\0t\206u\207v\211w\210x\201y\230z\231~\225:\ + :tc=cons25w: +cons25r-m|pc3r-m|ibmpc3r-mono|cons25-koi8r-m|freebsd console w/koi8-r cyrillic (mono):\ + :Co@:pa@:\ + :AB@:AF@:op@:ue=\E[m:us=\E[4m:tc=cons25r: +cons50r|cons50-koi8r|freebsd console w/koi8-r cyrillic (50 lines):\ + :li#50:tc=cons25r: +cons50r-m|cons50-koi8r-m|freebsd console w/koi8-r cyrillic (50-line mono):\ + :li#50:tc=cons25r-m: +cons60r|cons60-koi8r|freebsd console w/koi8-r cyrillic (60 lines):\ + :li#60:tc=cons25r: +cons60r-m|cons60-koi8r-m|freebsd console w/koi8-r cyrillic (60-line mono):\ + :li#60:tc=cons25r-m: +# ISO 8859-1 FreeBSD console +cons25l1|cons25-iso8859|freebsd console w/iso 8859-1 chars:\ + :ac=+\253\054\273-\030.\031`\201a\202f\207g\210i\247j\213k\214l\215m\216n\217o\220p\221q\222r\223s\224t\225u\226v\227w\230x\231y\232z\233~\237:\ + :tc=cons25w: +cons25l1-m|cons25-iso-m|freebsd console w/iso 8859-1 chars (mono):\ + :Co@:pa@:\ + :AB@:AF@:md@:mh@:op@:ue=\E[m:us=\E[4m:tc=cons25l1: +cons50l1|cons50-iso8859|freebsd console w/iso 8859-1 chars (50 lines):\ + :li#50:tc=cons25l1: +cons50l1-m|cons50-iso-m|freebsd console w/iso 8859-1 chars (50-line mono):\ + :li#50:tc=cons25l1-m: +cons60l1|cons60-iso|freebsd console w/iso 8859-1 chars (60 lines):\ + :li#60:tc=cons25l1: +cons60l1-m|cons60-iso-m|freebsd console w/iso 8859-1 chars (60-line mono):\ + :li#60:tc=cons25l1-m: + +#### 386BSD and BSD/OS Consoles +# + +# This was the original 386BSD console entry (I think). +# Some places it's named oldpc3|oldibmpc3. +# From: Alex R.N. Wetmore <aw2t@andrew.cmu.edu> +origpc3|origibmpc3|IBM PC 386BSD Console:\ + :am:bw:eo:xo:\ + :co#80:li#25:\ + :ac=j\331k\277l\332m\300n\305q\304t\303u\264v\301w\302x\263:\ + :cd=\E[J:ce=\E[K:cl=\Ec:cm=\E[%i%2;%2H:do=\E[B:ho=\E[H:\ + :kd=\E[B:kh=\E[Y:kl=\E[D:kr=\E[C:ku=\E[A:le=^H:md=\E[7m:\ + :me=\E[m\E[1;0x\E[2;7x:nd=\E[C:se=\E[1;0x\E[2;7x:\ + :sf=\E[S:so=\E[1;7x\E[2;0x:sr=\E[T:ue=\E[1;0x\E[2;7x:\ + :up=\E[A:us=\E[1;7x\E[2;0x: + +# description of BSD/386 console emulator in version 1.0 (supplied by BSDI) +oldpc3|oldibmpc3|old IBM PC BSD/386 Console:\ + :km:\ + :li#25:\ + :al=\E[L:bl=^G:cr=^M:dl=\E[M:do=^J:kH=\E[F:kI=\E[L:kN=\E[G:\ + :kP=\E[I:kb=^H:kd=\E[B:kh=\E[H:kl=\E[D:kr=\E[C:ku=\E[A:\ + :md=\E[=15F:me=\E[=R:mh=\E[=8F:nw=^M^J:sf=^J:ta=^I: + +# Description of BSD/OS console emulator in version 1.1, 2.0, 2.1 +# Note, the emulator supports many of the additional console features +# listed in the iBCS2 (e.g. character-set selection) though not all +# are described here. This entry really ought to be upgraded. +# Also note, the console will also work with fewer lines after doing +# "stty rows NN", e.g. to use 24 lines. +# (Color support from Kevin Rosenberg <kevin@cyberport.com>, 2 May 1996) +# Bug: The <op> capability resets attributes. +bsdos-pc-nobold|BSD/OS PC console w/o bold:\ + :am:eo:km:xo:\ + :co#80:it#8:li#25:\ + :AL=\E[%dL:DL=\E[%dM:DO=\E[%dB:LE=\E[%dD:RI=\E[%dC:\ + :UP=\E[%dA:al=\E[L:bl=^G:cd=\E[J:ce=\E[K:cl=\Ec:\ + :cm=\E[%i%d;%dH:cr=^M:dl=\E[M:do=^J:ho=\E[H:kH=\E[F:\ + :kI=\E[L:kN=\E[G:kP=\E[I:kb=^H:kd=\E[B:kh=\E[H:kl=\E[D:\ + :kr=\E[C:ku=\E[A:le=^H:nd=\E[C:nw=^M^J:rc=\E8:\ + :..sa=\E[0;10%?%p1%t;7%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;m%?%p5%t\E[=8F%;:\ + :sc=\E7:sf=^J:ta=^I:up=\E[A:\ + :tc=klone+sgr:tc=klone+color: +bsdos-pc|IBM PC BSD/OS Console:\ + :..sa=\E[0;10%?%p1%t;7%;%?%p2%t;1%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;m:tc=bsdos-pc-nobold: + +# Old names for BSD/OS PC console used in releases before 4.1. +pc3|BSD/OS on the PC Console:\ + :tc=bsdos-pc-nobold: +ibmpc3|pc3-bold|BSD/OS on the PC Console with bold instead of underline:\ + :tc=bsdos-pc: + +# BSD/OS on the SPARC +bsdos-sparc|Sun SPARC BSD/OS Console:\ + :tc=sun: + +# BSD/OS on the PowerPC +bsdos-ppc|PowerPC BSD/OS Console:\ + :tc=bsdos-pc: + +#### DEC VT100 and compatibles +# +# DEC terminals from the vt100 forward are collected here. Older DEC terminals +# and micro consoles can be found in the `obsolete' section. More details on +# the relationship between the VT100 and ANSI X3.64/ISO 6429/ECMA-48 may be +# found near the end of this file. +# +# Except where noted, these entries are DEC's official terminfos. +# Contact Bill Hedberg <hedberg@hannah.enet.dec.com> of Terminal Support +# Engineering for more information. Updated terminfos and termcaps +# are kept available at ftp://gatekeeper.dec.com/pub/DEC/termcaps. +# +# In October 1995 DEC sold its terminals business, including the VT and Dorio +# line and trademark, to SunRiver Data Systems. SunRiver has since changed +# its name to Boundless Technologies; see http://www.boundless.com. +# + +# NOTE: Any VT100 emulation, whether in hardware or software, almost +# certainly includes what DEC called the `Level 1 editing extension' codes; +# only the very oldest VT100s lacked these and there probably aren't any of +# those left alive. To capture these, use one of the VT102 entries. +# +# Note that the :xn: glitch in vt100 is not quite the same as on the Concept, +# since the cursor is left in a different position while in the +# weird state (concept at beginning of next line, vt100 at end +# of this line) so all versions of vi before 3.7 don't handle +# :xn: right on vt100. The correct way to handle :xn: is when +# you output the char in column 80, immediately output CR LF +# and then assume you are in column 1 of the next line. If :xn: +# is on, am should be on too. +# +# I assume you have smooth scroll off or are at a slow enough baud +# rate that it doesn't matter (1200? or less). Also this assumes +# that you set auto-nl to "on", if you set it off use vt100-nam +# below. +# +# The padding requirements listed here are guesses. It is strongly +# recommended that xon/xoff be enabled, as this is assumed here. +# +# The vt100 uses <rs2> and <rf> rather than :is:/:ct:/:st: because the +# tab settings are in non-volatile memory and don't need to be +# reset upon login. Also setting the number of columns glitches +# the screen annoyingly. You can type "reset" to get them set. +# +# The VT100 series terminals have cursor ("arrows") keys which can operate +# in two different modes: Cursor Mode and Application Mode. Cursor Mode +# is the reset state, and is assumed to be the normal state. Application +# Mode is the "set" state. In Cursor Mode, the cursor keys transmit +# "Esc [ {code}" sequences, conforming to ANSI standards. In Application +# Mode, the cursor keys transmit "Esc O <code>" sequences. Application Mode +# was provided primarily as an aid to the porting of VT52 applications. It is +# assumed that the cursor keys are normally in Cursor Mode, and expected that +# applications such as vi will always transmit the :ks: string. Therefore, +# the definitions for the cursor keys are made to match what the terminal +# transmits after the :ks: string is transmitted. If the :ks: string +# is a null string or is not defined, then cursor keys are assumed to be in +# "Cursor Mode", and the cursor keys definitions should match that assumption, +# else the appication may fail. It is also expected that applications will +# always transmit the :ke: string to the terminal before they exit. +# +# The VT100 series terminals have an auxilliary keypad, commonly referred to as +# the "Numeric Keypad", because it is a cluster of numeric and function keys. +# The Numeric Keypad which can operate in two different modes: Numeric Mode and +# Application Mode. Numeric Mode is the reset state, and is assumed to be +# the normal state. Application Mode is the "set" state. In Numeric Mode, +# the numeric and punctuation keys transmit ASCII 7-bit characters, and the +# Enter key transmits the same as the Return key (Note: the Return key +# can be configured to send either LF (\015) or CR LF). In Application Mode, +# all the keypad keys transmit "Esc O {code}" sequences. The PF1 - PF4 keys +# always send the same "Esc O {code}" sequences. It is assumed that the keypad +# is normally in Numeric Mode. If an application requires that the keypad be +# in Application Mode then it is expected that the user, or the application, +# will set the TERM environment variable to point to a terminfo entry which has +# defined the :ks: string to include the codes that switch the keypad into +# Application Mode, and the terminfo entry will also define function key +# fields to match the Application Mode control codes. If the :ks: string +# is a null string or is not defined, then the keypad is assumed to be in +# Numeric Mode. If the :ks: string switches the keypad into Application +# Mode, it is expected that the :ke: string will contain the control codes +# necessary to reset the keypad to "Normal" mode, and it is also expected that +# applications which transmit the :ks: string will also always transmit the +# :ke: string to the terminal before they exit. +# +# Here's a diagram of the VT100 keypad keys with their bindings. +# The top line is the name of the key (some DEC keyboards have the keys +# labelled somewhat differently, like GOLD instead of PF1, but this is +# the most "official" name). The second line is the escape sequence it +# generates in Application Keypad mode (where "$" means the ESC +# character). The third line contains two items, first the mapping of +# the key in terminfo, and then in termcap. +# _______________________________________ +# | PF1 | PF2 | PF3 | PF4 | +# | $OP | $OQ | $OR | $OS | +# |_kf1__k1_|_kf2__k2_|_kf3__k3_|_kf4__k4_| +# | 7 8 9 - | +# | $Ow | $Ox | $Oy | $Om | +# |_kf9__k9_|_kf10_k;_|_kf0__k0_|_________| +# | 4 | 5 | 6 | , | +# | $Ot | $Ou | $Ov | $Ol | +# |_kf5__k5_|_kf6__k6_|_kf7__k7_|_kf8__k8_| +# | 1 | 2 | 3 | | +# | $Oq | $Or | $Os | enter | +# |_ka1__K1_|_kb2__K2_|_ka3__K3_| $OM | +# | 0 | . | | +# | $Op | $On | | +# |___kc1_______K4____|_kc3__K5_|_kent_@8_| +# +# And here, for those of you with orphaned VT100s lacking documentation, is +# a description of the soft switches invoked when you do `Set Up'. +# +# Scroll 0-Jump Shifted 3 0-# +# | 1-Smooth | 1-British pound sign +# | Autorepeat 0-Off | Wrap Around 0-Off +# | | 1-On | | 1-On +# | | Screen 0-Dark Bkg | | New Line 0-Off +# | | | 1-Light Bkg | | | 1-On +# | | | Cursor 0-Underline | | | Interlace 0-Off +# | | | | 1-Block | | | | 1-On +# | | | | | | | | +# 1 1 0 1 1 1 1 1 0 1 0 0 0 0 1 0 <--Standard Settings +# | | | | | | | | +# | | | Auto XON/XOFF 0-Off | | | Power 0-60 Hz +# | | | 1-On | | | 1-50 Hz +# | | Ansi/VT52 0-VT52 | | Bits Per Char. 0-7 Bits +# | | 1-ANSI | | 1-8 Bits +# | Keyclick 0-Off | Parity 0-Off +# | 1-On | 1-On +# Margin Bell 0-Off Parity Sense 0-Odd +# 1-On 1-Even +# +# The following SET-UP modes are assumed for normal operation: +# ANSI_MODE AUTO_XON/XOFF_ON NEWLINE_OFF 80_COLUMNS +# WRAP_AROUND_ON JUMP_SCROLL_OFF +# Other SET-UP modes may be set for operator convenience or communication +# requirements; I recommend +# AUTOREPEAT_ON BLOCK_CURSOR MARGIN_BELL_OFF SHIFTED_3_# +# Unless you have a graphics add-on such as Digital Engineering's VT640 +# (and even then, whenever it can be arranged!) you should set +# INTERLACE_OFF +# +# (vt100: I added <rmam>/<smam> based on the init string, also :bs:. -- esr) +vt100|vt100-am|dec vt100 (w/advanced video):\ + :am:bs:ms:xn:xo:\ + :co#80:it#8:li#24:vt#3:\ + :@8=\EOM:DO=\E[%dB:K1=\EOq:K2=\EOr:K3=\EOs:K4=\EOp:K5=\EOn:\ + :LE=\E[%dD:RA=\E[?7l:RI=\E[%dC:SA=\E[?7h:UP=\E[%dA:\ + :ac=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~:\ + :ae=^O:as=^N:bl=^G:cb=\E[1K:cd=\E[J:ce=\E[K:cl=\E[H\E[J:\ + :cm=\E[%i%d;%dH:cr=^M:cs=\E[%i%d;%dr:ct=\E[3g:do=^J:\ + :eA=\E(B\E)0:ho=\E[H:k0=\EOy:k1=\EOP:k2=\EOQ:k3=\EOR:\ + :k4=\EOS:k5=\EOt:k6=\EOu:k7=\EOv:k8=\EOl:k9=\EOw:k;=\EOx:\ + :kb=^H:kd=\EOB:ke=\E[?1l\E>:kl=\EOD:kr=\EOC:ks=\E[?1h\E=:\ + :ku=\EOA:le=^H:mb=\E[5m:md=\E[1m:me=\E[m\017:mr=\E[7m:\ + :nd=\E[C:r2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h:rc=\E8:\ + :..sa=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;:\ + :sc=\E7:se=\E[m:sf=^J:so=\E[7m:sr=\EM:st=\EH:ta=^I:ue=\E[m:\ + :up=\E[A:us=\E[4m: +vt100nam|vt100-nam|vt100 no automargins:\ + :am@:xn@:tc=vt100-am: +vt100-vb|dec vt100 (w/advanced video) & no beep:\ + :bl@:vb=\E[?5h\E[?5l:tc=vt100: + +# Ordinary vt100 in 132 column ("wide") mode. +vt100-w|vt100-w-am|dec vt100 132 cols (w/advanced video):\ + :co#132:li#24:\ + :r2=\E>\E[?3h\E[?4l\E[?5l\E[?8h:tc=vt100-am: +vt100-w-nam|vt100-nam-w|dec vt100 132 cols (w/advanced video no automargin):\ + :co#132:li#14:vt@:\ + :r2=\E>\E[?3h\E[?4l\E[?5l\E[?8h:tc=vt100-nam: + +# vt100 with no advanced video. +vt100-nav|vt100 without advanced video option:\ + :sg#1:\ + :mb@:md@:me@:mr@:sa@:se=\E[m:so=\E[7m:ue@:us@:tc=vt100: +vt100-nav-w|vt100-w-nav|dec vt100 132 cols 14 lines (no advanced video option):\ + :co#132:li#14:tc=vt100-nav: + +# vt100 with one of the 24 lines used as a status line. +# We put the status line on the top. +vt100-s|vt100-s-top|vt100-top-s|vt100 for use with top sysline:\ + :es:hs:\ + :li#23:\ + :cl=\E[2;1H\E[J:cm=\E[%i%+^A;%dH:cs=\E[%i%i%d;%dr:\ + :ds=\E7\E[1;24r\E8:fs=\E8:ho=\E[2;1H:is=\E7\E[2;24r\E8:\ + :ts=\E7\E[1;%p1%dH\E[1K:\ + :tc=vt100-am: + +# Status line at bottom. +# Clearing the screen will clobber status line. +vt100-s-bot|vt100-bot-s|vt100 for use with bottom sysline:\ + :es:hs:\ + :li#23:\ + :ds=\E7\E[1;24r\E8:fs=\E8:is=\E[1;23r\E[23;1H:\ + :ts=\E7\E[24;%p1%dH\E[1K:\ + :tc=vt100-am: + +# Most of the `vt100' emulators out there actually emulate a vt102 +# This entry (or vt102-nsgr) is probably the right thing to use for +# these. +vt102|dec vt102:\ + :mi:\ + :al=\E[L:dc=\E[P:dl=\E[M:ei=\E[4l:im=\E[4h:tc=vt100: +vt102-w|dec vt102 in wide mode:\ + :co#132:\ + :r3=\E[?3h:tc=vt102: + +# Many brain-dead PC comm programs that pretend to be `vt100-compatible' +# fail to interpret the ^O and ^N escapes properly. Symptom: the :me: +# string in the canonical vt100 entry above leaves the screen littered +# with little snowflake or star characters (IBM PC ROM character \017 = ^O) +# after highlight turnoffs. This entry should fix that, and even leave +# ACS support working, at the cost of making multiple-highlight changes +# slightly more expensive. +# From: Eric S. Raymond <esr@snark.thyrsus.com> July 22 1995 +vt102-nsgr|vt102 no sgr (use if you see snowflakes after highlight changes):\ + :me=\E[m:sa@:\ + :tc=vt102: + +# VT125 Graphics CRT. Clear screen also erases graphics +vt125|vt125 graphics terminal:\ + :cl=\E[H\E[2J\EPpS(E)\E\:tc=vt100: + +# This isn't a DEC entry, it came from University of Wisconsin. +# (vt131: I added <rmam>/<smam> based on the init string, also :bs: -- esr) +vt131|dec vt131:\ + :am:bs:xn:\ + :co#80:it#8:li#24:vt#3:\ + :RA=\E[?7h:SA=\E[?7h:bl=^G:cd=50\E[J:ce=3\E[K:\ + :cl=50\E[;H\E[2J:cm=5\E[%i%d;%dH:cr=^M:cs=\E[%i%d;%dr:\ + :do=^J:ho=\E[H:is=\E[1;24r\E[24;1H:k1=\EOP:k2=\EOQ:\ + :k3=\EOR:k4=\EOS:kb=^H:kd=\EOB:ke=\E[?1l\E>:kl=\EOD:\ + :kr=\EOC:ks=\E[?1h\E=:ku=\EOA:le=^H:mb=2\E[5m:md=2\E[1m:\ + :me=2\E[m:mr=2\E[7m:nd=2\E[C:nw=^M^J:\ + :r1=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h:rc=\E8:sc=\E7:\ + :se=2\E[m:so=2\E[7m:sr=5\EM:ta=^I:ue=2\E[m:up=2\E[A:\ + :us=2\E[4m: + +# vt132 - like vt100 but slower and has ins/del line and such. +# I'm told that :im:/:ei: are backwards in the terminal from the +# manual and from the ANSI standard, this describes the actual +# terminal. I've never actually used a vt132 myself, so this +# is untested. +# +vt132|DEC vt132:\ + :xn:\ + :al=\E[L:dc=\E[P:dl=\E[M:ei=\E[4h:im=\E[4l:ip=:sf=\n:tc=vt100: + +# This vt220 description maps F5--F9 to the second block of function keys +# at the top of the keyboard. The "DO" key is used as F10 to avoid conflict +# with the key marked (ESC) on the vt220. See vt220d for an alternate mapping. +# PF1--PF4 are used as F1--F4. +# +vt220-old|vt200-old|DEC VT220 in vt100 emulation mode:\ + :am:bs:mi:pt:xn:xo:\ + :co#80:li#24:vt#3:\ + :@7=\E[4~:RA=\E[?7l:SA=\E[?7h:\ + :ac=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~:\ + :ae=\E(B:al=\E[L:as=\E(0:bl=^G:cd=\E[J:ce=\E[K:\ + :cl=\E[H\E[2J:cm=\E[%i%d;%dH:cr=^M:cs=\E[%i%d;%dr:\ + :dc=\E[P:dl=\E[M:do=\E[B:ei=\E[4l:ho=\E[H:\ + :if=/usr/share/tabset/vt100:im=\E[4h:\ + :is=\E[1;24r\E[24;1H:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:\ + :k5=\E[17~:k6=\E[18~:k7=\E[19~:k8=\E[20~:k9=\E[21~:\ + :k;=\E[29~:kD=\E[3~:kI=\E[2~:kN=\E[6~:kP=\E[5~:kb=^H:\ + :kd=\E[B:kh=\E[1~:kl=\E[D:kr=\E[C:ku=\E[A:le=^H:mb=\E[5m:\ + :md=\E[1m:me=\E[m:mr=\E[7m:nd=\E[C:nl=^J:\ + :r2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h:rc=\E8:\ + :rf=/usr/share/tabset/vt100:\ + :..sa=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e\E(B%;:\ + :sc=\E7:se=\E[27m:sf=20\ED:so=\E[7m:sr=14\EM:ta=^I:\ + :ue=\E[24m:up=\E[A:us=\E[4m:ve=\E[?25h:vi=\E[?25l: + +# A much better description of the VT200/220; used to be vt220-8 +# (untranslatable capabilities removed to fit entry within 1023 bytes) +# (sgr removed to fit entry within 1023 bytes) +# (terminfo-only capabilities suppressed to fit entry within 1023 bytes) +vt220|vt200|dec vt220:\ + :am:bs:mi:ms:xn:xo:\ + :co#80:it#8:li#24:vt#3:\ + :AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:IC=\E[%d@:\ + :LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:ae=^O:al=\E[L:as=^N:bl=^G:\ + :cd=\E[J:ce=\E[K:cl=\E[H\E[J:cm=\E[%i%d;%dH:cr=^M:\ + :cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:do=^J:ec=\E[%dX:\ + :ei=\E[4l:ho=\E[H:if=/usr/share/tabset/vt100:im=\E[4h:\ + :is=\E[?7h\E[>\E[?1h\E F\E[?4l:k1=\EOP:k2=\EOQ:k3=\EOR:\ + :k4=\EOS:k6=\E[17~:k7=\E[18~:k8=\E[19~:k9=\E[20~:kI=\E[2~:\ + :kN=\E[6~:kP=\E[5~:kb=^H:kd=\E[B:kh=\E[H:kl=\E[D:kr=\E[C:\ + :ku=\E[A:le=^H:mb=\E[5m:md=\E[1m:me=\E[m:mr=\E[7m:nd=\E[C:\ + :nw=\EE:rc=\E8:sc=\E7:se=\E[27m:sf=\ED:so=\E[7m:sr=\EM:\ + :st=\EH:ta=^I:ue=\E[24m:up=\E[A:us=\E[4m:vb=\E[?5h\E[?5l: +vt220-w|vt200-w|DEC vt220 in wide mode:\ + :co#132:\ + :r3=\E[?3h:tc=vt220: +# (untranslatable capabilities removed to fit entry within 1023 bytes) +# (sgr removed to fit entry within 1023 bytes) +# (terminfo-only capabilities suppressed to fit entry within 1023 bytes) +vt220-8bit|vt220-8|vt200-8bit|vt200-8|dec vt220/200 in 8-bit mode:\ + :am:bs:mi:ms:xn:xo:\ + :co#80:it#8:li#24:vt#3:\ + :AL=\233%dL:DC=\233%dP:DL=\233%dM:DO=\233%dB:IC=\233%d@:\ + :LE=\233%dD:RI=\233%dC:UP=\233%dA:ae=^O:al=\233L:as=^N:\ + :bl=^G:cd=\233J:ce=\233K:cl=\233H\233J:cm=\233%i%d;%dH:\ + :cr=^M:cs=\233%i%d;%dr:ct=\2333g:dc=\233P:dl=\233M:do=^J:\ + :ec=\233%dX:ei=\2334l:ho=\233H:\ + :if=/usr/share/tabset/vt100:im=\2334h:\ + :is=\233?7h\233>\233?1h\E F\233?4l:k1=\EOP:k2=\EOQ:\ + :k3=\EOR:k4=\EOS:k6=\23317~:k7=\23318~:k8=\23319~:\ + :k9=\23320~:kI=\2332~:kN=\2336~:kP=\2335~:kb=^H:kd=\233B:\ + :kh=\233H:kl=\233D:kr=\233C:ku=\233A:le=^H:mb=\2335m:\ + :md=\2331m:me=\233m:mr=\2337m:nd=\233C:nw=\EE:rc=\E8:\ + :sc=\E7:se=\23327m:sf=\ED:so=\2337m:sr=\EM:st=\EH:ta=^I:\ + :ue=\23324m:up=\233A:us=\2334m:vb=\233?5h\233?5l: + +# +# vt220d: +# This vt220 description regards F6--F10 as the second block of function keys +# at the top of the keyboard. This mapping follows the description given +# in the VT220 Programmer Reference Manual and agrees with the labeling +# on some terminals that emulate the vt220. There is no support for an F5. +# See vt220 for an alternate mapping. +# +vt220d|DEC VT220 in vt100 mode with DEC function key labeling:\ + :F1=\E[23~:F2=\E[24~:F3=\E[25~:F4=\E[26~:F5=\E[28~:\ + :F6=\E[29~:F7=\E[31~:F8=\E[32~:F9=\E[33~:FA=\E[34~:k5@:\ + :k6=\E[17~:k7=\E[18~:k8=\E[19~:k9=\E[20~:k;=\E[21~:\ + :tc=vt220-old: + +vt220-nam|v200-nam|VT220 in vt100 mode with no auto margins:\ + :am@:\ + :r2=\E>\E[?3l\E[?4l\E[?5l\E[?7l\E[?8h:tc=vt220: + +# vt220 termcap written Tue Oct 25 20:41:10 1988 by Alex Latzko +# (not an official DEC entry!) +# The problem with real vt220 terminals is they don't send escapes when in +# in vt220 mode. This can be gotten around two ways. 1> don't send +# escapes or 2> put the vt220 into vt100 mode and use all the nifty +# features of vt100 advanced video which it then has. +# +# This entry takes the view of putting a vt220 into vt100 mode so +# you can use the escape key in emacs and everything else which needs it. +# +# You probably don't want to use this on a VMS machine since VMS will think +# it has a vt220 and will get fouled up coming out of emacs +# +# From: Alexander Latzko <latzko@marsenius.rutgers.edu>, 30 Dec 1996 +# (Added vt100 :rc:,:sc: to quiet a tic warning -- esr) +vt200-js|vt220-js|dec vt200 series with jump scroll:\ + :am:\ + :co#80:\ + :al=\E[L:bl=^G:cd=\E[J:ce=\E[K:cl=\E[H\E[J:cm=\E[%i%d;%dH:\ + :cr=^M:cs=\E[%i%d;%dr:dc=\E[P:dl=\E[M:dm=:do=^J:ed=:\ + :ei=\E[4l:ho=\E[H:im=\E[4h:\ + :is=\E[61"p\E[H\E[?3l\E[?4l\E[?1l\E[?5l\E[?6l\E[?7h\E[?8h\E[?25h\E>\E[m:\ + :k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:kb=^H:kd=\EOB:\ + :ke=\E[?1l\E>:kl=\EOD:kr=\EOC:ks=\E[?1h\E=:ku=\EOA:le=^H:\ + :nw=^M\ED:r1=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h:rc=\E8:\ + :rf=/usr/lib/tabset/vt100:sc=\E7:se=5\E[27m:sf=\ED:\ + :so=5\E[7m:sr=\EM:ta=^I:ue=\E[24m:up=\E[A:us=\E[4m: + + +# This was DEC's vt320. Use the purpose-built one below instead +#vt320|DEC VT320 in vt100 emulation mode, +# use=vt220, + +# +# Use v320n for SCO's LYRIX. Otherwise, use Adam Thompson's vt320-nam. +# +vt320nam|v320n|DEC VT320 in vt100 emul. mode with NO AUTO WRAP mode:\ + :am@:\ + :r2=\E>\E[?3l\E[?4l\E[?5l\E[?7l\E[?8h:tc=vt220: + +# These entries are not DEC's official ones, they were purpose-built for the +# VT320. Here are the designer's notes: +# <kel> is end on a PC kbd. Actually 'select' on a VT. Mapped to +# 'Erase to End of Field'... since nothing seems to use 'end' anyways... +# khome is Home on a PC kbd. Actually 'FIND' on a VT. +# Things that use <knxt> usually use tab anyways... and things that don't use +# tab usually use <knxt> instead... +# kprv is same as tab - Backtab is useless... +# I left out :sa: because of its RIDICULOUS complexity, +# and the resulting fact that it causes the termcap translation of the entry +# to SMASH the 1k-barrier... +# From: Adam Thompson <athompso@pangea.ca> Sept 10 1995 +# (vt320: uncommented :fs:, comnmmented out <kslt> to avoid a conflict --esr) +# (untranslatable capabilities removed to fit entry within 1023 bytes) +# (sgr removed to fit entry within 1023 bytes) +# (terminfo-only capabilities suppressed to fit entry within 1023 bytes) +vt320|vt300|dec vt320 7 bit terminal:\ + :am:es:hs:mi:ms:xn:\ + :co#80:li#24:ws#80:\ + :AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:IC=\E[%d@:\ + :K1=\EOw:K2=\EOu:K3=\EOy:K4=\EOq:K5=\EOs:LE=\E[%dD:\ + :RI=\E[%dC:UP=\E[%dA:ae=\E(B:al=\E[L:as=\E(0:bl=^G:cd=\E[J:\ + :ce=\E[K:cl=\E[H\E[2J:cm=\E[%i%d;%dH:cr=^M:\ + :cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:do=^J:ec=\E[%dX:\ + :ei=\E[4l:fs=\E[0$}:ho=\E[H:im=\E[4h:\ + :is=\E>\E[?3l\E[?4l\E[5?l\E[?7h\E[?8h\E[1;24r\E[24;1H:\ + :k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:k6=\E[17~:k7=\E[18~:\ + :k8=\E[19~:k9=\E[20~:kD=\E[3~:kI=\E[2~:kN=\E[6~:kP=\E[5~:\ + :kb=\177:kd=\EOB:ke=\E[?1l\E>:kh=\E[1~:kl=\EOD:kr=\EOC:\ + :ks=\E[?1h\E=:ku=\EOA:le=^H:mb=\E[5m:md=\E[1m:me=\E[m:\ + :mr=\E[7m:nd=\E[C:nw=\EE:rc=\E8:sc=\E7:se=\E[m:sf=\ED:\ + :so=\E[7m:sr=\EM:st=\EH:ta=^I:ts=\E[1$}\E[H\E[K:ue=\E[m:\ + :up=\E[A:us=\E[4m:ve=\E[?25h:vi=\E[?25l: +vt320-nam|vt300-nam|dec vt320 7 bit terminal with no am to make SAS happy:\ + :am@:\ + :is=\E>\E[?3l\E[?4l\E[5?l\E[?7l\E[?8h\E[1;24r\E[24;1H:\ + :r2=\E>\E[?3l\E[?4l\E[5?l\E[?7l\E[?8h\E[1;24r\E[24;1H:\ + :tc=vt320: +# We have to init 132-col mode, not 80-col mode. +vt320-w|vt300-w|dec vt320 wide 7 bit terminal:\ + :co#132:ws#132:\ + :is=\E>\E[?3h\E[?4l\E[5?l\E[?7h\E[?8h\E[1;24r\E[24;1H:\ + :r2=\E>\E[?3h\E[?4l\E[5?l\E[?7h\E[?8h\E[1;24r\E[24;1H:\ + :tc=vt320: +vt320-w-nam|vt300-w-nam|dec vt320 wide 7 bit terminal with no am:\ + :am@:\ + :is=\E>\E[?3h\E[?4l\E[5?l\E[?7l\E[?8h\E[1;24r\E[24;1H:\ + :r2=\E>\E[?3h\E[?4l\E[5?l\E[?7l\E[?8h\E[1;24r\E[24;1H:\ + :tc=vt320-w: + +# VT330 and VT340 -- These are ReGIS and SIXEL graphics terminals +# which are pretty much a superset of the VT320. They have the +# host writable status line, yet another different DRCS matrix size, +# and such, but they add the DEC Technical character set, Multiple text +# pages, selectable length pages, and the like. The difference between +# the vt330 and vt340 is that the latter has only 2 planes and a monochrome +# monitor, the former has 4 planes and a color monitor. These terminals +# support VT131 and ANSI block mode, but as with much of these things, +# termcap/terminfo doesn't deal with these features. +# +# Note that this entry is are set up in what was the standard way for GNU +# Emacs v18 terminal modes to deal with the cursor keys in that the arrow +# keys were switched into application mode at the same time the numeric pad +# is switched into application mode. This changes the definitions of the +# arrow keys. Emacs v19 is smarter and mines its keys directly out of +# your termcap or terminfo entry, +# +# From: Daniel Glasser <dag@persoft.persoft.com>, 13 Oct 1993 +# (vt340: string capability "sb=\E[M" corrected to "sr"; +# also, added <rmam>/<smam> based on the init string -- esr) +vt340|dec-vt340|vt330|dec-vt330|dec vt340 graphics terminal with 24 line page:\ + :am:es:hs:mi:ms:xn:xo:\ + :co#80:it#8:li#24:vt#3:\ + :AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:IC=\E[%d@:\ + :LE=\E[%dD:RA=\E[?7l:RI=\E[%dC:SA=\E[?7h:UP=\E[%dA:\ + :ac=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~:\ + :ae=^O:al=\E[L:as=^N:cd=\E[J:ce=\E[K:cl=\E[H\E[J:\ + :cm=\E[%i%d;%dH:cr=^M:cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:\ + :dl=\E[M:do=^J:ds=\E[2$~\r\E[1$}\E[K\E[$}:ei=\E[4l:\ + :fs=\E[$}:ho=\E[H:im=\E[4h:\ + :is=\E<\E F\E>\E[?1h\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H:\ + :k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:k6=\E[17~:k7=\E[18~:\ + :k8=\E[19~:k9=\E[20~:kb=^H:kd=\EOB:ke=\E[?1l\E>:kl=\EOD:\ + :kr=\EOC:ks=\E[?1h\E=:ku=\EOA:l1=pf1:l2=pf2:l3=pf3:l4=pf4:\ + :le=^H:mb=\E[5m:md=\E[1m:me=\E[m:mr=\E[7m:nd=\E[C:nw=^M\ED:\ + :r1=\E[?3l:rc=\E8:rf=/usr/share/tabset/vt300:sc=\E7:\ + :se=\E[27m:sf=\ED:so=\E[7m:sr=\EM:st=\EH:ta=^I:\ + :ts=\E[2$~\E[1$}\E[1;%dH:ue=\E[24m:up=\E[A:us=\E[4m:\ + :vb=200\E[?5h\E[?5l:ve=\E[?25h:vi=\E[?25l:vs=\E[?25h: + +# DEC doesn't supply a vt400 description, so we add Daniel Glasser's +# (originally written with vt420 as its primary name, and usable for it). +# +# VT400/420 -- This terminal is a superset of the vt320. It adds the multiple +# text pages and long text pages with selectable length of the vt340, along +# with left and right margins, rectangular area text copy, fill, and erase +# operations, selected region character attribute change operations, +# page memory and rectangle checksums, insert/delete column, reception +# macros, and other features too numerous to remember right now. TERMCAP +# can only take advantage of a few of these added features. +# +# Note that this entry is are set up in what was the standard way for GNU +# Emacs v18 terminal modes to deal with the cursor keys in that the arrow +# keys were switched into application mode at the same time the numeric pad +# is switched into application mode. This changes the definitions of the +# arrow keys. Emacs v19 is smarter and mines its keys directly out of +# your termcap entry, +# +# From: Daniel Glasser <dag@persoft.persoft.com>, 13 Oct 1993 +# (vt400: string capability ":sb=\E[M:" corrected to ":sr=\E[M:"; +# also, added <rmam>/<smam> based on the init string -- esr) +# (untranslatable capabilities removed to fit entry within 1023 bytes) +# (sgr removed to fit entry within 1023 bytes) +# (terminfo-only capabilities suppressed to fit entry within 1023 bytes) +vt400|vt400-24|dec-vt400|dec vt400 24x80 column autowrap:\ + :am:es:hs:mi:ms:xn:xo:\ + :co#80:it#8:li#24:vt#3:\ + :AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:IC=\E[%d@:\ + :LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:ae=^O:al=\E[L:as=^N:\ + :cd=10\E[J:ce=4\E[K:cl=10\E[H\E[J:cm=\E[%i%d;%dH:cr=^M:\ + :cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:do=^J:\ + :ds=\E[2$~\r\E[1$}\E[K\E[$}:ei=\E[4l:fs=\E[$}:ho=\E[H:\ + :ic=\E[@:im=\E[4h:\ + :is=\E<\E F\E>\E[?1h\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H:\ + :k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:k6=\E[17~:k7=\E[18~:\ + :k8=\E[19~:k9=\E[20~:kb=^H:kd=\EOB:ke=\E[?1l\E>:kl=\EOD:\ + :kr=\EOC:ks=\E[?1h\E=:ku=\EOA:le=^H:mb=\E[5m:md=\E[1m:\ + :me=\E[m:mr=\E[7m:nd=\E[C:nw=^M\ED:rc=\E8:sc=\E7:se=\E[27m:\ + :sf=\ED:so=\E[7m:sr=\EM:st=\EH:ta=^I:\ + :ts=\E[2$~\E[1$}\E[1;%dH:ue=\E[24m:up=\E[A:us=\E[4m:\ + :vb=200\E[?5h\E[?5l:ve=\E[?25h:vi=\E[?25l:vs=\E[?25h: + +# (vt420: I removed :k0:, it collided with <kf10>. I also restored +# a missing :sc: -- esr) +vt420|DEC VT420:\ + :am:mi:xn:xo:\ + :co#80:li#24:vt#3:\ + :*6=\E[4~:@0=\E[1~:RA=\E[?7l:\ + :S5=\E[?0;0r\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h:\ + :SA=\E[?7h:\ + :ac=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~:\ + :ae=\E(B:al=\E[L:as=\E(0:bl=^G:cd=\E[J:ce=\E[K:\ + :cl=\E[H\E[2J:cm=\E[%i%d;%dH:cr=^M:cs=\E[%i%d;%dr:\ + :dc=\E[P:dl=\E[M:do=\E[B:ei=\E[4l:ho=\E[H:\ + :i2=\E[?67h\E[64;1"p:if=/usr/share/tabset/vt300:\ + :im=\E[4h:is=\E[1;24r\E[24;1H:k1=\EOP:k2=\EOQ:k3=\EOR:\ + :k4=\EOS:k5=\E[17~:k6=\E[18~:k7=\E[19~:k8=\E[20~:\ + :k9=\E[21~:k;=\E[29~:kD=\E[3~:kI=\E[2~:kN=\E[6~:kP=\E[5~:\ + :kb=^H:kd=\E[B:ke=\E>:kl=\E[D:kr=\E[C:ks=\E=:ku=\E[A:le=^H:\ + :mb=\E[5m:md=\E[1m:me=\E[m:mr=\E[7m:nd=\E[C:\ + :r3=\E[?67h\E[64;1"p:rc=\E8:rf=/usr/share/tabset/vt300:\ + :..sa=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e\E(B%;:\ + :sc=\E7:se=\E[m:sf=\ED:so=\E[7m:sr=\EM:ta=^I:ue=\E[m:\ + :up=\E[A:us=\E[4m: + +# +# DEC VT220 and up support DECUDK (user-defined keys). DECUDK (i.e., pfx) +# takes two parameters, the key and the string. Translating the key is +# straightforward (keys 1-5 are not defined on real terminals, though some +# emulators define these): +# +# if (key < 16) then value = key; +# else if (key < 21) then value = key + 1; +# else if (key < 25) then value = key + 2; +# else if (key < 27) then value = key + 3; +# else if (key < 30) then value = key + 4; +# else value = key + 5; +# +# The string must be the hexadecimal equivalent, e.g., "5052494E" for "PRINT". +# There's no provision in terminfo for emitting a string in this format, so the +# application has to know it. +# +vt420pc|DEC VT420 w/PC keyboard:\ + :@7=\E[4~:F1=\E[23~:F2=\E[24~:F3=\E[11;2~:F4=\E[12;2~:\ + :F5=\E[13;2~:F6=\E[14;2~:F7=\E[15;2~:F8=\E[17;2~:\ + :F9=\E[18;2~:FA=\E[19;2~:FB=\E[20;2~:FC=\E[21;2~:\ + :FD=\E[23;2~:FE=\E[24;2~:FF=\E[23~:FG=\E[24~:FH=\E[25~:\ + :FI=\E[26~:FJ=\E[28~:FK=\E[29~:FL=\E[31~:FM=\E[32~:\ + :FN=\E[33~:FO=\E[34~:FP=\E[35~:FQ=\E[36~:FR=\E[23;2~:\ + :FS=\E[24;2~:FT=\E[25;2~:FU=\E[26;2~:FV=\E[28;2~:\ + :FW=\E[29;2~:FX=\E[31;2~:FY=\E[32;2~:FZ=\E[33;2~:\ + :Fa=\E[34;2~:Fb=\E[35;2~:Fc=\E[36;2~:\ + :S6=USR_TERM\072vt420pcdos\072:k1=\E[11~:k2=\E[12~:\ + :k3=\E[13~:k4=\E[14~:k5=\E[15~:k6=\E[17~:k7=\E[18~:\ + :k8=\E[19~:k9=\E[20~:k;=\E[21~:kD=\177:kh=\E[H:\ + :..px=\EP1;1|%?%{16}%p1%>%t%{0}%e%{21}%p1%>%t%{1}%e%{25}%p1%>%t%{2}%e%{27}%p1%>%t%{3}%e%{30}%p1%>%t%{4}%e%{5}%;%p1%+%d/%p2%s\E\:tc=vt420: + +vt420pcdos|DEC VT420 w/PC for DOS Merge:\ + :li#25:\ + :S1=%?%p2%{19}%=%t\E\023\021%e%p2%{32}%<%t\E%p2%c%e%p2%{127}%=%t\E\177%e%p2%c%;:\ + :S4=\E[?1;2r\E[34h:\ + :S5=\E[?0;0r\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h:S6@:\ + :me=\E[m:sa@:\ + :tc=vt420pc: + +vt420f|DEC VT420 with VT kbd; VT400 mode; F1-F5 used as Fkeys:\ + :F1=\E[23~:F2=\E[24~:F3=\E[25~:F4=\E[26~:F5=\E[28~:\ + :F6=\E[29~:F7=\E[31~:F8=\E[32~:F9=\E[33~:FA=\E[34~:\ + :k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~:k5=\E[15~:\ + :k6=\E[17~:k7=\E[18~:k8=\E[19~:k9=\E[20~:k;=\E[21~:\ + :kD=\177:kh=\E[H:l1=\EOP:l2=\EOQ:l3=\EOR:l4=\EOS:\ + :tc=vt420: + +vt510|DEC VT510:\ + :tc=vt420: +vt510pc|DEC VT510 w/PC keyboard:\ + :tc=vt420pc: +vt510pcdos|DEC VT510 w/PC for DOS Merge:\ + :tc=vt420pcdos: + +# VT520/VT525 +# +# The VT520 is a monochrome text terminal capable of managing up to +# four independent sessions in the terminal. It has multiple ANSI +# emulations (VT520, VT420, VT320, VT220, VT100, VT PCTerm, SCO Console) +# and ASCII emulations (WY160/60, PCTerm, 50/50+, 150/120, TVI 950, +# 925 910+, ADDS A2). This terminfo data is for the ANSI emulations only. +# +# Terminal Set-Up is entered by pressing [F3], [Caps Lock]/[F3] or +# [Alt]/[Print Screen] depending upon which keyboard and which +# terminal mode is being used. If Set-Up has been disabled or +# assigned to an unknown key, Set-Up may be entered by pressing +# [F3] as the first key after power up, regardless of keyboard type. +# (vt520: I added <rmam>/<smam> based on the init string, also :sc: -- esr) +# (untranslatable capabilities removed to fit entry within 1023 bytes) +vt520|DEC VT520:\ + :am:mi:xn:xo:\ + :co#80:li#24:vt#3:\ + :*6=\E[4~:@0=\E[1~:RA=\E[?7l:\ + :S5=\E[?0;0r\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h:\ + :SA=\E[?7h:\ + :ac=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~:\ + :ae=\E(B:al=\E[L:as=\E(0:bl=^G:cd=\E[J:ce=\E[K:\ + :cl=\E[H\E[2J:cm=\E[%i%d;%dH:cr=^M:cs=\E[%i%d;%dr:\ + :dc=\E[P:dl=\E[M:do=\E[B:ei=\E[4l:ho=\E[H:\ + :i2=\E[?67h\E[64;1"p:if=/usr/share/tabset/vt300:\ + :im=\E[4h:is=\E[1;24r\E[24;1H:k0=\E[29~:k1=\EOP:k2=\EOQ:\ + :k3=\EOR:k4=\EOS:k5=\E[17~:k6=\E[18~:k7=\E[19~:k8=\E[20~:\ + :k9=\E[21~:k;=\E[29~:kD=\E[3~:kI=\E[2~:kN=\E[6~:kP=\E[5~:\ + :kb=^H:kd=\E[B:kl=\E[D:kr=\E[C:ku=\E[A:le=^H:mb=\E[5m:\ + :md=\E[1m:me=\E[m:mr=\E[7m:nd=\E[C:r3=\E[?67h\E[64;1"p:\ + :rc=\E8:rf=/usr/share/tabset/vt300:sc=\E7:se=\E[m:sf=\ED:\ + :so=\E[7m:sr=\EM:ta=^I:ue=\E[m:up=\E[A:us=\E[4m: + +# (vt525: I added <rmam>/<smam> based on the init string; +# removed :se:=\E[m, :ue:=\E[m, added :sc: -- esr) +# (untranslatable capabilities removed to fit entry within 1023 bytes) +vt525|DEC VT525:\ + :am:mi:xn:xo:\ + :co#80:li#24:vt#3:\ + :*6=\E[4~:@0=\E[1~:RA=\E[?7l:\ + :S5=\E[?0;0r\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h:\ + :SA=\E[?7h:\ + :ac=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~:\ + :ae=\E(B:al=\E[L:as=\E(0:bl=^G:cd=\E[J:ce=\E[K:\ + :cl=\E[H\E[2J:cm=\E[%i%d;%dH:cr=^M:cs=\E[%i%d;%dr:\ + :dc=\E[P:dl=\E[M:do=\E[B:ei=\E[4l:ho=\E[H:\ + :i2=\E[?67h\E[64;1"p:if=/usr/share/tabset/vt300:\ + :im=\E[4h:is=\E[1;24r\E[24;1H:k0=\E[29~:k1=\EOP:k2=\EOQ:\ + :k3=\EOR:k4=\EOS:k5=\E[17~:k6=\E[18~:k7=\E[19~:k8=\E[20~:\ + :k9=\E[21~:k;=\E[29~:kD=\E[3~:kI=\E[2~:kN=\E[6~:kP=\E[5~:\ + :kb=^H:kd=\E[B:kl=\E[D:kr=\E[C:ku=\E[A:le=^H:mb=\E[5m:\ + :md=\E[1m:me=\E[m:mr=\E[7m:nd=\E[C:r3=\E[?67h\E[64;1"p:\ + :rc=\E8:rf=/usr/share/tabset/vt300:sc=\E7:se=\E[m:sf=\ED:\ + :so=\E[7m:sr=\EM:ta=^I:ue=\E[m:up=\E[A:us=\E[4m: diff --git a/tests/examplefiles/terminfo b/tests/examplefiles/terminfo new file mode 100644 index 00000000..2b68d035 --- /dev/null +++ b/tests/examplefiles/terminfo @@ -0,0 +1,1445 @@ +######## This example from excerpt of <http://www.catb.org/esr/terminfo/>: +# +# Version 11.0.1 +# $Date: 2000/03/02 15:51:11 $ +# terminfo syntax +# + +######## ANSI, UNIX CONSOLE, AND SPECIAL TYPES +# +# This section describes terminal classes and brands that are still +# quite common. +# + +#### Specials +# +# Special "terminals". These are used to label tty lines when you don't +# know what kind of terminal is on it. The characteristics of an unknown +# terminal are the lowest common denominator - they look about like a ti 700. +# + +dumb|80-column dumb tty, + am, + cols#80, + bel=^G, cr=^M, cud1=^J, ind=^J, +unknown|unknown terminal type, + gn, use=dumb, +lpr|printer|line printer, + hc, os, + cols#132, lines#66, + bel=^G, cr=^M, cub1=^H, cud1=^J, ff=^L, ind=^J, +glasstty|classic glass tty interpreting ASCII control characters, + am, + cols#80, + bel=^G, clear=^L, cr=^M, cub1=^H, cud1=^J, ht=^I, kcub1=^H, + kcud1=^J, nel=^M^J, +vanilla, + bel=^G, cr=^M, cud1=^J, ind=^J, + +#### ANSI.SYS/ISO 6429/ECMA-48 Capabilities +# +# See the end-of-file comment for more on these. +# + +# ANSI capabilities are broken up into pieces, so that a terminal +# implementing some ANSI subset can use many of them. +ansi+local1, + cub1=\E[D, cud1=\E[B, cuf1=\E[C, cuu1=\E[A, +ansi+local, + cub=\E[%p1%dD, cud=\E[%p1%dB, cuf=\E[%p1%dC, + cuu=\E[%p1%dA, + use=ansi+local1, +ansi+tabs, + cbt=\E[Z, ht=^I, hts=\EH, tbc=\E[2g, +ansi+inittabs, + it#8, use=ansi+tabs, +ansi+erase, + clear=\E[H\E[J, ed=\E[J, el=\E[K, +ansi+rca, + hpa=\E[%p1%{1}%+%dG, vpa=\E[%p1%{1}%+%dd, +ansi+cup, + cup=\E[%i%p1%d;%p2%dH, home=\E[H, +ansi+rep, + rep=%p1%c\E[%p2%{1}%-%db, +ansi+idl1, + dl1=\E[M, il1=\E[L, +ansi+idl, + dl=\E[%p1%dM, il=\E[%p1%dL, use=ansi+idl1, +ansi+idc, + dch1=\E[P, ich=\E[%p1%d@, ich1=\E[@, rmir=\E6, smir=\E6, +ansi+arrows, + kbs=^H, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, + khome=\E[H, +ansi+sgr|ansi graphic renditions, + blink=\E[5m, invis=\E[8m, rev=\E[7m, sgr0=\E[0m, +ansi+sgrso|ansi standout only, + rmso=\E[m, smso=\E[7m, +ansi+sgrul|ansi underline only, + rmul=\E[m, smul=\E[4m, +ansi+sgrbold|ansi graphic renditions; assuming terminal has bold; not dim, + bold=\E[1m, + sgr=\E[%?%p1%t7;%;%?%p2%t4;%;%?%p3%t7;%;%?%p4%t5;%;%?%p6%t1;%;m, use=ansi+sgr, use=ansi+sgrso, use=ansi+sgrul, +ansi+sgrdim|ansi graphic renditions; assuming terminal has dim; not bold, + dim=\E[2m, + sgr=\E[%?%p1%t7;%;%?%p2%t4;%;%?%p3%t7;%;%?%p4%t5;%;%?%p5%t2;%;m, use=ansi+sgr, use=ansi+sgrso, use=ansi+sgrul, +ansi+pp|ansi printer port, + mc0=\E[0i, mc4=\E[4i, mc5=\E[5i, +ansi+csr|ansi scroll-region plus cursor save & restore, + csr=\E[%i%p1%d;%p2%dr, rc=\E8, sc=\E7, + +# The IBM PC alternate character set. Plug this into any Intel console entry. +# We use \E[11m for rmacs rather than \E[12m so the <acsc> string can use the +# ROM graphics for control characters such as the diamond, up- and down-arrow. +# This works with the System V, Linux, and BSDI consoles. It's a safe bet this +# will work with any Intel console, they all seem to have inherited \E[11m +# from the ANSI.SYS de-facto standard. +klone+acs|alternate character set for ansi.sys displays, + acsc=+\020\,\021-\030.^Y0\333`\004a\261f\370g\361h\260j\331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u\264v\301w\302x\263y\363z\362{\343|\330}\234~\376, + rmacs=\E[10m, smacs=\E[11m, + +# Highlight controls corresponding to the ANSI.SYS standard. Most +# console drivers for Intel boxes obey these. Makes the same assumption +# about \E[11m as klone+acs. True ANSI/ECMA-48 would have <rmso=\E[27m>, +# <rmul=\E[24m>, but this isn't a documented feature of ANSI.SYS. +klone+sgr|attribute control for ansi.sys displays, + blink=\E[5m, bold=\E[1m, invis=\E[8m, rev=\E[7m, + rmpch=\E[10m, rmso=\E[m, rmul=\E[m, + sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;m, + sgr0=\E[0;10m, smpch=\E[11m, smso=\E[7m, smul=\E[4m, + use=klone+acs, + +# Highlight controls corresponding to the ANSI.SYS standard. *All* +# console drivers for Intel boxes obey these. Does not assume \E[11m will +# work; uses \E[12m instead, which is pretty bulletproof but loses you the ACS +# diamond and arrow characters under curses. +klone+sgr-dumb|attribute control for ansi.sys displays (no ESC [ 11 m), + blink=\E[5m, bold=\E[1m, invis=\E[8m, rev=\E[7m, rmso=\E[m, + rmul=\E[m, + sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;12%;m, + sgr0=\E[0;10m, smacs=\E[12m, smso=\E[7m, smul=\E[4m, + use=klone+acs, + +# KOI8-R (RFC1489) acs (alternate character set) +# From: Qing Long <qinglong@Bolizm.ihep.su>, 24 Feb 1996. +klone+koi8acs|alternate character set for ansi.sys displays with KOI8 charset, + acsc=+\020\,\021-\036.^_0\215`\004a\237f\234g\232h\222i\220j\205k\203l\202m\204n\212o\213p\216q\0r\217s\214t\206u\207v\210w\211x\201y\230z\231{\267|\274}L~\225, + rmacs=\E[10m, smacs=\E[11m, + +# ANSI.SYS color control. The setab/setaf caps depend on the coincidence +# between SVr4/XPG4's color numbers and ANSI.SYS attributes. Here are longer +# but equivalent strings that don't rely on that coincidence: +# 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, +# The DOS 5 manual asserts that these sequences meet the ISO 6429 standard. +# They match a subset of ECMA-48. +klone+color|color control for ansi.sys and ISO6429-compatible displays, + colors#8, ncv#3, pairs#64, + op=\E[37;40m, setab=\E[4%p1%dm, setaf=\E[3%p1%dm, + +# This is better than klone+color, it doesn't assume white-on-black as the +# default color pair, but many `ANSI' terminals don't grok the <op> cap. +ecma+color|color control for ECMA-48-compatible terminals, + colors#8, ncv#3, pairs#64, + op=\E[39;49m, setab=\E[4%p1%dm, setaf=\E[3%p1%dm, + +# Attribute control for ECMA-48-compatible terminals +ecma+sgr|attribute capabilities for true ECMA-48 terminals, + rmso=\E[27m, rmul=\E[24m, + use=klone+sgr, + +# For comparison, here are all the capabilities implied by the Intel +# Binary Compatibility Standard (level 2) that fit within terminfo. +# For more detail on this rather pathetic standard, see the comments +# near the end of this file. +ibcs2|Intel Binary Compatibility Standard prescriptions, + cbt=\E[Z, clear=\Ec, cub=\E[%p1%dD, cud=\E[%p1%dB, + cuf=\E[%p1%dC, cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, + dch=\E[%p1%dP, dispc=\E=%p1%dg, ech=\E[%p1%dX, + hpa=\E[%i%p1%dG, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, + indn=\E[%p1%dS, rc=\E7, rin=\E[%p1%dT, rmam=\E[?7l, sc=\E7, + smam=\E[?7h, tbc=\E[g, vpa=\E[%i%p1%dd, + +#### ANSI/ECMA-48 terminals and terminal emulators +# +# See near the end of this file for details on ANSI conformance. +# Don't mess with these entries! Lots of other entries depend on them! +# +# This section lists entries in a least-capable to most-capable order. +# if you're in doubt about what `ANSI' matches yours, try them in that +# order and back off from the first that breaks. + +# ansi-mr is for ANSI terminals with ONLY relative cursor addressing +# and more than one page of memory. It uses local motions instead of +# direct cursor addressing, and makes almost no assumptions. It does +# assume auto margins, no padding and/or xon/xoff, and a 24x80 screen. +ansi-mr|mem rel cup ansi, + am, xon, + cols#80, lines#24, use=vanilla, use=ansi+erase, + use=ansi+local1, + +# ansi-mini is a bare minimum ANSI terminal. This should work on anything, but +# beware of screen size problems and memory relative cursor addressing. +ansi-mini|minimum ansi standard terminal, + am, xon, + cols#80, lines#24, use=vanilla, use=ansi+cup, + use=ansi+erase, + +# ansi-mtabs adds relative addressing and minimal tab support +ansi-mtabs|any ansi terminal with pessimistic assumptions, + it#8, + ht=^I, use=ansi+local1, use=ansi-mini, + +# ANSI X3.64 from emory!mlhhh (Hugh Hansard) via BRL +# +# The following is an entry for the full ANSI 3.64 (1977). It lacks +# padding, but most terminals using the standard are "fast" enough +# not to require any -- even at 9600 bps. If you encounter problems, +# try including the padding specifications. +# +# Note: the :as: and :ae: specifications are not implemented here, for +# the available termcap documentation does not make clear WHICH alternate +# character set to specify. ANSI 3.64 seems to make allowances for several. +# Please make the appropriate adjustments to fit your needs -- that is +# if you will be using alternate character sets. +# +# There are very few terminals running the full ANSI 3.64 standard, +# so I could only test this entry on one verified terminal (Visual 102). +# I would appreciate the results on other terminals sent to me. +# +# Please report comments, changes, and problems to: +# +# U.S. MAIL: Hugh Hansard +# Box: 22830 +# Emory University +# Atlanta, GA. 30322. +# +# USENET {akgua,msdc,sb1,sb6,gatech}!emory!mlhhh. +# +# (Added vt100 <rc>,<sc> to quiet a tic warning --esr) +ansi77|ansi 3.64 standard 1977 version, + am, mir, + cols#80, it#8, lines#24, + bel=^G, clear=\E[;H\E[2J, cr=^M, csr=\E[%i%p1%d;%p2%dr, + cub1=^H, cud1=\E[B, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, + cuu1=\E[A, dch1=\E[P, dl1=\E[M$<5*/>, ed=\E[J, el=\E[K, + home=\E[H, ht=^I, il1=\E[L$<5*/>, ind=\ED, kbs=^H, + kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf1=\EOP, + kf2=\EOR, kf4=\EOS, khome=\E[H, nel=^M\ED, rc=\E8, ri=\EM, + rmir=\E[4l, rmso=\E[m, rmul=\E[m, sc=\E7, smir=\E[4h, + smso=\E[7m, smul=\E[4m, + +# Procomm and some other ANSI emulations don't recognize all of the ANSI- +# standard capabilities. This entry deletes <cuu>, <cuf>, <cud>, <cub>, and +# <vpa>/<hpa> capabilities, forcing curses to use repetitions of <cuu1>, +# <cuf1>, <cud1> and <cub1>. Also deleted <ich> and <ich1>, as QModem up to +# 5.03 doesn't recognize these. Finally, we delete <rep> and <ri>, which seem +# to confuse many emulators. On the other hand, we can count on these programs +# doing <rmacs>/<smacs>/<sgr>. Older versions of this entry featured +# <invis=\E[9m>, but <invis=\E[8m> now seems to be more common under +# ANSI.SYS influence. +# From: Eric S. Raymond <esr@snark.thyrsus.com> Oct 30 1995 +pcansi-m|pcansi-mono|ibm-pc terminal programs claiming to be ansi (mono mode), + am, mir, msgr, + cols#80, it#8, lines#24, + bel=^G, cbt=\E[Z, clear=\E[H\E[J, cr=^M, cub1=\E[D, + cud1=\E[B, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, + dch1=\E[P, dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, ht=^I, + hts=\EH, il1=\E[L, ind=^J, kbs=^H, kcub1=\E[D, kcud1=\E[B, + kcuf1=\E[C, kcuu1=\E[A, khome=\E[H, tbc=\E[2g, + use=klone+sgr-dumb, +pcansi-25-m|pcansi25m|ibm-pc terminal programs with 25 lines (mono mode), + lines#25, use=pcansi-m, +pcansi-33-m|pcansi33m|ibm-pc terminal programs with 33 lines (mono mode), + lines#33, use=pcansi-m, +pcansi-43-m|ansi43m|ibm-pc terminal programs with 43 lines (mono mode), + lines#43, use=pcansi-m, +# The color versions. All PC emulators do color... +pcansi|ibm-pc terminal programs claiming to be ansi, + use=klone+color, use=pcansi-m, +pcansi-25|pcansi25|ibm-pc terminal programs with 25 lines, + lines#25, use=pcansi, +pcansi-33|pcansi33|ibm-pc terminal programs with 33 lines, + lines#33, use=pcansi, +pcansi-43|pcansi43|ibm-pc terminal programs with 43 lines, + lines#43, use=pcansi, + +# ansi-m -- full ANSI X3.64 with ANSI.SYS-compatible attributes, no color. +# If you want pound signs rather than dollars, replace `B' with `A' +# in the <s0ds>, <s1ds>, <s2ds>, and <s3ds> capabilities. +# From: Eric S. Raymond <esr@snark.thyrsus.com> Nov 6 1995 +ansi-m|ansi-mono|ANSI X3.64-1979 terminal with ANSI.SYS compatible attributes, + mc5i, + cub=\E[%p1%dD, cud=\E[%p1%dB, cuf=\E[%p1%dC, + cuu=\E[%p1%dA, dch=\E[%p1%dP, dl=\E[%p1%dM, + ech=\E[%p1%dX, el1=\E[1K, hpa=\E[%i%p1%dG, ht=\E[I, + ich=\E[%p1%d@, il=\E[%p1%dL, indn=\E[%p1%dS, kbs=^H, + kcbt=\E[Z, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, + kich1=\E[L, mc4=\E[4i, mc5=\E[5i, nel=\r\E[S, + rep=%p1%c\E[%p2%{1}%-%db, rin=\E[%p1%dT, s0ds=\E(B, + s1ds=\E)B, s2ds=\E*B, s3ds=\E+B, tbc=\E[2g, + vpa=\E[%i%p1%dd, use=pcansi-m, + +# ansi -- this terminfo expresses the largest subset of X3.64 that will fit in +# standard terminfo. Assumes ANSI.SYS-compatible attributes and color. +# From: Eric S. Raymond <esr@snark.thyrsus.com> Nov 6 1995 +ansi|ansi/pc-term compatible with color, + u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?%[;0123456789]c, + u9=\E[c, + use=ecma+color, use=klone+sgr, use=ansi-m, + +# ansi-generic is a vanilla ANSI terminal. This is assumed to implement +# all the normal ANSI stuff with no extensions. It assumes +# insert/delete line/char is there, so it won't work with +# vt100 clones. It assumes video attributes for bold, blink, +# underline, and reverse, which won't matter much if the terminal +# can't do some of those. Padding is assumed to be zero, which +# shouldn't hurt since xon/xoff is assumed. +ansi-generic|generic ansi standard terminal, + am, xon, + cols#80, lines#24, use=vanilla, use=ansi+csr, use=ansi+cup, + use=ansi+rca, use=ansi+erase, use=ansi+tabs, + use=ansi+local, use=ansi+idc, use=ansi+idl, use=ansi+rep, + use=ansi+sgrbold, use=ansi+arrows, + +#### Linux consoles +# + +# This entry is good for the 1.2.13 or later version of the Linux console. +# +# *************************************************************************** +# * * +# * WARNING: * +# * Linuxes come with a default keyboard mapping kcbt=^I. This entry, in * +# * response to user requests, assumes kcbt=\E[Z, the ANSI/ECMA reverse-tab * +# * character. Here are the keymap replacement lines that will set this up: * +# * * +# keycode 15 = Tab Tab +# alt keycode 15 = Meta_Tab +# shift keycode 15 = F26 +# string F26 ="\033[Z" +# * * +# * This has to use a key slot which is unfortunate (any unused one will * +# * do, F26 is the higher-numbered one). The change ought to be built * +# * into the kernel tables. * +# * * +# *************************************************************************** +# +# The 1.3.x kernels add color-change capabilities; if yours doesn't have this +# and it matters, turn off <ccc>. The %02x escape used to implement this is +# not back-portable to SV curses and not supported in ncurses versions before +# 1.9.9. All linux kernels since 1.2.13 (at least) set the screen size +# themselves; this entry assumes that capability. +# +# This entry is good for the 1.2.13 or later version of the Linux console. +# +# *************************************************************************** +# * * +# * WARNING: * +# * Linuxes come with a default keyboard mapping kcbt=^I. This entry, in * +# * response to user requests, assumes kcbt=\E[Z, the ANSI/ECMA reverse-tab * +# * character. Here are the keymap replacement lines that will set this up: * +# * * +# keycode 15 = Tab Tab +# alt keycode 15 = Meta_Tab +# shift keycode 15 = F26 +# string F26 ="\033[Z" +# * * +# * This has to use a key slot which is unfortunate (any unused one will * +# * do, F26 is the higher-numbered one). The change ought to be built * +# * into the kernel tables. * +# * * +# *************************************************************************** +# +# The 1.3.x kernels add color-change capabilities; if yours doesn't have this +# and it matters, turn off <ccc>. The %02x escape used to implement this is +# not back-portable to SV curses and not supported in ncurses versions before +# 1.9.9. All linux kernels since 1.2.13 (at least) set the screen size +# themselves; this entry assumes that capability. +# +# The 2.2.x kernels add a private mode that sets the cursor type; use that to +# get a block cursor for cvvis. +# reported by Frank Heckenbach <frank@g-n-u.de>. +linux|linux console, + am, bce, eo, mir, msgr, xenl, xon, + it#8, ncv#2, + acsc=+\020\,\021-\030.^Y0\333`\004a\261f\370g\361h\260i\316j\331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u\264v\301w\302x\263y\363z\362{\343|\330}\234~\376, + bel=^G, civis=\E[?25l\E[?1c, clear=\E[H\E[J, + cnorm=\E[?25h\E[?0c, cr=^M, csr=\E[%i%p1%d;%p2%dr, + cub1=^H, cud1=^J, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, + cuu1=\E[A, cvvis=\E[?25h\E[?8c, dch=\E[%p1%dP, dch1=\E[P, + dim=\E[2m, dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, + el=\E[K, el1=\E[1K, flash=\E[?5h\E[?5l$<200/>, home=\E[H, + hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ich=\E[%p1%d@, ich1=\E[@, + il=\E[%p1%dL, il1=\E[L, ind=^J, kb2=\E[G, kbs=\177, + kcbt=\E[Z, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, + kdch1=\E[3~, kend=\E[4~, kf1=\E[[A, 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[[B, kf20=\E[34~, kf3=\E[[C, kf4=\E[[D, + kf5=\E[[E, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, + khome=\E[1~, kich1=\E[2~, knp=\E[6~, kpp=\E[5~, kspd=^Z, + nel=^M^J, rc=\E8, rev=\E[7m, ri=\EM, rmir=\E[4l, rmso=\E[27m, + rmul=\E[24m, rs1=\Ec\E]R, sc=\E7, + sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p5%t;2%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;m, + smir=\E[4h, smul=\E[4m, tbc=\E[3g, u6=\E[%i%d;%dR, + u7=\E[6n, u8=\E[?6c, u9=\E[c, vpa=\E[%i%p1%dd, + use=klone+sgr, use=ecma+color, +linux-m|Linux console no color, + colors@, pairs@, + setab@, setaf@, setb@, setf@, use=linux, +linux-c-nc|linux console 1.3.x hack for ncurses only, + ccc, + initc=\E]P%p1%x%p2%{255}%*%{1000}%/%02x%p3%{255}%*%{1000}%/%02x%p4%{255}%*%{1000}%/%02x, + oc=\E]R, + use=linux, +# From: Dennis Henriksen <opus@osrl.dk>, 9 July 1996 +linux-c|linux console 1.3.6+ with private palette for each virtual console, + ccc, + colors#8, pairs#64, + initc=\E]P%?%p1%{9}%>%t%p1%{10}%-%'a'%+%c%e%p1%d%;%p2%{255}%&%Pr%gr%{16}%/%Px%?%gx%{9}%>%t%gx%{10}%-%'A'%+%c%e%gx%d%;%gr%{15}%&%Px%?%gx%{9}%>%t%gx%{10}%-%'A'%+%c%e%gx%d%;%p3%{255}%&%Pr%gr%{16}%/%Px%?%gx%{9}%>%t%gx%{10}%-%'A'%+%c%e%gx%d%;%gr%{15}%&%Px%?%gx%{9}%>%t%gx%{10}%-%'A'%+%c%e%gx%d%;%p4%{255}%&%Pr%gr%{16}%/%Px%?%gx%{9}%>%t%gx%{10}%-%'A'%+%c%e%gx%d%;%gr%{15}%&%Px%?%gx%{9}%>%t%gx%{10}%-%'A'%+%c%e%gx%d%;, + oc=\E]R, + use=linux, + +# See the note on ICH/ICH1 VERSUS RMIR/SMIR near the end of file +linux-nic|linux with ich/ich1 suppressed for non-curses programs, + ich@, ich1@, + use=linux, + +# This assumes you have used setfont(8) to load one of the Linux koi8-r fonts. +# acsc entry from Pavel Roskin" <pavel@absolute.spb.su>, 29 Sep 1997. +linux-koi8|linux with koi8 alternate character set, + acsc=+\020\,\021-\030.^Y0\215`\004a\221f\234g\237h\220i\276j\205k\203l\202m\204n\212o~p\0q\0r\0s_t\206u\207v\211w\210x\201y\230z\231{\267|\274~\224, + use=linux, use=klone+koi8acs, + +# Another entry for KOI8-r with Qing Long's acsc. +# (which one better complies with the standard?) +linux-koi8r|linux with koi8-r alternate character set, + use=linux, use=klone+koi8acs, + +# Entry for the latin1 and latin2 fonts +linux-lat|linux with latin1 or latin2 alternate character set, + acsc=+\020\,\021-\030.^Y0\333`\004a\013f\370g\361h\260i\316j\211k\214l\206m\203n\305o~p\304q\212r\304s_t\207u\215v\301w\302x\205y\363z\362{\343|\330}\234~\376, + use=linux, + +#### NetBSD consoles +# +# pcvt termcap database entries (corresponding to release 3.31) +# Author's last edit-date: [Fri Sep 15 20:29:10 1995] +# +# (For the terminfo master file, I translated these into terminfo syntax. +# Then I dropped all the pseudo-HP entries. we don't want and can't use +# the :Xs: flag. Then I split :is: into a size-independent <is1> and a +# size-dependent <is2>. Finally, I added <rmam>/<smam> -- esr) + +# NOTE: <ich1> has been taken out of this entry. for reference, it should +# be <ich1=\E[@>. For discussion, see ICH/ICH1 VERSUS RMIR/SMIR below. +# (esr: added <civis> and <cnorm> to resolve NetBSD Problem Report #4583) +pcvtXX|pcvt vt200 emulator (DEC VT220), + am, km, mir, msgr, xenl, + it#8, vt#3, + acsc=++\,\,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz~~, + bel=^G, blink=\E[5m, bold=\E[1m, civis=\E[?25l, + clear=\E[H\E[J, cnorm=\E[?25h, cr=^M, + csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, + cud=\E[%p1%dB, cud1=\E[B, 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, el1=\E[1K, home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@, + il=\E[%p1%dL, il1=\E[L, ind=\ED, indn=\E[%p1%dS, + is1=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, kbs=\177, + kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, + kdch1=\E[3~, kf1=\E[17~, kf2=\E[18~, kf3=\E[19~, + kf4=\E[20~, kf5=\E[21~, kf6=\E[23~, kf7=\E[24~, kf8=\E[25~, + khome=\E[1~, kich1=\E[2~, kll=\E[4~, knp=\E[6~, kpp=\E[5~, + nel=\EE, rc=\E8, rev=\E[7m, rf=/usr/share/tabset/vt100, + ri=\EM, rin=\E[%p1%dT, rmacs=\E(B, rmam=\E[?7l, rmir=\E[4l, + rmkx=\E[?1l\E>, rmso=\E[27m, rmul=\E[24m, + rs1=\Ec\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\E7, + sgr0=\E[m, smacs=\E(0, smam=\E[?7h, smir=\E[4h, + smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g, + +# NetBSD/FreeBSD vt220 terminal emulator console (pc keyboard & monitor) +# termcap entries for pure VT220-Emulation and 25, 28, 35, 40, 43 and +# 50 lines entries; 80 columns +pcvt25|dec vt220 emulation with 25 lines, + cols#80, lines#25, + is2=\E[1;25r\E[25;1H, use=pcvtXX, +pcvt28|dec vt220 emulation with 28 lines, + cols#80, lines#28, + is2=\E[1;28r\E[28;1H, use=pcvtXX, +pcvt35|dec vt220 emulation with 35 lines, + cols#80, lines#35, + is2=\E[1;35r\E[35;1H, use=pcvtXX, +pcvt40|dec vt220 emulation with 40 lines, + cols#80, lines#40, + is2=\E[1;40r\E[40;1H, use=pcvtXX, +pcvt43|dec vt220 emulation with 43 lines, + cols#80, lines#43, + is2=\E[1;43r\E[43;1H, use=pcvtXX, +pcvt50|dec vt220 emulation with 50 lines, + cols#80, lines#50, + is2=\E[1;50r\E[50;1H, use=pcvtXX, + +# NetBSD/FreeBSD vt220 terminal emulator console (pc keyboard & monitor) +# termcap entries for pure VT220-Emulation and 25, 28, 35, 40, 43 and +# 50 lines entries; 132 columns +pcvt25w|dec vt220 emulation with 25 lines and 132 cols, + cols#132, lines#25, + is2=\E[1;25r\E[25;1H, use=pcvtXX, +pcvt28w|dec vt220 emulation with 28 lines and 132 cols, + cols#132, lines#28, + is2=\E[1;28r\E[28;1H, use=pcvtXX, +pcvt35w|dec vt220 emulation with 35 lines and 132 cols, + cols#132, lines#35, + is2=\E[1;35r\E[35;1H, use=pcvtXX, +pcvt40w|dec vt220 emulation with 40 lines and 132 cols, + cols#132, lines#40, + is2=\E[1;40r\E[40;1H, use=pcvtXX, +pcvt43w|dec vt220 emulation with 43 lines and 132 cols, + cols#132, lines#43, + is2=\E[1;43r\E[43;1H, use=pcvtXX, +pcvt50w|dec vt220 emulation with 50 lines and 132 cols, + cols#132, lines#50, + is2=\E[1;50r\E[50;1H, use=pcvtXX, + +# Terminfo entries to enable the use of the ncurses library in colour on a +# NetBSD-arm32 console (only tested on a RiscPC). +# Created by Dave Millen <dmill@globalnet.co.uk> 22.07.98 +# modified codes for setf/setb to setaf/setab, then to klone+color, corrected +# typo in invis - TD +arm100|arm100-am|Arm(RiscPC) ncurses compatible (for 640x480), + am, bce, msgr, xenl, xon, + cols#80, it#8, lines#30, + acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, + bel=^G, blink=\E[5m$<2>, bold=\E[1m$<2>, + clear=\E[H\E[J$<50>, 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$<2>, + cup=\E[%i%p1%d;%p2%dH$<5>, cuu=\E[%p1%dA, + cuu1=\E[A$<2>, ed=\E[J$<50>, el=\E[K$<3>, el1=\E[1K$<3>, + enacs=\E(B\E)0, home=\E[H, ht=^I, hts=\EH, ind=^J, + invis=\E[8m$<2>, ka1=\E[q, ka3=\E[s, kb2=\E[r, kbs=^H, + kc1=\E[p, kc3=\E[n, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, + kcuu1=\E[A, kent=\E[M, kf0=\E[y, kf1=\E[P, kf10=\E[x, + kf2=\E[Q, kf3=\E[R, kf4=\E[S, kf5=\E[t, kf6=\E[u, kf7=\E[v, + kf8=\E[l, kf9=\E[w, rc=\E8, rev=\E[6m$<2>, ri=\EM$<5>, + rmacs=^O, rmam=\E[?7l, rmkx=\E[?1l\E>, rmso=\E[m$<2>, + rmul=\E[m$<2>, rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, + sc=\E7, + sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;, + sgr0=\E[m\017$<2>, smacs=^N, smam=\E[?7h, smkx=\E[?1h\E=, + smso=\E[7m$<2>, smul=\E[4m$<2>, tbc=\E[3g, + use=ecma+sgr, use=klone+color, +arm100-w|arm100-wam|Arm(RiscPC) ncurses compatible (for 1024x768), + cols#132, lines#50, use=arm100, + +# NetBSD/x68k console vt200 emulator. This port runs on a 68K machine +# manufactured by Sharp for the Japenese market. +# From Minoura Makoto <minoura@netlaputa.or.jp>, 12 May 1996 +x68k|x68k-ite|NetBSD/x68k ITE, + cols#96, lines#32, + kclr=\E[9~, khlp=\E[28~, use=vt220, + +# <tv@pobox.com>: +# Entry for the DNARD OpenFirmware console, close to ANSI but not quite. +# +# (still unfinished, but good enough so far.) +ofcons, + bw, + cols#80, lines#30, + bel=^G, blink=\2337;2m, bold=\2331m, clear=^L, cr=^M, + cub=\233%p1%dD, cub1=\233D, cud=\233%p1%dB, cud1=\233B, + cuf=\233%p1%dC, cuf1=\233C, cup=\233%i%p1%d;%p2%dH, + cuu=\233%p1%dA, cuu1=\233A, dch=\233%p1%dP, dch1=\233P, + dim=\2332m, dl=\233%p1%dM, dl1=\233M, ed=\233J, el=\233K, + flash=^G, ht=^I, ich=\233%p1%d@, ich1=\233@, il=\233%p1%dL, + il1=\233L, ind=^J, invis=\2338m, kbs=^H, kcub1=\233D, + kcud1=\233B, kcuf1=\233C, kcuu1=\233A, kdch1=\233P, + kf1=\2330P, kf10=\2330M, kf2=\2330Q, kf3=\2330W, + kf4=\2330x, kf5=\2330t, kf6=\2330u, kf7=\2330q, kf8=\2330r, + kf9=\2330p, knp=\233/, kpp=\233?, nel=^M^J, rev=\2337m, + rmso=\2330m, rmul=\2330m, sgr0=\2330m, + +# NetBSD "wscons" emulator in vt220 mode +# These are micro-minimal and probably need to be redone for real +# after the manner of the pcvt entries. +wsvt25|NetBSD wscons in 25 line DEC VT220 mode, + cols#80, lines#25, use=vt220, + +wsvt25m|NetBSD wscons in 25 line DEC VT220 mode with Meta, + km, + cols#80, lines#25, use=vt220, + +# `rasterconsole' provided by 4.4BSD, NetBSD and OpenBSD on SPARC, and +# DECstation/pmax. +rcons|BSD rasterconsole, + use=sun-il, +# Color version of above. Color currenly only provided by NetBSD. +rcons-color|BSD rasterconsole with ANSI color, + bce, + colors#8, pairs#64, + op=\E[m, setab=\E[4%dm, setaf=\E[3%dm, use=rcons, + +#### FreeBSD console entries +# +# From: Andrey Chernov <ache@astral.msk.su> 29 Mar 1996 +# Andrey Chernov maintains the FreeBSD termcap distributions. +# +# Note: Users of FreeBSD 2.1.0 and older versions must either upgrade +# or comment out the :cb: capability in the console entry. +# +# Alexander Lukyanov reports: +# I have seen FreeBSD-2.1.5R... The old el1 bug changed, but it is still there. +# Now el1 clears not only to the line beginning, but also a large chunk +# of previous line. But there is another bug - ech does not work at all. +# + +# for syscons +# common entry without semigraphics +# Bug: The <op> capability resets attributes. +# Bug? The ech and el1 attributes appear to move the cursor in some cases; for +# instance el1 does if the cursor is moved to the right margin first. Removed +# by T.Dickey 97/5/3 (ech=\E[%p1%dX, el1=\E[1K) +# +# Setting colors turns off reverse; we cannot guarantee order, so use ncv. +# Note that this disables standout with color. +cons25w|ansiw|ansi80x25-raw|freebsd console (25-line raw mode), + am, bce, bw, eo, msgr, npc, + colors#8, cols#80, it#8, lines#25, ncv#21, pairs#64, + bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[J, + cnorm=\E[=0C, cr=^M, cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, + cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C, + cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, + cvvis=\E[=1C, dch=\E[%p1%dP, dch1=\E[P, dim=\E[30;1m, + dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, + hpa=\E[%i%p1%d`, ht=^I, ich=\E[%p1%d@, ich1=\E[@, + il=\E[%p1%dL, il1=\E[L, ind=\E[S, indn=\E[%p1%dS, kb2=\E[E, + kbs=^H, kcbt=\E[Z, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, + kcuu1=\E[A, kdch1=\177, kend=\E[F, kf1=\E[M, kf10=\E[V, + kf11=\E[W, kf12=\E[X, kf2=\E[N, kf3=\E[O, kf4=\E[P, kf5=\E[Q, + kf6=\E[R, kf7=\E[S, kf8=\E[T, kf9=\E[U, khome=\E[H, + kich1=\E[L, knp=\E[G, kpp=\E[I, nel=\E[E, op=\E[x, rev=\E[7m, + ri=\E[T, rin=\E[%p1%dT, rmso=\E[m, rs1=\E[x\E[m\Ec, + setab=\E[4%p1%dm, setaf=\E[3%p1%dm, sgr0=\E[m, + smso=\E[7m, vpa=\E[%i%p1%dd, +cons25|ansis|ansi80x25|freebsd console (25-line ansi mode), + acsc=-\030.^Y0\333`\004a\260f\370g\361h\261i\025j\331k\277l\332m\300n\305q\304t\303u\264v\301w\302x\263y\363z\362~\371, + use=cons25w, +cons25-m|ansis-mono|ansi80x25-mono|freebsd console (25-line mono ansi mode), + colors@, pairs@, + bold@, dim@, op@, rmul=\E[m, setab@, setaf@, smul=\E[4m, use=cons25, +cons30|ansi80x30|freebsd console (30-line ansi mode), + lines#30, use=cons25, +cons30-m|ansi80x30-mono|freebsd console (30-line mono ansi mode), + lines#30, use=cons25-m, +cons43|ansi80x43|freebsd console (43-line ansi mode), + lines#43, use=cons25, +cons43-m|ansi80x43-mono|freebsd console (43-line mono ansi mode), + lines#43, use=cons25-m, +cons50|ansil|ansi80x50|freebsd console (50-line ansi mode), + lines#50, use=cons25, +cons50-m|ansil-mono|ansi80x50-mono|freebsd console (50-line mono ansi mode), + lines#50, use=cons25-m, +cons60|ansi80x60|freebsd console (60-line ansi mode), + lines#60, use=cons25, +cons60-m|ansi80x60-mono|freebsd console (60-line mono ansi mode), + lines#60, use=cons25-m, +cons25r|pc3r|ibmpc3r|cons25-koi8-r|freebsd console w/koi8-r cyrillic, + acsc=-\030.^Y0\215`\004a\220f\234h\221i\025j\205k\203l\202m\204n\212q\0t\206u\207v\211w\210x\201y\230z\231~\225, + use=cons25w, +cons25r-m|pc3r-m|ibmpc3r-mono|cons25-koi8r-m|freebsd console w/koi8-r cyrillic (mono), + colors@, pairs@, + op@, rmul=\E[m, setab@, setaf@, smul=\E[4m, use=cons25r, +cons50r|cons50-koi8r|freebsd console w/koi8-r cyrillic (50 lines), + lines#50, use=cons25r, +cons50r-m|cons50-koi8r-m|freebsd console w/koi8-r cyrillic (50-line mono), + lines#50, use=cons25r-m, +cons60r|cons60-koi8r|freebsd console w/koi8-r cyrillic (60 lines), + lines#60, use=cons25r, +cons60r-m|cons60-koi8r-m|freebsd console w/koi8-r cyrillic (60-line mono), + lines#60, use=cons25r-m, +# ISO 8859-1 FreeBSD console +cons25l1|cons25-iso8859|freebsd console w/iso 8859-1 chars, + acsc=+\253\,\273-\030.\031`\201a\202f\207g\210i\247j\213k\214l\215m\216n\217o\220p\221q\222r\223s\224t\225u\226v\227w\230x\231y\232z\233~\237, + use=cons25w, +cons25l1-m|cons25-iso-m|freebsd console w/iso 8859-1 chars (mono), + colors@, pairs@, + bold@, dim@, op@, rmul=\E[m, setab@, setaf@, smul=\E[4m, use=cons25l1, +cons50l1|cons50-iso8859|freebsd console w/iso 8859-1 chars (50 lines), + lines#50, use=cons25l1, +cons50l1-m|cons50-iso-m|freebsd console w/iso 8859-1 chars (50-line mono), + lines#50, use=cons25l1-m, +cons60l1|cons60-iso|freebsd console w/iso 8859-1 chars (60 lines), + lines#60, use=cons25l1, +cons60l1-m|cons60-iso-m|freebsd console w/iso 8859-1 chars (60-line mono), + lines#60, use=cons25l1-m, + +#### 386BSD and BSD/OS Consoles +# + +# This was the original 386BSD console entry (I think). +# Some places it's named oldpc3|oldibmpc3. +# From: Alex R.N. Wetmore <aw2t@andrew.cmu.edu> +origpc3|origibmpc3|IBM PC 386BSD Console, + am, bw, eo, xon, + cols#80, lines#25, + acsc=j\331k\277l\332m\300n\305q\304t\303u\264v\301w\302x\263, + bold=\E[7m, clear=\Ec, cub1=^H, cud1=\E[B, cuf1=\E[C, + cup=\E[%i%p1%2d;%p2%2dH, cuu1=\E[A, ed=\E[J, el=\E[K, + home=\E[H, ind=\E[S, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, + kcuu1=\E[A, khome=\E[Y, ri=\E[T, rmso=\E[1;0x\E[2;7x, + rmul=\E[1;0x\E[2;7x, sgr0=\E[m\E[1;0x\E[2;7x, + smso=\E[1;7x\E[2;0x, smul=\E[1;7x\E[2;0x, + +# description of BSD/386 console emulator in version 1.0 (supplied by BSDI) +oldpc3|oldibmpc3|old IBM PC BSD/386 Console, + km, + lines#25, + bel=^G, bold=\E[=15F, cr=^M, cud1=^J, dim=\E[=8F, dl1=\E[M, + ht=^I, il1=\E[L, ind=^J, kbs=^H, kcub1=\E[D, kcud1=\E[B, + kcuf1=\E[C, kcuu1=\E[A, khome=\E[H, kich1=\E[L, kll=\E[F, + knp=\E[G, kpp=\E[I, nel=^M^J, sgr0=\E[=R, + +# Description of BSD/OS console emulator in version 1.1, 2.0, 2.1 +# Note, the emulator supports many of the additional console features +# listed in the iBCS2 (e.g. character-set selection) though not all +# are described here. This entry really ought to be upgraded. +# Also note, the console will also work with fewer lines after doing +# "stty rows NN", e.g. to use 24 lines. +# (Color support from Kevin Rosenberg <kevin@cyberport.com>, 2 May 1996) +# Bug: The <op> capability resets attributes. +bsdos-pc-nobold|BSD/OS PC console w/o bold, + am, eo, km, xon, + cols#80, it#8, lines#25, + bel=^G, clear=\Ec, cr=^M, 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, + dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, ht=^I, + il=\E[%p1%dL, il1=\E[L, ind=^J, kbs=^H, kcub1=\E[D, + kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, khome=\E[H, kich1=\E[L, + kll=\E[F, knp=\E[G, kpp=\E[I, nel=^M^J, rc=\E8, sc=\E7, + sgr=\E[0;10%?%p1%t;7%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;m%?%p5%t\E[=8F%;, + use=klone+sgr, use=klone+color, +bsdos-pc|IBM PC BSD/OS Console, + sgr=\E[0;10%?%p1%t;7%;%?%p2%t;1%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;m, use=bsdos-pc-nobold, + +# Old names for BSD/OS PC console used in releases before 4.1. +pc3|BSD/OS on the PC Console, + use=bsdos-pc-nobold, +ibmpc3|pc3-bold|BSD/OS on the PC Console with bold instead of underline, + use=bsdos-pc, + +# BSD/OS on the SPARC +bsdos-sparc|Sun SPARC BSD/OS Console, + use=sun, + +# BSD/OS on the PowerPC +bsdos-ppc|PowerPC BSD/OS Console, + use=bsdos-pc, + +#### DEC VT100 and compatibles +# +# DEC terminals from the vt100 forward are collected here. Older DEC terminals +# and micro consoles can be found in the `obsolete' section. More details on +# the relationship between the VT100 and ANSI X3.64/ISO 6429/ECMA-48 may be +# found near the end of this file. +# +# Except where noted, these entries are DEC's official terminfos. +# Contact Bill Hedberg <hedberg@hannah.enet.dec.com> of Terminal Support +# Engineering for more information. Updated terminfos and termcaps +# are kept available at ftp://gatekeeper.dec.com/pub/DEC/termcaps. +# +# In October 1995 DEC sold its terminals business, including the VT and Dorio +# line and trademark, to SunRiver Data Systems. SunRiver has since changed +# its name to Boundless Technologies; see http://www.boundless.com. +# + +# NOTE: Any VT100 emulation, whether in hardware or software, almost +# certainly includes what DEC called the `Level 1 editing extension' codes; +# only the very oldest VT100s lacked these and there probably aren't any of +# those left alive. To capture these, use one of the VT102 entries. +# +# Note that the <xenl> glitch in vt100 is not quite the same as on the Concept, +# since the cursor is left in a different position while in the +# weird state (concept at beginning of next line, vt100 at end +# of this line) so all versions of vi before 3.7 don't handle +# <xenl> right on vt100. The correct way to handle <xenl> is when +# you output the char in column 80, immediately output CR LF +# and then assume you are in column 1 of the next line. If <xenl> +# is on, am should be on too. +# +# I assume you have smooth scroll off or are at a slow enough baud +# rate that it doesn't matter (1200? or less). Also this assumes +# that you set auto-nl to "on", if you set it off use vt100-nam +# below. +# +# The padding requirements listed here are guesses. It is strongly +# recommended that xon/xoff be enabled, as this is assumed here. +# +# The vt100 uses <rs2> and <rf> rather than <is2>/<tbc>/<hts> because the +# tab settings are in non-volatile memory and don't need to be +# reset upon login. Also setting the number of columns glitches +# the screen annoyingly. You can type "reset" to get them set. +# +# The VT100 series terminals have cursor ("arrows") keys which can operate +# in two different modes: Cursor Mode and Application Mode. Cursor Mode +# is the reset state, and is assumed to be the normal state. Application +# Mode is the "set" state. In Cursor Mode, the cursor keys transmit +# "Esc [ {code}" sequences, conforming to ANSI standards. In Application +# Mode, the cursor keys transmit "Esc O <code>" sequences. Application Mode +# was provided primarily as an aid to the porting of VT52 applications. It is +# assumed that the cursor keys are normally in Cursor Mode, and expected that +# applications such as vi will always transmit the <smkx> string. Therefore, +# the definitions for the cursor keys are made to match what the terminal +# transmits after the <smkx> string is transmitted. If the <smkx> string +# is a null string or is not defined, then cursor keys are assumed to be in +# "Cursor Mode", and the cursor keys definitions should match that assumption, +# else the appication may fail. It is also expected that applications will +# always transmit the <rmkx> string to the terminal before they exit. +# +# The VT100 series terminals have an auxilliary keypad, commonly referred to as +# the "Numeric Keypad", because it is a cluster of numeric and function keys. +# The Numeric Keypad which can operate in two different modes: Numeric Mode and +# Application Mode. Numeric Mode is the reset state, and is assumed to be +# the normal state. Application Mode is the "set" state. In Numeric Mode, +# the numeric and punctuation keys transmit ASCII 7-bit characters, and the +# Enter key transmits the same as the Return key (Note: the Return key +# can be configured to send either LF (\015) or CR LF). In Application Mode, +# all the keypad keys transmit "Esc O {code}" sequences. The PF1 - PF4 keys +# always send the same "Esc O {code}" sequences. It is assumed that the keypad +# is normally in Numeric Mode. If an application requires that the keypad be +# in Application Mode then it is expected that the user, or the application, +# will set the TERM environment variable to point to a terminfo entry which has +# defined the <smkx> string to include the codes that switch the keypad into +# Application Mode, and the terminfo entry will also define function key +# fields to match the Application Mode control codes. If the <smkx> string +# is a null string or is not defined, then the keypad is assumed to be in +# Numeric Mode. If the <smkx> string switches the keypad into Application +# Mode, it is expected that the <rmkx> string will contain the control codes +# necessary to reset the keypad to "Normal" mode, and it is also expected that +# applications which transmit the <smkx> string will also always transmit the +# <rmkx> string to the terminal before they exit. +# +# Here's a diagram of the VT100 keypad keys with their bindings. +# The top line is the name of the key (some DEC keyboards have the keys +# labelled somewhat differently, like GOLD instead of PF1, but this is +# the most "official" name). The second line is the escape sequence it +# generates in Application Keypad mode (where "$" means the ESC +# character). The third line contains two items, first the mapping of +# the key in terminfo, and then in termcap. +# _______________________________________ +# | PF1 | PF2 | PF3 | PF4 | +# | $OP | $OQ | $OR | $OS | +# |_kf1__k1_|_kf2__k2_|_kf3__k3_|_kf4__k4_| +# | 7 8 9 - | +# | $Ow | $Ox | $Oy | $Om | +# |_kf9__k9_|_kf10_k;_|_kf0__k0_|_________| +# | 4 | 5 | 6 | , | +# | $Ot | $Ou | $Ov | $Ol | +# |_kf5__k5_|_kf6__k6_|_kf7__k7_|_kf8__k8_| +# | 1 | 2 | 3 | | +# | $Oq | $Or | $Os | enter | +# |_ka1__K1_|_kb2__K2_|_ka3__K3_| $OM | +# | 0 | . | | +# | $Op | $On | | +# |___kc1_______K4____|_kc3__K5_|_kent_@8_| +# +# And here, for those of you with orphaned VT100s lacking documentation, is +# a description of the soft switches invoked when you do `Set Up'. +# +# Scroll 0-Jump Shifted 3 0-# +# | 1-Smooth | 1-British pound sign +# | Autorepeat 0-Off | Wrap Around 0-Off +# | | 1-On | | 1-On +# | | Screen 0-Dark Bkg | | New Line 0-Off +# | | | 1-Light Bkg | | | 1-On +# | | | Cursor 0-Underline | | | Interlace 0-Off +# | | | | 1-Block | | | | 1-On +# | | | | | | | | +# 1 1 0 1 1 1 1 1 0 1 0 0 0 0 1 0 <--Standard Settings +# | | | | | | | | +# | | | Auto XON/XOFF 0-Off | | | Power 0-60 Hz +# | | | 1-On | | | 1-50 Hz +# | | Ansi/VT52 0-VT52 | | Bits Per Char. 0-7 Bits +# | | 1-ANSI | | 1-8 Bits +# | Keyclick 0-Off | Parity 0-Off +# | 1-On | 1-On +# Margin Bell 0-Off Parity Sense 0-Odd +# 1-On 1-Even +# +# The following SET-UP modes are assumed for normal operation: +# ANSI_MODE AUTO_XON/XOFF_ON NEWLINE_OFF 80_COLUMNS +# WRAP_AROUND_ON JUMP_SCROLL_OFF +# Other SET-UP modes may be set for operator convenience or communication +# requirements; I recommend +# AUTOREPEAT_ON BLOCK_CURSOR MARGIN_BELL_OFF SHIFTED_3_# +# Unless you have a graphics add-on such as Digital Engineering's VT640 +# (and even then, whenever it can be arranged!) you should set +# INTERLACE_OFF +# +# (vt100: I added <rmam>/<smam> based on the init string, also <OTbs>. -- esr) +vt100|vt100-am|dec vt100 (w/advanced video), + am, msgr, xenl, xon, + cols#80, it#8, lines#24, vt#3, + acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, + bel=^G, blink=\E[5m$<2>, bold=\E[1m$<2>, + clear=\E[H\E[J$<50>, 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$<2>, + cup=\E[%i%p1%d;%p2%dH$<5>, cuu=\E[%p1%dA, + cuu1=\E[A$<2>, ed=\E[J$<50>, el=\E[K$<3>, el1=\E[1K$<3>, + enacs=\E(B\E)0, home=\E[H, ht=^I, hts=\EH, ind=^J, ka1=\EOq, + ka3=\EOs, kb2=\EOr, kbs=^H, kc1=\EOp, kc3=\EOn, kcub1=\EOD, + kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kent=\EOM, kf0=\EOy, + kf1=\EOP, kf10=\EOx, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\EOt, + kf6=\EOu, kf7=\EOv, kf8=\EOl, kf9=\EOw, rc=\E8, + rev=\E[7m$<2>, ri=\EM$<5>, rmacs=^O, rmam=\E[?7l, + rmkx=\E[?1l\E>, rmso=\E[m$<2>, rmul=\E[m$<2>, + rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\E7, + sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;, + sgr0=\E[m\017$<2>, smacs=^N, smam=\E[?7h, smkx=\E[?1h\E=, + smso=\E[7m$<2>, smul=\E[4m$<2>, tbc=\E[3g, +vt100nam|vt100-nam|vt100 no automargins, + am@, xenl@, use=vt100-am, +vt100-vb|dec vt100 (w/advanced video) & no beep, + bel@, flash=\E[?5h\E[?5l, use=vt100, + +# Ordinary vt100 in 132 column ("wide") mode. +vt100-w|vt100-w-am|dec vt100 132 cols (w/advanced video), + cols#132, lines#24, + rs2=\E>\E[?3h\E[?4l\E[?5l\E[?8h, use=vt100-am, +vt100-w-nam|vt100-nam-w|dec vt100 132 cols (w/advanced video no automargin), + cols#132, lines#14, vt@, + rs2=\E>\E[?3h\E[?4l\E[?5l\E[?8h, use=vt100-nam, + +# vt100 with no advanced video. +vt100-nav|vt100 without advanced video option, + xmc#1, + blink@, bold@, rev@, rmso=\E[m, rmul@, sgr@, sgr0@, smso=\E[7m, + smul@, + use=vt100, +vt100-nav-w|vt100-w-nav|dec vt100 132 cols 14 lines (no advanced video option), + cols#132, lines#14, use=vt100-nav, + +# vt100 with one of the 24 lines used as a status line. +# We put the status line on the top. +vt100-s|vt100-s-top|vt100-top-s|vt100 for use with top sysline, + eslok, hs, + lines#23, + clear=\E[2;1H\E[J$<50>, csr=\E[%i%i%p1%d;%p2%dr, + cup=\E[%i%p1%{1}%+%d;%p2%dH$<5>, dsl=\E7\E[1;24r\E8, + fsl=\E8, home=\E[2;1H, is2=\E7\E[2;24r\E8, + tsl=\E7\E[1;%p1%dH\E[1K, use=vt100-am, + +# Status line at bottom. +# Clearing the screen will clobber status line. +vt100-s-bot|vt100-bot-s|vt100 for use with bottom sysline, + eslok, hs, + lines#23, + dsl=\E7\E[1;24r\E8, fsl=\E8, is2=\E[1;23r\E[23;1H, + tsl=\E7\E[24;%p1%dH\E[1K, + use=vt100-am, + +# Most of the `vt100' emulators out there actually emulate a vt102 +# This entry (or vt102-nsgr) is probably the right thing to use for +# these. +vt102|dec vt102, + mir, + dch1=\E[P, dl1=\E[M, il1=\E[L, rmir=\E[4l, smir=\E[4h, use=vt100, +vt102-w|dec vt102 in wide mode, + cols#132, + rs3=\E[?3h, use=vt102, + +# Many brain-dead PC comm programs that pretend to be `vt100-compatible' +# fail to interpret the ^O and ^N escapes properly. Symptom: the <sgr0> +# string in the canonical vt100 entry above leaves the screen littered +# with little snowflake or star characters (IBM PC ROM character \017 = ^O) +# after highlight turnoffs. This entry should fix that, and even leave +# ACS support working, at the cost of making multiple-highlight changes +# slightly more expensive. +# From: Eric S. Raymond <esr@snark.thyrsus.com> July 22 1995 +vt102-nsgr|vt102 no sgr (use if you see snowflakes after highlight changes), + sgr@, sgr0=\E[m, + use=vt102, + +# VT125 Graphics CRT. Clear screen also erases graphics +vt125|vt125 graphics terminal, + clear=\E[H\E[2J\EPpS(E)\E\\$<50>, use=vt100, + +# This isn't a DEC entry, it came from University of Wisconsin. +# (vt131: I added <rmam>/<smam> based on the init string, also <OTbs> -- esr) +vt131|dec vt131, + am, xenl, + cols#80, it#8, lines#24, vt#3, + bel=^G, blink=\E[5m$<2/>, bold=\E[1m$<2/>, + clear=\E[;H\E[2J$<50/>, cr=^M, csr=\E[%i%p1%d;%p2%dr, + cub1=^H, cud1=^J, cuf1=\E[C$<2/>, + cup=\E[%i%p1%d;%p2%dH$<5/>, cuu1=\E[A$<2/>, + ed=\E[J$<50/>, el=\E[K$<3/>, home=\E[H, ht=^I, + is2=\E[1;24r\E[24;1H, kbs=^H, kcub1=\EOD, kcud1=\EOB, + kcuf1=\EOC, kcuu1=\EOA, kf1=\EOP, kf2=\EOQ, kf3=\EOR, + kf4=\EOS, nel=^M^J, rc=\E8, rev=\E[7m$<2/>, ri=\EM$<5/>, + rmam=\E[?7h, rmkx=\E[?1l\E>, rmso=\E[m$<2/>, + rmul=\E[m$<2/>, + rs1=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\E7, + sgr0=\E[m$<2/>, smam=\E[?7h, smkx=\E[?1h\E=, + smso=\E[7m$<2/>, smul=\E[4m$<2/>, + +# vt132 - like vt100 but slower and has ins/del line and such. +# I'm told that <smir>/<rmir> are backwards in the terminal from the +# manual and from the ANSI standard, this describes the actual +# terminal. I've never actually used a vt132 myself, so this +# is untested. +# +vt132|DEC vt132, + xenl, + dch1=\E[P$<7>, dl1=\E[M$<99>, il1=\E[L$<99>, ind=\n$<30>, + ip=$<7>, rmir=\E[4h, smir=\E[4l, + use=vt100, + +# This vt220 description maps F5--F9 to the second block of function keys +# at the top of the keyboard. The "DO" key is used as F10 to avoid conflict +# with the key marked (ESC) on the vt220. See vt220d for an alternate mapping. +# PF1--PF4 are used as F1--F4. +# +vt220-old|vt200-old|DEC VT220 in vt100 emulation mode, + am, mir, xenl, xon, + cols#80, lines#24, vt#3, + acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, + bel=^G, blink=\E[5m$<2>, bold=\E[1m$<2>, civis=\E[?25l, + clear=\E[H\E[2J$<50>, cnorm=\E[?25h, cr=^M, + csr=\E[%i%p1%d;%p2%dr, cub1=^H, cud1=\E[B, cuf1=\E[C, + cup=\E[%i%p1%d;%p2%dH$<10>, cuu1=\E[A, dch1=\E[P, + dl1=\E[M, ed=\E[J$<50>, el=\E[K$<3>, home=\E[H, ht=^I, + if=/usr/share/tabset/vt100, il1=\E[L, ind=\ED$<20/>, + is2=\E[1;24r\E[24;1H, kbs=^H, kcub1=\E[D, kcud1=\E[B, + kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[3~, kend=\E[4~, kf1=\EOP, + kf10=\E[29~, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\E[17~, + kf6=\E[18~, kf7=\E[19~, kf8=\E[20~, kf9=\E[21~, + khome=\E[1~, kich1=\E[2~, knp=\E[6~, kpp=\E[5~, rc=\E8, + rev=\E[7m$<2>, rf=/usr/share/tabset/vt100, + ri=\EM$<14/>, rmacs=\E(B$<4>, rmam=\E[?7l, rmir=\E[4l, + rmso=\E[27m, rmul=\E[24m, + rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\E7, + sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e\E(B%;, + sgr0=\E[m$<2>, smacs=\E(0$<2>, smam=\E[?7h, smir=\E[4h, + smso=\E[7m, smul=\E[4m, + +# A much better description of the VT200/220; used to be vt220-8 +vt220|vt200|dec vt220, + am, mc5i, mir, msgr, xenl, xon, + cols#80, it#8, lines#24, vt#3, + acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, + bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[J, 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, + ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E)0, + flash=\E[?5h$<200/>\E[?5l, home=\E[H, ht=^I, hts=\EH, + ich=\E[%p1%d@, if=/usr/share/tabset/vt100, + il=\E[%p1%dL, il1=\E[L, ind=\ED, + is2=\E[?7h\E[>\E[?1h\E F\E[?4l, kbs=^H, kcub1=\E[D, + kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf1=\EOP, kf10=\E[21~, + kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, + kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\EOQ, + kf20=\E[34~, kf3=\EOR, kf4=\EOS, kf6=\E[17~, kf7=\E[18~, + kf8=\E[19~, kf9=\E[20~, kfnd=\E[1~, khlp=\E[28~, + khome=\E[H, kich1=\E[2~, knp=\E[6~, kpp=\E[5~, krdo=\E[29~, + kslt=\E[4~, lf1=pf1, lf2=pf2, lf3=pf3, lf4=pf4, mc0=\E[i, + mc4=\E[4i, mc5=\E[5i, nel=\EE, rc=\E8, rev=\E[7m, ri=\EM, + rmacs=^O, rmam=\E[?7l, rmir=\E[4l, rmso=\E[27m, + rmul=\E[24m, rs1=\E[?3l, sc=\E7, sgr0=\E[m, smacs=^N, + smam=\E[?7h, smir=\E[4h, smso=\E[7m, smul=\E[4m, tbc=\E[3g, +vt220-w|vt200-w|DEC vt220 in wide mode, + cols#132, + rs3=\E[?3h, use=vt220, +vt220-8bit|vt220-8|vt200-8bit|vt200-8|dec vt220/200 in 8-bit mode, + am, mc5i, mir, msgr, xenl, xon, + cols#80, it#8, lines#24, vt#3, + acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, + bel=^G, blink=\2335m, bold=\2331m, clear=\233H\233J, 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, + dch=\233%p1%dP, dch1=\233P, dl=\233%p1%dM, dl1=\233M, + ech=\233%p1%dX, ed=\233J, el=\233K, el1=\2331K, enacs=\E)0, + flash=\233?5h$<200/>\233?5l, home=\233H, ht=^I, hts=\EH, + ich=\233%p1%d@, if=/usr/share/tabset/vt100, + il=\233%p1%dL, il1=\233L, ind=\ED, + is2=\233?7h\233>\233?1h\E F\233?4l, kbs=^H, + kcub1=\233D, kcud1=\233B, kcuf1=\233C, kcuu1=\233A, + kf1=\EOP, kf10=\23321~, kf11=\23323~, kf12=\23324~, + kf13=\23325~, kf14=\23326~, kf17=\23331~, kf18=\23332~, + kf19=\23333~, kf2=\EOQ, kf20=\23334~, kf3=\EOR, kf4=\EOS, + kf6=\23317~, kf7=\23318~, kf8=\23319~, kf9=\23320~, + kfnd=\2331~, khlp=\23328~, khome=\233H, kich1=\2332~, + knp=\2336~, kpp=\2335~, krdo=\23329~, kslt=\2334~, lf1=pf1, + lf2=pf2, lf3=pf3, lf4=pf4, mc0=\233i, mc4=\2334i, mc5=\2335i, + nel=\EE, rc=\E8, rev=\2337m, ri=\EM, rmacs=^O, rmam=\233?7l, + rmir=\2334l, rmso=\23327m, rmul=\23324m, rs1=\233?3l, + sc=\E7, sgr0=\233m, smacs=^N, smam=\233?7h, smir=\2334h, + smso=\2337m, smul=\2334m, tbc=\2333g, + +# +# vt220d: +# This vt220 description regards F6--F10 as the second block of function keys +# at the top of the keyboard. This mapping follows the description given +# in the VT220 Programmer Reference Manual and agrees with the labeling +# on some terminals that emulate the vt220. There is no support for an F5. +# See vt220 for an alternate mapping. +# +vt220d|DEC VT220 in vt100 mode with DEC function key labeling, + 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~, kf20=\E[34~, kf5@, kf6=\E[17~, + kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, + use=vt220-old, + +vt220-nam|v200-nam|VT220 in vt100 mode with no auto margins, + am@, + rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7l\E[?8h, use=vt220, + +# vt220 termcap written Tue Oct 25 20:41:10 1988 by Alex Latzko +# (not an official DEC entry!) +# The problem with real vt220 terminals is they don't send escapes when in +# in vt220 mode. This can be gotten around two ways. 1> don't send +# escapes or 2> put the vt220 into vt100 mode and use all the nifty +# features of vt100 advanced video which it then has. +# +# This entry takes the view of putting a vt220 into vt100 mode so +# you can use the escape key in emacs and everything else which needs it. +# +# You probably don't want to use this on a VMS machine since VMS will think +# it has a vt220 and will get fouled up coming out of emacs +# +# From: Alexander Latzko <latzko@marsenius.rutgers.edu>, 30 Dec 1996 +# (Added vt100 <rc>,<sc> to quiet a tic warning -- esr) +vt200-js|vt220-js|dec vt200 series with jump scroll, + am, + cols#80, + bel=^G, clear=\E[H\E[J, cr=^M, csr=\E[%i%p1%d;%p2%dr, + cub1=^H, cud1=^J, cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, + dch1=\E[P, dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, ht=^I, + il1=\E[L, ind=\ED, + is2=\E[61"p\E[H\E[?3l\E[?4l\E[?1l\E[?5l\E[?6l\E[?7h\E[?8h\E[?25h\E>\E[m, + kbs=^H, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, + kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, nel=^M\ED, rc=\E8, + rf=/usr/lib/tabset/vt100, ri=\EM, rmdc=, rmir=\E[4l, + rmkx=\E[?1l\E>, rmso=\E[27m$<5/>, rmul=\E[24m, + rs1=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\E7, smdc=, + smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m$<5/>, smul=\E[4m, + + +# This was DEC's vt320. Use the purpose-built one below instead +#vt320|DEC VT320 in vt100 emulation mode, +# use=vt220, + +# +# Use v320n for SCO's LYRIX. Otherwise, use Adam Thompson's vt320-nam. +# +vt320nam|v320n|DEC VT320 in vt100 emul. mode with NO AUTO WRAP mode, + am@, + rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7l\E[?8h, use=vt220, + +# These entries are not DEC's official ones, they were purpose-built for the +# VT320. Here are the designer's notes: +# <kel> is end on a PC kbd. Actually 'select' on a VT. Mapped to +# 'Erase to End of Field'... since nothing seems to use 'end' anyways... +# khome is Home on a PC kbd. Actually 'FIND' on a VT. +# Things that use <knxt> usually use tab anyways... and things that don't use +# tab usually use <knxt> instead... +# kprv is same as tab - Backtab is useless... +# I left out <sgr> because of its RIDICULOUS complexity, +# and the resulting fact that it causes the termcap translation of the entry +# to SMASH the 1k-barrier... +# From: Adam Thompson <athompso@pangea.ca> Sept 10 1995 +# (vt320: uncommented <fsl>, comnmmented out <kslt> to avoid a conflict --esr) +vt320|vt300|dec vt320 7 bit terminal, + am, eslok, hs, mir, msgr, xenl, + cols#80, lines#24, wsl#80, + acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, + bel=^G, blink=\E[5m, bold=\E[1m, civis=\E[?25l, + clear=\E[H\E[2J, cnorm=\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, + 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, fsl=\E[0$}, + home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, + il1=\E[L, ind=\ED, + is2=\E>\E[?3l\E[?4l\E[5?l\E[?7h\E[?8h\E[1;24r\E[24;1H, + ka1=\EOw, ka3=\EOy, kb2=\EOu, kbs=\177, kc1=\EOq, kc3=\EOs, + kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, + kdch1=\E[3~, kel=\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, + kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, + khome=\E[1~, kich1=\E[2~, knp=\E[6~, knxt=^I, kpp=\E[5~, + kprv=\E[Z, mc0=\E[i, mc4=\E[?4i, mc5=\E[?5i, nel=\EE, rc=\E8, + rev=\E[7m, rf=/usr/share/tabset/vt300, ri=\EM, + rmacs=\E(B, rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l\E>, + rmso=\E[m, rmul=\E[m, + rs2=\E>\E[?3l\E[?4l\E[5?l\E[?7h\E[?8h\E[1;24r\E[24;1H, + sc=\E7, sgr0=\E[m, smacs=\E(0, smam=\E[?7h, smir=\E[4h, + smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g, + tsl=\E[1$}\E[H\E[K, +vt320-nam|vt300-nam|dec vt320 7 bit terminal with no am to make SAS happy, + am@, + is2=\E>\E[?3l\E[?4l\E[5?l\E[?7l\E[?8h\E[1;24r\E[24;1H, + rs2=\E>\E[?3l\E[?4l\E[5?l\E[?7l\E[?8h\E[1;24r\E[24;1H, + use=vt320, +# We have to init 132-col mode, not 80-col mode. +vt320-w|vt300-w|dec vt320 wide 7 bit terminal, + cols#132, wsl#132, + is2=\E>\E[?3h\E[?4l\E[5?l\E[?7h\E[?8h\E[1;24r\E[24;1H, + rs2=\E>\E[?3h\E[?4l\E[5?l\E[?7h\E[?8h\E[1;24r\E[24;1H, + use=vt320, +vt320-w-nam|vt300-w-nam|dec vt320 wide 7 bit terminal with no am, + am@, + is2=\E>\E[?3h\E[?4l\E[5?l\E[?7l\E[?8h\E[1;24r\E[24;1H, + rs2=\E>\E[?3h\E[?4l\E[5?l\E[?7l\E[?8h\E[1;24r\E[24;1H, + use=vt320-w, + +# VT330 and VT340 -- These are ReGIS and SIXEL graphics terminals +# which are pretty much a superset of the VT320. They have the +# host writable status line, yet another different DRCS matrix size, +# and such, but they add the DEC Technical character set, Multiple text +# pages, selectable length pages, and the like. The difference between +# the vt330 and vt340 is that the latter has only 2 planes and a monochrome +# monitor, the former has 4 planes and a color monitor. These terminals +# support VT131 and ANSI block mode, but as with much of these things, +# termcap/terminfo doesn't deal with these features. +# +# Note that this entry is are set up in what was the standard way for GNU +# Emacs v18 terminal modes to deal with the cursor keys in that the arrow +# keys were switched into application mode at the same time the numeric pad +# is switched into application mode. This changes the definitions of the +# arrow keys. Emacs v19 is smarter and mines its keys directly out of +# your termcap or terminfo entry, +# +# From: Daniel Glasser <dag@persoft.persoft.com>, 13 Oct 1993 +# (vt340: string capability "sb=\E[M" corrected to "sr"; +# also, added <rmam>/<smam> based on the init string -- esr) +vt340|dec-vt340|vt330|dec-vt330|dec vt340 graphics terminal with 24 line page, + am, eslok, hs, mir, msgr, xenl, xon, + cols#80, it#8, lines#24, vt#3, + acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, + blink=\E[5m, bold=\E[1m, civis=\E[?25l, clear=\E[H\E[J, + cnorm=\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[?25h, dch=\E[%p1%dP, + dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, + dsl=\E[2$~\r\E[1$}\E[K\E[$}, ed=\E[J, el=\E[K, + flash=\E[?5h\E[?5l$<200/>, fsl=\E[$}, home=\E[H, ht=^I, + hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=\ED, + is2=\E<\E F\E>\E[?1h\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H, + kbs=^H, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, + kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf6=\E[17~, + kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, lf1=pf1, lf2=pf2, + lf3=pf3, lf4=pf4, nel=^M\ED, rc=\E8, rev=\E[7m, + rf=/usr/share/tabset/vt300, ri=\EM, rmacs=^O, + rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[27m, + rmul=\E[24m, rs1=\E[?3l, sc=\E7, sgr0=\E[m, smacs=^N, + smam=\E[?7h, smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m, + smul=\E[4m, tbc=\E[3g, tsl=\E[2$~\E[1$}\E[1;%dH, + +# DEC doesn't supply a vt400 description, so we add Daniel Glasser's +# (originally written with vt420 as its primary name, and usable for it). +# +# VT400/420 -- This terminal is a superset of the vt320. It adds the multiple +# text pages and long text pages with selectable length of the vt340, along +# with left and right margins, rectangular area text copy, fill, and erase +# operations, selected region character attribute change operations, +# page memory and rectangle checksums, insert/delete column, reception +# macros, and other features too numerous to remember right now. TERMCAP +# can only take advantage of a few of these added features. +# +# Note that this entry is are set up in what was the standard way for GNU +# Emacs v18 terminal modes to deal with the cursor keys in that the arrow +# keys were switched into application mode at the same time the numeric pad +# is switched into application mode. This changes the definitions of the +# arrow keys. Emacs v19 is smarter and mines its keys directly out of +# your termcap entry, +# +# From: Daniel Glasser <dag@persoft.persoft.com>, 13 Oct 1993 +# (vt400: string capability ":sb=\E[M:" corrected to ":sr=\E[M:"; +# also, added <rmam>/<smam> based on the init string -- esr) +vt400|vt400-24|dec-vt400|dec vt400 24x80 column autowrap, + am, eslok, hs, mir, msgr, xenl, xon, + cols#80, it#8, lines#24, vt#3, + acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, + blink=\E[5m, bold=\E[1m, civis=\E[?25l, + clear=\E[H\E[J$<10/>, cnorm=\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[?25h, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, + dl1=\E[M, dsl=\E[2$~\r\E[1$}\E[K\E[$}, ed=\E[J$<10/>, + el=\E[K$<4/>, flash=\E[?5h\E[?5l$<200/>, fsl=\E[$}, + home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@, ich1=\E[@, + il=\E[%p1%dL, il1=\E[L, ind=\ED, + is2=\E<\E F\E>\E[?1h\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H, + kbs=^H, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, + kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf6=\E[17~, + kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, lf1=pf1, lf2=pf2, + lf3=pf3, lf4=pf4, nel=^M\ED, rc=\E8, rev=\E[7m, + rf=/usr/share/tabset/vt300, ri=\EM, rmacs=^O, + rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[27m, + rmul=\E[24m, rs1=\E<\E[?3l\E[!p\E[?7h, sc=\E7, sgr0=\E[m, + smacs=^N, smam=\E[?7h, smir=\E[4h, smkx=\E[?1h\E=, + smso=\E[7m, smul=\E[4m, tbc=\E[3g, + tsl=\E[2$~\E[1$}\E[1;%dH, + +# (vt420: I removed <kf0>, it collided with <kf10>. I also restored +# a missing <sc> -- esr) +vt420|DEC VT420, + am, mir, xenl, xon, + cols#80, lines#24, vt#3, + acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, + bel=^G, blink=\E[5m$<2>, bold=\E[1m$<2>, + clear=\E[H\E[2J$<50>, cr=^M, csr=\E[%i%p1%d;%p2%dr, + cub1=^H, cud1=\E[B, cuf1=\E[C, + cup=\E[%i%p1%d;%p2%dH$<10>, cuu1=\E[A, dch1=\E[P, + dl1=\E[M, ed=\E[J$<50>, el=\E[K$<3>, home=\E[H, ht=^I, + if=/usr/share/tabset/vt300, il1=\E[L, ind=\ED, + is2=\E[1;24r\E[24;1H, is3=\E[?67h\E[64;1"p, kbs=^H, + kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, + kdch1=\E[3~, kf1=\EOP, kf10=\E[29~, kf2=\EOQ, kf3=\EOR, + kf4=\EOS, kf5=\E[17~, kf6=\E[18~, kf7=\E[19~, kf8=\E[20~, + kf9=\E[21~, kfnd=\E[1~, kich1=\E[2~, knp=\E[6~, kpp=\E[5~, + kslt=\E[4~, rc=\E8, rev=\E[7m$<2>, + rf=/usr/share/tabset/vt300, ri=\EM, rmacs=\E(B$<4>, + rmam=\E[?7l, rmir=\E[4l, rmkx=\E>, + rmsc=\E[?0;0r\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, + rmso=\E[m, rmul=\E[m, rs3=\E[?67h\E[64;1"p, sc=\E7, + sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e\E(B%;, + sgr0=\E[m$<2>, smacs=\E(0$<2>, smam=\E[?7h, smir=\E[4h, + smkx=\E=, smso=\E[7m, smul=\E[4m, + +# +# DEC VT220 and up support DECUDK (user-defined keys). DECUDK (i.e., pfx) +# takes two parameters, the key and the string. Translating the key is +# straightforward (keys 1-5 are not defined on real terminals, though some +# emulators define these): +# +# if (key < 16) then value = key; +# else if (key < 21) then value = key + 1; +# else if (key < 25) then value = key + 2; +# else if (key < 27) then value = key + 3; +# else if (key < 30) then value = key + 4; +# else value = key + 5; +# +# The string must be the hexadecimal equivalent, e.g., "5052494E" for "PRINT". +# There's no provision in terminfo for emitting a string in this format, so the +# application has to know it. +# +vt420pc|DEC VT420 w/PC keyboard, + kdch1=\177, kend=\E[4~, kf1=\E[11~, kf10=\E[21~, + kf11=\E[23~, kf12=\E[24~, kf13=\E[11;2~, kf14=\E[12;2~, + kf15=\E[13;2~, kf16=\E[14;2~, kf17=\E[15;2~, + kf18=\E[17;2~, kf19=\E[18;2~, kf2=\E[12~, kf20=\E[19;2~, + kf21=\E[20;2~, kf22=\E[21;2~, kf23=\E[23;2~, + kf24=\E[24;2~, kf25=\E[23~, kf26=\E[24~, kf27=\E[25~, + kf28=\E[26~, kf29=\E[28~, kf3=\E[13~, kf30=\E[29~, + kf31=\E[31~, kf32=\E[32~, kf33=\E[33~, kf34=\E[34~, + kf35=\E[35~, kf36=\E[36~, kf37=\E[23;2~, kf38=\E[24;2~, + kf39=\E[25;2~, kf4=\E[14~, kf40=\E[26;2~, kf41=\E[28;2~, + kf42=\E[29;2~, kf43=\E[31;2~, kf44=\E[32;2~, + kf45=\E[33;2~, kf46=\E[34;2~, kf47=\E[35;2~, + kf48=\E[36;2~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, + kf8=\E[19~, kf9=\E[20~, khome=\E[H, + pctrm=USR_TERM\:vt420pcdos\:, + pfx=\EP1;1|%?%{16}%p1%>%t%{0}%e%{21}%p1%>%t%{1}%e%{25}%p1%>%t%{2}%e%{27}%p1%>%t%{3}%e%{30}%p1%>%t%{4}%e%{5}%;%p1%+%d/%p2%s\E\\, use=vt420, + +vt420pcdos|DEC VT420 w/PC for DOS Merge, + lines#25, + dispc=%?%p2%{19}%=%t\E\023\021%e%p2%{32}%<%t\E%p2%c%e%p2%{127}%=%t\E\177%e%p2%c%;, + pctrm@, + rmsc=\E[?0;0r\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sgr@, + sgr0=\E[m, smsc=\E[?1;2r\E[34h, + use=vt420pc, + +vt420f|DEC VT420 with VT kbd; VT400 mode; F1-F5 used as Fkeys, + kdch1=\177, 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~, + khome=\E[H, lf1=\EOP, lf2=\EOQ, lf3=\EOR, lf4=\EOS, + use=vt420, + +vt510|DEC VT510, + use=vt420, +vt510pc|DEC VT510 w/PC keyboard, + use=vt420pc, +vt510pcdos|DEC VT510 w/PC for DOS Merge, + use=vt420pcdos, + +# VT520/VT525 +# +# The VT520 is a monochrome text terminal capable of managing up to +# four independent sessions in the terminal. It has multiple ANSI +# emulations (VT520, VT420, VT320, VT220, VT100, VT PCTerm, SCO Console) +# and ASCII emulations (WY160/60, PCTerm, 50/50+, 150/120, TVI 950, +# 925 910+, ADDS A2). This terminfo data is for the ANSI emulations only. +# +# Terminal Set-Up is entered by pressing [F3], [Caps Lock]/[F3] or +# [Alt]/[Print Screen] depending upon which keyboard and which +# terminal mode is being used. If Set-Up has been disabled or +# assigned to an unknown key, Set-Up may be entered by pressing +# [F3] as the first key after power up, regardless of keyboard type. +# (vt520: I added <rmam>/<smam> based on the init string, also <sc> -- esr) +vt520|DEC VT520, + am, mir, xenl, xon, + cols#80, lines#24, vt#3, + acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, + bel=^G, blink=\E[5m$<2>, bold=\E[1m$<2>, + clear=\E[H\E[2J$<50>, cr=^M, csr=\E[%i%p1%d;%p2%dr, + cub1=^H, cud1=\E[B, cuf1=\E[C, + cup=\E[%i%p1%d;%p2%dH$<10>, cuu1=\E[A, dch1=\E[P, + dl1=\E[M, ed=\E[J$<50>, el=\E[K$<3>, home=\E[H, ht=^I, + if=/usr/share/tabset/vt300, il1=\E[L, ind=\ED, + is2=\E[1;24r\E[24;1H, is3=\E[?67h\E[64;1"p, kbs=^H, + kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, + kdch1=\E[3~, kf0=\E[29~, kf1=\EOP, kf10=\E[29~, kf2=\EOQ, + kf3=\EOR, kf4=\EOS, kf5=\E[17~, kf6=\E[18~, kf7=\E[19~, + kf8=\E[20~, kf9=\E[21~, kfnd=\E[1~, kich1=\E[2~, knp=\E[6~, + kpp=\E[5~, kslt=\E[4~, + pfx=\EP1;1|%?%{16}%p1%>%t%{0}%e%{21}%p1%>%t%{1}%e%{25}%p1%>%t%{2}%e%{27}%p1%>%t%{3}%e%{30}%p1%>%t%{4}%e%{5}%;%p1%+%d/%p2%s\E\\, + rc=\E8, rev=\E[7m$<2>, rf=/usr/share/tabset/vt300, + ri=\EM, rmacs=\E(B$<4>, rmam=\E[?7l, rmir=\E[4l, + rmsc=\E[?0;0r\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, + rmso=\E[m, rmul=\E[m, rs3=\E[?67h\E[64;1"p, sc=\E7, + sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e\E(B%;, + sgr0=\E[m$<2>, smacs=\E(0$<2>, smam=\E[?7h, smir=\E[4h, + smso=\E[7m, smul=\E[4m, + +# (vt525: I added <rmam>/<smam> based on the init string; +# removed <rmso>=\E[m, <rmul>=\E[m, added <sc> -- esr) +vt525|DEC VT525, + am, mir, xenl, xon, + cols#80, lines#24, vt#3, + acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, + bel=^G, blink=\E[5m$<2>, bold=\E[1m$<2>, + clear=\E[H\E[2J$<50>, cr=^M, csr=\E[%i%p1%d;%p2%dr, + cub1=^H, cud1=\E[B, cuf1=\E[C, + cup=\E[%i%p1%d;%p2%dH$<10>, cuu1=\E[A, dch1=\E[P, + dl1=\E[M, ed=\E[J$<50>, el=\E[K$<3>, home=\E[H, ht=^I, + if=/usr/share/tabset/vt300, il1=\E[L, ind=\ED, + is2=\E[1;24r\E[24;1H, is3=\E[?67h\E[64;1"p, kbs=^H, + kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, + kdch1=\E[3~, kf0=\E[29~, kf1=\EOP, kf10=\E[29~, kf2=\EOQ, + kf3=\EOR, kf4=\EOS, kf5=\E[17~, kf6=\E[18~, kf7=\E[19~, + kf8=\E[20~, kf9=\E[21~, kfnd=\E[1~, kich1=\E[2~, knp=\E[6~, + kpp=\E[5~, kslt=\E[4~, + pfx=\EP1;1|%?%{16}%p1%>%t%{0}%e%{21}%p1%>%t%{1}%e%{25}%p1%>%t%{2}%e%{27}%p1%>%t%{3}%e%{30}%p1%>%t%{4}%e%{5}%;%p1%+%d/%p2%s\E\\, + rc=\E8, rev=\E[7m$<2>, rf=/usr/share/tabset/vt300, + ri=\EM, rmacs=\E(B$<4>, rmam=\E[?7l, rmir=\E[4l, + rmsc=\E[?0;0r\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, + rmso=\E[m, rmul=\E[m, rs3=\E[?67h\E[64;1"p, sc=\E7, + sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e\E(B%;, + sgr0=\E[m$<2>, smacs=\E(0$<2>, smam=\E[?7h, smir=\E[4h, + smso=\E[7m, smul=\E[4m, diff --git a/tests/examplefiles/test.csd b/tests/examplefiles/test.csd new file mode 100644 index 00000000..9122309b --- /dev/null +++ b/tests/examplefiles/test.csd @@ -0,0 +1,260 @@ +<CsoundSynthesizer> +<CsInstruments> +// This is a Csound orchestra file for testing a Pygments <http://pygments.org> +// lexer. Csound single-line comments can be preceded by a pair of forward +// slashes... +; ...or a semicolon. + +/* Block comments begin with /* and end with */ + +// Orchestras begin with a header of audio parameters. +nchnls = 1 +nchnls_i = 1 +sr = 44100 +0dbfs = 1 +ksmps = 10 + +// The control rate kr = sr / ksmps can be omitted when the number of audio +// samples in a control period (ksmps) is set, but kr may appear in older +// orchestras. +kr = 4410 + +// Orchestras contain instruments. These begin with the keyword instr followed +// by a comma-separated list of numbers or names of the instrument. Instruments +// end at the endin keyword and cannot be nested. +instr 1, N_a_M_e_, +Name + // Instruments contain statements. Here is a typical statement: + aSignal oscil 0dbfs, 440, 1 + // Statements are terminated with a newline (possibly preceded by a comment). + // To write a statement on several lines, precede the newline with a + // backslash. + prints \ + "hello, world\n";comment + + // Csound 6 introduced function syntax for opcodes with one or zero outputs. + // The oscil statement above is the same as + aSignal = oscil(0dbfs, 440, 1) + + // Instruments can contain control structures. + kNote = p3 + if (kNote == 0) then + kFrequency = 220 + elseif kNote == 1 then // Parentheses around binary expressions are optional. + kFrequency = 440 + endif + + // Csound 6 introduced looping structures. + iIndex = 0 + while iIndex < 5 do + print iIndex + iIndex += 1 + od + iIndex = 0 + until iIndex >= 5 do + print iIndex + iIndex += 1 + enduntil + // Both kinds of loops can be terminated by either od or enduntil. + + // Single-line strings are enclosed in double-quotes. + prints "string\\\r\n\t\"" + // Multi-line strings are enclosed in pairs of curly braces. + prints {{ + hello, + + world + }} + + // Instruments often end with a statement containing an output opcode. + outc aSignal +endin + +// Orchestras can also contain user-defined opcodes (UDOs). Here is an +// oscillator with one audio-rate output and two control-rate inputs: +opcode anOscillator, a, kk + kAmplitude, kFrequency xin + aSignal vco2 kAmplitude, kFrequency + xout aSignal +endop +instr TestOscillator + outc(anOscillator(0dbfs, 110)) +endin + +// Python can be executed in Csound +// <http://www.csounds.com/manual/html/pyrun.html>. So can Lua +// <http://www.csounds.com/manual/html/lua.html>. +pyruni {{ +import random + +pool = [(1 + i / 10.0) ** 1.2 for i in range(100)] + +def get_number_from_pool(n, p): + if random.random() < p: + i = int(random.random() * len(pool)) + pool[i] = n + return random.choice(pool) +}} + +// The Csound preprocessor supports conditional compilation and including files. +#ifdef DEBUG +#undef DEBUG +#include "filename.orc" +#endif + +// The preprocessor also supports object- and function-like macros. This is an +// object-like macro that defines a number: +#define A_HZ #440# + +// This is a function-like macro: +#define OSCIL_MACRO(VOLUME'FREQUENCY'TABLE) #oscil $VOLUME, $FREQUENCY, $TABLE# + +// Bodies of macros are enclosed in # and can contain newlines. The arguments of +// function-like macros are separated by single-quotes. Uses of macros are +// prefixed with a dollar sign. +instr TestMacro + aSignal $OSCIL_MACRO(1'$A_HZ'1) + // Not unlike PHP, macros expand in double-quoted strings. + prints "The frequency of the oscillator is $A_HZ Hz.\n" + out aSignal +endin + +// Here are other things to note about Csound. + +// There are two bitwise NOT operators, ~ and ¬ (U+00AC). The latter is common +// on keyboards in the United Kingdom +// <https://en.wikipedia.org/wiki/British_and_American_keyboards>. +instr TestBitwiseNOT + print ~42 + print ¬42 +endin + +// Csound uses # for bitwise XOR, which the Csound manual calls bitwise +// non-equivalence <http://www.csounds.com/manual/html/opnonequiv.html>. +instr TestBitwiseXOR + print 0 # 0 + print 0 # 1 + print 1 # 0 + print 1 # 1 +endin + +// Loops and if-then statements are relatively recent additions to Csound. There +// are many flow-control opcodes that involve goto and labels. +instr TestGoto + // This... + if p3 > 0 goto if_label + goto else_label +if_label: + prints "if branch\n" + goto endif_label +else_label: + prints "else branch\n" +endif_label: + + // ...is the same as this. + if p3 > 0 then + prints "if branch\n" + else + prints "else branch\n" + endif + + // This... + iIndex = 0 +loop_label: + print iIndex + iIndex += 1 + if iIndex < 10 goto loop_label + + // ...is the same as this... + iIndex = 0 +loop_lt_label: + print iIndex + loop_lt iIndex, 1, 10, loop_lt_label + + // ...and this. + iIndex = 0 + while iIndex < 10 do + print iIndex + iIndex += 1 + od +endin + +// The prints and printks opcodes +// <https://github.com/csound/csound/blob/develop/OOps/ugrw1.c#L831>, arguably +// the primary methods of logging output, treat certain sequences of characters +// different from printf in C. +instr TestPrints + // ^ prints an ESCAPE character (U+001B), not a CIRCUMFLEX ACCENT character + // (U+005E). ^^ prints a CIRCUMFLEX ACCENT. + prints "^^\n" + // ~ prints an ESCAPE character (U+001B) followed by a [, not a TILDE + // character (U+007E). ~~ prints a TILDE. + prints "~~\n" + // \A, \B, \N, \R, and \T correspond to the escaped lowercase characters (that + // is, BELL (U+0007), BACKSPACE (U+0008), new line (U+000A), CARRIAGE RETURN + // (U+000D), and tab (U+0009)). + prints "\T\R\N" + // %n, %r, and %t are the same as \n, \r, and \t, as are %N, %R, and %T. + prints "%t%r%n" + // %! prints a semicolon. This is a hold-over from old versions of Csound that + // allowed comments to begin in strings. + prints "; %!\n" +endin + +// The arguments of function-like macros can be separated by # instead of '. +// These two lines define the same macro. +#define OSCIL_MACRO(VOLUME'FREQUENCY'TABLE) #oscil $VOLUME, $FREQUENCY, $TABLE# +#define OSCIL_MACRO(VOLUME#FREQUENCY#TABLE) #oscil $VOLUME, $FREQUENCY, $TABLE# + +// Uses of macros can optionally be suffixed with a period. +instr TestMacroPeriodSuffix + aSignal $OSCIL_MACRO.(1'$A_HZ'1) + prints "The frequency of the oscillator is $A_HZ.Hz.\n" + out aSignal +endin + +// Csound has @ and @@ operator-like macros that, when followed by a literal +// non-negative integer, expand to the next power of 2 and the next power of 2 +// plus 1: +// @x = 2^(ceil(log2(x + 1))), x >= 0 +// @@0 = 2 +// @@x = 2^(ceil(log2(x))) + 1, x > 0 +// These macros are in +// <https://github.com/csound/csound/blob/develop/Engine/csound_orc.l#L542> (and +// <https://github.com/csound/csound/blob/develop/Engine/csound_sco.lex#L202>) +// and are described at <http://www.csounds.com/manual/html/ScoreEval.html>. +instr TestAt + prints "%d %2d %2d\n", 0, @0, @@0 + prints "%d %2d %2d\n", 1, @1, @@1 + prints "%d %2d %2d\n", 2, @2, @@2 + prints "%d %2d %2d\n", 3, @3, @@3 + prints "%d %2d %2d\n", 4, @4, @@4 + prints "%d %2d %2d\n", 5, @5, @@5 + prints "%d %2d %2d\n", 6, @6, @@6 + prints "%d %2d %2d\n", 7, @7, @@7 + prints "%d %2d %2d\n", 8, @8, @@8 + prints "%d %2d %2d\n", 9, @9, @@9 +endin + +// Including newlines in macros can lead to confusing code, but it tests the +// lexer. +instr MacroAbuse + if 1 == 1 then + prints "on\n" +#define FOO# +BAR +#endif // This ends the if statement. It is not a preprocessor directive. +endin +</CsInstruments> +<CsScore> +f 1 0 16384 10 1 +i "N_a_M_e_" 0 2 +i "TestOscillator" 2 2 +i "TestBitwiseNOT" 0 1 +i "TestBitwiseXOR" 0 1 +i "TestGoto" 0 1 +i "TestMacroPeriodSuffix" 4 1 +i "TestAt" 0 1 +i "MacroAbuse" 0 1 +e +</CsScore> +</CsoundSynthesizer> diff --git a/tests/examplefiles/test.ecl b/tests/examplefiles/test.ecl deleted file mode 100644 index b686492a..00000000 --- a/tests/examplefiles/test.ecl +++ /dev/null @@ -1,58 +0,0 @@ -/*############################################################################## - - Copyright (C) 2011 HPCC Systems. - - All rights reserved. This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -############################################################################## */ - -#option ('slidingJoins', true); - -namesRecord := - RECORD -string20 surname; -string10 forename; -integer2 age; -integer2 dadAge; -integer2 mumAge; - END; - -namesRecord2 := - record -string10 extra; -namesRecord; - end; - -namesTable := dataset('x',namesRecord,FLAT); -namesTable2 := dataset('y',namesRecord2,FLAT); - -integer2 aveAgeL(namesRecord l) := (l.dadAge+l.mumAge)/2; -integer2 aveAgeR(namesRecord2 r) := (r.dadAge+r.mumAge)/2; - -// Standard join on a function of left and right -output(join(namesTable, namesTable2, aveAgeL(left) = aveAgeR(right))); - -//Several simple examples of sliding join syntax -output(join(namesTable, namesTable2, left.age >= right.age - 10 and left.age <= right.age +10)); -output(join(namesTable, namesTable2, left.age between right.age - 10 and right.age +10)); -output(join(namesTable, namesTable2, left.age between right.age + 10 and right.age +30)); -output(join(namesTable, namesTable2, left.age between (right.age + 20) - 10 and (right.age +20) + 10)); -output(join(namesTable, namesTable2, aveAgeL(left) between aveAgeR(right)+10 and aveAgeR(right)+40)); - -//Same, but on strings. Also includes age to ensure sort is done by non-sliding before sliding. -output(join(namesTable, namesTable2, left.surname between right.surname[1..10]+'AAAAAAAAAA' and right.surname[1..10]+'ZZZZZZZZZZ' and left.age=right.age)); -output(join(namesTable, namesTable2, left.surname between right.surname[1..10]+'AAAAAAAAAA' and right.surname[1..10]+'ZZZZZZZZZZ' and left.age=right.age,all)); - -//This should not generate a self join -output(join(namesTable, namesTable, left.age between right.age - 10 and right.age +10)); - diff --git a/tests/examplefiles/test.sco b/tests/examplefiles/test.sco new file mode 100644 index 00000000..a0b39251 --- /dev/null +++ b/tests/examplefiles/test.sco @@ -0,0 +1,10 @@ +f 1 0 16384 10 1 +i "N_a_M_e_" 0 2 +i "TestOscillator" 2 2 +i "TestBitwiseNOT" 0 1 +i "TestBitwiseXOR" 0 1 +i "TestGoto" 0 1 +i "TestMacroPeriodSuffix" 4 1 +i "TestAt" 0 1 +i "MacroAbuse" 0 1 +e diff --git a/tests/test_clexer.py b/tests/test_clexer.py index 6a3dcbce..fd7f58fc 100644 --- a/tests/test_clexer.py +++ b/tests/test_clexer.py @@ -234,3 +234,26 @@ class CLexerTest(unittest.TestCase): (Token.Text, u'\n'), ] self.assertEqual(tokens, list(self.lexer.get_tokens(textwrap.dedent(fragment)))) + + def testPreprocFile(self): + fragment = u'#include <foo>\n' + tokens = [ + (Token.Comment.Preproc, u'#'), + (Token.Comment.Preproc, u'include'), + (Token.Text, u' '), + (Token.Comment.PreprocFile, u'<foo>'), + (Token.Comment.Preproc, u'\n'), + ] + self.assertEqual(tokens, list(self.lexer.get_tokens(fragment))) + + def testPreprocFile2(self): + fragment = u'#include "foo.h"\n' + tokens = [ + (Token.Comment.Preproc, u'#'), + (Token.Comment.Preproc, u'include'), + (Token.Text, u' '), + (Token.Comment.PreprocFile, u'"foo.h"'), + (Token.Comment.Preproc, u'\n'), + ] + self.assertEqual(tokens, list(self.lexer.get_tokens(fragment))) + diff --git a/tests/test_ezhil.py b/tests/test_ezhil.py new file mode 100644 index 00000000..23b9cb41 --- /dev/null +++ b/tests/test_ezhil.py @@ -0,0 +1,182 @@ +# -*- coding: utf-8 -*- +""" + Basic EzhilLexer Test + ~~~~~~~~~~~~~~~~~~~~ + + :copyright: Copyright 2015 Muthiah Annamalai <ezhillang@gmail.com> + :license: BSD, see LICENSE for details. +""" + +import unittest + +from pygments.token import Operator, Number, Text, Token +from pygments.lexers import EzhilLexer + + +class EzhilTest(unittest.TestCase): + + def setUp(self): + self.lexer = EzhilLexer() + self.maxDiff = None + + def testSum(self): + fragment = u'1+3\n' + tokens = [ + (Number.Integer, u'1'), + (Operator, u'+'), + (Number.Integer, u'3'), + (Text, u'\n'), + ] + self.assertEqual(tokens, list(self.lexer.get_tokens(fragment))) + + def testGCDExpr(self): + fragment = u'1^3+(5-5)*gcd(a,b)\n' + tokens = [ + (Token.Number.Integer,u'1'), + (Token.Operator,u'^'), + (Token.Literal.Number.Integer, u'3'), + (Token.Operator, u'+'), + (Token.Punctuation, u'('), + (Token.Literal.Number.Integer, u'5'), + (Token.Operator, u'-'), + (Token.Literal.Number.Integer, u'5'), + (Token.Punctuation, u')'), + (Token.Operator, u'*'), + (Token.Name, u'gcd'), + (Token.Punctuation, u'('), + (Token.Name, u'a'), + (Token.Operator, u','), + (Token.Name, u'b'), + (Token.Punctuation, u')'), + (Token.Text, u'\n') + ] + self.assertEqual(tokens, list(self.lexer.get_tokens(fragment))) + + def testIfStatement(self): + fragment = u"""@( 0 > 3 ) ஆனால் + பதிப்பி "wont print" +முடி""" + tokens = [ + (Token.Operator, u'@'), + (Token.Punctuation, u'('), + (Token.Text, u' '), + (Token.Literal.Number.Integer,u'0'), + (Token.Text, u' '), + (Token.Operator,u'>'), + (Token.Text, u' '), + (Token.Literal.Number.Integer, u'3'), + (Token.Text, u' '), + (Token.Punctuation, u')'), + (Token.Text, u' '), + (Token.Keyword, u'ஆனால்'), + (Token.Text, u'\n'), + (Token.Text, u'\t'), + (Token.Keyword, u'பதிப்பி'), + (Token.Text, u' '), + (Token.Literal.String, u'"wont print"'), + (Token.Text, u'\t'), + (Token.Text, u'\n'), + (Token.Keyword, u'முடி'), + (Token.Text, u'\n') + ] + self.assertEqual(tokens, list(self.lexer.get_tokens(fragment))) + + def testFunction(self): + fragment = u"""# (C) முத்தையா அண்ணாமலை 2013, 2015 +நிரல்பாகம் gcd ( x, y ) + மு = max(x,y) + q = min(x,y) + + @( q == 0 ) ஆனால் + பின்கொடு மு + முடி + பின்கொடு gcd( மு - q , q ) +முடி\n""" + tokens = [ + (Token.Comment.Single, + u'# (C) \u0bae\u0bc1\u0ba4\u0bcd\u0ba4\u0bc8\u0baf\u0bbe \u0b85\u0ba3\u0bcd\u0ba3\u0bbe\u0bae\u0bb2\u0bc8 2013, 2015\n'), + (Token.Keyword,u'நிரல்பாகம்'), + (Token.Text, u' '), + (Token.Name, u'gcd'), + (Token.Text, u' '), + (Token.Punctuation, u'('), + (Token.Text, u' '), + (Token.Name, u'x'), + (Token.Operator, u','), + (Token.Text, u' '), + (Token.Name, u'y'), + (Token.Text, u' '), + (Token.Punctuation, u')'), + (Token.Text, u'\n'), + (Token.Text, u' '), + (Token.Name, u'\u0bae\u0bc1'), + (Token.Text, u' '), + (Token.Operator, u'='), + (Token.Text, u' '), + (Token.Name.Builtin, u'max'), + (Token.Punctuation, u'('), + (Token.Name, u'x'), + (Token.Operator, u','), + (Token.Name, u'y'), + (Token.Punctuation, u')'), + (Token.Text, u'\n'), + (Token.Text, u' '), + (Token.Name, u'q'), + (Token.Text, u' '), + (Token.Operator, u'='), + (Token.Text, u' '), + (Token.Name.Builtin, u'min'), + (Token.Punctuation, u'('), + (Token.Name, u'x'), + (Token.Operator, u','), + (Token.Name, u'y'), + (Token.Punctuation, u')'), + (Token.Text, u'\n'), + (Token.Text, u'\n'), + (Token.Text, u' '), + (Token.Operator, u'@'), + (Token.Punctuation, u'('), + (Token.Text, u' '), + (Token.Name, u'q'), + (Token.Text, u' '), + (Token.Operator, u'=='), + (Token.Text, u' '), + (Token.Literal.Number.Integer, u'0'), + (Token.Text, u' '), + (Token.Punctuation, u')'), + (Token.Text, u' '), + (Token.Keyword, u'ஆனால்'), + (Token.Text, u'\n'), + (Token.Text, u' '), + (Token.Keyword, u'பின்கொடு'), + (Token.Text, u' '), + (Token.Name, u'\u0bae\u0bc1'), + (Token.Text, u'\n'), + (Token.Text, u' '), + (Token.Keyword, u'முடி'), + (Token.Text, u'\n'), + (Token.Text, u' '), + (Token.Keyword, u'\u0baa\u0bbf\u0ba9\u0bcd\u0b95\u0bca\u0b9f\u0bc1'), + (Token.Text, u' '), + (Token.Name, u'gcd'), + (Token.Punctuation, u'('), + (Token.Text, u' '), + (Token.Name, u'\u0bae\u0bc1'), + (Token.Text, u' '), + (Token.Operator, u'-'), + (Token.Text, u' '), + (Token.Name, u'q'), + (Token.Text, u' '), + (Token.Operator, u','), + (Token.Text, u' '), + (Token.Name, u'q'), + (Token.Text, u' '), + (Token.Punctuation, u')'), + (Token.Text, u'\n'), + (Token.Keyword, u'முடி'), #u'\u0bae\u0bc1\u0b9f\u0bbf'), + (Token.Text, u'\n') + ] + self.assertEqual(tokens, list(self.lexer.get_tokens(fragment))) + +if __name__ == "__main__": + unittest.main() |