diff --git a/evennia/utils/eveditor.py b/evennia/utils/eveditor.py index c7a7a04c92..7557c40a0e 100644 --- a/evennia/utils/eveditor.py +++ b/evennia/utils/eveditor.py @@ -67,7 +67,7 @@ _DEFAULT_WIDTH = settings.CLIENT_DEFAULT_WIDTH # ------------------------------------------------------------- _HELP_TEXT = _( - """ + f""" - any non-command is appended to the end of the buffer. : - view buffer or only line(s) :: - raw-view buffer or only line(s) @@ -97,8 +97,10 @@ _HELP_TEXT = _( :s - search/replace word or regex in buffer or on line - :j - justify buffer or line . is f, c, l or r. Default f (full) - :f - flood-fill entire buffer or line . Equivalent to :j l + :j = - justify buffer or line . is f, c, l or r. is + width. Default for is l (left). Default for is {_DEFAULT_WIDTH} + :f = - flood-fill entire buffer or line to width . + Equivalent to :j l :fi - indent entire buffer or line :fd - de-indent entire buffer or line @@ -686,7 +688,14 @@ class CmdEditorGroup(CmdEditorBase): editor.update_buffer(buf) elif cmd == ":f": # :f flood-fill buffer or lines of buffer. + # :f = flood-fill buffer or lines of buffer to width . width = _DEFAULT_WIDTH + if self.arg1: + value = self.arg1.lstrip("=") + if not value.isdigit(): + self.caller.msg("Width must be a number.") + return + width = int(value) if not self.linerange: lstart = 0 lend = self.cline + 1 @@ -698,7 +707,7 @@ class CmdEditorGroup(CmdEditorBase): buf = linebuffer[:lstart] + fbuf.split("\n") + linebuffer[lend:] editor.update_buffer(buf) elif cmd == ":j": - # :f justify buffer of with as align (one of + # :j = justify buffer of to width with as align (one of # f(ull), c(enter), r(ight) or l(left). Default is full. align_map = { "full": "f", @@ -711,7 +720,10 @@ class CmdEditorGroup(CmdEditorBase): "l": "l", } align_name = {"f": "Full", "c": "Center", "l": "Left", "r": "Right"} - width = _DEFAULT_WIDTH + # shift width arg right if no alignment specified + if self.arg1.startswith('='): + self.arg2 = self.arg1 + self.arg1 = None if self.arg1 and self.arg1.lower() not in align_map: self.caller.msg( _("Valid justifications are") @@ -719,6 +731,13 @@ class CmdEditorGroup(CmdEditorBase): ) return align = align_map[self.arg1.lower()] if self.arg1 else "f" + width = _DEFAULT_WIDTH + if self.arg2: + value = self.arg2.lstrip("=") + if not value.isdigit(): + self.caller.msg("Width must be a number.") + return + width = int(value) if not self.linerange: lstart = 0 lend = self.cline + 1