MCPcopy Index your code
hub / github.com/SourceCode-AI/aura / _align_text

Method _align_text

aura/output/text.py:133–152  ·  view source on GitHub ↗
(self, text, width, pos=-1)

Source from the content-addressed store, hash-verified

131 self.align(line, left=left, right=right)
132
133 def _align_text(self, text, width, pos=-1):
134 content_len = self.ansi_length(text)
135 remaining_len = width
136 overflow = content_len - remaining_len
137
138 if content_len > remaining_len:
139 parts = self.ANSI_RE.split(text)[::-1]
140 for idx, x in enumerate(parts):
141 if x.startswith(r"\x1b"):
142 continue
143 if len(x) > overflow:
144 parts[idx] = x[:-overflow-6] + " [...]"
145 break
146
147 text = "".join(parts[::-1])
148
149 if pos == -1:
150 return text + " " * (remaining_len - content_len)
151 else:
152 return " " * (remaining_len - content_len) + text
153
154 def print_tables(self, *tables):
155 table_widths = [t.width+2 for t in tables]

Callers 5

alignMethod · 0.95
print_tablesMethod · 0.95
output_tableMethod · 0.95
output_info_dataMethod · 0.95
pprintMethod · 0.95

Calls 2

ansi_lengthMethod · 0.95
joinMethod · 0.80

Tested by

no test coverage detected