def subcode_recolorize_main(self): # monkey patch update to avoid flickering of subcode markers _update = self.update try: self.update = lambda: None ColorDelegator.recolorize_main(self) finally: self.update = _update # must restore update function item = self.tag_nextrange("TODO", '1.0') if item: self.update() return # colorizer didn't finish labeling MAYBESUBCODE, abort # colorize the MAYBESUBCODE as SUBCODE if it is, else comment next = "1.0" while True: item = self.tag_nextrange("MAYBESUBCODE", next) if not item: break # remove MAYBESUBCODE and replace with COMMENT head, tail = item self.tag_remove("MAYBESUBCODE", head, tail) self.tag_add("COMMENT", head, tail) chars = self.get(head, tail) #print 'consider', repr(chars) # tag multiline comments then subcode markers m = self.subcodeprog.search(chars) while m: value = m.groupdict()['SUBCODE'] if value: a, b = m.span("SUBCODE") start = head + "+%dc" % a stop = head + "+%dc" % b if not chars[:a].strip( ): # fix subtle bug for ## ## lines self.tag_remove("COMMENT", start, stop) self.tag_add("SUBCODE", start, stop) m = self.subcodeprog.search(chars, m.end()) next = tail self.update()
def recolorize_main(self): if not self.subcode_enable: return ColorDelegator.recolorize_main(self) else: return self.subcode_recolorize_main()
def recolorize_main(self): self.tag_remove('TODO', '1.0', 'iomark') self.tag_add('SYNC', '1.0', 'iomark') ColorDelegator.recolorize_main(self)