diff options
author | Abinoam Praxedes Marques Jr <abinoam@gmail.com> | 2015-05-24 11:31:05 -0300 |
---|---|---|
committer | Abinoam Praxedes Marques Jr <abinoam@gmail.com> | 2015-05-24 11:31:05 -0300 |
commit | fbfd29f5175caac64e5c215d099c5f6a7446c496 (patch) | |
tree | af10ea5474c33a7131442d2f5710920ffdc181d1 | |
parent | f8ce3e971b34e2ab5db66db0a05e3869281b2c10 (diff) | |
download | highline-fbfd29f5175caac64e5c215d099c5f6a7446c496.tar.gz |
Aggregate code and simplify conditionals
-rwxr-xr-x | lib/highline.rb | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/lib/highline.rb b/lib/highline.rb index b7f0d86..21cd60c 100755 --- a/lib/highline.rb +++ b/lib/highline.rb @@ -689,32 +689,24 @@ class HighLine if question.echo == true and question.limit.nil? get_line(question) else - line = "" + line = "" terminal.raw_no_echo_mode_exec do while character = terminal.get_character(@input) + break if character == "\n" or character == "\r" + # honor backspace and delete if character == "\b" chopped = line.chop! output_erase_char if chopped and question.echo else line << character + @output.print(line[-1]) if question.echo == true + @output.print(question.echo) if question.echo and question.echo != true end - # looking for carriage return (decimal 13) or - # newline (decimal 10) in raw input - break if character == "\n" or character == "\r" - if question.echo != false - if character == "\b" - # Do nothing - zombie code TODO: Remove it - else - if question.echo == true - @output.print(line[-1]) - else - @output.print(question.echo) - end - end - @output.flush - end + + @output.flush + break if question.limit and line.size == question.limit end end |