Пример #1
0
def _(item, target):
    cursor = target.end_cursor
    target.clear_cursor = None
    cursor.insertText('\n')
    target.text_register.append(cursor.position(), item.username, style='in-prompt')

    if item.code and is_comment(item.code):
        in_prompt = _make_in_prompt(target.chat_prompt, item.execution_count)
        target.insert_html(in_prompt, cursor)
        if len(item.code.split('\n')) != 1:
            cursor.insertText('\n')
        target.insert_ansi_text(de_comment(item.code), item.ansi_codes and target.use_ansi, cursor)
        target.ansi_processor.reset_sgr()
    else:
        before_prompt = cursor.position()
        in_prompt = _make_in_prompt(target.in_prompt, item.execution_count)
        target.insert_html(in_prompt, cursor)
        after_prompt = cursor.position()
        target.highlighter.enable(after_prompt-before_prompt)
        if item.code:
            target.insert_ansi_text(item.code, item.ansi_codes and target.use_ansi, cursor)
            target.ansi_processor.reset_sgr()
        target.highlighter.disable()
    if item.code and item.code[-1] != '\n':
        cursor.insertText('\n')
Пример #2
0
 def test_de5(self):
     res = de_comment(self.c)
     self.assertEqual(res, 'a\nb\nc')
Пример #3
0
 def test_de4(self):
     res = de_comment(self.b)
     self.assertEqual(res, 'a#b')
Пример #4
0
 def test_de3(self):
     res = de_comment(self.a)
     self.assertEqual(res, 'a\nb')
Пример #5
0
 def test_de2(self):
     res = de_comment(self.u)
     self.assertEqual(res, 'hi')
Пример #6
0
 def test_de0(self):
     res = de_comment(self.s)
     self.assertEqual(res, '   hello')