def test_04(): "copy cells" model = TextModel('') tmp = TextModel(u'for a in range(5):\n print a') cell = Cell([tmp.texel], [Characters(u'')]) model.insert(len(model), mk_textmodel(cell)) tmp = model.copy(0, len(model)) model.insert(0, tmp)
i2 = model.position2index(erow-1, ecol) if token.LPAR <= toktype and toktype <= token.OP: toktype = token.OP elif toktype == token.NAME and keyword.iskeyword(toktext): toktype = _KEYWORD try: color = _colors[toktype] except: return model.set_properties(i1, i2, color=color) text = rawtext.decode(coding) model = TextModel(text) tokenize.tokenize(instream, tokeneater) return model.copy(0, len(model)-1) def ansi_print(text): def ansi_text(texel): if texel.is_group: return ''.join([ansi_text(child) for child in texel.childs]) if texel.style: return texel.style.get('color', '')+texel.text+RESET return texel.text print ansi_text(text.texel)