Merge pull request #43 from RaiKoHoff/Bugfixes_and_More

some fixes and features, that missed the latest notepad2-mod
This commit is contained in:
Derick Payne 2017-08-07 09:31:40 +02:00 committed by GitHub
commit 92a23f0bf3
9 changed files with 52 additions and 53 deletions

View File

@ -782,14 +782,14 @@ void SurfaceGDI::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fil
DWORD valEmpty = dwordFromBGRA(0,0,0,0);
DWORD valFill = dwordFromBGRA(
static_cast<byte>(GetBValue(fill.AsLong()) * alphaFill / 255),
static_cast<byte>(GetGValue(fill.AsLong()) * alphaFill / 255),
static_cast<byte>(GetRValue(fill.AsLong()) * alphaFill / 255),
static_cast<byte>(fill.GetBlue() * alphaFill / 255),
static_cast<byte>(fill.GetGreen() * alphaFill / 255),
static_cast<byte>(fill.GetRed() * alphaFill / 255),
static_cast<byte>(alphaFill));
DWORD valOutline = dwordFromBGRA(
static_cast<byte>(GetBValue(outline.AsLong()) * alphaOutline / 255),
static_cast<byte>(GetGValue(outline.AsLong()) * alphaOutline / 255),
static_cast<byte>(GetRValue(outline.AsLong()) * alphaOutline / 255),
static_cast<byte>(outline.GetBlue() * alphaFill / 255),
static_cast<byte>(outline.GetGreen() * alphaFill / 255),
static_cast<byte>(outline.GetRed() * alphaFill / 255),
static_cast<byte>(alphaOutline));
DWORD *pixels = static_cast<DWORD *>(image);
for (int y=0; y<height; y++) {

View File

@ -58,10 +58,8 @@ static const WCHAR *pDirListProp = L"DirListData";
//
BOOL DirList_Init(HWND hwnd,LPCWSTR pszHeader)
{
HIMAGELIST hil;
SHFILEINFO shfi;
LV_COLUMN lvc;
// Allocate DirListData Property
LPDLDATA lpdl = (LPVOID)GlobalAlloc(GPTR,sizeof(DLDATA));
@ -101,11 +99,7 @@ BOOL DirList_Init(HWND hwnd,LPCWSTR pszHeader)
lpdl->hExitThread = CreateEvent(NULL,TRUE,FALSE,NULL);
lpdl->hTerminatedThread = CreateEvent(NULL,TRUE,TRUE,NULL);
lvc;
pszHeader;
return TRUE;
}

View File

@ -1719,7 +1719,6 @@ void EditTitleCase(HWND hwnd)
UINT cpEdit;
int i;
BOOL bNewWord = TRUE;
BOOL bWordEnd = TRUE;
BOOL bChanged = FALSE;
#ifdef BOOKMARK_EDITION
@ -2207,6 +2206,7 @@ void EditHex2Char(HWND hwnd) {
if (SendMessage(hwnd,SCI_GETSELTEXT,0,0) <= COUNTOF(ch)) {
SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)ch);
ch[31] = '\0';
if (StrChrIA(ch,' ') || StrChrIA(ch,'\t') || StrChrIA(ch,'\r') || StrChrIA(ch,'\n') || StrChrIA(ch,'-'))
return;
@ -2262,13 +2262,14 @@ void EditModifyNumber(HWND hwnd,BOOL bIncrease) {
if (iSelEnd - iSelStart) {
char chFormat[32] = "";
char chNumber[32];
char chFormat[32] = { '\0' };
char chNumber[32] = { '\0' };
int iNumber;
int iWidth;
if (SendMessage(hwnd,SCI_GETSELTEXT,0,0) <= COUNTOF(chNumber)) {
SendMessage(hwnd,SCI_GETSELTEXT,0,(LPARAM)chNumber);
chNumber[31] = '\0';
if (StrChrIA(chNumber,'-'))
return;
@ -2397,7 +2398,7 @@ void EditTabsToSpaces(HWND hwnd,int nTabWidth,BOOL bOnlyIndentingWS)
for (iTextW = 0; iTextW < cchTextW; iTextW++)
{
WCHAR w = pszTextW[iTextW];
if (w == L'\t' && (!bOnlyIndentingWS || bOnlyIndentingWS && bIsLineStart)) {
if (w == L'\t' && (!bOnlyIndentingWS || bIsLineStart)) {
for (j = 0; j < nTabWidth - i % nTabWidth; j++)
pszConvW[cchConvW++] = L' ';
i = 0;
@ -2527,7 +2528,7 @@ void EditSpacesToTabs(HWND hwnd,int nTabWidth,BOOL bOnlyIndentingWS)
for (iTextW = 0; iTextW < cchTextW; iTextW++)
{
WCHAR w = pszTextW[iTextW];
if ((w == L' ' || w == L'\t') && (!bOnlyIndentingWS || bOnlyIndentingWS && bIsLineStart)) {
if ((w == L' ' || w == L'\t') && (!bOnlyIndentingWS || bIsLineStart)) {
space[j++] = w;
if (j == nTabWidth - i % nTabWidth || w == L'\t') {
if (j > 1 || pszTextW[iTextW+1] == L' ' || pszTextW[iTextW+1] == L'\t')
@ -2814,14 +2815,14 @@ void EditMoveDown(HWND hwnd)
//
void EditModifyLines(HWND hwnd,LPCWSTR pwszPrefix,LPCWSTR pwszAppend)
{
char mszPrefix1[256*3] = "";
char mszPrefix2[256*3] = "";
char mszPrefix1[256*3] = { '\0' };
char mszPrefix2[256*3] = { '\0' };
BOOL bPrefixNum = FALSE;
int iPrefixNum = 0;
int iPrefixNumWidth = 1;
char *pszPrefixNumPad = "";
char mszAppend1[256*3] = "";
char mszAppend2[256*3] = "";
char mszAppend1[256*3] = { '\0' };
char mszAppend2[256*3] = { '\0' };
BOOL bAppendNum = FALSE;
int iAppendNum = 0;
int iAppendNumWidth = 1;
@ -3168,7 +3169,7 @@ void EditAlignText(HWND hwnd,int nMode)
else {
char tchLineBuf[BUFSIZE_ALIGN*3] = "";
char tchLineBuf[BUFSIZE_ALIGN*3] = { '\0' };
WCHAR wchLineBuf[BUFSIZE_ALIGN*3] = L"";
WCHAR *pWords[BUFSIZE_ALIGN*3/2];
WCHAR *p = wchLineBuf;
@ -3361,8 +3362,8 @@ void EditAlignText(HWND hwnd,int nMode)
//
void EditEncloseSelection(HWND hwnd,LPCWSTR pwszOpen,LPCWSTR pwszClose)
{
char mszOpen[256*3] = "";
char mszClose[256*3] = "";
char mszOpen[256*3] = { '\0' };
char mszClose[256*3] = { '\0' };
int mbcp;
int iSelStart = (int)SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);
@ -3427,7 +3428,7 @@ void EditEncloseSelection(HWND hwnd,LPCWSTR pwszOpen,LPCWSTR pwszClose)
//
void EditToggleLineComments(HWND hwnd,LPCWSTR pwszComment,BOOL bInsertAtStart)
{
char mszComment[256*3] = "";
char mszComment[256*3] = { '\0' };
int cchComment;
int mbcp;
int iAction = 0;
@ -4745,7 +4746,7 @@ void EditEnsureSelectionVisible(HWND hwnd)
//
void EditGetExcerpt(HWND hwnd,LPWSTR lpszExcerpt,DWORD cchExcerpt)
{
WCHAR tch[256] = L"";
WCHAR tch[256] = { L'\0' };
WCHAR *p;
DWORD cch = 0;
UINT cpEdit;

View File

@ -1014,8 +1014,8 @@ void PathRelativeToApp(
//
void PathAbsoluteFromApp(LPWSTR lpszSrc,LPWSTR lpszDest,int cchDest,BOOL bExpandEnv) {
WCHAR wchPath[MAX_PATH];
WCHAR wchResult[MAX_PATH];
WCHAR wchPath[MAX_PATH] = { L'\0'};
WCHAR wchResult[MAX_PATH] = { L'\0'};
if (lpszSrc == NULL) {
ZeroMemory(lpszDest, (cchDest == 0) ? MAX_PATH : cchDest);
@ -1026,8 +1026,11 @@ void PathAbsoluteFromApp(LPWSTR lpszSrc,LPWSTR lpszDest,int cchDest,BOOL bExpand
SHGetFolderPath(NULL,CSIDL_PERSONAL,NULL,SHGFP_TYPE_CURRENT,wchPath);
PathAppend(wchPath,lpszSrc+CSTRLEN("%CSIDL:MYDOCUMENTS%"));
}
else
else {
if (lpszSrc) {
lstrcpyn(wchPath,lpszSrc,COUNTOF(wchPath));
}
}
if (bExpandEnv)
ExpandEnvironmentStringsEx(wchPath,COUNTOF(wchPath));

View File

@ -19,7 +19,8 @@ extern HINSTANCE g_hInstance;
extern UINT16 g_uWinVer;
#define COUNTOF(ar) (sizeof(ar)/sizeof(ar[0]))
#define UNUSED(expr) (void)(expr)
#define COUNTOF(ar) ARRAYSIZE(ar) //#define COUNTOF(ar) (sizeof(ar)/sizeof(ar[0]))
#define CSTRLEN(s) (COUNTOF(s)-1)

View File

@ -738,9 +738,6 @@ int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR lpCmdLine,int n
OleUninitialize();
return(int)(msg.wParam);
hPrevInst;
}
@ -2921,10 +2918,9 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
case IDM_EDIT_SWAP:
if (SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) -
SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0) == 0) {
int iNewPos = -1;
int iPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0);
SendMessage(hwndEdit,SCI_PASTE,0,0);
iNewPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0);
int iNewPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0);
SendMessage(hwndEdit,SCI_SETSEL,iPos,iNewPos);
SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_CLEARCLIPBOARD,1),0);
}

View File

@ -289,7 +289,7 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "Zoom &In\tCtrl++", IDM_VIEW_ZOOMIN
MENUITEM "Zoom &Out\tCtrl+-", IDM_VIEW_ZOOMOUT
MENUITEM "Reset &Zoom\tCtrl+/", IDM_VIEW_RESETZOOM
MENUITEM "Reset &Zoom\tCtrl+0", IDM_VIEW_RESETZOOM
END
POPUP "&Settings"
BEGIN
@ -305,7 +305,7 @@ BEGIN
MENUITEM "Sticky Window &Position", IDM_VIEW_STICKYWINPOS
MENUITEM "&Always On Top\tAlt+T", IDM_VIEW_ALWAYSONTOP
MENUITEM "Minimi&ze To Tray", IDM_VIEW_MINTOTRAY
MENUITEM "Transparent &Mode\tCtrl+0", IDM_VIEW_TRANSPARENT
MENUITEM "Transparent &Mode\tCtrl+Numpad_*", IDM_VIEW_TRANSPARENT
MENUITEM SEPARATOR
MENUITEM "Single &File Instance", IDM_VIEW_SINGLEFILEINSTANCE
MENUITEM "File &Change Notification...\tAlt+F5", IDM_VIEW_CHANGENOTIFY
@ -375,7 +375,7 @@ END
IDR_MAINWND ACCELERATORS
BEGIN
"0", IDM_VIEW_TRANSPARENT, VIRTKEY, CONTROL, NOINVERT
"0", IDM_VIEW_RESETZOOM, VIRTKEY, CONTROL, NOINVERT
"0", IDM_FILE_NEWWINDOW2, VIRTKEY, ALT, NOINVERT
"0", IDM_VIEW_WORDWRAPSYMBOLS, VIRTKEY, SHIFT, CONTROL, NOINVERT
"1", CMD_STRINGIFY, VIRTKEY, CONTROL, NOINVERT
@ -468,7 +468,6 @@ BEGIN
VK_DELETE, CMD_CTRLDEL, VIRTKEY, CONTROL, NOINVERT
VK_DELETE, IDM_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT
VK_DELETE, IDM_EDIT_DELETELINERIGHT, VIRTKEY, SHIFT, CONTROL, NOINVERT
VK_DIVIDE, IDM_VIEW_RESETZOOM, VIRTKEY, CONTROL, NOINVERT
VK_DOWN, IDM_EDIT_MOVELINEDOWN, VIRTKEY, SHIFT, CONTROL, NOINVERT
VK_ESCAPE, CMD_ESCAPE, VIRTKEY, NOINVERT
VK_ESCAPE, CMD_SHIFTESC, VIRTKEY, SHIFT, NOINVERT
@ -513,7 +512,12 @@ BEGIN
VK_F9, IDM_FILE_MANAGEFAV, VIRTKEY, ALT, NOINVERT
VK_F9, CMD_COPYPATHNAME, VIRTKEY, SHIFT, NOINVERT
VK_F9, IDM_EDIT_INSERT_PATHNAME, VIRTKEY, SHIFT, CONTROL, NOINVERT
VK_OEM_2, IDM_VIEW_RESETZOOM, VIRTKEY, CONTROL, NOINVERT
VK_OEM_2, IDM_EDIT_LINECOMMENT, VIRTKEY, CONTROL, NOINVERT
VK_OEM_2, IDM_EDIT_STREAMCOMMENT, VIRTKEY, SHIFT, CONTROL, NOINVERT
VK_DIVIDE, IDM_EDIT_LINECOMMENT, VIRTKEY, CONTROL, NOINVERT
VK_DIVIDE, IDM_EDIT_STREAMCOMMENT, VIRTKEY, SHIFT, CONTROL, NOINVERT
VK_NUMPAD0, IDM_VIEW_RESETZOOM, VIRTKEY, CONTROL, NOINVERT
VK_MULTIPLY, IDM_VIEW_TRANSPARENT, VIRTKEY, CONTROL, NOINVERT
VK_OEM_COMMA, CMD_JUMP2SELSTART, VIRTKEY, CONTROL, NOINVERT
VK_OEM_MINUS, IDM_VIEW_ZOOMOUT, VIRTKEY, CONTROL, NOINVERT
VK_OEM_MINUS, CMD_DECREASENUM, VIRTKEY, CONTROL, ALT, NOINVERT

View File

@ -2709,7 +2709,7 @@ void Style_Load()
// default scheme
iDefaultLexer = IniSectionGetInt(pIniSection,L"DefaultScheme",0);
iDefaultLexer = min(max(iDefaultLexer,0),NUMLEXERS-1);
iDefaultLexer = min(max(iDefaultLexer,0),COUNTOF(pLexArray)-1);
// auto select
bAutoSelect = (IniSectionGetInt(pIniSection,L"AutoSelect",1)) ? 1 : 0;
@ -2721,7 +2721,7 @@ void Style_Load()
cyStyleSelectDlg = IniSectionGetInt(pIniSection,L"SelectDlgSizeY",0);
cyStyleSelectDlg = max(cyStyleSelectDlg,324);
for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) {
for (iLexer = 0; iLexer < COUNTOF(pLexArray); iLexer++) {
LoadIniSection(pLexArray[iLexer]->pszName,pIniSection,cchIniSection);
if (!IniSectionGetString(pIniSection,L"FileNameExtensions",pLexArray[iLexer]->pszDefExt,
pLexArray[iLexer]->szExtensions,COUNTOF(pLexArray[iLexer]->szExtensions)))
@ -2783,7 +2783,7 @@ void Style_Save()
}
ZeroMemory(pIniSection,cchIniSection);
for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) {
for (iLexer = 0; iLexer < COUNTOF(pLexArray); iLexer++) {
IniSectionSetString(pIniSection,L"FileNameExtensions",pLexArray[iLexer]->szExtensions);
i = 0;
while (pLexArray[iLexer]->Styles[i].iStyle != -1) {
@ -2826,7 +2826,7 @@ BOOL Style_Import(HWND hwnd)
WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024);
int cchIniSection = (int)LocalSize(pIniSection)/sizeof(WCHAR);
for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) {
for (iLexer = 0; iLexer < COUNTOF(pLexArray); iLexer++) {
if (GetPrivateProfileSection(pLexArray[iLexer]->pszName,pIniSection,cchIniSection,szFile)) {
if (!IniSectionGetString(pIniSection,L"FileNameExtensions",pLexArray[iLexer]->pszDefExt,
pLexArray[iLexer]->szExtensions,COUNTOF(pLexArray[iLexer]->szExtensions)))
@ -2878,7 +2878,7 @@ BOOL Style_Export(HWND hwnd)
WCHAR *pIniSection = LocalAlloc(LPTR,sizeof(WCHAR)*32*1024);
int cchIniSection = (int)LocalSize(pIniSection)/sizeof(WCHAR);
for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) {
for (iLexer = 0; iLexer < COUNTOF(pLexArray); iLexer++) {
IniSectionSetString(pIniSection,L"FileNameExtensions",pLexArray[iLexer]->szExtensions);
i = 0;
while (pLexArray[iLexer]->Styles[i].iStyle != -1) {
@ -3418,7 +3418,7 @@ PEDITLEXER __fastcall Style_MatchLexer(LPCWSTR lpszMatch,BOOL bCheckNames)
if (!bCheckNames) {
for (i = 0; i < NUMLEXERS; i++) {
for (i = 0; i < COUNTOF(pLexArray); i++) {
ZeroMemory(tch,sizeof(WCHAR)*COUNTOF(tch));
lstrcpy(tch,pLexArray[i]->szExtensions);
@ -3441,7 +3441,7 @@ PEDITLEXER __fastcall Style_MatchLexer(LPCWSTR lpszMatch,BOOL bCheckNames)
int cch = lstrlen(lpszMatch);
if (cch >= 3) {
for (i = 0; i < NUMLEXERS; i++) {
for (i = 0; i < COUNTOF(pLexArray); i++) {
if (StrCmpNI(pLexArray[i]->pszName,lpszMatch,cch) == 0)
return(pLexArray[i]);
}
@ -3625,7 +3625,7 @@ void Style_SetXMLLexer(HWND hwnd)
//
void Style_SetLexerFromID(HWND hwnd,int id)
{
if (id >= 0 && id < NUMLEXERS) {
if (id >= 0 && id < COUNTOF(pLexArray)) {
Style_SetLexer(hwnd,pLexArray[id]);
}
}
@ -4448,7 +4448,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP
SHGFI_SMALLICON | SHGFI_SYSICONINDEX),TVSIL_NORMAL);
// Add lexers
for (i = 0; i < NUMLEXERS; i++)
for (i = 0; i < COUNTOF(pLexArray); i++)
{
if (!found && lstrcmp(pLexArray[i]->pszName,pLexCurrent->pszName) == 0)
{
@ -4959,7 +4959,7 @@ void Style_ConfigDlg(HWND hwnd)
// Backup Styles
c = 0;
for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) {
for (iLexer = 0; iLexer < COUNTOF(pLexArray); iLexer++) {
StyleBackup[c++] = StrDup(pLexArray[iLexer]->szExtensions);
i = 0;
while (pLexArray[iLexer]->Styles[i].iStyle != -1) {
@ -4976,7 +4976,7 @@ void Style_ConfigDlg(HWND hwnd)
{
// Restore Styles
c = 0;
for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) {
for (iLexer = 0; iLexer < COUNTOF(pLexArray); iLexer++) {
lstrcpy(pLexArray[iLexer]->szExtensions,StyleBackup[c++]);
i = 0;
while (pLexArray[iLexer]->Styles[i].iStyle != -1) {
@ -5075,7 +5075,7 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR
ListView_InsertColumn(hwndLV,0,&lvc);
// Add lexers
for (i = 0; i < NUMLEXERS; i++)
for (i = 0; i < COUNTOF(pLexArray); i++)
Style_AddLexerToListView(hwndLV,pLexArray[i]);
ListView_SetColumnWidth(hwndLV,0,LVSCW_AUTOSIZE_USEHEADER);

View File

@ -31,7 +31,7 @@ typedef struct _editstyle
typedef struct _keywordlist
{
char *pszKeyWords[9];
char *pszKeyWords[KEYWORDSET_MAX + 1];
} KEYWORDLIST, *PKEYWORDLIST;