def __init__(self, jid=''): Tab.__init__(self) self.name = jid self.text_win = None self._text_buffer = TextBuffer() self.chatstate = None # can be "active", "composing", "paused", "gone", "inactive" # We keep a reference of the event that will set our chatstate to "paused", so that # we can delete it or change it if we need to self.timed_event_paused = None # Keeps the last sent message to complete it easily in completion_correct, and to replace it. self.last_sent_message = None self.key_func['M-v'] = self.move_separator self.key_func['M-h'] = self.scroll_separator self.key_func['M-/'] = self.last_words_completion self.key_func['^M'] = self.on_enter self.register_command('say', self.command_say, usage='<message>', shortdesc='Send the message.') self.register_command('xhtml', self.command_xhtml, usage='<custom xhtml>', shortdesc='Send custom XHTML.') self.register_command('clear', self.command_clear, shortdesc='Clear the current buffer.') self.register_command( 'correct', self.command_correct, desc='Fix the last message with whatever you want.', shortdesc='Correct the last message.', completion=self.completion_correct) self.chat_state = None self.update_commands() self.update_keys() # Get the logs log_nb = config.get('load_log') logs = self.load_logs(log_nb) if logs: for message in logs: self._text_buffer.add_message(**message)
def setUp(self): self.buf = TextBuffer('hello')
def test_join_other_buffer(self): other_buf = TextBuffer(' world!') self.buf.join(other_buf) self.assertEqual(self.buf.contents.head.value, 'h') self.assertEqual(self.buf.contents.tail.value, '!') self.assertEqual(len(self.buf.contents), 12)