(node)
| 1565 | |
| 1566 | |
| 1567 | def _change_node(node): |
| 1568 | # Changes the value of the menu node 'node' if it is a symbol. Bools and |
| 1569 | # tristates are toggled, while other symbol types pop up a text entry |
| 1570 | # dialog. |
| 1571 | # |
| 1572 | # Returns False if the value of 'node' can't be changed. |
| 1573 | |
| 1574 | if not _changeable(node): |
| 1575 | return False |
| 1576 | |
| 1577 | # sc = symbol/choice |
| 1578 | sc = node.item |
| 1579 | |
| 1580 | if sc.orig_type in (INT, HEX, STRING): |
| 1581 | s = sc.str_value |
| 1582 | |
| 1583 | while True: |
| 1584 | s = _input_dialog( |
| 1585 | "{} ({})".format(node.prompt[0], TYPE_TO_STR[sc.orig_type]), |
| 1586 | s, _range_info(sc)) |
| 1587 | |
| 1588 | if s is None: |
| 1589 | break |
| 1590 | |
| 1591 | if sc.orig_type in (INT, HEX): |
| 1592 | s = s.strip() |
| 1593 | |
| 1594 | # 'make menuconfig' does this too. Hex values not starting with |
| 1595 | # '0x' are accepted when loading .config files though. |
| 1596 | if sc.orig_type == HEX and not s.startswith(("0x", "0X")): |
| 1597 | s = "0x" + s |
| 1598 | |
| 1599 | if _check_valid(sc, s): |
| 1600 | _set_val(sc, s) |
| 1601 | break |
| 1602 | |
| 1603 | elif len(sc.assignable) == 1: |
| 1604 | # Handles choice symbols for choices in y mode, which are a special |
| 1605 | # case: .assignable can be (2,) while .tri_value is 0. |
| 1606 | _set_val(sc, sc.assignable[0]) |
| 1607 | |
| 1608 | else: |
| 1609 | # Set the symbol to the value after the current value in |
| 1610 | # sc.assignable, with wrapping |
| 1611 | val_index = sc.assignable.index(sc.tri_value) |
| 1612 | _set_val(sc, sc.assignable[(val_index + 1) % len(sc.assignable)]) |
| 1613 | |
| 1614 | |
| 1615 | if _is_y_mode_choice_sym(sc) and not node.list: |
| 1616 | # Immediately jump to the parent menu after making a choice selection, |
| 1617 | # like 'make menuconfig' does, except if the menu node has children |
| 1618 | # (which can happen if a symbol 'depends on' a choice symbol that |
| 1619 | # immediately precedes it). |
| 1620 | _leave_menu() |
| 1621 | |
| 1622 | |
| 1623 | return True |
| 1624 |
no test coverage detected