-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.pas
More file actions
130 lines (100 loc) · 2.84 KB
/
Main.pas
File metadata and controls
130 lines (100 loc) · 2.84 KB
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
unit Main;
(*
Preparing a small demo repository
The /git sample is easier to test with a small repository whose state is known in advance.
# Open a Windows cmd.exe prompt and run:
mkdir demo-git && cd demo-git
git init
git config user.email "test@example.com"
git config user.name "Demo"
echo "# Demo" > README.md
git add README.md
git commit -m "initial"
echo "Hello" > a.txt
git add a.txt
git commit -m "add a.txt"
echo "World" >> a.txt
git add a.txt
git commit -m "extend a.txt"
echo "Unstaged change" >> a.txt
echo "Staged change" > b.txt
git add b.txt
# Create the .git directory in the folder upstream of bin64.
Then configure the host application with this repository root as the Git working directory:
- FGitService := TGitService.Create(FRunner, '..\');
*)
interface
uses
System.SysUtils, System.Types, System.Classes,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Layouts,
{--- Pythia-Webview }
FMX.WVPythia.Chat, WVPythia.Types,
{--- Adapter }
FMX.WVPythia.Services,
{--- Git plugin integration }
Demo.Git.Plugin.Intf, Demo.Git.Plugin.Service, Demo.Git.Plugin, Demo.Shell.Runner;
type
TForm1 = class(TForm)
Layout1: TLayout;
procedure FormCreate(Sender: TObject);
private
FGitService: TGitService;
FRunner: TShellRunner;
procedure DoOnInitialized;
procedure DisplayDocumentation;
public
Pythia: TFMXPythia;
end;
var
Form1: TForm1;
implementation
uses
WVPythia.TextFile.Helper;
{$R *.fmx}
{ TForm1 }
procedure TForm1.DisplayDocumentation;
begin
var Filename := '..\demos\FMX\plugin-git\README.md';;
if not FileExists(Filename) then
begin
Pythia.DisplayWarning(Format('Documentation file not found: `%s`', [Filename]));
Exit;
end;
var Documentation := TFileIoHelper.LoadFromFile(Filename);
Pythia.Display(Documentation, False);
Pythia.DisplaySpacer();
Pythia.ScrollToTop();
end;
procedure TForm1.DoOnInitialized;
begin
TFMXAlphaBlend.ShowWindow(Self);
DisplayDocumentation;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
{$IFDEF DEBUG}
ReportMemoryLeaksOnShutdown := True;
{$ENDIF}
Width := 1350;
Height := 870;
Caption := Format(
'Plugin Demo - The git command (Pythia-webview2 version: %s)',
[TFMXPythia.Version]
);
TFMXAlphaBlend.HideWindow(Self);
Pythia := TFMXPythia.Create(Layout1);
Pythia.AttachHost(Self);
Pythia.ServiceAdapter := TFMXChatManagedItemDialogService.Create;
{--- Host-side plugin wiring }
Pythia.OnRegisterCommandPlugins :=
procedure
begin
FRunner := TShellRunner.Create;
FGitService := TGitService.Create(FRunner, '..\');
FGitService.Browser := Pythia;
Pythia.CommandLine.RegisterPlugin(TGitPlugin.Create(FGitService));
end;
Pythia.OnInitialized := DoOnInitialized;
Pythia.Update;
end;
end.