Skip to content

Commit

Permalink
Support clear recent history, see XhmikosR/notepad2-mod#7.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Aug 12, 2018
1 parent 006d6c6 commit 91e571d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
15 changes: 13 additions & 2 deletions src/Dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,7 @@ INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lPar
hdwp = DeferCtlPos(hdwp, hwnd, IDOK, dx, dy, SWP_NOSIZE);
hdwp = DeferCtlPos(hdwp, hwnd, IDCANCEL, dx, dy, SWP_NOSIZE);
hdwp = DeferCtlPos(hdwp, hwnd, IDC_FILEMRU, dx, dy, SWP_NOMOVE);
hdwp = DeferCtlPos(hdwp, hwnd, IDC_EMPTY_MRU, dx, dy, SWP_NOSIZE);
hdwp = DeferCtlPos(hdwp, hwnd, IDC_SAVEMRU, 0, dy, SWP_NOSIZE);
EndDeferWindowPos(hdwp);
ListView_SetColumnWidth(GetDlgItem(hwnd, IDC_FILEMRU), 0, LVSCW_AUTOSIZE_USEHEADER);
Expand All @@ -1022,8 +1023,9 @@ INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lPar
return TRUE;

case WM_NOTIFY: {
if (((LPNMHDR)(lParam))->idFrom == IDC_FILEMRU) {
switch (((LPNMHDR)(lParam))->code) {
LPNMHDR pnmhdr = (LPNMHDR)lParam;
if (pnmhdr->idFrom == IDC_FILEMRU) {
switch (pnmhdr->code) {
case NM_DBLCLK:
SendMessage(hwnd, WM_COMMAND, MAKELONG(IDOK, 1), 0);
break;
Expand Down Expand Up @@ -1096,6 +1098,15 @@ INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lPar
EnableWindow(GetDlgItem(hwnd, IDOK), ListView_GetSelectedCount(GetDlgItem(hwnd, IDC_FILEMRU)));
break;
}
} else if (pnmhdr->idFrom == IDC_EMPTY_MRU) {
if ((pnmhdr->code == NM_CLICK || pnmhdr->code == NM_RETURN)) {
MRU_Empty(pFileMRU);
if (lstrlen(szCurFile) > 0) {
MRU_Add(pFileMRU, szCurFile);
}
MRU_Save(pFileMRU);
SendMessage(hwnd, WM_COMMAND, MAKELONG(0x00A0, 1), 0);
}
}
}
return TRUE;
Expand Down
3 changes: 2 additions & 1 deletion src/Notepad2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,8 @@ CAPTION "Open Recent File"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
CONTROL "",IDC_FILEMRU,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,7,7,212,158
CONTROL "&Remember recent files.",IDC_SAVEMRU,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,169,114,10
CONTROL "&Remember recent files on exit.",IDC_SAVEMRU,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,169,114,10
CONTROL "<a>Clear History</a>",IDC_EMPTY_MRU,"SysLink",WS_TABSTOP,169,169,54,10
DEFPUSHBUTTON "OK",IDOK,67,183,50,14,WS_DISABLED
PUSHBUTTON "Cancel",IDCANCEL,169,183,50,14
SCROLLBAR IDC_RESIZEGRIP,7,187,10,10
Expand Down
2 changes: 1 addition & 1 deletion src/Styles.c
Original file line number Diff line number Diff line change
Expand Up @@ -2691,7 +2691,7 @@ void Style_SaveFontQuality(void) {
LPWSTR lpszStyle = lexDefault.Styles[0 + iIdx].szValue;
WCHAR *p = StrStrI(lpszStyle, L"smoothing:");
if (p != NULL) {
lstrcpyn(szNewStyle, lpszStyle, p - lpszStyle);
lstrcpyn(szNewStyle, lpszStyle, (int)(p - lpszStyle));
} else {
lstrcpy(szNewStyle, lpszStyle);
}
Expand Down
1 change: 1 addition & 0 deletions src/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#define IDC_STYLEFORE 103
#define IDC_AUTOSTRIPBLANKS 103
#define IDC_ENCODINGFROMFILEVARS 103
#define IDC_EMPTY_MRU 103

#define IDD_ABOUT 100
#define IDC_VERSION 100
Expand Down

0 comments on commit 91e571d

Please sign in to comment.