A new action copy_ansi_to_clipboard to copy the current selection with ANSI formatting codes

Fixes #4665
This commit is contained in:
Kovid Goyal
2022-02-10 12:20:19 +05:30
parent ce8b0cf748
commit 1170cf474f
6 changed files with 124 additions and 20 deletions

View File

@@ -530,6 +530,28 @@ class TestScreen(BaseTest):
s.scroll(2, True)
self.ae(s.text_for_selection(), expected)
s.reset()
s.draw('ab cd')
s.start_selection(0, 0)
s.update_selection(1, 3)
self.ae(s.text_for_selection(), ('ab ', 'cd'))
self.ae(s.text_for_selection(False, True), ('ab', 'cd'))
s.reset()
s.draw('ab cd')
s.start_selection(0, 0)
s.update_selection(3, 4)
self.ae(s.text_for_selection(), ('ab ', ' ', 'cd'))
self.ae(s.text_for_selection(False, True), ('ab', '\n', 'cd'))
s.reset()
s.draw('a')
s.select_graphic_rendition(32)
s.draw('b')
s.select_graphic_rendition(39)
s.draw('c xy')
s.start_selection(0, 0)
s.update_selection(1, 3)
self.ae(s.text_for_selection(), ('abc ', 'xy'))
self.ae(s.text_for_selection(True), ('a\x1b[32mb\x1b[39mc ', 'xy', '\x1b[m'))
self.ae(s.text_for_selection(True, True), ('a\x1b[32mb\x1b[39mc', 'xy', '\x1b[m'))
def test_soft_hyphen(self):
s = self.create_screen()