@@ -155,8 +155,6 @@ TEditor = class(TObject)
155
155
fCurrentEvalWord: String;
156
156
fIgnoreCaretChange: boolean;
157
157
fPreviousEditors: TList;
158
- fDblClickTime: Cardinal;
159
- fDblClickMousePos: TBufferCoord;
160
158
fCompletionTimer: TTimer;
161
159
fCompletionBox: TCodeCompletion;
162
160
fCompletionInitialPosition: TBufferCoord;
@@ -172,8 +170,6 @@ TEditor = class(TObject)
172
170
procedure EditorKeyDown (Sender: TObject; var Key: Word; Shift: TShiftState);
173
171
procedure EditorKeyUp (Sender: TObject; var Key: Word; Shift: TShiftState);
174
172
procedure EditorMouseUp (Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
175
- procedure EditorDblClick (Sender: TObject);
176
- procedure EditorClick (Sender: TObject);
177
173
procedure EditorStatusChange (Sender: TObject; Changes: TSynStatusChanges);
178
174
procedure EditorReplaceText (Sender: TObject; const aSearch, aReplace: String; Line, Column: integer; var Action:
179
175
TSynReplaceAction);
@@ -346,9 +342,9 @@ procedure TDebugGutter.LinesDeleted(FirstLine, Count: integer);
346
342
347
343
{ Encoding }
348
344
349
- function IsStrUTF8 (const Tex : AnsiString): boolean;
345
+ function IsStrUTF8 (const Text : AnsiString): boolean;
350
346
begin
351
- result := (Tex <> ' ' ) and (UTF8Decode(Tex ) <> ' ' );
347
+ result := (Text <> ' ' ) and (UTF8Decode(Text ) <> Text );
352
348
end ;
353
349
354
350
function UTF8FileBOM (const FileName: string): boolean;
@@ -506,8 +502,8 @@ constructor TEditor.Create(const Filename: String; InProject, NewFile: boolean;
506
502
// TSynEditStringListEx(fText.Lines).SetEncoding(AEncoding);
507
503
end ;
508
504
end ;
509
-
510
505
fText.Lines.LoadFromFile(FileName, AEncoding);
506
+
511
507
fNew := False;
512
508
513
509
// Save main.cpp as main.123456789.cpp
@@ -518,8 +514,8 @@ constructor TEditor.Create(const Filename: String; InProject, NewFile: boolean;
518
514
end else
519
515
begin
520
516
// Initialize Lines
521
- var EmptyStream := TStringStream.Create(' ' );
522
- fText.Lines.LoadFromStream(EmptyStream);
517
+ var EmptyStream := TStringStream.Create(' ' , devEditor.GetNewDocEncoding );
518
+ fText.Lines.LoadFromStream(EmptyStream, devEditor.GetNewDocEncoding );
523
519
EmptyStream.Free;
524
520
525
521
fNew := True;
@@ -534,8 +530,6 @@ constructor TEditor.Create(const Filename: String; InProject, NewFile: boolean;
534
530
fText.OnStatusChange := EditorStatusChange;
535
531
fText.OnReplaceText := EditorReplaceText;
536
532
fText.OnDropFiles := EditorDropFiles;
537
- fText.OnDblClick := EditorDblClick;
538
- fText.OnClick := EditorClick;
539
533
fText.OnMouseUp := EditorMouseUp;
540
534
fText.OnMouseMove := EditorMouseMove;
541
535
fText.OnGutterClick := EditorGutterClick;
@@ -1104,6 +1098,9 @@ function TEditor.UpdateEncoding(const FileName: string; AEncoding: TEncoding = n
1104
1098
Exit;
1105
1099
end ;
1106
1100
1101
+ if Assigned(LLines.Encoding) and (LLines.Encoding <> TEncoding.Default) then
1102
+ Exit;
1103
+
1107
1104
for I := 0 to LLines.Count-1 do
1108
1105
if IsStrUTF8(LLines[i]) then
1109
1106
// if _IsUnicodeStringMappableToAnsi(LLines[i]) then
@@ -1755,38 +1752,6 @@ procedure TEditor.CompletionInsert(const append: String);
1755
1752
end ;
1756
1753
end ;
1757
1754
1758
- procedure TEditor.EditorDblClick (Sender: TObject);
1759
- begin
1760
- fDblClickTime := GetTickCount;
1761
- fText.GetPositionOfMouse(fDblClickMousePos);
1762
- end ;
1763
-
1764
- procedure TEditor.EditorClick (Sender: TObject);
1765
- var
1766
- fTripleClickTime: Cardinal;
1767
- fTripleClickMousePos: TBufferCoord;
1768
- begin
1769
- fTripleClickTime := GetTickCount;
1770
- fText.GetPositionOfMouse(fTripleClickMousePos);
1771
- if (fTripleClickTime > fDblClickTime) and
1772
- (fTripleClickTime - GetDoubleClickTime < fDblClickTime) and
1773
- (fTripleClickMousePos.Char = fDblClickMousePos.Char) and
1774
- (fTripleClickMousePos.Line = fDblClickMousePos.Line) then begin
1775
-
1776
- // Don't let the editor change the caret
1777
- fText.StateFlags := fText.StateFlags - [sfOleDragSource];
1778
-
1779
- // Select the current line
1780
- if fText.CaretY < fText.Lines.Count then begin
1781
- fText.BlockBegin := BufferCoord(1 , fText.CaretY);
1782
- fText.BlockEnd := BufferCoord(1 , fText.CaretY + 1 );
1783
- end else begin
1784
- fText.BlockBegin := BufferCoord(1 , fText.CaretY);
1785
- fText.BlockEnd := BufferCoord(Length(fText.Lines[fText.CaretY - 1 ]) + 1 , fText.CaretY);
1786
- end ;
1787
- end ;
1788
- end ;
1789
-
1790
1755
procedure TEditor.EditorMouseMove (Sender: TObject; Shift: TShiftState; X, Y: Integer);
1791
1756
var
1792
1757
s: String;
@@ -2020,8 +1985,7 @@ procedure TEditor.EditorPaintTransient(Sender: TObject; Canvas: TCanvas; Transie
2020
1985
Exit;
2021
1986
2022
1987
// Is the OpenChar before/after us highlighted as a symbol (not a comment or something)?
2023
- if not (fText.GetHighlighterAttriAtRowCol(HighlightCharPos, S, Attri) and (Attri = fText.Highlighter.SymbolAttribute))
2024
- then
1988
+ if not (fText.GetHighlighterAttriAtRowCol(HighlightCharPos, S, Attri) and (Attri = fText.Highlighter.SymbolAttribute)) then
2025
1989
Exit;
2026
1990
2027
1991
// Find the corresponding bracket
@@ -2041,17 +2005,17 @@ procedure TEditor.EditorPaintTransient(Sender: TObject; Canvas: TCanvas; Transie
2041
2005
Canvas.Font.Style := Attri.Style;
2042
2006
2043
2007
// Draw the character the caret is at here using this color
2044
- SetColors(HighlightCharPos);
2045
2008
Pix := fText.RowColumnToPixels(fText.BufferToDisplayPos(HighlightCharPos));
2009
+ SetColors(HighlightCharPos); // SetColors must be after BufferToDisplayPos as BufferToDisplayPos reset Canvas
2046
2010
2047
2011
if Pix.X > fText.Gutter.Width then begin // only draw if inside viewable area
2048
2012
S := fText.Lines[HighlightCharPos.Line - 1 ][HighlightCharPos.Char];
2049
2013
Canvas.TextOut(Pix.X, Pix.Y, S);
2050
2014
end ;
2051
2015
2052
2016
// Then draw complement
2053
- SetColors(ComplementCharPos);
2054
2017
Pix := fText.RowColumnToPixels(fText.BufferToDisplayPos(ComplementCharPos));
2018
+ SetColors(ComplementCharPos); // SetColors must be after BufferToDisplayPos as BufferToDisplayPos reset Canvas
2055
2019
2056
2020
if Pix.X > fText.Gutter.Width then begin // only draw if inside viewable area
2057
2021
S := fText.Lines[ComplementCharPos.Line - 1 ][ComplementCharPos.Char];
@@ -2262,11 +2226,6 @@ procedure TSynEditEx.CommandProcessor(Command: TSynEditorCommand; AChar: Char; D
2262
2226
2263
2227
inherited ;
2264
2228
2265
- if SpaceCount2 > 0 then begin
2266
- // Lines[CaretY] := Copy(Lines[BackCounter], 1, SpaceCount2); // copy previous indent
2267
- if not (eoTabsToSpaces in Options) then
2268
- SpaceCount2 := SpaceCount2-(TabWidth-1 ); // Workaround to fix #55
2269
- end ;
2270
2229
var Attr: TSynHighlighterAttributes;
2271
2230
if GetHighlighterAttriAtRowCol(BufferCoord(Length(Temp), CaretY - 1 ), Temp, Attr) then begin // only add indent to source files
2272
2231
if Attr <> Highlighter.CommentAttribute then begin // and outside of comments
@@ -2280,8 +2239,8 @@ procedure TSynEditEx.CommandProcessor(Command: TSynEditorCommand; AChar: Char; D
2280
2239
end ;
2281
2240
end ;
2282
2241
end ;
2242
+ InternalCaretXY := BufferCoord(SpaceCount2 + 1 , CaretY);
2283
2243
end ;
2284
- InternalCaretXY := BufferCoord(SpaceCount2 + 1 , CaretY);
2285
2244
Exit;
2286
2245
end ;
2287
2246
@@ -2313,6 +2272,14 @@ constructor TSynEditEx.Create(AOwner: TComponent);
2313
2272
begin
2314
2273
inherited Create(AOwner);
2315
2274
FeoAddIndent := False;
2275
+
2276
+ var DeleteLineIndex := Keystrokes.FindCommand(ecDeleteLine);
2277
+ if DeleteLineIndex <> -1 then
2278
+ Keystrokes.Delete(DeleteLineIndex);
2279
+
2280
+ DeleteLineIndex := Keystrokes.FindCommand(ecDeleteEOL);
2281
+ if DeleteLineIndex <> -1 then
2282
+ Keystrokes.Delete(DeleteLineIndex);
2316
2283
end ;
2317
2284
2318
2285
procedure TSynEditEx.DoComment ;
0 commit comments