View Issue Details

IDProjectCategoryView StatusLast Update
0004540JEDI VCL00 JVCL Componentspublic2008-10-18 02:55
Reportern9zleAssigned ToAHUser 
PrioritynormalSeveritytweakReproducibilityalways
Status resolvedResolutionfixed 
Product VersionDaily / GIT 
Target VersionFixed in Version3.36 
Summary0004540: Can't use sLineBreak in D2009 for jveditor.pas GetselText
DescriptionsLineBreak 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 Informationfunction 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;
TagsNo tags attached.

Activities

AHUser

2008-10-18 02:55

developer   ~0014877

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