Skip to content

Commit 33d6beb

Browse files
committed
refactor/melhorias
1 parent 2c582f1 commit 33d6beb

File tree

3 files changed

+56
-49
lines changed

3 files changed

+56
-49
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: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ TDelphiAIDevChatView = class(TDockableForm)
106106
FbtnUseCurrentUnitCodeWidth: Integer;
107107
FbtnCodeOnlyWidth: Integer;
108108
FbtnDefaultsQuestionsWidth: Integer;
109-
procedure ReadFromFile;
110-
procedure WriteToFile;
109+
procedure FillMemoReturnWithFile;
110+
procedure SaveMemoReturnInFile;
111111
procedure InitializeRichEditReturn;
112112
procedure ProcessSend;
113113
procedure AddResponseSimple(const AString: string);
@@ -125,6 +125,7 @@ TDelphiAIDevChatView = class(TDockableForm)
125125
procedure AddItemsPopupMenuQuestion;
126126
procedure DoProcessClickInItemDefaultQuestions(ACodeOnly: Boolean; AQuestion: string);
127127
procedure ProcessWordWrap;
128+
procedure ConfScreenOnCreate;
128129
public
129130
constructor Create(AOwner: TComponent); override;
130131
destructor Destroy; override;
@@ -187,14 +188,13 @@ constructor TDelphiAIDevChatView.Create(AOwner: TComponent);
187188
FSettings := FChat.Settings.GetInstance;
188189
FPopupMenuQuestions := TDelphiAIDevDefaultsQuestionsPopupMenu.Create;
189190

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

196195
destructor TDelphiAIDevChatView.Destroy;
197196
begin
197+
Self.SaveMemoReturnInFile; ////
198198
FPopupMenuQuestions.Free;
199199
FChat.Free;
200200
inherited;
@@ -204,49 +204,57 @@ procedure TDelphiAIDevChatView.FormShow(Sender: TObject);
204204
begin
205205
Self.ConfScreenOnShow;
206206
Self.InitializeRichEditReturn;
207-
Self.ReadFromFile;
207+
////Self.FillMemoReturnWithFile;
208208
Self.ProcessWordWrap;
209-
//Self.GetSelectedBlockForQuestion;
210209

211210
Self.AddItemsPopupMenuQuestion;
212211
TUtils.MemoFocusOnTheEnd(mmQuestion);
213212
end;
214213

215-
procedure TDelphiAIDevChatView.AddItemsPopupMenuQuestion;
214+
procedure TDelphiAIDevChatView.FormActivate(Sender: TObject);
216215
begin
217-
FPopupMenuQuestions
218-
.ProcessClickInItem(DoProcessClickInItemDefaultQuestions)
219-
.CreateMenus(pMenuQuestions);
216+
Self.ConfLabelCurrentAI;
220217
end;
221218

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

230-
mmQuestion.Lines.Add(AQuestion);
223+
pnWait.Visible := False;
224+
FbtnUseCurrentUnitCodeWidth := btnUseCurrentUnitCode.Width;
225+
FbtnCodeOnlyWidth := btnCodeOnly.Width;
226+
FbtnDefaultsQuestionsWidth := btnDefaultsQuestions.Width;
227+
228+
ShapeCommands.Left := 0;
229+
ShapeCommands.Top := 0;
230+
ShapeCommands.Width := ShapeCommands.Parent.Width;
231+
ShapeCommands.Height := ShapeCommands.Parent.Height;
231232
end;
232233

233234
procedure TDelphiAIDevChatView.ConfScreenOnShow;
234235
begin
235236
TUtilsOTA.IDEThemingAll(TDelphiAIDevChatView, Self);
236-
Self.Constraints.MinWidth := 150;
237-
Self.Constraints.MinHeight := 150;
238-
239237
btnMoreActions.Font.Color := TUtilsOTA.ActiveThemeColorDefault;
240238

241-
ShapeCommands.Left := 0;
242-
ShapeCommands.Top := 0;
243-
ShapeCommands.Width := ShapeCommands.Parent.Width;
244-
ShapeCommands.Height := ShapeCommands.Parent.Height;
239+
Self.Constraints.MinWidth := 200;
240+
Self.Constraints.MinHeight := 300;
245241
end;
246242

247-
procedure TDelphiAIDevChatView.FormActivate(Sender: TObject);
243+
procedure TDelphiAIDevChatView.AddItemsPopupMenuQuestion;
248244
begin
249-
Self.ConfLabelCurrentAI;
245+
FPopupMenuQuestions
246+
.ProcessClickInItem(DoProcessClickInItemDefaultQuestions)
247+
.CreateMenus(pMenuQuestions);
248+
end;
249+
250+
procedure TDelphiAIDevChatView.DoProcessClickInItemDefaultQuestions(ACodeOnly: Boolean; AQuestion: string);
251+
begin
252+
if ACodeOnly then
253+
btnCodeOnly.ImageIndex := CodeOnly_ImageIndex_ON
254+
else
255+
btnCodeOnly.ImageIndex := CodeOnly_ImageIndex_OFF;
256+
257+
mmQuestion.Lines.Add(AQuestion);
250258
end;
251259

