GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Use width aware slice · pp1992m/bpython@ef91741

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • bpython/curtsiesfrontend
    • replpainter.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎bpython/curtsiesfrontend/replpainter.py‎

Copy file name to clipboardExpand all lines: bpython/curtsiesfrontend/replpainter.py
+8-5Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,14 @@ def display_linize(msg, columns, blank_line=False):
2525
"""Returns lines obtained by splitting msg over multiple lines.
2626
2727
Warning: if msg is empty, returns an empty list of lines"""
28-
display_lines = ([msg[start:end]
29-
for start, end in zip(
30-
range(0, len(msg), columns),
31-
range(columns, len(msg) + columns, columns))]
32-
if msg else ([''] if blank_line else []))
28+
msg = fmtstr(msg)
29+
try:
30+
display_lines = [msg.width_aware_slice(slice(start, end))
31+
for start, end in zip(
32+
range(0, msg.width, columns),
33+
range(columns, msg.width + columns, columns))]
34+
except ValueError:
35+
display_lines = ([''] if blank_line else [])
3336
return display_lines
3437

3538

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.