Skip to content

Commit

Permalink
Merge pull request #6 from young-developer/develop
Browse files Browse the repository at this point in the history
Fix loading crash. New version 1.12.3
  • Loading branch information
Oleksii Maryshchenko committed Jan 9, 2018
2 parents 9354fee + f2f2040 commit 83d1888
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 38 deletions.
22 changes: 11 additions & 11 deletions src/DockingFeature/NavigateTo.rc
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSM
CAPTION "About NavigateTo"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
LTEXT "Navigate To v.1.12.2",IDC_STATIC_TEXT,7,7,124,8
LTEXT "Author: Oleksii Maryshchenko",IDC_STATIC_TEXT,7,29,137,8
LTEXT "young_developer@mail.ru",IDC_STATIC_TEXT,8,39,89,8
LTEXT "2018",IDC_STATIC_TEXT,182,51,19,8
LTEXT "omaryshchenko.info",IDC_STATIC_TEXT2,8,49,89,8
LTEXT "Navigate To v.1.12.3",IDC_STATIC_TEXT,7,7,124,8
LTEXT "Author: Oleksii Maryshchenko",IDC_STATIC_TEXT+1,7,29,137,8
LTEXT "young_developer@mail.ru",IDC_STATIC_TEXT+2B,8,39,89,8
LTEXT "2018",IDC_STATIC_TEXT+3,182,51,19,8
LTEXT "omaryshchenko.info",IDC_STATIC_TEXT2+4,8,49,89,8
END


Expand All @@ -43,8 +43,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,12,2,0
PRODUCTVERSION 1,12,2,0
FILEVERSION 1,12,3,0
PRODUCTVERSION 1,12,3,0
FILEFLAGSMASK 0x37L
#ifdef _DEBUG
FILEFLAGS 0x21L
Expand All @@ -59,15 +59,15 @@ BEGIN
BEGIN
BLOCK "080904b0"
BEGIN
VALUE "Comments", "Latest Source available from https://github.com/young-developer/nppNavigateTo"
VALUE "Comments", "Latest Sources available - https://github.com/young-developer/nppNavigateTo"
VALUE "CompanyName", "Oleksii Maryshchenko"
VALUE "FileDescription", "Notepad++ File NavigateTO : a free (GPL) source code file NavigateTo"
VALUE "FileVersion", "1, 12, 2, 0"
VALUE "FileVersion", "1, 12, 3, 0"
VALUE "InternalName", "NavigateTo"
VALUE "LegalCopyright", "Copyright (C) 2017 Oleksii Maryshchenko"
VALUE "LegalCopyright", "Copyright (C) 2018 Oleksii Maryshchenko"
VALUE "OriginalFilename", "NavigateTo.dll"
VALUE "ProductName", "NavigateTo plugin"
VALUE "ProductVersion", "1, 12, 2, 0"
VALUE "ProductVersion", "1, 12, 3, 0"
VALUE "SpecialBuild", "UNICODE"
END
END
Expand Down
97 changes: 73 additions & 24 deletions src/DockingFeature/NavigateToDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,24 @@ LRESULT CALLBACK ComboProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);

bool isDropDownOpened = false;

std::string GetErrorAsString(DWORD errorMessageID)
{
//Get the error message, if any.
if (errorMessageID == 0)
return std::string(); //No error message has been recorded

LPSTR messageBuffer = nullptr;
size_t size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, errorMessageID, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&messageBuffer, 0, NULL);

std::string message(messageBuffer, size);

//Free the buffer.
LocalFree(messageBuffer);

return message;
}

