Skip to content

Commit 72b65b8

Browse files
committed
Merge branch 'develop'
2 parents ca499eb + dd736d6 commit 72b65b8

File tree

4 files changed

+76
-44
lines changed

4 files changed

+76
-44
lines changed

Src/Chat/DelphiAIDev.Chat.View.dfm

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ object DelphiAIDevChatView: TDelphiAIDevChatView
8181
ShowHint = True
8282
TabOrder = 1
8383
Zoom = 100
84-
ExplicitTop = 18
8584
end
8685
object pnBackQuestion: TPanel
8786
Left = 18
@@ -188,7 +187,7 @@ object DelphiAIDevChatView: TDelphiAIDevChatView
188187
Margins.Bottom = 0
189188
Align = alRight
190189
Caption = '* Use current unit code in query * '
191-
ImageIndex = 1
190+
ImageIndex = 0
192191
Images = ImageList1
193192
TabOrder = 0
194193
OnClick = btnUseCurrentUnitCodeClick
@@ -229,7 +228,6 @@ object DelphiAIDevChatView: TDelphiAIDevChatView
229228
PopupMenu = pMenuQuestions
230229
TabOrder = 2
231230
OnClick = btnDefaultsQuestionsClick
232-
ExplicitLeft = 126
233231
end
234232
end
235233
end

Src/Chat/DelphiAIDev.Chat.View.pas

Lines changed: 55 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ TDelphiAIDevChatView = class(TDockableForm)
106106
FbtnUseCurrentUnitCodeWidth: Integer;
107107
FbtnCodeOnlyWidth: Integer;
108108
FbtnDefaultsQuestionsWidth: Integer;
109-
procedure ReadFromFile;
110-
procedure WriteToFile;
109+
FQuestionOnShow: string;
110+
procedure FillMemoReturnWithFile;
111+
procedure SaveMemoReturnInFile;
111112
procedure InitializeRichEditReturn;
112113
procedure ProcessSend;
113114
procedure AddResponseSimple(const AString: string);
@@ -125,9 +126,11 @@ TDelphiAIDevChatView = class(TDockableForm)
125126
procedure AddItemsPopupMenuQuestion;
126127
procedure DoProcessClickInItemDefaultQuestions(ACodeOnly: Boolean; AQuestion: string);
127128
procedure ProcessWordWrap;
129+
procedure ConfScreenOnCreate;
128130
public
129131
constructor Create(AOwner: TComponent); override;
130132
destructor Destroy; override;
133+
property QuestionOnShow: string write FQuestionOnShow;
131134
end;
132135

133136
var
@@ -186,15 +189,15 @@ constructor TDelphiAIDevChatView.Create(AOwner: TComponent);
186189
FChat := TDelphiAIDevChat.Create;
187190
FSettings := FChat.Settings.GetInstance;
188191
FPopupMenuQuestions := TDelphiAIDevDefaultsQuestionsPopupMenu.Create;
192+
FQuestionOnShow := '';
189193

190-
pnWait.Visible := False;
191-
FbtnUseCurrentUnitCodeWidth := btnUseCurrentUnitCode.Width;
192-
FbtnCodeOnlyWidth := btnCodeOnly.Width;
193-
FbtnDefaultsQuestionsWidth := btnDefaultsQuestions.Width;
194+
Self.ConfScreenOnCreate;
195+
Self.FillMemoReturnWithFile; ////
194196
end;
195197

196198
destructor TDelphiAIDevChatView.Destroy;
197199
begin
200+
Self.SaveMemoReturnInFile; ////
198201
FPopupMenuQuestions.Free;
199202
FChat.Free;
200203
inherited;
@@ -204,49 +207,65 @@ procedure TDelphiAIDevChatView.FormShow(Sender: TObject);
204207
begin
205208
Self.ConfScreenOnShow;
206209
Self.InitializeRichEditReturn;
207-
Self.ReadFromFile;
210+
////Self.FillMemoReturnWithFile;
208211
Self.ProcessWordWrap;
209-
//Self.GetSelectedBlockForQuestion;
210212

211213
Self.AddItemsPopupMenuQuestion;
214+
212215
TUtils.MemoFocusOnTheEnd(mmQuestion);
213216
end;
214217

215-
procedure TDelphiAIDevChatView.AddItemsPopupMenuQuestion;
218+
procedure TDelphiAIDevChatView.FormActivate(Sender: TObject);
216219
begin
217-
FPopupMenuQuestions
218-
.ProcessClickInItem(DoProcessClickInItemDefaultQuestions)
219-
.CreateMenus(pMenuQuestions);
220+
Self.ConfLabelCurrentAI;
221+
222+
if not FQuestionOnShow.Trim.IsEmpty then
223+
begin
224+
mmQuestion.Lines.Clear;
225+
mmQuestion.Lines.Add(FQuestionOnShow);
226+
FQuestionOnShow := '';
227+
end;
220228
end;
221229

