1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
procedure getDefaultMenuFile(S : TStrings);
begin
With S do
begin
Add('{');
Add(' "context-menu": {');
Add(' "atom-text-editor": [');
Add(' {');
Add(' "label": "Toggle %PACKAGENAME%",');
Add(' "command": "%PACKAGENAME%:toggle"');
Add(' }');
Add(' ]');
Add(' },');
Add(' "menu": [');
Add(' {');
Add(' "label": "Packages",');
Add(' "submenu": [');
Add(' {');
Add(' "label": "%PACKAGENAME%",');
Add(' "submenu": [');
Add(' {');
Add(' "label": "Toggle",');
Add(' "command": "%PACKAGENAME%:toggle"');
Add(' }');
Add(' ]');
Add(' }');
Add(' ]');
Add(' }');
Add(' ]');
Add('}');
end;
end;
procedure getDefaultCSSFile(S : TStrings);
begin
With S do
begin
Add('// The ui-variables file is provided by base themes provided by Atom.');
Add('//');
Add('// See https://github.com/atom/atom-dark-ui/blob/master/styles/ui-variables.less');
Add('// for a full listing of what''s available.');
Add('@import "ui-variables";');
Add('');
Add('.%PACKAGENAME% {');
Add('}');
end;
end;
Procedure GetDefaultGlueFile(S : TStrings);
begin
With S do
begin
Add('''use babel'';');
Add('');
Add('import { CompositeDisposable } from ''atom'';');
Add('import { pas, rtl } from ''./%PACKAGEPROJECTNAME%.js'';');
Add('');
Add('export default {');
Add(' activate(state) {');
Add(' rtl.run();');
Add(' this.subscriptions = new CompositeDisposable();');
Add(' this.atomEnv = {');
Add(' atomGlobal : atom,');
Add(' subscriptions : this.subscriptions,');
Add(' initialState : state');
Add(' }');
Add(' this.atomHandler = {');
Add(' onDeactivate : function (a) {},');
Add(' onSerialize : function (a,o) {}');
Add(' }');
Add(' pas.program.InitAtom(this.atomEnv,this.atomHandler);');
Add(' },');
Add('');
Add(' deactivate() {');
Add(' if (this.atomHandler.onDeactivate) {');
Add(' this.atomHandler.onDeactivate(this.atomEnv)');
Add(' }');
Add(' this.subscriptions.dispose();');
Add(' },');
Add('');
Add(' serialize() {');
Add(' var obj = {};');
Add(' if (this.atomHandler.onSerialize) {');
Add(' this.atomHandler.onSerialize(this.atomEnv,obj)');
Add(' }');
Add(' return obj;');
Add(' }');
Add('};');
end;
end;
Procedure GetDefaultProjectFile(S : TStrings);
begin
With S do
begin
Add('program %PACKAGEPROJECTNAME%;');
Add('');
Add('{$mode objfpc}');
Add('');
Add('uses');
Add(' JS, Classes, SysUtils, libAtom, atomapp, Web;');
Add('');
Add('');
Add('Type');
Add(' { %CLASSNAME% }');
Add('');
Add(' %CLASSNAME% = Class(TAtomApplication)');
Add(' Private');
Add(' Protected');
Add(' procedure DoActivate(aState : TJSObject); override;');
Add(' procedure DoDeactivate; override;');
Add(' procedure DoSerialize(aState : TJSObject); override;');
Add(' Public');
Add(' // %PACKAGEHANDLERINTFS%');
Add(' end;');
Add('');
Add('');
Add('// Do not change the name of this procedure, the Javascript glue code depends on it.');
Add('// If you do want to change it, change the glue code as well.');
Add('Procedure InitAtom(aAtom : TAtomEnvironment; aCallBacks : TAtomPackageCallBacks);');
Add('');
Add('begin');
Add(' If Application=Nil then');
Add(' Application:=%CLASSNAME%.Create(Nil);');
Add(' Application.SaveAtomEnvironment(aAtom,aCallBacks);');
Add('end;');
Add('');
Add('{ %CLASSNAME% }');
Add('');
Add('procedure %CLASSNAME%.DoActivate(aState: TJSObject);');
Add('');
Add('Var');
Add(' cmds : TJSObject;');
Add('begin');
Add(' inherited DoActivate(aState);');
Add(' // %PACKAGEHANDLERREGS%');
Add('end;');
Add('');
Add('procedure %CLASSNAME%.DoDeactivate();');
Add('begin');
Add('// Deactivation code here');
Add('end;');
Add('');
Add('procedure %CLASSNAME%.DoSerialize(aState: TJSObject);');
Add('begin');
Add(' inherited DoSerialize(aState);');
Add('end;');
Add('');
Add('// %PACKAGEHANDLERIMPLS%');
Add('// This code is needed to prevent the pas2js compiler from removing the InitAtom call.');
Add('var');
Add(' dummy : JSValue;');
Add('');
Add('begin');
Add(' Application:=%CLASSNAME%.Create(Nil);');
Add(' dummy:=@InitAtom;');
Add('end.');
end;
end;
Procedure getdefaultKeyMapFile(Src : TStrings);
begin
With Src do
begin
Add('{');
Add(' "atom-workspace": {');
Add(' "ctrl-alt-o": "%PACKAGENAME%:toggle"');
Add(' }');
Add('}');
end;
end;
|