How to use the curtsies.formatstring.width_aware_slice function in curtsies

To help you get started, we’ve selected a few curtsies examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bpython / curtsies / tests / test_fmtstr.py View on Github external
def test_combining_char_aware_slice(self):
        self.assertEqual(width_aware_slice('abc', 0, 2), 'ab')
        self.assertEqual(width_aware_slice('abc', 1, 3), 'bc')
        self.assertEqual(width_aware_slice('abc', 0, 3), 'abc')
        self.assertEqual(width_aware_slice('ab\u0300c', 0, 3), 'ab\u0300c')
        self.assertEqual(width_aware_slice('ab\u0300c', 0, 2), 'ab\u0300')
        self.assertEqual(width_aware_slice('ab\u0300c', 1, 3), 'b\u0300c')
        self.assertEqual(width_aware_slice('ab\u0300\u0300c', 1, 3), 'b\u0300\u0300c')
        self.assertEqual(width_aware_slice('ab\u0300\u0300c', 0, 2), 'ab\u0300\u0300')
        self.assertEqual(width_aware_slice('ab\u0300\u0300c', 2, 3), 'c')
github bpython / curtsies / tests / test_fmtstr.py View on Github external
def test_combining_char_aware_slice(self):
        self.assertEqual(width_aware_slice('abc', 0, 2), 'ab')
        self.assertEqual(width_aware_slice('abc', 1, 3), 'bc')
        self.assertEqual(width_aware_slice('abc', 0, 3), 'abc')
        self.assertEqual(width_aware_slice('ab\u0300c', 0, 3), 'ab\u0300c')
        self.assertEqual(width_aware_slice('ab\u0300c', 0, 2), 'ab\u0300')
        self.assertEqual(width_aware_slice('ab\u0300c', 1, 3), 'b\u0300c')
        self.assertEqual(width_aware_slice('ab\u0300\u0300c', 1, 3), 'b\u0300\u0300c')
        self.assertEqual(width_aware_slice('ab\u0300\u0300c', 0, 2), 'ab\u0300\u0300')
        self.assertEqual(width_aware_slice('ab\u0300\u0300c', 2, 3), 'c')
github bpython / curtsies / tests / test_fmtstr.py View on Github external
def test_char_width_aware_slice(self):
        self.assertEqual(width_aware_slice('abc', 1, 2), 'b')
        self.assertEqual(width_aware_slice('aEbc', 0, 4), 'aEb')
        self.assertEqual(width_aware_slice('aEbc', 1, 4), 'Eb')
        self.assertEqual(width_aware_slice('aEbc', 2, 4), ' b')
        self.assertEqual(width_aware_slice('aEbc', 0, 2), 'a ')
github bpython / curtsies / tests / test_fmtstr.py View on Github external
def test_combining_char_aware_slice(self):
        self.assertEqual(width_aware_slice('abc', 0, 2), 'ab')
        self.assertEqual(width_aware_slice('abc', 1, 3), 'bc')
        self.assertEqual(width_aware_slice('abc', 0, 3), 'abc')
        self.assertEqual(width_aware_slice('ab\u0300c', 0, 3), 'ab\u0300c')
        self.assertEqual(width_aware_slice('ab\u0300c', 0, 2), 'ab\u0300')
        self.assertEqual(width_aware_slice('ab\u0300c', 1, 3), 'b\u0300c')
        self.assertEqual(width_aware_slice('ab\u0300\u0300c', 1, 3), 'b\u0300\u0300c')
        self.assertEqual(width_aware_slice('ab\u0300\u0300c', 0, 2), 'ab\u0300\u0300')
        self.assertEqual(width_aware_slice('ab\u0300\u0300c', 2, 3), 'c')
github bpython / curtsies / tests / test_fmtstr.py View on Github external
def test_char_width_aware_slice(self):
        self.assertEqual(width_aware_slice('abc', 1, 2), 'b')
        self.assertEqual(width_aware_slice('aEbc', 0, 4), 'aEb')
        self.assertEqual(width_aware_slice('aEbc', 1, 4), 'Eb')
        self.assertEqual(width_aware_slice('aEbc', 2, 4), ' b')
        self.assertEqual(width_aware_slice('aEbc', 0, 2), 'a ')
github bpython / curtsies / tests / test_fmtstr.py View on Github external
def test_combining_char_aware_slice(self):
        self.assertEqual(width_aware_slice('abc', 0, 2), 'ab')
        self.assertEqual(width_aware_slice('abc', 1, 3), 'bc')
        self.assertEqual(width_aware_slice('abc', 0, 3), 'abc')
        self.assertEqual(width_aware_slice('ab\u0300c', 0, 3), 'ab\u0300c')
        self.assertEqual(width_aware_slice('ab\u0300c', 0, 2), 'ab\u0300')
        self.assertEqual(width_aware_slice('ab\u0300c', 1, 3), 'b\u0300c')
        self.assertEqual(width_aware_slice('ab\u0300\u0300c', 1, 3), 'b\u0300\u0300c')
        self.assertEqual(width_aware_slice('ab\u0300\u0300c', 0, 2), 'ab\u0300\u0300')
        self.assertEqual(width_aware_slice('ab\u0300\u0300c', 2, 3), 'c')
github bpython / curtsies / tests / test_fmtstr.py View on Github external
def test_combining_char_aware_slice(self):
        self.assertEqual(width_aware_slice('abc', 0, 2), 'ab')
        self.assertEqual(width_aware_slice('abc', 1, 3), 'bc')
        self.assertEqual(width_aware_slice('abc', 0, 3), 'abc')
        self.assertEqual(width_aware_slice('ab\u0300c', 0, 3), 'ab\u0300c')
        self.assertEqual(width_aware_slice('ab\u0300c', 0, 2), 'ab\u0300')
        self.assertEqual(width_aware_slice('ab\u0300c', 1, 3), 'b\u0300c')
        self.assertEqual(width_aware_slice('ab\u0300\u0300c', 1, 3), 'b\u0300\u0300c')
        self.assertEqual(width_aware_slice('ab\u0300\u0300c', 0, 2), 'ab\u0300\u0300')
        self.assertEqual(width_aware_slice('ab\u0300\u0300c', 2, 3), 'c')
github bpython / curtsies / tests / test_fmtstr.py View on Github external
def test_combining_char_aware_slice(self):
        self.assertEqual(width_aware_slice('abc', 0, 2), 'ab')
        self.assertEqual(width_aware_slice('abc', 1, 3), 'bc')
        self.assertEqual(width_aware_slice('abc', 0, 3), 'abc')
        self.assertEqual(width_aware_slice('ab\u0300c', 0, 3), 'ab\u0300c')
        self.assertEqual(width_aware_slice('ab\u0300c', 0, 2), 'ab\u0300')
        self.assertEqual(width_aware_slice('ab\u0300c', 1, 3), 'b\u0300c')
        self.assertEqual(width_aware_slice('ab\u0300\u0300c', 1, 3), 'b\u0300\u0300c')
        self.assertEqual(width_aware_slice('ab\u0300\u0300c', 0, 2), 'ab\u0300\u0300')
        self.assertEqual(width_aware_slice('ab\u0300\u0300c', 2, 3), 'c')
github bpython / curtsies / tests / test_fmtstr.py View on Github external
def test_char_width_aware_slice(self):
        self.assertEqual(width_aware_slice('abc', 1, 2), 'b')
        self.assertEqual(width_aware_slice('aEbc', 0, 4), 'aEb')
        self.assertEqual(width_aware_slice('aEbc', 1, 4), 'Eb')
        self.assertEqual(width_aware_slice('aEbc', 2, 4), ' b')
        self.assertEqual(width_aware_slice('aEbc', 0, 2), 'a ')
github bpython / curtsies / tests / test_fmtstr.py View on Github external
def test_combining_char_aware_slice(self):
        self.assertEqual(width_aware_slice('abc', 0, 2), 'ab')
        self.assertEqual(width_aware_slice('abc', 1, 3), 'bc')
        self.assertEqual(width_aware_slice('abc', 0, 3), 'abc')
        self.assertEqual(width_aware_slice('ab\u0300c', 0, 3), 'ab\u0300c')
        self.assertEqual(width_aware_slice('ab\u0300c', 0, 2), 'ab\u0300')
        self.assertEqual(width_aware_slice('ab\u0300c', 1, 3), 'b\u0300c')
        self.assertEqual(width_aware_slice('ab\u0300\u0300c', 1, 3), 'b\u0300\u0300c')
        self.assertEqual(width_aware_slice('ab\u0300\u0300c', 0, 2), 'ab\u0300\u0300')
        self.assertEqual(width_aware_slice('ab\u0300\u0300c', 2, 3), 'c')