{
To do:
- vor schließen Fenster oder Tabseite -> Datei speichern oder fragen
- In Editwindow -> Editorliste ergänzen
- in Main: Zeile 109 und 153 TEditorPages//(Container)
- in TEditorPages mit TPageControl -> Wenn Noname.pas, dann Datei in diesen Editor
}
unit editor2;
{$ifdef fpc}{$mode objfpc}{$H+}{$endif}
{.define USE_SPTBX}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs,
SynHighlighterPas, SynHighlighterCpp, SynHighlighterDFM, SynHighlighterJava,
SynHighlighterPerl, SynHighlighterHTML, SynHighlighterXML, SynHighlighterCss,
SynHighlighterPHP, SynHighlighterSQL, SynHighlighterPython,
SynEdit, SynCompletionProposal, SynExportHTML, SynMacroRecorder, SynEditHighlighter,
{$ifndef FPC} {$ifdef USE_SPTBX}SpTBXTabs,
{$endif} {$endif}
ComCtrls, Contnrs, ExtCtrls
{$ifdef fpc},Process
{$endif};
//nur FPC Version
const
HIGHLIGHTER_PAS = 0;
HIGHLIGHTER_FPC = 1;
HIGHLIGHTER_CPP = 2;
HIGHLIGHTER_LFM = 3;
HIGHLIGHTER_JAV = 4;
HIGHLIGHTER_PRL = 5;
HIGHLIGHTER_HTM = 6;
HIGHLIGHTER_XML = 7;
HIGHLIGHTER_CSS = 8;
HIGHLIGHTER_PHP = 9;
HIGHLIGHTER_SQL = 10;
HIGHLIGHTER_PYT = 11;
HIGHLIGHTER_ASM = 12;
type
THighLighters =
class(TStringList)
private
function GetHighlighter(
Index: Integer): TSynCustomHighlighter;
public
function Add(AHighlighter: TSynCustomHighlighter): Integer;
property Highlighters[
Index: Integer]: TSynCustomHighlighter
read GetHighlighter;
end;
{ TEditorPage }
{$ifdef USE_SPTBX}
TEditorPage =
class(TSpTBXTabSheet)
{$else}
TEditorPage =
class(TTabSheet)
{$endif}
private
FDefaultExt: ShortString;
FEditor: TSynEdit;
FExtension: ShortString;
FFilename: ShortString;
//Name der Editordatei
FHighlighter: TSynCustomHighlighter;
FHighlighters: THighlighters;
FEmptyFileNames: TStringList;
FHighlighterIX: Integer;
{$ifdef fpc}
FProcess: TProcess;
//nur FPC Version
{$endif}
function HighlighterEquivalentToFileExt(AFileExt: ShortString): Integer;
function GetHighlighter: Integer;
procedure SetDefaultExt(Value: ShortString);
procedure SetFilename(AFilename: ShortString);
procedure SetHighlighter(AHighlighter: Integer);
public
//Compiler ist individuell für die Editordatei
procedure Compile;
procedure CompileSource(AFilename: ShortString);
constructor Create(AOwner: TComponent);
destructor Destroy;
override;
procedure LoadFromFile(AFilename: ShortString);
procedure Save;
procedure SaveAs(AFilename: ShortString);
property Editor: TSynEdit
read FEditor;
property FileExt: ShortString
read FExtension
write FExtension;
property Filename: ShortString
read FFilename
write SetFilename;
property Highlighter: Integer
read GetHighlighter
write SetHighlighter;
property DefaultExt: ShortString
write SetDefaultExt;
end;
TEditorsList =
class(TObjectList)
private
function GetEditors(
Index: Integer): TEditorPage;
public
function AddEditor(AEditor: TEditorPage): Integer;
property Editors[
Index: Integer]: TEditorPage
read GetEditors;
default;
end;
(*
Here the Editor-PageControl follows
*)
{ TEditorPages }
{$ifdef USE_SPTBX}
TEditorPages =
class(TSpTBXTabControl)
{$else}
TEditorPages =
class(TPageControl)
{$endif}
private
FProjectName: ShortString;
//Name des Projektes
{$ifdef fpc}
FProcess: TProcess;
//nur FPC Version zum Start des Compilers
{$endif}
function GetEditorPages: TEditorpages;
public
//Compiler ist derjenige der das Projekt überstzt
//Compiler des einzelnen Editors kann dagegen eine andere Programmiersprache
//übersetzen und den Bin-code in den Code des Projektes linken
procedure Compile;
procedure CompileProject(AProject: ShortString);
procedure Debug;
procedure DebugProject(AProjectName: ShortString);
procedure OpenEditor(AFilename: ShortString);
procedure CloseCurrentEditor;
constructor Create(AOwner: TComponent);
destructor Destroy;
override;
procedure Save;
procedure SaveAs(AFilename: ShortString);
procedure SaveAll;
property Editors: TEditorPages
read GetEditorPages;
{$ifdef fpc}
{$endif}
end;
{ TEditorPagesContainer }
TEditorPagesContainer =
class(TPanel)
private
FEditorPage: TEditorsList;
FEditPage: TObjectList;
FEditorPages: TEditorPages;
function GetPageCount: Integer;
public
procedure OpenEditor(AFilename: ShortString);
procedure CloseCurrentEditor;
constructor Create(AOwner: TComponent);
destructor Destroy;
override;
procedure Save;
procedure SaveAs(AFilename: ShortString);
procedure SaveAll;
property Editors: TEditorPages
read FEditorPages;
property PageCount: Integer
read GetPageCount;
end;
{ TEditorWindow }
TEditorWindow =
class(TForm)
private
FDefaultExt: ShortString;
FEditor: TSynEdit;
FExtension: ShortString;
FFilename: ShortString;
FHighlighter: TSynCustomHighlighter;
FHighlighters: THighlighters;
FEmptyFileNames: TStringList;
FHighlighterIX: Integer;
{$ifdef fpc}
FProcess: TProcess;
//nur FPC Version
{$endif}
FStatusBar: TStatusBar;
function HighlighterEquivalentToFileExt(AFileExt: ShortString): Integer;
function GetHighlighter: Integer;
procedure SetDefaultExt(value: ShortString);
procedure SetFilename(AFilename: ShortString);
procedure SetHighlighter(AHighlighter: Integer);
public
procedure Compile;
procedure CompileSource(AFilename: ShortString);
constructor Create(AOwner: TComponent);
destructor Destroy;
override;
procedure NewFile;
procedure LoadFromFile(AFilename: ShortString);
procedure Save;
procedure SaveAs(AFilename: ShortString);
property FileExt: ShortString
read FExtension
write FExtension;
property Filename: ShortString
read FFilename
write SetFilename;
property Highlighter: Integer
read GetHighlighter
write SetHighlighter;
property DefaultExt: ShortString
write SetDefaultExt;
end;
var
IDEEditor: TEditorPages;
implementation
{ THighlighters }
function THighlighters.GetHighlighter(
Index: Integer): TSynCustomHighlighter;
begin
Result := TSynCustomHighlighter(Objects[
Index]);
end;
function THighlighters.Add(AHighlighter: TSynCustomHighlighter): Integer;
begin
Result := AddObject(AHighlighter.
Name, AHighlighter);
end;
{ TEditorPage }
procedure TEditorPage.SetDefaultExt(value: ShortString);
begin
if FDefaultExt<> value
then FDefaultExt := value;
end;
function TEditorPage.HighlighterEquivalentToFileExt(AFileExt: ShortString
): Integer;
begin
if AFileExt = '
pas'
then
begin
FEditor.Highlighter := TSynPasSyn.Create(self);
FHighlighter := FEditor.Highlighter;
Result := 0;
end;
if AFileExt = '
pp'
then
begin
FEditor.Highlighter := TSynPasSyn.Create(self);
FHighlighter := FEditor.Highlighter;
Result := 1;
end;
if (AFileExt = '
cpp')
or (AFileExt = '
c')
then
begin
FEditor.Highlighter := TSynCppSyn.Create(self);
FHighlighter := FEditor.Highlighter;
Result := 2;
end;
if (AFileExt = '
lfm')
or (AFileExt = '
dfm')
then
begin
FEditor.Highlighter := TSynDfmSyn.Create(self);
FHighlighter := FEditor.Highlighter;
Result := 3;
end;
if AFileExt = '
java'
then
begin
FEditor.Highlighter := TSynJavaSyn.Create(self);
FHighlighter := FEditor.Highlighter;
Result := 4;
end;
if AFileExt = '
perl'
then
begin
FEditor.Highlighter := TSynPerlSyn.Create(self);
FHighlighter := FEditor.Highlighter;
Result := 5;
end;
if AFileExt = '
html'
then
begin
FEditor.Highlighter := TSynHtmlSyn.Create(self);
FHighlighter := FEditor.Highlighter;
Result := 6;
end;
if AFileExt = '
xml'
then
begin
FEditor.Highlighter := TSynXmlSyn.Create(self);
FHighlighter := FEditor.Highlighter;
Result := 7;
end;
if AFileExt = '
css'
then
begin
FEditor.Highlighter := TSynCssSyn.Create(self);
FHighlighter := FEditor.Highlighter;
Result := 8;
end;
if AFileExt = '
php'
then
begin
FEditor.Highlighter := TSynPhpSyn.Create(self);
FHighlighter := FEditor.Highlighter;
Result := 9;
end;
if AFileExt = '
sql'
then
begin
FEditor.Highlighter := TSynSqlSyn.Create(self);
FHighlighter := FEditor.Highlighter;
Result := 10;
end;
if AFileExt = '
python'
then
begin
FEditor.Highlighter := TSynPythonSyn.Create(self);
FHighlighter := FEditor.Highlighter;
Result := 11;
end;
{
if (AFileExt = 'asm') or (AFileExt = 'as') then
begin
FEditor.Highlighter := TSynAsmSyn.Create(self);
FHighlighter := FEditor.Highlighter;
Result := 12;
end;
}
end;
function TEditorPage.GetHighlighter: Integer;
begin
Result := FHighlighterIX;
end;
procedure TEditorPage.SetFilename(AFilename: ShortString);
begin
LoadFromFile(AFilename);
{
FFilename := AFilename;
if (FFilename <> '') and (POS('Noname', FFilename)=0) then
begin
FEditor.Lines.LoadFromFile(FFilename);
Caption := FFilename;
end else Caption := 'Untitled';
}
end;
procedure TEditorPage.SetHighlighter(AHighlighter: Integer);
begin
if FHighlighterIX >= FHighlighters.Count
then ShowMessage('
Diese Syntax wird vom Editor nicht unterstützt!');
if FHighlighterIX < FHighlighters.Count
then
if FHighlighterIX <> AHighlighter
then
begin
FHighlighterIX := AHighlighter;
FEditor.Highlighter := TSynCustomHighlighter(FHighlighters.Highlighters[FHighlighterIX]);
Highlighter := FHighlighterIX;
end;
end;
procedure TEditorPage.Compile;
begin
end;
procedure TEditorPage.CompileSource(AFilename: ShortString);
begin
end;
constructor TEditorPage.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FHighlighters := THighlighters.Create;
//nur UnixShellScript fehlt aus dem Repertoire der Lazarus Synedit-Highlighter
FHighlighters.Add(TSynPasSyn.Create(self));
FHighlighters.Add(TSynCppSyn.Create(self));
FHighlighters.Add(TSynDfmSyn.Create(self));
FHighlighters.Add(TSynJavaSyn.Create(self));
FHighlighters.Add(TSynPerlSyn.Create(self));
FHighlighters.Add(TSynHtmlSyn.Create(self));
FHighlighters.Add(TSynXmlSyn.Create(self));
FHighlighters.Add(TSynCssSyn.Create(self));
FHighlighters.Add(TSynPHPSyn.Create(self));
FHighlighters.Add(TSynSQLSyn.Create(self));
FHighlighters.Add(TSynPythonSyn.Create(self));
FEmptyFileNames := TStringList.Create;
FEmptyFileNames.Add('
Noname.pas');
FEmptyFileNames.Add('
Noname.pp');
FEmptyFileNames.Add('
Noname.cpp');
FEmptyFileNames.Add('
Noname.lfm');
FEmptyFileNames.Add('
Noname.java');
FEmptyFileNames.Add('
Noname.Perl');
FEmptyFileNames.Add('
Noname.Html');
FEmptyFileNames.Add('
Noname.xml');
FEmptyFileNames.Add('
Noname.css');
FEmptyFileNames.Add('
Noname.php');
FEmptyFileNames.Add('
Noname.sql');
FEmptyFileNames.Add('
Noname.python');
FEditor := TSynEdit.Create(self);
FEditor.Parent := self;
FEditor.Align := alClient;
FDefaultExt := '
pas';
end;
destructor TEditorPage.Destroy;
begin
if FEditor<>
nil then FreeAndNil(FEditor);
if FEmptyFileNames<>
nil then FreeAndNil(FEmptyFileNames);
if FHighlighters<>
nil then FreeAndNil(FHighlighters);
inherited Destroy;
end;
procedure TEditorPage.LoadFromFile(AFilename: ShortString);
var Ext: ShortString;
begin
if (AFilename<>'
')
then
begin
Ext := ExtractFileExt(AFilename);
System.Delete(Ext, 1, 1);
//SetHighlighter(HighlighterEquivalentToFileExt(Ext));
FHighlighterIX := HighlighterEquivalentToFileExt(Ext);
FEditor.Lines.LoadFromFile(AFilename);
FFilename := AFilename;
Caption := ExtractFilename(FFilename);
end
else
begin
Ext := FDefaultExt;
FHighlighterIX := HighlighterEquivalentToFileExt(Ext);
if (FHighlighterIX >= 0)
and (FHighlighterIX < FEmptyFileNames.Count)
then
begin
Caption := FEmptyFileNames[FHighlighterIX];
end
else Caption := '
Untitled';
end;
end;
procedure TEditorPage.Save;
begin
//Wenn FFilename = '' dann Dateidialog aufrufen und Filename erfragen
SaveAs(FFilename);
end;
procedure TEditorPage.SaveAs(AFilename: ShortString);
begin
FEditor.Lines.SaveToFile(AFilename);
FFileName := AFilename;
Caption := ExtractFileName(AFilename);
end;
{ TEditorsList }
function TEditorsList.GetEditors(
Index: Integer): TEditorPage;
begin
Result := TEditorPage(Items[
Index]);
end;
function TEditorsList.AddEditor(AEditor: TEditorPage): Integer;
begin
Result := Add(AEditor);
end;
{ TEditorPages }
function TEditorPages.GetEditorPages: TEditorpages;
begin
Result := self;
end;
procedure TEditorPages.Compile;
begin
end;
procedure TEditorPages.CompileProject(AProject: ShortString);
begin
end;
procedure TEditorPages.Debug;
begin
end;
procedure TEditorPages.DebugProject(AProjectName: ShortString);
begin
end;
procedure TEditorPages.OpenEditor(AFilename: ShortString);
var Page: TEditorPage;
begin
Page := TEditorPage.Create(self);
Page.LoadFromFile(AFileName);
{$ifdef USE_SPTBX}
Page.TabControl := self;
{$else}
Page.PageControl := self;
{$endif}
end;
procedure TEditorPages.CloseCurrentEditor;
var mResult: Integer;
begin
if TEditorPage(ActivePage).Editor.Modified
then
begin
mResult := MessageDlg('
', mtWarning, [mbYes, mbNo, mbCancel], 0);
if MResult = mrYes
then TEditorPage(ActivePage).Save;
end;
ActivePage.Free;
end;
constructor TEditorPages.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
{$ifdef fpc}
Process := TProcess.Create(self);
{$endif}
end;
destructor TEditorPages.Destroy;
begin
{$ifdef fpc}
if Process<>
nil then FreeAndNil(Process);
{$endif}
inherited Destroy;
end;
procedure TEditorPages.Save;
begin
TEditorPage(ActivePage).Save;
end;
procedure TEditorPages.SaveAs(AFilename: ShortString);
begin
TEditorPage(ActivePage).SaveAs(AFileName);
end;
procedure TEditorPages.SaveAll;
var Index: Integer;
begin
for Index := IdeEditor.PageCount - 1
downto 0
do
TEditorPage(Pages[
Index]).Save;
end;
{ TEditorPagesContainer }
function TEditorPagesContainer.GetPageCount: Integer;
begin
Result := FEditorPages.PageCount;
end;
procedure TEditorPagesContainer.OpenEditor(AFilename: ShortString);
var Editor: TEditorPage; Extension: ShortString;
Index: Integer;
begin
{
Editor := TEditorPage.Create(self);
Editor.PageControl := FEditorPages;
Editor.LoadFromFile(AFilename);
}
Index := FEditPage.Add
{Editor}(TEditorPage.Create(self));
TEditorPage(FEditPage[
Index]).Parent := self;
{$ifdef USE_SPTBX}
TEditorPage(FEditPage[
Index]).TabControl := FEditorPages;
{$else}
TEditorPage(FEditPage[
Index]).PageControl := FEditorPages;
{$endif}
TEditorPage(FEditPage[
Index]).LoadFromFile(AFilename);
//Extension := ExtractFileExt(AFileName);
//System.Delete(Extension, 1, 1);
//Editor.HighlighterEquivalentToFileExt(Extension);
//Editor.Highlighter := HIGHLIGHTER_PAS;
//Editor.Editor.Highlighter := TSynPasSyn.Create(self);
end;
procedure TEditorPagesContainer.CloseCurrentEditor;
var MResult: Word;
begin
if TEditorPage(FEditorPages.ActivePage).Editor.Modified
then
begin
mResult := MessageDlg('
', mtWarning, [mbYes, mbNo, mbCancel], 0);
if MResult = mrYes
then TEditorPage(FEditorPages.ActivePage).Save;
end;
if (FEditorPages<>
nil)
and (FEditorPages.ActivePage<>
nil)
then
FEditorPages.ActivePage.Free;
end;
constructor TEditorPagesContainer.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FEditorPages := TEditorPages.Create(AOwner);
FEditorPages.Align := alClient;
FEditorPages.Parent := self;
FEditorPage := TEditorsList.Create;
FEditPage := TObjectList.Create;
end;
destructor TEditorPagesContainer.Destroy;
begin
if FEditPage<>
nil then FreeAndNil(FEditPage);
if FEditorPage<>
nil then FreeAndNil(FEditorPage);
if FEditorPages<>
nil then FreeAndNil(FEditorPages);
inherited Destroy;
end;
procedure TEditorPagesContainer.Save;
begin
TEditorPage(FEditorPages.ActivePage).Save;
end;
procedure TEditorPagesContainer.SaveAs(AFilename: ShortString);
begin
TEditorPage(FEditorPages.ActivePage).SaveAs(AFilename);
//TEditorPage(FEditorPages.ActivePage).Caption := ExtractFileName(AFilename);
end;
procedure TEditorPagesContainer.SaveAll;
var Index: Integer;
begin
for Index := IdeEditor.PageCount - 1
downto 0
do
TEditorPage(FEditorPages.Pages[
Index]).Save;
end;
{ TEditorWindow }
procedure TEditorWindow.SetDefaultExt(value: ShortString);
begin
if FDefaultExt<> value
then FDefaultExt := value;
end;
function TEditorWindow.HighlighterEquivalentToFileExt(AFileExt: ShortString
): Integer;
begin
if AFileExt = '
pas'
then
begin
FEditor.Highlighter := TSynPasSyn.Create(self);
FHighlighter := FEditor.Highlighter;
Result := 0;
end;
if AFileExt = '
pp'
then
begin
FEditor.Highlighter := TSynPasSyn.Create(self);
FHighlighter := FEditor.Highlighter;
Result := 1;
end;
if AFileExt = '
cpp'
then
begin
FEditor.Highlighter := TSynCppSyn.Create(self);
FHighlighter := FEditor.Highlighter;
Result := 2;
end;
if (AFileExt = '
lfm')
or (AFileExt = '
dfm')
then
begin
FEditor.Highlighter := TSynDfmSyn.Create(self);
FHighlighter := FEditor.Highlighter;
Result := 3;
end;
if AFileExt = '
java'
then
begin
FEditor.Highlighter := TSynJavaSyn.Create(self);
FHighlighter := FEditor.Highlighter;
Result := 4;
end;
if AFileExt = '
perl'
then
begin
FEditor.Highlighter := TSynPerlSyn.Create(self);
FHighlighter := FEditor.Highlighter;
Result := 5;
end;
if AFileExt = '
html'
then
begin
FEditor.Highlighter := TSynHtmlSyn.Create(self);
FHighlighter := FEditor.Highlighter;
Result := 6;
end;
if AFileExt = '
xml'
then
begin
FEditor.Highlighter := TSynXmlSyn.Create(self);
FHighlighter := FEditor.Highlighter;
Result := 7;
end;
if AFileExt = '
css'
then
begin
FEditor.Highlighter := TSynCssSyn.Create(self);
FHighlighter := FEditor.Highlighter;
Result := 8;
end;
if AFileExt = '
php'
then
begin
FEditor.Highlighter := TSynPhpSyn.Create(self);
FHighlighter := FEditor.Highlighter;
Result := 9;
end;
if AFileExt = '
sql'
then
begin
FEditor.Highlighter := TSynSqlSyn.Create(self);
FHighlighter := FEditor.Highlighter;
Result := 10;
end;
if AFileExt = '
python'
then
begin
FEditor.Highlighter := TSynPythonSyn.Create(self);
FHighlighter := FEditor.Highlighter;
Result := 11;
end;
end;
function TEditorWindow.GetHighlighter: Integer;
begin
Result := FHighlighterIX;
end;
procedure TEditorWindow.SetFilename(AFilename: ShortString);
begin
LoadFromFile(AFilename);
end;
procedure TEditorWindow.SetHighlighter(AHighlighter: Integer);
begin
if FHighlighterIX >= FHighlighters.Count
then ShowMessage('
Diese Syntax wird vom Editor nicht unterstützt!');
if FHighlighterIX < FHighlighters.Count
then
if FHighlighterIX <> AHighlighter
then
begin
FHighlighterIX := AHighlighter;
FEditor.Highlighter := TSynCustomHighlighter(FHighlighters.Highlighters[FHighlighterIX]);
Highlighter := FHighlighterIX;
end;
end;
procedure TEditorWindow.Compile;
begin
end;
procedure TEditorWindow.CompileSource(AFilename: ShortString);
begin
end;
constructor TEditorWindow.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FormStyle := fsMDIChild;
FHighlighters := THighlighters.Create;
//nur UnixShellScript fehlt aus dem Repertoire der Lazarus Synedit-Highlighter
FHighlighters.Add(TSynPasSyn.Create(self));
FHighlighters.Add(TSynCppSyn.Create(self));
FHighlighters.Add(TSynDfmSyn.Create(self));
FHighlighters.Add(TSynJavaSyn.Create(self));
FHighlighters.Add(TSynPerlSyn.Create(self));
FHighlighters.Add(TSynHtmlSyn.Create(self));
FHighlighters.Add(TSynXmlSyn.Create(self));
FHighlighters.Add(TSynCssSyn.Create(self));
FHighlighters.Add(TSynPHPSyn.Create(self));
FHighlighters.Add(TSynSQLSyn.Create(self));
FHighlighters.Add(TSynPythonSyn.Create(self));
FEmptyFileNames := TStringList.Create;
FEmptyFileNames.Add('
Noname.pas');
FEmptyFileNames.Add('
Noname.cpp');
FEmptyFileNames.Add('
Noname.lfm');
FEmptyFileNames.Add('
Noname.java');
FEmptyFileNames.Add('
Noname.Perl');
FEmptyFileNames.Add('
Noname.Html');
FEmptyFileNames.Add('
Noname.xml');
FEmptyFileNames.Add('
Noname.css');
FEmptyFileNames.Add('
Noname.php');
FEmptyFileNames.Add('
Noname.sql');
FEmptyFileNames.Add('
Noname.python');
FStatusBar:= TStatusBar.Create(self);
FStatusBar.Parent := self;
FEditor := TSynEdit.Create(self);
FEditor.Parent := self;
FEditor.WordWrap := false;
FEditor.WantTabs := true;
FEditor.WantReturns := true;
FEditor.Align := alClient;
FDefaultExt := '
pas';
end;
destructor TEditorWindow.Destroy;
begin
//FEditor.Free;
//FStatusBar.Free;
FEmptyFileNames.Free;
FHighlighters.Free;
inherited Destroy;
end;
procedure TEditorWindow.NewFile;
begin
LoadFromFile('
');
end;
procedure TEditorWindow.LoadFromFile(AFilename: ShortString);
var Ext: ShortString;
begin
if (AFilename<>'
')
then
begin
Ext := ExtractFileExt(AFilename);
System.Delete(Ext, 1, 1);
//SetHighlighter(HighlighterEquivalentToFileExt(Ext));
FHighlighterIX := HighlighterEquivalentToFileExt(Ext);
FEditor.Lines.LoadFromFile(AFilename);
FFilename := AFilename;
Caption := ExtractFilename(FFilename);
end
else
begin
Ext := FDefaultExt;
FHighlighterIX := HighlighterEquivalentToFileExt(Ext);
if (FHighlighterIX >= 0)
and (FHighlighterIX < FEmptyFileNames.Count)
then Caption := FEmptyFileNames[FHighlighterIX]
else Caption := '
Untitled';
end;
end;
procedure TEditorWindow.Save;
begin
SaveAs(FFilename);
end;
procedure TEditorWindow.SaveAs(AFilename: ShortString);
begin
FEditor.Lines.SaveToFile(AFilename);
FFilename := AFilename;
Caption := ExtractFileName(AFilename);
end;
end.