@@ -65,6 +65,7 @@ TScintRangeList = class(TList<TScintRange>)
65
65
TScintRectangle = record
66
66
Left, Top, Right, Bottom: Integer;
67
67
end ;
68
+ TScintSelectionMode = (ssmStream, ssmRectangular, ssmLines, ssmThinRectangular);
68
69
TScintStyleNumber = 0 ..StyleNumbers-1 ;
69
70
TScintVirtualSpaceOption = (svsRectangularSelection, svsUserAccessible,
70
71
svsNoWrapLineStart);
@@ -79,6 +80,8 @@ TScintRangeToFormat = record
79
80
TScintEditStrings = class ;
80
81
TScintCustomStyler = class ;
81
82
83
+ EScintEditError = class (Exception);
84
+
82
85
TScintEdit = class (TWinControl)
83
86
private
84
87
FAcceptDroppedFiles: Boolean;
@@ -135,6 +138,7 @@ TScintEdit = class(TWinControl)
135
138
function GetSelectionAnchorPosition (Selection: Integer): Integer;
136
139
function GetSelectionCaretPosition (Selection: Integer): Integer;
137
140
function GetSelectionCount : Integer;
141
+ function GetSelectionMode : TScintSelectionMode;
138
142
function GetSelText : String;
139
143
function GetTopLine : Integer;
140
144
function GetZoom : Integer;
@@ -157,6 +161,7 @@ TScintEdit = class(TWinControl)
157
161
procedure SetSelection (const Value : TScintRange);
158
162
procedure SetSelectionAnchorPosition (Selection: Integer; const AnchorPos: Integer);
159
163
procedure SetSelectionCaretPosition (Selection: Integer; const CaretPos: Integer);
164
+ procedure SetSelectionMode (const Value : TScintSelectionMode);
160
165
procedure SetSelText (const Value : String);
161
166
procedure SetStyler (const Value : TScintCustomStyler);
162
167
procedure SetTabWidth (const Value : Integer);
@@ -185,7 +190,8 @@ TScintEdit = class(TWinControl)
185
190
procedure CheckPosRange (const StartPos, EndPos: Integer);
186
191
procedure CreateParams (var Params: TCreateParams); override;
187
192
procedure CreateWnd ; override;
188
- class procedure Error (const S: String);
193
+ class function GetErrorException (const S: String): EScintEditError;
194
+ class procedure Error (const S: String); overload;
189
195
class procedure ErrorFmt (const S: String; const Args: array of const );
190
196
function GetMainSelection : Integer;
191
197
function GetTarget : TScintRange;
@@ -316,6 +322,7 @@ TScintEdit = class(TWinControl)
316
322
property SelectionAnchorPosition[Selection: Integer]: Integer read GetSelectionAnchorPosition write SetSelectionAnchorPosition;
317
323
property SelectionCaretPosition[Selection: Integer]: Integer read GetSelectionCaretPosition write SetSelectionCaretPosition;
318
324
property SelectionCount: Integer read GetSelectionCount;
325
+ property SelectionMode: TScintSelectionMode read GetSelectionMode write SetSelectionMode;
319
326
property SelText: String read GetSelText write SetSelText;
320
327
property Styler: TScintCustomStyler read FStyler write SetStyler;
321
328
property TopLine: Integer read GetTopLine write SetTopLine;
@@ -462,8 +469,6 @@ TScintPixmap = class
462
469
property Pixmap: Pointer read GetPixmap;
463
470
end ;
464
471
465
- EScintEditError = class (Exception);
466
-
467
472
function ScintRawStringIsBlank (const S: TScintRawString): Boolean;
468
473
469
474
implementation
@@ -743,9 +748,14 @@ procedure TScintEdit.EndUndoAction;
743
748
Call(SCI_ENDUNDOACTION, 0 , 0 );
744
749
end ;
745
750
751
+ class function TScintEdit.GetErrorException (const S: String): EScintEditError;
752
+ begin
753
+ Result := EScintEditError.Create(' TScintEdit error: ' + S);
754
+ end ;
755
+
746
756
class procedure TScintEdit.Error (const S: String);
747
757
begin
748
- raise EScintEditError.Create( ' TScintEdit error: ' + S);
758
+ raise GetErrorException( S);
749
759
end ;
750
760
751
761
class procedure TScintEdit.ErrorFmt (const S: String; const Args: array of const );
@@ -856,8 +866,9 @@ function TScintEdit.GetLineEndings: TScintLineEndings;
856
866
case Call(SCI_GETEOLMODE, 0 , 0 ) of
857
867
SC_EOL_CR: Result := sleCR;
858
868
SC_EOL_LF: Result := sleLF;
869
+ SC_EOL_CRLF: Result := sleCRLF;
859
870
else
860
- Result := sleCRLF ;
871
+ raise GetErrorException( ' Unexpected SCI_GETEOLMODE result ' ) ;
861
872
end ;
862
873
end ;
863
874
@@ -1077,6 +1088,18 @@ function TScintEdit.GetSelectionCount: Integer;
1077
1088
Result := Call(SCI_GETSELECTIONS, 0 , 0 );
1078
1089
end ;
1079
1090
1091
+ function TScintEdit.GetSelectionMode : TScintSelectionMode;
1092
+ begin
1093
+ case Call(SCI_GETSELECTIONMODE, 0 , 0 ) of
1094
+ SC_SEL_STREAM: Result := ssmStream;
1095
+ SC_SEL_RECTANGLE: Result := ssmRectangular;
1096
+ SC_SEL_LINES: Result := ssmLines;
1097
+ SC_SEL_THIN: Result := ssmThinRectangular;
1098
+ else
1099
+ raise GetErrorException(' Unexpected SCI_GETSELECTIONMODE result' );
1100
+ end ;
1101
+ end ;
1102
+
1080
1103
function TScintEdit.GetSelText : String;
1081
1104
begin
1082
1105
Result := ConvertRawStringToString(GetRawSelText);
@@ -1536,6 +1559,21 @@ procedure TScintEdit.SetSelectionCaretPosition(Selection: Integer;
1536
1559
Call(SCI_SETSELECTIONNCARET, Selection, CaretPos);
1537
1560
end ;
1538
1561
1562
+ procedure TScintEdit.SetSelectionMode (const Value : TScintSelectionMode);
1563
+ begin
1564
+ var Mode: Integer;
1565
+ if Value = ssmStream then
1566
+ Mode := SC_SEL_STREAM
1567
+ else if Value = ssmRectangular then
1568
+ Mode := SC_SEL_RECTANGLE
1569
+ else if Value = ssmLines then
1570
+ Mode := SC_SEL_LINES
1571
+ else
1572
+ Mode := SC_SEL_THIN;
1573
+ { Note this uses *CHANGE* and not *SET* }
1574
+ Call(SCI_CHANGESELECTIONMODE, Mode, 0 );
1575
+ end ;
1576
+
1539
1577
procedure TScintEdit.SetSelText (const Value : String);
1540
1578
begin
1541
1579
SetRawSelText(ConvertStringToRawString(Value ));
0 commit comments