[NEW_FEATURE] Add "Save Copy As" feature.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@199 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
b177e060bc
commit
fd437c9c7d
@ -940,7 +940,7 @@ bool Notepad_plus::doReload(const char *fileName, bool alert)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Notepad_plus::doSave(const char *filename, UniMode mode)
|
bool Notepad_plus::doSave(const char *filename, UniMode mode, bool isCopy)
|
||||||
{
|
{
|
||||||
bool isHidden = false;
|
bool isHidden = false;
|
||||||
bool isSys = false;
|
bool isSys = false;
|
||||||
@ -974,13 +974,16 @@ bool Notepad_plus::doSave(const char *filename, UniMode mode)
|
|||||||
|
|
||||||
if (fp)
|
if (fp)
|
||||||
{
|
{
|
||||||
// Notify plugins that current file is about to be saved
|
|
||||||
SCNotification scnN;
|
SCNotification scnN;
|
||||||
|
// Notify plugins that current file is about to be saved
|
||||||
|
if (!isCopy)
|
||||||
|
{
|
||||||
|
|
||||||
scnN.nmhdr.code = NPPN_FILEBEFORESAVE;
|
scnN.nmhdr.code = NPPN_FILEBEFORESAVE;
|
||||||
scnN.nmhdr.hwndFrom = _hSelf;
|
scnN.nmhdr.hwndFrom = _hSelf;
|
||||||
scnN.nmhdr.idFrom = 0;
|
scnN.nmhdr.idFrom = 0;
|
||||||
_pluginsManager.notify(&scnN);
|
_pluginsManager.notify(&scnN);
|
||||||
|
}
|
||||||
char data[blockSize + 1];
|
char data[blockSize + 1];
|
||||||
int lengthDoc = _pEditView->getCurrentDocLen();
|
int lengthDoc = _pEditView->getCurrentDocLen();
|
||||||
for (int i = 0; i < lengthDoc; i += blockSize)
|
for (int i = 0; i < lengthDoc; i += blockSize)
|
||||||
@ -994,17 +997,20 @@ bool Notepad_plus::doSave(const char *filename, UniMode mode)
|
|||||||
}
|
}
|
||||||
UnicodeConvertor.fclose();
|
UnicodeConvertor.fclose();
|
||||||
|
|
||||||
_pEditView->updateCurrentBufTimeStamp();
|
|
||||||
_pEditView->execute(SCI_SETSAVEPOINT);
|
|
||||||
|
|
||||||
if (isHidden)
|
if (isHidden)
|
||||||
::SetFileAttributes(filename, attrib | FILE_ATTRIBUTE_HIDDEN);
|
::SetFileAttributes(filename, attrib | FILE_ATTRIBUTE_HIDDEN);
|
||||||
|
|
||||||
if (isSys)
|
if (isSys)
|
||||||
::SetFileAttributes(filename, attrib | FILE_ATTRIBUTE_SYSTEM);
|
::SetFileAttributes(filename, attrib | FILE_ATTRIBUTE_SYSTEM);
|
||||||
|
|
||||||
|
if (!isCopy)
|
||||||
|
{
|
||||||
|
_pEditView->updateCurrentBufTimeStamp();
|
||||||
|
_pEditView->execute(SCI_SETSAVEPOINT);
|
||||||
|
|
||||||
scnN.nmhdr.code = NPPN_FILESAVED;
|
scnN.nmhdr.code = NPPN_FILESAVED;
|
||||||
_pluginsManager.notify(&scnN);
|
_pluginsManager.notify(&scnN);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
::MessageBox(_hSelf, "Please check whether if this file is opened in another program", "Save failed", MB_OK);
|
::MessageBox(_hSelf, "Please check whether if this file is opened in another program", "Save failed", MB_OK);
|
||||||
@ -1397,7 +1403,7 @@ bool Notepad_plus::findInOpenedFiles() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Notepad_plus::fileSaveAs()
|
bool Notepad_plus::fileSaveAs(bool isSaveCopy)
|
||||||
{
|
{
|
||||||
FileDialog fDlg(_hSelf, _hInst);
|
FileDialog fDlg(_hSelf, _hInst);
|
||||||
|
|
||||||
@ -1418,13 +1424,16 @@ bool Notepad_plus::fileSaveAs()
|
|||||||
int i = _pEditView->findDocIndexByName(pfn);
|
int i = _pEditView->findDocIndexByName(pfn);
|
||||||
if ((i == -1) || (i == currentDocIndex))
|
if ((i == -1) || (i == currentDocIndex))
|
||||||
{
|
{
|
||||||
doSave(pfn, _pEditView->getCurrentBuffer().getUnicodeMode());
|
doSave(pfn, _pEditView->getCurrentBuffer().getUnicodeMode(), isSaveCopy);
|
||||||
|
if (!isSaveCopy)
|
||||||
|
{
|
||||||
_pEditView->setCurrentTitle(pfn);
|
_pEditView->setCurrentTitle(pfn);
|
||||||
_pEditView->setCurrentDocReadOnly(false);
|
_pEditView->setCurrentDocReadOnly(false);
|
||||||
_pDocTab->updateCurrentTabItem(PathFindFileName(pfn));
|
_pDocTab->updateCurrentTabItem(PathFindFileName(pfn));
|
||||||
setTitleWith(pfn);
|
setTitleWith(pfn);
|
||||||
setLangStatus(_pEditView->getCurrentDocType());
|
setLangStatus(_pEditView->getCurrentDocType());
|
||||||
checkLangsMenu(-1);
|
checkLangsMenu(-1);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2652,6 +2661,10 @@ void Notepad_plus::command(int id)
|
|||||||
fileSaveAs();
|
fileSaveAs();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case IDM_FILE_SAVECOPYAS :
|
||||||
|
fileSaveAs(true);
|
||||||
|
break;
|
||||||
|
|
||||||
case IDM_FILE_LOADSESSION:
|
case IDM_FILE_LOADSESSION:
|
||||||
fileLoadSession();
|
fileLoadSession();
|
||||||
break;
|
break;
|
||||||
|
@ -117,9 +117,9 @@ public:
|
|||||||
bool fileCloseAllButCurrent();
|
bool fileCloseAllButCurrent();
|
||||||
bool fileSave();
|
bool fileSave();
|
||||||
bool fileSaveAll();
|
bool fileSaveAll();
|
||||||
bool fileSaveAs();
|
bool fileSaveAs(bool isSaveCopy = false);
|
||||||
|
|
||||||
bool doSave(const char *filename, UniMode mode);
|
bool doSave(const char *filename, UniMode mode, bool isSaveCopy = false);
|
||||||
// end fileOperation
|
// end fileOperation
|
||||||
|
|
||||||
void filePrint(bool showDialog);
|
void filePrint(bool showDialog);
|
||||||
|
@ -249,6 +249,7 @@ BEGIN
|
|||||||
MENUITEM "Re&load from disk", IDM_FILE_RELOAD
|
MENUITEM "Re&load from disk", IDM_FILE_RELOAD
|
||||||
MENUITEM "&Save", IDM_FILE_SAVE
|
MENUITEM "&Save", IDM_FILE_SAVE
|
||||||
MENUITEM "Save &As...", IDM_FILE_SAVEAS
|
MENUITEM "Save &As...", IDM_FILE_SAVEAS
|
||||||
|
MENUITEM "Save Copy As...", IDM_FILE_SAVECOPYAS
|
||||||
MENUITEM "Sav&e All", IDM_FILE_SAVEALL
|
MENUITEM "Sav&e All", IDM_FILE_SAVEALL
|
||||||
MENUITEM "&Close", IDM_FILE_CLOSE
|
MENUITEM "&Close", IDM_FILE_CLOSE
|
||||||
MENUITEM "Cl&ose All", IDM_FILE_CLOSEALL
|
MENUITEM "Cl&ose All", IDM_FILE_CLOSEALL
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#define IDM_FILE_LOADSESSION (IDM_FILE + 12)
|
#define IDM_FILE_LOADSESSION (IDM_FILE + 12)
|
||||||
#define IDM_FILE_SAVESESSION (IDM_FILE + 13)
|
#define IDM_FILE_SAVESESSION (IDM_FILE + 13)
|
||||||
#define IDM_FILE_RELOAD (IDM_FILE + 14)
|
#define IDM_FILE_RELOAD (IDM_FILE + 14)
|
||||||
|
#define IDM_FILE_SAVECOPYAS (IDM_FILE + 15)
|
||||||
|
|
||||||
// A mettre à jour si on ajoute nouveau menu item dans le menu "File"
|
// A mettre à jour si on ajoute nouveau menu item dans le menu "File"
|
||||||
#define IDM_FILEMENU_LASTONE IDM_FILE_RELOAD
|
#define IDM_FILEMENU_LASTONE IDM_FILE_RELOAD
|
||||||
|
Loading…
Reference in New Issue
Block a user