mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 08:59:13 +02:00
implemented inserting Tab chars in synedit
git-svn-id: trunk@5314 -
This commit is contained in:
parent
70c99062d7
commit
aeff605972
@ -876,6 +876,34 @@ begin
|
|||||||
fSynEditClipboardFormat := ClipboardRegisterFormat(SYNEDIT_CLIPBOARD_FORMAT);
|
fSynEditClipboardFormat := ClipboardRegisterFormat(SYNEDIT_CLIPBOARD_FORMAT);
|
||||||
Result:=fSynEditClipboardFormat;
|
Result:=fSynEditClipboardFormat;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function CreateTabsAndSpaces(StartPos, SpaceLen, TabWidth: integer;
|
||||||
|
TabsToSpaces: boolean): string;
|
||||||
|
var
|
||||||
|
TabCount: Integer;
|
||||||
|
EndPos: Integer;
|
||||||
|
PosPlusOneTab: Integer;
|
||||||
|
begin
|
||||||
|
Result:='';
|
||||||
|
if TabsToSpaces then begin
|
||||||
|
Result:=StringOfChar(' ',SpaceLen);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
TabCount:=0;
|
||||||
|
EndPos:=StartPos+SpaceLen;
|
||||||
|
while StartPos<EndPos do begin
|
||||||
|
PosPlusOneTab:=StartPos+TabWidth-((StartPos-1) mod TabWidth);
|
||||||
|
if PosPlusOneTab<=EndPos then begin
|
||||||
|
inc(TabCount);
|
||||||
|
StartPos:=PosPlusOneTab;
|
||||||
|
end else begin
|
||||||
|
Result:=StringOfChar(' ',EndPos-StartPos);
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if TabCount>0 then
|
||||||
|
Result:=StringOfChar(#9,TabCount)+Result;
|
||||||
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
function Roundoff(X: Extended): Longint;
|
function Roundoff(X: Extended): Longint;
|
||||||
@ -3796,8 +3824,13 @@ var
|
|||||||
Result := 0;
|
Result := 0;
|
||||||
sLeftSide := Copy(LineText, 1, CaretX - 1);
|
sLeftSide := Copy(LineText, 1, CaretX - 1);
|
||||||
if CaretX - 1 > Length(sLeftSide) then begin
|
if CaretX - 1 > Length(sLeftSide) then begin
|
||||||
sLeftSide := sLeftSide + StringOfChar(' ',
|
{$IFDEF SYN_LAZARUS}
|
||||||
CaretX - 1 - Length(sLeftSide));
|
sLeftSide := sLeftSide + CreateTabsAndSpaces(CaretX,
|
||||||
|
CaretX-1-Length(sLeftSide),TabWidth,
|
||||||
|
eoTabsToSpaces in Options);
|
||||||
|
{$ELSE}
|
||||||
|
sLeftSide := sLeftSide + StringOfChar(' ', CaretX-1-Length(sLeftSide));
|
||||||
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
sRightSide := Copy(LineText, CaretX, Length(LineText) - (CaretX - 1));
|
sRightSide := Copy(LineText, CaretX, Length(LineText) - (CaretX - 1));
|
||||||
if eoTrimTrailingSpaces in Options then
|
if eoTrimTrailingSpaces in Options then
|
||||||
@ -7324,7 +7357,11 @@ begin
|
|||||||
repeat
|
repeat
|
||||||
// NOTE mh: after throwing in real tabs we have to use:
|
// NOTE mh: after throwing in real tabs we have to use:
|
||||||
// PrevLine := pConvert(Lines[iLine], TabWidth);
|
// PrevLine := pConvert(Lines[iLine], TabWidth);
|
||||||
|
{$IFDEF SYN_LAZARUS}
|
||||||
|
PrevLine := TSynEditStringList(fLines).ExpandedStrings[iLine];
|
||||||
|
{$ELSE}
|
||||||
PrevLine := Lines[iLine];
|
PrevLine := Lines[iLine];
|
||||||
|
{$ENDIF}
|
||||||
if (Length(PrevLine) >= MinLen) then begin
|
if (Length(PrevLine) >= MinLen) then begin
|
||||||
p := @PrevLine[MinLen];
|
p := @PrevLine[MinLen];
|
||||||
// scan over non-whitespaces
|
// scan over non-whitespaces
|
||||||
@ -7350,14 +7387,19 @@ begin
|
|||||||
i := TabWidth - (CaretX - 1) mod TabWidth;
|
i := TabWidth - (CaretX - 1) mod TabWidth;
|
||||||
if i = 0 then i := TabWidth;
|
if i = 0 then i := TabWidth;
|
||||||
end;
|
end;
|
||||||
|
{$IFDEF SYN_LAZARUS}
|
||||||
|
// i now contains the needed spaces
|
||||||
|
Spaces:=CreateTabsAndSpaces(CaretX,i,TabWidth,eoTabsToSpaces in Options);
|
||||||
|
{$ELSE}
|
||||||
Spaces := StringOfChar(' ', i);
|
Spaces := StringOfChar(' ', i);
|
||||||
|
{$ENDIF}
|
||||||
if SelAvail then begin
|
if SelAvail then begin
|
||||||
fUndoList.AddChange(crDelete, fBlockBegin, fBlockEnd, SelText,
|
fUndoList.AddChange(crDelete, fBlockBegin, fBlockEnd, SelText,
|
||||||
SelectionMode);
|
SelectionMode);
|
||||||
end;
|
end;
|
||||||
{begin} //mh 2000-10-01
|
{begin} //mh 2000-10-01
|
||||||
StartOfBlock := CaretXY;
|
StartOfBlock := CaretXY;
|
||||||
NewCaretX := StartOfBlock.X + i;
|
NewCaretX := StartOfBlock.X + {$IFDEF SYN_LAZARUS}length(Spaces){$ELSE}i{$ENDIF};
|
||||||
SetSelText(Spaces);
|
SetSelText(Spaces);
|
||||||
ChangeScroll := not (eoScrollPastEol in fOptions);
|
ChangeScroll := not (eoScrollPastEol in fOptions);
|
||||||
try
|
try
|
||||||
|
@ -54,7 +54,6 @@ type
|
|||||||
property Items[Index: integer]: TMethod read GetItems write SetItems; default;
|
property Items[Index: integer]: TMethod read GetItems write SetItems; default;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function DeleteAmpersands(var Str : String) : Longint;
|
|
||||||
|
|
||||||
function ShortCutToShortCutText(ShortCut: TShortCut): string;
|
function ShortCutToShortCutText(ShortCut: TShortCut): string;
|
||||||
function ShortCutTextToShortCut(const ShortCutText: string): TShortCut;
|
function ShortCutTextToShortCut(const ShortCutText: string): TShortCut;
|
||||||
@ -85,6 +84,7 @@ procedure MakeMinMax(var i1, i2: integer);
|
|||||||
procedure CalculateLeftTopWidthHeight(X1,Y1,X2,Y2: integer;
|
procedure CalculateLeftTopWidthHeight(X1,Y1,X2,Y2: integer;
|
||||||
var Left,Top,Width,Height: integer);
|
var Left,Top,Width,Height: integer);
|
||||||
|
|
||||||
|
function DeleteAmpersands(var Str : String) : Longint;
|
||||||
function BreakString(const s: string; MaxLineLength, Indent: integer): string;
|
function BreakString(const s: string; MaxLineLength, Indent: integer): string;
|
||||||
|
|
||||||
function ComparePointers(p1, p2: Pointer): integer;
|
function ComparePointers(p1, p2: Pointer): integer;
|
||||||
|
Loading…
Reference in New Issue
Block a user