Win-specific: Scan Popup now worked with ConEmu console emulator (patch by ConEmu authors)

This commit is contained in:
Abs62 2012-04-12 16:43:09 +04:00
parent b0e009d456
commit 296d6d5203
2 changed files with 31 additions and 2 deletions

View file

@ -13,6 +13,7 @@ TKnownWndClass GetWindowType(HWND WND, const char* WNDClass)
"INTERNET EXPLORER_SERVER",
"CONSOLEWINDOWCLASS", // NT
"TTYGRAB", // 9x
"VIRTUALCONSOLECLASS", // ConEmu
};
TKnownWndClass KnownClasses[] = {
kwcRichEdit,
@ -22,17 +23,23 @@ TKnownWndClass GetWindowType(HWND WND, const char* WNDClass)
kwcInternetExplorer_Server,
kwcConsole,
kwcConsole,
kwcConEmu,
};
int i;
for (i=0; i<7; i++) {
for (i=0; i<8; i++) {
if (_stricmp(WNDClass, StrKnownClasses[i])==0)
break;
}
if (i<7) {
if (i<8) {
if (KnownClasses[i] == kwcMultiLineEdit) {
if ((GetWindowLong(WND, GWL_STYLE) & ES_MULTILINE) == 0)
return kwcSingleLineEdit;
}
else if (KnownClasses[i] == kwcConEmu) {
HWND hConsole = (HWND)(DWORD_PTR)GetWindowLongPtr(WND, 0);
if (!hConsole || !IsWindow(hConsole))
return kwcUnknown;
}
return KnownClasses[i];
} else
return kwcUnknown;
@ -169,6 +176,26 @@ static char* GetWordFromConsole(HWND WND, POINT Pt, DWORD *BeginPos)
return Result;
}
static char* GetWordFromConEmu(HWND WND, POINT Pt, DWORD *BeginPos)
{
HWND hConsole = (HWND)(DWORD_PTR)GetWindowLongPtr(WND, 0);
if (!hConsole || !IsWindow(hConsole))
return NULL;
RECT rcConEmu;
if (!GetWindowRect(WND, &rcConEmu) || rcConEmu.right <= rcConEmu.left || rcConEmu.bottom <= rcConEmu.top)
return NULL;
RECT rcConsole;
if (!GetClientRect(hConsole, &rcConsole) || rcConsole.right <= rcConsole.left || rcConsole.bottom <= rcConsole.top)
return NULL;
POINT ptReal = { (Pt.x - rcConEmu.left) * (rcConsole.right - rcConsole.left + 1) / ( rcConEmu.right - rcConEmu.left + 1),
(Pt.y - rcConEmu.top) * (rcConsole.bottom - rcConsole.top + 1 ) / (rcConEmu.bottom - rcConEmu.top + 1) };
ClientToScreen(hConsole, &ptReal);
return GetWordFromConsole(hConsole, ptReal, BeginPos);
}
char* TryGetWordFromAnyWindow(TKnownWndClass WndType, HWND WND, POINT Pt, DWORD *BeginPos)
{
typedef char* (*GetWordFunction_t)(HWND, POINT, DWORD*);
@ -179,6 +206,7 @@ char* TryGetWordFromAnyWindow(TKnownWndClass WndType, HWND WND, POINT Pt, DWORD
ExtractWordFromEditPos,
ExtractWordFromIE,
GetWordFromConsole,
GetWordFromConEmu,
};
return GetWordFunction[WndType](WND, Pt, BeginPos);
}

View file

@ -10,6 +10,7 @@ typedef enum TKnownWndClass {
kwcSingleLineEdit,
kwcInternetExplorer_Server,
kwcConsole,
kwcConEmu,
} TKnownWndClass;
TKnownWndClass GetWindowType(HWND WND, const char* WNDClass);