llm-shell 0.10.0 → 0.11.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/LICENSE +21 -0
- data/README.md +24 -160
- data/exe/llm-shell +7 -0
- data/llm-shell.gemspec +26 -32
- metadata +36 -372
- data/bin/llm-shell +0 -21
- data/lib/llm/shell/command.rb +0 -88
- data/lib/llm/shell/commands/clear_screen.rb +0 -18
- data/lib/llm/shell/commands/debug_mode.rb +0 -12
- data/lib/llm/shell/commands/dir_import.rb +0 -33
- data/lib/llm/shell/commands/disable_tool.rb +0 -33
- data/lib/llm/shell/commands/enable_tool.rb +0 -33
- data/lib/llm/shell/commands/file_import.rb +0 -25
- data/lib/llm/shell/commands/help.rb +0 -53
- data/lib/llm/shell/commands/show_chat.rb +0 -31
- data/lib/llm/shell/commands/show_version.rb +0 -17
- data/lib/llm/shell/commands/system_prompt.rb +0 -21
- data/lib/llm/shell/completion.rb +0 -40
- data/lib/llm/shell/config.rb +0 -34
- data/lib/llm/shell/default.rb +0 -23
- data/lib/llm/shell/formatter.rb +0 -41
- data/lib/llm/shell/internal/coderay/lib/coderay/duo.rb +0 -81
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/_map.rb +0 -17
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/comment_filter.rb +0 -25
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/count.rb +0 -39
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/debug.rb +0 -49
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/debug_lint.rb +0 -63
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/div.rb +0 -23
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/encoder.rb +0 -190
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/filter.rb +0 -58
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/html/css.rb +0 -65
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/html/numbering.rb +0 -108
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/html/output.rb +0 -164
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/html.rb +0 -333
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/json.rb +0 -83
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/lines_of_code.rb +0 -45
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/lint.rb +0 -59
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/null.rb +0 -18
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/page.rb +0 -24
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/span.rb +0 -23
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/statistic.rb +0 -95
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/terminal.rb +0 -195
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/text.rb +0 -46
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/token_kind_filter.rb +0 -111
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/xml.rb +0 -72
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders/yaml.rb +0 -50
- data/lib/llm/shell/internal/coderay/lib/coderay/encoders.rb +0 -18
- data/lib/llm/shell/internal/coderay/lib/coderay/for_redcloth.rb +0 -95
- data/lib/llm/shell/internal/coderay/lib/coderay/helpers/file_type.rb +0 -151
- data/lib/llm/shell/internal/coderay/lib/coderay/helpers/plugin.rb +0 -55
- data/lib/llm/shell/internal/coderay/lib/coderay/helpers/plugin_host.rb +0 -221
- data/lib/llm/shell/internal/coderay/lib/coderay/helpers/word_list.rb +0 -72
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/_map.rb +0 -24
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/c.rb +0 -189
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/clojure.rb +0 -217
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/cpp.rb +0 -217
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/css.rb +0 -196
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/debug.rb +0 -75
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/delphi.rb +0 -144
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/diff.rb +0 -221
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/erb.rb +0 -81
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/go.rb +0 -208
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/groovy.rb +0 -268
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/haml.rb +0 -168
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/html.rb +0 -275
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/java/builtin_types.rb +0 -421
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/java.rb +0 -174
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/java_script.rb +0 -236
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/json.rb +0 -98
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/lua.rb +0 -280
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/php.rb +0 -527
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/python.rb +0 -287
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/raydebug.rb +0 -75
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/ruby/patterns.rb +0 -178
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/ruby/string_state.rb +0 -79
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/ruby.rb +0 -477
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/sass.rb +0 -232
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/scanner.rb +0 -337
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/sql.rb +0 -169
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/taskpaper.rb +0 -36
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/text.rb +0 -26
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/xml.rb +0 -17
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners/yaml.rb +0 -140
- data/lib/llm/shell/internal/coderay/lib/coderay/scanners.rb +0 -27
- data/lib/llm/shell/internal/coderay/lib/coderay/styles/_map.rb +0 -7
- data/lib/llm/shell/internal/coderay/lib/coderay/styles/alpha.rb +0 -153
- data/lib/llm/shell/internal/coderay/lib/coderay/styles/style.rb +0 -18
- data/lib/llm/shell/internal/coderay/lib/coderay/styles.rb +0 -15
- data/lib/llm/shell/internal/coderay/lib/coderay/token_kinds.rb +0 -85
- data/lib/llm/shell/internal/coderay/lib/coderay/tokens.rb +0 -164
- data/lib/llm/shell/internal/coderay/lib/coderay/tokens_proxy.rb +0 -55
- data/lib/llm/shell/internal/coderay/lib/coderay/version.rb +0 -3
- data/lib/llm/shell/internal/coderay/lib/coderay.rb +0 -284
- data/lib/llm/shell/internal/io-line/lib/io/line/multiple.rb +0 -19
- data/lib/llm/shell/internal/io-line/lib/io/line.rb +0 -28
- data/lib/llm/shell/internal/llm.rb/lib/llm/bot/builder.rb +0 -31
- data/lib/llm/shell/internal/llm.rb/lib/llm/bot/conversable.rb +0 -37
- data/lib/llm/shell/internal/llm.rb/lib/llm/bot/prompt/completion.rb +0 -49
- data/lib/llm/shell/internal/llm.rb/lib/llm/bot/prompt/respond.rb +0 -49
- data/lib/llm/shell/internal/llm.rb/lib/llm/bot.rb +0 -150
- data/lib/llm/shell/internal/llm.rb/lib/llm/buffer.rb +0 -162
- data/lib/llm/shell/internal/llm.rb/lib/llm/client.rb +0 -36
- data/lib/llm/shell/internal/llm.rb/lib/llm/error.rb +0 -49
- data/lib/llm/shell/internal/llm.rb/lib/llm/eventhandler.rb +0 -44
- data/lib/llm/shell/internal/llm.rb/lib/llm/eventstream/event.rb +0 -69
- data/lib/llm/shell/internal/llm.rb/lib/llm/eventstream/parser.rb +0 -88
- data/lib/llm/shell/internal/llm.rb/lib/llm/eventstream.rb +0 -8
- data/lib/llm/shell/internal/llm.rb/lib/llm/file.rb +0 -91
- data/lib/llm/shell/internal/llm.rb/lib/llm/function.rb +0 -177
- data/lib/llm/shell/internal/llm.rb/lib/llm/message.rb +0 -178
- data/lib/llm/shell/internal/llm.rb/lib/llm/mime.rb +0 -140
- data/lib/llm/shell/internal/llm.rb/lib/llm/multipart.rb +0 -101
- data/lib/llm/shell/internal/llm.rb/lib/llm/object/builder.rb +0 -38
- data/lib/llm/shell/internal/llm.rb/lib/llm/object/kernel.rb +0 -53
- data/lib/llm/shell/internal/llm.rb/lib/llm/object.rb +0 -89
- data/lib/llm/shell/internal/llm.rb/lib/llm/provider.rb +0 -352
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/error_handler.rb +0 -36
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/files.rb +0 -155
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/format/completion_format.rb +0 -88
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/format.rb +0 -29
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/models.rb +0 -54
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/response/completion.rb +0 -39
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/response/enumerable.rb +0 -11
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/response/file.rb +0 -23
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/response/web_search.rb +0 -21
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic/stream_parser.rb +0 -66
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/anthropic.rb +0 -138
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/deepseek/format/completion_format.rb +0 -68
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/deepseek/format.rb +0 -27
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/deepseek.rb +0 -75
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/audio.rb +0 -73
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/error_handler.rb +0 -47
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/files.rb +0 -146
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/format/completion_format.rb +0 -69
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/format.rb +0 -39
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/images.rb +0 -133
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/models.rb +0 -60
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/completion.rb +0 -35
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/embedding.rb +0 -8
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/file.rb +0 -11
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/files.rb +0 -15
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/image.rb +0 -31
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/models.rb +0 -15
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/response/web_search.rb +0 -22
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini/stream_parser.rb +0 -86
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/gemini.rb +0 -173
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/llamacpp.rb +0 -74
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/error_handler.rb +0 -36
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/format/completion_format.rb +0 -77
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/format.rb +0 -29
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/models.rb +0 -56
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/response/completion.rb +0 -28
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/response/embedding.rb +0 -9
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama/stream_parser.rb +0 -44
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/ollama.rb +0 -116
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/audio.rb +0 -91
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/error_handler.rb +0 -46
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/files.rb +0 -134
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format/completion_format.rb +0 -90
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format/moderation_format.rb +0 -35
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format/respond_format.rb +0 -72
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format.rb +0 -54
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/images.rb +0 -109
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/models.rb +0 -55
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/moderations.rb +0 -65
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/audio.rb +0 -7
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/completion.rb +0 -40
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/embedding.rb +0 -9
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/enumerable.rb +0 -23
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/file.rb +0 -7
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/image.rb +0 -16
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/moderations.rb +0 -34
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/responds.rb +0 -48
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/response/web_search.rb +0 -21
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/responses/stream_parser.rb +0 -76
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/responses.rb +0 -99
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/stream_parser.rb +0 -86
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/vector_stores.rb +0 -228
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/openai.rb +0 -206
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/xai/images.rb +0 -58
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/xai.rb +0 -72
- data/lib/llm/shell/internal/llm.rb/lib/llm/providers/zai.rb +0 -74
- data/lib/llm/shell/internal/llm.rb/lib/llm/response.rb +0 -67
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/array.rb +0 -26
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/boolean.rb +0 -13
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/integer.rb +0 -43
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/leaf.rb +0 -78
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/null.rb +0 -13
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/number.rb +0 -43
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/object.rb +0 -41
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/string.rb +0 -34
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema/version.rb +0 -8
- data/lib/llm/shell/internal/llm.rb/lib/llm/schema.rb +0 -81
- data/lib/llm/shell/internal/llm.rb/lib/llm/server_tool.rb +0 -32
- data/lib/llm/shell/internal/llm.rb/lib/llm/tool/param.rb +0 -75
- data/lib/llm/shell/internal/llm.rb/lib/llm/tool.rb +0 -78
- data/lib/llm/shell/internal/llm.rb/lib/llm/utils.rb +0 -19
- data/lib/llm/shell/internal/llm.rb/lib/llm/version.rb +0 -5
- data/lib/llm/shell/internal/llm.rb/lib/llm.rb +0 -121
- data/lib/llm/shell/internal/optparse/lib/optionparser.rb +0 -2
- data/lib/llm/shell/internal/optparse/lib/optparse/ac.rb +0 -70
- data/lib/llm/shell/internal/optparse/lib/optparse/date.rb +0 -18
- data/lib/llm/shell/internal/optparse/lib/optparse/kwargs.rb +0 -27
- data/lib/llm/shell/internal/optparse/lib/optparse/shellwords.rb +0 -7
- data/lib/llm/shell/internal/optparse/lib/optparse/time.rb +0 -11
- data/lib/llm/shell/internal/optparse/lib/optparse/uri.rb +0 -7
- data/lib/llm/shell/internal/optparse/lib/optparse/version.rb +0 -80
- data/lib/llm/shell/internal/optparse/lib/optparse.rb +0 -2469
- data/lib/llm/shell/internal/paint/lib/paint/constants.rb +0 -104
- data/lib/llm/shell/internal/paint/lib/paint/pa.rb +0 -13
- data/lib/llm/shell/internal/paint/lib/paint/rgb_colors.rb +0 -14
- data/lib/llm/shell/internal/paint/lib/paint/shortcuts.rb +0 -100
- data/lib/llm/shell/internal/paint/lib/paint/shortcuts_version.rb +0 -5
- data/lib/llm/shell/internal/paint/lib/paint/util.rb +0 -16
- data/lib/llm/shell/internal/paint/lib/paint/version.rb +0 -5
- data/lib/llm/shell/internal/paint/lib/paint.rb +0 -261
- data/lib/llm/shell/internal/reline/lib/reline/config.rb +0 -378
- data/lib/llm/shell/internal/reline/lib/reline/face.rb +0 -199
- data/lib/llm/shell/internal/reline/lib/reline/history.rb +0 -76
- data/lib/llm/shell/internal/reline/lib/reline/io/ansi.rb +0 -322
- data/lib/llm/shell/internal/reline/lib/reline/io/dumb.rb +0 -120
- data/lib/llm/shell/internal/reline/lib/reline/io/windows.rb +0 -530
- data/lib/llm/shell/internal/reline/lib/reline/io.rb +0 -55
- data/lib/llm/shell/internal/reline/lib/reline/key_actor/base.rb +0 -37
- data/lib/llm/shell/internal/reline/lib/reline/key_actor/composite.rb +0 -17
- data/lib/llm/shell/internal/reline/lib/reline/key_actor/emacs.rb +0 -517
- data/lib/llm/shell/internal/reline/lib/reline/key_actor/vi_command.rb +0 -518
- data/lib/llm/shell/internal/reline/lib/reline/key_actor/vi_insert.rb +0 -517
- data/lib/llm/shell/internal/reline/lib/reline/key_actor.rb +0 -8
- data/lib/llm/shell/internal/reline/lib/reline/key_stroke.rb +0 -119
- data/lib/llm/shell/internal/reline/lib/reline/kill_ring.rb +0 -125
- data/lib/llm/shell/internal/reline/lib/reline/line_editor.rb +0 -2356
- data/lib/llm/shell/internal/reline/lib/reline/unicode/east_asian_width.rb +0 -1292
- data/lib/llm/shell/internal/reline/lib/reline/unicode.rb +0 -421
- data/lib/llm/shell/internal/reline/lib/reline/version.rb +0 -3
- data/lib/llm/shell/internal/reline/lib/reline.rb +0 -527
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/generated_parser.rb +0 -712
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/handler.rb +0 -268
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/local_date.rb +0 -35
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/local_date_time.rb +0 -42
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/local_time.rb +0 -40
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/parser.rb +0 -21
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/scanner.rb +0 -92
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/string_utils.rb +0 -40
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb/version.rb +0 -5
- data/lib/llm/shell/internal/tomlrb/lib/tomlrb.rb +0 -49
- data/lib/llm/shell/markdown.rb +0 -83
- data/lib/llm/shell/options.rb +0 -39
- data/lib/llm/shell/renderer.rb +0 -51
- data/lib/llm/shell/repl.rb +0 -111
- data/lib/llm/shell/tool.rb +0 -42
- data/lib/llm/shell/tools/read_file.rb +0 -15
- data/lib/llm/shell/tools/system.rb +0 -17
- data/lib/llm/shell/tools/write_file.rb +0 -16
- data/lib/llm/shell/version.rb +0 -8
- data/lib/llm/shell.rb +0 -132
- data/lib/llm-shell.rb +0 -3
- data/libexec/llm-shell/shell +0 -43
- data/share/llm-shell/prompts/default.txt +0 -21
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
require 'io/console'
|
|
2
|
-
require 'io/wait'
|
|
3
|
-
|
|
4
|
-
class Reline::ANSI < Reline::IO
|
|
5
|
-
ANSI_CURSOR_KEY_BINDINGS = {
|
|
6
|
-
# Up
|
|
7
|
-
'A' => [:ed_prev_history, {}],
|
|
8
|
-
# Down
|
|
9
|
-
'B' => [:ed_next_history, {}],
|
|
10
|
-
# Right
|
|
11
|
-
'C' => [:ed_next_char, { ctrl: :em_next_word, meta: :em_next_word }],
|
|
12
|
-
# Left
|
|
13
|
-
'D' => [:ed_prev_char, { ctrl: :ed_prev_word, meta: :ed_prev_word }],
|
|
14
|
-
# End
|
|
15
|
-
'F' => [:ed_move_to_end, {}],
|
|
16
|
-
# Home
|
|
17
|
-
'H' => [:ed_move_to_beg, {}],
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
attr_writer :input, :output
|
|
21
|
-
|
|
22
|
-
def initialize
|
|
23
|
-
@input = STDIN
|
|
24
|
-
@output = STDOUT
|
|
25
|
-
@buf = []
|
|
26
|
-
@output_buffer = nil
|
|
27
|
-
@old_winch_handler = nil
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def encoding
|
|
31
|
-
@input.external_encoding || Encoding.default_external
|
|
32
|
-
rescue IOError
|
|
33
|
-
# STDIN.external_encoding raises IOError in Ruby <= 3.0 when STDIN is closed
|
|
34
|
-
Encoding.default_external
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def set_default_key_bindings(config)
|
|
38
|
-
set_bracketed_paste_key_bindings(config)
|
|
39
|
-
set_default_key_bindings_ansi_cursor(config)
|
|
40
|
-
set_default_key_bindings_comprehensive_list(config)
|
|
41
|
-
{
|
|
42
|
-
[27, 91, 90] => :completion_journey_up, # S-Tab
|
|
43
|
-
}.each_pair do |key, func|
|
|
44
|
-
config.add_default_key_binding_by_keymap(:emacs, key, func)
|
|
45
|
-
config.add_default_key_binding_by_keymap(:vi_insert, key, func)
|
|
46
|
-
end
|
|
47
|
-
{
|
|
48
|
-
# default bindings
|
|
49
|
-
[27, 32] => :em_set_mark, # M-<space>
|
|
50
|
-
[24, 24] => :em_exchange_mark, # C-x C-x
|
|
51
|
-
}.each_pair do |key, func|
|
|
52
|
-
config.add_default_key_binding_by_keymap(:emacs, key, func)
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def set_bracketed_paste_key_bindings(config)
|
|
57
|
-
[:emacs, :vi_insert, :vi_command].each do |keymap|
|
|
58
|
-
config.add_default_key_binding_by_keymap(keymap, START_BRACKETED_PASTE.bytes, :bracketed_paste_start)
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def set_default_key_bindings_ansi_cursor(config)
|
|
63
|
-
ANSI_CURSOR_KEY_BINDINGS.each do |char, (default_func, modifiers)|
|
|
64
|
-
bindings = [
|
|
65
|
-
["\e[#{char}", default_func], # CSI + char
|
|
66
|
-
["\eO#{char}", default_func] # SS3 + char, application cursor key mode
|
|
67
|
-
]
|
|
68
|
-
if modifiers[:ctrl]
|
|
69
|
-
# CSI + ctrl_key_modifier + char
|
|
70
|
-
bindings << ["\e[1;5#{char}", modifiers[:ctrl]]
|
|
71
|
-
end
|
|
72
|
-
if modifiers[:meta]
|
|
73
|
-
# CSI + meta_key_modifier + char
|
|
74
|
-
bindings << ["\e[1;3#{char}", modifiers[:meta]]
|
|
75
|
-
# Meta(ESC) + CSI + char
|
|
76
|
-
bindings << ["\e\e[#{char}", modifiers[:meta]]
|
|
77
|
-
end
|
|
78
|
-
bindings.each do |sequence, func|
|
|
79
|
-
key = sequence.bytes
|
|
80
|
-
config.add_default_key_binding_by_keymap(:emacs, key, func)
|
|
81
|
-
config.add_default_key_binding_by_keymap(:vi_insert, key, func)
|
|
82
|
-
config.add_default_key_binding_by_keymap(:vi_command, key, func)
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def set_default_key_bindings_comprehensive_list(config)
|
|
88
|
-
{
|
|
89
|
-
# xterm
|
|
90
|
-
[27, 91, 51, 126] => :key_delete, # kdch1
|
|
91
|
-
[27, 91, 53, 126] => :ed_search_prev_history, # kpp
|
|
92
|
-
[27, 91, 54, 126] => :ed_search_next_history, # knp
|
|
93
|
-
|
|
94
|
-
# Console (80x25)
|
|
95
|
-
[27, 91, 49, 126] => :ed_move_to_beg, # Home
|
|
96
|
-
[27, 91, 52, 126] => :ed_move_to_end, # End
|
|
97
|
-
|
|
98
|
-
# urxvt / exoterm
|
|
99
|
-
[27, 91, 55, 126] => :ed_move_to_beg, # Home
|
|
100
|
-
[27, 91, 56, 126] => :ed_move_to_end, # End
|
|
101
|
-
}.each_pair do |key, func|
|
|
102
|
-
config.add_default_key_binding_by_keymap(:emacs, key, func)
|
|
103
|
-
config.add_default_key_binding_by_keymap(:vi_insert, key, func)
|
|
104
|
-
config.add_default_key_binding_by_keymap(:vi_command, key, func)
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
def with_raw_input
|
|
109
|
-
if @input.tty?
|
|
110
|
-
@input.raw(intr: true) { yield }
|
|
111
|
-
else
|
|
112
|
-
yield
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
def inner_getc(timeout_second)
|
|
117
|
-
unless @buf.empty?
|
|
118
|
-
return @buf.shift
|
|
119
|
-
end
|
|
120
|
-
until @input.wait_readable(0.01)
|
|
121
|
-
timeout_second -= 0.01
|
|
122
|
-
return nil if timeout_second <= 0
|
|
123
|
-
|
|
124
|
-
Reline.core.line_editor.handle_signal
|
|
125
|
-
end
|
|
126
|
-
c = @input.getbyte
|
|
127
|
-
|
|
128
|
-
# When "Escape non-ASCII Input with Control-V" is enabled in macOS Terminal.app,
|
|
129
|
-
# all non-ascii bytes are automatically escaped with `C-v`.
|
|
130
|
-
# "\xE3\x81\x82" (U+3042) becomes "\x16\xE3\x16\x81\x16\x82".
|
|
131
|
-
(c == 0x16 && @input.tty? && @input.raw(min: 0, time: 0, &:getbyte)) || c
|
|
132
|
-
rescue Errno::EIO
|
|
133
|
-
# Maybe the I/O has been closed.
|
|
134
|
-
nil
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
START_BRACKETED_PASTE = String.new("\e[200~", encoding: Encoding::ASCII_8BIT)
|
|
138
|
-
END_BRACKETED_PASTE = String.new("\e[201~", encoding: Encoding::ASCII_8BIT)
|
|
139
|
-
def read_bracketed_paste
|
|
140
|
-
buffer = String.new(encoding: Encoding::ASCII_8BIT)
|
|
141
|
-
until buffer.end_with?(END_BRACKETED_PASTE)
|
|
142
|
-
c = inner_getc(Float::INFINITY)
|
|
143
|
-
break unless c
|
|
144
|
-
buffer << c
|
|
145
|
-
end
|
|
146
|
-
string = buffer.delete_suffix(END_BRACKETED_PASTE).force_encoding(encoding)
|
|
147
|
-
string.valid_encoding? ? string : ''
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
# if the usage expects to wait indefinitely, use Float::INFINITY for timeout_second
|
|
151
|
-
def getc(timeout_second)
|
|
152
|
-
inner_getc(timeout_second)
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
def in_pasting?
|
|
156
|
-
not empty_buffer?
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
def empty_buffer?
|
|
160
|
-
unless @buf.empty?
|
|
161
|
-
return false
|
|
162
|
-
end
|
|
163
|
-
!@input.wait_readable(0)
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
def ungetc(c)
|
|
167
|
-
@buf.unshift(c)
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
def retrieve_keybuffer
|
|
171
|
-
begin
|
|
172
|
-
return unless @input.wait_readable(0.001)
|
|
173
|
-
str = @input.read_nonblock(1024)
|
|
174
|
-
str.bytes.each do |c|
|
|
175
|
-
@buf.push(c)
|
|
176
|
-
end
|
|
177
|
-
rescue EOFError
|
|
178
|
-
end
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
def get_screen_size
|
|
182
|
-
s = @input.winsize
|
|
183
|
-
return s if s[0] > 0 && s[1] > 0
|
|
184
|
-
s = [ENV["LINES"].to_i, ENV["COLUMNS"].to_i]
|
|
185
|
-
return s if s[0] > 0 && s[1] > 0
|
|
186
|
-
[24, 80]
|
|
187
|
-
rescue SystemCallError
|
|
188
|
-
[24, 80]
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
def set_screen_size(rows, columns)
|
|
192
|
-
@input.winsize = [rows, columns]
|
|
193
|
-
self
|
|
194
|
-
rescue SystemCallError
|
|
195
|
-
self
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
private def cursor_pos_internal(timeout:)
|
|
199
|
-
match = nil
|
|
200
|
-
@input.raw do |stdin|
|
|
201
|
-
@output << "\e[6n"
|
|
202
|
-
@output.flush
|
|
203
|
-
timeout_at = Time.now + timeout
|
|
204
|
-
buf = +''
|
|
205
|
-
while (wait = timeout_at - Time.now) > 0 && stdin.wait_readable(wait)
|
|
206
|
-
buf << stdin.readpartial(1024)
|
|
207
|
-
if (match = buf.match(/\e\[(?<row>\d+);(?<column>\d+)R/))
|
|
208
|
-
buf = match.pre_match + match.post_match
|
|
209
|
-
break
|
|
210
|
-
end
|
|
211
|
-
end
|
|
212
|
-
@buf.concat buf.bytes
|
|
213
|
-
end
|
|
214
|
-
[match[:column].to_i - 1, match[:row].to_i - 1] if match
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
def cursor_pos
|
|
218
|
-
col, row = cursor_pos_internal(timeout: 0.5) if both_tty?
|
|
219
|
-
Reline::CursorPos.new(col || 0, row || 0)
|
|
220
|
-
end
|
|
221
|
-
|
|
222
|
-
def both_tty?
|
|
223
|
-
@input.tty? && @output.tty?
|
|
224
|
-
end
|
|
225
|
-
|
|
226
|
-
def write(string)
|
|
227
|
-
if @output_buffer
|
|
228
|
-
@output_buffer << string
|
|
229
|
-
else
|
|
230
|
-
@output.write(string)
|
|
231
|
-
end
|
|
232
|
-
end
|
|
233
|
-
|
|
234
|
-
def buffered_output
|
|
235
|
-
@output_buffer = +''
|
|
236
|
-
yield
|
|
237
|
-
@output.write(@output_buffer)
|
|
238
|
-
ensure
|
|
239
|
-
@output_buffer = nil
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
def move_cursor_column(x)
|
|
243
|
-
write "\e[#{x + 1}G"
|
|
244
|
-
end
|
|
245
|
-
|
|
246
|
-
def move_cursor_up(x)
|
|
247
|
-
if x > 0
|
|
248
|
-
write "\e[#{x}A"
|
|
249
|
-
elsif x < 0
|
|
250
|
-
move_cursor_down(-x)
|
|
251
|
-
end
|
|
252
|
-
end
|
|
253
|
-
|
|
254
|
-
def move_cursor_down(x)
|
|
255
|
-
if x > 0
|
|
256
|
-
write "\e[#{x}B"
|
|
257
|
-
elsif x < 0
|
|
258
|
-
move_cursor_up(-x)
|
|
259
|
-
end
|
|
260
|
-
end
|
|
261
|
-
|
|
262
|
-
def hide_cursor
|
|
263
|
-
write "\e[?25l"
|
|
264
|
-
end
|
|
265
|
-
|
|
266
|
-
def show_cursor
|
|
267
|
-
write "\e[?25h"
|
|
268
|
-
end
|
|
269
|
-
|
|
270
|
-
def erase_after_cursor
|
|
271
|
-
write "\e[K"
|
|
272
|
-
end
|
|
273
|
-
|
|
274
|
-
# This only works when the cursor is at the bottom of the scroll range
|
|
275
|
-
# For more details, see https://github.com/ruby/reline/pull/577#issuecomment-1646679623
|
|
276
|
-
def scroll_down(x)
|
|
277
|
-
return if x.zero?
|
|
278
|
-
# We use `\n` instead of CSI + S because CSI + S would cause https://github.com/ruby/reline/issues/576
|
|
279
|
-
write "\n" * x
|
|
280
|
-
end
|
|
281
|
-
|
|
282
|
-
def clear_screen
|
|
283
|
-
write "\e[2J"
|
|
284
|
-
write "\e[1;1H"
|
|
285
|
-
end
|
|
286
|
-
|
|
287
|
-
def set_winch_handler(&handler)
|
|
288
|
-
@old_winch_handler = Signal.trap('WINCH') do |arg|
|
|
289
|
-
handler.call
|
|
290
|
-
@old_winch_handler.call(arg) if @old_winch_handler.respond_to?(:call)
|
|
291
|
-
end
|
|
292
|
-
@old_cont_handler = Signal.trap('CONT') do |arg|
|
|
293
|
-
@input.raw!(intr: true) if @input.tty?
|
|
294
|
-
# Rerender the screen. Note that screen size might be changed while suspended.
|
|
295
|
-
handler.call
|
|
296
|
-
@old_cont_handler.call(arg) if @old_cont_handler.respond_to?(:call)
|
|
297
|
-
end
|
|
298
|
-
rescue ArgumentError
|
|
299
|
-
# Signal.trap may raise an ArgumentError if the platform doesn't support the signal.
|
|
300
|
-
end
|
|
301
|
-
|
|
302
|
-
def read_single_char(timeout_second)
|
|
303
|
-
# Disable intr to read `C-c` `C-z` `C-\` for quoted insert
|
|
304
|
-
@input.raw(intr: false) do
|
|
305
|
-
super
|
|
306
|
-
end
|
|
307
|
-
end
|
|
308
|
-
|
|
309
|
-
def prep
|
|
310
|
-
# Enable bracketed paste
|
|
311
|
-
write "\e[?2004h" if Reline.core.config.enable_bracketed_paste && both_tty?
|
|
312
|
-
retrieve_keybuffer
|
|
313
|
-
nil
|
|
314
|
-
end
|
|
315
|
-
|
|
316
|
-
def deprep(otio)
|
|
317
|
-
# Disable bracketed paste
|
|
318
|
-
write "\e[?2004l" if Reline.core.config.enable_bracketed_paste && both_tty?
|
|
319
|
-
Signal.trap('WINCH', @old_winch_handler) if @old_winch_handler
|
|
320
|
-
Signal.trap('CONT', @old_cont_handler) if @old_cont_handler
|
|
321
|
-
end
|
|
322
|
-
end
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
require 'io/wait'
|
|
2
|
-
|
|
3
|
-
class Reline::Dumb < Reline::IO
|
|
4
|
-
RESET_COLOR = '' # Do not send color reset sequence
|
|
5
|
-
|
|
6
|
-
attr_writer :output
|
|
7
|
-
|
|
8
|
-
def initialize(encoding: nil)
|
|
9
|
-
@input = STDIN
|
|
10
|
-
@output = STDOUT
|
|
11
|
-
@buf = []
|
|
12
|
-
@pasting = false
|
|
13
|
-
@encoding = encoding
|
|
14
|
-
@screen_size = [24, 80]
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def dumb?
|
|
18
|
-
true
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def encoding
|
|
22
|
-
if @encoding
|
|
23
|
-
@encoding
|
|
24
|
-
elsif RUBY_PLATFORM =~ /mswin|mingw/
|
|
25
|
-
Encoding::UTF_8
|
|
26
|
-
else
|
|
27
|
-
@input.external_encoding || Encoding.default_external
|
|
28
|
-
end
|
|
29
|
-
rescue IOError
|
|
30
|
-
# STDIN.external_encoding raises IOError in Ruby <= 3.0 when STDIN is closed
|
|
31
|
-
Encoding.default_external
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def set_default_key_bindings(_)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def input=(val)
|
|
38
|
-
@input = val
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def with_raw_input
|
|
42
|
-
yield
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def write(string)
|
|
46
|
-
@output.write(string)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def buffered_output
|
|
50
|
-
yield
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def getc(_timeout_second)
|
|
54
|
-
unless @buf.empty?
|
|
55
|
-
return @buf.shift
|
|
56
|
-
end
|
|
57
|
-
c = nil
|
|
58
|
-
loop do
|
|
59
|
-
Reline.core.line_editor.handle_signal
|
|
60
|
-
result = @input.wait_readable(0.1)
|
|
61
|
-
next if result.nil?
|
|
62
|
-
c = @input.read(1)
|
|
63
|
-
break
|
|
64
|
-
end
|
|
65
|
-
c&.ord
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def ungetc(c)
|
|
69
|
-
@buf.unshift(c)
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def get_screen_size
|
|
73
|
-
@screen_size
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def cursor_pos
|
|
77
|
-
Reline::CursorPos.new(0, 0)
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def hide_cursor
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def show_cursor
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def move_cursor_column(val)
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
def move_cursor_up(val)
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def move_cursor_down(val)
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
def erase_after_cursor
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def scroll_down(val)
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
def clear_screen
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
def set_screen_size(rows, columns)
|
|
105
|
-
@screen_size = [rows, columns]
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
def set_winch_handler(&handler)
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
def in_pasting?
|
|
112
|
-
@pasting
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
def prep
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def deprep(otio)
|
|
119
|
-
end
|
|
120
|
-
end
|