|
1 | 1 | " This file is autogenerated from the script 'generate_L2U_keymap.jl' |
2 | | -" The full script can be found in the comments at the bottom of this file |
3 | 2 | " The symbols are based on Julia version 1.1.0-DEV.695 |
| 3 | +" The full generating script can be found in the comments at the bottom of this file, |
| 4 | +" and it can be extracted with: |
| 5 | +" |
| 6 | +" $ grep '^">' latex2unicode_utf-8.vim | cut -c4- > generate_L2U_keymap.jl' |
| 7 | +" |
| 8 | +" To produce this keymap file you need to have Julia compilied from source, and |
| 9 | +" to run `make UnicodeData.txt` inside Julia's `doc` directory. |
| 10 | +" Then you can run: |
| 11 | +" |
| 12 | +" $ julia generate_L2U_keymap.jl.jl |
| 13 | +" |
4 | 14 |
|
5 | 15 | scriptencoding utf-8 |
6 | 16 |
|
@@ -7069,155 +7079,139 @@ loadkeymap |
7069 | 7079 | \\zeta <char-0x003B6> " ζ : GREEK SMALL LETTER ZETA |
7070 | 7080 | " --------------------------------- ---------------------------- " ---------- : -------------------------------------------------------------------------------------------------------- |
7071 | 7081 |
|
7072 | | -"" Below here is the script that was used to produce this file. |
7073 | | -"" You can copy it to a file called 'generate_L2U_keymap.jl', removing the initial quotes, and run: |
7074 | | -"" |
7075 | | -"" $ julia generate_L2U_keymap.jl |
7076 | | -"" |
| 7082 | +" Below here is the script that was used to produce this file. |
7077 | 7083 |
|
7078 | | -" #!/bin/env julia |
7079 | | -" |
7080 | | -" const filename = "latex2unicode_utf-8" |
7081 | | -" |
7082 | | -" function unambiguous_completions(completions::Dict{String,String}) |
7083 | | -" return completions |
7084 | | -" allinputs = sort!(collect(keys(completions))) |
7085 | | -" new_completions = copy(completions) |
7086 | | -" |
7087 | | -" for input in allinputs |
7088 | | -" chars = completions[input] |
7089 | | -" l = length(input) |
7090 | | -" for i = 2:(l-1) |
7091 | | -" n = length(filter(x->startswith(x, input[1:i]), allinputs)) |
7092 | | -" @assert n ≥ 1 |
7093 | | -" n > 1 && continue |
7094 | | -" for j = i:(l-1) |
7095 | | -" # new_completions[input[1:j] * "<Tab>"] = chars |
7096 | | -" new_completions[input[1:j]] = chars |
7097 | | -" end |
7098 | | -" break |
7099 | | -" end |
7100 | | -" # new_completions[input * "<Tab>"] = chars |
7101 | | -" end |
7102 | | -" return new_completions |
7103 | | -" end |
7104 | | -" |
7105 | | -" # We want to avoid situations in which the user types e.g. \delt and pauses, |
7106 | | -" # and the result is "∇t" because "\del" gets recognized and then there is some leftover "t". |
7107 | | -" # This allows us to get completions with <Tab> for example. |
7108 | | -" function fix_completions(completions::Dict{String,String}) |
7109 | | -" allinputs = sort!(collect(keys(completions))) |
7110 | | -" new_completions = copy(completions) |
7111 | | -" |
7112 | | -" for input in allinputs |
7113 | | -" chars = completions[input] |
7114 | | -" l = length(input) |
7115 | | -" longer = filter(x->startswith(x, input)&&length(x)>l, allinputs) |
7116 | | -" n = length(longer) |
7117 | | -" n == 0 && continue |
7118 | | -" new_completions[input * "<Tab>"] = chars |
7119 | | -" for other in longer |
7120 | | -" for j = (l+1):(length(other)-1) |
7121 | | -" haskey(new_completions, other[1:j]) && continue |
7122 | | -" new_completions[other[1:j]] = other[1:j] |
7123 | | -" end |
7124 | | -" end |
7125 | | -" end |
7126 | | -" return new_completions |
7127 | | -" end |
7128 | | -" |
7129 | | -" function unicode_data() |
7130 | | -" file = normpath(Sys.BINDIR, "..", "..", "doc", "UnicodeData.txt") |
7131 | | -" names = Dict{UInt32, String}() |
7132 | | -" open(file) do unidata |
7133 | | -" for line in readlines(unidata) |
7134 | | -" id, name, desc = split(line, ";")[[1, 2, 11]] |
7135 | | -" codepoint = parse(UInt32, "0x$id") |
7136 | | -" names[codepoint] = (name == "" ? desc : desc == "" ? name : "$name / $desc") |
7137 | | -" end |
7138 | | -" end |
7139 | | -" return names |
7140 | | -" end |
7141 | | -" |
7142 | | -" # Prepend a dotted circle ('◌' i.e. '\u25CC') to combining characters |
7143 | | -" function fix_combining_chars(char) |
7144 | | -" cat = Base.Unicode.category_code(char) |
7145 | | -" return string(cat == 6 || cat == 8 ? "◌" : "", char) |
7146 | | -" end |
7147 | | -" |
7148 | | -" function table_entries(completions::Dict{String,String}, unicode_dict) |
7149 | | -" latex = String[] |
7150 | | -" code = String[] |
7151 | | -" unicode = String[] |
7152 | | -" desc = String[] |
7153 | | -" |
7154 | | -" for (input, chars) in sort!(collect(completions)) |
7155 | | -" code_points, unicode_names, characters = String[], String[], String[] |
7156 | | -" if startswith(chars, "\\") |
7157 | | -" push!(code_points, replace(chars, "\\" => "\\\\")) |
7158 | | -" push!(unicode_names, "(Incomplete sequence)") |
7159 | | -" push!(characters, "") |
7160 | | -" else |
7161 | | -" for char in chars |
7162 | | -" push!(code_points, "<char-0x$(uppercase(string(UInt32(char), base = 16, pad = 5)))>") |
7163 | | -" push!(unicode_names, get(unicode_dict, UInt32(char), "(No Unicode name)")) |
7164 | | -" push!(characters, isempty(characters) ? fix_combining_chars(char) : "$char") |
7165 | | -" end |
7166 | | -" end |
7167 | | -" push!(latex, replace(input, "\\"=>"\\\\")) |
7168 | | -" push!(code, join(code_points)) |
7169 | | -" push!(unicode, join(characters)) |
7170 | | -" push!(desc, join(unicode_names, " + ")) |
7171 | | -" end |
7172 | | -" return latex, code, unicode, desc |
7173 | | -" end |
7174 | | -" |
7175 | | -" open("$filename.vim","w") do f |
7176 | | -" println(f, "\" This file is autogenerated from the script '$(basename(Base.source_path()))'") |
7177 | | -" println(f, "\" The full script can be found in the comments at the bottom of this file") |
7178 | | -" println(f, "\" The symbols are based on Julia version $VERSION") |
7179 | | -" println(f) |
7180 | | -" println(f, "scriptencoding utf-8") |
7181 | | -" println(f) |
7182 | | -" println(f, "let b:keymap_name = \"L2U\"") |
7183 | | -" println(f, "loadkeymap") |
7184 | | -" println(f) |
7185 | | -" col_headers = ["\" Tab completion sequence", "Code point", "Character", "Unicode name"] |
7186 | | -" |
7187 | | -" latex, code, unicode, desc = |
7188 | | -" table_entries( |
7189 | | -" fix_completions(merge( |
7190 | | -" REPL.REPLCompletions.latex_symbols, |
7191 | | -" REPL.REPLCompletions.emoji_symbols |
7192 | | -" )), |
7193 | | -" unicode_data() |
7194 | | -" ) |
7195 | | -" |
7196 | | -" lw = max(length(col_headers[3]), maximum(map(length, latex))) |
7197 | | -" cw = max(length(col_headers[1]), maximum(map(length, code))) |
7198 | | -" uw = max(length(col_headers[2]), maximum(map(length, unicode))) |
7199 | | -" dw = max(length(col_headers[4]), maximum(map(length, desc))) |
7200 | | -" |
7201 | | -" print_padded(l, c, u, d) = println(f, rpad(l, lw), " ", rpad(c, cw), " \" ", rpad(u, uw), " : ", d) |
7202 | | -" |
7203 | | -" print_padded(col_headers...) |
7204 | | -" print_padded("\" " * "-"^(lw-2), "-"^cw, "-"^uw, "-"^dw) |
7205 | | -" |
7206 | | -" for (l, c, u, d) in zip(latex, code, unicode, desc) |
7207 | | -" print_padded(l, c, u, d) |
7208 | | -" end |
7209 | | -" print_padded("\" " * "-"^(lw-2), "-"^cw, "-"^uw, "-"^dw) |
7210 | | -" |
7211 | | -" println(f) |
7212 | | -" println(f, "\"\" Below here is the script that was used to produce this file.") |
7213 | | -" println(f, "\"\" You can copy it to a file called 'generate_L2U_keymap.jl', removing the initial quotes, and run:") |
7214 | | -" println(f, "\"\"") |
7215 | | -" println(f, "\"\" \$ julia generate_L2U_keymap.jl") |
7216 | | -" println(f, "\"\"") |
7217 | | -" println(f) |
7218 | | -" for l in readlines(Base.source_path()) |
7219 | | -" println(f, "\" ", l) |
7220 | | -" end |
7221 | | -" println(f) |
7222 | | -" end |
| 7084 | +"> #!/bin/env julia |
| 7085 | +"> |
| 7086 | +"> const filename = "latex2unicode_utf-8" |
| 7087 | +"> |
| 7088 | +"> # We want to avoid situations in which the user types e.g. \delt and pauses, |
| 7089 | +"> # and the result is "∇t" because "\del" gets recognized and then there is some leftover "t". |
| 7090 | +"> # This allows us to get completions with <Tab> for example. |
| 7091 | +"> function fix_completions(completions::Dict{String,String}) |
| 7092 | +"> allinputs = sort!(collect(keys(completions))) |
| 7093 | +"> new_completions = copy(completions) |
| 7094 | +"> |
| 7095 | +"> for input in allinputs |
| 7096 | +"> chars = completions[input] |
| 7097 | +"> l = length(input) |
| 7098 | +"> longer = filter(x->startswith(x, input)&&length(x)>l, allinputs) |
| 7099 | +"> n = length(longer) |
| 7100 | +"> n == 0 && continue |
| 7101 | +"> new_completions[input * "<Tab>"] = chars |
| 7102 | +"> for other in longer |
| 7103 | +"> for j = (l+1):(length(other)-1) |
| 7104 | +"> haskey(new_completions, other[1:j]) && continue |
| 7105 | +"> new_completions[other[1:j]] = other[1:j] |
| 7106 | +"> end |
| 7107 | +"> end |
| 7108 | +"> end |
| 7109 | +"> return new_completions |
| 7110 | +"> end |
| 7111 | +"> |
| 7112 | +"> function unicode_data() |
| 7113 | +"> file = normpath(Sys.BINDIR, "..", "..", "doc", "UnicodeData.txt") |
| 7114 | +"> names = Dict{UInt32, String}() |
| 7115 | +"> open(file) do unidata |
| 7116 | +"> for line in readlines(unidata) |
| 7117 | +"> id, name, desc = split(line, ";")[[1, 2, 11]] |
| 7118 | +"> codepoint = parse(UInt32, "0x$id") |
| 7119 | +"> names[codepoint] = (name == "" ? desc : desc == "" ? name : "$name / $desc") |
| 7120 | +"> end |
| 7121 | +"> end |
| 7122 | +"> return names |
| 7123 | +"> end |
| 7124 | +"> |
| 7125 | +"> # Prepend a dotted circle ('◌' i.e. '\u25CC') to combining characters |
| 7126 | +"> function fix_combining_chars(char) |
| 7127 | +"> cat = Base.Unicode.category_code(char) |
| 7128 | +"> return string(cat == 6 || cat == 8 ? "◌" : "", char) |
| 7129 | +"> end |
| 7130 | +"> |
| 7131 | +"> function table_entries(completions::Dict{String,String}, unicode_dict) |
| 7132 | +"> latex = String[] |
| 7133 | +"> code = String[] |
| 7134 | +"> unicode = String[] |
| 7135 | +"> desc = String[] |
| 7136 | +"> |
| 7137 | +"> for (input, chars) in sort!(collect(completions)) |
| 7138 | +"> code_points, unicode_names, characters = String[], String[], String[] |
| 7139 | +"> if startswith(chars, "\\") |
| 7140 | +"> push!(code_points, replace(chars, "\\" => "\\\\")) |
| 7141 | +"> push!(unicode_names, "(Incomplete sequence)") |
| 7142 | +"> push!(characters, "") |
| 7143 | +"> else |
| 7144 | +"> for char in chars |
| 7145 | +"> push!(code_points, "<char-0x$(uppercase(string(UInt32(char), base = 16, pad = 5)))>") |
| 7146 | +"> push!(unicode_names, get(unicode_dict, UInt32(char), "(No Unicode name)")) |
| 7147 | +"> push!(characters, isempty(characters) ? fix_combining_chars(char) : "$char") |
| 7148 | +"> end |
| 7149 | +"> end |
| 7150 | +"> push!(latex, replace(input, "\\"=>"\\\\")) |
| 7151 | +"> push!(code, join(code_points)) |
| 7152 | +"> push!(unicode, join(characters)) |
| 7153 | +"> push!(desc, join(unicode_names, " + ")) |
| 7154 | +"> end |
| 7155 | +"> return latex, code, unicode, desc |
| 7156 | +"> end |
| 7157 | +"> |
| 7158 | +"> open("$filename.vim","w") do f |
| 7159 | +"> print(f, """ |
| 7160 | +"> " This file is autogenerated from the script '$(basename(Base.source_path()))' |
| 7161 | +"> " The symbols are based on Julia version $VERSION |
| 7162 | +"> " The full generating script can be found in the comments at the bottom of this file, |
| 7163 | +"> " and it can be extracted with: |
| 7164 | +"> " |
| 7165 | +"> " \$ grep '^\">' $filename.vim | cut -c4- > $(basename(Base.source_path()))' |
| 7166 | +"> " |
| 7167 | +"> " To produce this keymap file you need to have Julia compilied from source, and |
| 7168 | +"> " to run `make UnicodeData.txt` inside Julia's `doc` directory. |
| 7169 | +"> " Then you can run: |
| 7170 | +"> " |
| 7171 | +"> " \$ julia $(basename(Base.source_path())).jl |
| 7172 | +"> " |
| 7173 | +"> |
| 7174 | +"> scriptencoding utf-8 |
| 7175 | +"> |
| 7176 | +"> let b:keymap_name = "L2U" |
| 7177 | +"> loadkeymap |
| 7178 | +"> |
| 7179 | +"> """) |
| 7180 | +"> |
| 7181 | +"> col_headers = ["\" Tab completion sequence", "Code point", "Character", "Unicode name"] |
| 7182 | +"> |
| 7183 | +"> latex, code, unicode, desc = |
| 7184 | +"> table_entries( |
| 7185 | +"> fix_completions(merge( |
| 7186 | +"> REPL.REPLCompletions.latex_symbols, |
| 7187 | +"> REPL.REPLCompletions.emoji_symbols |
| 7188 | +"> )), |
| 7189 | +"> unicode_data() |
| 7190 | +"> ) |
| 7191 | +"> |
| 7192 | +"> lw = max(length(col_headers[3]), maximum(map(length, latex))) |
| 7193 | +"> cw = max(length(col_headers[1]), maximum(map(length, code))) |
| 7194 | +"> uw = max(length(col_headers[2]), maximum(map(length, unicode))) |
| 7195 | +"> dw = max(length(col_headers[4]), maximum(map(length, desc))) |
| 7196 | +"> |
| 7197 | +"> print_padded(l, c, u, d) = println(f, rpad(l, lw), " ", rpad(c, cw), " \" ", rpad(u, uw), " : ", d) |
| 7198 | +"> |
| 7199 | +"> print_padded(col_headers...) |
| 7200 | +"> print_padded("\" " * "-"^(lw-2), "-"^cw, "-"^uw, "-"^dw) |
| 7201 | +"> |
| 7202 | +"> for (l, c, u, d) in zip(latex, code, unicode, desc) |
| 7203 | +"> print_padded(l, c, u, d) |
| 7204 | +"> end |
| 7205 | +"> print_padded("\" " * "-"^(lw-2), "-"^cw, "-"^uw, "-"^dw) |
| 7206 | +"> |
| 7207 | +"> print(f, """ |
| 7208 | +"> |
| 7209 | +"> " Below here is the script that was used to produce this file. |
| 7210 | +"> |
| 7211 | +"> """) |
| 7212 | +"> for l in readlines(Base.source_path()) |
| 7213 | +"> println(f, "\"> ", l) |
| 7214 | +"> end |
| 7215 | +"> println(f) |
| 7216 | +"> end |
7223 | 7217 |
|
0 commit comments