(interp, menuPtr, string, indexPtr)
| 1721 | * A standard Tcl result. If all went well, then *indexPtr is |
| 1722 | * filled in with the entry index corresponding to string |
| 1723 | * (ranges from -1 to the number of entries in the menu minus |
| 1724 | * one). Otherwise an error message is left in interp->result. |
| 1725 | * |
| 1726 | * Side effects: |
| 1727 | * None. |
| 1728 | * |
| 1729 | *-------------------------------------------------------------- |
| 1730 | */ |
| 1731 | |
| 1732 | static int |
| 1733 | GetMenuIndex(interp, menuPtr, string, indexPtr) |
| 1734 | Tcl_Interp *interp; /* For error messages. */ |
| 1735 | Menu *menuPtr; /* Menu for which the index is being |
| 1736 | * specified. */ |
| 1737 | char *string; /* Specification of an entry in menu. See |
| 1738 | * manual entry for valid .*/ |
| 1739 | int *indexPtr; /* Where to store converted relief. */ |
| 1740 | { |
| 1741 | int i, y; |
| 1742 | |
| 1743 | if ((string[0] == 'a') && (strcmp(string, "active") == 0)) { |
| 1744 | *indexPtr = menuPtr->active; |
| 1745 | return TCL_OK; |
| 1746 | } |
| 1747 | |
| 1748 | if ((string[0] == 'l') && (strcmp(string, "last") == 0)) { |
| 1749 | *indexPtr = menuPtr->numEntries-1; |
| 1750 | return TCL_OK; |
| 1751 | } |
| 1752 | |
| 1753 | if ((string[0] == 'n') && (strcmp(string, "none") == 0)) { |
| 1754 | *indexPtr = -1; |
| 1755 | return TCL_OK; |
| 1756 | } |
| 1757 | |
| 1758 | if (string[0] == '@') { |
| 1759 | if (Tcl_GetInt(interp, string+1, &y) == TCL_OK) { |
| 1760 | if (y < 0) { |
| 1761 | *indexPtr = -1; |
| 1762 | return TCL_OK; |
| 1763 | } |
| 1764 | for (i = 0; i < menuPtr->numEntries; i++) { |
| 1765 | y -= menuPtr->entries[i]->height; |
| 1766 | if (y < 0) { |
| 1767 | break; |
| 1768 | } |
| 1769 | } |
| 1770 | if (i >= menuPtr->numEntries) { |
| 1771 | i = -1; |
| 1772 | } |
| 1773 | *indexPtr = i; |
| 1774 | return TCL_OK; |
| 1775 | } else { |
| 1776 | Tcl_SetResult(interp, (char *) NULL, TCL_STATIC); |
| 1777 | } |
| 1778 | } |
| 1779 | |
| 1780 | if (isdigit(string[0])) { |
no test coverage detected