Commit graph

650 commits

Author SHA1 Message Date
Samuel Williams
e788481843 [ruby/reline] Avoid using blocking IO.select.
de94746393
2021-06-25 17:42:45 +09:00
aycabta
046fd3ac8c Rescue conversion error of inputrc 2021-06-21 22:12:14 +09:00
aycabta
30cc07fdc1 Check Ruby version to use Fiddle with variadic args in test-all 2021-06-21 18:44:10 +09:00
aycabta
90df426426 [ruby/reline] Version 0.2.6
5917e3a337
2021-06-21 17:58:49 +09:00
aycabta
95a3cdade6 [ruby/reline] Remove FIXME comment in #render
acd8f8efbb
2021-06-21 17:58:49 +09:00
aycabta
b06218ce6f [ruby/reline] Remove TODO comment in #render_partial
bb6ea232c2
2021-06-21 17:58:49 +09:00
aycabta
8135f489be [ruby/reline] Add binding C-x C-x to em_exchange_mark on Windows
24a2489b62
2021-06-21 17:58:49 +09:00
aycabta
fa5a258e93 [ruby/reline] Treat C-Space as M-Space on Windows
69beca2863
2021-06-21 17:58:49 +09:00
aycabta
582b5705ab [ruby/reline] Check existance of a constant, Fiddle::VERSION
4b74c3d83a
2021-06-21 17:58:48 +09:00
aycabta
18b79b4c49 [ruby/reline] Add Meta+arrow-keys in extended entries of terminfo
af6f6ed088
2021-06-21 17:58:48 +09:00
aycabta
60d1d6aa89 [ruby/reline] Terminfo.tigetstr should be able to receive tiparm in method chain
4a3e308163
2021-06-21 17:58:48 +09:00
aycabta
5e09da2f7a [ruby/reline] Terminfo.tigetstr and tiparm should return String object
1e287d10cc
2021-06-21 17:58:48 +09:00
aycabta
46c813969b [ruby/reline] Add terminfo support
74a7ffaa2f
2021-06-21 17:58:48 +09:00
aycabta
1b543dc226 [ruby/reline] Handle Errno::ENOTTY correctly
8daa392ba6
2021-06-21 17:58:48 +09:00
Jeremy Evans
242bad9a87 [ruby/reline] Fix Reline::Unicode.calculate_width when input is not a TTY
This fixes an error when output is redirected:

```
$ run_ruby -rreline -e '$stderr.puts Reline::Unicode.calculate_width("\u221a").inspect' </dev/null >/dev/null
/home/jeremy/tmp/ruby/lib/reline/ansi.rb:189:in `raw': Operation not supported by device (Errno::ENODEV)
```

The @@encoding -> defined?(@@encoding) changes is necessary because
without that part of the commit, the following error would be raised
by the above command:

```
/home/jeremy/tmp/reline/lib/reline/general_io.rb:10:in `encoding': uninitialized class variable @@encoding in Reline::GeneralIO (NameError)
```

Problem reported and initial patch for Windows provided by
Richard Sharman.

I tested this only on OpenBSD, but hopefully it works for other
operating systems.

