MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / wrap_text_pager

Function wrap_text_pager

pager/PagerRagnar.py:124–138  ·  view source on GitHub ↗

Wrap text by character count (no PIL font needed).

(text, max_chars=40, **kwargs)

Source from the content-addressed store, hash-verified

122 original_wrap = shared_data.wrap_text
123
124 def wrap_text_pager(text, max_chars=40, **kwargs):
125 """Wrap text by character count (no PIL font needed)."""
126 lines = []
127 words = text.split()
128 line = ''
129 for word in words:
130 if len(line) + len(word) + 1 <= max_chars:
131 line = line + (' ' if line else '') + word
132 else:
133 if line:
134 lines.append(line)
135 line = word
136 if line:
137 lines.append(line)
138 return lines
139
140 shared_data.wrap_text = wrap_text_pager
141

Callers

nothing calls this directly

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected