Make open 64 bits file possible

ref:
https://github.com/notepad-plus-plus/notepad-plus-plus/pull/11047#issuecomment-1019387562
This commit is contained in:
Don Ho 2022-01-25 03:40:10 +01:00
parent 23b8b3edf6
commit f4c777e576
2 changed files with 16 additions and 10 deletions

View File

@ -88,15 +88,15 @@ intptr_t CALLBACK GoToLineDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
case IDOK : case IDOK :
{ {
int line = getLine(); long long line = getLine();
if (line != -1) if (line != -1)
{ {
display(false); display(false);
cleanLineEdit(); cleanLineEdit();
if (_mode == go2line) if (_mode == go2line)
{ {
(*_ppEditView)->execute(SCI_ENSUREVISIBLE, line-1); (*_ppEditView)->execute(SCI_ENSUREVISIBLE, static_cast<WPARAM>(line - 1));
(*_ppEditView)->execute(SCI_GOTOLINE, line-1); (*_ppEditView)->execute(SCI_GOTOLINE, static_cast<WPARAM>(line - 1));
} }
else else
{ {
@ -105,7 +105,7 @@ intptr_t CALLBACK GoToLineDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
{ {
// make sure not jumping into the middle of a multibyte character // make sure not jumping into the middle of a multibyte character
// or into the middle of a CR/LF pair for Windows files // or into the middle of a CR/LF pair for Windows files
auto before = (*_ppEditView)->execute(SCI_POSITIONBEFORE, line); auto before = (*_ppEditView)->execute(SCI_POSITIONBEFORE, static_cast<WPARAM>(line));
posToGoto = (*_ppEditView)->execute(SCI_POSITIONAFTER, before); posToGoto = (*_ppEditView)->execute(SCI_POSITIONAFTER, before);
} }
auto sci_line = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, posToGoto); auto sci_line = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, posToGoto);
@ -185,6 +185,8 @@ void GoToLineDlg::updateLinesNumbers() const
size_t currentDocLength = (*_ppEditView)->getCurrentDocLen(); size_t currentDocLength = (*_ppEditView)->getCurrentDocLen();
limit = (currentDocLength > 0 ? currentDocLength - 1 : 0); limit = (currentDocLength > 0 ? currentDocLength - 1 : 0);
} }
::SetDlgItemInt(_hSelf, ID_CURRLINE, (UINT)current, FALSE);
::SetDlgItemInt(_hSelf, ID_LASTLINE, (UINT)limit, FALSE);
::SetDlgItemTextA(_hSelf, ID_CURRLINE, std::to_string(current).c_str());
::SetDlgItemTextA(_hSelf, ID_LASTLINE, std::to_string(limit).c_str());
} }

View File

@ -61,10 +61,14 @@ private :
::SetDlgItemText(_hSelf, ID_GOLINE_EDIT, TEXT("")); ::SetDlgItemText(_hSelf, ID_GOLINE_EDIT, TEXT(""));
}; };
int getLine() const { long long getLine() const {
BOOL isSuccessful; const int maxLen = 256;
int line = ::GetDlgItemInt(_hSelf, ID_GOLINE_EDIT, &isSuccessful, FALSE); char goLineEditStr[maxLen] = {'\0'};
return (isSuccessful?line:-1); UINT count = ::GetDlgItemTextA(_hSelf, ID_GOLINE_EDIT, goLineEditStr, maxLen);
if (!count)
return -1;
char* p_end;
return strtoll(goLineEditStr, &p_end, 10);
}; };
}; };