Add quote_wrap option
This commit is contained in:
parent
e0ec1a87bb
commit
b4a3aabad9
2 changed files with 29 additions and 10 deletions
|
@ -62,14 +62,11 @@ class Formatted(object):
|
||||||
# type: (List[FormattedString]) -> None
|
# type: (List[FormattedString]) -> None
|
||||||
self.substrings = substrings
|
self.substrings = substrings
|
||||||
|
|
||||||
@property
|
def textwrapper(self, width, colors):
|
||||||
def textwrapper(self):
|
|
||||||
quote_pair = color_pair(G.CONFIG.color.quote_fg,
|
|
||||||
G.CONFIG.color.quote_bg)
|
|
||||||
return textwrap.TextWrapper(
|
return textwrap.TextWrapper(
|
||||||
width=67,
|
width=width,
|
||||||
initial_indent="{}> ".format(W.color(quote_pair)),
|
initial_indent="{}> ".format(W.color(colors)),
|
||||||
subsequent_indent="{}> ".format(W.color(quote_pair)),
|
subsequent_indent="{}> ".format(W.color(colors)),
|
||||||
)
|
)
|
||||||
|
|
||||||
def is_formatted(self):
|
def is_formatted(self):
|
||||||
|
@ -356,9 +353,21 @@ class Formatted(object):
|
||||||
elif name == "strikethrough":
|
elif name == "strikethrough":
|
||||||
return string_strikethrough(string)
|
return string_strikethrough(string)
|
||||||
elif name == "quote":
|
elif name == "quote":
|
||||||
return self.textwrapper.fill(
|
quote_pair = color_pair(G.CONFIG.color.quote_fg,
|
||||||
W.string_remove_color(string.replace("\n", ""), "")
|
G.CONFIG.color.quote_bg)
|
||||||
)
|
|
||||||
|
if G.CONFIG.look.quote_wrap >= 0:
|
||||||
|
wrapper = self.textwrapper(G.CONFIG.look.quote_wrap, quote_pair)
|
||||||
|
return wrapper.fill(
|
||||||
|
W.string_remove_color(string.replace("\n", ""), "")
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
# Don't wrap, just add quote markers to all lines
|
||||||
|
return "{color_on}{text}{color_off}".format(
|
||||||
|
color_on=W.color(quote_pair),
|
||||||
|
text="> " + W.string_remove_color(string.replace("\n", "\n> "), ""),
|
||||||
|
color_off=W.color("resetcolor")
|
||||||
|
)
|
||||||
elif name == "code":
|
elif name == "code":
|
||||||
code_color_pair = color_pair(
|
code_color_pair = color_pair(
|
||||||
G.CONFIG.color.untagged_code_fg,
|
G.CONFIG.color.untagged_code_fg,
|
||||||
|
|
|
@ -540,6 +540,16 @@ class MatrixConfig(WeechatConfig):
|
||||||
("Number of spaces to add as a margin around around a code "
|
("Number of spaces to add as a margin around around a code "
|
||||||
"block"),
|
"block"),
|
||||||
),
|
),
|
||||||
|
Option(
|
||||||
|
"quote_wrap",
|
||||||
|
"integer",
|
||||||
|
"",
|
||||||
|
-1,
|
||||||
|
1000,
|
||||||
|
"67",
|
||||||
|
("After how many characters to soft-wrap lines in a quote "
|
||||||
|
"block (reply message). Set to -1 to disable soft-wrapping."),
|
||||||
|
),
|
||||||
Option(
|
Option(
|
||||||
"human_buffer_names",
|
"human_buffer_names",
|
||||||
"boolean",
|
"boolean",
|
||||||
|
|
Loading…
Reference in a new issue