def get_tag(self, index=None): """find (X) tag.""" if index is None: index = self.active target = self.get_text(index) line = self.get_current_line(index) r = self.ctrls[index].getSelection() ret = None regindx = re.compile("^\(([^\)]*?)\)") if not regindx.search(line): start, end = tools.get_current_line(target, r.Min) match = regindx.match(target[start:end]) while not match and start > 0: start, end = tools.get_current_line(target, start -1) match = regindx.match(target[start:end]) if match: ret = match.group(1) return ret
def get_current_line(self, index=None, r=None): """get current line.""" if index is None: index = self.active edit = self.ctrls[index] if r is None: r = edit.getSelection() target = edit.getText() start, end = tools.get_current_line(target, r.Min) return target[start:end]
def get_tag(self, index=None): """find (X) tag.""" if index is None: index = self.active target = self.get_text(index) line = self.get_current_line(index) r = self.ctrls[index].getSelection() ret = None regindx = re.compile("^\(([^\)]*?)\)") if not regindx.search(line): start, end = tools.get_current_line(target, r.Min) match = regindx.match(target[start:end]) while not match and start > 0: start, end = tools.get_current_line(target, start - 1) match = regindx.match(target[start:end]) if match: ret = match.group(1) return ret
def select_current_line(self, index=None): if index is None: index = self.active edit = self.ctrls[index] r = edit.getSelection() target = edit.getText() start, end = tools.get_current_line(target, r.Min) if target[start:end].strip(): r.Min = start r.Max = end edit.setSelection(r)