222-
procedure TDelphiAIDevChatView.DoProcessClickInItemDefaultQuestions(
223-
ACodeOnly: Boolean; AQuestion: string);
230+
procedure TDelphiAIDevChatView.ConfScreenOnCreate;
224231
begin
225-
if ACodeOnly then
226-
btnCodeOnly.ImageIndex := CodeOnly_ImageIndex_ON
227-
else
228-
btnCodeOnly.ImageIndex := CodeOnly_ImageIndex_OFF;
232+
mmReturn.Lines.Clear;
229233

230-
mmQuestion.Lines.Add(AQuestion);
234+
pnWait.Visible := False;
235+
FbtnUseCurrentUnitCodeWidth := btnUseCurrentUnitCode.Width;
236+
FbtnCodeOnlyWidth := btnCodeOnly.Width;
237+
FbtnDefaultsQuestionsWidth := btnDefaultsQuestions.Width;
238+
239+
ShapeCommands.Left := 0;
240+
ShapeCommands.Top := 0;
241+
ShapeCommands.Width := ShapeCommands.Parent.Width;
242+
ShapeCommands.Height := ShapeCommands.Parent.Height;
231243
end;
232244

233245
procedure TDelphiAIDevChatView.ConfScreenOnShow;
234246
begin
235247
TUtilsOTA.IDEThemingAll(TDelphiAIDevChatView, Self);
236-
Self.Constraints.MinWidth := 150;
237-
Self.Constraints.MinHeight := 150;
238-
239248
btnMoreActions.Font.Color := TUtilsOTA.ActiveThemeColorDefault;
240249

241-
ShapeCommands.Left := 0;
242-
ShapeCommands.Top := 0;
243-
ShapeCommands.Width := ShapeCommands.Parent.Width;
244-
ShapeCommands.Height := ShapeCommands.Parent.Height;
250+
Self.Constraints.MinWidth := 200;
251+
Self.Constraints.MinHeight := 300;
245252
end;
246253

247-
procedure TDelphiAIDevChatView.FormActivate(Sender: TObject);
254+
procedure TDelphiAIDevChatView.AddItemsPopupMenuQuestion;
248255
begin
249-
Self.ConfLabelCurrentAI;
256+
FPopupMenuQuestions
257+
.ProcessClickInItem(DoProcessClickInItemDefaultQuestions)
258+
.CreateMenus(pMenuQuestions);
259+
end;
260+
261+
procedure TDelphiAIDevChatView.DoProcessClickInItemDefaultQuestions(ACodeOnly: Boolean; AQuestion: string);
262+
begin
263+
if ACodeOnly then
264+
btnCodeOnly.ImageIndex := CodeOnly_ImageIndex_ON
265+
else
266+
btnCodeOnly.ImageIndex := CodeOnly_ImageIndex_OFF;
267+
268+
mmQuestion.Lines.Add(AQuestion);
250269
end;
251270

