Changeset 15 for trunk/StudioPackage


Ignore:
Timestamp:
Aug 6, 2012, 2:35:22 PM (12 years ago)
Author:
chronos
Message:
  • Added: Registration of new file templates for modules.
  • Added: Program stores last opened file list in registry.
Location:
trunk/StudioPackage
Files:
4 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/StudioPackage/Forms/UFormMain.lfm

    r14 r15  
    11object FormMain: TFormMain
    2   Left = 150
     2  Left = 240
    33  Height = 520
    4   Top = 112
     4  Top = 108
    55  Width = 747
    66  Caption = 'LibreDevelop Studio'
     
    2727    Width = 747
    2828    Caption = 'ToolBar1'
     29    Images = DataModule1.ImageListMain
    2930    TabOrder = 1
    3031    object ToolButton1: TToolButton
    3132      Left = 1
    32       Hint = 'New project'
    3333      Top = 2
    34       Caption = 'New...'
    35       ImageIndex = 4
     34      Action = AFileNew
    3635    end
    3736    object ToolButton2: TToolButton
    3837      Left = 24
    39       Hint = 'Open project'
    4038      Top = 2
    41       Caption = 'Open...'
    42       ImageIndex = 8
     39      Action = AFileOpen
     40      DropdownMenu = PopupMenuRecentFiles
     41      Style = tbsDropDown
    4342    end
    4443    object ToolButton3: TToolButton
    45       Left = 47
    46       Hint = 'Save project'
     44      Left = 59
    4745      Top = 2
    48       Caption = 'Save'
    49       ImageIndex = 13
     46      Action = AFileSaveAs
    5047    end
    5148    object ToolButton4: TToolButton
    52       Left = 70
    53       Hint = 'Close project'
     49      Left = 82
    5450      Top = 2
    55       Caption = 'Close'
    56       ImageIndex = 3
     51      Action = AFileClose
    5752    end
    5853  end
     
    117112        Action = AFileOpen
    118113      end
    119       object MenuItem29: TMenuItem
    120         Action = AFileOpenRecent
     114      object MenuItemFileOpenRecent: TMenuItem
     115        Caption = 'Open recent'
     116        ImageIndex = 8
     117        OnClick = MenuItemFileOpenRecentClick
    121118      end
    122119      object MenuItem30: TMenuItem
     
    313310      Caption = 'Open recent'
    314311      ImageIndex = 8
     312      OnExecute = AFileOpenRecentExecute
    315313    end
    316314    object AFileSave: TAction
     
    318316      Caption = 'Save'
    319317      ImageIndex = 13
     318      OnExecute = AFileSaveExecute
    320319      ShortCut = 16467
    321320    end
     
    324323      Caption = 'Save as...'
    325324      ImageIndex = 13
     325      OnExecute = AFileSaveAsExecute
    326326      ShortCut = 24659
    327327    end
     
    387387    top = 272
    388388  end
     389  object LastOpenedList1: TLastOpenedList
     390    MaxCount = 10
     391    OnChange = LastOpenedList1Change
     392    left = 80
     393    top = 160
     394  end
     395  object PopupMenuRecentFiles: TPopupMenu
     396    Images = DataModule1.ImageListMain
     397    left = 259
     398    top = 69
     399  end
    389400end
  • trunk/StudioPackage/Forms/UFormMain.lrt

    r14 r15  
    11TFORMMAIN.CAPTION=LibreDevelop Studio
    22TFORMMAIN.TOOLBAR1.CAPTION=ToolBar1
    3 TFORMMAIN.TOOLBUTTON1.HINT=New project
    4 TFORMMAIN.TOOLBUTTON1.CAPTION=New...
    5 TFORMMAIN.TOOLBUTTON2.HINT=Open project
    6 TFORMMAIN.TOOLBUTTON2.CAPTION=Open...
    7 TFORMMAIN.TOOLBUTTON3.HINT=Save project
    8 TFORMMAIN.TOOLBUTTON3.CAPTION=Save
    9 TFORMMAIN.TOOLBUTTON4.HINT=Close project
    10 TFORMMAIN.TOOLBUTTON4.CAPTION=Close
    113TFORMMAIN.MENUITEM26.CAPTION=File
     4TFORMMAIN.MENUITEMFILEOPENRECENT.CAPTION=Open recent
    125TFORMMAIN.MENUITEM33.CAPTION=-
    136TFORMMAIN.MENUITEM2.CAPTION=Edit
  • trunk/StudioPackage/Forms/UFormMain.pas

    r14 r15  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,
    9   ActnList, ComCtrls, ExtCtrls, UDataModule;
     9  ActnList, ComCtrls, ExtCtrls, ULastOpenedList, UCoolTranslator, UDataModule,
     10  URegistry;
    1011
    1112type
     
    4445    AClipboardCut: TAction;
    4546    ActionListMain: TActionList;
     47    LastOpenedList1: TLastOpenedList;
    4648    MainMenu: TMainMenu;
    4749    MenuItem15: TMenuItem;
     
    6062    MenuItem27: TMenuItem;
    6163    MenuItem28: TMenuItem;
    62     MenuItem29: TMenuItem;
     64    MenuItemFileOpenRecent: TMenuItem;
    6365    MenuItem30: TMenuItem;
    6466    MenuItem31: TMenuItem;
     
    8991    PageControlBottom: TPageControl;
    9092    PageControlCenter: TPageControl;
     93    PopupMenuRecentFiles: TPopupMenu;
    9194    SaveDialogFile: TSaveDialog;
    9295    Splitter1: TSplitter;
     
    102105    procedure AFileNewExecute(Sender: TObject);
    103106    procedure AFileOpenExecute(Sender: TObject);
     107    procedure AFileOpenRecentExecute(Sender: TObject);
     108    procedure AFileSaveAsExecute(Sender: TObject);
     109    procedure AFileSaveExecute(Sender: TObject);
    104110    procedure AViewModulesExecute(Sender: TObject);
    105111    procedure AViewSettingsExecute(Sender: TObject);
     
    108114    procedure FormDestroy(Sender: TObject);
    109115    procedure FormShow(Sender: TObject);
     116    procedure LastOpenedList1Change(Sender: TObject);
     117    procedure MenuItemFileOpenRecentClick(Sender: TObject);
    110118  private
    111119    procedure DockInit;
    112120  public
     121    procedure UpdateInterface;
    113122    procedure OpenedFileChange(Sender: TObject);
     123    procedure LoadFromRegistry(Context: TRegistryContext);
     124    procedure SaveToRegistry(Context: TRegistryContext);
    114125  end;
    115126
     
    117128  FormMain: TFormMain;
    118129
     130
    119131implementation
    120132
     
    122134
    123135uses
    124   UFormSourceCode, UFormSettings, UFormModuleList;
     136  UFormSourceCode, UFormSettings, UFormModuleList, UFormNewFile, USource;
    125137
    126138{ TFormMain }
     
    133145procedure TFormMain.AFileCloseExecute(Sender: TObject);
    134146begin
    135   DataModule1.OpenedFiles.CloseFile(DataModule1.OpenedFiles.Selected.FileName);
     147  DataModule1.OpenedFiles.CloseFile(DataModule1.OpenedFiles.Selected);
    136148end;
    137149
    138150procedure TFormMain.AFileNewExecute(Sender: TObject);
    139 begin
    140   DataModule1.OpenedFiles.NewFile;
     151var
     152  NewFile: TSource;
     153begin
     154  if FormNewFile.ShowModal = mrOk then
     155    if Assigned(FormNewFile.ListView1.Selected) then begin
     156      NewFile := TFileTemplate(FormNewFile.ListView1.Selected.Data).Execute;
     157      DataModule1.OpenedFiles.OpenFile(NewFile);
     158    end;
    141159end;
    142160
     
    145163  OpenDialogFile.Filter := DataModule1.FileTypes.GetDialogFilter;
    146164  if OpenDialogFile.Execute then begin
    147     DataModule1.OpenedFiles.OpenFile(OpenDialogFile.FileName);
    148   end;
     165    LastOpenedList1.AddItem(OpenDialogFile.FileName);
     166    DataModule1.OpenedFiles.OpenFileName(OpenDialogFile.FileName);
     167  end;
     168end;
     169
     170procedure TFormMain.AFileOpenRecentExecute(Sender: TObject);
     171begin
     172  if Sender is TMenuItem then
     173    DataModule1.OpenedFiles.OpenFileName(TMenuItem(Sender).Caption);
     174end;
     175
     176procedure TFormMain.AFileSaveAsExecute(Sender: TObject);
     177begin
     178  SaveDialogFile.FileName := DataModule1.OpenedFiles.Selected.Name;
     179  if SaveDialogFile.Execute then begin
     180    LastOpenedList1.AddItem(SaveDialogFile.FileName);
     181    DataModule1.OpenedFiles.Selected.Name := SaveDialogFile.FileName;
     182  end;
     183end;
     184
     185procedure TFormMain.AFileSaveExecute(Sender: TObject);
     186begin
     187
    149188end;
    150189
     
    177216begin
    178217  DockInit;
     218  UpdateInterface;
     219end;
     220
     221procedure TFormMain.LastOpenedList1Change(Sender: TObject);
     222begin
     223  LastOpenedList1.LoadToMenuItem(PopupMenuRecentFiles.Items, AFileOpenRecentExecute);
     224  LastOpenedList1.LoadToMenuItem(MenuItemFileOpenRecent, AFileOpenRecentExecute);
     225end;
     226
     227procedure TFormMain.MenuItemFileOpenRecentClick(Sender: TObject);
     228begin
     229
    179230end;
    180231
     
    186237}end;
    187238
     239procedure TFormMain.UpdateInterface;
     240begin
     241  AFileClose.Enabled := Assigned(DataModule1.OpenedFiles.Selected);
     242  AFileSave.Enabled := Assigned(DataModule1.OpenedFiles.Selected);
     243  AFileSaveAs.Enabled := Assigned(DataModule1.OpenedFiles.Selected);
     244end;
     245
    188246procedure TFormMain.OpenedFileChange(Sender: TObject);
    189247var
     
    193251  with DataModule1.OpenedFiles do begin
    194252    for I := 0 to Count - 1 do
    195     with TOpenedFile(Items[I]) do begin
     253    with TSource(Items[I]) do begin
    196254      if not Assigned(Form.Parent) then begin
    197255        NewTabSheet := PageControlCenter.AddTabSheet;
    198         NewTabSheet.Caption := ExtractFileName(FileName);
     256        NewTabSheet.Caption := ExtractFileName(Name);
    199257        //NewTabSheet.PopupMenu := ;
    200258        Form.ManualDock(NewTabSheet, nil, alClient);
     
    206264end;
    207265
     266procedure TFormMain.LoadFromRegistry(Context: TRegistryContext);
     267begin
     268  LastOpenedList1.LoadFromRegistry(Context.RootKey, Context.Key + '\RecentFiles');
     269end;
     270
     271procedure TFormMain.SaveToRegistry(Context: TRegistryContext);
     272begin
     273  LastOpenedList1.SaveToRegistry(Context.RootKey, Context.Key + '\RecentFiles');
     274end;
     275
    208276end.
    209277
  • trunk/StudioPackage/Languages/UDataModule.po

    r13 r15  
    66msgstr ""
    77
     8#: udatamodule.stextfile
     9msgid "Text file"
     10msgstr ""
     11
  • trunk/StudioPackage/LibreDevelopStudio.lpk

    r11 r15  
    2323      </Other>
    2424    </CompilerOptions>
    25     <Files Count="5">
     25    <Files Count="6">
    2626      <Item1>
    2727        <Filename Value="Forms\UFormMain.pas"/>
     
    4444        <UnitName Value="UFormModuleList"/>
    4545      </Item5>
     46      <Item6>
     47        <Filename Value="Forms\UFormNewFile.pas"/>
     48        <UnitName Value="UFormNewFile"/>
     49      </Item6>
    4650    </Files>
    4751    <i18n>
     
    5155    </i18n>
    5256    <Type Value="RunAndDesignTime"/>
    53     <RequiredPkgs Count="5">
     57    <RequiredPkgs Count="7">
    5458      <Item1>
    55         <PackageName Value="LDStudioCommon"/>
     59        <PackageName Value="CoolTranslator"/>
    5660      </Item1>
    5761      <Item2>
    58         <PackageName Value="synedit"/>
     62        <PackageName Value="Common"/>
    5963      </Item2>
    6064      <Item3>
    61         <PackageName Value="TemplateGenerics"/>
     65        <PackageName Value="LDStudioCommon"/>
    6266      </Item3>
    6367      <Item4>
    64         <PackageName Value="LCL"/>
     68        <PackageName Value="synedit"/>
    6569      </Item4>
    6670      <Item5>
     71        <PackageName Value="TemplateGenerics"/>
     72      </Item5>
     73      <Item6>
     74        <PackageName Value="LCL"/>
     75      </Item6>
     76      <Item7>
    6777        <PackageName Value="FCL"/>
    68       </Item5>
     78      </Item7>
    6979    </RequiredPkgs>
    7080    <UsageOptions>
  • trunk/StudioPackage/LibreDevelopStudio.pas

    r11 r15  
    99uses
    1010  UFormMain, UDataModule, UFormSourceCode, UFormSettings, UFormModuleList,
    11   LazarusPackageIntf;
     11  UFormNewFile, LazarusPackageIntf;
    1212
    1313implementation
  • trunk/StudioPackage/UDataModule.lfm

    r14 r15  
    733733    OnUnregisterMainMenuItem = APIUnregisterMainMenuItem
    734734    OnDockForm = APIDockForm
     735    OnGetRegistryContext = APIGetRegistryContext
     736    OnRegisterFileTemplate = APIRegisterFileTemplate
     737    OnUnregisterFileTemplate = APIUnregisterFileTemplate
    735738    left = 92
    736739    top = 168
    737740  end
     741  object CoolTranslator1: TCoolTranslator
     742    POFilesFolder = 'Languages'
     743    left = 92
     744    top = 8
     745  end
     746  object ApplicationInfo1: TApplicationInfo
     747    Identification = 1
     748    VersionMajor = 1
     749    VersionMinor = 0
     750    VersionBugFix = 0
     751    VersionSuffix = 'alfa'
     752    HomePage = 'http://svn.zdechov.net/trac/LibreDevelop'
     753    AuthorsName = 'Chronos'
     754    EmailContact = 'robie@centrum.cz'
     755    AppName = 'LibreDevelop Studio'
     756    ReleaseDate = 41096
     757    RegistryKey = '\Software\LibreDevelop\Studio'
     758    RegistryRoot = rrKeyCurrentUser
     759    left = 92
     760    top = 224
     761  end
    738762end
  • trunk/StudioPackage/UDataModule.pas

    r14 r15  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, ActnList, Controls, SpecializedList,
    9   USource, UModularSystem, ULDStudioAPI, Menus, ComCtrls;
     9  USource, UModularSystem, UCoolTranslator, ULDStudioAPI, Menus, ComCtrls,
     10  Registry, URegistry, UApplicationInfo;
    1011
    1112type
    1213
    13   { TOpenedFile }
    14 
    15   TOpenedFile = class
    16   private
    17     FFileName: string;
    18     procedure SetFileName(AValue: string);
    19   public
    20     Modified: Boolean;
    21     Form: TForm;
    22     property FileName: string read FFileName write SetFileName;
     14  { TTextTemplate }
     15
     16  TTextTemplate = class(TFileTemplate)
     17    constructor Create; override;
     18  end;
     19
     20  { TTextFileType }
     21
     22  TTextFileType = class(TSourceType)
     23    constructor Create; override;
    2324  end;
    2425
     
    2930    FOnChange: TNotifyEvent;
    3031  public
    31     Selected: TOpenedFile;
    32     function FindByFileName(Value: string): TOpenedFile;
    33     procedure CloseFile(FileName: string);
    34     procedure OpenFile(FileName: string);
     32    Selected: TSource;
     33    function FindByFileName(Value: string): TSource;
     34    procedure CloseFile(Source: TSource);
     35    procedure OpenFileName(FileName: string);
     36    procedure OpenFile(Source: TSource);
    3537    procedure NewFile;
    3638    property OnChange: TNotifyEvent read FOnChange write FOnChange;
     
    4244  published
    4345    ActionListRegistred: TActionList;
     46    ApplicationInfo1: TApplicationInfo;
     47    CoolTranslator1: TCoolTranslator;
    4448    ImageListMain: TImageList;
    4549    API: TLDStudioAPI;
    4650    procedure APIDockForm(Form: TForm; Target: TDockTarget);
     51    function APIGetRegistryContext: TRegistryContext;
     52    procedure APIRegisterFileTemplate(Template: TFileTemplate);
    4753    procedure APIRegisterFileType(FileType: TSourceType);
    4854    procedure APIRegisterForm(Form: TForm);
     
    5056      ParentItem: TMenuItem; Index: Integer);
    5157    procedure APIUnregisterAction(Action: TAction);
     58    procedure APIUnregisterFileTemplate(Template: TFileTemplate);
    5259    procedure APIUnregisterFileType(FileType: TSourceType);
    5360    procedure APIUnregisterForm(Form: TForm);
    5461    procedure APIUnregisterMainMenuItem(MenuItem: TMenuItem);
     62    procedure APIOpenFile(FileName: string);
     63    procedure APIRegisterAction(Action: TAction);
    5564    procedure DataModuleCreate(Sender: TObject);
    5665    procedure DataModuleDestroy(Sender: TObject);
    57     procedure APIOpenFile(FileName: string);
    58     procedure APIRegisterAction(Action: TAction);
    5966  private
     67    TextFileType: TSourceType;
     68    TextFileTemplate: TTextTemplate;
     69    procedure AutoOpen;
    6070    procedure DockToPageControl(PageControl: TPageControl; Form: TForm);
    6171  public
    6272    ModuleManager: TModuleManager;
    6373    FileTypes: TFileTypes;
     74    FileTemplates: TFileTemplates;
    6475    OpenedFiles: TOpenedFiles;
    65   end;
     76    procedure LoadFromRegistry(Context: TRegistryContext);
     77    procedure SaveToRegistry(Context: TRegistryContext);
     78  end;
     79
    6680
    6781var
     
    7488
    7589uses
    76   UFormSourceCode, UFormMain, UFormSettings, UFormModuleList;
     90  UFormSourceCode, UFormMain, UFormSettings, UFormModuleList, UFormNewFile;
    7791
    7892resourcestring
    7993  SNewFile = 'New file';
    80 
    81 procedure TOpenedFile.SetFileName(AValue: string);
    82 begin
    83   if FFileName = AValue then Exit;
    84   FFileName := AValue;
    85   if Assigned(Form) then
    86     Form.Caption := ExtractFileName(FFileName);
    87 end;
     94  STextFile = 'Text file';
     95
     96{ TTextFileType }
     97
     98constructor TTextFileType.Create;
     99begin
     100  inherited Create;
     101  Extension := '.txt';
     102  Title := 'Text file';;
     103end;
     104
     105{ TTextTemplate }
     106
     107constructor TTextTemplate.Create;
     108begin
     109  inherited Create;
     110  Name := STextFile;
     111end;
     112
    88113
    89114{ TOpenedFiles }
    90115
    91 function TOpenedFiles.FindByFileName(Value: string): TOpenedFile;
     116function TOpenedFiles.FindByFileName(Value: string): TSource;
    92117var
    93118  I: Integer;
    94119begin
    95120  I := 0;
    96   while (I < Count) and (TOpenedFile(Items[I]).FileName <> Value) do Inc(I);
    97   if I < Count then Result := TOpenedFile(Items[I])
     121  while (I < Count) and (TSource(Items[I]).Name <> Value) do Inc(I);
     122  if I < Count then Result := TSource(Items[I])
    98123    else Result := nil;
    99124end;
    100125
    101 procedure TOpenedFiles.CloseFile(FileName: string);
    102 var
    103   OpenedFile: TOpenedFile;
    104 begin
    105   OpenedFile := FindByFileName(FileName);
    106   FreeAndNil(OpenedFile.Form);
    107   Remove(OpenedFile);
     126procedure TOpenedFiles.CloseFile(Source: TSource);
     127begin
     128  FreeAndNil(Source.Form);
     129  Remove(Source);
    108130  if Assigned(FOnChange) then FOnChange(Self);
    109131end;
    110132
    111 procedure TOpenedFiles.OpenFile(FileName: string);
    112 var
    113   NewFile: TOpenedFile;
    114 begin
    115   NewFile := TOpenedFile(AddNew(TOpenedFile.Create));
    116   NewFile.FileName := FileName;
     133procedure TOpenedFiles.OpenFileName(FileName: string);
     134var
     135  NewFile: TSourceText;
     136begin
     137  NewFile := TSourceText.Create;
     138  NewFile.Name := FileName;
     139  OpenFile(NewFile);
     140end;
     141
     142procedure TOpenedFiles.OpenFile(Source: TSource);
     143begin
     144  AddNew(Source);
     145  Source.Form := TFormSourceCode.Create(nil);
     146  Source.Form.Caption := ExtractFileName(Source.Name);
     147  Source.Form.Visible := True;
     148  Selected := Source;
     149  if Assigned(FOnChange) then FOnChange(Self);
     150end;
     151
     152procedure TOpenedFiles.NewFile;
     153var
     154  NewFile: TSource;
     155begin
     156  NewFile := TSourceText(AddNew(TSource.Create));
     157  NewFile.Name := SNewFile;
    117158  NewFile.Form := TFormSourceCode.Create(nil);
    118   NewFile.Form.Caption := ExtractFileName(NewFile.FileName);
     159  NewFile.Form.Caption := ExtractFileName(NewFile.Name);
    119160  NewFile.Form.Visible := True;
    120161  Selected := NewFile;
     
    122163end;
    123164
    124 procedure TOpenedFiles.NewFile;
    125 var
    126   NewFile: TOpenedFile;
    127 begin
    128   NewFile := TOpenedFile(AddNew(TOpenedFile.Create));
    129   NewFile.FileName := SNewFile;
    130   NewFile.Form := TFormSourceCode.Create(nil);
    131   NewFile.Form.Caption := ExtractFileName(NewFile.FileName);
    132   NewFile.Form.Visible := True;
    133   Selected := NewFile;
    134   if Assigned(FOnChange) then FOnChange(Self);
    135 end;
    136 
    137165{ TDataModule1 }
    138166
    139167procedure TDataModule1.DataModuleCreate(Sender: TObject);
    140168begin
     169  FileTemplates := TFileTemplates.Create;
     170  FileTemplates.OwnsObjects := False;
    141171  FileTypes := TFileTypes.Create;
    142172  FileTypes.OwnsObjects := False;
     
    144174  ModuleManager := TModuleManager.Create(nil);
    145175  ModuleManager.API := API;
     176
     177  TextFileType := TTextFileType.Create;
     178  API.RegisterFileType(TextFileType);
     179  TextFileTemplate := TTextTemplate.Create;
     180  API.RegisterFileTemplate(TextFileTemplate);
    146181
    147182  FormMain := TFormMain.Create(nil);
     
    151186  FormSettings := TFormSettings.Create(nil);
    152187  FormModuleList := TFormModuleList.Create(nil);
    153 
     188  FormNewFile := TFormNewFile.Create(nil);
     189
     190  LoadFromRegistry(RegContext(HKEY(ApplicationInfo1.RegistryRoot), ApplicationInfo1.RegistryKey));
     191
     192  DataModule1 := Self;
    154193  FormMain.Show;
     194  AutoOpen;
    155195end;
    156196
     
    191231end;
    192232
     233procedure TDataModule1.LoadFromRegistry(Context: TRegistryContext);
     234begin
     235  with TRegistryEx.Create do
     236  try
     237    RootKey := Context.RootKey;
     238    OpenKey(Context.Key, True);
     239
     240  finally
     241    Free;
     242  end;
     243  FormMain.LoadFromRegistry(Context);
     244end;
     245
     246procedure TDataModule1.SaveToRegistry(Context: TRegistryContext);
     247begin
     248  with TRegistryEx.Create do
     249  try
     250    RootKey := Context.RootKey;
     251    OpenKey(Context.Key, True);
     252
     253  finally
     254    Free;
     255  end;
     256  FormMain.SaveToRegistry(Context);
     257end;
     258
    193259procedure TDataModule1.APIDockForm(Form: TForm; Target: TDockTarget);
    194260begin
     
    203269end;
    204270
     271function TDataModule1.APIGetRegistryContext: TRegistryContext;
     272begin
     273  Result := RegContext(HKEY(ApplicationInfo1.RegistryRoot), ApplicationInfo1.RegistryKey);
     274end;
     275
     276procedure TDataModule1.APIRegisterFileTemplate(Template: TFileTemplate);
     277begin
     278  FileTemplates.Add(Template);
     279end;
     280
    205281procedure TDataModule1.APIUnregisterAction(Action: TAction);
    206282begin
     
    208284end;
    209285
     286procedure TDataModule1.APIUnregisterFileTemplate(Template: TFileTemplate);
     287begin
     288  FileTemplates.Remove(Template);
     289end;
     290
    210291procedure TDataModule1.APIUnregisterFileType(FileType: TSourceType);
    211292begin
     
    220301procedure TDataModule1.DataModuleDestroy(Sender: TObject);
    221302begin
     303  API.UnregisterFileType(TextFileType);
     304  FreeAndNil(TextFileType);
     305  API.UnregisterFileTemplate(TextFileTemplate);
     306  FreeAndNil(TextFileTemplate);
     307
     308  SaveToRegistry(RegContext(HKEY(ApplicationInfo1.RegistryRoot), ApplicationInfo1.RegistryKey));
    222309  FreeAndNil(ModuleManager);
     310  FreeAndNil(FormNewFile);
    223311  FreeAndNil(FormMain);
    224312  FreeAndNil(FormSourceCode);
     
    227315  FreeAndNil(OpenedFiles);
    228316  FreeAndNil(FileTypes);
     317  FreeAndNil(FileTemplates);
     318end;
     319
     320procedure TDataModule1.AutoOpen;
     321var
     322  FileName: string;
     323begin
     324  if (ParamCount > 0) then begin
     325    FileName := UTF8Encode(ParamStr(1));
     326    if FileExistsUTF8(FileName) then begin
     327      OpenedFiles.OpenFileName(FileName);
     328    end;
     329  end;
    229330end;
    230331
    231332procedure TDataModule1.APIOpenFile(FileName: string);
    232333begin
    233   OpenedFiles.OpenFile(FileName);
     334  OpenedFiles.OpenFileName(FileName);
    234335end;
    235336
Note: See TracChangeset for help on using the changeset viewer.