Add new API NPPM_SAVEFILE to save any file.
Close #1214, closes #817 This API saves a file without having to actually focus on the file. // VOID NPPM_SAVEFILE(0, const TCHAR *fileNameToSave)
This commit is contained in:
parent
1c84051d99
commit
624e5fa1ae
@ -413,6 +413,9 @@ enum winVer{ WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, W
|
||||
#define NPPM_SETEDITORBORDEREDGE (NPPMSG + 93)
|
||||
// VOID NPPM_SETEDITORBORDEREDGE(0, BOOL withEditorBorderEdgeOrNot)
|
||||
|
||||
#define NPPM_SAVEFILE (NPPMSG + 94)
|
||||
// VOID NPPM_SAVEFILE(0, const TCHAR *fileNameToSave)
|
||||
|
||||
#define RUNCOMMAND_USER (WM_USER + 3000)
|
||||
#define NPPM_GETFULLCURRENTPATH (RUNCOMMAND_USER + FULL_CURRENT_PATH)
|
||||
#define NPPM_GETCURRENTDIRECTORY (RUNCOMMAND_USER + CURRENT_DIRECTORY)
|
||||
|
@ -240,6 +240,7 @@ public:
|
||||
bool fileCloseAllToRight();
|
||||
bool fileSave(BufferID id = BUFFER_INVALID);
|
||||
bool fileSaveAll();
|
||||
bool fileSaveSpecific(const generic_string& fileNameToSave);
|
||||
bool fileSaveAs(BufferID id = BUFFER_INVALID, bool isSaveCopy = false);
|
||||
bool fileDelete(BufferID id = BUFFER_INVALID);
|
||||
bool fileRename(BufferID id = BUFFER_INVALID);
|
||||
|
@ -406,6 +406,11 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
||||
return fileSaveAll();
|
||||
}
|
||||
|
||||
case NPPM_SAVEFILE:
|
||||
{
|
||||
return fileSaveSpecific((const TCHAR *)lParam);
|
||||
}
|
||||
|
||||
case NPPM_GETCURRENTNATIVELANGENCODING:
|
||||
{
|
||||
return _nativeLangSpeaker.getLangEncoding();
|
||||
|
@ -1125,6 +1125,27 @@ bool Notepad_plus::fileSave(BufferID id)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Notepad_plus::fileSaveSpecific(const generic_string& fileNameToSave)
|
||||
{
|
||||
BufferID idToSave = _mainDocTab.findBufferByName(fileNameToSave.c_str());
|
||||
if (idToSave == BUFFER_INVALID)
|
||||
{
|
||||
idToSave = _subDocTab.findBufferByName(fileNameToSave.c_str());
|
||||
}
|
||||
//do not use else syntax, id might be taken from sub doc tab,
|
||||
//in which case fileSave needs to be executed also
|
||||
if (idToSave != BUFFER_INVALID)
|
||||
{
|
||||
fileSave(idToSave);
|
||||
checkDocState();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Notepad_plus::fileSaveAll() {
|
||||
if (viewVisible(MAIN_VIEW)) {
|
||||
for(int i = 0; i < _mainDocTab.nbItem(); ++i) {
|
||||
|
Loading…
Reference in New Issue
Block a user