* paleobug solved, paste from windows now wraps lines to 200 char. Solves #4943

git-svn-id: trunk@16600 -
This commit is contained in:
marco 2010-12-19 21:59:21 +00:00
parent 9e0b67a2cb
commit 5f3a312d1b

View File

@ -5706,41 +5706,19 @@ begin
end; end;
{$ifdef WinClipSupported} {$ifdef WinClipSupported}
const
linelimit = 200;
function TCustomCodeEditor.ClipPasteWin: Boolean; function TCustomCodeEditor.ClipPasteWin: Boolean;
var OK: boolean; var
l,i : longint; StorePos : TPoint;
p,p10,p2,p13 : pchar;
s : string;
BPos,EPos,StorePos : TPoint;
first : boolean; first : boolean;
procedure InsertStringWrap(const s: string; var i : Longint);
var
BPos,EPos: TPoint;
begin begin
Lock;
OK:=WinClipboardSupported;
if OK then
begin
first:=true;
StorePos:=CurPos;
i:=CurPos.Y;
l:=GetTextWinClipboardSize;
if l=0 then
OK:=false
else
OK:=GetTextWinClipBoardData(p,l);
if OK then
begin
if l>500 then
PushInfo(msg_readingwinclipboard);
AddGroupedAction(eaPasteWin);
p2:=p;
p13:=strpos(p,#13);
p10:=strpos(p,#10);
while assigned(p10) do
begin
if p13+1=p10 then
p13[0]:=#0
else
p10[0]:=#0;
s:=strpas(p2);
if first then if first then
begin begin
{ we need to cut the line in two { we need to cut the line in two
@ -5758,22 +5736,66 @@ begin
EPOS.X:=Length(s);EPos.Y:=i; EPOS.X:=Length(s);EPos.Y:=i;
AddAction(eaInsertLine,BPos,EPos,GetDisplayText(i),GetFlags); AddAction(eaInsertLine,BPos,EPos,GetDisplayText(i),GetFlags);
end; end;
if p13+1=p10 then end;
p13[0]:=#13
var
OK: boolean;
l,i,len,len10 : longint;
p,p10,p2,p13 : pchar;
s : string;
begin
Lock;
OK:=WinClipboardSupported;
if OK then
begin
first:=true;
StorePos:=CurPos;
i:=CurPos.Y;
l:=GetTextWinClipboardSize;
if l=0 then
OK:=false
else else
p10[0]:=#10; OK:=GetTextWinClipBoardData(p,l);
p2:=@p10[1]; if OK then
begin
if l>500 then
PushInfo(msg_readingwinclipboard);
AddGroupedAction(eaPasteWin);
p2:=p;
len:=strlen(p2);
// issue lines ((#13)#10 terminated) of maximally "linelimit" chars.
// does not take initial X position into account
repeat
p13:=strpos(p2,#13); p13:=strpos(p2,#13);
p10:=strpos(p2,#10); p10:=strpos(p2,#10);
end; if len> linelimit then
if strlen(p2)>0 then len:=linelimit;
if assigned(p10) then
begin begin
s:=strpas(p2); len10:=p10-p2;
if not first then if len10<len then
SetCurPtr(0,i+1); begin
InsertText(s); if p13+1=p10 then
dec(len10);
len:=len10;
end
else
p10:=nil; // signal no cleanup
end; end;
SetCurPtr(StorePos.X,StorePos.Y); setlength(s,len);
if len>0 then
move(p2^,s[1],len);
// cleanup
if assigned(p10) then
p2:=p10+1
else
inc(p2,len);
insertstringwrap(s,i);
len:=strlen(p2);
until len=0;
SetCurPtr(StorePos.X,StorePos.Y); // y+i to get after paste?
SetModified(true); SetModified(true);
UpdateAttrs(StorePos.Y,attrAll); UpdateAttrs(StorePos.Y,attrAll);
CloseGroupedAction(eaPasteWin); CloseGroupedAction(eaPasteWin);