tty-prompt 0.18.1 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +23 -0
  3. data/README.md +174 -63
  4. data/Rakefile +2 -2
  5. data/examples/ask_blank.rb +9 -0
  6. data/examples/enum_select_disabled.rb +1 -1
  7. data/examples/enum_select_paged.rb +1 -1
  8. data/examples/expand_auto.rb +29 -0
  9. data/examples/mask.rb +1 -1
  10. data/examples/multi_select.rb +1 -1
  11. data/examples/multi_select_disabled_paged.rb +22 -0
  12. data/examples/multi_select_paged.rb +1 -1
  13. data/examples/select_disabled_paged.rb +22 -0
  14. data/examples/select_paginated.rb +1 -1
  15. data/lib/tty/prompt.rb +46 -10
  16. data/lib/tty/prompt/{enum_paginator.rb → block_paginator.rb} +19 -18
  17. data/lib/tty/prompt/choice.rb +1 -3
  18. data/lib/tty/prompt/enum_list.rb +31 -9
  19. data/lib/tty/prompt/expander.rb +19 -1
  20. data/lib/tty/prompt/keypress.rb +30 -35
  21. data/lib/tty/prompt/list.rb +112 -40
  22. data/lib/tty/prompt/mask_question.rb +2 -3
  23. data/lib/tty/prompt/multi_list.rb +36 -12
  24. data/lib/tty/prompt/paginator.rb +37 -25
  25. data/lib/tty/prompt/question.rb +29 -5
  26. data/lib/tty/prompt/slider.rb +16 -8
  27. data/lib/tty/prompt/symbols.rb +30 -6
  28. data/lib/tty/prompt/timer.rb +75 -0
  29. data/lib/tty/prompt/version.rb +1 -1
  30. data/spec/spec_helper.rb +18 -2
  31. data/spec/unit/ask_spec.rb +45 -4
  32. data/spec/unit/{enum_paginator_spec.rb → block_paginator_spec.rb} +14 -5
  33. data/spec/unit/choice/from_spec.rb +16 -0
  34. data/spec/unit/enum_select_spec.rb +104 -32
  35. data/spec/unit/expand_spec.rb +104 -12
  36. data/spec/unit/keypress_spec.rb +2 -8
  37. data/spec/unit/mask_spec.rb +9 -1
  38. data/spec/unit/multi_select_spec.rb +348 -118
  39. data/spec/unit/paginator_spec.rb +29 -10
  40. data/spec/unit/select_spec.rb +390 -108
  41. data/spec/unit/slider_spec.rb +48 -6
  42. data/spec/unit/timer_spec.rb +29 -0
  43. data/tty-prompt.gemspec +4 -6
  44. metadata +17 -46
  45. data/lib/tty/prompt/timeout.rb +0 -78
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4993a3639c2dec47c658cddd6a8c3d98b4efb7bec6cc3d1b90dfd184d9b6f889
4
- data.tar.gz: d069f2c94118978bbfa04e54c967a0d8ce185adc6d7eb74446988350bca21d06
3
+ metadata.gz: 5b95f394284033f244487a624ca98d9d4aca8a1d5b01c08d181a3bbfe509aa4a
4
+ data.tar.gz: 32031c9ca43c3098418f54051af00bdcba6075532ba0878a3b8efda844ba076f
5
5
  SHA512:
6
- metadata.gz: c1dd9287d14e3aa2eb8357d9ff759cdec52182535bc9697f97d4da7ab7c111f27ec61bfc176cc16cc7c8f4f2ca1dcd3af4784df1c82e95b0382f4cb2dc7cc782
7
- data.tar.gz: 62ed0bc598c3a6b6b65ed7a5f14a7bacd769a5d46dfa041afb67d4d7a4de407e4cb5334fc25942351551414c0c29d68a9fc51aa238e198931677639c3ad4d382
6
+ metadata.gz: decec13d7b8a65ba78d5c2eea5ed3366976670c1a7e0ebe228c25cf5b494aa82fe3131e5521fe3c8d882d10b2db2aa6934749f1583f767630f4bf3a4fc59eb96
7
+ data.tar.gz: 7d1e877c0f4e1df2db06726cd8748b6e777f59cf055177d480610687db46ad7de12ee7cfe7aa454414816020bfa35ab5a1e273b680946a45d287b6563e7a1ff6
@@ -1,5 +1,27 @@
1
1
  # Change log
2
2
 
