Skip to content

Commit dd736d6

Browse files
committed
refactor/melhorias-chat-view
1 parent 33d6beb commit dd736d6

File tree

3 files changed

+37
-12
lines changed

3 files changed

+37
-12
lines changed

Src/Chat/DelphiAIDev.Chat.View.pas

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ TDelphiAIDevChatView = class(TDockableForm)
106106
FbtnUseCurrentUnitCodeWidth: Integer;
107107
FbtnCodeOnlyWidth: Integer;
108108
FbtnDefaultsQuestionsWidth: Integer;
109+
FQuestionOnShow: string;
109110
procedure FillMemoReturnWithFile;
110111
procedure SaveMemoReturnInFile;
111112
procedure InitializeRichEditReturn;
@@ -129,6 +130,7 @@ TDelphiAIDevChatView = class(TDockableForm)
129130
public
130131
constructor Create(AOwner: TComponent); override;
131132
destructor Destroy; override;
133+
property QuestionOnShow: string write FQuestionOnShow;
132134
end;
133135

134136
var
@@ -187,6 +189,7 @@ constructor TDelphiAIDevChatView.Create(AOwner: TComponent);
187189
FChat := TDelphiAIDevChat.Create;
188190
FSettings := FChat.Settings.GetInstance;
189191
FPopupMenuQuestions := TDelphiAIDevDefaultsQuestionsPopupMenu.Create;
192+
FQuestionOnShow := '';
190193

191194
Self.ConfScreenOnCreate;
192195
Self.FillMemoReturnWithFile; ////
@@ -208,12 +211,20 @@ procedure TDelphiAIDevChatView.FormShow(Sender: TObject);
208211
Self.ProcessWordWrap;
209212

210213
Self.AddItemsPopupMenuQuestion;
214+
211215
TUtils.MemoFocusOnTheEnd(mmQuestion);
212216
end;
213217

214218
procedure TDelphiAIDevChatView.FormActivate(Sender: TObject);
215219
begin
216220
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;
217228
end;
218229

219230
procedure TDelphiAIDevChatView.ConfScreenOnCreate;

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: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ 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)
1516
private
16-
//procedure KeyProcBlockReturn(const Context: IOTAKeyContext; KeyCode: TShortcut; var BindingResult: TKeyBindingResult);
17+
procedure KeyProcBlockReturn(const Context: IOTAKeyContext; KeyCode: TShortcut; var BindingResult: TKeyBindingResult);
1718
procedure KeyProcBlockReturnAndAlt(const Context: IOTAKeyContext; KeyCode: TShortcut; var BindingResult: TKeyBindingResult);
1819
protected
1920
function GetBindingType: TBindingType;
@@ -37,8 +38,8 @@ implementation
3738

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

4445
procedure UnRegisterSelf;
@@ -81,19 +82,32 @@ procedure TDelphiAIDevIDEShortcuts.BindKeyboard(const BindingServices: IOTAKeyBi
8182
if TUtilsOTA.CurrentProjectIsDelphiAIDeveloperDPROJ then
8283
Exit;
8384

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

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;
90+
procedure TDelphiAIDevIDEShortcuts.KeyProcBlockReturn(const Context: IOTAKeyContext; KeyCode: TShortcut; var BindingResult: TKeyBindingResult);
91+
begin
92+
Exit;
93+
94+
TUtils.AddLog(GetCurrentLineOrBlock(CnOtaGetTopMostEditView));
95+
BindingResult := krNextProc; //krUnhandled;
96+
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;
99113

0 commit comments

Comments
 (0)