MCPcopy Create free account
hub / github.com/bpython/bpython / matches_lines

Function matches_lines

bpython/curtsiesfrontend/replpainter.py:61–89  ·  view source on GitHub ↗
(rows, columns, matches, current, config, match_format)

Source from the content-addressed store, hash-verified

59
60
61def matches_lines(rows, columns, matches, current, config, match_format):
62 highlight_color = func_for_letter(config.color_scheme["operator"].lower())
63
64 if not matches:
65 return []
66 color = func_for_letter(config.color_scheme["main"])
67 max_match_width = max(len(m) for m in matches)
68 words_wide = max(1, (columns - 1) // (max_match_width + 1))
69 matches = [match_format(m) for m in matches]
70 if current:
71 current = match_format(current)
72
73 matches = paginate(rows, matches, current, words_wide)
74
75 result = [
76 fmtstr(" ").join(
77 (
78 color(m.ljust(max_match_width))
79 if m != current
80 else highlight_color(m.ljust(max_match_width))
81 )
82 for m in matches[i : i + words_wide]
83 )
84 for i in range(0, len(matches), words_wide)
85 ]
86
87 logger.debug("match: %r" % current)
88 logger.debug("matches_lines: %r" % result)
89 return result
90
91
92def formatted_argspec(funcprops, arg_pos, columns, config):

Callers 1

paint_infoboxFunction · 0.85

Calls 2

func_for_letterFunction · 0.85
paginateFunction · 0.85

Tested by

no test coverage detected