252260
procedure TDelphiAIDevChatView.mmQuestionChange(Sender: TObject);
@@ -268,7 +276,7 @@ procedure TDelphiAIDevChatView.mmQuestionKeyDown(Sender: TObject; var Key: Word;
268276

269277
procedure TDelphiAIDevChatView.mmQuestionKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
270278
begin
271-
if (ssCtrl in Shift)and(Key = 65)then
279+
if (ssCtrl in Shift)and(Key = 65) then
272280
begin
273281
mmQuestion.SelectAll;
274282
Key := 0;
@@ -277,7 +285,7 @@ procedure TDelphiAIDevChatView.mmQuestionKeyUp(Sender: TObject; var Key: Word; S
277285

278286
procedure TDelphiAIDevChatView.FormClose(Sender: TObject; var Action: TCloseAction);
279287
begin
280-
Self.WriteToFile;
288+
////Self.SaveMemoReturnInFile;
281289
Self.WaitingFormOFF;
282290
end;
283291

@@ -323,20 +331,20 @@ procedure TDelphiAIDevChatView.FormResize(Sender: TObject);
323331
end;
324332
end;
325333

326-
procedure TDelphiAIDevChatView.ReadFromFile;
334+
procedure TDelphiAIDevChatView.FillMemoReturnWithFile;
327335
begin
328336
if(FileExists(TUtils.GetPathFileChat))then
329337
mmReturn.Lines.LoadFromFile(TUtils.GetPathFileChat)
330338
end;
331339

332-
procedure TDelphiAIDevChatView.SelectAll1Click(Sender: TObject);
340+
procedure TDelphiAIDevChatView.SaveMemoReturnInFile;
333341
begin
334-
mmReturn.SelectAll;
342+
mmReturn.Lines.SaveToFile(TUtils.GetPathFileChat);
335343
end;
336344

337-
procedure TDelphiAIDevChatView.WriteToFile;
345+
procedure TDelphiAIDevChatView.SelectAll1Click(Sender: TObject);
338346
begin
339-
mmReturn.Lines.SaveToFile(TUtils.GetPathFileChat);
347+
mmReturn.SelectAll;
340348
end;
341349

342350
procedure TDelphiAIDevChatView.cBoxSizeFontKeyPress(Sender: TObject; var Key: Char);
@@ -678,7 +686,7 @@ procedure TDelphiAIDevChatView.btnMoreActionsClick(Sender: TObject);
678686

679687
procedure TDelphiAIDevChatView.InitializeRichEditReturn;
680688
begin
681-
mmReturn.Lines.Clear;
689+
//mmReturn.Lines.Clear;
682690
mmReturn.SelAttributes.Name := 'Courier New';
683691
mmReturn.SelAttributes.Size := 10;
684692

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface
1313
type
1414
TDelphiAIDevIDEShortcuts = class(TNotifierObject, IOTAKeyboardBinding)
1515
private
16-
procedure KeyProcBlockReturn(const Context: IOTAKeyContext; KeyCode: TShortcut; var BindingResult: TKeyBindingResult);
16+
//procedure KeyProcBlockReturn(const Context: IOTAKeyContext; KeyCode: TShortcut; var BindingResult: TKeyBindingResult);
1717
procedure KeyProcBlockReturnAndAlt(const Context: IOTAKeyContext; KeyCode: TShortcut; var BindingResult: TKeyBindingResult);
1818
protected
1919
function GetBindingType: TBindingType;
@@ -37,13 +37,13 @@ implementation
3737

3838
procedure RegisterSelf;
3939
begin
40-
// if(Index < 0)and(true)then
41-
// Index := TUtilsOTA.GetIOTAKeyboardServices.AddKeyboardBinding(TDelphiAIDevIDEShortcuts.New);
40+
if Index < 0 then
41+
Index := TUtilsOTA.GetIOTAKeyboardServices.AddKeyboardBinding(TDelphiAIDevIDEShortcuts.New);
4242
end;
4343

4444
procedure UnRegisterSelf;
4545
begin
46-
if(Index >= 0)then
46+
if Index >= 0 then
4747
begin
4848
TUtilsOTA.GetIOTAKeyboardServices.RemoveKeyboardBinding(Index);
4949
Index := -1;
@@ -81,21 +81,22 @@ procedure TDelphiAIDevIDEShortcuts.BindKeyboard(const BindingServices: IOTAKeyBi
8181
if TUtilsOTA.CurrentProjectIsDelphiAIDeveloperDPROJ then
8282
Exit;
8383

84-
BindingServices.AddKeyBinding([Shortcut(VK_RETURN, [])], Self.KeyProcBlockReturn, nil);
84+
//BindingServices.AddKeyBinding([Shortcut(VK_RETURN, [])], Self.KeyProcBlockReturn, nil);
8585
BindingServices.AddKeyBinding([Shortcut(VK_RETURN, [ssAlt])], Self.KeyProcBlockReturnAndAlt, nil);
8686
end;
8787

88-
procedure TDelphiAIDevIDEShortcuts.KeyProcBlockReturn(const Context: IOTAKeyContext; KeyCode: TShortcut; var BindingResult: TKeyBindingResult);
89-
begin
90-
TUtils.AddLog(GetCurrentLineOrBlock(CnOtaGetTopMostEditView));
91-
BindingResult := krNextProc; //krUnhandled;
92-
end;
88+
//procedure TDelphiAIDevIDEShortcuts.KeyProcBlockReturn(const Context: IOTAKeyContext; KeyCode: TShortcut; var BindingResult: TKeyBindingResult);
89+
//begin
90+
// TUtils.AddLog(GetCurrentLineOrBlock(CnOtaGetTopMostEditView));
91+
// BindingResult := krNextProc; //krUnhandled;
92+
//end;
9393

9494
procedure TDelphiAIDevIDEShortcuts.KeyProcBlockReturnAndAlt(const Context: IOTAKeyContext; KeyCode: TShortcut; var BindingResult: TKeyBindingResult);
9595
begin
9696
TUtils.AddLog('Enter and Alt' + GetCurrentLineOrBlock(CnOtaGetTopMostEditView));
9797
BindingResult := krNextProc; //krUnhandled;
9898
end;
99+
99100
initialization
100101

101102
finalization

0 commit comments

Comments
 (0)