Commit graph

378 commits

Author SHA1 Message Date
aycabta
2910684c45 [ruby/reline] Cache dynamic prompt for 0.5sec
06b89d0e61
2020-12-05 02:58:59 +09:00
aycabta
b763c5cdf0 [ruby/reline] Stop rerendering if the cursor is only moved
30e8eaf855
2020-12-05 02:58:59 +09:00
aycabta
a297565a4e [ruby/reline] Split #rerender method that is too huge
d0fbc89253
2020-12-05 02:58:59 +09:00
aycabta
b545ab219b [ruby/reline] Stop rerendering whole screen when adding newline at end of buffer
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.33sec -> 0.22sec

496c6a1892
2020-12-05 02:58:59 +09:00
aycabta
c85035363f [ruby/reline] Key strokes like 2dl should behave d2l
Key strokes, vi arg, operator, and motion should be treated as operator, vi
arg, and motion.

d1a7e74aa4
2020-12-05 02:58:58 +09:00
aycabta
dbfc1f30d5 [ruby/reline] Add alias vi-movement-mode to vi-command-mode for compatibility
a79c297567
2020-12-05 02:58:58 +09:00
aycabta
48742614df [ruby/reline] Move alias_method to right after original definition
b7c8b93fa9
2020-12-05 02:58:58 +09:00
aycabta
9750c27afc [ruby/reline] Call process_insert when the end of pasting plural fullwidth chars
594484d9f9
2020-12-05 02:58:58 +09:00
aycabta
ba8e5f77eb [ruby/reline] Motions e, E, t, f should include a char on cursor if follows operator
86e9a76499
2020-12-05 02:58:58 +09:00
aycabta
6be3b2da19 [ruby/reline] Implement vi_yank
164aaf9a5f
2020-12-05 02:58:58 +09:00
aycabta
2dc4aca8d1 [ruby/reline] Operator with arg need to make sure that they take arg to avoid crashing
1c0c06de1f
2020-12-05 02:58:58 +09:00
aycabta
92b22db6a7 [ruby/reline] Unimplemented vi command should be no-op
abc90e6867
2020-12-05 02:58:58 +09:00
aycabta
faf8f216be [ruby/reline] Keep operator proc as a local variable in the scope
The proc variable will be used later so the instance variable will be changes.

496c4361f6
2020-12-05 02:58:58 +09:00
aycabta
564aadce62 [ruby/reline] Skip em_exchange_mark without mark
abb56e5ec3
2020-12-05 02:58:58 +09:00
aycabta
266ffdde8e [ruby/reline] Continuous insertion buffering
The rendering time in IRB has been reduced as follows:

  start = Time.now

  [{"_id"=>"5f9072a4589a06d2d74b6028",
    "index"=>0,
    "guid"=>"6b3051e2-dbc7-4537-bdb9-6cd7bb5358a7",
    "isActive"=>true,
    "balance"=>"$1,442.84",
    "picture"=>"http://placehold.it/32x32",
    "age"=>34,
    "eyeColor"=>"blue",
    "name"=>{"first"=>"Ward", "last"=>"Levy"},
    "company"=>"HYPLEX",
    "email"=>"ward.levy@hyplex.us",
    "phone"=>"+1 (867) 568-3319",
    "address"=>"867 Cobek Court, Clara, Maryland, 3254",
    "about"=>
     "Exercitation eu ex aliqua sit. Pariatur aliquip incididunt sint id non consectetur ullamco Lorem ea mollit duis amet sint labore. Commodo laborum labore commodo officia in cillum adipisicing esse excepteur cupidatat adipisicing ut. Non esse incididunt voluptate aliquip cillum eu aute duis laboris sit et. Amet enim quis tempor occaecat excepteur exercitation excepteur deserunt amet cillum adipisicing.",
    "registered"=>"Monday, May 25, 2015 6:51 AM",
    "latitude"=>"16.001127",
    "longitude"=>"-72.377848",
    "tags"=>["dolore", "nostrud", "occaecat", "cillum", "nisi"],
    "range"=>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
    "friends"=>
     [{"id"=>0, "name"=>"Alison Bryant"},
      {"id"=>1, "name"=>"Ester Espinoza"},
      {"id"=>2, "name"=>"Sullivan Kane"}],
    "greeting"=>"Hello, Ward! You have 7 unread messages.",
    "favoriteFruit"=>"apple"}]

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

2.17sec -> 0.92sec

  start = Time.now

  "Exercitation eu ex aliqua sit. Pariatur aliquip incididunt sint id non consectetur ullamco Lorem ea mollit duis amet sint labore. Commodo laborum labore commodo officia in cillum adipisicing esse excepteur cupidatat adipisicing ut. Non esse incididunt voluptate aliquip cillum eu aute duis laboris sit et. Amet enim quis tempor occaecat excepteur exercitation excepteur deserunt amet cillum adipisicing."

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

1.57sec -> 0.22sec

  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.88sec -> 0.77sec

7d87ac5a12
2020-12-05 02:58:58 +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.

