Skip to content

Commit fb23394

Browse files
committed
bk/2024-06-14-0942
1 parent 4357444 commit fb23394

3 files changed

Lines changed: 72 additions & 35 deletions

File tree

Src/Chat/DelphiCopilot.Chat.View.dfm

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
object DelphiCopilotChatView: TDelphiCopilotChatView
22
Left = 0
33
Top = 0
4-
Caption = 'Chat - Delphi Copilot'
4+
BorderIcons = [biSystemMenu, biMaximize]
5+
Caption = 'Copilot Chat'
56
ClientHeight = 661
6-
ClientWidth = 974
7+
ClientWidth = 975
78
Color = clBtnFace
89
Font.Charset = DEFAULT_CHARSET
910
Font.Color = clWindowText
@@ -22,7 +23,7 @@ object DelphiCopilotChatView: TDelphiCopilotChatView
2223
object pnBack: TPanel
2324
Left = 0
2425
Top = 0
25-
Width = 974
26+
Width = 956
2627
Height = 661
2728
Margins.Left = 0
2829
Margins.Top = 0
@@ -31,18 +32,18 @@ object DelphiCopilotChatView: TDelphiCopilotChatView
3132
Align = alClient
3233
BevelEdges = []
3334
BevelOuter = bvNone
34-
Padding.Left = 10
35+
Padding.Left = 18
3536
Padding.Top = 15
36-
Padding.Right = 10
3737
ParentBackground = False
3838
TabOrder = 0
39+
ExplicitWidth = 958
3940
DesignSize = (
40-
974
41+
956
4142
661)
4243
object Splitter1: TSplitter
43-
Left = 10
44-
Top = 524
45-
Width = 954
44+
Left = 18
45+
Top = 523
46+
Width = 938
4647
Height = 3
4748
Cursor = crVSplit
4849
Align = alBottom
@@ -52,10 +53,10 @@ object DelphiCopilotChatView: TDelphiCopilotChatView
5253
end
5354
object mmReturn: TRichEdit
5455
AlignWithMargins = True
55-
Left = 10
56+
Left = 18
5657
Top = 15
57-
Width = 954
58-
Height = 506
58+
Width = 938
59+
Height = 505
5960
Margins.Left = 0
6061
Margins.Top = 0
6162
Margins.Right = 0
@@ -78,11 +79,13 @@ object DelphiCopilotChatView: TDelphiCopilotChatView
7879
ShowHint = True
7980
TabOrder = 2
8081
Zoom = 100
82+
ExplicitLeft = 15
83+
ExplicitTop = 12
8184
end
82-
object pnBottom: TPanel
83-
Left = 10
84-
Top = 527
85-
Width = 954
85+
object pnBackQuestion: TPanel
86+
Left = 18
87+
Top = 526
88+
Width = 938
8689
Height = 113
8790
Margins.Left = 0
8891
Margins.Top = 0
@@ -93,8 +96,10 @@ object DelphiCopilotChatView: TDelphiCopilotChatView
9396
Padding.Top = 5
9497
ParentBackground = False
9598
TabOrder = 0
99+
ExplicitLeft = 10
100+
ExplicitWidth = 948
96101
object pnBackBtnSend: TPanel
97-
Left = 872
102+
Left = 856
98103
Top = 5
99104
Width = 82
100105
Height = 108
@@ -105,14 +110,14 @@ object DelphiCopilotChatView: TDelphiCopilotChatView
105110
Align = alRight
106111
BevelOuter = bvNone
107112
Padding.Left = 3
108-
Padding.Right = 10
109113
ParentBackground = False
110114
TabOrder = 0
115+
ExplicitLeft = 866
111116
object btnSend: TButton
112117
AlignWithMargins = True
113118
Left = 3
114119
Top = 0
115-
Width = 69
120+
Width = 79
116121
Height = 24
117122
Cursor = crHandPoint
118123
Margins.Left = 0
@@ -123,13 +128,14 @@ object DelphiCopilotChatView: TDelphiCopilotChatView
123128
Caption = 'Send'
124129
TabOrder = 0
125130
OnClick = btnSendClick
131+
ExplicitWidth = 69
126132
end
127133
end
128134
object mmQuestion: TMemo
129135
AlignWithMargins = True
130136
Left = 0
131137
Top = 5
132-
Width = 872
138+
Width = 856
133139
Height = 108
134140
Margins.Left = 0
135141
Margins.Top = 0
@@ -146,17 +152,19 @@ object DelphiCopilotChatView: TDelphiCopilotChatView
146152
OnChange = mmQuestionChange
147153
OnKeyDown = mmQuestionKeyDown
148154
OnKeyUp = mmQuestionKeyUp
155+
ExplicitWidth = 866
149156
end
150157
end
151158
object pnCommands: TPanel
152-
Left = 866
159+
Left = 850
153160
Top = 0
154161
Width = 79
155162
Height = 24
156163
Anchors = [akTop, akRight]
157164
BevelOuter = bvNone
158165
ParentBackground = False
159166
TabOrder = 1
167+
ExplicitLeft = 860
160168
object ShapeCommands: TShape
161169
Left = 0
162170
Top = 0
@@ -246,11 +254,11 @@ object DelphiCopilotChatView: TDelphiCopilotChatView
246254
ExplicitHeight = 22
247255
end
248256
end
249-
object Panel9: TPanel
250-
Left = 10
251-
Top = 640
252-
Width = 954
253-
Height = 21
257+
object pnBackStatusBar: TPanel
258+
Left = 18
259+
Top = 639
260+
Width = 938
261+
Height = 22
254262
Margins.Left = 0
255263
Margins.Top = 0
256264
Margins.Right = 0
@@ -260,11 +268,13 @@ object DelphiCopilotChatView: TDelphiCopilotChatView
260268
Padding.Top = 3
261269
ParentBackground = False
262270
TabOrder = 3
271+
ExplicitLeft = 10
272+
ExplicitWidth = 948
263273
object lbCurrentAI: TLabel
264274
Left = 0
265275
Top = 3
266276
Width = 56
267-
Height = 18
277+
Height = 19
268278
Cursor = crHandPoint
269279
Hint = 'AI being used'
270280
Align = alLeft
@@ -313,6 +323,18 @@ object DelphiCopilotChatView: TDelphiCopilotChatView
313323
TabOrder = 0
314324
end
315325
end
326+
object StatusBar1: TStatusBar
327+
Left = 956
328+
Top = 0
329+
Width = 19
330+
Height = 661
331+
Align = alRight
332+
Panels = <
333+
item
334+
Width = 50
335+
end>
336+
ExplicitLeft = 958
337+
end
316338
object ImageList1: TImageList
317339
Left = 96
318340
Top = 240

