llm-shell 0.9.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +61 -66
- data/lib/llm/shell/command.rb +40 -40
- data/lib/llm/shell/commands/clear_screen.rb +4 -18
- data/lib/llm/shell/commands/debug_mode.rb +12 -0
- data/lib/llm/shell/commands/dir_import.rb +4 -20
- data/lib/llm/shell/commands/disable_tool.rb +33 -0
- data/lib/llm/shell/commands/enable_tool.rb +33 -0
- data/lib/llm/shell/commands/file_import.rb +4 -20
- data/lib/llm/shell/commands/help.rb +23 -36
- data/lib/llm/shell/commands/show_chat.rb +4 -19
- data/lib/llm/shell/commands/show_version.rb +4 -20
- data/lib/llm/shell/commands/system_prompt.rb +4 -18
- data/lib/llm/shell/completion.rb +5 -5
- data/lib/llm/shell/config.rb +4 -5
- data/lib/llm/shell/formatter.rb +1 -2
- data/lib/llm/shell/internal/coderay/lib/coderay/duo.rb +81 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/_map.rb +17 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/comment_filter.rb +25 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/count.rb +39 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/debug.rb +49 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/debug_lint.rb +63 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/div.rb +23 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/encoder.rb +190 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/filter.rb +58 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/html/css.rb +65 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/html/numbering.rb +108 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/html/output.rb +164 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/html.rb +333 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/json.rb +83 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/lines_of_code.rb +45 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/lint.rb +59 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/null.rb +18 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/page.rb +24 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/span.rb +23 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/statistic.rb +95 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/terminal.rb +195 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/text.rb +46 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/token_kind_filter.rb +111 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/xml.rb +72 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/yaml.rb +50 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders.rb +18 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/for_redcloth.rb +95 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/helpers/file_type.rb +151 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/helpers/plugin.rb +55 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/helpers/plugin_host.rb +221 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/helpers/word_list.rb +72 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/_map.rb +24 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/c.rb +189 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/clojure.rb +217 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/cpp.rb +217 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/css.rb +196 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/debug.rb +75 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/delphi.rb +144 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/diff.rb +221 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/erb.rb +81 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/go.rb +208 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/groovy.rb +268 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/haml.rb +168 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/html.rb +275 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/java/builtin_types.rb +421 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/java.rb +174 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/java_script.rb +236 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/json.rb +98 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/lua.rb +280 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/php.rb +527 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/python.rb +287 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/raydebug.rb +75 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/ruby/patterns.rb +178 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/ruby/string_state.rb +79 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/ruby.rb +477 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/sass.rb +232 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/scanner.rb +337 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/sql.rb +169 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/taskpaper.rb +36 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/text.rb +26 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/xml.rb +17 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/yaml.rb +140 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners.rb +27 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/styles/_map.rb +7 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/styles/alpha.rb +153 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/styles/style.rb +18 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/styles.rb +15 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/token_kinds.rb +85 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/tokens.rb +164 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/tokens_proxy.rb +55 -0
- data/lib/llm/shell/internal/coderay/lib/coderay/version.rb +3 -0
- data/lib/llm/shell/internal/coderay/lib/coderay.rb +284 -0
- data/lib/llm/shell/internal/io-line/lib/io/line/multiple.rb +19 -0
- data/lib/{io → llm/shell/internal/io-line/lib/io}/line.rb +2 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/bot/builder.rb +31 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/bot/conversable.rb +37 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/bot/prompt/completion.rb +49 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/bot/prompt/respond.rb +49 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/bot.rb +150 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/buffer.rb +162 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/client.rb +36 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/error.rb +49 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/eventhandler.rb +44 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/eventstream/event.rb +69 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/eventstream/parser.rb +88 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/eventstream.rb +8 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/file.rb +91 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/function.rb +177 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/message.rb +178 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/mime.rb +140 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/multipart.rb +101 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/object/builder.rb +38 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/object/kernel.rb +53 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/object.rb +89 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/provider.rb +352 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/error_handler.rb +36 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/files.rb +155 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/format/completion_format.rb +88 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/format.rb +29 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/models.rb +54 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/response/completion.rb +39 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/response/enumerable.rb +11 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/response/file.rb +23 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/response/web_search.rb +21 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/stream_parser.rb +66 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic.rb +138 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/deepseek/format/completion_format.rb +68 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/deepseek/format.rb +27 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/deepseek.rb +75 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/audio.rb +73 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/error_handler.rb +47 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/files.rb +146 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/format/completion_format.rb +69 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/format.rb +39 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/images.rb +133 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/models.rb +60 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/completion.rb +35 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/embedding.rb +8 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/file.rb +11 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/files.rb +15 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/image.rb +31 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/models.rb +15 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/web_search.rb +22 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/stream_parser.rb +86 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini.rb +173 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/llamacpp.rb +74 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/error_handler.rb +36 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/format/completion_format.rb +77 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/format.rb +29 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/models.rb +56 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/response/completion.rb +28 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/response/embedding.rb +9 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/stream_parser.rb +44 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama.rb +116 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/audio.rb +91 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/error_handler.rb +46 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/files.rb +134 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format/completion_format.rb +90 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format/moderation_format.rb +35 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format/respond_format.rb +72 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format.rb +54 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/images.rb +109 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/models.rb +55 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/moderations.rb +65 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/audio.rb +7 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/completion.rb +40 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/embedding.rb +9 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/enumerable.rb +23 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/file.rb +7 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/image.rb +16 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/moderations.rb +34 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/responds.rb +48 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/web_search.rb +21 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/responses/stream_parser.rb +76 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/responses.rb +99 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/stream_parser.rb +86 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/vector_stores.rb +228 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai.rb +206 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/xai/images.rb +58 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/xai.rb +72 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/zai.rb +74 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/response.rb +67 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/array.rb +26 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/boolean.rb +13 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/integer.rb +43 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/leaf.rb +78 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/null.rb +13 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/number.rb +43 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/object.rb +41 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/string.rb +34 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/version.rb +8 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema.rb +81 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/server_tool.rb +32 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/tool/param.rb +75 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/tool.rb +78 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/utils.rb +19 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm/version.rb +5 -0
- data/lib/llm/shell/internal/llm.rb/lib/llm.rb +121 -0
- data/lib/llm/shell/internal/optparse/lib/optionparser.rb +2 -0
- data/lib/llm/shell/internal/optparse/lib/optparse/ac.rb +70 -0
- data/lib/llm/shell/internal/optparse/lib/optparse/date.rb +18 -0
- data/lib/llm/shell/internal/optparse/lib/optparse/kwargs.rb +27 -0
- data/lib/llm/shell/internal/optparse/lib/optparse/shellwords.rb +7 -0
- data/lib/llm/shell/internal/optparse/lib/optparse/time.rb +11 -0
- data/lib/llm/shell/internal/optparse/lib/optparse/uri.rb +7 -0
- data/lib/llm/shell/internal/optparse/lib/optparse/version.rb +80 -0
- data/lib/llm/shell/internal/optparse/lib/optparse.rb +2469 -0
- data/lib/llm/shell/internal/paint/lib/paint/constants.rb +104 -0
- data/lib/llm/shell/internal/paint/lib/paint/pa.rb +13 -0
- data/lib/llm/shell/internal/paint/lib/paint/rgb_colors.rb +14 -0
- data/lib/llm/shell/internal/paint/lib/paint/shortcuts.rb +100 -0
- data/lib/llm/shell/internal/paint/lib/paint/shortcuts_version.rb +5 -0
- data/lib/llm/shell/internal/paint/lib/paint/util.rb +16 -0
- data/lib/llm/shell/internal/paint/lib/paint/version.rb +5 -0
- data/lib/llm/shell/internal/paint/lib/paint.rb +261 -0
- data/lib/llm/shell/internal/reline/lib/reline/config.rb +378 -0
- data/lib/llm/shell/internal/reline/lib/reline/face.rb +199 -0
- data/lib/llm/shell/internal/reline/lib/reline/history.rb +76 -0
- data/lib/llm/shell/internal/reline/lib/reline/io/ansi.rb +322 -0
- data/lib/llm/shell/internal/reline/lib/reline/io/dumb.rb +120 -0
- data/lib/llm/shell/internal/reline/lib/reline/io/windows.rb +530 -0
- data/lib/llm/shell/internal/reline/lib/reline/io.rb +55 -0
- data/lib/llm/shell/internal/reline/lib/reline/key_actor/base.rb +37 -0
- data/lib/llm/shell/internal/reline/lib/reline/key_actor/composite.rb +17 -0
- data/lib/llm/shell/internal/reline/lib/reline/key_actor/emacs.rb +517 -0
- data/lib/llm/shell/internal/reline/lib/reline/key_actor/vi_command.rb +518 -0
- data/lib/llm/shell/internal/reline/lib/reline/key_actor/vi_insert.rb +517 -0
- data/lib/llm/shell/internal/reline/lib/reline/key_actor.rb +8 -0
- data/lib/llm/shell/internal/reline/lib/reline/key_stroke.rb +119 -0
- data/lib/llm/shell/internal/reline/lib/reline/kill_ring.rb +125 -0
- data/lib/llm/shell/internal/reline/lib/reline/line_editor.rb +2356 -0
- data/lib/llm/shell/internal/reline/lib/reline/unicode/east_asian_width.rb +1292 -0
- data/lib/llm/shell/internal/reline/lib/reline/unicode.rb +421 -0
- data/lib/llm/shell/internal/reline/lib/reline/version.rb +3 -0
- data/lib/llm/shell/internal/reline/lib/reline.rb +527 -0
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/generated_parser.rb +712 -0
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/handler.rb +268 -0
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/local_date.rb +35 -0
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/local_date_time.rb +42 -0
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/local_time.rb +40 -0
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/parser.rb +21 -0
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/scanner.rb +92 -0
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/string_utils.rb +40 -0
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/version.rb +5 -0
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb.rb +49 -0
- data/lib/llm/shell/options.rb +1 -1
- data/lib/llm/shell/renderer.rb +2 -3
- data/lib/llm/shell/repl.rb +21 -16
- data/lib/llm/shell/tool.rb +42 -0
- data/lib/llm/shell/tools/read_file.rb +15 -0
- data/lib/llm/shell/tools/system.rb +17 -0
- data/lib/llm/shell/tools/write_file.rb +16 -0
- data/lib/llm/shell/version.rb +1 -1
- data/lib/llm/shell.rb +83 -39
- data/libexec/llm-shell/shell +4 -6
- data/llm-shell.gemspec +0 -4
- metadata +233 -63
- data/lib/llm/function.rb +0 -17
- data/lib/llm/shell/command/extension.rb +0 -42
- data/lib/llm/shell/commands/utils.rb +0 -21
- data/lib/llm/shell/functions/read_file.rb +0 -22
- data/lib/llm/shell/functions/write_file.rb +0 -22
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
module Reline::KeyActor
|
|
2
|
+
VI_INSERT_MAPPING = [
|
|
3
|
+
# 0 ^@
|
|
4
|
+
nil,
|
|
5
|
+
# 1 ^A
|
|
6
|
+
:ed_insert,
|
|
7
|
+
# 2 ^B
|
|
8
|
+
:ed_insert,
|
|
9
|
+
# 3 ^C
|
|
10
|
+
:ed_insert,
|
|
11
|
+
# 4 ^D
|
|
12
|
+
:vi_list_or_eof,
|
|
13
|
+
# 5 ^E
|
|
14
|
+
:ed_insert,
|
|
15
|
+
# 6 ^F
|
|
16
|
+
:ed_insert,
|
|
17
|
+
# 7 ^G
|
|
18
|
+
:ed_insert,
|
|
19
|
+
# 8 ^H
|
|
20
|
+
:vi_delete_prev_char,
|
|
21
|
+
# 9 ^I
|
|
22
|
+
:complete,
|
|
23
|
+
# 10 ^J
|
|
24
|
+
:ed_newline,
|
|
25
|
+
# 11 ^K
|
|
26
|
+
:ed_insert,
|
|
27
|
+
# 12 ^L
|
|
28
|
+
:ed_insert,
|
|
29
|
+
# 13 ^M
|
|
30
|
+
:ed_newline,
|
|
31
|
+
# 14 ^N
|
|
32
|
+
:menu_complete,
|
|
33
|
+
# 15 ^O
|
|
34
|
+
:ed_insert,
|
|
35
|
+
# 16 ^P
|
|
36
|
+
:menu_complete_backward,
|
|
37
|
+
# 17 ^Q
|
|
38
|
+
:ed_ignore,
|
|
39
|
+
# 18 ^R
|
|
40
|
+
:vi_search_prev,
|
|
41
|
+
# 19 ^S
|
|
42
|
+
:vi_search_next,
|
|
43
|
+
# 20 ^T
|
|
44
|
+
:ed_transpose_chars,
|
|
45
|
+
# 21 ^U
|
|
46
|
+
:vi_kill_line_prev,
|
|
47
|
+
# 22 ^V
|
|
48
|
+
:ed_quoted_insert,
|
|
49
|
+
# 23 ^W
|
|
50
|
+
:ed_delete_prev_word,
|
|
51
|
+
# 24 ^X
|
|
52
|
+
:ed_insert,
|
|
53
|
+
# 25 ^Y
|
|
54
|
+
:em_yank,
|
|
55
|
+
# 26 ^Z
|
|
56
|
+
:ed_insert,
|
|
57
|
+
# 27 ^[
|
|
58
|
+
:vi_command_mode,
|
|
59
|
+
# 28 ^\
|
|
60
|
+
:ed_ignore,
|
|
61
|
+
# 29 ^]
|
|
62
|
+
:ed_insert,
|
|
63
|
+
# 30 ^^
|
|
64
|
+
:ed_insert,
|
|
65
|
+
# 31 ^_
|
|
66
|
+
:ed_insert,
|
|
67
|
+
# 32 SPACE
|
|
68
|
+
:ed_insert,
|
|
69
|
+
# 33 !
|
|
70
|
+
:ed_insert,
|
|
71
|
+
# 34 "
|
|
72
|
+
:ed_insert,
|
|
73
|
+
# 35 #
|
|
74
|
+
:ed_insert,
|
|
75
|
+
# 36 $
|
|
76
|
+
:ed_insert,
|
|
77
|
+
# 37 %
|
|
78
|
+
:ed_insert,
|
|
79
|
+
# 38 &
|
|
80
|
+
:ed_insert,
|
|
81
|
+
# 39 '
|
|
82
|
+
:ed_insert,
|
|
83
|
+
# 40 (
|
|
84
|
+
:ed_insert,
|
|
85
|
+
# 41 )
|
|
86
|
+
:ed_insert,
|
|
87
|
+
# 42 *
|
|
88
|
+
:ed_insert,
|
|
89
|
+
# 43 +
|
|
90
|
+
:ed_insert,
|
|
91
|
+
# 44 ,
|
|
92
|
+
:ed_insert,
|
|
93
|
+
# 45 -
|
|
94
|
+
:ed_insert,
|
|
95
|
+
# 46 .
|
|
96
|
+
:ed_insert,
|
|
97
|
+
# 47 /
|
|
98
|
+
:ed_insert,
|
|
99
|
+
# 48 0
|
|
100
|
+
:ed_digit,
|
|
101
|
+
# 49 1
|
|
102
|
+
:ed_digit,
|
|
103
|
+
# 50 2
|
|
104
|
+
:ed_digit,
|
|
105
|
+
# 51 3
|
|
106
|
+
:ed_digit,
|
|
107
|
+
# 52 4
|
|
108
|
+
:ed_digit,
|
|
109
|
+
# 53 5
|
|
110
|
+
:ed_digit,
|
|
111
|
+
# 54 6
|
|
112
|
+
:ed_digit,
|
|
113
|
+
# 55 7
|
|
114
|
+
:ed_digit,
|
|
115
|
+
# 56 8
|
|
116
|
+
:ed_digit,
|
|
117
|
+
# 57 9
|
|
118
|
+
:ed_digit,
|
|
119
|
+
# 58 :
|
|
120
|
+
:ed_insert,
|
|
121
|
+
# 59 ;
|
|
122
|
+
:ed_insert,
|
|
123
|
+
# 60 <
|
|
124
|
+
:ed_insert,
|
|
125
|
+
# 61 =
|
|
126
|
+
:ed_insert,
|
|
127
|
+
# 62 >
|
|
128
|
+
:ed_insert,
|
|
129
|
+
# 63 ?
|
|
130
|
+
:ed_insert,
|
|
131
|
+
# 64 @
|
|
132
|
+
:ed_insert,
|
|
133
|
+
# 65 A
|
|
134
|
+
:ed_insert,
|
|
135
|
+
# 66 B
|
|
136
|
+
:ed_insert,
|
|
137
|
+
# 67 C
|
|
138
|
+
:ed_insert,
|
|
139
|
+
# 68 D
|
|
140
|
+
:ed_insert,
|
|
141
|
+
# 69 E
|
|
142
|
+
:ed_insert,
|
|
143
|
+
# 70 F
|
|
144
|
+
:ed_insert,
|
|
145
|
+
# 71 G
|
|
146
|
+
:ed_insert,
|
|
147
|
+
# 72 H
|
|
148
|
+
:ed_insert,
|
|
149
|
+
# 73 I
|
|
150
|
+
:ed_insert,
|
|
151
|
+
# 74 J
|
|
152
|
+
:ed_insert,
|
|
153
|
+
# 75 K
|
|
154
|
+
:ed_insert,
|
|
155
|
+
# 76 L
|
|
156
|
+
:ed_insert,
|
|
157
|
+
# 77 M
|
|
158
|
+
:ed_insert,
|
|
159
|
+
# 78 N
|
|
160
|
+
:ed_insert,
|
|
161
|
+
# 79 O
|
|
162
|
+
:ed_insert,
|
|
163
|
+
# 80 P
|
|
164
|
+
:ed_insert,
|
|
165
|
+
# 81 Q
|
|
166
|
+
:ed_insert,
|
|
167
|
+
# 82 R
|
|
168
|
+
:ed_insert,
|
|
169
|
+
# 83 S
|
|
170
|
+
:ed_insert,
|
|
171
|
+
# 84 T
|
|
172
|
+
:ed_insert,
|
|
173
|
+
# 85 U
|
|
174
|
+
:ed_insert,
|
|
175
|
+
# 86 V
|
|
176
|
+
:ed_insert,
|
|
177
|
+
# 87 W
|
|
178
|
+
:ed_insert,
|
|
179
|
+
# 88 X
|
|
180
|
+
:ed_insert,
|
|
181
|
+
# 89 Y
|
|
182
|
+
:ed_insert,
|
|
183
|
+
# 90 Z
|
|
184
|
+
:ed_insert,
|
|
185
|
+
# 91 [
|
|
186
|
+
:ed_insert,
|
|
187
|
+
# 92 \
|
|
188
|
+
:ed_insert,
|
|
189
|
+
# 93 ]
|
|
190
|
+
:ed_insert,
|
|
191
|
+
# 94 ^
|
|
192
|
+
:ed_insert,
|
|
193
|
+
# 95 _
|
|
194
|
+
:ed_insert,
|
|
195
|
+
# 96 `
|
|
196
|
+
:ed_insert,
|
|
197
|
+
# 97 a
|
|
198
|
+
:ed_insert,
|
|
199
|
+
# 98 b
|
|
200
|
+
:ed_insert,
|
|
201
|
+
# 99 c
|
|
202
|
+
:ed_insert,
|
|
203
|
+
# 100 d
|
|
204
|
+
:ed_insert,
|
|
205
|
+
# 101 e
|
|
206
|
+
:ed_insert,
|
|
207
|
+
# 102 f
|
|
208
|
+
:ed_insert,
|
|
209
|
+
# 103 g
|
|
210
|
+
:ed_insert,
|
|
211
|
+
# 104 h
|
|
212
|
+
:ed_insert,
|
|
213
|
+
# 105 i
|
|
214
|
+
:ed_insert,
|
|
215
|
+
# 106 j
|
|
216
|
+
:ed_insert,
|
|
217
|
+
# 107 k
|
|
218
|
+
:ed_insert,
|
|
219
|
+
# 108 l
|
|
220
|
+
:ed_insert,
|
|
221
|
+
# 109 m
|
|
222
|
+
:ed_insert,
|
|
223
|
+
# 110 n
|
|
224
|
+
:ed_insert,
|
|
225
|
+
# 111 o
|
|
226
|
+
:ed_insert,
|
|
227
|
+
# 112 p
|
|
228
|
+
:ed_insert,
|
|
229
|
+
# 113 q
|
|
230
|
+
:ed_insert,
|
|
231
|
+
# 114 r
|
|
232
|
+
:ed_insert,
|
|
233
|
+
# 115 s
|
|
234
|
+
:ed_insert,
|
|
235
|
+
# 116 t
|
|
236
|
+
:ed_insert,
|
|
237
|
+
# 117 u
|
|
238
|
+
:ed_insert,
|
|
239
|
+
# 118 v
|
|
240
|
+
:ed_insert,
|
|
241
|
+
# 119 w
|
|
242
|
+
:ed_insert,
|
|
243
|
+
# 120 x
|
|
244
|
+
:ed_insert,
|
|
245
|
+
# 121 y
|
|
246
|
+
:ed_insert,
|
|
247
|
+
# 122 z
|
|
248
|
+
:ed_insert,
|
|
249
|
+
# 123 {
|
|
250
|
+
:ed_insert,
|
|
251
|
+
# 124 |
|
|
252
|
+
:ed_insert,
|
|
253
|
+
# 125 }
|
|
254
|
+
:ed_insert,
|
|
255
|
+
# 126 ~
|
|
256
|
+
:ed_insert,
|
|
257
|
+
# 127 ^?
|
|
258
|
+
:vi_delete_prev_char,
|
|
259
|
+
# 128 M-^@
|
|
260
|
+
nil,
|
|
261
|
+
# 129 M-^A
|
|
262
|
+
nil,
|
|
263
|
+
# 130 M-^B
|
|
264
|
+
nil,
|
|
265
|
+
# 131 M-^C
|
|
266
|
+
nil,
|
|
267
|
+
# 132 M-^D
|
|
268
|
+
nil,
|
|
269
|
+
# 133 M-^E
|
|
270
|
+
nil,
|
|
271
|
+
# 134 M-^F
|
|
272
|
+
nil,
|
|
273
|
+
# 135 M-^G
|
|
274
|
+
nil,
|
|
275
|
+
# 136 M-^H
|
|
276
|
+
nil,
|
|
277
|
+
# 137 M-^I
|
|
278
|
+
nil,
|
|
279
|
+
# 138 M-^J
|
|
280
|
+
:key_newline,
|
|
281
|
+
# 139 M-^K
|
|
282
|
+
nil,
|
|
283
|
+
# 140 M-^L
|
|
284
|
+
nil,
|
|
285
|
+
# 141 M-^M
|
|
286
|
+
:key_newline,
|
|
287
|
+
# 142 M-^N
|
|
288
|
+
nil,
|
|
289
|
+
# 143 M-^O
|
|
290
|
+
nil,
|
|
291
|
+
# 144 M-^P
|
|
292
|
+
nil,
|
|
293
|
+
# 145 M-^Q
|
|
294
|
+
nil,
|
|
295
|
+
# 146 M-^R
|
|
296
|
+
nil,
|
|
297
|
+
# 147 M-^S
|
|
298
|
+
nil,
|
|
299
|
+
# 148 M-^T
|
|
300
|
+
nil,
|
|
301
|
+
# 149 M-^U
|
|
302
|
+
nil,
|
|
303
|
+
# 150 M-^V
|
|
304
|
+
nil,
|
|
305
|
+
# 151 M-^W
|
|
306
|
+
nil,
|
|
307
|
+
# 152 M-^X
|
|
308
|
+
nil,
|
|
309
|
+
# 153 M-^Y
|
|
310
|
+
nil,
|
|
311
|
+
# 154 M-^Z
|
|
312
|
+
nil,
|
|
313
|
+
# 155 M-^[
|
|
314
|
+
nil,
|
|
315
|
+
# 156 M-^\
|
|
316
|
+
nil,
|
|
317
|
+
# 157 M-^]
|
|
318
|
+
nil,
|
|
319
|
+
# 158 M-^^
|
|
320
|
+
nil,
|
|
321
|
+
# 159 M-^_
|
|
322
|
+
nil,
|
|
323
|
+
# 160 M-SPACE
|
|
324
|
+
nil,
|
|
325
|
+
# 161 M-!
|
|
326
|
+
nil,
|
|
327
|
+
# 162 M-"
|
|
328
|
+
nil,
|
|
329
|
+
# 163 M-#
|
|
330
|
+
nil,
|
|
331
|
+
# 164 M-$
|
|
332
|
+
nil,
|
|
333
|
+
# 165 M-%
|
|
334
|
+
nil,
|
|
335
|
+
# 166 M-&
|
|
336
|
+
nil,
|
|
337
|
+
# 167 M-'
|
|
338
|
+
nil,
|
|
339
|
+
# 168 M-(
|
|
340
|
+
nil,
|
|
341
|
+
# 169 M-)
|
|
342
|
+
nil,
|
|
343
|
+
# 170 M-*
|
|
344
|
+
nil,
|
|
345
|
+
# 171 M-+
|
|
346
|
+
nil,
|
|
347
|
+
# 172 M-,
|
|
348
|
+
nil,
|
|
349
|
+
# 173 M--
|
|
350
|
+
nil,
|
|
351
|
+
# 174 M-.
|
|
352
|
+
nil,
|
|
353
|
+
# 175 M-/
|
|
354
|
+
nil,
|
|
355
|
+
# 176 M-0
|
|
356
|
+
nil,
|
|
357
|
+
# 177 M-1
|
|
358
|
+
nil,
|
|
359
|
+
# 178 M-2
|
|
360
|
+
nil,
|
|
361
|
+
# 179 M-3
|
|
362
|
+
nil,
|
|
363
|
+
# 180 M-4
|
|
364
|
+
nil,
|
|
365
|
+
# 181 M-5
|
|
366
|
+
nil,
|
|
367
|
+
# 182 M-6
|
|
368
|
+
nil,
|
|
369
|
+
# 183 M-7
|
|
370
|
+
nil,
|
|
371
|
+
# 184 M-8
|
|
372
|
+
nil,
|
|
373
|
+
# 185 M-9
|
|
374
|
+
nil,
|
|
375
|
+
# 186 M-:
|
|
376
|
+
nil,
|
|
377
|
+
# 187 M-;
|
|
378
|
+
nil,
|
|
379
|
+
# 188 M-<
|
|
380
|
+
nil,
|
|
381
|
+
# 189 M-=
|
|
382
|
+
nil,
|
|
383
|
+
# 190 M->
|
|
384
|
+
nil,
|
|
385
|
+
# 191 M-?
|
|
386
|
+
nil,
|
|
387
|
+
# 192 M-@
|
|
388
|
+
nil,
|
|
389
|
+
# 193 M-A
|
|
390
|
+
nil,
|
|
391
|
+
# 194 M-B
|
|
392
|
+
nil,
|
|
393
|
+
# 195 M-C
|
|
394
|
+
nil,
|
|
395
|
+
# 196 M-D
|
|
396
|
+
nil,
|
|
397
|
+
# 197 M-E
|
|
398
|
+
nil,
|
|
399
|
+
# 198 M-F
|
|
400
|
+
nil,
|
|
401
|
+
# 199 M-G
|
|
402
|
+
nil,
|
|
403
|
+
# 200 M-H
|
|
404
|
+
nil,
|
|
405
|
+
# 201 M-I
|
|
406
|
+
nil,
|
|
407
|
+
# 202 M-J
|
|
408
|
+
nil,
|
|
409
|
+
# 203 M-K
|
|
410
|
+
nil,
|
|
411
|
+
# 204 M-L
|
|
412
|
+
nil,
|
|
413
|
+
# 205 M-M
|
|
414
|
+
nil,
|
|
415
|
+
# 206 M-N
|
|
416
|
+
nil,
|
|
417
|
+
# 207 M-O
|
|
418
|
+
nil,
|
|
419
|
+
# 208 M-P
|
|
420
|
+
nil,
|
|
421
|
+
# 209 M-Q
|
|
422
|
+
nil,
|
|
423
|
+
# 210 M-R
|
|
424
|
+
nil,
|
|
425
|
+
# 211 M-S
|
|
426
|
+
nil,
|
|
427
|
+
# 212 M-T
|
|
428
|
+
nil,
|
|
429
|
+
# 213 M-U
|
|
430
|
+
nil,
|
|
431
|
+
# 214 M-V
|
|
432
|
+
nil,
|
|
433
|
+
# 215 M-W
|
|
434
|
+
nil,
|
|
435
|
+
# 216 M-X
|
|
436
|
+
nil,
|
|
437
|
+
# 217 M-Y
|
|
438
|
+
nil,
|
|
439
|
+
# 218 M-Z
|
|
440
|
+
nil,
|
|
441
|
+
# 219 M-[
|
|
442
|
+
nil,
|
|
443
|
+
# 220 M-\
|
|
444
|
+
nil,
|
|
445
|
+
# 221 M-]
|
|
446
|
+
nil,
|
|
447
|
+
# 222 M-^
|
|
448
|
+
nil,
|
|
449
|
+
# 223 M-_
|
|
450
|
+
nil,
|
|
451
|
+
# 224 M-`
|
|
452
|
+
nil,
|
|
453
|
+
# 225 M-a
|
|
454
|
+
nil,
|
|
455
|
+
# 226 M-b
|
|
456
|
+
nil,
|
|
457
|
+
# 227 M-c
|
|
458
|
+
nil,
|
|
459
|
+
# 228 M-d
|
|
460
|
+
nil,
|
|
461
|
+
# 229 M-e
|
|
462
|
+
nil,
|
|
463
|
+
# 230 M-f
|
|
464
|
+
nil,
|
|
465
|
+
# 231 M-g
|
|
466
|
+
nil,
|
|
467
|
+
# 232 M-h
|
|
468
|
+
nil,
|
|
469
|
+
# 233 M-i
|
|
470
|
+
nil,
|
|
471
|
+
# 234 M-j
|
|
472
|
+
nil,
|
|
473
|
+
# 235 M-k
|
|
474
|
+
nil,
|
|
475
|
+
# 236 M-l
|
|
476
|
+
nil,
|
|
477
|
+
# 237 M-m
|
|
478
|
+
nil,
|
|
479
|
+
# 238 M-n
|
|
480
|
+
nil,
|
|
481
|
+
# 239 M-o
|
|
482
|
+
nil,
|
|
483
|
+
# 240 M-p
|
|
484
|
+
nil,
|
|
485
|
+
# 241 M-q
|
|
486
|
+
nil,
|
|
487
|
+
# 242 M-r
|
|
488
|
+
nil,
|
|
489
|
+
# 243 M-s
|
|
490
|
+
nil,
|
|
491
|
+
# 244 M-t
|
|
492
|
+
nil,
|
|
493
|
+
# 245 M-u
|
|
494
|
+
nil,
|
|
495
|
+
# 246 M-v
|
|
496
|
+
nil,
|
|
497
|
+
# 247 M-w
|
|
498
|
+
nil,
|
|
499
|
+
# 248 M-x
|
|
500
|
+
nil,
|
|
501
|
+
# 249 M-y
|
|
502
|
+
nil,
|
|
503
|
+
# 250 M-z
|
|
504
|
+
nil,
|
|
505
|
+
# 251 M-{
|
|
506
|
+
nil,
|
|
507
|
+
# 252 M-|
|
|
508
|
+
nil,
|
|
509
|
+
# 253 M-}
|
|
510
|
+
nil,
|
|
511
|
+
# 254 M-~
|
|
512
|
+
nil,
|
|
513
|
+
# 255 M-^?
|
|
514
|
+
nil
|
|
515
|
+
# EOF
|
|
516
|
+
]
|
|
517
|
+
end
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
class Reline::KeyStroke
|
|
2
|
+
ESC_BYTE = 27
|
|
3
|
+
CSI_PARAMETER_BYTES_RANGE = 0x30..0x3f
|
|
4
|
+
CSI_INTERMEDIATE_BYTES_RANGE = (0x20..0x2f)
|
|
5
|
+
|
|
6
|
+
attr_accessor :encoding
|
|
7
|
+
|
|
8
|
+
def initialize(config, encoding)
|
|
9
|
+
@config = config
|
|
10
|
+
@encoding = encoding
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Input exactly matches to a key sequence
|
|
14
|
+
MATCHING = :matching
|
|
15
|
+
# Input partially matches to a key sequence
|
|
16
|
+
MATCHED = :matched
|
|
17
|
+
# Input matches to a key sequence and the key sequence is a prefix of another key sequence
|
|
18
|
+
MATCHING_MATCHED = :matching_matched
|
|
19
|
+
# Input does not match to any key sequence
|
|
20
|
+
UNMATCHED = :unmatched
|
|
21
|
+
|
|
22
|
+
def match_status(input)
|
|
23
|
+
matching = key_mapping.matching?(input)
|
|
24
|
+
matched = key_mapping.get(input)
|
|
25
|
+
if matching && matched
|
|
26
|
+
MATCHING_MATCHED
|
|
27
|
+
elsif matching
|
|
28
|
+
MATCHING
|
|
29
|
+
elsif matched
|
|
30
|
+
MATCHED
|
|
31
|
+
elsif input[0] == ESC_BYTE
|
|
32
|
+
match_unknown_escape_sequence(input, vi_mode: @config.editing_mode_is?(:vi_insert, :vi_command))
|
|
33
|
+
else
|
|
34
|
+
s = input.pack('c*').force_encoding(@encoding)
|
|
35
|
+
if s.valid_encoding?
|
|
36
|
+
s.size == 1 ? MATCHED : UNMATCHED
|
|
37
|
+
else
|
|
38
|
+
# Invalid string is MATCHING (part of valid string) or MATCHED (invalid bytes to be ignored)
|
|
39
|
+
MATCHING_MATCHED
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def expand(input)
|
|
45
|
+
matched_bytes = nil
|
|
46
|
+
(1..input.size).each do |i|
|
|
47
|
+
bytes = input.take(i)
|
|
48
|
+
status = match_status(bytes)
|
|
49
|
+
matched_bytes = bytes if status == MATCHED || status == MATCHING_MATCHED
|
|
50
|
+
break if status == MATCHED || status == UNMATCHED
|
|
51
|
+
end
|
|
52
|
+
return [[], []] unless matched_bytes
|
|
53
|
+
|
|
54
|
+
func = key_mapping.get(matched_bytes)
|
|
55
|
+
s = matched_bytes.pack('c*').force_encoding(@encoding)
|
|
56
|
+
if func.is_a?(Array)
|
|
57
|
+
# Perform simple macro expansion for single byte key bindings.
|
|
58
|
+
# Multibyte key bindings and recursive macro expansion are not supported yet.
|
|
59
|
+
macro = func.pack('c*').force_encoding(@encoding)
|
|
60
|
+
keys = macro.chars.map do |c|
|
|
61
|
+
f = key_mapping.get(c.bytes)
|
|
62
|
+
Reline::Key.new(c, f.is_a?(Symbol) ? f : :ed_insert, false)
|
|
63
|
+
end
|
|
64
|
+
elsif func
|
|
65
|
+
keys = [Reline::Key.new(s, func, false)]
|
|
66
|
+
else
|
|
67
|
+
if s.valid_encoding? && s.size == 1
|
|
68
|
+
keys = [Reline::Key.new(s, :ed_insert, false)]
|
|
69
|
+
else
|
|
70
|
+
keys = []
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
[keys, input.drop(matched_bytes.size)]
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
private
|
|
78
|
+
|
|
79
|
+
# returns match status of CSI/SS3 sequence and matched length
|
|
80
|
+
def match_unknown_escape_sequence(input, vi_mode: false)
|
|
81
|
+
idx = 0
|
|
82
|
+
return UNMATCHED unless input[idx] == ESC_BYTE
|
|
83
|
+
idx += 1
|
|
84
|
+
idx += 1 if input[idx] == ESC_BYTE
|
|
85
|
+
|
|
86
|
+
case input[idx]
|
|
87
|
+
when nil
|
|
88
|
+
if idx == 1 # `ESC`
|
|
89
|
+
return MATCHING_MATCHED
|
|
90
|
+
else # `ESC ESC`
|
|
91
|
+
return MATCHING
|
|
92
|
+
end
|
|
93
|
+
when 91 # == '['.ord
|
|
94
|
+
# CSI sequence `ESC [ ... char`
|
|
95
|
+
idx += 1
|
|
96
|
+
idx += 1 while idx < input.size && CSI_PARAMETER_BYTES_RANGE.cover?(input[idx])
|
|
97
|
+
idx += 1 while idx < input.size && CSI_INTERMEDIATE_BYTES_RANGE.cover?(input[idx])
|
|
98
|
+
when 79 # == 'O'.ord
|
|
99
|
+
# SS3 sequence `ESC O char`
|
|
100
|
+
idx += 1
|
|
101
|
+
else
|
|
102
|
+
# `ESC char` or `ESC ESC char`
|
|
103
|
+
return UNMATCHED if vi_mode
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
case input.size
|
|
107
|
+
when idx
|
|
108
|
+
MATCHING
|
|
109
|
+
when idx + 1
|
|
110
|
+
MATCHED
|
|
111
|
+
else
|
|
112
|
+
UNMATCHED
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def key_mapping
|
|
117
|
+
@config.key_bindings
|
|
118
|
+
end
|
|
119
|
+
end
|