beec3399a8
2020-12-05 02:58:58 +09:00
aycabta
4af2e4111b [ruby/reline] Deduplicate completed items
2dabf0c786
2020-12-05 02:58:58 +09:00
aycabta
f36dc2b6de [ruby/reline] Treat prompt correctly when Reline.prompt_proc isn't set
9c9ba0eff3
2020-09-12 08:35:52 +09:00
aycabta
ce389ade45 [ruby/reline] Move cursor to currect vertical pos after rendering a logical line
9b932df544
2020-09-12 08:35:52 +09:00
aycabta
9baf1bd0a4 [ruby/reline] Stop using chomp option of lines method
3e2f55c3e0
2020-09-12 08:35:52 +09:00
aycabta
0ec19cc843 [ruby/reline] Stop erasing chars after the cursor at eol
When the cursor is at the end of the line and erases characters after the
cursor, some terminals delete the character at the cursor position.

e96ec97b02
2020-09-12 08:35:52 +09:00
Hiroshi SHIBATA
b194973dcd
Revert the related commits about Tempfile.open change.
Start with fa21985a7a
  to d7492a0be8
2020-09-09 21:10:48 +09:00
Benoit Daloze
3beecafc2c Fix usages of Tempfile.open(&block) that expected the file to still be there after the block 2020-08-29 12:30:24 +02:00
aycabta
1f09c43628 [ruby/reline] Move width calculator methods to Reline::Unicode
f348ecd9f5
2020-08-28 11:05:18 +09:00
Nobuyoshi Nakada
f2435c1508 [ruby/reline] Get rid of loading pathname unnecessarily
9bd54b7f1c
2020-08-18 19:09:58 +09:00
aycabta
ad24eaabfd [ruby/reline] Remove duplicated line of code
Co-authored-by: Quentin Sabah <quentin.sabah@gmail.com>

5526e9f7ee
2020-08-18 19:08:50 +09:00
Mark Delk
44b24ab4c1 [ruby/reline] Support mode icon
Co-authored-by: aycabta <aycabta@gmail.com>

067b618123
2020-08-18 19:08:32 +09:00
aycabta
f56e05fa7d [ruby/reline] Remove unnecessary TODO commnet
23c67fb7b3
2020-05-17 19:26:53 +09:00
aycabta
db0d850d4e [ruby/reline] Add ed_search_next_history
ca750b676b
2020-04-18 23:12:52 +09:00
aycabta
bea3e31e5f [ruby/reline] Add ed_search_prev_history
e9ae288825
2020-04-18 23:12:52 +09:00
aycabta
08c1c3f220 [ruby/reline] Use vi_search_{prev,next} to incremental search
cab312f584
2020-04-18 23:09:31 +09:00
aycabta
afe997857e [ruby/reline] Rename search_history with incremental_search_history
d563063ea0
2020-04-18 23:09:31 +09:00
aycabta
f245fb1ab8 [ruby/reline] Work with wrong $/ value correctly
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.

a93119c847
2020-02-14 22:47:27 +09:00
aycabta
06c37fa5b4 [ruby/reline] Bypass cursor down when a char is rendered at eol on Windows
A newline is automatically inserted if a character is rendered at eol on
Windows command prompt.

4bfea07e4a
2020-02-02 03:28:20 +09:00
aycabta
2943ebd240 [ruby/reline] Implement vi_change_meta
8538e0e10f
2020-01-21 09:52:32 +09:00
aycabta
3b407abe9b [ruby/reline] Implement vi_prev_char and vi_to_prev_char
0ad3ee63fa
2020-01-20 19:13:19 +09:00
aycabta
b17797a694 [ruby/reline] Implement vi_to_next_char
066ecb0a21
2020-01-20 19:13:19 +09:00
aycabta
800c2a8e4c Implement vi_insert_at_bol and vi_add_at_eol 2020-01-17 01:37:01 +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
aycabta
439e1ccd08 Complete indented and quoted string correctly
def foo
    ''.upca[TAB]

This will be completed to be:

  def foo
  ''.upcase

The indent was gone. This commit fixes the bug.
2020-01-06 01:20:24 +09:00
KOBAYASHI Shuji
9b928fa443 [ruby/reline] Sort completion list
#### Legacy mode:

  ```console
  $ irb --legacy
  irb(main):001:0> l[TAB][TAB]
  lambda           load             local_variables  loop
  ```

#### Before this patch:

  ```console
  $ irb
  irb(main):001:0> l[TAB][TAB]
  local_variables
  loop
  lambda
  load
  ```

#### After this patch:

  ```console
  $ irb
  irb(main):001:0> l[TAB][TAB]
  lambda
  load
  local_variables
  loop
  ```

6074069c7d
2020-01-05 11:28:01 +09:00
aycabta
778634f778 Drop an invalid char as UTF-8 2019-12-27 16:02:30 +09:00
aycabta
8a705245e5 Save last breaking point to complete 2019-12-25 18:45:24 +09:00
aycabta
ed5b4bae6a The behavior of vi_end_of_transmission should be the same of vi_list_or_eof 2019-12-25 09:52:37 +09:00
aycabta
622e47a1db ^D on non-empty line in vi mode behaves like Enter 2019-12-25 09:34:13 +09:00
aycabta
7758849cb5 Remove unused variable 2019-12-24 18:39:48 +09:00
aycabta
42e2a322f1 The delete-char-or-list shows completed list when called at end of line
It doesn't behave the same as the delete-char.
2019-12-24 18:34:43 +09:00
Nobuyoshi Nakada
e68999c82c
Fixed misspellings
Fixed misspellings reported at [Bug #16437], for default gems.
2019-12-20 12:19:45 +09:00
aycabta
d616926af9 Remove an unnecessary variable 2019-12-17 14:21:07 +09:00