void moveSelectionUp(BOOL wrap)
{

Expand Down Expand Up @@ -428,28 +446,34 @@ INT_PTR CALLBACK NavigateToDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM

_winMgr.CalcLayout(_hSelf);
_winMgr.SetWindowPositions(_hSelf);
if (NULL != hwndListView)
{
RECT rc;
GetClientRect(hwndListView, &rc);
LONG width = rc.right - rc.left;
LVCOLUMN LvCol;
memset(&LvCol, 0, sizeof(LvCol)); // Zero Members
LvCol.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; // Type of mask
LvCol.cx = static_cast<LONG>(width*0.4); // width between each coloum
LvCol.pszText = TEXT("Name"); // First Header Text
::SendMessage(hwndListView, LVM_SETEXTENDEDLISTVIEWSTYLE, WPARAM(0), LVS_EX_FULLROWSELECT); // Set style
::SendMessage(hwndListView, LVM_INSERTCOLUMN, NAME_COLUMN, (LPARAM)&LvCol); // Insert/Show the coloum
LvCol.pszText = TEXT("Path");
LvCol.cx = static_cast<LONG>(width*0.6); // width of column
SendMessage(hwndListView, LVM_INSERTCOLUMN, PATH_COLUMN, (LPARAM)&LvCol); // ...

SendMessage(hwndGoLineEdit, CB_SETMINVISIBLE, 8, 0); // Visible items = 8
//ListView_SetExtendedListViewStyle(hwndListView,LVS_EX_HEADERDRAGDROP); //now we can drag&drop headers :)
refreshResultsList();
goToCenter();
fitColumnsToSize();
SetFocus(hwndListView);
}
else
{
nppManager->showMessageBox(TEXT("init dialog list is nullpointer"));
}

RECT rc;
GetClientRect(hwndListView, &rc);
LONG width = rc.right - rc.left;

LVCOLUMN LvCol;
memset(&LvCol,0,sizeof(LvCol)); // Zero Members
LvCol.mask=LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; // Type of mask
LvCol.cx=static_cast<LONG>(width*0.4); // width between each coloum
LvCol.pszText=TEXT("Name"); // First Header Text
::SendMessage(hwndListView,LVM_SETEXTENDEDLISTVIEWSTYLE, WPARAM(0),LVS_EX_FULLROWSELECT); // Set style
::SendMessage(hwndListView,LVM_INSERTCOLUMN,NAME_COLUMN,(LPARAM)&LvCol); // Insert/Show the coloum
LvCol.pszText=TEXT("Path");
LvCol.cx=static_cast<LONG>(width*0.6); // width of column
SendMessage(hwndListView,LVM_INSERTCOLUMN,PATH_COLUMN,(LPARAM)&LvCol); // ...

SendMessage(hwndGoLineEdit,CB_SETMINVISIBLE,8,0); // Visible items = 8
//ListView_SetExtendedListViewStyle(hwndListView,LVS_EX_HEADERDRAGDROP); //now we can drag&drop headers :)
refreshResultsList();
goToCenter();
fitColumnsToSize();
SetFocus(hwndListView);
return SizeableDlg::run_dlgProc(message, wParam, lParam);
}
break;
Expand Down Expand Up @@ -986,9 +1010,31 @@ void NavigateToDlg::addFileToListView(const File& file)
lis.iItem = 0;
lis.cchTextMax = MAX_PATH;
lis.iSubItem = 0;
lis.mask = LVIF_TEXT | LVIF_PARAM;
lis.mask = LVIF_PARAM;
lis.lParam = (LPARAM)&fileList[file.getBufferId()];
SendMessage(hwndListView,LVM_INSERTITEM,0,(LPARAM)&lis);// Send info to the Listview
lis.pszText = TEXT("empty");
try
{
if (_hSelf != NULL)
{
ghwndListView = ::GetDlgItem(_hSelf, IDC_RESULTS_LIST);
if (ghwndListView == NULL)
throw GetLastError();
int indexOfNewItem = SendMessage(ghwndListView, LVM_INSERTITEM, 0, (LPARAM)&lis);// Send info to the Listview
if (indexOfNewItem == -1)
throw GetLastError();
}
else
throw GetLastError();
}
catch (DWORD aCause)
{
if (!GetErrorAsString(aCause).empty())
{
std::string error = GetErrorAsString(aCause).append(" Could not add file ");
nppManager->showMessageBox(NppManager::strToWStr(error).append(fileList[file.getBufferId()].getFileName()), TEXT("Exception"));
}
}
}
}

Expand Down Expand Up @@ -1124,11 +1170,14 @@ void NavigateToDlg::updateCurrentFileStatus(FileStatus status)

void NavigateToDlg::beNotified(SCNotification *notifyCode)
{
if (_hSelf == NULL)
return;

switch (notifyCode->nmhdr.code)
{
case NPPN_FILEOPENED:
case NPPN_FILERENAMED:
addFileToListView(notifyCode->nmhdr.idFrom);
addFileToListView(notifyCode->nmhdr.idFrom);
if(isVisible())
refreshResultsList(false);
break;
Expand Down
4 changes: 2 additions & 2 deletions src/NppManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ NppManager::~NppManager(void)
{
}

void NppManager::showMessageBox(const std::wstring& text)
void NppManager::showMessageBox(const std::wstring& text, const std::wstring &msgTitle)
{
::MessageBox(nppData._nppHandle, text.c_str() , TEXT("Info"), MB_OK);
::MessageBox(nppData._nppHandle, text.c_str(), msgTitle.c_str(), MB_OK);
}

bool NppManager::switchToFile(const File* file)
Expand Down
2 changes: 1 addition & 1 deletion src/NppManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class NppManager
bool switchToFile(const File* file);
bool switchToFile(const int index, const int view);
bool openContextMenu(const int index, const int view);
void showMessageBox(const std::wstring& text);
void showMessageBox(const std::wstring& text, const std::wstring &msgTitle = TEXT("Info"));
int getBufferIdByFilePath(const std::wstring& filePath);
int getIndexByFilePath(const std::wstring& filePath);
HWND getCurrentHScintilla(int which);
Expand Down

0 comments on commit 83d1888

Please sign in to comment.