reline 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d28ea6c28099d6ee05888e139f26785b7f524b2d43b97169a262d3039fe4b12d
4
- data.tar.gz: c929cedf8040597cdaf6d19ab14aa6724cf4b47dbf4c78b6a1fc2e74637bfc09
3
+ metadata.gz: bb3a343a202a2c043257a432f50eb05eeb58b5638a88c24eb095c96a40b03fea
4
+ data.tar.gz: e9c8aec5f70fe3897fb8f835d0d5b228a93a5444b0a7ce804290c19ae44c6c55
5
5
  SHA512:
6
- metadata.gz: f9c4c8c540077105e8c326dd7ee0de350dbf8cd7a0aba14ad467f28b2dbb9c52eade5601e56ada651d2ea6f713e2a47891545bccdd9ea11c43d01dfe315fdd27
7
- data.tar.gz: 7e8a2c186e0b4c84e3a7ddc62ab08dce768d1ea768ffc91bcf880e0227bb003c2b8fa288e45044cf1ab73144bd7ec46e9ac0faa582721acaf55726fc111706d4
6
+ metadata.gz: a0e2a92e1e007d23542313783108250c66ad81b90389c306a9f413b8426ce14a39e14731f974aa8fcabcddaeceae529a70388e6e1a3db6ec7a511278b0c568d7
7
+ data.tar.gz: 0f86f497938921154a475f4b63059a4cda560b44b5b6f9fb63b3b4afcae9de3ea351c1226640eb074546a765b2f51ff5a62bd1af20142a6211c8e74a06f16a57
@@ -9,7 +9,7 @@ class Reline::KeyActor::Emacs < Reline::KeyActor::Base
9
9
  # 3 ^C
10
10
  :ed_ignore,
11
11
  # 4 ^D
12
- :em_delete_or_list,
12
+ :em_delete,
13
13
  # 5 ^E
14
14
  :ed_move_to_end,
15
15
  # 6 ^F
@@ -595,14 +595,22 @@ class Reline::LineEditor
595
595
  [target, preposing, completed, postposing]
596
596
  end
597
597
 
598
- private def complete(list)
598
+ private def complete(list, just_show_list = false)
599
599
  case @completion_state
600
600
  when CompletionState::NORMAL, CompletionState::JOURNEY
601
601
  @completion_state = CompletionState::COMPLETION
602
602
  when CompletionState::PERFECT_MATCH
603
603
  @dig_perfect_match_proc&.(@perfect_matched)
604
604
  end
605
- is_menu = (@completion_state == CompletionState::MENU or @completion_state == CompletionState::MENU_WITH_PERFECT_MATCH)
605
+ if just_show_list
606
+ is_menu = true
607
+ elsif @completion_state == CompletionState::MENU
608
+ is_menu = true
609
+ elsif @completion_state == CompletionState::MENU_WITH_PERFECT_MATCH
610
+ is_menu = true
611
+ else
612
+ is_menu = false
613
+ end
606
614
  result = complete_internal_proc(list, is_menu)
607
615
  if @completion_state == CompletionState::MENU_WITH_PERFECT_MATCH
608
616
  @completion_state = CompletionState::PERFECT_MATCH
@@ -621,7 +629,7 @@ class Reline::LineEditor
621
629
  else
622
630
  @completion_state = CompletionState::MENU
623
631
  end
624
- if target < completed
632
+ if not just_show_list and target < completed
625
633
  @line = preposing + completed + completion_append_character.to_s + postposing
626
634
  line_to_pointer = preposing + completed + completion_append_character.to_s
627
635
  @cursor_max = calculate_width(@line)
@@ -1567,7 +1575,7 @@ class Reline::LineEditor
1567
1575
  end
1568
1576
  end
1569
1577
 
1570
- private def em_delete_or_list(key)
1578
+ private def em_delete(key)
1571
1579
  if (not @is_multiline and @line.empty?) or (@is_multiline and @line.empty? and @buffer_of_lines.size == 1)
1572
1580
  @line = nil
1573
1581
  if @buffer_of_lines.size > 1
@@ -1592,7 +1600,19 @@ class Reline::LineEditor
1592
1600
  @rest_height += 1
1593
1601
  end
1594
1602
  end
1595
- alias_method :delete_char, :em_delete_or_list
1603
+ alias_method :delete_char, :em_delete
1604
+
1605
+ private def em_delete_or_list(key)
1606
+ if @line.empty? or @byte_pointer < @line.bytesize
1607
+ em_delete(key)
1608
+ else # show completed list
1609
+ result = call_completion_proc
1610
+ if result.is_a?(Array)
1611
+ complete(result, true)
1612
+ end
1613
+ end
1614
+ end
1615
+ alias_method :delete_char_or_list, :em_delete_or_list
1596
1616
 
1597
1617
  private def em_yank(key)
1598
1618
  yanked = @kill_ring.yank
@@ -1896,18 +1916,6 @@ class Reline::LineEditor
1896
1916
  private def vi_yank(key)
1897
1917
  end
1898
1918
 
1899
- private def vi_end_of_transmission(key)
1900
- if @line.empty?
1901
- @line = nil
1902
- if @buffer_of_lines.size > 1
1903
- scroll_down(@highest_in_all - @first_line_started_from)
1904
- end
1905
- Reline::IOGate.move_cursor_column(0)
1906
- @eof = true
1907
- finish
1908
- end
1909
- end
1910
-
1911
1919
  private def vi_list_or_eof(key)
1912
1920
  if (not @is_multiline and @line.empty?) or (@is_multiline and @line.empty? and @buffer_of_lines.size == 1)
1913
1921
  @line = nil
@@ -1918,9 +1926,11 @@ class Reline::LineEditor
1918
1926
  @eof = true
1919
1927
  finish
1920
1928
  else
1921
- # TODO: list
1929
+ ed_newline(key)
1922
1930
  end
1923
1931
  end
1932
+ alias_method :vi_end_of_transmission, :vi_list_or_eof
1933
+ alias_method :vi_eof_maybe, :vi_list_or_eof
1924
1934
 
1925
1935
  private def ed_delete_next_char(key, arg: 1)
1926
1936
  byte_size = Reline::Unicode.get_next_mbchar_size(@line, @byte_pointer)
@@ -1,3 +1,3 @@
1
1
  module Reline
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - aycabta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-24 00:00:00.000000000 Z
11
+ date: 2019-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: io-console