lib/textbringer/utils.rb in textbringer-0.2.5 vs lib/textbringer/utils.rb in textbringer-0.2.6

- old
+ new

@@ -192,11 +192,12 @@ else file end } } - file = read_from_minibuffer(prompt, completion_proc: f, default: default) + file = read_from_minibuffer(prompt, completion_proc: f, + initial_value: default) File.expand_path(file) end def complete_for_minibuffer(s, candidates) candidates.select { |i| i.start_with?(s) } @@ -210,9 +211,16 @@ def read_command_name(prompt) f = ->(s) { complete_for_minibuffer(s.tr("-", "_"), Commands.list.map(&:to_s)) } read_from_minibuffer(prompt, completion_proc: f) + end + + def read_encoding(prompt, **opts) + f = ->(s) { + complete_for_minibuffer(s.upcase, Encoding.list.map(&:name)) + } + read_from_minibuffer(prompt, completion_proc: f, **opts) end def yes_or_no?(prompt) loop { s = read_from_minibuffer(prompt + " (yes or no) ")