Skip to content

Commit 1c7e170

Browse files
GE Debugger: Allow search by state name.
Since adding breakpoint as the first column, the default search behavior stopped working. This restores it, searching for any matching column.
1 parent 5b5529b commit 1c7e170

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

Windows/W32Util/Misc.cpp

+41
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,50 @@ int GenericListControl::HandleNotify(LPARAM lParam) {
288288
return 0;
289289
}
290290

291+
if (mhdr->code == LVN_INCREMENTALSEARCH) {
292+
NMLVFINDITEM *request = (NMLVFINDITEM *)lParam;
293+
uint32_t supported = LVFI_WRAP | LVFI_STRING | LVFI_PARTIAL | LVFI_SUBSTRING;
294+
if ((request->lvfi.flags & ~supported) == 0 && (request->lvfi.flags & LVFI_STRING) != 0) {
295+
bool wrap = (request->lvfi.flags & LVFI_WRAP) != 0;
296+
bool partial = (request->lvfi.flags & (LVFI_PARTIAL | LVFI_SUBSTRING)) != 0;
297+
298+
// It seems like 0 is always sent for start, let's override.
299+
int startRow = request->iStart;
300+
if (startRow == 0)
301+
startRow = GetSelectedIndex();
302+
int result = OnIncrementalSearch(startRow, request->lvfi.psz, wrap, partial);
303+
if (result != -1) {
304+
request->lvfi.flags = LVFI_PARAM;
305+
request->lvfi.lParam = (LPARAM)result;
306+
}
307+
}
308+
}
309+
291310
return 0;
292311
}
293312

313+
int GenericListControl::OnIncrementalSearch(int startRow, const wchar_t *str, bool wrap, bool partial) {
314+
return -1;
315+
int size = GetRowCount();
316+
size_t searchlen = wcslen(str);
317+
if (!wrap)
318+
size -= startRow;
319+
320+
// We start with the earliest column, preferring matches on the leftmost columns by default.
321+
for (int c = 0; c < columnCount; ++c) {
322+
for (int i = 0; i < size; ++i) {
323+
int r = (startRow + i) % size;
324+
stringBuffer[0] = 0;
325+
GetColumnText(stringBuffer, r, c);
326+
int difference = partial ? _wcsnicmp(str, stringBuffer, searchlen) : _wcsicmp(str, stringBuffer);
327+
if (difference == 0)
328+
return r;
329+
}
330+
}
331+
332+
return -1;
333+
}
334+
294335
void GenericListControl::Update() {
295336
if (!updateScheduled_) {
296337
SetTimer(handle, IDT_UPDATE, UPDATE_DELAY, nullptr);

Windows/W32Util/Misc.h

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ class GenericListControl
6868
virtual bool OnRowPrePaint(int row, LPNMLVCUSTOMDRAW msg) { return false; }
6969
virtual bool OnColPrePaint(int row, int col, LPNMLVCUSTOMDRAW msg) { return false; }
7070

71+
virtual int OnIncrementalSearch(int startRow, const wchar_t *str, bool wrap, bool partial);
72+
7173
private:
7274
static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
7375
void ProcessUpdate();

0 commit comments

Comments
 (0)