close
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Lib/curses/textpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,8 @@ def gather(self):
stop = self._end_of_line(y)
if stop == 0 and self.stripspaces:
continue
for x in range(self.maxx+1):
if self.stripspaces and x > stop:
break
result = result + str(self.win.in_wch(y, x))
count = stop+1 if self.stripspaces else self.maxx+1
result = result + str(self.win.in_wchstr(y, 0, count))
if self.maxy > 0:
result = result + "\n"
return result
Expand Down
16 changes: 16 additions & 0 deletions Lib/test/test_curses.py
Original file line number Diff line number Diff line change
Expand Up @@ -2660,6 +2660,22 @@ def test_textbox_combining(self):
box.do_command(ch)
self.assertEqual(box.gather(), text + ' ')

@requires_wide_build
def test_textbox_double_width(self):
# A double-width (East Asian) character occupies two cells. gather()
# reads a whole line at a time so that the second cell, which holds
# the same character, is not reported as another one.
text = '你好'
if self._encodable(text):
box, win = self._make_textbox(1, 12)
for ch in text:
box.do_command(ch)
self.assertEqual(box.gather(), text + ' ')
box, win = self._make_textbox(1, 12, stripspaces=0)
for ch in text:
box.do_command(ch)
self.assertEqual(box.gather(), text + ' ' * 8)

def test_textbox_edit_wide(self):
# edit() reads characters through get_wch(). Each character is pushed
# with unget_wch(), which on a narrow build requires it to encode to a
Expand Down
Loading