📄 x3.c
字号:
}
//-------------------------------------------------------------------------
int FindNextString(HWND hwnd, FINDREPLACE *find, struct re_registers **r, int
*n)
{
char *buf = GetEditData(GetDlgItem(hwnd, ID_EDITCHILD));
int len;
if (buf)
{
int pos;
charinfo a;
// SendMessage(GetDlgItem(hwnd,ID_EDITCHILD),EM_GETSEL, (WPARAM)&pos,0) ;
SendMessage(GetDlgItem(hwnd, ID_EDITCHILD), EM_EXGETSEL, 0, (LPARAM) &a)
;
pos = a.min;
if (pos != lastfound && findpos != - 1)
findpos = pos;
if (findpos == - 1)
if (find->Flags &FR_DOWN)
findpos = 0;
else
findpos = strlen(buf);
findpos = xfind(find, buf, findpos, &len, r, n);
lastfound = findpos;
free(buf);
if (findpos >= 0)
{
charinfo r;
r.min = findpos;
r.max = findpos + len;
SendMessage(GetDlgItem(hwnd, ID_EDITCHILD), EM_EXSETSEL, 0, (LPARAM)
&r);
SendMessage(GetDlgItem(hwnd, ID_EDITCHILD), EM_SCROLLCARET, 0, 0);
UpdateWindow(GetDlgItem(hwnd, ID_EDITCHILD));
SendMessage(hwnd, WM_COMMAND, ID_REDRAWSTATUS, 0);
if (find->Flags &FR_DOWN)
findpos += len;
else
{
findpos -= len;
if (findpos < 0)
{
findpos = 0;
goto done;
}
}
MoveFindWindow(GetDlgItem(hwnd, ID_EDITCHILD), findpos, findpos +
len);
}
else
{
done: SendMessage(GetDlgItem(hwnd, ID_EDITCHILD), EM_SETSEL, - 1,
0);
SendMessage(hwnd, WM_COMMAND, ID_REDRAWSTATUS, 0);
if (!(find->Flags &FR_REPLACEALL))
{
ExtendedMessageBox("Search", MB_SETFOREGROUND | MB_SYSTEMMODAL,
"No more matches found");
}
findpos = - 1;
return TRUE;
}
return FALSE;
}
return TRUE;
}
//-------------------------------------------------------------------------
void ReplaceNextString(HWND hwnd, FINDREPLACE *replace)
{
char buf[256];
int flags;
static struct re_registers *registers;
int regnum;
charinfo a, a2;
int selected;
selected = IsDlgButtonChecked(hwndFind, IDC_RADIO_SELECTED_TEXT; if
(selected)
{
SendMessage(GetDlgItem(hwnd, ID_EDITCHILD), EM_EXGETSEL, 0, (LPARAM) &a)
;
} replace->Flags |= FR_DOWN; flags = replace->Flags; SendMessage(GetDlgItem
(hwnd, ID_EDITCHILD), EM_HIDESELECTION, 1, 0);
while (TRUE)
{
int notthere = FALSE; if (!found || (flags &FR_FINDNEXT))
{
notthere = FindNextString(hwnd, replace, ®isters, ®num); if (
(!found || selected && pos >= a.max) && !(flags &FR_REPLACEALL))
{
found = !notthere; if (flags &FR_REPLACEALL)
{
SendMessage(GetDlgItem(hwnd, ID_EDITCHILD), EM_EXSETSEL, 0,
(LPARAM) &a);
}
SendMessage(GetDlgItem(hwnd, ID_EDITCHILD), EM_HIDESELECTION, 0,
0); SendMessage(hwnd, WM_COMMAND, ID_REDRAWSTATUS, 0);
return ;
}
found = !notthere;
}
if (notthere)
{
SendMessage(GetDlgItem(hwnd, ID_EDITCHILD), EM_HIDESELECTION, 0, 0)
; SendMessage(hwnd, WM_COMMAND, ID_REDRAWSTATUS, 0); if (flags
&FR_REPLACEALL)
{
SendMessage(GetDlgItem(hwnd, ID_EDITCHILD), EM_EXSETSEL, 0,
(LPARAM) &a);
}
return ;
}
if (flags &(FR_REPLACE | FR_REPLACEALL))
{
int readonly = SendMessage(GetDlgItem(hwnd, ID_EDITCHILD),
EM_GETREADONLY, 0, 0); if (!readonly)
{
if (IsWindow(GetDlgItem(hwndFind, 990)) && IsDlgButtonChecked
(hwndFind, 990))
{
int i, dest = 0; char *dta = GetEditData(GetDlgItem(hwnd,
ID_EDITCHILD)); for (i = 0; i < strlen(replace
->lpstrReplaceWith) && dest < 255; i++)
{
if (replace->lpstrReplaceWith[i] == '\\')
{
if (replace->lpstrReplaceWith[++i])
{
int index = replace->lpstrReplaceWith[i]; if
(isdigit(index))
{
index -= '0'; if (dta && index <= regnum)
{
int j; for (j = registers
->start[index]; j < registers
->end[index] && dest < 255; j++)
buf[dest++] = dta[j];
}
}
else
buf[dest++] = replace->lpstrReplaceWith[i];
}
}
else
buf[dest++] = replace->lpstrReplaceWith[i];
}
free(dta); buf[dest] = 0;
}
else
{
strcpy(buf, replace->lpstrReplaceWith);
}
if (selected)
{
SendMessage(GetDlgItem(hwnd, ID_EDITCHILD), EM_EXGETSEL, 0,
(LPARAM) &a2); a.max += strlen(buf) - (a2.max - a2.min)
;
}
SendMessage(GetDlgItem(hwnd, ID_EDITCHILD), EM_REPLACESEL, 1,
(LPARAM)buf); UpdateWindow(GetDlgItem(hwnd, ID_EDITCHILD));
}
findpos += strlen(replace->lpstrReplaceWith) - strlen(replace
->lpstrFindWhat); found = FALSE;
}
if (!(flags &FR_REPLACEALL))if (flags &FR_REPLACE)
{
flags &= ~FR_REPLACE; flags |= FR_FINDNEXT;
}
else
{
SendMessage(GetDlgItem(hwnd, ID_EDITCHILD), EM_HIDESELECTION, 0, 0)
; SendMessage(hwnd, WM_COMMAND, ID_REDRAWSTATUS, 0); return ;
}
}
}
//-------------------------------------------------------------------------
void drawParams(DWINFO *info, HWND hwnd)
{
char buf[512]; int start, ins, col, sel; int readonly = SendMessage(info
->dwHandle, EM_GETREADONLY, 0, 0); int mod = SendMessage(info->dwHandle,
EM_GETMODIFY, 0, 0); charinfo a; SendMessage(info->dwHandle, EM_GETSEL,
(WPARAM) &sel, 0); SendMessage(GetDlgItem(hwnd, ID_EDITCHILD),
EM_EXGETSEL, 0, (LPARAM) &a); sel = a.min; start = SendMessage(info
->dwHandle, EM_EXLINEFROMCHAR, 0, sel); ins = SendMessage(info
->dwHandle, EM_GETINSERTSTATUS, 0, 0); col = SendMessage(info->dwHandle,
EM_GETCOLUMN, 0, 0); sprintf(buf, "Line: %d", start + 1); SendMessage
(hwndStatus, SB_SETTEXT, 1, (LPARAM)buf); sprintf(buf, "Col: %d", col +
1); SendMessage(hwndStatus, SB_SETTEXT, 2, (LPARAM)buf); SendMessage
(hwndStatus, SB_SETTEXT, 3, (LPARAM)(ins ? "INS" : "OVR")); if
(readonly)SendMessage(hwndStatus, SB_SETTEXT, 4, (LPARAM)("READ-ONLY"))
;
else
SendMessage(hwndStatus, SB_SETTEXT, 4, (LPARAM)(mod ? "MODIFIED" : " "))
; SendMessage(hwndStatus, SB_SETTEXT, 0 | SBT_NOBORDERS, (LPARAM)" ")
;
strcpy(buf, info->dwTitle); if (mod)strcat(buf, " *"); SendMessage(hwnd,
WM_SETTEXT, 0, (LPARAM)buf);
}
//-------------------------------------------------------------------------
void eraseParams(HWND hwnd)
{
SendMessage(hwndStatus, SB_SETTEXT, 1, (LPARAM)" "); SendMessage
(hwndStatus, SB_SETTEXT, 2, (LPARAM)" "); SendMessage(hwndStatus,
SB_SETTEXT, 3, (LPARAM)" "); SendMessage(hwndStatus, SB_SETTEXT, 4,
(LPARAM)" ");
}
//-------------------------------------------------------------------------
int PaintBreakpoints(HWND hwnd, HDC dc, PAINTSTRUCT *paint, RECT *rcl)
{
HBRUSH graybrush, graybrush1; RECT r, r1; int i; HDC hMemDC =
CreateCompatibleDC(dc); DWINFO *ptr = (DWINFO*)GetWindowLong(hwnd, 0);
int linenum = SendMessage(ptr->dwHandle, EM_GETFIRSTVISIBLELINE, 0, 0)
+ 1; int chpos1 = SendMessage(ptr->dwHandle, EM_LINEINDEX, linenum, 0);
int ypos; int lines, offset = 0; int height; short *lt; int lc; POINTL
pt; int bpline = BPLine(ptr->dwName); SendMessage(ptr->dwHandle,
EM_POSFROMCHAR, (WPARAM) &pt, chpos1); ypos = pt.y;
SendMessage(ptr->dwHandle, EM_GETRECT, 0, (LPARAM) &r1); lines = r1.bottom
/ (height = SendMessage(ptr->dwHandle, EM_GETTEXTHEIGHT, 0, 0));
if (ypos < height)offset = ypos - height;
graybrush = CreateSolidBrush(GetSysColor(COLOR_3DFACE)); FillRect(dc, rcl,
graybrush); DeleteObject(graybrush); if (uState != notDebugging)
{
lt = GetLineTable(ptr->dwName, &lc); if (lt)
{
int j = 0; graybrush1 = GetStockObject(BLACK_BRUSH); r.left = 28;
r.right = 32; for (i = linenum; i <= linenum + lines; i++)
{
int oldline = TagOldLine(ptr->dwName, i);
while (lt[j] < oldline)j++; if (lt[j] == oldline)
{
r.top = offset + (i - linenum) *height; r.bottom = r.top +
height; FillRect(dc, &r, graybrush1);
}
}
}
}
for (i = linenum; i <= linenum + lines; i++)
{
int type = IsTagged(ptr->dwName, i); switch (type)
{
case TAG_BP:
if (bpline == i)
{
SelectObject(hMemDC, stoppcBitmap); BitBlt(dc, 12, (i -
linenum) *height + offset, 16, 16, hMemDC, 0, 0,
SRCCOPY); break;
}
// fallthrough
default:
SelectObject(hMemDC, tagBmps[type]); BitBlt(dc, 12, (i -
linenum) *height + offset, 16, 16, hMemDC, 0, 0, SRCCOPY);
break; case - 1: if (bpline == i)
{
SelectObject(hMemDC, pcBitmap); BitBlt(dc, 12, (i - linenum)
*height + offset, 16, 16, hMemDC, 0, 0, SRCCOPY);
}
break;
}
}
DeleteDC(hMemDC);
}
//-------------------------------------------------------------------------
LRESULT CALLBACK _export gotoProc(HWND hwnd, UINT iMessage, WPARAM wParam,
LPARAM lParam)
{
char buf[3]; switch (iMessage)
{
case WM_COMMAND:
if (wParam == IDOK)
{
int i = GetEditFieldValue(hwnd, IDC_GOTO); EndDialog(hwnd, i);
break;
}
if (HIWORD(wParam) == EN_CHANGE)
{
DisableControl(hwnd, IDOK, !GetWindowText((HWND)lParam, buf, 2))
; break;
}
if (wParam != IDCANCEL)break; case WM_CLOSE:
EndDialog(hwnd, 0); break; case WM_INITDIALOG:
CenterWindow(hwnd); SetEditField(hwnd, IDC_GOTO, "");
DisableControl(hwnd, IDOK, 1); break;
}
return 0;
}
//-------------------------------------------------------------------------
void recolorize(DWINFO *ptr)
{
int colorizing = COLORIZE_NONE; if (stristr(ptr->dwName, ".c") == ptr
->dwName + strlen(ptr->dwName) - 2 || stristr(ptr->dwName, ".cpp") ==
ptr->dwName + strlen(ptr->dwName) - 4 || stristr(ptr->dwName, ".h") ==
ptr->dwName + strlen(ptr->dwName) - 2)colorizing = COLORIZE_C;
else if (stristr(ptr->dwName, ".asm") == ptr->dwName + strlen(ptr->dwName)
- 4 || stristr(ptr->dwName, ".asi") == ptr->dwName + strlen(ptr->dwName)
- 4 || stristr(ptr->dwName, ".inc") == ptr->dwName + strlen(ptr->dwName)
- 4)colorizing = COLORIZE_ASM; SendMessage(ptr->dwHandle, EM_COLORIZE,
0, colorizing);
}
//-------------------------------------------------------------------------
void asyncLoadFile(DWINFO *ptr)
{
recolorize(ptr); if (ptr->dwName[0])LoadFile(ptr->self, ptr);
else
ShowWindow(ptr->dwHandle, SW_SHOW); if (ptr->dwLineNo != - 1)
{
PostMessage(ptr->self, WM_COMMAND, IDM_SETLINE, ptr->dwLineNo);
}
PostMessage(hwndSourceTab, WM_RESETTABS, 0, 0);
}
//-------------------------------------------------------------------------
LRESULT CALLBACK _export DrawProc(HWND hwnd, UINT iMessage, WPARAM wParam,
LPARAM lParam)
{
DWORD threadhand; DWINFO *ptr, *ptr1; OPENFILENAME ofn; HDC dc; HPEN hpen,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -