bugnano / rnr

The RNR File Manager (RNR's Not Ranger)
GNU General Public License v3.0
53 stars 1 forks source link

CanvasError: Canvas text is wider than the maxcol specified #3

Closed patrick-tang closed 3 years ago

patrick-tang commented 3 years ago

Got error when trying to open a folder with files in long non-english file name. Error log:

File "/usr/bin/rnr", line 8, in sys.exit(main()) File "/usr/lib/python3.9/site-packages/rnr/main.py", line 1063, in main app.run() File "/usr/lib/python3.9/site-packages/rnr/main.py", line 244, in run self.loop.run() File "/usr/lib/python3.9/site-packages/urwid/main_loop.py", line 287, in run self._run() File "/usr/lib/python3.9/site-packages/urwid/main_loop.py", line 385, in _run self.event_loop.run() File "/usr/lib/python3.9/site-packages/urwid/main_loop.py", line 790, in run self._loop() File "/usr/lib/python3.9/site-packages/urwid/main_loop.py", line 818, in _loop self._entering_idle() File "/usr/lib/python3.9/site-packages/urwid/main_loop.py", line 779, in _entering_idle callback() File "/usr/lib/python3.9/site-packages/urwid/main_loop.py", line 574, in entering_idle self.draw_screen() File "/usr/lib/python3.9/site-packages/urwid/main_loop.py", line 588, in draw_screen canvas = self._topmost_widget.render(self.screen_size, focus=True) File "/usr/lib/python3.9/site-packages/urwid/widget.py", line 145, in cached_render canv = fn(self, size, focus=focus) File "/usr/lib/python3.9/site-packages/urwid/widget.py", line 1761, in render canv = get_delegate(self).render(size, focus=focus) File "/usr/lib/python3.9/site-packages/urwid/widget.py", line 145, in cached_render canv = fn(self, size, focus=focus) File "/usr/lib/python3.9/site-packages/urwid/container.py", line 1565, in render canv = w.render((maxcol, rows), focus=focus and item_focus) File "/usr/lib/python3.9/site-packages/urwid/widget.py", line 145, in cached_render canv = fn(self, size, focus=focus) File "/usr/lib/python3.9/site-packages/urwid/container.py", line 2130, in render canv = w.render(sub_size, File "/usr/lib/python3.9/site-packages/urwid/widget.py", line 145, in cached_render canv = fn(self, size, focus=focus) File "/usr/lib/python3.9/site-packages/urwid/widget.py", line 1761, in render canv = get_delegate(self).render(size, focus=focus) File "/usr/lib/python3.9/site-packages/urwid/widget.py", line 145, in cached_render canv = fn(self, size, focus=focus) File "/usr/lib/python3.9/site-packages/urwid/container.py", line 1565, in render canv = w.render((maxcol, rows), focus=focus and item_focus) File "/usr/lib/python3.9/site-packages/urwid/widget.py", line 145, in cached_render canv = fn(self, size, focus=focus) File "/usr/lib/python3.9/site-packages/urwid/decoration.py", line 226, in render canv = self._original_widget.render(size, focus=focus) File "/usr/lib/python3.9/site-packages/urwid/widget.py", line 145, in cached_render canv = fn(self, size, focus=focus) File "/usr/lib/python3.9/site-packages/urwid/widget.py", line 1761, in render canv = get_delegate(self).render(size, focus=focus) File "/usr/lib/python3.9/site-packages/urwid/widget.py", line 145, in cached_render canv = fn(self, size, focus=focus) File "/usr/lib/python3.9/site-packages/urwid/container.py", line 1565, in render canv = w.render((maxcol, rows), focus=focus and item_focus) File "/usr/lib/python3.9/site-packages/urwid/widget.py", line 145, in cached_render canv = fn(self, size, focus=focus) File "/usr/lib/python3.9/site-packages/urwid/container.py", line 2130, in render canv = w.render(sub_size, File "/usr/lib/python3.9/site-packages/urwid/widget.py", line 145, in cached_render canv = fn(self, size, focus=focus) File "/usr/lib/python3.9/site-packages/urwid/listbox.py", line 470, in render canvas = widget.render((maxcol,)) File "/usr/lib/python3.9/site-packages/urwid/widget.py", line 145, in cached_render canv = fn(self, size, focus=focus) File "/usr/lib/python3.9/site-packages/urwid/decoration.py", line 226, in render canv = self._original_widget.render(size, focus=focus) File "/usr/lib/python3.9/site-packages/urwid/widget.py", line 145, in cached_render canv = fn(self, size, focus=focus) File "/usr/lib/python3.9/site-packages/urwid/container.py", line 2130, in render canv = w.render(sub_size, File "/usr/lib/python3.9/site-packages/urwid/widget.py", line 145, in cached_render canv = fn(self, size, focus=focus) File "/usr/lib/python3.9/site-packages/urwid/widget.py", line 1005, in render return apply_text_layout(text, attr, trans, maxcol) File "/usr/lib/python3.9/site-packages/urwid/canvas.py", line 1315, in apply_text_layout return TextCanvas(t, a, c, maxcol=maxcol) File "/usr/lib/python3.9/site-packages/urwid/canvas.py", line 358, in init raise CanvasError("Canvas text is wider than the maxcol specified \n%r\n%r\n%r"%(maxcol,widths,text)) urwid.canvas.CanvasError: Canvas text is wider than the maxcol specified 61 [85] [b' \xe6\x9c\x89\xe7\x94\x9f\xe4\xb9\x8b\xe5\xb9\xb4\xe4\xb8\x80\xe5\xae\x9a\xe8\xa6\x81\xe8\xaf\xbb\xe7\x9a\x84\xe7\xa7\x91\xe5\xb9\xbb\xe7\xbb\x8f\xe5\x85\xb8\xe7\x83\xa7\xe8\x84\x91\xe7\xa5\x9e\xe4\xbd\x9c\xef\xbc\x88\xe5\x85\xb128\xe5\x86\x8c\xef\xbc\x89\xef\xbc\x88\xe9\x98\xbf\xe8\xa5\xbf\xe8\x8e\xab\xe5\xa4\xab\xe5\xbf\x8c\xe8\xbe\xb0\xe7\xba\xaa\xe5\xbf\xb5\xe5\xa5\x97\xe8\xa3\x85\xef\xbc\x8c\xe9\x98\xbf\xe7\x91\x9f\xc2\xb7\xe5\x85\x8b\xe6\x8b\x89\xe5\x85\x8b.epub']

version: 1.0.2 platform: Manjaro 20.2.1 (kernel 5.10.18-1-MANJARO, GNome 3.38.4) python: 3.9.1

The long non-english file name: 有生之年一定要读的科幻经典烧脑神作(共28册)(阿西莫夫忌辰纪念套装,阿瑟·克拉克.epub

bugnano commented 3 years ago

Thank you for the bug report. This is not a bug of rnr di-per-se, but a bug in the Urwid framework used by rnr. I'll try looking into it, but from my experience the Urwid team is not very fast in merging new pull requests and releasing new versions. You could try issuing a bug report to Urwid as well.

patrick-tang commented 3 years ago

Thank you for the bug report. This is not a bug of rnr di-per-se, but a bug in the Urwid framework used by rnr. I'll try looking into it, but from my experience the Urwid team is not very fast in merging new pull requests and releasing new versions. You could try issuing a bug report to Urwid as well.

Thanks @bugnano . let me see if I can find Urwid in Github and check if that's a known bug with PR.

bugnano commented 3 years ago

Actually, I'm able to fix the problem in rnr, without touching Urwid. Asian characters can have a width of 2, so I need to take into account that factor when displaying the file names. I think that by tomorrow it will be fixed.

patrick-tang commented 3 years ago

Actually, I'm able to fix the problem in rnr, without touching Urwid. Asian characters can have a width of 2, so I need to take into account that factor when displaying the file names. I think that by tomorrow it will be fixed.

Thanks, @bugnano . I haven't got chance to search Urwid project yet. Been too busy this week.

bugnano commented 3 years ago

Fixed in version 1.0.3

patrick-tang commented 3 years ago

Fixed in version 1.0.3

@bugnano I just verified the long non-english file name won't crash rnr any more. Good work! I also noticed the solution was to shorten the file name for display by cut some of characters in the middle of the name. That works :+1: