diff options
author | Jonathan Slenders <jonathan@slenders.be> | 2018-05-22 22:27:16 +0200 |
---|---|---|
committer | Jonathan Slenders <jonathan@slenders.be> | 2018-05-22 22:27:16 +0200 |
commit | 2d3beb9d8918358d85ee95642098c7bf47e68754 (patch) | |
tree | 72f4f82031ed0e5a08647710c0b48089019acd3d | |
parent | bd3524a37f85aed9c26e6acf3a6a58db2d32c01a (diff) |
Take char1/2 instead of get_char1/2 as input in TabsProcessor.
-rw-r--r-- | prompt_toolkit/layout/processors.py | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/prompt_toolkit/layout/processors.py b/prompt_toolkit/layout/processors.py index c01f7418..05b982fb 100644 --- a/prompt_toolkit/layout/processors.py +++ b/prompt_toolkit/layout/processors.py @@ -7,7 +7,7 @@ fragment types. """ from __future__ import unicode_literals from abc import ABCMeta, abstractmethod -from six import with_metaclass +from six import with_metaclass, text_type from six.moves import range from prompt_toolkit.application.current import get_app @@ -17,7 +17,7 @@ from prompt_toolkit.filters import to_filter, vi_insert_multiple_mode from prompt_toolkit.formatted_text import to_formatted_text from prompt_toolkit.formatted_text.utils import fragment_list_len, fragment_list_to_text from prompt_toolkit.search import SearchDirection -from prompt_toolkit.utils import to_int +from prompt_toolkit.utils import to_int, to_str from .utils import explode_text_fragments @@ -537,18 +537,17 @@ class TabsProcessor(Processor): :param tabstop: Horizontal space taken by a tab. (`int` or callable that returns an `int`). - :param get_char1: Callable that returns a character (text of length one). - This one is used for the first space taken by the tab. - :param get_char2: Like `get_char1`, but for the rest of the space. + :param char1: Character or callable that returns a character (text of + length one). This one is used for the first space taken by the tab. + :param char2: Like `char1`, but for the rest of the space. """ - def __init__(self, tabstop=4, get_char1=None, get_char2=None, - style='class:tab'): + def __init__(self, tabstop=4, char1='|', char2='\u2508', style='class:tab'): assert isinstance(tabstop, int) or callable(tabstop) - assert get_char1 is None or callable(get_char1) - assert get_char2 is None or callable(get_char2) + assert callable(char1) or isinstance(char1, text_type) + assert callable(char2) or isinstance(char2, text_type) - self.get_char1 = get_char1 or get_char2 or (lambda: '|') - self.get_char2 = get_char2 or get_char1 or (lambda: '\u2508') + self.char1 = char1 + self.char2 = char2 self.tabstop = tabstop self.style = style @@ -557,8 +556,8 @@ class TabsProcessor(Processor): style = self.style # Create separator for tabs. - separator1 = self.get_char1() - separator2 = self.get_char2() + separator1 = to_str(self.char1) + separator2 = to_str(self.char2) # Transform fragments. fragments = explode_text_fragments(ti.fragments) |