(instance: PythonScriptingInstance, old_value: Any, new_value: Any)
| 1449 | |
| 1450 | |
| 1451 | def _set_current_selection(instance: PythonScriptingInstance, old_value: Any, new_value: Any): |
| 1452 | if not instance.interpreter.locals["current_ui_view"]: |
| 1453 | return |
| 1454 | |
| 1455 | if (not isinstance(new_value, list)) and \ |
| 1456 | (not isinstance(new_value, tuple)): |
| 1457 | return |
| 1458 | if len(new_value) != 2: |
| 1459 | raise ValueError("Current selection needs to be a list or tuple of two items") |
| 1460 | |
| 1461 | new_value = [new_value[0], new_value[1]] |
| 1462 | |
| 1463 | if isinstance(new_value[0], str): |
| 1464 | new_value[0] = instance.interpreter.active_view.parse_expression( |
| 1465 | new_value[0], |
| 1466 | instance.interpreter.active_addr |
| 1467 | ) |
| 1468 | |
| 1469 | if isinstance(new_value[1], str): |
| 1470 | new_value[1] = instance.interpreter.active_view.parse_expression( |
| 1471 | new_value[1], |
| 1472 | instance.interpreter.active_addr |
| 1473 | ) |
| 1474 | |
| 1475 | if new_value[0] != instance.interpreter.active_selection_begin or \ |
| 1476 | new_value[1] != instance.interpreter.active_selection_end: |
| 1477 | new_selection = (new_value[0], new_value[1]) |
| 1478 | binaryninja.mainthread.execute_on_main_thread( |
| 1479 | lambda: instance.interpreter.locals["current_ui_view"].setSelectionOffsets(new_selection) |
| 1480 | ) |
| 1481 | |
| 1482 | |
| 1483 | PythonScriptingProvider.register_magic_variable( |
nothing calls this directly
no test coverage detected