mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-17 14:10:55 +02:00
* paleobug solved, paste from windows now wraps lines to 200 char. Solves #4943
git-svn-id: trunk@16600 -
This commit is contained in:
parent
9e0b67a2cb
commit
5f3a312d1b
114
ide/weditor.pas
114
ide/weditor.pas
@ -5706,18 +5706,49 @@ 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;
|
||||||
|
first : boolean;
|
||||||
|
|
||||||
|
procedure InsertStringWrap(const s: string; var i : Longint);
|
||||||
|
var
|
||||||
|
BPos,EPos: TPoint;
|
||||||
|
begin
|
||||||
|
if first then
|
||||||
|
begin
|
||||||
|
{ we need to cut the line in two
|
||||||
|
if not at end of line PM }
|
||||||
|
InsertNewLine;
|
||||||
|
SetCurPtr(StorePos.X,StorePos.Y);
|
||||||
|
InsertText(s);
|
||||||
|
first:=false;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
Inc(i);
|
||||||
|
InsertLine(i,s);
|
||||||
|
BPos.X:=0;BPos.Y:=i;
|
||||||
|
EPOS.X:=Length(s);EPos.Y:=i;
|
||||||
|
AddAction(eaInsertLine,BPos,EPos,GetDisplayText(i),GetFlags);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
OK: boolean;
|
||||||
|
l,i,len,len10 : longint;
|
||||||
p,p10,p2,p13 : pchar;
|
p,p10,p2,p13 : pchar;
|
||||||
s : string;
|
s : string;
|
||||||
BPos,EPos,StorePos : TPoint;
|
|
||||||
first : boolean;
|
|
||||||
begin
|
begin
|
||||||
Lock;
|
Lock;
|
||||||
OK:=WinClipboardSupported;
|
OK:=WinClipboardSupported;
|
||||||
if OK then
|
if OK then
|
||||||
begin
|
begin
|
||||||
|
|
||||||
first:=true;
|
first:=true;
|
||||||
StorePos:=CurPos;
|
StorePos:=CurPos;
|
||||||
i:=CurPos.Y;
|
i:=CurPos.Y;
|
||||||
@ -5732,48 +5763,39 @@ begin
|
|||||||
PushInfo(msg_readingwinclipboard);
|
PushInfo(msg_readingwinclipboard);
|
||||||
AddGroupedAction(eaPasteWin);
|
AddGroupedAction(eaPasteWin);
|
||||||
p2:=p;
|
p2:=p;
|
||||||
p13:=strpos(p,#13);
|
len:=strlen(p2);
|
||||||
p10:=strpos(p,#10);
|
// issue lines ((#13)#10 terminated) of maximally "linelimit" chars.
|
||||||
while assigned(p10) do
|
// does not take initial X position into account
|
||||||
begin
|
repeat
|
||||||
if p13+1=p10 then
|
p13:=strpos(p2,#13);
|
||||||
p13[0]:=#0
|
p10:=strpos(p2,#10);
|
||||||
else
|
if len> linelimit then
|
||||||
p10[0]:=#0;
|
len:=linelimit;
|
||||||
s:=strpas(p2);
|
if assigned(p10) then
|
||||||
if first then
|
begin
|
||||||
begin
|
len10:=p10-p2;
|
||||||
{ we need to cut the line in two
|
if len10<len then
|
||||||
if not at end of line PM }
|
begin
|
||||||
InsertNewLine;
|
if p13+1=p10 then
|
||||||
SetCurPtr(StorePos.X,StorePos.Y);
|
dec(len10);
|
||||||
InsertText(s);
|
len:=len10;
|
||||||
first:=false;
|
end
|
||||||
end
|
else
|
||||||
else
|
p10:=nil; // signal no cleanup
|
||||||
begin
|
end;
|
||||||
Inc(i);
|
setlength(s,len);
|
||||||
InsertLine(i,s);
|
if len>0 then
|
||||||
BPos.X:=0;BPos.Y:=i;
|
move(p2^,s[1],len);
|
||||||
EPOS.X:=Length(s);EPos.Y:=i;
|
// cleanup
|
||||||
AddAction(eaInsertLine,BPos,EPos,GetDisplayText(i),GetFlags);
|
if assigned(p10) then
|
||||||
end;
|
p2:=p10+1
|
||||||
if p13+1=p10 then
|
else
|
||||||
p13[0]:=#13
|
inc(p2,len);
|
||||||
else
|
insertstringwrap(s,i);
|
||||||
p10[0]:=#10;
|
len:=strlen(p2);
|
||||||
p2:=@p10[1];
|
until len=0;
|
||||||
p13:=strpos(p2,#13);
|
|
||||||
p10:=strpos(p2,#10);
|
SetCurPtr(StorePos.X,StorePos.Y); // y+i to get after paste?
|
||||||
end;
|
|
||||||
if strlen(p2)>0 then
|
|
||||||
begin
|
|
||||||
s:=strpas(p2);
|
|
||||||
if not first then
|
|
||||||
SetCurPtr(0,i+1);
|
|
||||||
InsertText(s);
|
|
||||||
end;
|
|
||||||
SetCurPtr(StorePos.X,StorePos.Y);
|
|
||||||
SetModified(true);
|
SetModified(true);
|
||||||
UpdateAttrs(StorePos.Y,attrAll);
|
UpdateAttrs(StorePos.Y,attrAll);
|
||||||
CloseGroupedAction(eaPasteWin);
|
CloseGroupedAction(eaPasteWin);
|
||||||
|
Loading…
Reference in New Issue
Block a user