@@ -37,6 +37,8 @@ TTextRange = class
3737 FStartPos: Sci_Position;
3838 FEndPos: Sci_Position;
3939
40+ function GetAnchor (): Sci_Position;
41+ procedure SetAnchor (const AValue: Sci_Position);
4042 function GetStart (): Sci_Position; virtual ;
4143 procedure SetStart (const AValue: Sci_Position); virtual ;
4244 function GetEnd (): Sci_Position; virtual ;
@@ -57,10 +59,12 @@ TTextRange = class
5759 destructor Destroy; override;
5860
5961 procedure Select ();
62+ procedure ClearSelection ;
6063 procedure Indent (const Levels: integer = 1 );
6164 procedure Mark (const Style: integer; const DurationInMs: cardinal = 0 );
6265
6366 property Document: TActiveDocument read FEditor;
67+ property Anchor: Sci_Position read GetAnchor write SetAnchor;
6468 property StartPos: Sci_Position read FStartPos write SetStart;
6569 property EndPos: Sci_Position read FEndPos write SetEnd;
6670 property Length: Sci_Position read GetLength write SetLength;
@@ -75,8 +79,6 @@ TTextRange = class
7579 { -------------------------------------------------------------------------------------------- }
7680 TSelection = class (TTextRange)
7781 protected
78- function GetAnchor (): Sci_Position;
79- procedure SetAnchor (const AValue: Sci_Position);
8082 function GetCurrentPos (): Sci_Position;
8183 procedure SetCurrentPos (const AValue: Sci_Position);
8284 function GetStart (): Sci_Position; override;
@@ -90,7 +92,6 @@ TSelection = class(TTextRange)
9092 public
9193 constructor Create(const AEditor: TActiveDocument);
9294
93- property Anchor: Sci_Position read GetAnchor write SetAnchor;
9495 property Position: Sci_Position read GetCurrentPos write SetCurrentPos;
9596 property StartPos: Sci_Position read GetStart write SetStart;
9697 property EndPos: Sci_Position read GetEnd write SetEnd;
@@ -143,6 +144,7 @@ TActiveDocument = class(TWindowedObject)
143144 procedure SetText (const AValue: WideString);
144145 function GetLength (): Sci_Position;
145146 function GetLineCount (): Sci_Position;
147+ function GetNextLineStart (): Sci_Position;
146148 function GetLangType (): LangType;
147149 procedure SetLangType (const AValue: LangType);
148150
@@ -174,6 +176,7 @@ TActiveDocument = class(TWindowedObject)
174176 property Text: WideString read GetText write SetText;
175177 property Length: Sci_Position read GetLength;
176178 property LineCount: Sci_Position read GetLineCount;
179+ property NextLineStartPosition: Sci_Position read GetNextLineStart;
177180 property Language: LangType read GetLangType write SetLangType;
178181
179182 property CurrentPosition:Sci_Position read GetCurrentPos write SetCurrentPos;
@@ -301,6 +304,18 @@ destructor TTextRange.Destroy;
301304 inherited ;
302305end ;
303306
307+ { ------------------------------------------------------------------------------------------------ }
308+ function TTextRange.GetAnchor : Sci_Position;
309+ begin
310+ Result := FEditor.SendMessage(SCI_GETANCHOR);
311+ end ;
312+
313+ { ------------------------------------------------------------------------------------------------ }
314+ procedure TTextRange.SetAnchor (const AValue: Sci_Position);
315+ begin
316+ FEditor.SendMessage(SCI_SETANCHOR, AValue);
317+ end ;
318+
304319{ ------------------------------------------------------------------------------------------------ }
305320
306321function TTextRange.GetStart : Sci_Position;
@@ -467,6 +482,18 @@ procedure TTextRange.Select;
467482 FEditor.SendMessage(SCI_SCROLLCARET);
468483end ;
469484
485+ { ------------------------------------------------------------------------------------------------ }
486+ procedure TTextRange.ClearSelection ();
487+ var
488+ SciMsg: Cardinal;
489+ begin
490+ if (Self.Anchor > FEditor.CurrentPosition) then
491+ SciMsg := SCI_POSITIONBEFORE
492+ else
493+ SciMsg := SCI_POSITIONAFTER;
494+ FEditor.CurrentPosition := FEditor.SendMessage(SciMsg, FEditor.CurrentPosition);
495+ end ;
496+
470497{ ================================================================================================ }
471498{ TSelection }
472499
@@ -477,18 +504,6 @@ constructor TSelection.Create(const AEditor: TActiveDocument);
477504
478505{ ------------------------------------------------------------------------------------------------ }
479506
480- function TSelection.GetAnchor : Sci_Position;
481- begin
482- Result := FEditor.SendMessage(SCI_GETANCHOR);
483- end ;
484- { ------------------------------------------------------------------------------------------------ }
485- procedure TSelection.SetAnchor (const AValue: Sci_Position);
486- begin
487- FEditor.SendMessage(SCI_SETANCHOR, AValue);
488- end ;
489-
490- { ------------------------------------------------------------------------------------------------ }
491-
492507function TSelection.GetCurrentPos : Sci_Position;
493508begin
494509 Result := FEditor.SendMessage(SCI_GETCURRENTPOS);
@@ -864,6 +879,16 @@ function TActiveDocument.GetLineCount: Sci_Position;
864879
865880{ ------------------------------------------------------------------------------------------------ }
866881
882+ function TActiveDocument.GetNextLineStart (): Sci_Position;
883+ var
884+ LineEndCurrent: Sci_Position;
885+ begin
886+ LineEndCurrent := SendMessage(SCI_GETLINEENDPOSITION, SendMessage(SCI_LINEFROMPOSITION, CurrentPosition));
887+ Result := SendMessage(SCI_POSITIONAFTER, LineEndCurrent);
888+ end ;
889+
890+ { ------------------------------------------------------------------------------------------------ }
891+
867892function TActiveDocument.GetLines (const FirstLine: Sci_Position; const Count: Sci_Position): TTextRange;
868893var
869894 LineCount: Sci_Position;
0 commit comments