sawaal 1.0.2 → 1.1.0
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 +11 -0
- data/lib/sawaal.rb +6 -6
- data/lib/sawaal/cursor.rb +10 -0
- data/lib/sawaal/selections.rb +21 -11
- data/lib/sawaal/selector.rb +1 -1
- data/lib/sawaal/tty.rb +1 -1
- data/lib/sawaal/version.rb +1 -1
- data/spec/version_spec.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: f83a00ac10ede43f129020b8d41fbacd18293e36
|
|
4
|
+
data.tar.gz: d1fc746b0afac374c12d231e08f21fe790cd68da
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 20c2be2726ea28a67b78a3952b3173af2532a8da54c4cffdabab806deedde0e69783c7443e2c8178c7558e759e530438c959c9aa8551cc0fc4d0226275fe002b
|
|
7
|
+
data.tar.gz: 6d8c445b93ea703b7f20c09570d06986ad5e34a55489c0fb59a40d12d941a7b29b8d5c582f0c10cbfb6fb648a4b6691f3447b334edcb1d6764639500ed22447f
|
data/CHANGELOG.md
CHANGED
|
@@ -16,6 +16,17 @@ List of changes so far that have been released to ruby gems.
|
|
|
16
16
|
|
|
17
17
|
<!-- markdown-toc end -->
|
|
18
18
|
|
|
19
|
+
1.1.0 / 2015-07-29
|
|
20
|
+
==================
|
|
21
|
+
|
|
22
|
+
## Minor improvements
|
|
23
|
+
|
|
24
|
+
### Hide help on keypress
|
|
25
|
+
|
|
26
|
+
## Bugfixes
|
|
27
|
+
|
|
28
|
+
### Read C-c properly
|
|
29
|
+
|
|
19
30
|
1.0.2 / 2015-07-29
|
|
20
31
|
==================
|
|
21
32
|
|
data/lib/sawaal.rb
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
require 'io/console'
|
|
4
4
|
require 'timeout'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
require_relative './sawaal/color'
|
|
7
|
+
require_relative './sawaal/cursor'
|
|
8
|
+
require_relative './sawaal/selections'
|
|
9
|
+
require_relative './sawaal/selector'
|
|
10
|
+
require_relative './sawaal/tty'
|
|
11
|
+
require_relative './sawaal/version'
|
|
12
12
|
|
|
13
13
|
# Helps a command line application by allowing it to ask
|
|
14
14
|
# multiple choice questions
|
data/lib/sawaal/cursor.rb
CHANGED
|
@@ -12,6 +12,7 @@ module Sawaal
|
|
|
12
12
|
def initialize
|
|
13
13
|
@text = []
|
|
14
14
|
@current_line_index = -1
|
|
15
|
+
@help_hidden = false
|
|
15
16
|
end
|
|
16
17
|
|
|
17
18
|
def save_excursion(&block)
|
|
@@ -45,6 +46,15 @@ module Sawaal
|
|
|
45
46
|
TTY.print '(use arrow keys, press <enter> when finished)'
|
|
46
47
|
end
|
|
47
48
|
|
|
49
|
+
def hide_help
|
|
50
|
+
return if @help_hidden
|
|
51
|
+
restore_position
|
|
52
|
+
clear_line
|
|
53
|
+
move_down
|
|
54
|
+
move_to_beginning
|
|
55
|
+
@help_hidden = true
|
|
56
|
+
end
|
|
57
|
+
|
|
48
58
|
def write_item(item)
|
|
49
59
|
line = "#{bold TTY::ARROW} #{item}"
|
|
50
60
|
move_down
|
data/lib/sawaal/selections.rb
CHANGED
|
@@ -15,17 +15,15 @@ module Sawaal
|
|
|
15
15
|
def select
|
|
16
16
|
loop do
|
|
17
17
|
ch = read_char
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
exit 33
|
|
28
|
-
end
|
|
18
|
+
|
|
19
|
+
# hide help after any keypress
|
|
20
|
+
@cursor.hide_help
|
|
21
|
+
|
|
22
|
+
# selection has been made
|
|
23
|
+
break if ch == TTY::RETURN
|
|
24
|
+
|
|
25
|
+
# move selection
|
|
26
|
+
handle_input(ch)
|
|
29
27
|
end
|
|
30
28
|
|
|
31
29
|
selected = @cursor.current_line_index
|
|
@@ -33,6 +31,18 @@ module Sawaal
|
|
|
33
31
|
@keys[@cursor.current_line_index]
|
|
34
32
|
end
|
|
35
33
|
|
|
34
|
+
def handle_input(ch)
|
|
35
|
+
case ch
|
|
36
|
+
when TTY::MOVE_UP
|
|
37
|
+
@cursor.highlight(@cursor.current_line_index - 1)
|
|
38
|
+
when TTY::MOVE_DOWN
|
|
39
|
+
@cursor.highlight(@cursor.current_line_index + 1)
|
|
40
|
+
when TTY::CONTROL_C
|
|
41
|
+
@cursor.write_selection(red('<terminated>'))
|
|
42
|
+
exit 33
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
36
46
|
def write
|
|
37
47
|
@items.each do |item|
|
|
38
48
|
@cursor.write_item(item)
|
data/lib/sawaal/selector.rb
CHANGED
data/lib/sawaal/tty.rb
CHANGED
data/lib/sawaal/version.rb
CHANGED
data/spec/version_spec.rb
CHANGED