252271
procedure TDelphiAIDevChatView.mmQuestionChange(Sender: TObject);
@@ -268,7 +287,7 @@ procedure TDelphiAIDevChatView.mmQuestionKeyDown(Sender: TObject; var Key: Word;
268287

269288
procedure TDelphiAIDevChatView.mmQuestionKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
270289
begin
271-
if (ssCtrl in Shift)and(Key = 65)then
290+
if (ssCtrl in Shift)and(Key = 65) then
272291
begin
273292
mmQuestion.SelectAll;
274293
Key := 0;
@@ -277,7 +296,7 @@ procedure TDelphiAIDevChatView.mmQuestionKeyUp(Sender: TObject; var Key: Word; S
277296

278297
procedure TDelphiAIDevChatView.FormClose(Sender: TObject; var Action: TCloseAction);
279298
begin
280-
Self.WriteToFile;
299+
////Self.SaveMemoReturnInFile;
281300
Self.WaitingFormOFF;
282301
end;
283302

@@ -323,20 +342,20 @@ procedure TDelphiAIDevChatView.FormResize(Sender: TObject);
323342
end;
324343
end;
325344

326-
procedure TDelphiAIDevChatView.ReadFromFile;
345+
procedure TDelphiAIDevChatView.FillMemoReturnWithFile;
327346
begin
328347
if(FileExists(TUtils.GetPathFileChat))then
329348
mmReturn.Lines.LoadFromFile(TUtils.GetPathFileChat)
330349
end;
331350

332-
procedure TDelphiAIDevChatView.SelectAll1Click(Sender: TObject);
351+
procedure TDelphiAIDevChatView.SaveMemoReturnInFile;
333352
begin
334-
mmReturn.SelectAll;
353+
mmReturn.Lines.SaveToFile(TUtils.GetPathFileChat);
335354
end;
336355

337-
procedure TDelphiAIDevChatView.WriteToFile;
356+
procedure TDelphiAIDevChatView.SelectAll1Click(Sender: TObject);
338357
begin
339-
mmReturn.Lines.SaveToFile(TUtils.GetPathFileChat);
358+
mmReturn.SelectAll;
340359
end;
341360

342361
procedure TDelphiAIDevChatView.cBoxSizeFontKeyPress(Sender: TObject; var Key: Char);
@@ -678,7 +697,7 @@ procedure TDelphiAIDevChatView.btnMoreActionsClick(Sender: TObject);
678697

679698
procedure TDelphiAIDevChatView.InitializeRichEditReturn;
680699
begin
681-
mmReturn.Lines.Clear;
700+
//mmReturn.Lines.Clear;
682701
mmReturn.SelAttributes.Name := 'Courier New';
683702
mmReturn.SelAttributes.Size := 10;
684703

Src/Consts/DelphiAIDev.Consts.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ interface
55
type
66
TConsts = class
77
public const
8-
SEMANTIC_VERSION = '1.5.0';
8+
SEMANTIC_VERSION = '1.6.0';
99
SEMANTIC_VERSION_LB = 'Version: ' + SEMANTIC_VERSION;
1010
WIN_CONTROL_FOCU_NIL = nil;
1111
DELPHI_AI_DEVELOPER_DPROJ = 'DelphiAIDeveloper.dproj';

Src/IDE/Shortcuts/DelphiAIDev.IDE.Shortcuts.pas

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ interface
88
Winapi.Windows,
99
Vcl.Menus,
1010
ToolsAPI,
11-
DelphiAIDev.Utils.CnWizard;
11+
DelphiAIDev.Utils.CnWizard,
12+
DelphiAIDev.Chat.View;
1213

1314
type
1415
TDelphiAIDevIDEShortcuts = class(TNotifierObject, IOTAKeyboardBinding)
@@ -37,13 +38,13 @@ implementation
3738

3839
procedure RegisterSelf;
3940
begin
40-
// if(Index < 0)and(true)then
41+
// if Index < 0 then
4142
// Index := TUtilsOTA.GetIOTAKeyboardServices.AddKeyboardBinding(TDelphiAIDevIDEShortcuts.New);
4243
end;
4344

4445
procedure UnRegisterSelf;
4546
begin
46-
if(Index >= 0)then
47+
if Index >= 0 then
4748
begin
4849
TUtilsOTA.GetIOTAKeyboardServices.RemoveKeyboardBinding(Index);
4950
Index := -1;
@@ -81,21 +82,35 @@ procedure TDelphiAIDevIDEShortcuts.BindKeyboard(const BindingServices: IOTAKeyBi
8182
if TUtilsOTA.CurrentProjectIsDelphiAIDeveloperDPROJ then
8283
Exit;
8384

85+
Exit;
8486
BindingServices.AddKeyBinding([Shortcut(VK_RETURN, [])], Self.KeyProcBlockReturn, nil);
8587
BindingServices.AddKeyBinding([Shortcut(VK_RETURN, [ssAlt])], Self.KeyProcBlockReturnAndAlt, nil);
8688
end;
8789

8890
procedure TDelphiAIDevIDEShortcuts.KeyProcBlockReturn(const Context: IOTAKeyContext; KeyCode: TShortcut; var BindingResult: TKeyBindingResult);
8991
begin
92+
Exit;
93+
9094
TUtils.AddLog(GetCurrentLineOrBlock(CnOtaGetTopMostEditView));
9195
BindingResult := krNextProc; //krUnhandled;
9296
end;
9397

9498
procedure TDelphiAIDevIDEShortcuts.KeyProcBlockReturnAndAlt(const Context: IOTAKeyContext; KeyCode: TShortcut; var BindingResult: TKeyBindingResult);
99+
var
100+
LTextCurrentLineOrBlock: string;
95101
begin
96-
TUtils.AddLog('Enter and Alt' + GetCurrentLineOrBlock(CnOtaGetTopMostEditView));
102+
//TUtils.AddLog('Enter and Alt' + GetCurrentLineOrBlock(CnOtaGetTopMostEditView));
103+
104+
LTextCurrentLineOrBlock := GetCurrentLineOrBlock(CnOtaGetTopMostEditView);
105+
if LTextCurrentLineOrBlock.Trim.IsEmpty then
106+
Exit;
107+
108+
DelphiAIDev.Chat.View.DelphiAIDevChatView.QuestionOnShow := LTextCurrentLineOrBlock;
109+
DelphiAIDev.Chat.View.DelphiAIDevChatViewShowDockableForm;
110+
97111
BindingResult := krNextProc; //krUnhandled;
98112
end;
113+
99114
initialization
100115

101116
finalization

0 commit comments

Comments
 (0)