3
+ ## [v0.19.0] - 2019-05-27
4
+
5
+ ### Added
6
+ * Add Prompt#debug to allow displaying values in terminal's top right corner
7
+ * Add :max to limit number of choices in #multi_select prompt
8
+ * Add :value to pre populate #ask prompt line content
9
+ * Add :auto_hint to expand default hint in #expand prompt by Ewoudt Kellerman(@hellola)
10
+ * Add Timer to track and timeout code execution
11
+
12
+ ### Changed
13
+ * Change Paginator to expose #start_index & #end_index
14
+ * Change Paginator to figure out #start_index based on per page size and adjust boundaries to match active selection
15
+ * Change #ask prompt to allow no question
16
+ * Change #enum_select to automatically assigned non-disabled default option
17
+ * Change #enum_select to set default choice when navigating by page
18
+ * Change #select & #multi_select to allow navigation by page with left/right keys
19
+ * Change #keypress to use Timer
20
+ * Change Choice#from to allow any object coercible to string
21
+ * Change to remove test artifacts from the gem bundle
22
+ * Change to remove timers dependency
23
+ * Change to update tty-reader dependency
24
+
3
25
  ## [v0.18.1] - 2018-12-29
4
26
 
5
27
  ### Changed
@@ -304,6 +326,7 @@
304
326
 
305
327
  * Initial implementation and release
306
328
 
