delphi - SynEdit OnPaintTransientDemo -


i'm working delphi 2007 , synedit component.

i'm main developer of open source editor (tinn-r) , i'm trying switch synedit ansi unicode.

after months of work working fine except onpainttransient procedure.

to try discover source of problem have tried original demo onpainttransientdemo. works in latest ansi version of synedit. however, i'm not getting same result latest unicode version.

if instruction occupies 1 line, 1 symbol "[] {} or ()" near @ cursor mistakenly highlighted, closes not.

in other words, when click on first bracket "(" last bracket ")" doesn't change color. should color start , end tag. example, considering "|" cursor position:

(|aaaa) -> ( highlighted (aaaa|) -> ) highlighted 

however, if symbols in different lines both correctly highlighted:

(|a a a) -> both () highlighted  (a a a|) -> both () highlighted 

this looking bug in sources of component!
(doing debug not find source of bug.)

anyone can please?

the code below (iceman original author) works fine me:

procedure tform1.editorpainttransient(sender: tobject; canvas: tcanvas; transienttype: ttransienttype); var   editor: tsynedit;   openchars: array of widechar;//[0..2] of widechar=();   closechars: array of widechar;//[0..2] of widechar=();   attri: tsynhighlighterattributes;  function ischarbracket(achar: widechar): boolean; begin   case achar of     '{',     '[',     '(',     '<',     '}',     ']',     ')',     '>':     result:= true;   else     result:= false;   end; end;  function chartopixels(p: tbuffercoord): tpoint; begin   result:=editor.rowcolumntopixels(editor.buffertodisplaypos(p)); end;  procedure setcanvasstyle; begin   editor.canvas.brush.style:= bssolid; //clear;   editor.canvas.font.assign(editor.font);   editor.canvas.font.style:= attri.style;   if (transienttype = ttafter) begin     editor.canvas.font.color:= fbracketfg;     editor.canvas.brush.color:= fbracketbg;   end   else begin     editor.canvas.font.color:= attri.foreground;     editor.canvas.brush.color:= attri.background;   end;    if (editor.canvas.font.color = clnone)     editor.canvas.font.color:= editor.font.color;   if (editor.canvas.brush.color = clnone)     editor.canvas.brush.color:= editor.color; end;  var p  : tbuffercoord; pix: tpoint; d  : tdisplaycoord; s  : widestring; i,  arraylength,  start: integer; tmpchara,  tmpcharb: widechar;  begin   try     // if memo1.inreplacestatus = false     // begin     (*     if fmain.syntaxhenabled = false exit;     if memo1.highlighter = nil exit;     if fmain.bracketmatching = false exit;     if tsynedit(sender).selavail exit;     *)     editor:= tsynedit(sender);     arraylength:= 3;     (*     if (editor.highlighter = synhtmlsyn1) or (editor.highlighter = synxmlsyn1)     inc(arraylength);     *)     setlength(openchars,               arraylength);     setlength(closechars,               arraylength);      i:= 0 arraylength - 1       case of         0: begin              openchars[i]:= '(';              closechars[i]:= ')';            end;         1: begin              openchars[i]:= '{';              closechars[i]:= '}';            end;         2: begin              openchars[i]:= '[';              closechars[i]:= ']';            end;         3: begin              openchars[i]:= '<';              closechars[i]:= '>';            end;       end;      p:= editor.caretxy;     d:= editor.displayxy;     start:= editor.selstart;      if (start > 0) ,        (start <= length(editor.text))       tmpchara:= editor.text[start]     else       tmpchara:= #0;      if (start < length(editor.text))       tmpcharb:= editor.text[start + 1]     else       tmpcharb:= #0;      if not ischarbracket(tmpchara) ,        not ischarbracket(tmpcharb)       exit;      s:= tmpcharb;     if not ischarbracket(tmpcharb) begin       p.char:= p.char - 1;       s:= tmpchara;     end;      editor.gethighlighterattriatrowcol(p,                                        s,                                        attri);      if (editor.highlighter.symbolattribute = attri) begin       i:= low(openchars) high(openchars) begin         if (s = openchars[i]) or            (s = closechars[i]) begin           pix:= chartopixels(p);           setcanvasstyle;           editor.canvas.textout(pix.x,                                 pix.y,                                 s);           p := editor.getmatchingbracketex(p);            if (p.char > 0) ,              (p.line > 0) begin             pix:= chartopixels(p);             if pix.x > editor.gutter.width begin               setcanvasstyle;               if s = openchars[i]                 editor.canvas.textout(pix.x,                                       pix.y,                                       closechars[i])               else                 editor.canvas.textout(pix.x,                                       pix.y,                                       openchars[i]);             end; //if pix.x >           end; //if (p.char > 0)         end; //if (s = openchars[i])       end; //for i:= low(openchars)       editor.canvas.brush.style := bssolid;     end; //if (editor.highlighter.symbolattribute = attri)   except   // todo   end; //try end; 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -