refact full text replacement

This commit is contained in:
Basile Burg 2016-11-27 08:52:35 +01:00
parent f3fadfffe0
commit ee6e282f2b
No known key found for this signature in database
GPG Key ID: 1868039F415CB8CF
2 changed files with 22 additions and 12 deletions

View File

@ -305,10 +305,7 @@ begin
try try
str := TStringList.Create; str := TStringList.Create;
processOutputToStrings(prc,str); processOutputToStrings(prc,str);
fDoc.ClearAll; fDoc.replaceUndoableContent(str.strictText);
fDoc.InsertTextAtCaret(str.Text);
fDoc.SelStart:= high(integer);
fDoc.ExecuteCommand(ecDeleteLastChar, #0, nil);
except except
fDoc.Lines.Assign(fBackup); fDoc.Lines.Assign(fBackup);
end; end;

View File

@ -268,6 +268,7 @@ type
procedure nextProtectionGroup; procedure nextProtectionGroup;
procedure sortLines; procedure sortLines;
function implementMain: THasMain; function implementMain: THasMain;
procedure replaceUndoableContent(const value: string);
// //
property IdentifierMatchOptions: TIdentifierMatchOptions read fMatchOpts write setMatchOpts; property IdentifierMatchOptions: TIdentifierMatchOptions read fMatchOpts write setMatchOpts;
property Identifier: string read fIdentifier; property Identifier: string read fIdentifier;
@ -2288,10 +2289,28 @@ begin
end; end;
end; end;
procedure TCESynMemo.replaceUndoableContent(const value: string);
var
b: TPoint;
e: TPoint;
p: TPoint;
begin
p := CaretXY;
b := point(1,1);
e := Point(length(Lines[lines.Count-1])+1,lines.Count);
TextBetweenPoints[b,e] := value;
CaretXY := p;
EnsureCursorPosVisible;
fModified := true;
end;
procedure TCESynMemo.checkFileDate; procedure TCESynMemo.checkFileDate;
var var
newDate: double; newDate: double;
str: TStringList; str: TStringList;
txt: string;
b,e: TPoint;
p: TPoint;
begin begin
if fFilename = fTempFileName then exit; if fFilename = fTempFileName then exit;
if fDisableFileDateCheck then exit; if fDisableFileDateCheck then exit;
@ -2307,11 +2326,7 @@ begin
str := TStringList.Create; str := TStringList.Create;
try try
str.LoadFromFile(fFilename); str.LoadFromFile(fFilename);
ClearAll; replaceUndoableContent(str.strictText);
InsertTextAtCaret(str.Text);
SelStart:= high(integer);
ExecuteCommand(ecDeleteLastChar, #0, nil);
fModified := true;
finally finally
str.Free; str.Free;
end; end;
@ -2361,9 +2376,7 @@ begin
//lst[i] := lne; //lst[i] := lne;
end} end}
end; end;
lne := lst.Text; clipboard.asText := lst.strictText;
setLength(lne, lne.length - lst.LineBreak.length);
clipboard.asText := lne;
finally finally
lst.free; lst.free;
end; end;