329
+ [v0.19.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.18.1...v0.19.0
307
330
  [v0.18.1]: https://github.com/piotrmurach/tty-prompt/compare/v0.18.0...v0.18.1
308
331
  [v0.18.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.17.2...v0.18.0
309
332
  [v0.17.2]: https://github.com/piotrmurach/tty-prompt/compare/v0.17.1...v0.17.2
data/README.md CHANGED
@@ -65,12 +65,13 @@ Or install it yourself as:
65
65
  * [2.1 ask](#21-ask)
66
66
  * [2.1.1 convert](#211-convert)
67
67
  * [2.1.2 default](#212-default)
68
- * [2.1.3 echo](#213-echo)
69
- * [2.1.4 error messages](#214-error-messages)
70
- * [2.1.5 in](#215-in)
71
- * [2.1.6 modify](#216-modify)
72
- * [2.1.7 required](#217-required)
73
- * [2.1.8 validate](#218-validate)
68
+ * [2.1.3 value](#213-value)
69
+ * [2.1.4 echo](#214-echo)
70
+ * [2.1.5 error messages](#215-error-messages)
71
+ * [2.1.6 in](#216-in)
72
+ * [2.1.7 modify](#217-modify)
73
+ * [2.1.8 required](#218-required)
74
+ * [2.1.9 validate](#219-validate)
74
75
  * [2.2 keypress](#22-keypress)
75
76
  * [2.2.1 :timeout](#221-timeout)
76
77
  * [2.3 multiline](#23-multiline)
@@ -80,14 +81,19 @@ Or install it yourself as:
80
81
  * [2.6.1 choices](#261-choices)
81
82
  * [2.6.1.1 :disabled](#2611-disabled)
82
83
  * [2.6.2 select](#262-select)
83
- * [2.6.2.1 :disabled](#2621-disabled)
84
- * [2.6.2.2 :filter](#2622-filter)
84
+ * [2.6.2.1 :per_page](#2621-per_page)
85
+ * [2.6.2.2 :disabled](#2622-disabled)
86
+ * [2.6.2.3 :filter](#2623-filter)
85
87
  * [2.6.3 multi_select](#263-multi_select)
86
88
  * [2.6.3.1 :disabled](#2631-disabled)
87
89
  * [2.6.3.2 :echo](#2632-echo)
88
90
  * [2.6.3.3 :filter](#2633-filter)
91
+ * [2.6.3.4 :max](#2634-max)
89
92
  * [2.6.4 enum_select](#264-enum_select)
93
+ * [2.6.4.1 :per_page](#2641-per_page)
94
+ * [2.6.4.1 :disabled](#2641-disabled)
90
95
  * [2.7 expand](#27-expand)
96
+ * [2.7.1 auto_hint](#271-auto_hint)
91
97
  * [2.8 collect](#28-collect)
92
98
  * [2.9 suggest](#29-suggest)
93
99
  * [2.10 slider](#210-slider)
@@ -97,12 +103,13 @@ Or install it yourself as:
97
103
  * [2.11.3 error](#2113-error)
98
104
  * [2.12 keyboard events](#212-keyboard-events)
99
105
  * [3. settings](#3-settings)
100
- * [3.1 active_color](#31-active_color)
101
- * [3.2 enable_color](#32-enable-color)
102
- * [3.3 help_color](#33-help_color)
103
- * [3.4 interrupt](#34-interrupt)
104
- * [3.5 prefix](#35-prefix)
105
- * [3.6 track_history](#36-track_history)
106
+ * [3.1 :symbols](#31-symbols)
107
+ * [3.2 :active_color](#32-active_color)
108
+ * [3.3 :enable_color](#33-enable-color)
109
+ * [3.4 :help_color](#34-help_color)
110
+ * [3.5 :interrupt](#35-interrupt)
111
+ * [3.6 :prefix](#36-prefix)
112
+ * [3.7 :track_history](#37-track_history)
106
113
 
107
114
  ## 1. Usage
108
115
 
@@ -112,7 +119,7 @@ In order to start asking questions on the command line, create prompt:
112
119
  prompt = TTY::Prompt.new
113
120
  ```
114
121
 
115
- and then call `ask` with the question for simple input:
122
+ And then call `ask` with the question for simple input:
116
123
 
117
124
  ```ruby
118
125
  prompt.ask('What is your name?', default: ENV['USER'])
@@ -138,7 +145,7 @@ Asking question with list of options couldn't be easier using `select` like so:
138
145
  ```ruby
139
146
  prompt.select("Choose your destiny?", %w(Scorpion Kano Jax))
140
147
  # =>
141
- # Choose your destiny? (Use arrow keys, press Enter to select)
148
+ # Choose your destiny? (Use ↑/↓ arrow keys, press Enter to select)
142
149
  # ‣ Scorpion
143
150
  # Kano
144
151
  # Jax
@@ -151,7 +158,7 @@ choices = %w(vodka beer wine whisky bourbon)
151
158
  prompt.multi_select("Select drinks?", choices)
152
159
  # =>
153
160
  #
154
- # Select drinks? (Use arrow keys, press Space to select and Enter to finish)"
161
+ # Select drinks? (Use ↑/↓ arrow keys, press Space to select and Enter to finish)"
155
162
  # ‣ ⬡ vodka
156
163
  # ⬡ beer
157
164
  # ⬡ wine
@@ -274,7 +281,17 @@ prompt.ask('What is your name?', default: 'Anonymous')
274
281
  # What is your name? (Anonymous)
275
282
  ```
276
283
 
277
- #### 2.1.3 echo
284
+ #### 2.1.3 value
285
+
286
+ To pre-populate the input line for editing use `:value` option:
287
+
288
+ ```ruby
289
+ prompt.ask("What is your name?", value: "Piotr")
290
+ # =>
291
+ # What is your name? Piotr
292
+ ```
293
+
294
+ #### 2.1.4 echo
278
295
 
279
296
  To control whether the input is shown back in terminal or not use `:echo` option like so:
280
297
 
@@ -282,7 +299,7 @@ To control whether the input is shown back in terminal or not use `:echo` option
282
299
  prompt.ask('password:', echo: false)
283
300
  ```
284
301
 
285
- #### 2.1.4 error messages
302
+ #### 2.1.5 error messages
286
303
 
287
304
  By default `tty-prompt` comes with predefined error messages for `required`, `in`, `validate` options.
288
305
 
@@ -294,7 +311,7 @@ prompt.ask('What is your email?') do |q|
294
311
  end
295
312
  ```
296
313
 
297
- or change the `messages` key entry out of `:required?`, `:valid?`, `:range?`:
314
+ Or change the `messages` key entry out of `:required?`, `:valid?`, `:range?`:
298
315
 
299
316
  ```ruby
300
317
  prompt.ask('What is your email?') do |q|
@@ -303,7 +320,7 @@ prompt.ask('What is your email?') do |q|
303
320
  end
304
321
  ```
305
322
 
306
- to change default range validation error message do:
323
+ To change default range validation error message do:
307
324
 
308
325
  ```ruby
309
326
  prompt.ask('How spicy on scale (1-5)? ') do |q|
@@ -312,7 +329,7 @@ prompt.ask('How spicy on scale (1-5)? ') do |q|
312
329
  end
313
330
  ```
314
331
 
315
- #### 2.1.5 in
332
+ #### 2.1.6 in
316
333
 
317
334
  In order to check that provided input falls inside a range of inputs use the `in` option. For example, if we wanted to ask a user for a single digit in given range we may do following:
318
335
 
@@ -320,7 +337,7 @@ In order to check that provided input falls inside a range of inputs use the `in
320
337
  ask("Provide number in range: 0-9?") { |q| q.in('0-9') }
321
338
  ```
322
339
 
323
- #### 2.1.6 modify
340
+ #### 2.1.7 modify
324
341
 
325
342
  Set the `:modify` option if you want to handle whitespace or letter capitalization.
326
343
 
@@ -345,7 +362,7 @@ Available whitespace settings are:
345
362
  :remove # remove all whitespace
346
363
  ```
347
364
 
348
- #### 2.1.7 required
365
+ #### 2.1.8 required
349
366
 
350
367
  To ensure that input is provided use `:required` option:
351
368
 
@@ -355,7 +372,7 @@ prompt.ask("What's your phone number?", required: true)
355
372
  # >> Value must be provided
356
373
  ```
357
374
 
358
- #### 2.1.8 validate
375
+ #### 2.1.9 validate
359
376
 
360
377
  In order to validate that input matches a given patter you can pass the `validate` option. Validate setting accepts `Regex`, `Proc` or `Symbol`.
361
378
 
@@ -420,7 +437,7 @@ The `multiline` uses similar options to those supported by `ask` prompt. For exa
420
437
  prompt.multiline("Description?", default: 'A super sweet prompt.')
421
438
  ```
422
439
 
423
- or using DSL:
440
+ Or using DSL:
424
441
 
425
442
  ```ruby
426
443
  prompt.multiline("Description?") do |q|
@@ -438,12 +455,12 @@ prompt.mask('What is your secret?')
438
455
  # => What is your secret? ••••
439
456
  ```
440
457
 
441
- The masking character can be changed by passing `:mask` option:
458
+ The masking character can be changed by passing `:symbols` option with `:mask` key:
442
459
 
443
460
  ```ruby
444
- heart = prompt.decorate(' ', :magenta)
445
- prompt.mask('What is your secret?', mask: heart)
446
- # => What is your secret? ❤ ❤ ❤ ❤ ❤
461
+ heart = prompt.decorate(prompt.symbols[:heart] + ' ', :magenta)
462
+ prompt.mask('What is your secret?', symbols: {mask: heart})
463
+ # => What is your secret? ❤ ❤ ❤ ❤ ❤
447
464
  ```
448
465
 
449
466
  If you don't wish to show any output use `:echo` option like so:
@@ -584,7 +601,7 @@ For asking questions involving list of options use `select` method by passing th
584
601
  ```ruby
585
602
  prompt.select("Choose your destiny?", %w(Scorpion Kano Jax))
586
603
  # =>
587
- # Choose your destiny? (Use arrow keys, press Enter to select)
604
+ # Choose your destiny? (Use ↑/↓ arrow keys, press Enter to select)
588
605
  # ‣ Scorpion
589
606
  # Kano
590
607
  # Jax
@@ -599,7 +616,7 @@ prompt.select("Choose your destiny?") do |menu|
599
616
  menu.choice 'Jax'
600
617
  end
601
618
  # =>
602
- # Choose your destiny? (Use arrow keys, press Enter to select)
619
+ # Choose your destiny? (Use ↑/↓ arrow keys, press Enter to select)
603
620
  # ‣ Scorpion
604
621
  # Kano
605
622
  # Jax
@@ -614,7 +631,7 @@ prompt.select("Choose your destiny?") do |menu|
614
631
  menu.choice 'Jax', -> { 'Nice choice captain!' }
615
632
  end
616
633
  # =>
617
- # Choose your destiny? (Use arrow keys, press Enter to select)
634
+ # Choose your destiny? (Use ↑/↓ arrow keys, press Enter to select)
618
635
  # ‣ Scorpion
619
636
  # Kano
620
637
  # Jax
@@ -638,7 +655,7 @@ prompt.select("Choose your destiny?") do |menu|
638
655
  menu.choice 'Jax', 3
639
656
  end
640
657
  # =>
641
- # Choose your destiny? (Use arrow keys, press Enter to select)
658
+ # Choose your destiny? (Use ↑/↓ arrow keys, press Enter to select)
642
659
  # Scorpion
643
660
  # Kano
644
661
  # ‣ Jax
@@ -649,7 +666,7 @@ You can navigate the choices using the arrow keys or define your own key mapping
649
666
  ```ruby
650
667
  prompt.select("Choose your destiny?", %w(Scorpion Kano Jax), cycle: true)
651
668
  # =>
652
- # Choose your destiny? (Use arrow keys, press Enter to select)
669
+ # Choose your destiny? (Use ↑/↓ arrow keys, press Enter to select)
653
670
  # ‣ Scorpion
654
671
  # Kano
655
672
  # Jax
@@ -666,7 +683,7 @@ prompt.select("Choose your destiny?") do |menu|
666
683
  menu.choice 'Jax', 3
667
684
  end
668
685
  # =>
669
- # Choose your destiny? (Use arrow or number (0-9) keys, press Enter to select)
686
+ # Choose your destiny? (Use ↑/↓ arrow or number (0-9) keys, press Enter to select)
670
687
  # 1. Scorpion
671
688
  # 2. Kano
672
689
  # ‣ 3. Jax
@@ -676,7 +693,7 @@ You can configure help message and/or marker like so
676
693
 
677
694
  ```ruby
678
695
  choices = %w(Scorpion Kano Jax)
679
- prompt.select("Choose your destiny?", choices, help: "(Bash keyboard)", marker: '>')
696
+ prompt.select("Choose your destiny?", choices, help: "(Bash keyboard)", symbols: {marker: '>'})
680
697
  # =>
681
698
  # Choose your destiny? (Bash keyboard)
682
699
  # > Scorpion
@@ -684,18 +701,19 @@ prompt.select("Choose your destiny?", choices, help: "(Bash keyboard)", marker:
684
701
  # Jax
685
702
  ```
686
703
 
704
+ #### 2.6.1.1 `:per_page`
705
+
687
706
  By default the menu is paginated if selection grows beyond `6` items. To change this setting use `:per_page` configuration.
688
707
 
689
708
  ```ruby
690
709
  letters = ('A'..'Z').to_a
691
710
  prompt.select("Choose your letter?", letters, per_page: 4)
692
711
  # =>
693
- # Which letter? (Use arrow keys, press Enter to select)
712
+ # Which letter? (Use ↑/↓ and ←/→ arrow keys, press Enter to select)
694
713
  # ‣ A
695
714
  # B
696
715
  # C
697
716
  # D
698
- # (Move up or down to reveal more choices)
699
717
  ```
700
718
 
701
719
  You can also customise page navigation text using `:page_help` option:
@@ -708,7 +726,7 @@ prompt.select("Choose your letter?") do |menu|
708
726
  end
709
727
  ```
710
728
 
711
- #### 2.6.2.1 `:disabled`
729
+ #### 2.6.2.2 `:disabled`
712
730
 
713
731
  To disable menu choice, use the `:disabled` key with a value that explains the reason for the choice being unavailable. For example, out of all warriors, the Goro is currently injured:
714
732
 
@@ -728,7 +746,7 @@ The disabled choice will be displayed with a cross `✘` character next to it an
728
746
  ```ruby
729
747
  prompt.select('Choose your destiny?', warriors)
730
748
  # =>
731
- # Choose your destiny? (Use arrow keys, press Enter to select)
749
+ # Choose your destiny? (Use ↑/↓ arrow keys, press Enter to select)
732
750
  # ‣ Scorpion
733
751
  # Kano
734
752
  # ✘ Goro (injury)
@@ -737,7 +755,7 @@ prompt.select('Choose your destiny?', warriors)
737
755
  # Raiden
738
756
  ```
739
757
 
740
- #### 2.6.2.2 `:filter`
758
+ #### 2.6.2.3 `:filter`
741
759
 
742
760
  To activate dynamic list searching on letter/number key presses use `:filter` option:
743
761
 
@@ -745,7 +763,7 @@ To activate dynamic list searching on letter/number key presses use `:filter` op
745
763
  warriors = %w(Scorpion Kano Jax Kitana Raiden)
746
764
  prompt.select('Choose your destiny?', warriors, filter: true)
747
765
  # =>
748
- # Choose your destiny? (Use arrow keys, press Enter to select, and letter keys to filter)
766
+ # Choose your destiny? (Use ↑/↓ arrow keys, press Enter to select, and letter keys to filter)
749
767
  # ‣ Scorpion
750
768
  # Kano
751
769
  # Jax
@@ -783,7 +801,7 @@ choices = %w(vodka beer wine whisky bourbon)
783
801
  prompt.multi_select("Select drinks?", choices)
784
802
  # =>
785
803
  #
786
- # Select drinks? (Use arrow keys, press Space to select and Enter to finish)"
804
+ # Select drinks? (Use ↑/↓ arrow keys, press Space to select and Enter to finish)"
787
805
  # ‣ ⬡ vodka
788
806
  # ⬡ beer
789
807
  # ⬡ wine
@@ -887,12 +905,11 @@ By default the menu is paginated if selection grows beyond `6` items. To change
887
905
  letters = ('A'..'Z').to_a
888
906
  prompt.multi_select("Choose your letter?", letters, per_page: 4)
889
907
  # =>
890
- # Which letter? (Use arrow keys, press Space to select and Enter to finish)
908
+ # Which letter? (Use ↑/↓ and ←/→ arrow keys, press Space to select and Enter to finish)
891
909
  # ‣ ⬡ A
892
910
  # ⬡ B
893
911
  # ⬡ C
894
912
  # ⬡ D
895
- # (Move up or down to reveal more choices)
896
913
  ```
897
914
 
898
915
  #### 2.6.3.1 `:disabled`
@@ -915,7 +932,7 @@ The disabled choice will be displayed with a cross `✘` character next to it an
915
932
  ```ruby
916
933
  prompt.multi_select('Choose your favourite drink?', drinks)
917
934
  # =>
918
- # Choose your favourite drink? (Use arrow keys, press Space to select and Enter to finish)
935
+ # Choose your favourite drink? (Use ↑/↓ arrow keys, press Space to select and Enter to finish)
919
936
  # ‣ ⬡ bourbon
920
937
  # ✘ sake (out of stock)
921
938
  # ⬡ vodka
@@ -949,7 +966,7 @@ To activate dynamic list filtering on letter/number typing, use the :filter opti
949
966
  choices = %w(vodka beer wine whisky bourbon)
950
967
  prompt.multi_select("Select drinks?", choices, filter: true)
951
968
  # =>
952
- # Select drinks? (Use arrow keys, press Space to select and Enter to finish, and letter keys to filter)
969
+ # Select drinks? (Use ↑/↓ arrow keys, press Space to select and Enter to finish, and letter keys to filter)
953
970
  # ‣ ⬡ vodka
954
971
  # ⬡ beer
955
972
  # ⬡ wine
@@ -971,6 +988,22 @@ If the user changes or deletes a filter, the choices previously selected remain
971
988
 
972
989
  The `filter` option is not compatible with `enum`.
973
990
 
991
+ #### 2.6.3.4 `:max`
992
+
993
+ To limit the number of choices an user can select, use `:max` option:
994
+
995
+ ```ruby
996
+ choices = %w(vodka beer wine whisky bourbon)
997
+ prompt.multi_select("Select drinks?", choices, max: 3)
998
+ # =>
999
+ # Select drinks? (max. 3) vodka, beer, whisky
1000
+ # ⬢ vodka
1001
+ # ⬢ beer
1002
+ # ⬡ wine
1003
+ # ⬢ whisky
1004
+ # ‣ ⬡ bourbon
1005
+ ```
1006
+
974
1007
  ### 2.6.4 enum_select
975
1008
 
976
1009
  In order to ask for standard selection from indexed list you can use `enum_select` and pass question together with possible choices:
@@ -1030,6 +1063,8 @@ end
1030
1063
  # Select an editor? /usr/bin/vim
1031
1064
  ```
1032
1065
 
1066
+ #### 2.6.4.1 `:per_page`
1067
+
1033
1068
  By default the menu is paginated if selection grows beyond `6` items. To change this setting use `:per_page` configuration.
1034
1069
 
1035
1070
  ```ruby
@@ -1045,11 +1080,42 @@ prompt.enum_select("Choose your letter?", letters, per_page: 4)
1045
1080
  # (Press tab/right or left to reveal more choices)
1046
1081
  ```
1047
1082
 
1083
+ #### 2.6.4.2 `:disabled`
1084
+
1085
+ To make a choice unavailable use the `:disabled` option and, if you wish, as value provide a reason:
1086
+
1087
+ ```ruby
1088
+ choices = [
1089
+ {name: "Emacs", disabled: '(not installed)'},
1090
+ "Atom",
1091
+ "GNU nano",
1092
+ {name: "Notepad++", disabled: '(not installed)'},
1093
+ "Sublime",
1094
+ "Vim"
1095
+ ]
1096
+ ```
1097
+
1098
+ The disabled choice will be displayed with a cross ✘ character next to it and followed by an explanation:
1099
+
1100
+
1101
+ ```ruby
1102
+ prompt.enum_select('Select an editor', choices)
1103
+ # =>
1104
+ # Select an editor
1105
+ # ✘ 1) Emacs (not installed)
1106
+ # 2) Atom
1107
+ # 3) GNU nano
1108
+ # ✘ 4) Notepad++ (not installed)
1109
+ # 5) Sublime
1110
+ # 6) Vim
1111
+ # Choose 1-6 [2]:
1112
+ ```
1113
+
1048
1114
  ### 2.7 expand
1049
1115
 
1050
1116
  The `expand` provides a compact way to ask a question with many options.
1051
1117
 
1052
- As first argument `expand` takes the message to display and as a second an array of choices. Compared to the `select`, `multi_select` and `enum_select`, the choices need to be objects that include `:key`, `:name` and `:value` keys. The `:key` must be a single character. The help choice is added automatically as the last option and the key `h`.
1118
+ As first argument `expand` takes the message to display and as a second an array of choices. Compared to the `select`, `multi_select` and `enum_select`, the choices need to be objects that include `:key`, `:name` and `:value` keys. The `:key` must be a single character. The help choice is added automatically as the last option under the key `h`.
1053
1119
 
1054
1120
  ```ruby
1055
1121
  choices = [
@@ -1109,6 +1175,17 @@ If user types `h` and presses enter, an expanded view will be shown which furthe
1109
1175
 
1110
1176
  Run `examples/expand.rb` to see the prompt in action.
1111
1177
 
1178
+ #### 2.7.1 `:auto_hint`
1179
+
1180
+ To show hint by default use `:auto_hint` option:
1181
+
1182
+ ```ruby
1183
+ prompt.expand('Overwrite Gemfile?', choices, auto_hint: true)
1184
+ # =>
1185
+ # Overwrite Gemfile? (enter "h" for help) [y,n,q,h]
1186
+ # >> overwrite this file
1187
+ ```
1188
+
1112
1189
  ### 2.8 collect
1113
1190
 
1114
1191
  In order to collect more than one answer use `collect` method. Using the `key` you can describe the answers key name. All the methods for asking user input such as `ask`, `mask`, `select` can be directly invoked on the key. The key composition is very flexible by allowing nested keys. If you want the value to be automatically converted to required type use [convert](#221-convert).
@@ -1184,12 +1261,12 @@ prompt.suggest('b', possible, indent: 4, single_text: 'Perhaps you meant?')
1184
1261
 
1185
1262
  If you have constrained range of numbers for user to choose from you may consider using `slider`.
1186
1263
 
1187
- The slider provides easy visual way of picking a value marked by `O` marker. You can set `:min`(defaults to 0), `:max` and `:step`(defaults to 1) options to configure slider range:
1264
+ The slider provides easy visual way of picking a value marked by `●` symbol. You can set `:min`(defaults to 0), `:max` and `:step`(defaults to 1) options to configure slider range:
1188
1265
 
1189
1266
  ```ruby
1190
1267
  prompt.slider('Volume', max: 100, step: 5)
1191
1268
  # =>
1192
- # Volume ──────────O────────── 50
1269
+ # Volume ──────────●────────── 50
1193
1270
  # (Use arrow keys, press Enter to select)
1194
1271
  ```
1195
1272
 
@@ -1198,16 +1275,16 @@ By default the slider is configured to pick middle of the range as a start value
1198
1275
  ```ruby
1199
1276
  prompt.slider('Volume', max: 100, step: 5, default: 75)
1200
1277
  # =>
1201
- # Volume ───────────────O───── 75
1278
+ # Volume ───────────────●────── 75
1202
1279
  # (Use arrow keys, press Enter to select)
1203
1280
  ```
1204
1281
 
1205
- You can also change the default slider formatting using the `:format`. The value must contain the `:slider` token for placing the actual animation and any `sprintf` compatible flag for number display, in our case `%d`:
1282
+ You can also change the default slider formatting using the `:format`. The value must contain the `:slider` token to show current value and any `sprintf` compatible flag for number display, in our case `%d`:
1206
1283
 
1207
1284
  ```ruby
1208
1285
  prompt.slider('Volume', max: 100, step: 5, default: 75, format: "|:slider| %d%")
1209
1286
  # =>
1210
- # Volume |───────────────O─────| 75%
1287
+ # Volume |───────────────●──────| 75%
1211
1288
  # (Use arrow keys, press Enter to select)
1212
1289
  ```
1213
1290
 
@@ -1216,7 +1293,16 @@ You can also specify slider range with decimal numbers. For example, to have a s
1216
1293
  ```ruby
1217
1294
  prompt.slider("Volume", max: 10, step: 0.5, default: 5, format: "|:slider| %.1f")
1218
1295
  # =>
1219
- # Volume |───────────────O─────| 7.5
1296
+ # Volume |───────────────●──────| 7.5
1297
+ # (Use arrow keys, press Enter to select)
1298
+ ```
1299
+
1300
+ If you wish to change the slider handle and the slider range display use `:symbols` option:
1301
+
1302
+ ```ruby
1303
+ prompt.slider("Volume", max: 100, step: 5, default: 75, symbols: {bullet: 'x', line: '_'})
1304
+ # =>
1305
+ # Volume _______________x______ 75%
1220
1306
  # (Use arrow keys, press Enter to select)
1221
1307
  ```
1222
1308
 
@@ -1230,13 +1316,13 @@ prompt.slider('What size?') do |range|
1230
1316
  range.format "|:slider| %d%"
1231
1317
  end
1232
1318
  # =>
1233
- # Volume |───────────────O─────| 75%
1319
+ # Volume |───────────────●──────| 75%
1234
1320
  # (Use arrow keys, press Enter to select)
1235
1321
  ```
1236
1322
 
1237
1323
  ### 2.11 say
1238
1324
 
1239
- To simply print message out to stdout use `say` like so:
1325
+ To simply print message out to standard output use `say` like so:
1240
1326
 
1241
1327
  ```ruby
1242
1328
  prompt.say(...)
@@ -1324,7 +1410,32 @@ The available events are:
1324
1410
 
1325
1411
  ## 3 settings
1326
1412
 
1327
- ### 3.1 active_color
1413
+ ### 3.1. `:symbols`
1414
+
1415
+ Many prompts use symbols to display information. You can overwrite the default symbols for all the prompts using the `:symbols` key and hash of symbol names as value:
1416
+
1417
+ ```ruby
1418
+ prompt = TTY::Prompt.new(symbols: {marker: '>'})
1419
+ ```
1420
+
1421
+ The following symbols can be overwritten:
1422
+
1423
+ | Symbols | Unicode | ASCII |
1424
+ | ----------- |:-------:|:-----:|
1425
+ | tick | `✓` | `√` |
1426
+ | cross | `✘` | `x` |
1427
+ | marker | `‣` | `>` |
1428
+ | dot | `•` | `.` |
1429
+ | bullet | `●` | `O` |
1430
+ | line | `─` | `-` |
1431
+ | radio_on | `⬢` | `(*)` |
1432
+ | radio_off | `⬡` | `( )` |
1433
+ | arrow_up | `↑` | `↑` |
1434
+ | arrow_down | `↓` | `↓` |
1435
+ | arrow_left | `←` | `←` |
1436
+ | arrow_right| `→` | `→` |
1437
+
1438
+ ### 3.2 `:active_color`
1328
1439
 
1329
1440
  All prompt types support `:active_color` option. In case of `select`, `multi_select`, `enum_select` or `expand` this color is used to highlight the currently selected choice. All the resulted inputs provided by user that are read in by the prompt as answer are highlighted with this color. This option can be applied either globally for all prompts or individually.
1330
1441
 
@@ -1340,7 +1451,7 @@ prompt.select('What size?', %w(Large Medium Small), active_color: :cyan)
1340
1451
 
1341
1452
  Please [see pastel](https://github.com/piotrmurach/pastel#3-supported-colors) for all supported colors.
1342
1453
 
1343
- ### 3.2 enable_color
1454
+ ### 3.3 `:enable_color`
1344
1455
 
1345
1456
  If you wish to disable coloring for a prompt simply pass `:enable_color` option
1346
1457
 
@@ -1348,7 +1459,7 @@ If you wish to disable coloring for a prompt simply pass `:enable_color` option
1348
1459
  prompt = TTY::Prompt.new(enable_color: true)
1349
1460
  ```
1350
1461
 
1351
- ### 3.3 help_color
1462
+ ### 3.4 `:help_color`
1352
1463
 
1353
1464
  Prompts such as `select`, `multi_select`, `expand` support `:help_color` which is used to customize the help text. This option can be applied either globally for all prompts or individually.
1354
1465
 
@@ -1362,7 +1473,7 @@ or per individual input do:
1362
1473
  prompt.select('What size?', %w(Large Medium Small), help_color: :cyan)
1363
1474
  ```
1364
1475
 
1365
- ### 3.4 interrupt
1476
+ ### 3.5 `:interrupt`
1366
1477
 
1367
1478
  By default `InputInterrupt` error will be raised when the user hits the interrupt key(Control-C). However, you can customise this behaviour by passing the `:interrupt` option. The available options are:
1368
1479
 
@@ -1377,7 +1488,7 @@ For example, to send interrupt signal do:
1377
1488
  prompt = TTY::Prompt.new(interrupt: :signal)
1378
1489
  ```
1379
1490
 
1380
- ### 3.5 prefix
1491
+ ### 3.6 `:prefix`
1381
1492
 
1382
1493
  You can prefix each question asked using the `:prefix` option. This option can be applied either globally for all prompts or individual for each one:
1383
1494
 
@@ -1385,7 +1496,7 @@ You can prefix each question asked using the `:prefix` option. This option can b
1385
1496
  prompt = TTY::Prompt.new(prefix: '[?] ')
1386
1497
  ```
1387
1498
 
1388
- ### 3.6 track_history
1499
+ ### 3.7 `:track_history`
1389
1500
 
1390
1501
  The prompts that accept line input such as `multiline` or `ask` provide history buffer that tracks all the lines entered during `TTY::Prompt.new` interactions. The history buffer provides previous or next lines when user presses up/down arrows respectively. However, if you wish to disable this behaviour use `:track_history` option like so:
1391
1502