On Nov 29, 2007, at 9:46 AM, Graeme Geldenhuys wrote:

On 29/11/2007, Damien Gerard <[EMAIL PROTECTED]> wrote:

I would prefer the first one too. That's why I already recently posted
the code to do this :)


Excellent.  Well if nobody is going to apply that code to Lazarus, I
would like to do it on my local setup.  Mind emailing me the code or
telling me where I could find it?


Actually, I have no time for the moment to help patching Lazarus itself. But I am planning to :)
Here is an example. May be some changes will be necessary.


program demo;
{$mode objfpc}

uses sysutils;

function CutString(const s: UTF8String; const maxLen: integer = 30; const rightSide: boolean = false; const rightSideLen: integer = 8) : UTF8String;
var i : integer;
begin
if (0 = maxLen) or (length(s) < maxLen) or (rightSideLen > maxLen - 4) then
   begin
       result := s;
       exit;
   end;

   if rightSide then
   begin
       i := maxLen - (rightSideLen + 3);
result := TrimRight(leftStr(s, i)) + '...' + TrimLeft(rightStr(s, rightSideLen));
   end else begin
       result := leftStr(s, maxLen - 3) + '...';
   end;
end;



const LONG_PATH : UTF8String = '/Users/milipili/Projects/anotherFolder/ folder0/folder1/pixie/client/src/pixie/pixie.lpi';

begin
WriteLn(CutString(LONG_PATH, 60, true, 35)); // /Users/milipili/ Projec...r1/pixie/client/src/pixie/pixie.lpi
end.


--
Damien Gerard
[EMAIL PROTECTED]



_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to