Skip to content

Instantly share code, notes, and snippets.

@Infocatcher
Last active December 20, 2015 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Infocatcher/6200149 to your computer and use it in GitHub Desktop.
Save Infocatcher/6200149 to your computer and use it in GitHub Desktop.
AkelPad: delete current file, for Scripts plugin
// https://gist.github.com/Infocatcher/6200149
// Version: 0.1.2 - 2014-07-17
// Author: Infocatcher
//// Delete current file
// Usage:
// Call("Scripts::Main", 1, "deleteCurrentFile.js")
var confirm = AkelPad.GetArgValue("confirm", true);
var curFile = AkelPad.GetEditFile(0);
if(curFile) {
var hMainWnd = AkelPad.GetMainWnd();
var oSys = AkelPad.SystemFunction();
if(oSys.Call("kernel32::GetFileAttributes" + _TCHAR, curFile) != -1) {
if(
!confirm
|| AkelPad.MessageBox(
hMainWnd,
"Delete file?\n" + curFile,
WScript.ScriptName,
33 /*MB_OKCANCEL|MB_ICONQUESTION*/
) == 1 /*IDOK*/
) {
if(oSys.Call("kernel32::DeleteFile" + _TCHAR, curFile)) {
var lpFileTime = AkelPad.SendMessage(hMainWnd, 1223 /*AKD_GETFRAMEINFO*/, 133 /*FI_FILETIME*/, 0);
AkelPad.MemCopy(lpFileTime + 0 /*offsetof(FILETIME, dwLowDateTime)*/, 0, 3 /*DT_DWORD*/);
AkelPad.MemCopy(lpFileTime + 4 /*offsetof(FILETIME, dwHighDateTime)*/, 0, 3 /*DT_DWORD*/);
}
}
}
else {
AkelPad.MessageBox(
hMainWnd,
"File already deleted:\n" + curFile,
WScript.ScriptName,
64 /*MB_OK|MB_ICONINFORMATION*/
);
}
}
@Infocatcher
Copy link
Author

Ключ уже есть:

Call("Scripts::Main", 1, "deleteCurrentFile.js", "-confirm=false")

Насчет переименования вкладки не уверен, автоматика скорее всего обновит обратно после переключения вкладок.
Но можно пометить документ как измененный.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment