Skip to content

Commit

Permalink
Add new command jscript GetPathForDocID for plugins
Browse files Browse the repository at this point in the history
closes #358
  • Loading branch information
stefankueng committed Nov 17, 2023
1 parent 2827dac commit 6e2da4c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/res/AutoComplete.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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^)
Expand Down Expand Up @@ -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^)
12 changes: 12 additions & 0 deletions src/scripting/BasicScriptObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 6e2da4c

Please sign in to comment.