def OnAddComment(self, cmd, code): addspecific= cmd==ID_ADDPYCHECKNO2 _=list(self.GetSel()) _.sort() start,end=_ line_start, line_end = self.LineFromChar(start), self.LineFromChar(end) first=1 for i in range(line_start,line_end+1): line = self.GetLine(i) m = regexGrep.match(line) if m: if first: first=0 cmnt=dialog.GetSimpleInput( "Add to %s lines" % (line_end-line_start+1), addspecific and " #$pycheck_no=%(errtext)s" or " #$pycheck_no" ) if not cmnt: return 0 ##import pywin.debugger;pywin.debugger.set_trace() fname = m.group(1) line = int(m.group(2)) view = scriptutils.JumpToDocument(fname,line) pos=view.LineIndex(line)-1 if view.GetTextRange(pos-1,pos) in ('\r','\n'): pos -= 1 view.SetSel(pos, pos) errtext=m.group(3) if start!=end and line_start==line_end: errtext=self.GetSelText() errtext=repr(re.escape(errtext).replace('\ ',' ')) view.ReplaceSel( addspecific and cmnt % locals() or cmnt ) return 0
def OnLDblClick(self,params): line = self.GetLine() regexGrepResult = regexGrep.match(line) if regexGrepResult: fname = regexGrepResult.group(1) line = int(regexGrepResult.group(2)) scriptutils.JumpToDocument(fname, line) return 0 # dont pass on return 1 # pass it on by default.
return 1 # still was an error message. else: lineNoString = matchResult.group(2) # Attempt to locate the file (in case it is a relative spec) fileNameSpec = fileName fileName = scriptutils.LocatePythonFile(fileName) if fileName is None: # Dont force update, so it replaces the idle prompt. win32ui.SetStatusText( "Cant locate the file '%s'" % (fileNameSpec), 0) return 1 win32ui.SetStatusText( "Jumping to line " + lineNoString + " of file " + fileName, 1) if not scriptutils.JumpToDocument(fileName, string.atoi(lineNoString)): win32ui.SetStatusText("Could not open %s" % fileName) return 1 # still was an error message. return 1 return 0 # not an error line def write(self, msg): return self.template.write(msg) def writelines(self, lines): for line in lines: self.write(line) def flush(self): self.template.flush()
return 1 # still was an error message. else: lineNoString = matchResult.group(2) # Attempt to locate the file (in case it is a relative spec) fileNameSpec = fileName fileName = scriptutils.LocatePythonFile(fileName) if fileName is None: # Dont force update, so it replaces the idle prompt. win32ui.SetStatusText( "Cant locate the file '%s'" % (fileNameSpec), 0) return 1 win32ui.SetStatusText( "Jumping to line " + lineNoString + " of file " + fileName, 1) if not scriptutils.JumpToDocument(fileName, int(lineNoString)): win32ui.SetStatusText("Could not open %s" % fileName) return 1 # still was an error message. return 1 return 0 # not an error line def write(self, msg): return self.template.write(msg) def writelines(self, lines): for line in lines: self.write(line) def flush(self): self.template.flush()