Skip to content

Commit

Permalink
Merge commit 'refs/pull/116/head' of https://github.com/OCA/stock-log…
Browse files Browse the repository at this point in the history
…istics-barcode into 10.0-lns_master
  • Loading branch information
benwillig committed Nov 22, 2017
2 parents 7d12849 + fd58fc4 commit dc32d87
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions stock_scanner/hardware/sentinel.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
I18N_DOMAIN = 'sentinel'
I18N_DEFAULT = 'en_US'

NULL_CHAR = '\0'


# _ will be initialized by gettext.install but declared to prevent pep8 issues
_ = None
Expand Down Expand Up @@ -634,8 +636,11 @@ def _input_text(self, message, default='', size=None, title=None):
self._display(clear=True)

# Display the current value if echoing is needed
display_value = ''.join(
[curses.ascii.unctrl(char) for char in value])
display_value = ''.join([
curses.ascii.unctrl(char)
for char in value
if char != NULL_CHAR
])
display_start = max(0, len(display_value) - self.window_width + 1)
display_value = display_value[display_start:]
self._display(' ' * (self.window_width - 1), 0, line)
Expand All @@ -647,7 +652,15 @@ def _input_text(self, message, default='', size=None, title=None):
title=title)

# Printable character : store in value
if len(key) == 1 and (curses.ascii.isprint(key) or ord(key) < 32):
add_key = (
len(key) == 1 and
key != NULL_CHAR and
(
curses.ascii.isprint(key) or
ord(key)
)
)
if add_key:
value += key
# Backspace or del, remove the last character
elif key == 'KEY_BACKSPACE' or key == 'KEY_DC':
Expand Down

0 comments on commit dc32d87

Please sign in to comment.