parent
c4ff9f76a3
commit
3546268c23
|
@ -1995,7 +1995,7 @@ void Notepad_plus::checkDocState()
|
||||||
}
|
}
|
||||||
|
|
||||||
enableCommand(IDM_FILE_DELETE, isFileExisting, MENU);
|
enableCommand(IDM_FILE_DELETE, isFileExisting, MENU);
|
||||||
enableCommand(IDM_FILE_RENAME, isFileExisting, MENU);
|
//enableCommand(IDM_FILE_RENAME, isFileExisting, MENU);
|
||||||
enableCommand(IDM_FILE_OPEN_CMD, isFileExisting, MENU);
|
enableCommand(IDM_FILE_OPEN_CMD, isFileExisting, MENU);
|
||||||
enableCommand(IDM_FILE_OPEN_FOLDER, isFileExisting, MENU);
|
enableCommand(IDM_FILE_OPEN_FOLDER, isFileExisting, MENU);
|
||||||
enableCommand(IDM_FILE_RELOAD, isFileExisting, MENU);
|
enableCommand(IDM_FILE_RELOAD, isFileExisting, MENU);
|
||||||
|
|
|
@ -1404,17 +1404,52 @@ bool Notepad_plus::fileRename(BufferID id)
|
||||||
scnN.nmhdr.idFrom = (uptr_t)bufferID;
|
scnN.nmhdr.idFrom = (uptr_t)bufferID;
|
||||||
_pluginsManager.notify(&scnN);
|
_pluginsManager.notify(&scnN);
|
||||||
|
|
||||||
FileDialog fDlg(_pPublicInterface->getHSelf(), _pPublicInterface->getHinst());
|
|
||||||
|
|
||||||
fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL);
|
|
||||||
setFileOpenSaveDlgFilters(fDlg);
|
|
||||||
|
|
||||||
fDlg.setDefFileName(buf->getFileName());
|
|
||||||
TCHAR *pfn = fDlg.doSaveDlg();
|
|
||||||
|
|
||||||
bool success = false;
|
bool success = false;
|
||||||
if (pfn)
|
bool isFileExisting = PathFileExists(buf->getFullPathName()) != FALSE;
|
||||||
success = MainFileManager->moveFile(bufferID, pfn);
|
if (isFileExisting)
|
||||||
|
{
|
||||||
|
FileDialog fDlg(_pPublicInterface->getHSelf(), _pPublicInterface->getHinst());
|
||||||
|
|
||||||
|
fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL);
|
||||||
|
setFileOpenSaveDlgFilters(fDlg);
|
||||||
|
|
||||||
|
fDlg.setDefFileName(buf->getFileName());
|
||||||
|
TCHAR *pfn = fDlg.doSaveDlg();
|
||||||
|
|
||||||
|
if (pfn)
|
||||||
|
success = MainFileManager->moveFile(bufferID, pfn);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// We are just going to rename the tab nothing else
|
||||||
|
// So just rename the tab and rename the backup file too if applicable
|
||||||
|
|
||||||
|
StringDlg strDlg;
|
||||||
|
strDlg.init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), TEXT("Rename Current Tab"), TEXT("New Name : "), buf->getFileName(), 0, true);
|
||||||
|
|
||||||
|
TCHAR *tabNewName = reinterpret_cast<TCHAR *>(strDlg.doDialog());
|
||||||
|
if (tabNewName)
|
||||||
|
{
|
||||||
|
success = true;
|
||||||
|
buf->setFileName(tabNewName);
|
||||||
|
bool isSnapshotMode = NppParameters::getInstance()->getNppGUI().isSnapshotMode();
|
||||||
|
if (isSnapshotMode)
|
||||||
|
{
|
||||||
|
generic_string oldBackUpFile = buf->getBackupFileName();
|
||||||
|
|
||||||
|
// Change the backup file name and let MainFileManager decide the new filename
|
||||||
|
buf->setBackupFileName(TEXT(""));
|
||||||
|
|
||||||
|
// Create new backup
|
||||||
|
buf->setModifiedStatus(true);
|
||||||
|
bool bRes = MainFileManager->backupCurrentBuffer();
|
||||||
|
|
||||||
|
// Delete old backup
|
||||||
|
if (bRes)
|
||||||
|
::DeleteFile(oldBackUpFile.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
scnN.nmhdr.code = success ? NPPN_FILERENAMED : NPPN_FILERENAMECANCEL;
|
scnN.nmhdr.code = success ? NPPN_FILERENAMED : NPPN_FILERENAMECANCEL;
|
||||||
_pluginsManager.notify(&scnN);
|
_pluginsManager.notify(&scnN);
|
||||||
|
|
|
@ -564,7 +564,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
||||||
|
|
||||||
bool isFileExisting = PathFileExists(buf->getFullPathName()) != FALSE;
|
bool isFileExisting = PathFileExists(buf->getFullPathName()) != FALSE;
|
||||||
_tabPopupMenu.enableItem(IDM_FILE_DELETE, isFileExisting);
|
_tabPopupMenu.enableItem(IDM_FILE_DELETE, isFileExisting);
|
||||||
_tabPopupMenu.enableItem(IDM_FILE_RENAME, isFileExisting);
|
//_tabPopupMenu.enableItem(IDM_FILE_RENAME, isFileExisting);
|
||||||
_tabPopupMenu.enableItem(IDM_FILE_OPEN_FOLDER, isFileExisting);
|
_tabPopupMenu.enableItem(IDM_FILE_OPEN_FOLDER, isFileExisting);
|
||||||
_tabPopupMenu.enableItem(IDM_FILE_OPEN_CMD, isFileExisting);
|
_tabPopupMenu.enableItem(IDM_FILE_OPEN_CMD, isFileExisting);
|
||||||
|
|
||||||
|
|
|
@ -1449,7 +1449,10 @@ INT_PTR CALLBACK StringDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
|
||||||
if (_txtLen)
|
if (_txtLen)
|
||||||
::SendDlgItemMessage(_hSelf, IDC_STRING_EDIT, EM_SETLIMITTEXT, _txtLen, 0);
|
::SendDlgItemMessage(_hSelf, IDC_STRING_EDIT, EM_SETLIMITTEXT, _txtLen, 0);
|
||||||
|
|
||||||
return TRUE;
|
if (_shouldGotoCenter)
|
||||||
|
goToCenter();
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_COMMAND :
|
case WM_COMMAND :
|
||||||
|
|
|
@ -399,13 +399,14 @@ class StringDlg : public StaticDialog
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
StringDlg() : StaticDialog() {};
|
StringDlg() : StaticDialog() {};
|
||||||
void init(HINSTANCE hInst, HWND parent, const TCHAR *title, const TCHAR *staticName, const TCHAR *text2Set, int txtLen = 0) {
|
void init(HINSTANCE hInst, HWND parent, const TCHAR *title, const TCHAR *staticName, const TCHAR *text2Set, int txtLen = 0, bool bGotoCenter = false) {
|
||||||
Window::init(hInst, parent);
|
Window::init(hInst, parent);
|
||||||
_title = title;
|
_title = title;
|
||||||
_static = staticName;
|
_static = staticName;
|
||||||
_textValue = text2Set;
|
_textValue = text2Set;
|
||||||
_txtLen = txtLen;
|
_txtLen = txtLen;
|
||||||
};
|
_shouldGotoCenter = bGotoCenter;
|
||||||
|
};
|
||||||
|
|
||||||
INT_PTR doDialog() {
|
INT_PTR doDialog() {
|
||||||
return ::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_STRING_DLG), _hParent, dlgProc, reinterpret_cast<LPARAM>(this));
|
return ::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_STRING_DLG), _hParent, dlgProc, reinterpret_cast<LPARAM>(this));
|
||||||
|
@ -421,6 +422,7 @@ private :
|
||||||
generic_string _textValue;
|
generic_string _textValue;
|
||||||
generic_string _static;
|
generic_string _static;
|
||||||
int _txtLen = 0;
|
int _txtLen = 0;
|
||||||
|
bool _shouldGotoCenter = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class StylerDlg
|
class StylerDlg
|
||||||
|
|
Loading…
Reference in New Issue