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

Method ToText

source/hotkey.cpp:2111–2186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2109
2110
2111LPTSTR Hotkey::ToText(LPTSTR aBuf, int aBufSize, bool aAppendNewline)
2112// aBufSize is an int so that any negative values passed in from caller are not lost.
2113// Caller has ensured that aBuf isn't NULL.
2114// Translates this var into its text equivalent, putting the result into aBuf and
2115// returning the position in aBuf of its new string terminator.
2116{
2117 LPTSTR aBuf_orig = aBuf;
2118
2119 HotkeyVariant *vp;
2120 int existing_threads;
2121 for (existing_threads = 0, vp = mFirstVariant; vp; vp = vp->mNextVariant)
2122 existing_threads += vp->mExistingThreads;
2123
2124 TCHAR existing_threads_str[128];
2125 if (existing_threads)
2126 _itot(existing_threads, existing_threads_str, 10);
2127 else
2128 *existing_threads_str = '\0'; // Make it blank to avoid clutter in the hotkey display.
2129
2130 TCHAR htype[32];
2131 switch (mType)
2132 {
2133 case HK_NORMAL: _tcscpy(htype, _T("reg")); break;
2134 case HK_KEYBD_HOOK: _tcscpy(htype, _T("k-hook")); break;
2135 case HK_MOUSE_HOOK: _tcscpy(htype, _T("m-hook")); break;
2136 case HK_BOTH_HOOKS: _tcscpy(htype, _T("2-hooks")); break;
2137 case HK_JOYSTICK: _tcscpy(htype, _T("joypoll")); break;
2138 default: *htype = '\0'; // For maintainability; should never happen.
2139 }
2140
2141 LPTSTR enabled_str;
2142 if (IsCompletelyDisabled()) // Takes into account alt-tab vs. non-alt-tab, etc.
2143 enabled_str = _T("OFF");
2144 else if (mHookAction && mParentEnabled) // It's completely "on" in this case.
2145 enabled_str = _T("");
2146 else // It's on or if all individual variants are on, otherwise it's partial.
2147 {
2148 // Set default: Empty string means "ON" because it reduces clutter in the displayed list.
2149 for (enabled_str = _T(""), vp = mFirstVariant; vp; vp = vp->mNextVariant)
2150 if (!vp->mEnabled)
2151 {
2152 enabled_str = _T("PART");
2153 break;
2154 }
2155 }
2156
2157 TCHAR level_str[7]; // Room for "99-100".
2158 int min_level = 100, max_level = -1;
2159 for (vp = mFirstVariant; vp; vp = vp->mNextVariant)
2160 {
2161 if (min_level > vp->mInputLevel)
2162 min_level = vp->mInputLevel;
2163 if (max_level < vp->mInputLevel)
2164 max_level = vp->mInputLevel;
2165 }
2166 if (min_level != max_level)
2167 _stprintf(level_str, _T("%i-%i"), min_level, max_level);
2168 else if (min_level)

Callers 1

ListHotkeysMethod · 0.45

Calls 1

sntprintfFunction · 0.85

Tested by

no test coverage detected