Indent block when Persistent blocks are off

This commit is contained in:
Margers 2024-09-01 20:47:08 +00:00 committed by Michael Van Canneyt
parent 517123899a
commit 28aaa672a1

View File

@ -5376,11 +5376,15 @@ var
ey,i{,indlen} : Sw_integer;
S,Ind : String;
Pos : Tpoint;
WasPersistentBlocks : boolean;
begin
if IsReadOnly then Exit;
if (SelStart.X=SelEnd.X) and (SelStart.Y=SelEnd.Y) then Exit;
Lock;
AddGroupedAction(eaIndentBlock);
WasPersistentBlocks:=IsFlagSet(efPersistentBlocks);
if not WasPersistentBlocks then
SetFlags(GetFlags or efPersistentBlocks);
ey:=selend.y;
if selend.x=0 then
dec(ey);
@ -5425,6 +5429,9 @@ begin
AddAction(eaInsertText,Pos,Pos,Ind,GetFlags);
end;
SetCurPtr(CurPos.X,CurPos.Y);
{after SetCurPtr return PersistentBlocks as it was before}
if not WasPersistentBlocks then
SetFlags(GetFlags and (not longword(efPersistentBlocks)));
{ must be added manually here PM }
AddAction(eaMoveCursor,Pos,CurPos,'',GetFlags);
UpdateAttrsRange(SelStart.Y,SelEnd.Y,attrAll);
@ -5439,11 +5446,15 @@ var
ey,i,j,k,indlen : Sw_integer;
S : String;
Pos : TPoint;
WasPersistentBlocks : boolean;
begin
if IsReadOnly then Exit;
if (SelStart.X=SelEnd.X) and (SelStart.Y=SelEnd.Y) then Exit;
Lock;
AddGroupedAction(eaUnindentBlock);
WasPersistentBlocks:=IsFlagSet(efPersistentBlocks);
if not WasPersistentBlocks then
SetFlags(GetFlags or efPersistentBlocks);
ey:=selend.y;
if selend.x=0 then
dec(ey);
@ -5501,6 +5512,9 @@ begin
end;
end;
SetCurPtr(CurPos.X,CurPos.Y);
{after SetCurPtr return PersistentBlocks as it was before}
if not WasPersistentBlocks then
SetFlags(GetFlags and (not longword(efPersistentBlocks)));
UpdateAttrsRange(SelStart.Y,SelEnd.Y,attrAll);
DrawLines(CurPos.Y);
SetModified(true);