NO

Author Topic: IDE_TEXT Add-In  (Read 549 times)

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1857
IDE_TEXT Add-In
« on: April 26, 2019, 12:44:38 am »
IDE_TEXT Add-In add TEXT("test") for UNICODE purposes.
Add source menu option Insert TEXT()
Code: [Select]
ADDINAPI void WINAPI AddInCommandEx(int idCmd, LPCVOID pcvData)
{
HWND hDoc = AddIn_GetActiveDocument(g_hwndMain);
if (hDoc) {
ADDIN_RANGE range;
TCHAR szTmp[50];
AddIn_GetSourceSel(hDoc, &range);
int iStartPos = range.iStartPos;
int iEndPos = range.iEndPos;
// start
if (iStartPos) range.iStartPos = iStartPos - 1;
range.iEndPos = iStartPos;
AddIn_SetSourceSel(hDoc, &range);
AddIn_GetSourceSelText(hDoc, szTmp, sizeof(szTmp)/sizeof(TCHAR));
//AddIn_WriteOutput(g_hwndMain, szTmp);
if (*szTmp == '\"') range.iEndPos = iStartPos - 1;
else range.iStartPos = iStartPos;
AddIn_SetSourceSel(hDoc, &range);
AddIn_ReplaceSourceSelText(hDoc, TEXT("TEXT("));
// end
range.iStartPos = iEndPos + 5; // past TEXT(
range.iEndPos = iEndPos + 6;
AddIn_SetSourceSel(hDoc, &range);
AddIn_GetSourceSelText(hDoc, szTmp, sizeof(szTmp)/sizeof(TCHAR));
//AddIn_WriteOutput(g_hwndMain, szTmp);
if (*szTmp == '\"') range.iStartPos = iEndPos + 6;
else range.iEndPos = iEndPos + 5;
AddIn_SetSourceSel(hDoc, &range);
AddIn_ReplaceSourceSelText(hDoc, TEXT(")"));
}
}
May the source be with you