Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Add API for truncating/fitting/handling long titles. #24

Open
Robpol86 opened this issue May 22, 2016 · 0 comments
Open

Add API for truncating/fitting/handling long titles. #24

Robpol86 opened this issue May 22, 2016 · 0 comments

Comments

@Robpol86
Copy link
Owner

Implement table.title_cb which accepts a function/lambda that handles titles that won't fit in the top border.

Function signature expected:

:param str title: The title to overlay on the top border.
:param int max_len: Maximum number of characters that can be shown right now.

:return: Processed title and its length.
:rtype: (str, int)

Must return title that will fit in the border (else the table will appear broken/misaligned/wrapped) as well as the length of the string.

Length values are for visible characters. When using CJK (Chinese/Japanese/Korean) characters some may be len() of 1 but take up 2 visible spaces in terminals. Hence API expects function to return title length in case the function truncates the string and the last character is one short of the maximum width available due to it being a CJK character.

e.g. terminal with 7 spaces available for the title and the title is "世界你好" That's 8 visible spaces so if the function truncates it to "世界你" API expects length of 6 to be returned.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant