You've already forked lazarus-ccr
LazEdit: remove old ANSI versions of SaveToFile/LoadFromFile. Less hints.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7272 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -81,7 +81,7 @@ type
|
|||||||
procedure SetEditorOptions(AValue: TEditorOptions);
|
procedure SetEditorOptions(AValue: TEditorOptions);
|
||||||
procedure UpdateEditorOptions(Sender: TObject);
|
procedure UpdateEditorOptions(Sender: TObject);
|
||||||
function GetUniquePageCaption(const AName: String): String;
|
function GetUniquePageCaption(const AName: String): String;
|
||||||
procedure SetFileName(const Utf8Fn: String; const UpdateFileType: Boolean);
|
procedure SetFileName(const Fn: String; const UpdateFileType: Boolean);
|
||||||
//function ExtToFileType(const Ext: String): TEditorFileType;
|
//function ExtToFileType(const Ext: String): TEditorFileType;
|
||||||
function GuessFileType: TEditorFileType;
|
function GuessFileType: TEditorFileType;
|
||||||
function GuessSyntaxFromString(S: String): TEditorFileType;
|
function GuessSyntaxFromString(S: String): TEditorFileType;
|
||||||
@ -96,10 +96,8 @@ type
|
|||||||
property EditorOptions: TEditorOptions read FEditorOptions write SetEditorOptions;
|
property EditorOptions: TEditorOptions read FEditorOptions write SetEditorOptions;
|
||||||
public
|
public
|
||||||
procedure SetDefaultKeyStrokes; override; // is public in parent class
|
procedure SetDefaultKeyStrokes; override; // is public in parent class
|
||||||
procedure LoadFromFileAnsi(const AnsiFn: String; const AsTemplate: Boolean = False);
|
procedure LoadFromFile(const Fn: String; const AsTemplate: Boolean = False);
|
||||||
procedure LoadFromFileUtf8(const Utf8Fn: String; const AsTemplate: Boolean = False);
|
procedure SaveToFile(const Fn: String);
|
||||||
procedure SaveToFileAnsi(const AnsiFn: String);
|
|
||||||
procedure SaveToFileUtf8(const Utf8Fn: String);
|
|
||||||
function IsUnused: Boolean;
|
function IsUnused: Boolean;
|
||||||
procedure SetHighlighterByFileType(const AFileType: TEditorFileType; const Permanent: Boolean = False);
|
procedure SetHighlighterByFileType(const AFileType: TEditorFileType; const Permanent: Boolean = False);
|
||||||
procedure MarkSelection(const Pre, Post: String);
|
procedure MarkSelection(const Pre, Post: String);
|
||||||
@ -227,14 +225,14 @@ end;
|
|||||||
|
|
||||||
{TEditor}
|
{TEditor}
|
||||||
|
|
||||||
procedure TEditor.SetFileName(const Utf8Fn: String; const UpdateFileType: Boolean);
|
procedure TEditor.SetFileName(const Fn: String; const UpdateFileType: Boolean);
|
||||||
begin
|
begin
|
||||||
//debugln('TEditor.SetFileName: Utf8Fn = ',Utf8ToSys(Utf8Fn));
|
//debugln('TEditor.SetFileName: Fn = ',Fn);
|
||||||
if (FFileName = Utf8Fn) and (Utf8Fn <> EmptyStr) then Exit;
|
if (FFileName = Fn) and (Fn <> EmptyStr) then Exit;
|
||||||
FFileName := Utf8Fn;
|
FFileName := Fn;
|
||||||
if Assigned(FPage) then
|
if Assigned(FPage) then
|
||||||
begin
|
begin
|
||||||
FPage.Caption := GetUniquePageCaption(Utf8Fn);
|
FPage.Caption := GetUniquePageCaption(Fn);
|
||||||
//Debugln('TEditor.SetFileName: setting FPageCaption to ',FPage.Caption);
|
//Debugln('TEditor.SetFileName: setting FPageCaption to ',FPage.Caption);
|
||||||
end;
|
end;
|
||||||
//Unless you change ReadOnly, the scFileName will be removed from Changes in TSynEdit.DoOnStatuschange
|
//Unless you change ReadOnly, the scFileName will be removed from Changes in TSynEdit.DoOnStatuschange
|
||||||
@ -643,20 +641,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
//SynEdit deafults to UTF8 filenames when using LoadFromFile !!
|
procedure TEditor.LoadFromFile(const Fn: String; const AsTemplate: Boolean = False);
|
||||||
procedure TEditor.LoadFromFileAnsi(const AnsiFn: String; const AsTemplate: Boolean = False);
|
|
||||||
begin
|
begin
|
||||||
LoadFromFileUtf8(WinCPToUTF8(AnsiFn), AsTemplate);
|
//DebugLn('TEditor.LoadFromFile: Fn = ',Fn);
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TEditor.LoadFromFileUtf8(const Utf8Fn: String; const AsTemplate: Boolean = False);
|
|
||||||
begin
|
|
||||||
//DebugLn('TEditor.LoadFromFile: Utf8Fn = ',Utf8ToSys(Utf8Fn));
|
|
||||||
try
|
try
|
||||||
Lines.LoadFromFile(Utf8Fn);
|
Lines.LoadFromFile(Fn);
|
||||||
Modified := False;
|
Modified := False;
|
||||||
FNoFileTypeChangeOnSave := False;
|
FNoFileTypeChangeOnSave := False;
|
||||||
SetFileName(Utf8Fn, AutoFileTypeDetection);
|
SetFileName(Fn, AutoFileTypeDetection);
|
||||||
if AsTemplate then
|
if AsTemplate then
|
||||||
begin//blank out internal filename and update caption
|
begin//blank out internal filename and update caption
|
||||||
FFileName := EmptyStr;
|
FFileName := EmptyStr;
|
||||||
@ -674,12 +666,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TEditor.SaveToFileAnsi(const AnsiFn: String);
|
procedure TEditor.SaveToFile(const Fn: String);
|
||||||
begin
|
|
||||||
SaveToFileAnsi(WinCPToUtf8(AnsiFn));
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TEditor.SaveToFileUtf8(const Utf8Fn: String);
|
|
||||||
var
|
var
|
||||||
Attr: LongInt;
|
Attr: LongInt;
|
||||||
begin
|
begin
|
||||||
@ -688,16 +675,16 @@ begin
|
|||||||
//TFileStreamUtf8.Create fails on hidden files on Windows,
|
//TFileStreamUtf8.Create fails on hidden files on Windows,
|
||||||
//because it uses FILE_ATTRIBUTE_NORMAL
|
//because it uses FILE_ATTRIBUTE_NORMAL
|
||||||
//see http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858%28v=vs.85%29.aspx
|
//see http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858%28v=vs.85%29.aspx
|
||||||
Attr := FileGetAttrUTF8(Utf8Fn);
|
Attr := FileGetAttrUTF8(Fn);
|
||||||
if (Attr = LongInt(feInvalidHandle)) then Attr := 0;
|
if (Attr = LongInt(feInvalidHandle)) then Attr := 0;
|
||||||
if ((Attr and faHidden) = faHidden) then FileSetAttrUtf8(Utf8Fn, Attr and (not faHidden));
|
if ((Attr and faHidden{%H-}) = faHidden{%H-}) then FileSetAttrUtf8(Fn, Attr and (not faHidden{%H-}));
|
||||||
{$endif}
|
{$endif}
|
||||||
Lines.SaveToFile(Utf8Fn);
|
Lines.SaveToFile(Fn);
|
||||||
{$ifdef windows}
|
{$ifdef windows}
|
||||||
if ((Attr and faHidden) = faHidden) then FileSetAttrUtf8(Utf8Fn, Attr or faHidden or faArchive);
|
if ((Attr and faHidden{%H-}) = faHidden{%H-}) then FileSetAttrUtf8(Fn, Attr or faHidden{%H-} or faArchive);
|
||||||
{$endif}
|
{$endif}
|
||||||
Modified := False;
|
Modified := False;
|
||||||
SetFileName(Utf8Fn, AutoFileTypeDetection and (not FNoFileTypeChangeOnSave));
|
SetFileName(Fn, AutoFileTypeDetection and (not FNoFileTypeChangeOnSave));
|
||||||
except
|
except
|
||||||
Modified := True;
|
Modified := True;
|
||||||
SetFileName(EmptyStr, AutoFileTypeDetection and (not FNoFileTypeChangeOnSave));
|
SetFileName(EmptyStr, AutoFileTypeDetection and (not FNoFileTypeChangeOnSave));
|
||||||
@ -723,8 +710,8 @@ end;
|
|||||||
|
|
||||||
procedure TEditor.MarkSelection(const Pre, Post: String);
|
procedure TEditor.MarkSelection(const Pre, Post: String);
|
||||||
var
|
var
|
||||||
BB, BE, LC: TPoint;
|
BB, BE: TPoint;
|
||||||
BackwardsSel, HadSelection: Boolean;
|
HadSelection: Boolean;
|
||||||
begin
|
begin
|
||||||
//Putting all this in BeginUpdate/EndUpdate ensures that all actions taken here
|
//Putting all this in BeginUpdate/EndUpdate ensures that all actions taken here
|
||||||
//can be undone in one undo operation (otherwise it would take 2 or 3)
|
//can be undone in one undo operation (otherwise it would take 2 or 3)
|
||||||
@ -734,7 +721,6 @@ begin
|
|||||||
//than using SelStart and SelLength (like the old code did)
|
//than using SelStart and SelLength (like the old code did)
|
||||||
BB := BlockBegin;
|
BB := BlockBegin;
|
||||||
BE := BlockEnd;
|
BE := BlockEnd;
|
||||||
BackwardsSel := IsBackwardSel;
|
|
||||||
//In an newly create TSynEdit without any text SetTextBetweenPoints does not
|
//In an newly create TSynEdit without any text SetTextBetweenPoints does not
|
||||||
//adjust BlockBegin/BlockEnd at all, so force a line and set the caret at the top
|
//adjust BlockBegin/BlockEnd at all, so force a line and set the caret at the top
|
||||||
if (Lines.Count = 0) then //fixed in trunk, remove after 2.2 release
|
if (Lines.Count = 0) then //fixed in trunk, remove after 2.2 release
|
||||||
|
@ -45,7 +45,7 @@ Uses Classes, SysUtils, LCLProc;
|
|||||||
const
|
const
|
||||||
AppName = 'LazEdit';
|
AppName = 'LazEdit';
|
||||||
AboutTitle = 'About ' + AppName;
|
AboutTitle = 'About ' + AppName;
|
||||||
AppVersion = 'Version 2.2';
|
AppVersion = 'Version 2.3';
|
||||||
CopyLeftStatement = 'Copyright (c) 2011, 2020 by Bart Broersma, FlyingSheep Inc. and'+ LineEnding +
|
CopyLeftStatement = 'Copyright (c) 2011, 2020 by Bart Broersma, FlyingSheep Inc. and'+ LineEnding +
|
||||||
'Felipe Monteiro de Carvalho';
|
'Felipe Monteiro de Carvalho';
|
||||||
MetaGeneratorName = AppName + #32 + AppVersion;
|
MetaGeneratorName = AppName + #32 + AppVersion;
|
||||||
|
@ -358,7 +358,7 @@ type
|
|||||||
procedure acLayoutUnderlineExecute(Sender: TObject);
|
procedure acLayoutUnderlineExecute(Sender: TObject);
|
||||||
procedure FindReplaceDialogClose(Sender: TObject);
|
procedure FindReplaceDialogClose(Sender: TObject);
|
||||||
|
|
||||||
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
procedure FormClose(Sender: TObject; var {%H-}CloseAction: TCloseAction);
|
||||||
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure FormDestroy(Sender: TObject);
|
procedure FormDestroy(Sender: TObject);
|
||||||
@ -566,7 +566,6 @@ const pXY = 0; //Panels constanten
|
|||||||
opt_long_prefix = '--';
|
opt_long_prefix = '--';
|
||||||
opt_short_prefix = '-';
|
opt_short_prefix = '-';
|
||||||
opt_long_PCP = 'pcp'; //--pcp=path/to/configfile
|
opt_long_PCP = 'pcp'; //--pcp=path/to/configfile
|
||||||
opt_short_blankpage = 'n';
|
|
||||||
|
|
||||||
|
|
||||||
{ TLazEditMainForm }
|
{ TLazEditMainForm }
|
||||||
@ -2116,7 +2115,7 @@ begin
|
|||||||
if Assigned(Ed) then
|
if Assigned(Ed) then
|
||||||
begin
|
begin
|
||||||
try
|
try
|
||||||
Ed.LoadFromFileUtf8(Fn, AsTemplate);
|
Ed.LoadFromFile(Fn, AsTemplate);
|
||||||
//OnEditorStatusChange(Ed, scAll);
|
//OnEditorStatusChange(Ed, scAll);
|
||||||
MruList.Add(Fn);
|
MruList.Add(Fn);
|
||||||
Result := True;
|
Result := True;
|
||||||
@ -2139,7 +2138,7 @@ begin
|
|||||||
if (Fn = EmptyStr) then Exit(IoCancel);
|
if (Fn = EmptyStr) then Exit(IoCancel);
|
||||||
end;
|
end;
|
||||||
try
|
try
|
||||||
Editor.SaveToFileUtf8(Fn);
|
Editor.SaveToFile(Fn);
|
||||||
//OnEditorStatusChange(Editor, scAll);
|
//OnEditorStatusChange(Editor, scAll);
|
||||||
MruList.Add(Fn);
|
MruList.Add(Fn);
|
||||||
Result := IoSuccess;
|
Result := IoSuccess;
|
||||||
|
Reference in New Issue
Block a user