(self, event)
| 1242 | return "break" |
| 1243 | |
| 1244 | def enter_callback(self, event): |
| 1245 | if self.executing and not self.reading: |
| 1246 | return # Let the default binding (insert '\n') take over |
| 1247 | # If some text is selected, recall the selection |
| 1248 | # (but only if this before the I/O mark) |
| 1249 | try: |
| 1250 | sel = self.text.get("sel.first", "sel.last") |
| 1251 | if sel: |
| 1252 | if self.text.compare("sel.last", "<=", "iomark"): |
| 1253 | self.recall(sel, event) |
| 1254 | return "break" |
| 1255 | except: |
| 1256 | pass |
| 1257 | # If we're strictly before the line containing iomark, recall |
| 1258 | # the current line, less a leading prompt, less leading or |
| 1259 | # trailing whitespace |
| 1260 | if self.text.compare("insert", "<", "iomark linestart"): |
| 1261 | # Check if there's a relevant stdin range -- if so, use it. |
| 1262 | # Note: "stdin" blocks may include several successive statements, |
| 1263 | # so look for "console" tags on the newline before each statement |
| 1264 | # (and possibly on prompts). |
| 1265 | prev = self.text.tag_prevrange("stdin", "insert") |
| 1266 | if ( |
| 1267 | prev and |
| 1268 | self.text.compare("insert", "<", prev[1]) and |
| 1269 | # The following is needed to handle empty statements. |
| 1270 | "console" not in self.text.tag_names("insert") |
| 1271 | ): |
| 1272 | prev_cons = self.text.tag_prevrange("console", "insert") |
| 1273 | if prev_cons and self.text.compare(prev_cons[1], ">=", prev[0]): |
| 1274 | prev = (prev_cons[1], prev[1]) |
| 1275 | next_cons = self.text.tag_nextrange("console", "insert") |
| 1276 | if next_cons and self.text.compare(next_cons[0], "<", prev[1]): |
| 1277 | prev = (prev[0], self.text.index(next_cons[0] + "+1c")) |
| 1278 | self.recall(self.text.get(prev[0], prev[1]), event) |
| 1279 | return "break" |
| 1280 | next = self.text.tag_nextrange("stdin", "insert") |
| 1281 | if next and self.text.compare("insert lineend", ">=", next[0]): |
| 1282 | next_cons = self.text.tag_nextrange("console", "insert lineend") |
| 1283 | if next_cons and self.text.compare(next_cons[0], "<", next[1]): |
| 1284 | next = (next[0], self.text.index(next_cons[0] + "+1c")) |
| 1285 | self.recall(self.text.get(next[0], next[1]), event) |
| 1286 | return "break" |
| 1287 | # No stdin mark -- just get the current line, less any prompt |
| 1288 | indices = self.text.tag_nextrange("console", "insert linestart") |
| 1289 | if indices and \ |
| 1290 | self.text.compare(indices[0], "<=", "insert linestart"): |
| 1291 | self.recall(self.text.get(indices[1], "insert lineend"), event) |
| 1292 | else: |
| 1293 | self.recall(self.text.get("insert linestart", "insert lineend"), event) |
| 1294 | return "break" |
| 1295 | # If we're between the beginning of the line and the iomark, i.e. |
| 1296 | # in the prompt area, move to the end of the prompt |
| 1297 | if self.text.compare("insert", "<", "iomark"): |
| 1298 | self.text.mark_set("insert", "iomark") |
| 1299 | # If we're in the current input and there's only whitespace |
| 1300 | # beyond the cursor, erase that whitespace first |
| 1301 | s = self.text.get("insert", "end-1c") |
nothing calls this directly
no test coverage detected