Commit graph

133 commits

Author SHA1 Message Date
aycabta
6f41cab704 [ruby/reline] Suppress warning, "instance variable @ambiguous_width not initialized"
368f7e2f78
2021-10-11 16:24:45 +09:00
manga_osyo
b8327fb8b1 [ruby/reline] Refactoring Reline::Key.match? and add test.
90e8999ae4
2021-10-02 19:58:41 +09:00
aycabta
5dc753df47 [ruby/reline] Move #pointer from DialogRenderInfo to Dialog
92dbac0bff
2021-09-10 11:38:54 +09:00
aycabta
30203a6fd9 [ruby/reline] Use Symbol for method names
479eee5393
2021-09-07 02:42:49 +09:00
aycabta
966ed206a6 [ruby/reline] Limit number of chars only when completion source text (pointer == -1)
1d7b603811
2021-09-06 22:50:11 +09:00
aycabta
348bb62331 [ruby/reline] Cut out read_2nd_character_of_key_sequence
92518d1dee
2021-09-06 05:24:15 +09:00
aycabta
7de2c9a966 [ruby/reline] Use combined_key if it exists when comparing Reline::Key and Integer
8fca5f6f9c
2021-09-06 05:23:36 +09:00
aycabta
3773296bfc [ruby/reline] Allow Reline::KeyStroke to compare raw and meta-key processed key sequences
731103f9c9
2021-09-06 05:23:27 +09:00
aycabta
56ab22ab3d [ruby/reline] Support for key bindings result Symbol in Reline::Key
cf78a38064
2021-09-06 05:23:18 +09:00
aycabta
bbb3162dd2 [ruby/reline] Add Reline::Key#== as an alias to Reline::Key#match?
1fc3276c01
2021-09-06 05:23:11 +09:00
aycabta
bb6d45cfee [ruby/reline] Reline::Key supports the comparison with Integer
ebc3e0f673
2021-09-06 05:23:01 +09:00
aycabta
ec36ceb072 [ruby/reline] Implement scrollbar
4c7fc42151
2021-09-04 21:40:12 +09:00
aycabta
f445d34c25 [ruby/reline] Show even if it's only one candidate until a perfect match
fe7e34e79f
2021-09-04 02:16:28 +09:00
aycabta
9e0caba187 [ruby/reline] Add Reline::Key#match?
8f6aa3af2e
2021-09-03 04:27:48 +09:00
aycabta
8c067f182e [ruby/reline] Autocompletion ignites when target char length is 3 or longer
261830fda3
2021-09-03 01:12:46 +09:00
aycabta
f734590f8e [ruby/reline] Add a space
3d70e07331
2021-09-02 21:36:24 +09:00
aycabta
c8a07a1231 [ruby/reline] Fix Reline::Unicode.take_range as it was not fully functional
5da6a8d851
2021-08-31 15:19:32 +09:00
aycabta
c98b2e14c7 [ruby/reline] Pass "dialog" to context to get "dialog.scroll_top" later
d81f29a134
2021-08-31 05:26:53 +09:00
aycabta
32abd38014 [ruby/reline] Autocompletion dialog height 15
7e18716754
2021-08-31 05:26:45 +09:00
aycabta
81d40b5b7e [ruby/reline] Scroll autocompletion pointer in dialog correctly
dc79ed2dd8
2021-08-31 05:26:39 +09:00
aycabta
282f7ce896 [ruby/reline] Use DialogRenderInfo struct
ac6f652a39
2021-08-31 05:26:33 +09:00
aycabta
8750e1ada8 [ruby/reline] Fix Reline.autocompletion=() interface
71c2eb143d
2021-08-30 02:37:23 +09:00
aycabta
3a2e2a6848 [ruby/reline] Add Reline.autocompletion=() interface
a2e69f6277
2021-08-30 02:37:23 +09:00
aycabta
935bb4c617 [ruby/reline] Add autocompletion on emacs mode by Tab / S-Tab
22d0b4e5d8
2021-08-30 02:37:23 +09:00
aycabta
7857a1ab66 [ruby/reline] Make autocomplete dialog is registered first
d027dbe118
2021-08-29 20:30:33 +09:00
aycabta
535a1cc71c [ruby/reline] Delete show doc dialog to move it to IRB
640102fe27
2021-08-29 20:30:33 +09:00
aycabta
74ba532883 [ruby/reline] Remove an unnecessary variable
3b8cc5ce0a
2021-08-29 20:30:33 +09:00
aycabta
3248c42592 [ruby/reline] Remove dialog_proc_list accessor of Reline
ac8fa84f4d
2021-08-29 20:30:33 +09:00
aycabta
32124de17e [ruby/reline] Move constants of dialogs to under Reline
9100ea2934
2021-08-29 20:30:33 +09:00
aycabta
29586ec9f3 [ruby/reline] Use default dialog context to communicate others
5e67e6ffe0
2021-08-29 20:30:33 +09:00
aycabta
6273b9bb62 [ruby/reline] Use colored doc output with ANSI escape sequence
7d1c75b43f
2021-08-29 20:30:33 +09:00
aycabta
acd15a39d2 [ruby/reline] Support custom bg color
cd0cbf53d5
2021-08-29 20:30:33 +09:00
aycabta
78f46e6576 [ruby/reline] Show method or class doc correctly
a505294f12
2021-08-29 20:30:33 +09:00
aycabta
7e8a627052 [ruby/reline] Implement doc display dialog in conjunction with autocomplete
e97bbc4ccf
2021-08-29 20:30:33 +09:00
aycabta
4cd344c958 [ruby/reline] Add the ability to handle context between dialogs
063d9c70d9
2021-08-29 20:30:33 +09:00
aycabta
8d4370b066 [ruby/reline] Support for multiple dialog rendering
f589fab718
2021-08-29 20:30:33 +09:00
aycabta
acffb0b068 [ruby/reline] Cut out the autocomplete callback
46aa2694da
2021-08-29 20:30:33 +09:00
aycabta
4b2b10707a [ruby/reline] Implement dynamic selection of candidates
e46437df00
2021-08-29 20:30:33 +09:00
aycabta
8e463e3e73 [ruby/reline] Remove unnecessary condition
07e911ec8e
2021-08-29 20:30:33 +09:00
aycabta
18c0814fe0 [ruby/reline] Fix typo
6370353c71
2021-08-29 20:30:33 +09:00
aycabta
ca1a2d1f68 [ruby/reline] Show autocomplete correctly when starts from prev line
f31a76ff31
2021-08-29 20:30:33 +09:00
aycabta
fb9fe4c43f [ruby/reline] Display autocomplete below original line if end point was wrapped
49f3392d59
2021-08-29 20:30:33 +09:00
aycabta
fb0fc20196 [ruby/reline] Implement dialog with autocomplete callback
1401d6165e
2021-08-29 20:30:32 +09:00
aycabta
2a7e86844b [ruby/reline] Add require 'reline/terminfo' to use Reline::Terminfo.enabled?
7ef9805b35
2021-07-30 02:27:02 +09:00
aycabta
046fd3ac8c Rescue conversion error of inputrc 2021-06-21 22:12:14 +09:00
aycabta
00b027a69b [ruby/reline] Fix explamation of #read_io
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]

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

b8b3dd52c0
2021-02-07 05:09:18 +09:00