⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plgiface.pas

📁 Delphi编写的一个支持语法高亮显示和很多语言的文本编辑器
💻 PAS
字号:
{+-----------------------------------------------------------------------------+
 | PlgIface.pas                                                                |
 +-----------------------------------------------------------------------------+
 | Simply put this is a simple api wrapper for cEdit. These are the exported   |
 | functions which may be accessed by plugins.                                 |
 +-----------------------------------------------------------------------------+}
unit plgIface;

interface
uses sysutils, classes, Windows, menus, dialogs, uTypes;

  //procedure AddText(pText: PChar);

  function AddMenuItemA(PluginName, Caption, EventProc : PChar; Menu, Position : Integer) : Boolean; stdcall;
  function AddMenuItemExA(PluginName, Caption, EventProc, ShortCut : PChar; ContainerType, Container, Position, Data : Integer) : Boolean; stdcall;


implementation


uses fMain, dMain, fDoc;

{ Place all plugin related functions between these blocks }

var
  OwnerApp: Integer;


procedure AddText(pText: PChar); far;
begin
  if dmMain.selDoc <> nil then begin
    dmMain.SelDoc.sciMain.SelText :=  PText;
  end;
end;

function AddMenuItemA(PluginName, Caption, EventProc : PChar; Menu, Position : Integer) : Boolean; stdcall;
var
   mi : TPluginMI;
begin
// Add a menuitem to the main form...
   mi := TPluginMI.Create(nil);
   mi.Caption := string(Caption);
   mi.Tag := 80 + frmMain.PluginMenuItems.Count;
   mi.OnClick := frmMain.MenuItemClick;
   mi.plugin := PluginName;
   mi.evname := EventProc;
   //Result := mi.Handle;
   Result := True;
   frmMain.mnuMain.Items[Menu].Insert(Position, mi);
   frmMain.PluginMenuItems.Add(mi);
end;
function AddMenuItem(PluginName, Caption, EventProc : pChar; Menu, Position : Integer) : LongBool; stdcall;
begin
// This procedure adds a menuitem to the main interface...
  Result := AddMenuItemA(PluginName, Caption, EventProc, Menu, Position);
end;

function AddMenuItemExA(PluginName, Caption, EventProc, ShortCut : PChar; ContainerType, Container, Position, Data : Integer) : Boolean; stdcall;
var
   mi : TPluginMI;
begin
// Add a menuitem to the main form...
   mi := TPluginMI.Create(nil);
   mi.Caption := string(Caption);
   mi.Tag := 80 + frmMain.PluginMenuItems.Count;
   mi.ImageIndex := Data;
   mi.OnClick := frmMain.MenuItemClick;
   try
     mi.ShortCut := TextToShortCut(ShortCut);
   except
   end;
   mi.plugin := PluginName;
   mi.evname := EventProc;
   //Result := mi.Handle;
   Result := True;
   frmMain.mnuMain.Items[Container].Insert(Position, mi);
   frmMain.PluginMenuItems.Add(mi);
end;


function GetText: PChar; far;
begin
  if dmMain.selDoc <> nil then begin
    result := PChar(dmMain.SelDoc.sciMain.SelText);
  end;
end;

function SetText(str: String): string; far;
begin
  if dmMain.SelDoc <> nil then begin
    dmMain.SelDoc.sciMain.Text := str;
  end;
end;

function GetAllText: String; far;
begin
  if dmMain.SelDoc <> nil then begin
    result := dmMain.SelDoc.sciMain.Text;
  end;
end;

procedure SaveActive(pFile: PChar); far;
begin
  if dmMain.selDoc <> nil then
    dmMain.SelDoc.sciMain.Lines.SaveToFile(pFile);
end;

procedure SetPopupList(pStr1: TStrings; pStr2: TStrings); far;
begin
  if dmMain.SelDoc = nil then exit;
  dmMain.propose.InsertList := pStr1;
  dmMain.propose.ItemList := pStr2;
end;

procedure Init(Owner: Integer); far
begin
	OwnerAPP := Owner;
end;

{ Place all plugin related functions between these blocks }


{
  The following are exported functions. If you add a function you must add it's name
  to the list of exports
}

exports SetText, GetAllText, AddText, GetText, SaveActive, SetPopupList, Init, AddMenuItem;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -