Save breakpoints when file is saved
(self)
| 222 | pass |
| 223 | |
| 224 | def store_file_breaks(self): |
| 225 | "Save breakpoints when file is saved" |
| 226 | # XXX 13 Dec 2002 KBK Currently the file must be saved before it can |
| 227 | # be run. The breaks are saved at that time. If we introduce |
| 228 | # a temporary file save feature the save breaks functionality |
| 229 | # needs to be re-verified, since the breaks at the time the |
| 230 | # temp file is created may differ from the breaks at the last |
| 231 | # permanent save of the file. Currently, a break introduced |
| 232 | # after a save will be effective, but not persistent. |
| 233 | # This is necessary to keep the saved breaks synched with the |
| 234 | # saved file. |
| 235 | # |
| 236 | # Breakpoints are set as tagged ranges in the text. |
| 237 | # Since a modified file has to be saved before it is |
| 238 | # run, and since self.breakpoints (from which the subprocess |
| 239 | # debugger is loaded) is updated during the save, the visible |
| 240 | # breaks stay synched with the subprocess even if one of these |
| 241 | # unexpected breakpoint deletions occurs. |
| 242 | breaks = self.breakpoints |
| 243 | filename = self.io.filename |
| 244 | try: |
| 245 | with open(self.breakpointPath) as fp: |
| 246 | lines = fp.readlines() |
| 247 | except OSError: |
| 248 | lines = [] |
| 249 | try: |
| 250 | with open(self.breakpointPath, "w") as new_file: |
| 251 | for line in lines: |
| 252 | if not line.startswith(filename + '='): |
| 253 | new_file.write(line) |
| 254 | self.update_breakpoints() |
| 255 | breaks = self.breakpoints |
| 256 | if breaks: |
| 257 | new_file.write(filename + '=' + str(breaks) + '\n') |
| 258 | except OSError as err: |
| 259 | if not getattr(self.root, "breakpoint_error_displayed", False): |
| 260 | self.root.breakpoint_error_displayed = True |
| 261 | messagebox.showerror(title='IDLE Error', |
| 262 | message='Unable to update breakpoint list:\n%s' |
| 263 | % str(err), |
| 264 | parent=self.text) |
| 265 | |
| 266 | def restore_file_breaks(self): |
| 267 | self.text.update() # this enables setting "BREAK" tags to be visible |
no test coverage detected