ansi-select 0.3.1 → 0.3.2
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/CHANGELOG.md +5 -1
- data/lib/ansi/selector/impl.rb +8 -1
- data/lib/ansi/selector/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1378e23b4792a1b8e537ceb3a258bf114cb8e018
|
4
|
+
data.tar.gz: 643ed6980728846d7b0482ad4c0d5e5c414b90ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0d1de90043ec51fb3cf564c5fd13cf969a674ce4ecfd7ecd01ceac12abee05a3f7197b91e39ff4a1424b1c42c001fa8dd102220b0595d539cce95ecbe8a6d0e
|
7
|
+
data.tar.gz: 4d089f8d2ebe34c45c47466c2804c73532446e014c3ec9f12b35242228679525a3efc05694e7dbb690b13d674981067364a28289e5bf614ea79d137af378f5bf
|
data/CHANGELOG.md
CHANGED
data/lib/ansi/selector/impl.rb
CHANGED
@@ -3,6 +3,8 @@ require "io/console"
|
|
3
3
|
module Ansi
|
4
4
|
class Selector
|
5
5
|
class Impl
|
6
|
+
POSITION_SCRIPT_PATH = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "position.sh"))
|
7
|
+
|
6
8
|
CODES = {
|
7
9
|
standout_mode: `tput rev`,
|
8
10
|
exit_standout_mode: `tput rmso`,
|
@@ -156,7 +158,7 @@ module Ansi
|
|
156
158
|
elsif index > @cursor_line_index
|
157
159
|
(index - @cursor_line_index).times { tty.print CODES[:cursor_down] }
|
158
160
|
else
|
159
|
-
row_before_going =
|
161
|
+
row_before_going = cursor_row
|
160
162
|
(@cursor_line_index - index).times do |step|
|
161
163
|
tty.print(`tput ri`) if step >= row_before_going
|
162
164
|
tty.print CODES[:cursor_up]
|
@@ -179,6 +181,11 @@ module Ansi
|
|
179
181
|
text.size >= @columns ? text[0...(@columns - 2)] + '…' : text
|
180
182
|
end
|
181
183
|
|
184
|
+
# @return [Fixnum]
|
185
|
+
def cursor_row
|
186
|
+
`bash #{POSITION_SCRIPT_PATH}`.to_i
|
187
|
+
end
|
188
|
+
|
182
189
|
# @param [String] text
|
183
190
|
#
|
184
191
|
# @return [String]
|