Handle request to open file/line. If the selected or previous line in the output window contains a file name and line number, then open that file name in a new window and position on the line number. Otherwise, display an error messagebox.
(self, event=None)
| 128 | messagebox.showerror(*args, **kwargs) |
| 129 | |
| 130 | def goto_file_line(self, event=None): |
| 131 | """Handle request to open file/line. |
| 132 | |
| 133 | If the selected or previous line in the output window |
| 134 | contains a file name and line number, then open that file |
| 135 | name in a new window and position on the line number. |
| 136 | |
| 137 | Otherwise, display an error messagebox. |
| 138 | """ |
| 139 | line = self.text.get("insert linestart", "insert lineend") |
| 140 | result = file_line_helper(line) |
| 141 | if not result: |
| 142 | # Try the previous line. This is handy e.g. in tracebacks, |
| 143 | # where you tend to right-click on the displayed source line |
| 144 | line = self.text.get("insert -1line linestart", |
| 145 | "insert -1line lineend") |
| 146 | result = file_line_helper(line) |
| 147 | if not result: |
| 148 | self.showerror( |
| 149 | "No special line", |
| 150 | "The line you point at doesn't look like " |
| 151 | "a valid file name followed by a line number.", |
| 152 | parent=self.text) |
| 153 | return |
| 154 | filename, lineno = result |
| 155 | self.flist.gotofileline(filename, lineno) |
| 156 | |
| 157 | |
| 158 | # These classes are currently not used but might come in handy |