Fixes [Bug #17493]

c001971bb3
2021-06-21 17:58:48 +09:00
aycabta
26f31f880c [ruby/reline] Treat return key correctly on Windows
To fix Reline::TestRendering#test_binding_for_vi_movement_mode.

0df3d2a1dc
2021-06-21 17:58:48 +09:00
aycabta
b0cc46b484 [ruby/reline] The config file must accept any character encoding
In Japan, so many programmers used EUC-JP to write text files that contain
Japanese. Many .inputrc files which contain EUC-JP are still being copied and
used. This commit supports the whole encoding of what user set including UTF-8.

ref. https://github.com/ruby/reline/pull/280

0b45022e16
2021-06-21 17:58:48 +09:00
aycabta
c59bbd86a6 [ruby/reline] Use ReadConsoleInputW() instead of getwch()
This needs https://github.com/aycabta/yamatanooroti/pull/19, which is released
by yamatanooroti gem 0.0.7, to test with yamatanooroti.

06c1f45da1
2021-06-21 17:58:48 +09:00
Mark Delk
a049dfd10a [ruby/reline] ensure reline's encoding is used when reading inputrc character values
This change ensures we use `Reline::IOGate`'s `encoding` when converting
characters from their integer values.

This fixes an issue that may occur if you have UTF characters in your
`.inputrc`, but your default encoding isn't set.

For example:

```
> 127864.ord.chr
RangeError: 127864 out of char range
from (pry):1:in `chr'
> Reline::IOGate.encoding
=> #<Encoding:UTF-8>
> 127864.ord.chr(Reline::IOGate.encoding)
=> "🍸"
```

cf372fc0fc
2021-06-21 17:58:48 +09:00
aycabta
6496c76d2a [ruby/reline] Add calling Reline::Config#reset_default_key_bindings to #reset, which is forgot to call 2021-04-09 11:57:28 +09:00
Nobuyoshi Nakada
b0b3022f95
[ruby/reline] Moved development dependencies to Gemfile
As expressions in a gemspec file are evaluated at the build time,
but not the run time, the conditional in the gemspec will not work
as intended.

c09b7c454a
2021-04-08 21:41:00 +09:00
aycabta
5543695a19
[ruby/reline] Separate keystrokes each editing mode
ee23e6f3f8
2021-04-08 21:41:00 +09:00
aycabta
16f31da92e
[ruby/reline] Check WITH_VTERM env to add vterm gem as dependency
27b689a7e2
2021-04-08 21:41:00 +09:00
aycabta
47abb70234 [ruby/reline] Use vterm 0.0.5 or newer on Unix like OSes because suppresses SEGV
7562cf3b5f
2021-04-03 20:22:56 +09:00
aycabta
8a4472fb6d [ruby/reline] Version 0.2.5
22ce5651e5
2021-04-03 01:28:42 +09:00
aycabta
7e93917458 [ruby/reline] Reset @rest_height when clear screen
3a7019b0d5
2021-04-02 17:33:48 +09:00
aycabta
89caf51d93 [ruby/reline] Suppress crashing when completer_{quote,word_break}_characters is empty
c6f1164942
2021-03-24 15:43:34 +09:00
aycabta
758f2b35f9 [ruby/reline] Support preposing and postposing for Reline.completion_proc
1f469de90c
2021-03-24 15:43:27 +09:00
aycabta
4b33d860e8 [ruby/reline] Reline.delete_text removes the current line in multiline
da90c094a1
2021-03-24 15:43:19 +09:00
aycabta
f0743dd2a4 [ruby/reline] Version 0.2.4
462f971bd3
2021-02-26 05:24:01 +09:00
cremno
a7dda449e8 [ruby/reline] fix Reline::Windows.getconsolemode buffer
use double quotes to properly convert the \000 escape sequence.

236dfe5683
2021-02-22 12:19:21 +09:00
aycabta
aeac4ddcc0 [ruby/reline] Use UTF-8 only for width calc, rest uses original encoding
I confirmed that libvterm supports only which are UTF-8, US ASCII, UK, and
DEC graphics by reading source code, so can't test this patch by
yamatanoorogi gem through vterm gem for now.

This fixes ruby/irb#190.

44596c0cc7
2021-02-21 06:44:05 +09:00
Yoshinao Muramatu
38d30a6942 [ruby/reline] check ENABLE_VIRTUAL_TERMINAL_PROCESSING flag and switch eof processing
3535676689
2021-02-21 06:43:52 +09:00
Yoshinao Muramatu
38cefac7ce [ruby/reline] We still need support new and legacy behavior.
Revert "Support for change in Windows-specific behavior at eol"

This reverts commit cad4de6ee841b43f3f0e441626f9415c3eda0f82.

646587fc2c
2021-02-21 06:43:41 +09:00
Eamonn Webster
ac9e3b514b [ruby/reline] Avoid tripping over nil prompt
d4d9d3e3d4
2021-02-21 06:41:11 +09:00
aycabta
dc9e33016c [ruby/reline] Return 1 when char width not found
This fixes ruby/reline#261.

3cf1213014
2021-02-21 06:41:03 +09:00
aycabta
93ebfed0a9 [ruby/reline] Version 0.2.3
b26c7d60c8
2021-02-07 05:29:31 +09:00
aycabta
300084a854 [ruby/reline] Terminate correctly in the middle of lines higher than the screen
e1d9240ada
2021-02-07 05:12:19 +09:00
aycabta
fee19da230 [ruby/reline] Autowrap correctly when inserting chars in the middle of a line
ebaf37255f
2021-02-07 05:12:07 +09:00
aycabta
a19ed1623f [ruby/reline] The vi_histedit supports multiline
This closes ruby/reline#253.

f131f86d71
2021-02-07 05:11:54 +09:00
aycabta
a608bb3e9b [ruby/reline] Move cursor just after the last line when finished
ba06e4c480
2021-02-07 05:11:47 +09:00
aycabta
08162f0e69 [ruby/reline] Update cursor info by inserting newline even if not in pasting
92d314f514
2021-02-07 05:11:41 +09:00
aycabta
b371ca3f4f [ruby/reline] Handle past logs correctly when the code is higher than the screen
f197139b4a
2021-02-07 05:11:27 +09:00
aycabta
bd0f8b36fd [ruby/reline] Show all lines higher than the screen when finished
On Unix-like OSes, logs prior to the screen are not editable. When the code
is higher than the screen, the code is only shown on the screen until input
is finished, but when it is finished, all lines are outputted.

8cd9132a39
2021-02-07 05:11:13 +09:00
aycabta
03523fdafb [ruby/reline] Scroll down when ^C is pressed
6877a7e3f5
2021-02-07 05:11:00 +09:00
aycabta
ec6929a5dd [ruby/reline] Remove an unused variable
123ea51166
2021-02-07 05:10:50 +09:00
aycabta
433b975fe8 [ruby/reline] Initialize uninitialized variables in tests
25af4bb64b
2021-02-07 05:10:36 +09:00
aycabta
b69c965f47 [ruby/reline] Cache pasting state in processing a key
Because it's too slow.

The rendering time in IRB has been reduced as follows:

  start = Time.now

  def each_top_level_statement
    initialize_input
    catch(:TERM_INPUT) do
      loop do
        begin
          prompt
          unless l = lex
            throw :TERM_INPUT if @line == ''
          else
            @line_no += l.count("\n")
            next if l == "\n"
            @line.concat l
            if @code_block_open or @ltype or @continue or @indent > 0
              next
            end
          end
          if @line != "\n"
            @line.force_encoding(@io.encoding)
            yield @line, @exp_line_no
          end
          break if @io.eof?
          @line = ''
          @exp_line_no = @line_no

          @indent = 0
        rescue TerminateLineInput
          initialize_input
          prompt
        end
      end
    end
  end

  puts "Duration: #{Time.now - start} seconds"

0.22sec -> 0.14sec

b8b3dd52c0
2021-02-07 05:09:18 +09:00
aycabta
edafde6844 [ruby/irb] [ruby/irb] [ruby/reline] Version 0.2.2
dfb710946f

1a1cdf9628

fe99faf8bd
2021-01-18 02:10:02 +09:00
aycabta
e1449ae74f [ruby/reline] Reline::Windows.erase_after_cursor erases attributes too
68b961dfc7
2021-01-18 02:09:53 +09:00