https://gitcode.com/gh_mirrors/tt/TTextEditor/overview?utm_source=artical_gitcode&index=top&type=card&webUrl&isLogin=1

TTextEditor 项目常见问题解决方案

00]下载+安装
01]加载文本TextEditor1.Text
02]更改正文字体及大小
03]更改语法语言
04]更改视觉Theme

05]缩放显示,放大放小
06]一小段自动填充功能

07]导出为HTML文件


 

00]下载+安装

下载

链接:https://pan.baidu.com/s/1F7Z7J_XtcPjN-u7MDk13og 密码:14gq

安装

 将C:\Users\PC\Downloads\TTextEditor-main (1)\TTextEditor-main\Source加入Libary

 

 


 

01]加载文本TextEditor1.Text

TextEditor1.Text在设计的时候不能设置修改,只能在运行时动态加载

procedure TForm3.FormCreate(Sender: TObject);
begin
TextEditor1.Lines.LoadFromFile('Unit3.pas');
 TextEditor1.GoToLine(1);  //显示所有 文本
end;

 02]更改正文字体及大小

 03]更改语法语言JSON

 04]更改视觉Theme

 05]缩放显示,放大放小

procedure TForm1.ComboBox1Change(Sender: TObject);
begin 
 TextEditor1.Zoom(strToint(ComboBox1.Items[ComboBox1.ItemIndex]));
end;

 

 06]一小段自动填充功能

uses TextEditor.CompletionProposal.Snippets;

复制代码
procedure TForm1.FormCreate(Sender: TObject);
var
  LItem: TTextEditorCompletionProposalSnippetItem;
begin
//====================输入begin回车 触发 自动 在后面添加 end ===================================
    { "begin..end" with enter }
    LItem := TextEditor1.CompletionProposal.Snippets.Items.Add;
    with LItem do    begin
      Description := 'begin..end';
      Keyword := 'begin';
      ExecuteWith := seEnter;
    end;
    with LItem.Position do       begin
      Active := True;
      Column := 2;
      Row := 2;
    end;
    with LItem.Snippet do    begin
      Add('begin');
      Add('');
      Add('end');
    end;
//=================输入if 空格 触发,自动 在后面添加   True then==================================
    { "if True then" with space }
    LItem := TextEditor1.CompletionProposal.Snippets.Items.Add;
    with LItem do    begin
      Description := 'if True then';
      Keyword := 'if';
      ExecuteWith := seSpace;
    end;
    with LItem.Selection do    begin
      Active := True;
      FromColumn := 4;
      ToColumn := 8;
      FromRow := 1;
      ToRow := 1;
    end;
    LItem.Snippet.Add('if True then');
//==================================================
end;
复制代码

  

复制代码
//=================输入pr 空格 触发,自动 在后面添加  procedure==================================
    { "procedure  with space }
    LItem := TextEditor1.CompletionProposal.Snippets.Items.Add;

    with LItem do
    begin
      Description := 'procedure ';
      Keyword := 'pr';
      ExecuteWith := seSpace;
    end;

    with LItem.Position do       begin
      Active := True;
      Column := 11;
      Row := 1;
    end;

    LItem.Snippet.Add('procedure');
//==================================================
复制代码

 

复制代码
//====================输入with 回车 触发 自动 在后面添加 do end ===================================
    { "with .. do end" with enter }
    LItem := TextEditor1.CompletionProposal.Snippets.Items.Add;

    with LItem do
    begin
      Description := 'with..end';
      Keyword := 'with';
      ExecuteWith := seEnter;
    end;

    with LItem.Position do       begin
      Active := True;
      Column := 6;         //光标 在 第六列
      Row := 1;             //      第一行
    end;

    with LItem.Snippet do
    begin
      Add('with  do begin');
      Add('');
      Add('end');
    end;
复制代码

 07]导出为HTML文件

TextEditor1.ExportToHTML('c:\aaa.html');