def test_open_closed_strings(): text_widget = tkinter.Text() text_widget.insert("insert", TEST_STR1) font = tk_font.nametofont("TkDefaultFont") colorer = SyntaxColorer(text_widget, font, font) colorer._update_coloring() open_ranges = text_widget.tag_ranges("STRING_OPEN") closed_ranges = text_widget.tag_ranges( "STRING_CLOSED") + text_widget.tag_ranges("STRING_CLOSED3") expected_open_ranges = { ('3.11', '4.0'), } expected_closed_ranges = { ('2.11', '2.19'), ('4.11', '6.12'), } open_ranges_set = set([(str(open_ranges[i]), str(open_ranges[i + 1])) for i in range(0, len(open_ranges), 2)]) closed_ranges_set = set([(str(closed_ranges[i]), str(closed_ranges[i + 1])) for i in range(0, len(closed_ranges), 2)]) assert open_ranges_set == expected_open_ranges assert closed_ranges_set == expected_closed_ranges print("test passed")
def set_colorer(self): # TODO: some problem when doing fast rewind return self.colorer = SyntaxColorer(self.code_view.text, get_workbench().get_font("EditorFont"), get_workbench().get_font("BoldEditorFont"))
def test_open_closed_strings(): text_widget = tkinter.Text() text_widget.insert("insert", TEST_STR1) colorer = SyntaxColorer(text_widget) colorer._update_coloring() open_ranges = text_widget.tag_ranges("open_string") closed_ranges = text_widget.tag_ranges("string") + text_widget.tag_ranges( "string3") expected_open_ranges = {("3.11", "4.0")} expected_closed_ranges = {("2.11", "2.19"), ("4.11", "6.12")} open_ranges_set = {(str(open_ranges[i]), str(open_ranges[i + 1])) for i in range(0, len(open_ranges), 2)} closed_ranges_set = {(str(closed_ranges[i]), str(closed_ranges[i + 1])) for i in range(0, len(closed_ranges), 2)} assert open_ranges_set == expected_open_ranges assert closed_ranges_set == expected_closed_ranges print("test passed")
def set_colorer(self): self.colorer = SyntaxColorer(self.code_view.text)