reline 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/reline/line_editor.rb +19 -9
- data/lib/reline/unicode.rb +1 -0
- data/lib/reline/version.rb +1 -1
- data/lib/reline/windows.rb +24 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f165aeb5368335d41b08932f34d0457d612fe4dbe334748964c2bafaaa518b54
|
4
|
+
data.tar.gz: 4e268dfea3a18f61b6f0bdbbf4d7dd292b3f2d62e178835c971f7b9d3da96613
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c56912f662f9c0e53d793ff108ad44fa2ef231b07fa579ab11e793639b27dd076b6dcb54c7dcc1f68c52a73fbabddf8f41a9d8ea8ea53c06cee481628ea9e18
|
7
|
+
data.tar.gz: acc258dcbe8b5a3dbe536cc3084906bae2006972f7a3e34353f7f87bbb9b78d692e68b479abb412aae18c396efa2f8dc0210fabc04451cce3f48e7ac8a572093
|
data/lib/reline/line_editor.rb
CHANGED
@@ -124,6 +124,7 @@ class Reline::LineEditor
|
|
124
124
|
@prompt_cache_time = Time.now.to_f
|
125
125
|
end
|
126
126
|
prompt_list.map!{ prompt } if @vi_arg or @searching_prompt
|
127
|
+
prompt_list = [prompt] if prompt_list.empty?
|
127
128
|
mode_string = check_mode_string
|
128
129
|
prompt_list = prompt_list.map{ |pr| mode_string + pr } if mode_string
|
129
130
|
prompt = prompt_list[@line_index]
|
@@ -343,8 +344,9 @@ class Reline::LineEditor
|
|
343
344
|
else
|
344
345
|
end_of_line_cursor = new_cursor_max
|
345
346
|
end
|
346
|
-
line_to_calc.
|
347
|
-
|
347
|
+
line_to_calc.grapheme_clusters.each do |gc|
|
348
|
+
mbchar = gc.encode(Encoding::UTF_8)
|
349
|
+
mbchar_width = Reline::Unicode.get_mbchar_width(mbchar)
|
348
350
|
now = new_cursor + mbchar_width
|
349
351
|
if now > end_of_line_cursor or now > cursor
|
350
352
|
break
|
@@ -724,13 +726,17 @@ class Reline::LineEditor
|
|
724
726
|
Reline::IOGate.move_cursor_column(0)
|
725
727
|
if line.nil?
|
726
728
|
if calculate_width(visual_lines[index - 1], true) == Reline::IOGate.get_screen_size.last
|
727
|
-
#
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
729
|
+
# reaches the end of line
|
730
|
+
if Reline::IOGate.win? and Reline::IOGate.win_legacy_console?
|
731
|
+
# A newline is automatically inserted if a character is rendered at
|
732
|
+
# eol on command prompt.
|
733
|
+
else
|
734
|
+
# When the cursor is at the end of the line and erases characters
|
735
|
+
# after the cursor, some terminals delete the character at the
|
736
|
+
# cursor position.
|
737
|
+
move_cursor_down(1)
|
738
|
+
Reline::IOGate.move_cursor_column(0)
|
739
|
+
end
|
734
740
|
else
|
735
741
|
Reline::IOGate.erase_after_cursor
|
736
742
|
move_cursor_down(1)
|
@@ -739,6 +745,10 @@ class Reline::LineEditor
|
|
739
745
|
next
|
740
746
|
end
|
741
747
|
@output.write line
|
748
|
+
if Reline::IOGate.win? and Reline::IOGate.win_legacy_console? and calculate_width(line, true) == Reline::IOGate.get_screen_size.last
|
749
|
+
# A newline is automatically inserted if a character is rendered at eol on command prompt.
|
750
|
+
@rest_height -= 1 if @rest_height > 0
|
751
|
+
end
|
742
752
|
@output.flush
|
743
753
|
if @first_prompt
|
744
754
|
@first_prompt = false
|
data/lib/reline/unicode.rb
CHANGED
@@ -108,6 +108,7 @@ class Reline::Unicode
|
|
108
108
|
end
|
109
109
|
m = mbchar.encode(Encoding::UTF_8).match(MBCharWidthRE)
|
110
110
|
case
|
111
|
+
when m.nil? then 1 # TODO should be U+FFFD � REPLACEMENT CHARACTER
|
111
112
|
when m[:width_2_1], m[:width_2_2] then 2
|
112
113
|
when m[:width_3] then 3
|
113
114
|
when m[:width_0] then 0
|
data/lib/reline/version.rb
CHANGED
data/lib/reline/windows.rb
CHANGED
@@ -9,6 +9,10 @@ class Reline::Windows
|
|
9
9
|
true
|
10
10
|
end
|
11
11
|
|
12
|
+
def self.win_legacy_console?
|
13
|
+
@@legacy_console
|
14
|
+
end
|
15
|
+
|
12
16
|
RAW_KEYSTROKE_CONFIG = {
|
13
17
|
[224, 72] => :ed_prev_history, # ↑
|
14
18
|
[224, 80] => :ed_next_history, # ↓
|
@@ -94,6 +98,26 @@ class Reline::Windows
|
|
94
98
|
@@GetFileInformationByHandleEx = Win32API.new('kernel32', 'GetFileInformationByHandleEx', ['L', 'I', 'P', 'L'], 'I')
|
95
99
|
@@FillConsoleOutputAttribute = Win32API.new('kernel32', 'FillConsoleOutputAttribute', ['L', 'L', 'L', 'L', 'P'], 'L')
|
96
100
|
|
101
|
+
@@GetConsoleMode = Win32API.new('kernel32', 'GetConsoleMode', ['L', 'P'], 'L')
|
102
|
+
@@SetConsoleMode = Win32API.new('kernel32', 'SetConsoleMode', ['L', 'L'], 'L')
|
103
|
+
ENABLE_VIRTUAL_TERMINAL_PROCESSING = 4
|
104
|
+
|
105
|
+
private_class_method def self.getconsolemode
|
106
|
+
mode = "\000\000\000\000"
|
107
|
+
@@GetConsoleMode.call(@@hConsoleHandle, mode)
|
108
|
+
mode.unpack1('L')
|
109
|
+
end
|
110
|
+
|
111
|
+
private_class_method def self.setconsolemode(mode)
|
112
|
+
@@SetConsoleMode.call(@@hConsoleHandle, mode)
|
113
|
+
end
|
114
|
+
|
115
|
+
@@legacy_console = (getconsolemode() & ENABLE_VIRTUAL_TERMINAL_PROCESSING == 0)
|
116
|
+
#if @@legacy_console
|
117
|
+
# setconsolemode(getconsolemode() | ENABLE_VIRTUAL_TERMINAL_PROCESSING)
|
118
|
+
# @@legacy_console = (getconsolemode() & ENABLE_VIRTUAL_TERMINAL_PROCESSING == 0)
|
119
|
+
#end
|
120
|
+
|
97
121
|
@@input_buf = []
|
98
122
|
@@output_buf = []
|
99
123
|
|
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.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aycabta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: io-console
|