mirror of
https://github.com/evennia/evennia.git
synced 2025-10-29 11:26:10 +00:00
Fix justify m_len call. Fixes #3019
This commit is contained in:
parent
4c59a243dc
commit
045a83c6cc
2
Makefile
2
Makefile
@ -13,7 +13,7 @@ default:
|
||||
@echo " make test - run evennia test suite with all default values."
|
||||
@echo " make tests=evennia.path test - run only specific test or tests."
|
||||
@echo " make testp - run test suite using multiple cores."
|
||||
@echo " make publish - publish evennia to pypi (requires pypi credentials)
|
||||
@echo " make release - publish evennia to pypi (requires pypi credentials)
|
||||
|
||||
install:
|
||||
pip install -e .
|
||||
|
||||
@ -273,22 +273,12 @@ from django.conf import settings
|
||||
|
||||
# i18n
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from evennia import CmdSet, Command
|
||||
from evennia.commands import cmdhandler
|
||||
from evennia.utils import logger
|
||||
from evennia.utils.ansi import strip_ansi
|
||||
from evennia.utils.evtable import EvColumn, EvTable
|
||||
from evennia.utils.utils import (
|
||||
crop,
|
||||
dedent,
|
||||
is_iter,
|
||||
m_len,
|
||||
make_iter,
|
||||
mod_import,
|
||||
pad,
|
||||
to_str,
|
||||
)
|
||||
from evennia.utils.utils import crop, dedent, is_iter, m_len, make_iter, mod_import, pad, to_str
|
||||
|
||||
# read from protocol NAWS later?
|
||||
_MAX_TEXT_WIDTH = settings.CLIENT_DEFAULT_WIDTH
|
||||
@ -1179,6 +1169,7 @@ class EvMenu:
|
||||
for icol in range(ncols):
|
||||
start = icol * split
|
||||
end = min(start + split, max_end)
|
||||
print(f"col {icol}:", table[start:end])
|
||||
cols_list.append(EvColumn(*table[start:end]))
|
||||
|
||||
return str(EvTable(table=cols_list, border="none"))
|
||||
|
||||
@ -118,7 +118,6 @@ from copy import copy, deepcopy
|
||||
from textwrap import TextWrapper
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from evennia.utils.ansi import ANSIString
|
||||
from evennia.utils.utils import display_len as d_len
|
||||
from evennia.utils.utils import is_iter, justify
|
||||
|
||||
@ -34,13 +34,12 @@ from django.core.validators import validate_email as django_validate_email
|
||||
from django.utils import timezone
|
||||
from django.utils.html import strip_tags
|
||||
from django.utils.translation import gettext as _
|
||||
from evennia.utils import logger
|
||||
from simpleeval import simple_eval
|
||||
from twisted.internet import reactor, threads
|
||||
from twisted.internet.defer import returnValue # noqa - used as import target
|
||||
from twisted.internet.task import deferLater
|
||||
|
||||
from evennia.utils import logger
|
||||
|
||||
_MULTIMATCH_TEMPLATE = settings.SEARCH_MULTIMATCH_TEMPLATE
|
||||
_EVENNIA_DIR = settings.EVENNIA_DIR
|
||||
_GAME_DIR = settings.GAME_DIR
|
||||
@ -288,8 +287,8 @@ def justify(text, width=None, align="l", indent=0, fillchar=" "):
|
||||
# absolute mode - just crop or fill to width
|
||||
abs_lines = []
|
||||
for line in text.split("\n"):
|
||||
nlen = len(line)
|
||||
if len(line) < width:
|
||||
nlen = m_len(line)
|
||||
if m_len(line) < width:
|
||||
line += sp * (width - nlen)
|
||||
else:
|
||||
line = crop(line, width=width, suffix="")
|
||||
@ -304,7 +303,7 @@ def justify(text, width=None, align="l", indent=0, fillchar=" "):
|
||||
for ip, paragraph in enumerate(paragraphs):
|
||||
if ip > 0:
|
||||
words.append(("\n", 0))
|
||||
words.extend((word, len(word)) for word in paragraph.split())
|
||||
words.extend((word, m_len(word)) for word in paragraph.split())
|
||||
|
||||
if not words:
|
||||
# Just whitespace!
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user