MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / ParseOptions

Method ParseOptions

source/script_gui.cpp:4812–5162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4810
4811
4812ResultType GuiType::ParseOptions(LPTSTR aOptions, bool &aSetLastFoundWindow, ToggleValueType &aOwnDialogs)
4813// This function is similar to ControlParseOptions() further below, so should be maintained alongside it.
4814// Caller must have already initialized aSetLastFoundWindow/, bool &aOwnDialogs with desired starting values.
4815// Caller must ensure that aOptions is a modifiable string, since this method temporarily alters it.
4816{
4817 LONG nc_width, nc_height;
4818
4819 if (mHwnd)
4820 {
4821 // Since window already exists, its mStyle and mExStyle members might be out-of-date due to
4822 // "WinSet Transparent", etc. So update them:
4823 mStyle = GetWindowLong(mHwnd, GWL_STYLE);
4824 mExStyle = GetWindowLong(mHwnd, GWL_EXSTYLE);
4825 }
4826 DWORD style_orig = mStyle;
4827 DWORD exstyle_orig = mExStyle;
4828
4829 LPTSTR pos_of_the_x, next_option, option_end;
4830 TCHAR orig_char;
4831 bool adding; // Whether this option is being added (+) or removed (-).
4832
4833 for (next_option = aOptions; *next_option; next_option = omit_leading_whitespace(option_end))
4834 {
4835 if (*next_option == '-')
4836 {
4837 adding = false;
4838 // omit_leading_whitespace() is not called, which enforces the fact that the option word must
4839 // immediately follow the +/- sign. This is done to allow the flexibility to have options
4840 // omit the plus/minus sign, and also to reserve more flexibility for future option formats.
4841 ++next_option; // Point it to the option word itself.
4842 }
4843 else
4844 {
4845 // Assume option is being added in the absence of either sign. However, when we were
4846 // called by GuiControl(), the first option in the list must begin with +/- otherwise the cmd
4847 // would never have been properly detected as GUICONTROL_CMD_OPTIONS in the first place.
4848 adding = true;
4849 if (*next_option == '+')
4850 ++next_option; // Point it to the option word itself.
4851 //else do not increment, under the assumption that the plus has been omitted from a valid
4852 // option word and is thus an implicit plus.
4853 }
4854
4855 if (!*next_option) // In case the entire option string ends in a naked + or -.
4856 break;
4857 // Find the end of this option item:
4858 if ( !(option_end = StrChrAny(next_option, _T(" \t"))) ) // Space or tab.
4859 option_end = next_option + _tcslen(next_option); // Set to position of zero terminator instead.
4860 if (option_end == next_option)
4861 continue; // i.e. the string contains a + or - with a space or tab after it, which is intentionally ignored.
4862
4863 // Temporarily terminate to help eliminate ambiguity for words contained inside other words,
4864 // such as "Checked" inside of "CheckedGray":
4865 orig_char = *option_end;
4866 *option_end = '\0';
4867
4868 // Attributes and option words:
4869

Callers

nothing calls this directly

Calls 7

omit_leading_whitespaceFunction · 0.85
StrChrAnyFunction · 0.85
IsNumericFunction · 0.85
ATOI64Function · 0.85
ctoupperFunction · 0.85
ValueErrorFunction · 0.85
RuntimeErrorMethod · 0.80

Tested by

no test coverage detected