Src/Chat/DelphiCopilot.Chat.View.pas

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ TDelphiCopilotChatView = class(TDockableForm)
3838
Paste1: TMenuItem;
3939
SelectAll1: TMenuItem;
4040
pnBack: TPanel;
41-
pnBottom: TPanel;
41+
pnBackQuestion: TPanel;
4242
pnBackBtnSend: TPanel;
4343
btnSend: TButton;
4444
mmQuestion: TMemo;
@@ -53,11 +53,12 @@ TDelphiCopilotChatView = class(TDockableForm)
5353
pnWait: TPanel;
5454
ShapeWait: TShape;
5555
pnWaitCaption: TPanel;
56-
Panel9: TPanel;
57-
lbCurrentAI: TLabel;
5856
pMenuCurrentAI: TPopupMenu;
5957
Gemini1: TMenuItem;
6058
ChatGPT1: TMenuItem;
59+
pnBackStatusBar: TPanel;
60+
lbCurrentAI: TLabel;
61+
StatusBar1: TStatusBar;
6162
procedure FormShow(Sender: TObject);
6263
procedure cBoxSizeFontKeyPress(Sender: TObject; var Key: Char);
6364
procedure Cut1Click(Sender: TObject);
@@ -158,17 +159,15 @@ destructor TDelphiCopilotChatView.Destroy;
158159
procedure TDelphiCopilotChatView.FormShow(Sender: TObject);
159160
begin
160161
TUtilsOTA.IDEThemingAll(TDelphiCopilotChatView, Self);
161-
Self.Constraints.MinWidth := 100;
162-
Self.Constraints.MinHeight := 100;
162+
Self.Constraints.MinWidth := 150;
163+
Self.Constraints.MinHeight := 150;
163164

164165
Self.InitializeRichEditReturn;
165166
Self.ReadFromFile;
166167
Self.GetSelectedBlockForQuestion;
167168
btnMoreActions.Font.Color := TUtilsOTA.ActiveThemeColorDefault;
168169

169-
mmQuestion.SelectAll;
170-
mmQuestion.SelStart := Length(mmQuestion.Text);
171-
mmQuestion.SetFocus;
170+
TUtils.MemoFocusOnTheEnd(mmQuestion);
172171
end;
173172

174173
procedure TDelphiCopilotChatView.FormActivate(Sender: TObject);

Src/Utils/DelphiCopilot.Utils.pas

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ TUtils = class
2626
class function ShowMsgInternal(const AMsg, ADetails: string; const AIcon: TDelphiCopilotIcon;
2727
const AButtons: TC4DButtons; const ABtnFocu: TC4DBtnFocu; const AWinControlFocu: TWinControl): Boolean;
2828
public
29+
class procedure MemoFocusOnTheEnd(const AMemo: TMemo);
2930
class function IfThenColor(const Conditional: Boolean; const AColorTrue, AColorFalse: TColor): TColor;
3031
class function GetFormFromComponent(const AWinControl: TWinControl): TForm;
3132
class procedure CenterPanel(const APanel: TPanel); overload;
@@ -131,6 +132,21 @@ implementation
131132
DelphiCopilot.Consts,
132133
DelphiCopilot.WaitingScreen;
133134

135+
class procedure TUtils.MemoFocusOnTheEnd(const AMemo: TMemo);
136+
begin
137+
TThread.CreateAnonymousThread(
138+
procedure
139+
begin
140+
TThread.Synchronize(nil,
141+
procedure
142+
begin
143+
AMemo.SelStart := Length(AMemo.Text);
144+
AMemo.SelLength := 0;
145+
AMemo.SetFocus;
146+
end);
147+
end).Start;
148+
end;
149+
134150
class function TUtils.IfThenColor(const Conditional: Boolean; const AColorTrue, AColorFalse: TColor): TColor;
135151
begin
136152
Result := AColorFalse;

0 commit comments

Comments
 (0)