QScintilla/Editor.py

branch
maintenance
changeset 6206
a02b03b7bfec
parent 6166
bace7fb85a01
parent 6188
5a6ae3be31e6
child 6273
0daf79d65080
equal deleted inserted replaced
6205:ad8ed15f90e5 6206:a02b03b7bfec
2172 Public method to clear a breakpoint. 2172 Public method to clear a breakpoint.
2173 2173
2174 Note: This doesn't clear the breakpoint in the debugger, 2174 Note: This doesn't clear the breakpoint in the debugger,
2175 it just deletes it from the editor internal list of breakpoints. 2175 it just deletes it from the editor internal list of breakpoints.
2176 2176
2177 @param line linenumber of the breakpoint (integer) 2177 @param line line number of the breakpoint (integer)
2178 """ 2178 """
2179 if self.inLinesChanged: 2179 if self.inLinesChanged:
2180 return 2180 return
2181 2181
2182 for handle, (ln, _, _, _, _) in list(self.breaks.items()): 2182 for handle in self.breaks:
2183 if self.markerLine(handle) == line - 1: 2183 if self.markerLine(handle) == line - 1:
2184 break 2184 break
2185 else: 2185 else:
2186 # not found, simply ignore it 2186 # not found, simply ignore it
2187 return 2187 return
2216 Private method to toggle a breakpoint. 2216 Private method to toggle a breakpoint.
2217 2217
2218 @param line line number of the breakpoint (integer) 2218 @param line line number of the breakpoint (integer)
2219 @param temporary flag indicating a temporary breakpoint (boolean) 2219 @param temporary flag indicating a temporary breakpoint (boolean)
2220 """ 2220 """
2221 for handle, (ln, _, _, _, _) in list(self.breaks.items()): 2221 for handle in self.breaks:
2222 if self.markerLine(handle) == line - 1: 2222 if self.markerLine(handle) == line - 1:
2223 # delete breakpoint or toggle it to the next state 2223 # delete breakpoint or toggle it to the next state
2224 index = self.breakpointModel.getBreakPointIndex( 2224 index = self.breakpointModel.getBreakPointIndex(
2225 self.fileName, line) 2225 self.fileName, line)
2226 if Preferences.getDebugger("ThreeStateBreakPoints") and \ 2226 if Preferences.getDebugger("ThreeStateBreakPoints") and \
2251 """ 2251 """
2252 Private method to toggle a breakpoints enabled status. 2252 Private method to toggle a breakpoints enabled status.
2253 2253
2254 @param line line number of the breakpoint (integer) 2254 @param line line number of the breakpoint (integer)
2255 """ 2255 """
2256 for handle, (ln, cond, temp, enabled, ignorecount) in \ 2256 for handle in self.breaks:
2257 self.breaks.items():
2258 if self.markerLine(handle) == line - 1: 2257 if self.markerLine(handle) == line - 1:
2258 index = self.breakpointModel.getBreakPointIndex(
2259 self.fileName, line)
2260 self.breakpointModel.setBreakPointEnabledByIndex(
2261 index, not self.breaks[handle][3])
2259 break 2262 break
2260 else:
2261 # no breakpoint found on that line
2262 return
2263
2264 index = self.breakpointModel.getBreakPointIndex(self.fileName, line)
2265 self.breakpointModel.setBreakPointEnabledByIndex(index, not enabled)
2266 2263
2267 def curLineHasBreakpoint(self): 2264 def curLineHasBreakpoint(self):
2268 """ 2265 """
2269 Public method to check for the presence of a breakpoint at the current 2266 Public method to check for the presence of a breakpoint at the current
2270 line. 2267 line.
2338 """ 2335 """
2339 if line is not None: 2336 if line is not None:
2340 self.line = line - 1 2337 self.line = line - 1
2341 if self.line < 0: 2338 if self.line < 0:
2342 self.line, index = self.getCursorPosition() 2339 self.line, index = self.getCursorPosition()
2343 found = False 2340
2344 for handle, (ln, cond, temp, enabled, ignorecount) in \ 2341 for handle in self.breaks:
2345 self.breaks.items():
2346 if self.markerLine(handle) == self.line: 2342 if self.markerLine(handle) == self.line:
2347 found = True 2343 ln, cond, temp, enabled, ignorecount = self.breaks[handle]
2348 break 2344 index = self.breakpointModel.getBreakPointIndex(self.fileName,
2349 2345 ln)
2350 if found: 2346 if not index.isValid():
2351 index = self.breakpointModel.getBreakPointIndex(self.fileName, ln) 2347 return
2352 if not index.isValid(): 2348
2353 return 2349 from Debugger.EditBreakpointDialog import EditBreakpointDialog
2354 2350 dlg = EditBreakpointDialog(
2355 from Debugger.EditBreakpointDialog import EditBreakpointDialog 2351 (self.fileName, ln),
2356 dlg = EditBreakpointDialog( 2352 (cond, temp, enabled, ignorecount),
2357 (self.fileName, ln), 2353 self.condHistory, self, modal=True)
2358 (cond, temp, enabled, ignorecount), 2354 if dlg.exec_() == QDialog.Accepted:
2359 self.condHistory, self, modal=True) 2355 cond, temp, enabled, ignorecount = dlg.getData()
2360 if dlg.exec_() == QDialog.Accepted: 2356 self.breakpointModel.setBreakPointByIndex(
2361 cond, temp, enabled, ignorecount = dlg.getData() 2357 index, self.fileName, ln,
2362 self.breakpointModel.setBreakPointByIndex( 2358 (cond, temp, enabled, ignorecount))
2363 index, self.fileName, ln,
2364 (cond, temp, enabled, ignorecount))
2365 2359
2366 self.line = -1 2360 self.line = -1
2367 2361
2368 def menuNextBreakpoint(self): 2362 def menuNextBreakpoint(self):
2369 """ 2363 """
2411 Private slot to clear all breakpoints. 2405 Private slot to clear all breakpoints.
2412 2406
2413 @param fileName name of the file (string) 2407 @param fileName name of the file (string)
2414 """ 2408 """
2415 idxList = [] 2409 idxList = []
2416 for handle, (ln, _, _, _, _) in list(self.breaks.items()): 2410 for (ln, _, _, _, _) in self.breaks.values():
2417 index = self.breakpointModel.getBreakPointIndex(fileName, ln) 2411 index = self.breakpointModel.getBreakPointIndex(fileName, ln)
2418 if index.isValid(): 2412 if index.isValid():
2419 idxList.append(index) 2413 idxList.append(index)
2420 if idxList: 2414 if idxList:
2421 self.breakpointModel.deleteBreakPoints(idxList) 2415 self.breakpointModel.deleteBreakPoints(idxList)
2769 # step 1: mark saved changes 2763 # step 1: mark saved changes
2770 oldL = self.__oldText.splitlines() 2764 oldL = self.__oldText.splitlines()
2771 newL = self.__lastSavedText.splitlines() 2765 newL = self.__lastSavedText.splitlines()
2772 matcher = difflib.SequenceMatcher(None, oldL, newL) 2766 matcher = difflib.SequenceMatcher(None, oldL, newL)
2773 2767
2774 for token, i1, i2, j1, j2 in matcher.get_opcodes(): 2768 for token, _, _, j1, j2 in matcher.get_opcodes():
2775 if token in ["insert", "replace"]: 2769 if token in ["insert", "replace"]:
2776 for lineNo in range(j1, j2): 2770 for lineNo in range(j1, j2):
2777 self.markerAdd(lineNo, self.__changeMarkerSaved) 2771 self.markerAdd(lineNo, self.__changeMarkerSaved)
2778 self.__hasChangeMarkers = True 2772 self.__hasChangeMarkers = True
2779 2773
2780 # step 2: mark unsaved changes 2774 # step 2: mark unsaved changes
2781 oldL = self.__lastSavedText.splitlines() 2775 oldL = self.__lastSavedText.splitlines()
2782 newL = self.text().splitlines() 2776 newL = self.text().splitlines()
2783 matcher = difflib.SequenceMatcher(None, oldL, newL) 2777 matcher = difflib.SequenceMatcher(None, oldL, newL)
2784 2778
2785 for token, i1, i2, j1, j2 in matcher.get_opcodes(): 2779 for token, _, _, j1, j2 in matcher.get_opcodes():
2786 if token in ["insert", "replace"]: 2780 if token in ["insert", "replace"]:
2787 for lineNo in range(j1, j2): 2781 for lineNo in range(j1, j2):
2788 self.markerAdd(lineNo, self.__changeMarkerUnsaved) 2782 self.markerAdd(lineNo, self.__changeMarkerUnsaved)
2789 self.__hasChangeMarkers = True 2783 self.__hasChangeMarkers = True
2790 2784
2802 # mark saved changes 2796 # mark saved changes
2803 oldL = self.__oldText.splitlines() 2797 oldL = self.__oldText.splitlines()
2804 newL = self.__lastSavedText.splitlines() 2798 newL = self.__lastSavedText.splitlines()
2805 matcher = difflib.SequenceMatcher(None, oldL, newL) 2799 matcher = difflib.SequenceMatcher(None, oldL, newL)
2806 2800
2807 for token, i1, i2, j1, j2 in matcher.get_opcodes(): 2801 for token, _, _, j1, j2 in matcher.get_opcodes():
2808 if token in ["insert", "replace"]: 2802 if token in ["insert", "replace"]:
2809 for lineNo in range(j1, j2): 2803 for lineNo in range(j1, j2):
2810 self.markerAdd(lineNo, self.__changeMarkerSaved) 2804 self.markerAdd(lineNo, self.__changeMarkerSaved)
2811 self.__hasChangeMarkers = True 2805 self.__hasChangeMarkers = True
2812 2806
5696 if error: 5690 if error:
5697 _fn, lineno, col, code, msg = error 5691 _fn, lineno, col, code, msg = error
5698 self.toggleSyntaxError(lineno, col, True, msg) 5692 self.toggleSyntaxError(lineno, col, True, msg)
5699 5693
5700 warnings = problems.get('warnings', []) 5694 warnings = problems.get('warnings', [])
5701 for _fn, lineno, col, code, msg in warnings: 5695 for _fn, lineno, col, _code, msg in warnings:
5702 self.toggleWarning(lineno, col, True, msg) 5696 self.toggleWarning(lineno, col, True, msg)
5703 5697
5704 self.updateVerticalScrollBar() 5698 self.updateVerticalScrollBar()
5705 5699
5706 def __initOnlineSyntaxCheck(self): 5700 def __initOnlineSyntaxCheck(self):

eric ide

mercurial