プラグインからマクロの実行が可能です。
実行したいマクロをファイルで保存して、保存したマクロファイルを実行させます。
マクロの結果をプラグインから取得したい場合は、マクロで結果をファイルに保存して、プラグインでファイルを読み込みます。
ここでは、ファイルに保存とファイルの実行を説明します。
procedure DrawCustomColor(hwnd: HWND);
var
sStr1: String;
sStr2: String;
sStr3: String;
sStr12: String;
sStr13: String;
StrList11: TStringList;
LChecked1: LongBool;
LpPPoint1: PPoint;
LpPathName: array [0..MAX_PATH - 1] of Char;
LpFileName: array [0..MAX_PATH - 1] of Char;
// iDoc1: Integer;
// iDoc2: Integer;
// iDoc3: Integer;
// iDoc4: Integer;
begin
//書込禁止
//// 3.3.2
if Editor_Info(hwnd, MI_GET_READ_ONLY, 0) = 1 then
begin
LChecked1 := TRUE;
// Editor_SetStatus(hwnd, PChar('TRUE ' + inttostr(idoc1) + ' ' + inttostr(hwnd) + ' ' + inttostr(IntColorMode)));
end
else
begin
LChecked1 := FALSE;
// Editor_SetStatus(hwnd, PChar('FALSE ' + inttostr(idoc1) + ' ' +inttostr(hwnd) + ' ' + inttostr(IntColorMode)));
end;
//書き込み禁止 ON
if LChecked1 = TRUE then
begin
if IntColorMode <> 2 then
begin
//設定
IntColorMode := 2;
// 3.2.6
// MACROS_WRITE_BACK_SETTING = 'editor.WriteSettingInteger("Display", "GeneralBackColor", 0xFFFFFF)';
// MACROS_WRITE_FONT_SETTING = 'editor.WriteSettingInteger("Display", "GeneralForeColor", 0x000000)';
// MACROS_READ_SETTING = 'editor.ReadSettings()';
sStr1 := MACROS_WRITE_BACK_SETTING;
sStr1 := StringReplace(sStr1, '0xFFFFFF', IntToStr(ReadOnlyBackColor), []);
sStr2 := MACROS_WRITE_FONT_SETTING;
sStr2 := StringReplace(sStr2, '0x000000', IntToStr(ReadOnlyFontColor), []);
sStr3 := MACROS_READ_SETTING;
//
sStr12 := ExtractFilePath(ParamStr(0)) + MACROS_FOLDER_NAME + '\' + MACROS_FILE_NAME_READONLY;
//保存
StrList11 := TStringList.Create;
try
StrList11.Add(sStr1);
StrList11.Add(sStr2);
StrList11.Add(sStr3);
StrList11.SaveToFile(sStr12, TEncoding.UTF8);
finally
StrList11.Free;
end;
//Editor_RunMacro(hwnd: THandle;
// nFlags: Cardinal;
// nDefMacroLang: Cardinal;
// pszMacroFile: PChar;
// pszText: PChar;
// pptErrorPos: PPoint): HRESULT;
New(LpPPoint1);
try
FillChar(LpPathName, SizeOf(LpPathName), 0);
StrPCopy(PChar(@LpPathName[0]), sStr12);
FillChar(LpFileName, SizeOf(LpFileName), 0);
Editor_RunMacro(hwnd, RUN_FILE, MACRO_LANG_JSCRIPT, LpPathName, LpFileName, LpPPoint1);
finally
Dispose(LpPPoint1);
end;
end;
end
//書き込み禁止 OFF
else
begin
if IntColorMode <> 1 then
begin
//設定
IntColorMode := 1;
// MACROS_WRITE_BACK_SETTING = 'editor.WriteSettingInteger("Display", "GeneralBackColor", 0xFFFFFF)';
// MACROS_WRITE_FONT_SETTING = 'editor.WriteSettingInteger("Display", "GeneralForeColor", 0x000000)';
// MACROS_READ_SETTING = 'editor.ReadSettings()';
sStr1 := MACROS_WRITE_BACK_SETTING;
sStr1 := StringReplace(sStr1, '0xFFFFFF', IntToStr(NormalBackColor), []);
sStr2 := MACROS_WRITE_FONT_SETTING;
sStr2 := StringReplace(sStr2, '0x000000', IntToStr(NormalFontColor), []);
sStr3 := MACROS_READ_SETTING;
//
sStr13 := ExtractFilePath(ParamStr(0)) + MACROS_FOLDER_NAME + '\' + MACROS_FILE_NAME_NORMAL;
//保存
StrList11 := TStringList.Create;
try
StrList11.Add(sStr1);
StrList11.Add(sStr2);
StrList11.Add(sStr3);
StrList11.SaveToFile(sStr13, TEncoding.UTF8);
finally
StrList11.Free;
end;
//Editor_RunMacro(hwnd: THandle;
// nFlags: Cardinal;
// nDefMacroLang: Cardinal;
// pszMacroFile: PChar;
// pszText: PChar;
// pptErrorPos: PPoint): HRESULT;
New(LpPPoint1);
try
FillChar(LpPathName, SizeOf(LpPathName), 0);
StrPCopy(PChar(@LpPathName[0]), sStr13);
FillChar(LpFileName, SizeOf(LpFileName), 0);
Editor_RunMacro(hwnd, RUN_FILE, MACRO_LANG_JSCRIPT, LpPathName, LpFileName, LpPPoint1);
finally
Dispose(LpPPoint1);
end;
end;
end;
end;