Skip to content

Commit 685f872

Browse files
authored
Merge pull request #72 from sgapollo/master
Issues 18, 30, 38, 33, 55,66, 41
2 parents 8fb002d + aaf38e7 commit 685f872

File tree

8 files changed

+108
-102
lines changed

8 files changed

+108
-102
lines changed

Lang/English.lng

+3-1
Original file line numberDiff line numberDiff line change
@@ -1256,4 +1256,6 @@ Ver=1
12561256
79018=Could not find AStyle
12571257
79019=Powered by %s
12581258
79020=Max. line length:
1259-
79021=// Could not find the AStyle output file:<CR>// %s
1259+
79021=// Could not find the AStyle output file:<CR>// %s
1260+
79022=Use font ligatures is available
1261+
79023=New Document Encoding:

Source/Compiler.pas

+7-5
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ TCompiler = class
118118
implementation
119119

120120
uses
121-
System.UITypes, MultiLangSupport, Macros, devExec, main, StrUtils;
121+
System.UITypes, MultiLangSupport, Macros, devExec, main, StrUtils, System.IOUtils;
122122

123123
procedure TCompiler.DoLogEntry(const msg: String);
124124
begin
@@ -171,8 +171,10 @@ procedure TCompiler.NewMakeFile(var F: TextFile);
171171
// Create OBJ output directory
172172
SetCurrentDir(fProject.Directory); // .dev file location
173173
if fProject.Options.ObjectOutput <> '' then
174-
if not DirectoryExists(fProject.Options.ObjectOutput) then
175-
CreateDir(fProject.Options.ObjectOutput);
174+
TDirectory.CreateDirectory(fProject.Options.ObjectOutput);
175+
176+
if not fProject.Options.ExeOutput.IsEmpty then
177+
TDirectory.CreateDirectory(fProject.Options.ExeOutput);
176178

177179
// Should not return custom filename
178180
fMakefile := fProject.MakeFileName;
@@ -283,8 +285,8 @@ procedure TCompiler.WriteMakeDefines(var F: TextFile);
283285
end;
284286
Writeln(F, 'WINDRES = ' + fCompilerSet.windresName);
285287
if (ObjResFile <> '') then begin
286-
Writeln(F, 'RES = ' + GenMakePath1(ObjResFile));
287-
Writeln(F, 'OBJ = ' + Objects + ' $(RES)');
288+
Writeln(F, 'RES = ' + GenMakePath1(ExtractRelativePath(fProject.FileName, ObjResFile)));
289+
Writeln(F, 'OBJ = ' + Objects + ' $(RES)' );
288290
Writeln(F, 'LINKOBJ = ' + LinkObjects + ' $(RES)');
289291
end else begin
290292
Writeln(F, 'OBJ = ' + Objects);

Source/Editor.pas

+20-53
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ TEditor = class(TObject)
155155
fCurrentEvalWord: String;
156156
fIgnoreCaretChange: boolean;
157157
fPreviousEditors: TList;
158-
fDblClickTime: Cardinal;
159-
fDblClickMousePos: TBufferCoord;
160158
fCompletionTimer: TTimer;
161159
fCompletionBox: TCodeCompletion;
162160
fCompletionInitialPosition: TBufferCoord;
@@ -172,8 +170,6 @@ TEditor = class(TObject)
172170
procedure EditorKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
173171
procedure EditorKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
174172
procedure EditorMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
175-
procedure EditorDblClick(Sender: TObject);
176-
procedure EditorClick(Sender: TObject);
177173
procedure EditorStatusChange(Sender: TObject; Changes: TSynStatusChanges);
178174
procedure EditorReplaceText(Sender: TObject; const aSearch, aReplace: String; Line, Column: integer; var Action:
179175
TSynReplaceAction);
@@ -346,9 +342,9 @@ procedure TDebugGutter.LinesDeleted(FirstLine, Count: integer);
346342

347343
{ Encoding }
348344

349-
function IsStrUTF8(const Tex : AnsiString): boolean;
345+
function IsStrUTF8(const Text: AnsiString): boolean;
350346
begin
351-
result := (Tex <> '') and (UTF8Decode(Tex) <> '');
347+
result := (Text <> '') and (UTF8Decode(Text) <> Text);
352348
end;
353349

354350
function UTF8FileBOM(const FileName: string): boolean;
@@ -506,8 +502,8 @@ constructor TEditor.Create(const Filename: String; InProject, NewFile: boolean;
506502
//TSynEditStringListEx(fText.Lines).SetEncoding(AEncoding);
507503
end;
508504
end;
509-
510505
fText.Lines.LoadFromFile(FileName, AEncoding);
506+
511507
fNew := False;
512508

513509
// Save main.cpp as main.123456789.cpp
@@ -518,8 +514,8 @@ constructor TEditor.Create(const Filename: String; InProject, NewFile: boolean;
518514
end else
519515
begin
520516
// 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);
523519
EmptyStream.Free;
524520

525521
fNew := True;
@@ -534,8 +530,6 @@ constructor TEditor.Create(const Filename: String; InProject, NewFile: boolean;
534530
fText.OnStatusChange := EditorStatusChange;
535531
fText.OnReplaceText := EditorReplaceText;
536532
fText.OnDropFiles := EditorDropFiles;
537-
fText.OnDblClick := EditorDblClick;
538-
fText.OnClick := EditorClick;
539533
fText.OnMouseUp := EditorMouseUp;
540534
fText.OnMouseMove := EditorMouseMove;
541535
fText.OnGutterClick := EditorGutterClick;
@@ -1104,6 +1098,9 @@ function TEditor.UpdateEncoding(const FileName: string; AEncoding: TEncoding = n
11041098
Exit;
11051099
end;
11061100

1101+
if Assigned(LLines.Encoding) and (LLines.Encoding <> TEncoding.Default) then
1102+
Exit;
1103+
11071104
for I := 0 to LLines.Count-1 do
11081105
if IsStrUTF8(LLines[i]) then
11091106
//if _IsUnicodeStringMappableToAnsi(LLines[i]) then
@@ -1755,38 +1752,6 @@ procedure TEditor.CompletionInsert(const append: String);
17551752
end;
17561753
end;
17571754

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-
17901755
procedure TEditor.EditorMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
17911756
var
17921757
s: String;
@@ -2020,8 +1985,7 @@ procedure TEditor.EditorPaintTransient(Sender: TObject; Canvas: TCanvas; Transie
20201985
Exit;
20211986

20221987
// 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
20251989
Exit;
20261990

20271991
// Find the corresponding bracket
@@ -2041,17 +2005,17 @@ procedure TEditor.EditorPaintTransient(Sender: TObject; Canvas: TCanvas; Transie
20412005
Canvas.Font.Style := Attri.Style;
20422006

20432007
// Draw the character the caret is at here using this color
2044-
SetColors(HighlightCharPos);
20452008
Pix := fText.RowColumnToPixels(fText.BufferToDisplayPos(HighlightCharPos));
2009+
SetColors(HighlightCharPos); // SetColors must be after BufferToDisplayPos as BufferToDisplayPos reset Canvas
20462010

20472011
if Pix.X > fText.Gutter.Width then begin // only draw if inside viewable area
20482012
S := fText.Lines[HighlightCharPos.Line - 1][HighlightCharPos.Char];
20492013
Canvas.TextOut(Pix.X, Pix.Y, S);
20502014
end;
20512015

20522016
// Then draw complement
2053-
SetColors(ComplementCharPos);
20542017
Pix := fText.RowColumnToPixels(fText.BufferToDisplayPos(ComplementCharPos));
2018+
SetColors(ComplementCharPos); // SetColors must be after BufferToDisplayPos as BufferToDisplayPos reset Canvas
20552019

20562020
if Pix.X > fText.Gutter.Width then begin // only draw if inside viewable area
20572021
S := fText.Lines[ComplementCharPos.Line - 1][ComplementCharPos.Char];
@@ -2262,11 +2226,6 @@ procedure TSynEditEx.CommandProcessor(Command: TSynEditorCommand; AChar: Char; D
22622226

22632227
inherited;
22642228

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;
22702229
var Attr: TSynHighlighterAttributes;
22712230
if GetHighlighterAttriAtRowCol(BufferCoord(Length(Temp), CaretY - 1), Temp, Attr) then begin // only add indent to source files
22722231
if Attr <> Highlighter.CommentAttribute then begin // and outside of comments
@@ -2280,8 +2239,8 @@ procedure TSynEditEx.CommandProcessor(Command: TSynEditorCommand; AChar: Char; D
22802239
end;
22812240
end;
22822241
end;
2242+
InternalCaretXY := BufferCoord(SpaceCount2 + 1, CaretY);
22832243
end;
2284-
InternalCaretXY := BufferCoord(SpaceCount2 + 1, CaretY);
22852244
Exit;
22862245
end;
22872246

@@ -2313,6 +2272,14 @@ constructor TSynEditEx.Create(AOwner: TComponent);
23132272
begin
23142273
inherited Create(AOwner);
23152274
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);
23162283
end;
23172284

23182285
procedure TSynEditEx.DoComment;

0 commit comments

Comments
 (0)