Einzelnen Beitrag anzeigen

DualCoreCpu
(Gast)

n/a Beiträge
 
#21

AW: DesignIntf nicht gefunden

  Alt 26. Sep 2019, 09:34
Habe nun die DesignIde.pas Unit und auch die anderen (VCLEdit und StrEdit entfernt.

Nun kommt Fehlermeldung:

"DesignIde260 wird benötigt, kann aber nicht gefunden werden"!

So sieht mein Quellcode für mein Editorprojekt bisher aus:
Delphi-Quellcode:
program Edit;

uses
  Vcl.Forms,
  UFrame in 'UFrame.pas{Frame1: TFrame},
  SynAutoCorrect in '..\Synedit\Source\SynAutoCorrect.pas',
  SynAutoCorrectEditor in '..\Synedit\Source\SynAutoCorrectEditor.pas{frmAutoCorrectEditor},
  SynCompletionProposal in '..\Synedit\Source\SynCompletionProposal.pas',
  SynDBEdit in '..\Synedit\Source\SynDBEdit.pas',
  SynEdit in '..\Synedit\Source\SynEdit.pas',
  SynEditAutoComplete in '..\Synedit\Source\SynEditAutoComplete.pas',
  SynEditCodeFolding in '..\Synedit\Source\SynEditCodeFolding.pas',
  SynEditDocumentManager in '..\Synedit\Source\SynEditDocumentManager.pas',
  SynEditExport in '..\Synedit\Source\SynEditExport.pas',
  SynEditHighlighter in '..\Synedit\Source\SynEditHighlighter.pas',
  SynEditHighlighterOptions in '..\Synedit\Source\SynEditHighlighterOptions.pas',
  SynEditKbdHandler in '..\Synedit\Source\SynEditKbdHandler.pas',
  SynEditKeyCmdEditor in '..\Synedit\Source\SynEditKeyCmdEditor.pas{SynEditKeystrokeEditorForm},
  SynEditKeyCmds in '..\Synedit\Source\SynEditKeyCmds.pas',
  SynEditKeyCmdsEditor in '..\Synedit\Source\SynEditKeyCmdsEditor.pas{SynEditKeystrokesEditorForm},
  SynEditKeyConst in '..\Synedit\Source\SynEditKeyConst.pas',
  SynEditMiscClasses in '..\Synedit\Source\SynEditMiscClasses.pas',
  SynEditMiscProcs in '..\Synedit\Source\SynEditMiscProcs.pas',
  SynEditOptionsDialog in '..\Synedit\Source\SynEditOptionsDialog.pas{fmEditorOptionsDialog},
  SynEditPlugins in '..\Synedit\Source\SynEditPlugins.pas',
  SynEditPrint in '..\Synedit\Source\SynEditPrint.pas',
  SynEditPrinterInfo in '..\Synedit\Source\SynEditPrinterInfo.pas',
  SynEditPrintHeaderFooter in '..\Synedit\Source\SynEditPrintHeaderFooter.pas',
  SynEditPrintMargins in '..\Synedit\Source\SynEditPrintMargins.pas',
  SynEditPrintMarginsDialog in '..\Synedit\Source\SynEditPrintMarginsDialog.pas{SynEditPrintMarginsDlg},
  SynEditPrintPreview in '..\Synedit\Source\SynEditPrintPreview.pas',
  SynEditPrintTypes in '..\Synedit\Source\SynEditPrintTypes.pas',
  SynEditPropertyReg in '..\Synedit\Source\SynEditPropertyReg.pas',
  SynEditPythonBehaviour in '..\Synedit\Source\SynEditPythonBehaviour.pas',
  SynEditReg in '..\Synedit\Source\SynEditReg.pas',
  SynEditRegexSearch in '..\Synedit\Source\SynEditRegexSearch.pas',
  SynEditSearch in '..\Synedit\Source\SynEditSearch.pas',
  SynEditStrConst in '..\Synedit\Source\SynEditStrConst.pas',
  SynEditTextBuffer in '..\Synedit\Source\SynEditTextBuffer.pas',
  SynEditTypes in '..\Synedit\Source\SynEditTypes.pas',
  SynEditWildcardSearch in '..\Synedit\Source\SynEditWildcardSearch.pas',
  SynEditWordWrap in '..\Synedit\Source\SynEditWordWrap.pas',
  SynExportHTML in '..\Synedit\Source\SynExportHTML.pas',
  SynExportRTF in '..\Synedit\Source\SynExportRTF.pas',
  SynExportTeX in '..\Synedit\Source\SynExportTeX.pas',
  SynHighlighterADSP21xx in '..\Synedit\Source\SynHighlighterADSP21xx.pas',
  SynHighlighterAsm in '..\Synedit\Source\SynHighlighterAsm.pas',
  SynHighlighterAsmMASM in '..\Synedit\Source\SynHighlighterAsmMASM.pas',
  SynHighlighterAWK in '..\Synedit\Source\SynHighlighterAWK.pas',
  SynHighlighterBaan in '..\Synedit\Source\SynHighlighterBaan.pas',
  SynHighlighterBat in '..\Synedit\Source\SynHighlighterBat.pas',
  SynHighlighterCAC in '..\Synedit\Source\SynHighlighterCAC.pas',
  SynHighlighterCache in '..\Synedit\Source\SynHighlighterCache.pas',
  SynHighlighterCobol in '..\Synedit\Source\SynHighlighterCobol.pas',
  SynHighlighterCPM in '..\Synedit\Source\SynHighlighterCPM.pas',
  SynHighlighterCpp in '..\Synedit\Source\SynHighlighterCpp.pas',
  SynHighlighterCS in '..\Synedit\Source\SynHighlighterCS.pas',
  SynHighlighterCss in '..\Synedit\Source\SynHighlighterCss.pas',
  SynHighlighterDfm in '..\Synedit\Source\SynHighlighterDfm.pas',
  SynHighlighterDml in '..\Synedit\Source\SynHighlighterDml.pas',
  SynHighlighterDOT in '..\Synedit\Source\SynHighlighterDOT.pas',
  SynHighlighterDWS in '..\Synedit\Source\SynHighlighterDWS.pas',
  SynHighlighterEiffel in '..\Synedit\Source\SynHighlighterEiffel.pas',
  SynHighlighterFortran in '..\Synedit\Source\SynHighlighterFortran.pas',
  SynHighlighterFoxpro in '..\Synedit\Source\SynHighlighterFoxpro.pas',
  SynHighlighterGalaxy in '..\Synedit\Source\SynHighlighterGalaxy.pas',
  SynHighlighterGeneral in '..\Synedit\Source\SynHighlighterGeneral.pas',
  SynHighlighterGLSL in '..\Synedit\Source\SynHighlighterGLSL.pas',
  SynHighlighterGo in '..\Synedit\Source\SynHighlighterGo.pas',
  SynHighlighterGWS in '..\Synedit\Source\SynHighlighterGWS.pas',
  SynHighlighterHashEntries in '..\Synedit\Source\SynHighlighterHashEntries.pas',
  SynHighlighterHaskell in '..\Synedit\Source\SynHighlighterHaskell.pas',
  SynHighlighterHC11 in '..\Synedit\Source\SynHighlighterHC11.pas',
  SynHighlighterHP48 in '..\Synedit\Source\SynHighlighterHP48.pas',
  SynHighlighterHtml in '..\Synedit\Source\SynHighlighterHtml.pas',
  SynHighlighterIDL in '..\Synedit\Source\SynHighlighterIDL.pas',
  SynHighlighterIni in '..\Synedit\Source\SynHighlighterIni.pas',
  SynHighlighterInno in '..\Synedit\Source\SynHighlighterInno.pas',
  SynHighlighterJava in '..\Synedit\Source\SynHighlighterJava.pas',
  SynHighlighterJScript in '..\Synedit\Source\SynHighlighterJScript.pas',
  SynHighlighterJSON in '..\Synedit\Source\SynHighlighterJSON.pas',
  SynHighlighterKix in '..\Synedit\Source\SynHighlighterKix.pas',
  SynHighlighterLDraw in '..\Synedit\Source\SynHighlighterLDraw.pas',
  SynHighlighterLLVM in '..\Synedit\Source\SynHighlighterLLVM.pas',
  SynHighlighterM3 in '..\Synedit\Source\SynHighlighterM3.pas',
  SynHighlighterManager in '..\Synedit\Source\SynHighlighterManager.pas',
  SynHighlighterModelica in '..\Synedit\Source\SynHighlighterModelica.pas',
  SynHighlighterMsg in '..\Synedit\Source\SynHighlighterMsg.pas',
  SynHighlighterMulti in '..\Synedit\Source\SynHighlighterMulti.pas',
  SynHighlighterPas in '..\Synedit\Source\SynHighlighterPas.pas',
  SynHighlighterPerl in '..\Synedit\Source\SynHighlighterPerl.pas',
  SynHighlighterPHP in '..\Synedit\Source\SynHighlighterPHP.pas',
  SynHighlighterProgress in '..\Synedit\Source\SynHighlighterProgress.pas',
  SynHighlighterPython in '..\Synedit\Source\SynHighlighterPython.pas',
  SynHighlighterRC in '..\Synedit\Source\SynHighlighterRC.pas',
  SynHighlighterRexx in '..\Synedit\Source\SynHighlighterRexx.pas',
  SynHighlighterRuby in '..\Synedit\Source\SynHighlighterRuby.pas',
  SynHighlighterSDD in '..\Synedit\Source\SynHighlighterSDD.pas',
  SynHighlighterSml in '..\Synedit\Source\SynHighlighterSml.pas',
  SynHighlighterSQL in '..\Synedit\Source\SynHighlighterSQL.pas',
  SynHighlighterST in '..\Synedit\Source\SynHighlighterST.pas',
  SynHighlighterTclTk in '..\Synedit\Source\SynHighlighterTclTk.pas',
  SynHighlighterTeX in '..\Synedit\Source\SynHighlighterTeX.pas',
  SynHighlighterUNIXShellScript in '..\Synedit\Source\SynHighlighterUNIXShellScript.pas',
  SynHighlighterUnreal in '..\Synedit\Source\SynHighlighterUnreal.pas',
  SynHighlighterURI in '..\Synedit\Source\SynHighlighterURI.pas',
  SynHighlighterVB in '..\Synedit\Source\SynHighlighterVB.pas',
  SynHighlighterVBScript in '..\Synedit\Source\SynHighlighterVBScript.pas',
  SynHighlighterVrml97 in '..\Synedit\Source\SynHighlighterVrml97.pas',
  SynHighlighterWebIDL in '..\Synedit\Source\SynHighlighterWebIDL.pas',
  SynHighlighterXML in '..\Synedit\Source\SynHighlighterXML.pas',
  SynMacroRecorder in '..\Synedit\Source\SynMacroRecorder.pas',
  SynMemo in '..\Synedit\Source\SynMemo.pas',
  SynRegExpr in '..\Synedit\Source\SynRegExpr.pas',
  SynTextDrawer in '..\Synedit\Source\SynTextDrawer.pas',
  SynUnicode in '..\Synedit\Source\SynUnicode.pas',
  SynURIOpener in '..\Synedit\Source\SynURIOpener.pas',
  SynUsp10 in '..\Synedit\Source\SynUsp10.pas';

Application.CreateForm(TSynEditKeystrokeEditorForm, SynEditKeystrokeEditorForm);
Wo ist die klassische Begin End. Klammer geblieben?

Unit UEditor:
Delphi-Quellcode:
unit UEditor;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ToolWin, Vcl.ActnMan, Vcl.ActnCtrls,
  Vcl.ExtCtrls, Vcl.Menus, Vcl.ComCtrls, Vcl.CategoryButtons, editor2;

type
  TForm2 = class(TForm)
    MainMenu1: TMainMenu;
    Datei1: TMenuItem;
    Neu1: TMenuItem;
    InEditorholen1: TMenuItem;
    N1: TMenuItem;
    Speichern1: TMenuItem;
    Speichernunter1: TMenuItem;
    Allesspeichern1: TMenuItem;
    Schlieen1: TMenuItem;
    Allesschlieen1: TMenuItem;
    N2: TMenuItem;
    Beenden1: TMenuItem;
    Bearbeiten1: TMenuItem;
    T: TControlBar;
    CategoryPanelGroup1: TCategoryPanelGroup;
    ToolBar1: TToolBar;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    ToolButton3: TToolButton;
    ToolButton4: TToolButton;
    ToolButton5: TToolButton;
    ToolButton6: TToolButton;
    CategoryPanel1: TCategoryPanel;
    TreeView1: TTreeView;
    CategoryPanel2: TCategoryPanel;
    CategoryPanelGroup2: TCategoryPanelGroup;
    CategoryPanel3: TCategoryPanel;
    CategoryPanel4: TCategoryPanel;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    HeaderControl1: THeaderControl;
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

end.
Und mein Editor:
Delphi-Quellcode:
{
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 = 'pythonthen
  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 = 'pythonthen
  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.

Geändert von DualCoreCpu (26. Sep 2019 um 13:03 Uhr)
  Mit Zitat antworten Zitat