summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbinoam Praxedes Marques Jr <abinoam@gmail.com>2015-05-24 11:08:19 -0300
committerAbinoam Praxedes Marques Jr <abinoam@gmail.com>2015-05-24 11:29:30 -0300
commitf8ce3e971b34e2ab5db66db0a05e3869281b2c10 (patch)
tree47c71677a14cf181506b46977480e49c063198bf
parent9351eaefe67c6176cb9b5a0df996988bf6655e41 (diff)
downloadhighline-f8ce3e971b34e2ab5db66db0a05e3869281b2c10.tar.gz
Remove backspace_limit tracking need
Put the "echoing" with "chopping" altogether and remove the need for tracking a backspace_limit
-rwxr-xr-xlib/highline.rb14
1 files changed, 3 insertions, 11 deletions
diff --git a/lib/highline.rb b/lib/highline.rb
index 5ff9de9..b7f0d86 100755
--- a/lib/highline.rb
+++ b/lib/highline.rb
@@ -690,30 +690,22 @@ class HighLine
get_line(question)
else
line = ""
- backspace_limit = 0
terminal.raw_no_echo_mode_exec do
while character = terminal.get_character(@input)
# honor backspace and delete
if character == "\b"
- line.chop!
- backspace_limit -= 1
+ chopped = line.chop!
+ output_erase_char if chopped and question.echo
else
line << character
- backspace_limit = line.size
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"
- # only backspace if we have characters on the line to
- # eliminate, otherwise we'll tromp over the prompt
- if backspace_limit >= 0 then
- output_erase_char
- else
- # do nothing
- end
+ # Do nothing - zombie code TODO: Remove it
else
if question.echo == true
@output.print(line[-1])