📄 tags.c
字号:
l = l->next;
}
if (!l)
{
l = calloc(sizeof(struct tagfile), 1);
if (l)
{
struct tagfile **ls = &tagFileList;
while (*ls)
ls = &(*ls)->next;
*ls = l;
strcpy(l->name, name);
TagInsertChange(l, drawnLineno, delta);
}
}
}
//-------------------------------------------------------------------------
void TagLinesAdjust(char *name, int mode)
{
struct tagfile *l = tagFileList;
int i;
while (l)
{
if (!name || !stricmp(l->name, name))
{
if (mode == TAGM_DISCARDFILE || mode == TAGM_UPDATEDEBUG)
TagRemoveOld(l);
for (i = 0; i < TAG_MAX; i++)
{
struct tag *t = l->tagArray[i];
while (t)
{
switch (mode)
{
case TAGM_SAVEFILE:
t->editingLineno = t->drawnLineno;
break;
case TAGM_DISCARDFILE:
t->drawnLineno = t->editingLineno;
break;
case TAGM_UPDATEDEBUG:
t->debugLineno = t->drawnLineno;
break;
}
t = t->next;
}
}
}
l = l->next;
}
}
//-------------------------------------------------------------------------
void TagBreakpoint(char *module, int line)
{
if (module)
{
strcpy(bpModule, module);
}
else
{
bpModule[0] = 0;
}
bpLine = line;
}
//-------------------------------------------------------------------------
int BPLine(char *module)
{
if (bpModule[0] && !stricmp(bpModule, module))
return TagNewLine(module, bpLine);
return 0;
}
//-------------------------------------------------------------------------
void TagEraseAllEntries(void)
{
int i;
struct tagfile *l = tagFileList;
for (i = 0; i < TAG_MAX; i++)
TagRemoveAll(i);
while (l)
{
struct tagfile *s = l->next;
TagRemoveOld(l);
free(l);
l = s;
} tagFileList = 0;
}
//-------------------------------------------------------------------------
void ToggleBookMark(void)
{
HWND hWnd = GetFocus();
int i;
for (i = 0; i < numberofdrawwindows; i++)
{
DWINFO *ptr = (DWINFO*)GetWindowLong(children[i], 0);
if (ptr->dwHandle == hWnd)
{
char buf[256], *ch;
int addr, linenum;
SendMessage(ptr->dwHandle, EM_GETSEL, (WPARAM) &linenum, 0);
linenum = SendMessage(ptr->dwHandle, EM_LINEFROMCHAR, linenum, 0) +
1;
memset(buf, 0, 256);
*(short*)buf = 256;
SendMessage(ptr->dwHandle, EM_GETLINE, (WPARAM)linenum - 1, (LPARAM)
buf);
if (Tag(TAG_BOOKMARK, ptr->dwName, linenum, 0, ch = strdup(buf), 0,
0))
{
strcpy(currentBM.dwName, ptr->dwName);
currentBM.dwLineNo = linenum;
}
else
free(ch);
break;
}
}
}
//-------------------------------------------------------------------------
int findbmpos(struct tagfile **l, struct tag **t)
{
struct tagfile *il;
(*l) = tagFileList;
if (currentBM.dwName[0])
{
while ((*l))
{
if (!stricmp(currentBM.dwName, (*l)->name))
break;
(*l) = (*l)->next;
} if (!(*l))
(*l) = tagFileList;
}
if (!(*l))
return 0;
il = (*l);
do
{
(*t) = (*l)->tagArray[TAG_BOOKMARK];
while ((*t))
{
if ((*t)->drawnLineno >= currentBM.dwLineNo || (*l) != il)return 1;
(*t)
= (*t)->next;
}
(*l) = (*l)->next;
if (!(*l))
(*l) = tagFileList;
(*t) = (*l)->tagArray[TAG_BOOKMARK];
}
while ((*l) != il)
;
return 0;
}
//-------------------------------------------------------------------------
void NextBookMark(void)
{
struct tagfile *l;
struct tag *t, *st;
int sln;
if (!findbmpos(&l, &t))
return ;
st = t;
t = t->next;
do
{
if (t)
{
strcpy(currentBM.dwName, l->name);
currentBM.dwLineNo = t->drawnLineno;
currentBM.logMRU = FALSE;
CreateDrawWindow(¤tBM);
return ;
}
else
{
l = l->next;
if (!l)
l = tagFileList;
t = l->tagArray[TAG_BOOKMARK];
}
}
while (t != st);
}
//-------------------------------------------------------------------------
void PreviousBookMark(void)
{
DWINFO temp;
struct tagfile *l, *fl;
struct tag *t, *ft;
int sln, gotone = FALSE;
if (!findbmpos(&l, &t))
return ;
fl = tagFileList;
while (fl)
{
ft = fl->tagArray[TAG_BOOKMARK];
strcpy(temp.dwName, fl->name);
temp.logMRU = FALSE;
while (ft)
{
if (fl == l)
{
if (ft->drawnLineno == t->drawnLineno && gotone)
{
currentBM = temp;
CreateDrawWindow(¤tBM);
return ;
}
else if (ft->drawnLineno >= t->drawnLineno)
{
while (fl)
{
strcpy(temp.dwName, fl->name);
while (ft)
{
temp.dwLineNo = ft->drawnLineno;
ft = ft->next;
}
fl = fl->next;
if (fl)
ft = fl->tagArray[TAG_BOOKMARK];
}
currentBM = temp;
CreateDrawWindow(¤tBM);
return ;
}
}
temp.dwLineNo = ft->drawnLineno;
gotone = TRUE;
ft = ft->next;
}
fl = fl->next;
}
}
//-------------------------------------------------------------------------
LRESULT CALLBACK _export BMProc(HWND hwnd, UINT iMessage, WPARAM wParam, LPARAM
lParam)
{
static HFONT font;
LPMEASUREITEMSTRUCT mi;
LPDRAWITEMSTRUCT di;
LV_COLUMN lvC;
LV_ITEM item;
RECT r;
struct tagfile *l = &tagFileList;
struct tag *t, *t1;
HWND hwndlb;
int i;
switch (iMessage)
{
case WM_NOTIFY:
if (wParam == IDC_BMLISTBOX)
{
if (((LPNMHDR)lParam)->code == NM_DBLCLK)
{
SendMessage(hwnd, WM_COMMAND, IDC_BMGOTO, 0);
}
}
break;
case WM_COMMAND:
if (wParam == IDCANCEL)
{
DeleteObject(font);
DestroyWindow(hwnd);
hwndBookmark = 0;
}
else if (wParam == IDC_BMGOTO)
{
int sel = ListView_GetSelectionMark(GetDlgItem(hwnd,
IDC_BMLISTBOX));
if (sel == - 1)
{
DeleteObject(font);
EndDialog(hwnd, 1);
break;
}
item.iItem = sel;
item.iSubItem = 0;
item.mask = LVIF_PARAM;
ListView_GetItem(GetDlgItem(hwnd, IDC_BMLISTBOX), &item);
t1 = (struct tag*)item.lParam;
while (l)
{
t = l->tagArray[TAG_BOOKMARK];
while (t && t != t1)
t = t->next;
if (t)
{
strcpy(currentBM.dwName, l->name);
currentBM.dwLineNo = t->drawnLineno;
currentBM.logMRU = FALSE;
CreateDrawWindow(¤tBM);
break;
}
l = l->next;
}
DeleteObject(font);
EndDialog(hwnd, 1);
}
break;
case WM_MEASUREITEM:
mi = (LPMEASUREITEMSTRUCT)lParam;
hwndlb = GetDlgItem(hwnd, IDC_BMLISTBOX);
GetClientRect(hwndlb, &r);
mi->itemWidth = r.right;
mi->itemHeight = 14;
break;
case WM_INITDIALOG:
CenterWindow(hwnd);
font = CreateFontIndirect(&fontdata);
hwndlb = GetDlgItem(hwnd, IDC_BMLISTBOX);
SendMessage(hwndlb, WM_SETFONT, (WPARAM)font, 0);
GetWindowRect(hwndlb, &r);
lvC.mask = LVCF_WIDTH | LVCF_SUBITEM;
lvC.cx = r.right - r.left;
lvC.iSubItem = 0;
ListView_InsertColumn(hwndlb, 0, &lvC);
i = 0;
while (l)
{
t = l->tagArray[TAG_BOOKMARK];
while (t)
{
char buf[256];
sprintf(buf, "%s(%d): %s", l->name, t->drawnLineno, t
->extra);
item.iItem = i++;
item.iSubItem = 0;
item.mask = LVIF_PARAM | LVIF_TEXT;
item.lParam = (LPARAM)t;
item.pszText = buf;
ListView_InsertItem(hwndlb, &item);
t = t->next;
}
l = l->next;
}
break;
}
return 0;
}
//-------------------------------------------------------------------------
void ShowBookMarks(void)
{
hwndBookmark = CreateDialog(hInstance, "BOOKMARKDLG", hwndFrame, (DLGPROC)
BMProc);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -