Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0004540 [JEDI VCL] 00 JVCL Components tweak always 2008-10-17 08:54 2008-10-18 02:55
Reporter n9zle View Status public  
Assigned To AHUser
Priority normal Resolution fixed  
Status resolved   Product Version Daily / GIT
Summary 0004540: Can't use sLineBreak in D2009 for jveditor.pas GetselText
Description sLineBreak is a pAnsichar in 2009. (2 bytes)
Need a string = 0000013#10 that will work in both d2009 and older version.
pChar is unsafe as a pointer because char is now 2 bytes in d2009

Additional Information function TJvCustomEditor.GetSelText: string;
var
  S,slb: string;
  I,pi: Integer;
  Len, CLen: Integer;
begin

  with FSelection do
  begin
    Len := GetSelLength; // memory size to allocate
    Result := '';
    if Len = 0 then
      Exit;
    SetLength(Result, Len);
    slb := 0000013#10;
    if SelBlockFormat = bfColumn then
    begin
      if Len > 0 then
      begin
        pi := 1;
        for I := SelBegY to SelEndY do
        begin
          S := FLines[I];
          CLen := Length(S) - SelBegX;
          if CLen < 0 then
            CLen := 0;
          if CLen > SelEndX - SelBegX + 1 then
            CLen := SelEndX - SelBegX + 1;
          if CLen <> 0 then
          begin
            Move(S[SelBegX + 1],Result[pi], CLen*Sizeof(Char));
            Inc(Pi, CLen);
          end;

          if I < SelEndY then
          begin
            Move(slb[1], result[pi], sLineBreakLen*Sizeof(Char));
            Inc(pi, sLineBreakLen);
          end;
        end;
      end;
    end
    else
    begin
      if SelBegY = SelEndY then
        Move(FLines[SelEndY][SelBegX + 1], Result[1], Len*Sizeof(Char))
      else
      begin
        pi := 1;
        // first line
        S := FLines[SelBegY];
        CLen := (Length(S) - SelBegX);
        if CLen > 0 then
        begin
          Move(S[SelBegX + 1], Result[pi], CLen*Sizeof(Char));
          Inc(pi,CLen);
        end;

        // line break
        Move(slb[1], Result[pi], sLineBreakLen*Sizeof(Char));
        Inc(pi,sLineBreakLen);
        // lines between
        for I := SelBegY + 1 to SelEndY - 1 do
        begin
          // line
          S := FLines[I];
          Move(S[1], Result[pi], Length(S)*Sizeof(Char));
          Inc(pi, Length(S));

          // line break
          Move(slb[1], Result[pi], sLineBreakLen*Sizeof(Char));
          Inc(pi, sLineBreakLen);
        end;

        // last line
        S := FLines[SelEndY];
        CLen := SelEndX + Ord(SelBlockFormat = bfInclusive);

        if CLen > Length(S) then
          CLen := Length(S);
        if CLen > 0 then
          Move(S[1], Result[pi], CLen*Sizeof(Char));
      end;
    end;
  end;
end;
Tags No tags attached.
Attached Files

- Relationships

-  Notes
(0014877)
AHUser (developer)
2008-10-18 02:55

Fixed in SVN. I've added the "native" string sLineBreakStr constant to JvConsts.

- Issue History
Date Modified Username Field Change
2008-10-17 08:54 n9zle New Issue
2008-10-18 02:55 AHUser Status new => resolved
2008-10-18 02:55 AHUser Fixed in Version => Daily / SVN
2008-10-18 02:55 AHUser Resolution open => fixed
2008-10-18 02:55 AHUser Assigned To => AHUser
2008-10-18 02:55 AHUser Note Added: 0014877


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker