Граф коммитов

89 Коммитов

Автор SHA1 Сообщение Дата
aycabta 046fd3ac8c Rescue conversion error of inputrc 2021-06-21 22:12:14 +09:00
aycabta 00b027a69b [ruby/reline] Fix explamation of #read_io
https://github.com/ruby/reline/commit/301ed11bec
2021-06-21 17:58:49 +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]

https://github.com/ruby/reline/commit/c001971bb3
2021-06-21 17:58:48 +09:00
aycabta 5543695a19
[ruby/reline] Separate keystrokes each editing mode
https://github.com/ruby/reline/commit/ee23e6f3f8
2021-04-08 21:41:00 +09:00
aycabta b764c8d3c0 [ruby/reline] Add Reline.ungetc to control buffer
https://github.com/ruby/reline/commit/43ac03c624
2021-03-24 15:43:10 +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

https://github.com/ruby/reline/commit/b8b3dd52c0
2021-02-07 05:09:18 +09:00
ima1zumi 53510d1e8a [ruby/reline] [ruby/reline] Remove unused `attr_writer`
https://github.com/ruby/reline/commit/ecdc1b7116

https://github.com/ruby/reline/commit/a7922da16b
2020-12-22 23:45:43 +09:00
ima1zumi 299f5708a2 [ruby/reline] Fixed an exception occurred when ambiguous width character was passed to `#calculate_width` [Bug #17405]
https://github.com/ruby/reline/commit/f79b4c857f
2020-12-22 23:45:43 +09:00
aycabta 0158ba7e51 [ruby/reline] Make a log file on windows if debug env is set
https://github.com/ruby/reline/commit/dff30a2d44
2020-12-17 20:17:11 +09:00
aycabta c2bd5b84d0 [ruby/reline] Support bracketed paste mode
https://github.com/ruby/reline/commit/d1a6869322
2020-12-05 02:58:59 +09:00
aycabta 55cc397a87 [ruby/reline] Suppress callbacks in pasting
IRB uses Reline's 3 dynamic real-time callbacks with calling Ripper;
output_modifier_proc, prompt_proc, and auto_indent_proc. These processing
times make the paste time too long.

https://github.com/ruby/reline/commit/beec3399a8
2020-12-05 02:58:58 +09:00
aycabta 172d44e809 [ruby/reline] Add require 'rbconfig' to use RbConfig
https://github.com/ruby/reline/commit/4a0d32a3d0
2020-08-18 19:10:09 +09:00
Mark Delk 44b24ab4c1 [ruby/reline] Support mode icon
Co-authored-by: aycabta <aycabta@gmail.com>

https://github.com/ruby/reline/commit/067b618123
2020-08-18 19:08:32 +09:00
aycabta 215fe54777 [ruby/reline] Check Errno::EIO
Catch Errno::EIO what will be occurred if the console terminates I/O before
Reline finishes rendering.

https://github.com/ruby/reline/commit/e51eaa6d43
2020-08-18 19:04:31 +09:00
aycabta 68a7c8ad57 Reline callbacks can take nil 2020-05-14 12:27:33 +09:00
aycabta 69cd27c98e [ruby/reline] Suppress error when check ambiguous char width in LANG=C
https://github.com/ruby/reline/commit/623dffdd75
2020-03-26 17:41:21 +09:00
aycabta f245fb1ab8 [ruby/reline] Work with wrong $/ value correctly
https://github.com/ruby/reline/commit/962ebf5a1b
2020-03-26 17:41:21 +09:00
aycabta 2efb38e766 [ruby/reline] Use IO#write instead of IO#print
IO#print always adds a string of $\ automatically.

https://github.com/ruby/reline/commit/a93119c847
2020-02-14 22:47:27 +09:00
aycabta 8f4beec152 Always refer to Reline::IOGate.encoding 2020-01-26 12:50:11 +09:00
Lars Kanis d1166c6d39 Reline: Use a more robust detection of MinTTY
The previous detection per get_screen_size fails when stdout is passed
to a pipe. That is the case when running ruby tests in parallel ("-j" switch).
In this case Reline believes that it's running on MinTTY and the tests
are running with ANSI IOGate instead of the Windows adapter on MINGW.
So parallel test results were different to that of a single process.
This commit fixes these differencies.

The code is taken from git sources and translated to ruby.
NtQueryObject() is replaced by GetFileInformationByHandleEx(), because
NtQueryObject() is undocumented and is more difficult to use:
  c5a03b1e29/compat/winansi.c (L558)
2020-01-21 21:26:58 +09:00
aycabta f8ea2860b0 Introduce an abstracted structure about the encoding of Reline
The command prompt on Windows always uses Unicode to take input and print
output but most Reline implementation depends on Encoding.default_external.
This commit introduces an abstracted structure about the encoding of Reline.
2020-01-14 15:40:38 +09:00
Thomas Leitner a1713bedb1 [ruby/reline] Implement completion_append_character
There is already the possibility to set Reline.completion_append_character.
However, it is not used by the line editor.

https://github.com/ruby/reline/commit/ab798931b9
2019-12-17 13:19:37 +09:00
aycabta ec54ac9381 Support Readline.completion_quote_character by Reline 2019-12-11 11:13:05 +09:00
aycabta 6a22b2a091 Support completion with case-insensitive fashion
Reline performs completion in a case-insensitive fashon if
Readline.completion_case_fold or completion-ignore-case of .inputrc are set
"on".
2019-12-10 07:07:43 +09:00
aycabta a92560132b Support incremental search by last determined word
In the incremental search by C-r, search word is saved when it's determined. In
the next incremental search by C-r, if a user presses C-r again with the empty
search word, the determined previous search word is used to search.
2019-12-03 01:39:59 +09:00
manga_osyo 6723aa07e5 Change argument `Proc` to `#call` defined object.
This is the same as the behavior of Readline.
2019-11-21 00:47:37 +09:00
aycabta 633625a083 Mintty on Cygwin isn't a kind of command prompt, can process ANSI escape code 2019-11-20 17:55:19 +09:00
osyo-manga fe45bee093 Reline#readline and Reline#readmultiline to private. 2019-11-12 21:03:22 +09:00
aycabta 6e72b72881 Suppress "shadowing outer local variable" warning in 2.5 2019-11-08 16:18:36 +09:00
Jeremy Evans c4b627e2da Only taint on Ruby <2.7
Ruby 2.7 deprecates taint and it no longer has an effect.
2019-11-05 20:57:22 +09:00
Jeremy Evans d6ed7a984c Fix verbose warning being emitted
Fixes Ruby Bug 16281.
2019-10-31 17:51:50 +09:00
Lars Kanis 551edf64bc Reline: Fix wrong variable name
This raised a NameError before.
2019-09-09 19:16:01 +09:00
aycabta 744be55fad Remove duplicated delegation 2019-08-27 06:30:32 +09:00
aycabta fd0a4a64a3 Delegete an instance method to a class method correctly 2019-08-27 05:59:56 +09:00
aycabta f13db4adde Save value to @ambiguous_width because of a accessor 2019-08-27 05:33:27 +09:00
aycabta f2a5c50f94 The "private" doesn't make sence for class methods and a constant 2019-08-27 05:18:51 +09:00
aycabta 68207bb4fc Use preposing "private" to define methods 2019-08-27 05:18:51 +09:00
aycabta d8bcede9c3 Adjust method forwardings of Reline 2019-08-27 05:18:46 +09:00
manga_osyo 344f507e4e Remove .freeze. 2019-08-27 01:23:50 +09:00
manga_osyo 195f545c14 Fix `Reline::Windows`. 2019-08-27 01:23:24 +09:00
manga_osyo 298ac04710 Refactoring Reline. 2019-08-27 01:23:19 +09:00
manga_osyo f60e5a1f99 Remove test_mode in `lib/reline`. 2019-08-27 01:23:10 +09:00
Charles Oliver Nutter 842364792f Use host_os from RbConfig to detect host OS.
RUBY_PLATFORM on JRuby is always "java", so it will not reflect
the host operating system. This regex appears to be the consensus
way to detect Windows based on a search of Ruby code on Github:

https://github.com/search?q=%2Fmswin%7Cmsys%7Cmingw%7Ccygwin%7Cbccwin%7Cwince%7Cemc%2F&type=Code
2019-08-06 20:03:23 +09:00
manga_osyo 073cc52dcc Add `class Reline::History` and test. 2019-07-15 00:17:59 +09:00
aycabta 71ead07872 Add arg check to Reline.dig_perfect_match_proc= 2019-07-11 17:21:00 +09:00
aycabta 32e65e9e5a Print starting debug message with RELINE_STDERR_TTY 2019-06-18 21:58:05 +09:00
aycabta 235e72f17e Implement auto indent for multiline 2019-06-18 20:58:18 +09:00
aycabta 9402d019a5 Remove debug print 2019-06-14 08:45:52 +09:00
aycabta 64310b2573 Add Reline.prompt_proc 2019-06-14 07:42:53 +09:00
aycabta c75a3356b3 Move I/O access from Reline::KeyStroke to Reline 2019-06-05 11:29:59 +09:00