捐赠 | 广告 | 注册 | 发布 | 上传 | 关于我们    
  沪ICP备05001939号 DELPHI盒子 | 盒子论坛 | 盒子文章 | 盒子问答悬赏 | 最新更新 | 论坛检索 | 下载中心 | 高级搜索    
  精品专区 | 繁體中文 | 奖励公告栏 | 直通车账号登陆 | 关闭GOOGLE广告 | 临时留言    
盒子资源分类
全部展开 - 全部合拢
SynEdit Studio v5.0(2006.11.14)
关键字:SynEditStudio Syntax Editor Memo Parser 编辑器 代码折叠
来 自:原创
平 台:Win2k/XP/NT,Win2003 下载所需:0 火柴
深浅度:高级 完成时间:2006/11/14
发布者:bootini 发布时间:2006/11/14
编辑器:BDS2006 语  种:简体中文
分 类:编辑框与文本框 下载浏览:818/12997
加入到我的收藏
下载错误报错
登陆以后才能下载
 用户名:
 密 码:
自动登陆(30天有效)
图片如果打不开,说明流量不够了,请稍候下载……
  这一段时间好久没有更新了,主要是变懒了,无聊了,就一直在玩游戏,所以也就很少去更新了,情见谅。
 
v5.0(2006.11.14)
  * 修正 TSynEdit 鼠标在拖动中移动到Gutter放开会产生单击的错误
  * 修正 TSynEdit 对折叠的代码保护不足的错误
  * 修正 TSynEdit 无法编译的错误...
  * 修正 TSynEdit 自动换行的一个错误
  * 修正 TSynEdit SelectAll函数的错误
  * 修正 TSynEditPrint 打印预览中文乱码的问题
  * 修正 TSynEdit 打开文件后折叠信息没有更新
  * 修正 TSynEdit 在横向滚动时有乱码的错误
Google
 
本站原创作品,未经作者许可,严禁任何方式转载;转载作品,如果侵犯了您的权益,请联系我们
龙脉加密锁 15元起 Grid++Report 报表 申请支付@网
 相关文章
SynEditStudio v5.8
bootini 2007/12/6 下+9379/浏+23001 评+19
SynEditStudio V5.7 Fix 1
bootini 2007/6/13 下+835/浏+11211 评+3
Synedit ANSI v2.0.5 稳定版
senfore 2007/6/13 下+2215/浏+14157 评+0
SynEditStudio V5.7(2007.6.4)
bootini 2007/6/4 下+2735/浏+10218 评+7
SynEditStudio V5.5(2007.2.28)
bootini 2007/3/11 下+1956/浏+11589 评+10
SynEditStudio v5.4(2007.2.13)
bootini 2007/2/13 下+478/浏+8141 评+6
SynEditStudio v5.3(2007.02.03)
bootini 2007/2/3 下+356/浏+7667 评+4
SynEdit Studio v5.1(2006.12.28)
bootini 2006/12/29 下+733/浏+9819 评+5
SynEdit Studio v5.0(2006.11.14)
bootini 2006/11/14 下+818/浏+12998 评+12
SynEdit Studio v4.9(2006.09.04)
bootini 2006/9/4 下+1010/浏+12852 评+16
SynEditStudio v2006.08.25
bootini 2006/8/25 下+577/浏+9417 评+9
SynEditStudio v2006.08.06
bootini 2006/8/8 下+486/浏+9901 评+15
SynEditStudio v2006.07.25
bootini 2006/7/26 下+340/浏+8815 评+7
SynEditStudio v2006.07.22
bootini 2006/7/25 下+264/浏+8257 评+2
SynEditStudio v2006.07.10
bootini 2006/7/11 下+494/浏+9458 评+5
SynEditStudio v2006.06.22
bootini 2006/6/22 下+491/浏+9527 评+14
SynEdit Studio V2006.05.10
bootini 2006/5/10 下+658/浏+10107 评+3
SynEdit Studio V2006.05.07
bootini 2006/5/7 下+915/浏+11581 评+3
SynEdit Studio V2006.04.12 beta1.00
bootini 2006/4/14 下+359/浏+9572 评+1
SynEdit V2.0.3 For BDS2006
sail2000 2006/2/28 下+618/浏+10857 评+6
SynEdit Studio V2005.12.26 beta3.00
bootini 2005/12/26 下+947/浏+11216 评+10
UniSynEdit v2005-09-26
senfore 2005/9/28 下+689/浏+14337 评+0
SynEdit Studio V2005.09.10 beta2.00
bootini 2005/9/24 下+704/浏+13312 评+9
SynEdit Studio V2005.09.18 beta1.00
bootini 2005/9/19 下+503/浏+10942 评+5
Syn TextEditor v2.6.2.94
senfore 2005/9/9 下+1099/浏+13361 评+3
UniSynEdit-cvs-2005-09-05
senfore 2005/9/9 下+296/浏+11235 评+0
synedit-cvs-201b-2005-09-05
senfore 2005/9/9 下+267/浏+9980 评+0
SynEdit Studio V2005.09.05
bootini 2005/9/5 下+674/浏+12223 评+12
SynEdit Studio V2005.08.29
bootini 2005/8/28 下+493/浏+11043 评+15
SynEdit Studio V2005.07.29
bootini 2005/7/29 下+571/浏+11260 评+4
SynEdit Studio V2005.06.25
bootini 2005/6/25 下+410/浏+9884 评+8
SynEdit Studio V2005.06.08
bootini 2005/6/8 下+479/浏+12017 评+7
SynEdit Studio v2005.06.01 儿童节大礼包
bootini 2005/6/2 下+408/浏+10596 评+1
SynEdit Studio V2005.05.29
bootini 2005/5/29 下+270/浏+9474 评+3
SynEdit Studio V2005.05.23
bootini 2005/5/24 下+459/浏+10789 评+20
SynEdit Studio (编辑器)
bootini 2005/5/22 下+490/浏+14241 评+9
TSynSpellCheck v1.30
bootini 2005/5/16 下+291/浏+10091 评+1
SynUniParser v1.1
bootini 2005/5/16 下+388/浏+10412 评+1
SynEdit 姚乔锋修改最新版 V2005.05.15
bootini 2005/5/16 下+863/浏+13207 评+7
Tinn v0.0.94 (Synedit做的编辑器)
senfore 2005/3/23 下+861/浏+12260 评+1
synedit - cvs - 2005-02-26 (源代码编辑器…
senfore 2005/3/1 下+1122/浏+12818 评+2
SynEdit (姚乔锋修改完整版)
bootini 2004/12/20 下+741/浏+13706 评+14
SynEdit 姚乔锋修改版
bootini 2004/12/14 下+335/浏+11844 评+16
SynEdit 2004-10-09 修改版
hotyei 2004/12/11 下+353/浏+9835 评+7
SynEdit - cvs - 2004-10-09 (源代码编辑器…
bootini 2004/11/25 下+1040/浏+10403 评+6
SynEdit - CVSD 2004-08-25 (源代码编辑器)
senfore 2004/8/30 下+458/浏+11576 评+1
SynEdit - CVS 2004-06-20 (源代码编辑器)
leo 2004/8/20 下+438/浏+10862 评+3
绝地程序编辑器 v1.0.1.4 源代码
threedot 2004/8/19 下+2034/浏+20251 评+15
SynEdit - CVS 2004-05-09 (源代码编辑器)
epdi 2004/6/12 下+509/浏+12505 评+4
SynEdit v1.1 (源代码编辑器组件)
mantousoft 2004/2/11 下+1310/浏+17127 评+5
相关评论
共有评论12条 当前显示最后6条评论
bootini 2006/11/15 20:12:32
如果有错误的请到yaoqiaofeng.bopin.net下载5.0版本的补丁1
shamohu 2006/11/19 21:04:56
有无可能把镶入OLE的功能加进来?
zhude 2006/11/23 13:32:47
晕啊~这个版本的DEMO都不能折叠~~~~~~~~~~上一个版本的 4.9 的正常~~~~~
我安装了 5.1 的控件后~~不能编译 4.9 的DEMO ..........
zhude 2006/11/23 13:33:55
那位兄台指点下啊~~~~~~~~~~
zhude 2006/11/23 21:13:00
TSynEditor  如何实现自定义语法高亮??????????
zhude 2006/11/29 15:22:21

unit SynHighlighterSample;

{$I SynEdit.inc}

interface

uses
  SysUtils,
  Classes,
{$IFDEF SYN_CLX}
  QControls,
  QGraphics,
{$ELSE}
  Windows,
  Controls,
  Graphics,
{$ENDIF}
  SynEditTypes,
  SynEditHighlighter;

type
  TtkTokenKind = (
    tkComment,
    tkIdentifier,
    tkKey,
    tkNull,
    tkSpace,
    tkString,
    tkTest,
    tkUnknown);

  TRangeState = (rsUnKnown, rsBraceComment, rsCStyleComment, rsString);

  TProcTableProc = procedure of object;

  PIdentFuncTableFunc = ^TIdentFuncTableFunc;
  TIdentFuncTableFunc = function: TtkTokenKind of object;

const
  MaxKey = 96;

type
  TSynSampleSyn = class(TSynCustomHighlighter)
  private
    fLine: PChar;
    fLineNumber: Integer;
    fProcTable: array[#0..#255] of TProcTableProc;
    fRange: TRangeState;
    Run: LongInt;
    fStringLen: Integer;
    fToIdent: PChar;
    fTokenPos: Integer;
    fTokenID: TtkTokenKind;
    fIdentFuncTable: array[0 .. MaxKey] of TIdentFuncTableFunc;
    fCommentAttri: TSynHighlighterAttributes;
    fIdentifierAttri: TSynHighlighterAttributes;
    fKeyAttri: TSynHighlighterAttributes;
    fSpaceAttri: TSynHighlighterAttributes;
    fStringAttri: TSynHighlighterAttributes;
    fTestAttri: TSynHighlighterAttributes;
    function KeyHash(ToHash: PChar): Integer;
    function KeyComp(const aKey: string): Boolean;
    function Func52: TtkTokenKind;
    function Func72: TtkTokenKind;
    function Func96: TtkTokenKind;
    procedure IdentProc;
    procedure UnknownProc;
    function AltFunc: TtkTokenKind;
    procedure InitIdent;
    function IdentKind(MayBe: PChar): TtkTokenKind;
    procedure MakeMethodTables;
    procedure NullProc;
    procedure SpaceProc;
    procedure CRProc;
    procedure LFProc;
    procedure BraceCommentOpenProc;
    procedure BraceCommentProc;
    procedure CStyleCommentOpenProc;
    procedure CStyleCommentProc;
    procedure StringOpenProc;
    procedure StringProc;
  protected
    function GetIdentChars: TSynIdentChars; override;
    function GetSampleSource: string; override;
    function IsFilterStored: Boolean; override;
  public
    constructor Create(AOwner: TComponent); override;
    {$IFNDEF SYN_CPPB_1} class {$ENDIF}
    function GetLanguageName: string; override;
    function GetRange: Pointer; override;
    procedure ResetRange; override;
    procedure SetRange(Value: Pointer); override;
    function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes; override;
    function GetEOL: Boolean; override;
    function GetKeyWords: string;
    function GetTokenID: TtkTokenKind;
    procedure SetLine(NewValue: String; LineNumber: Integer); override;
    function GetToken: String; override;
    function GetTokenAttribute: TSynHighlighterAttributes; override;
    function GetTokenKind: integer; override;
    function GetTokenPos: Integer; override;
    procedure Next; override;
  published
    property CommentAttri: TSynHighlighterAttributes read fCommentAttri write fCommentAttri;
    property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri write fIdentifierAttri;
    property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri;
    property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri write fSpaceAttri;
    property StringAttri: TSynHighlighterAttributes read fStringAttri write fStringAttri;
    property TestAttri: TSynHighlighterAttributes read fTestAttri write fTestAttri;
  end;

implementation

uses
  SynEditStrConst;

{$IFDEF SYN_COMPILER_3_UP}
resourcestring
{$ELSE}
const
{$ENDIF}
  SYNS_FilterSamplelanguage = 'All files (*.*)|*.*';
  SYNS_LangSamplelanguage = 'Sample language';
  SYNS_AttrTest = 'Test';

var
  Identifiers: array[#0..#255] of ByteBool;
  mHashTable : array[#0..#255] of Integer;

procedure MakeIdentTable;
var
  I, J: Char;
begin
  for I := #0 to #255 do
  begin
    case I of
      '_', 'a'..'z', 'A'..'Z': Identifiers[I] := True;
    else
      Identifiers[I] := False;
    end;
    J := UpCase(I);
    case I in ['_', 'A'..'Z', 'a'..'z'] of
      True: mHashTable[I] := Ord(J) - 64
    else
      mHashTable[I] := 0;
    end;
  end;
end;

procedure TSynSampleSyn.InitIdent;
var
  I: Integer;
  pF: PIdentFuncTableFunc;
begin
  pF := PIdentFuncTableFunc(@fIdentFuncTable);
  for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do
  begin
    pF^ := AltFunc;
    Inc(pF);
  end;
  fIdentFuncTable[52] := Func52;
  fIdentFuncTable[72] := Func72;
  fIdentFuncTable[96] := Func96;
end;

function TSynSampleSyn.KeyHash(ToHash: PChar): Integer;
begin
  Result := 0;
  while ToHash^ in ['_', 'a'..'z', 'A'..'Z'] do
  begin
    inc(Result, mHashTable[ToHash^]);
    inc(ToHash);
  end;
  fStringLen := ToHash - fToIdent;
end;

function TSynSampleSyn.KeyComp(const aKey: String): Boolean;
var
  I: Integer;
  Temp: PChar;
begin
  Temp := fToIdent;
  if Length(aKey) = fStringLen then
  begin
    Result := True;
    for i := 1 to fStringLen do
    begin
      if mHashTable[Temp^] <> mHashTable[aKey[i]] then
      begin
        Result := False;
        break;
      end;
      inc(Temp);
    end;
  end
  else
    Result := False;
end;

function TSynSampleSyn.Func52: TtkTokenKind;
begin
  if KeyComp('Hello') then Result := tkKey else Result := tkIdentifier;
end;

function TSynSampleSyn.Func72: TtkTokenKind;
begin
  if KeyComp('World') then Result := tkKey else Result := tkIdentifier;
end;

function TSynSampleSyn.Func96: TtkTokenKind;
begin
  if KeyComp('SynEdit') then Result := tkTest else Result := tkIdentifier;
end;

function TSynSampleSyn.AltFunc: TtkTokenKind;
begin
  Result := tkIdentifier;
end;

function TSynSampleSyn.IdentKind(MayBe: PChar): TtkTokenKind;
var
  HashKey: Integer;
begin
  fToIdent := MayBe;
  HashKey := KeyHash(MayBe);
  if HashKey <= MaxKey then
    Result := fIdentFuncTable[HashKey]
  else
    Result := tkIdentifier;
end;

procedure TSynSampleSyn.MakeMethodTables;
var
  I: Char;
begin
  for I := #0 to #255 do
    case I of
      #0: fProcTable[I] := NullProc;
      #10: fProcTable[I] := LFProc;
      #13: fProcTable[I] := CRProc;
      '{': fProcTable[I] := BraceCommentOpenProc;
      '/': fProcTable[I] := CStyleCommentOpenProc;
      '"': fProcTable[I] := StringOpenProc;
      #1..#9,
      #11,
      #12,
      #14..#32 : fProcTable[I] := SpaceProc;
      'A'..'Z', 'a'..'z', '_': fProcTable[I] := IdentProc;
    else
      fProcTable[I] := UnknownProc;
    end;
end;

procedure TSynSampleSyn.SpaceProc;
begin
  fTokenID := tkSpace;
  repeat
    inc(Run);
  until not (fLine[Run] in [#1..#32]);
end;

procedure TSynSampleSyn.NullProc;
begin
  fTokenID := tkNull;
end;

procedure TSynSampleSyn.CRProc;
begin
  fTokenID := tkSpace;
  inc(Run);
  if fLine[Run] = #10 then
    inc(Run);
end;

procedure TSynSampleSyn.LFProc;
begin
  fTokenID := tkSpace;
  inc(Run);
end;

procedure TSynSampleSyn.BraceCommentOpenProc;
begin
  Inc(Run);
  fRange := rsBraceComment;
  BraceCommentProc;
  fTokenID := tkComment;
end;

procedure TSynSampleSyn.BraceCommentProc;
begin
  case fLine[Run] of
     #0: NullProc;
    #10: LFProc;
    #13: CRProc;
  else
    begin
      fTokenID := tkComment;
      repeat
        if (fLine[Run] = '}') then
        begin
          Inc(Run, 1);
          fRange := rsUnKnown;
          Break;
        end;
        if not (fLine[Run] in [#0, #10, #13]) then
          Inc(Run);
      until fLine[Run] in [#0, #10, #13];
    end;
  end;
end;

procedure TSynSampleSyn.CStyleCommentOpenProc;
begin
  Inc(Run);
  if (fLine[Run] = '*') then
  begin
    fRange := rsCStyleComment;
    CStyleCommentProc;
    fTokenID := tkComment;
  end
  else
    fTokenID := tkIdentifier;
end;

procedure TSynSampleSyn.CStyleCommentProc;
begin
  case fLine[Run] of
     #0: NullProc;
    #10: LFProc;
    #13: CRProc;
  else
    begin
      fTokenID := tkComment;
      repeat
        if (fLine[Run] = '*') and
          (fLine[Run + 1] = '/') then
        begin
          Inc(Run, 2);
          fRange := rsUnKnown;
          Break;
        end;
        if not (fLine[Run] in [#0, #10, #13]) then
          Inc(Run);
      until fLine[Run] in [#0, #10, #13];
    end;
  end;
end;

procedure TSynSampleSyn.StringOpenProc;
begin
  Inc(Run);
  fRange := rsString;
  StringProc;
  fTokenID := tkString;
end;

procedure TSynSampleSyn.StringProc;
begin
  fTokenID := tkString;
  repeat
    if (fLine[Run] = '"') then
    begin
      Inc(Run, 1);
      fRange := rsUnKnown;
      Break;
    end;
    if not (fLine[Run] in [#0, #10, #13]) then
      Inc(Run);
  until fLine[Run] in [#0, #10, #13];
end;

constructor TSynSampleSyn.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  fCommentAttri := TSynHighLighterAttributes.Create(SYNS_AttrComment);
  fCommentAttri.Style := [fsItalic];
  fCommentAttri.Foreground := clNavy;
  AddAttribute(fCommentAttri);

  fIdentifierAttri := TSynHighLighterAttributes.Create(SYNS_AttrIdentifier);
  AddAttribute(fIdentifierAttri);

  fKeyAttri := TSynHighLighterAttributes.Create(SYNS_AttrReservedWord);
  fKeyAttri.Style := [fsBold];
  AddAttribute(fKeyAttri);

  fSpaceAttri := TSynHighLighterAttributes.Create(SYNS_AttrSpace);
  AddAttribute(fSpaceAttri);

  fStringAttri := TSynHighLighterAttributes.Create(SYNS_AttrString);
  fStringAttri.Foreground := clRed;
  AddAttribute(fStringAttri);

  fTestAttri := TSynHighLighterAttributes.Create(SYNS_AttrTest);
  fTestAttri.Style := [fsUnderline, fsItalic];
  fTestAttri.Foreground := clBlue;
  fTestAttri.Background := clSilver;
  AddAttribute(fTestAttri);

  SetAttributesOnChange(DefHighlightChange);
  InitIdent;
  MakeMethodTables;
  fDefaultFilter := SYNS_FilterSamplelanguage;
  fRange := rsUnknown;
end;

procedure TSynSampleSyn.SetLine(NewValue: String; LineNumber: Integer);
begin
  fLine := PChar(NewValue);
  Run := 0;
  fLineNumber := LineNumber;
  Next;
end;

procedure TSynSampleSyn.IdentProc;
begin
  fTokenID := IdentKind((fLine + Run));
  inc(Run, fStringLen);
  while Identifiers[fLine[Run]] do
    Inc(Run);
end;

procedure TSynSampleSyn.UnknownProc;
begin
{$IFDEF SYN_MBCSSUPPORT}
  if FLine[Run] in LeadBytes then
    Inc(Run,2)
  else
{$ENDIF}
  inc(Run);
  fTokenID := tkUnknown;
end;

procedure TSynSampleSyn.Next;
begin
  fTokenPos := Run;
  case fRange of
    rsBraceComment: BraceCommentProc;
    rsCStyleComment: CStyleCommentProc;
  else
    begin
      fRange := rsUnknown;
      fProcTable[fLine[Run]];
    end;
  end;
end;

function TSynSampleSyn.GetDefaultAttribute(Index: integer): TSynHighLighterAttributes;
begin
  case Index of
    SYN_ATTR_COMMENT    : Result := fCommentAttri;
    SYN_ATTR_IDENTIFIER : Result := fIdentifierAttri;
    SYN_ATTR_KEYWORD    : Result := fKeyAttri;
    SYN_ATTR_STRING     : Result := fStringAttri;
    SYN_ATTR_WHITESPACE : Result := fSpaceAttri;
  else
    Result := nil;
  end;
end;

function TSynSampleSyn.GetEOL: Boolean;
begin
  Result := fTokenID = tkNull;
end;

function TSynSampleSyn.GetKeyWords: string;
begin
  Result := 
    'Hello,SynEdit,World';
end;

function TSynSampleSyn.GetToken: String;
var
  Len: LongInt;
begin
  Len := Run - fTokenPos;
  SetString(Result, (FLine + fTokenPos), Len);
end;

function TSynSampleSyn.GetTokenID: TtkTokenKind;
begin
  Result := fTokenId;
end;

function TSynSampleSyn.GetTokenAttribute: TSynHighLighterAttributes;
begin
  case GetTokenID of
    tkComment: Result := fCommentAttri;
    tkIdentifier: Result := fIdentifierAttri;
    tkKey: Result := fKeyAttri;
    tkSpace: Result := fSpaceAttri;
    tkString: Result := fStringAttri;
    tkTest: Result := fTestAttri;
    tkUnknown: Result := fIdentifierAttri;
  else
    Result := nil;
  end;
end;

function TSynSampleSyn.GetTokenKind: integer;
begin
  Result := Ord(fTokenId);
end;

function TSynSampleSyn.GetTokenPos: Integer;
begin
  Result := fTokenPos;
end;

function TSynSampleSyn.GetIdentChars: TSynIdentChars;
begin
  Result := ['_', 'a'..'z', 'A'..'Z'];
end;

function TSynSampleSyn.GetSampleSource: string;
begin
  Result := '{ Sample source for the demo highlighter }'#13#10 +
          #13#10 +
          'This highlighter will recognize the words Hello and'#13#10 +
          'World as keywords. It will also highlight "Strings".'#13#10 +
          #13#10 +
          'And a special keyword type: SynEdit'#13#10 +
          #13#10 +
          '/* This style of comments is also highlighted */';
end;

function TSynSampleSyn.IsFilterStored: Boolean;
begin
  Result := fDefaultFilter <> SYNS_FilterSamplelanguage;
end;

{$IFNDEF SYN_CPPB_1} class {$ENDIF}
function TSynSampleSyn.GetLanguageName: string;
begin
  Result := SYNS_LangSamplelanguage;
end;

procedure TSynSampleSyn.ResetRange;
begin
  fRange := rsUnknown;
end;

procedure TSynSampleSyn.SetRange(Value: Pointer);
begin
  fRange := TRangeState(Value);
end;

function TSynSampleSyn.GetRange: Pointer;
begin
  Result := Pointer(fRange);
end;

initialization
  MakeIdentTable;
{$IFNDEF SYN_CPPB_1}
  RegisterPlaceableHighlighter(TSynSampleSyn);
{$ENDIF}
end.
我要发表评论 查看全部评论
 
  DELPHI盒子版权所有 1999-2023 V4.01 粤ICP备10103342号-1 更新RSS列表