From 6e2da4c7f45289cac8c653225fcd648416771ec5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=BCng?= Date: Fri, 17 Nov 2023 19:05:13 +0100 Subject: [PATCH] Add new command jscript GetPathForDocID for plugins closes #358 --- src/res/AutoComplete.ini | 3 ++- src/scripting/BasicScriptObject.cpp | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/res/AutoComplete.ini b/src/res/AutoComplete.ini index e354b508..c992d0fe 100644 --- a/src/res/AutoComplete.ini +++ b/src/res/AutoComplete.ini @@ -786,7 +786,7 @@ snippet_GetClipboardText=GetClipboardText() snippet_GetCurrentTitle=GetCurrentTitle() snippet_GetDocIDFromPath=GetDocIDFromPath(^1path^) snippet_GetDocIDFromTabIndex=GetDocIDFromTabIndex(^1index^) -snippet_GetDocIdOfCurrentTab=GetDocIdOfCurrentTab(^1int^) +snippet_GetDocIdOfCurrentTab=GetDocIdOfCurrentTab() snippet_GetKeyState=GetKeyState(^1key^) snippet_GetTabCount=GetTabCount() snippet_GetTabIndexFromDocID=GetTabIndexFromDocID(^1id^) @@ -820,3 +820,4 @@ snippet_ReadSetting=ReadSetting("^1key^") snippet_SaveSetting=SaveSetting("^1key^", "^2value^") snippet_InvalidateCommand=InvalidateCommand(^1cmdId^) snippet_ExecuteCommand=ExecuteCommand(^1cmdId^) +snippet_GetPathForDocID)=GetPathForDocID(^1cmdId^) \ No newline at end of file diff --git a/src/scripting/BasicScriptObject.cpp b/src/scripting/BasicScriptObject.cpp index 8e36bc59..8b84b55f 100644 --- a/src/scripting/BasicScriptObject.cpp +++ b/src/scripting/BasicScriptObject.cpp @@ -930,6 +930,8 @@ HRESULT BasicScriptObject::GetIDsOfNames(REFIID /*riid*/, idList[i] = 145; else if (_wcsicmp(nameList[i], L"ExecuteCommand") == 0) idList[i] = 146; + else if (_wcsicmp(nameList[i], L"GetPathForDocID") == 0) + idList[i] = 147; else if (_wcsicmp(nameList[i], L"SciGetTextRange") == 0) idList[i] = 900; else if (_wcsicmp(nameList[i], L"SciGetCharAt") == 0) @@ -1493,6 +1495,16 @@ HRESULT BasicScriptObject::Invoke(DISPID id, pCmd->Execute(); } break; + case 147: // GetPathForDocID + { + if (args->cArgs != 1) + return DISP_E_BADPARAMCOUNT; + if (FAILED(VariantChangeType(&p1, &args->rgvarg[0], VARIANT_ALPHABOOL, VT_INT))) + return DISP_E_TYPEMISMATCH; + ret->vt = VT_BSTR; + ret->bstrVal = _bstr_t(GetDocumentFromID(DocID(p1.intVal)).m_path.c_str()).Detach(); + } + break; case 900: // SciGetTextRange if (args->cArgs != 2) return DISP_E_BADPARAMCOUNT;