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
str := TStringList.Create;
processOutputToStrings(prc,str);
fDoc.ClearAll;
fDoc.InsertTextAtCaret(str.Text);
fDoc.SelStart:= high(integer);
fDoc.ExecuteCommand(ecDeleteLastChar, #0, nil);
fDoc.replaceUndoableContent(str.strictText);
except
fDoc.Lines.Assign(fBackup);
end;

View File

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