Skip to content

Commit a2b9531

Browse files
committed
bk/2024-06-21-1433
1 parent eb679b3 commit a2b9531

File tree

4 files changed

+36
-77
lines changed

4 files changed

+36
-77
lines changed

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

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ TDelphiAIDevIDEShortcuts = class(TNotifierObject, IOTAKeyboardBinding)
2222
procedure BindKeyboard(const BindingServices: IOTAKeyBindingServices);
2323
public
2424
class function New: IOTAKeyboardBinding;
25-
constructor Create;
26-
destructor Destroy; override;
2725
end;
2826

2927
procedure RefreshRegister;
@@ -63,16 +61,6 @@ class function TDelphiAIDevIDEShortcuts.New: IOTAKeyboardBinding;
6361
Result := Self.Create;
6462
end;
6563

66-
constructor TDelphiAIDevIDEShortcuts.Create;
67-
begin
68-
69-
end;
70-
71-
destructor TDelphiAIDevIDEShortcuts.Destroy;
72-
begin
73-
inherited;
74-
end;
75-
7664
function TDelphiAIDevIDEShortcuts.GetBindingType: TBindingType;
7765
begin
7866
Result := btPartial;
@@ -90,51 +78,24 @@ function TDelphiAIDevIDEShortcuts.GetName: string;
9078

9179
procedure TDelphiAIDevIDEShortcuts.BindKeyboard(const BindingServices: IOTAKeyBindingServices);
9280
begin
93-
Exit;
94-
9581
BindingServices.AddKeyBinding([Shortcut(VK_RETURN, [])], Self.KeyProcBlockReturn, nil);
9682
BindingServices.AddKeyBinding([Shortcut(VK_RETURN, [ssAlt])], Self.KeyProcBlockReturnAndAlt, nil);
9783
end;
9884

9985
procedure TDelphiAIDevIDEShortcuts.KeyProcBlockReturn(const Context: IOTAKeyContext; KeyCode: TShortcut; var BindingResult: TKeyBindingResult);
10086
begin
101-
TUtils.ShowMsg(GetCurrentLine(CnOtaGetTopMostEditView));
87+
TUtils.AddLog(GetCurrentLineOrBlock(CnOtaGetTopMostEditView));
10288
BindingResult := krUnhandled;
10389
end;
10490

10591
procedure TDelphiAIDevIDEShortcuts.KeyProcBlockReturnAndAlt(const Context: IOTAKeyContext; KeyCode: TShortcut; var BindingResult: TKeyBindingResult);
10692
begin
107-
TUtils.ShowMsg('Enter and Alt' + GetCurrentLine(CnOtaGetTopMostEditView));
93+
TUtils.AddLog('Enter and Alt' + GetCurrentLineOrBlock(CnOtaGetTopMostEditView));
10894
BindingResult := krUnhandled;
10995
end;
11096
initialization
11197

11298
finalization
11399
UnRegisterSelf;
114100

115-
//procedure TDelphiAIDevIDEShortcuts.KeyProcBlockReturnAndAlt(const Context: IOTAKeyContext; KeyCode: TShortcut; var BindingResult: TKeyBindingResult);
116-
//var
117-
// LIOTAProject: IOTAProject;
118-
//begin
119-
// LIOTAProject := TUtilsOTA.GetCurrentProject;
120-
// if LIOTAProject = nil then
121-
// begin
122-
// BindingResult := krUnhandled;
123-
// Exit;
124-
// end;
125-
126-
// if TUtils.FileNameIsDelphiAIDeveloperDPROJ(LIOTAProject.FileName) then
127-
// begin
128-
// BindingResult := krUnhandled;
129-
// Exit;
130-
// end;
131-
//
132-
// TUtils.ShowMsg('Enter and Alt' + GetCurrentLine(CnOtaGetTopMostEditView));
133-
134-
// if(C4DWizardSettingsModel.BlockKeyInsert)then
135-
// BindingResult := krHandled
136-
// else
137-
// BindingResult := krUnhandled;
138-
//end;
139-
140101
end.

Src/Test/Test.pas

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,22 @@
22

33
interface
44

5+
type
6+
TTest = class
7+
private
8+
FId: Integer;
9+
FNome: string;
10+
FEndereco: string;
11+
public
12+
class procedure LoadClient;
13+
end;
14+
515
implementation
616

7-
//minha pergunta aqui
817

18+
class procedure TTest.LoadClient;
19+
begin
20+
21+
end;
922

1023
end.

Src/Utils/DelphiAIDev.Utils.CnWizard.pas

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ function CnOtaGetTopMostEditView: IOTAEditView;
2727
function CnOtaEditPosToLinePos(EditPos: TOTAEditPos; EditView: IOTAEditView = nil): Integer;
2828
function OTAEditPos(Col: SmallInt; Line: Longint): TOTAEditPos;
2929
function CnOtaGetCurrLineText(var Text: string; var LineNo: Integer; var CharIndex: Integer; View: IOTAEditView = nil): Boolean;
30-
function GetCurrentLine(const AEditView: IOTAEditView): string;
30+
function GetCurrentLineOrBlock(const AEditView: IOTAEditView): string;
3131

3232
implementation
3333

34+
uses
35+
DelphiAiDev.Utils,
36+
DelphiAiDev.Utils.OTA;
37+
3438
function QuerySvcs(const Instance: IUnknown; const Intf: TGUID; out Inst): Boolean;
3539
begin
3640
Result := (Instance <> nil) and Supports(Instance, Intf, Inst);
@@ -98,7 +102,7 @@ function CnOtaGetCurrLineText(var Text: string; var LineNo: Integer; var CharInd
98102
OutStr: AnsiString;
99103
begin
100104
Result := False;
101-
//teste
105+
102106
if not Assigned(View)then
103107
View := CnOtaGetTopMostEditView;
104108
if not Assigned(View) then
@@ -130,14 +134,11 @@ function CnOtaGetCurrLineText(var Text: string; var LineNo: Integer; var CharInd
130134
Result := True;
131135
end;
132136

133-
function GetCurrentLine(const AEditView: IOTAEditView): string;
137+
function GetCurrentLineOrBlock(const AEditView: IOTAEditView): string;
134138
var
135-
TextLen: Integer;
136-
StartPos: Integer;
137-
EndPos: Integer;
138-
LineNo: Integer;
139-
CharIndex: Integer;
140-
LineText: String;
139+
LLineText: string;
140+
LLineNo: Integer;
141+
LCharIndex: Integer;
141142
begin
142143
Result := '';
143144
// if IsEditControl(Screen.ActiveControl) and Assigned(AEditView) then
@@ -148,32 +149,11 @@ function GetCurrentLine(const AEditView: IOTAEditView): string;
148149
Exit;
149150

150151
if AEditView.Block.IsValid then
151-
begin
152-
// StartPos := CnOtaEditPosToLinePos(OTAEditPos(AEditView.Block.StartingColumn,
153-
// AEditView.Block.StartingRow), AEditView);
154-
// EndPos := CnOtaEditPosToLinePos(OTAEditPos(AEditView.Block.EndingColumn,
155-
// AEditView.Block.EndingRow), AEditView);
156-
// TextLen := AEditView.Block.Size;
157-
//
158-
// {$IFDEF UNICODE}
159-
// CnOtaInsertTextIntoEditorAtPosW(AEditView.Block.Text, StartPos, AEditView.Buffer);
160-
// {$ELSE}
161-
// CnOtaInsertTextIntoEditorAtPos(ConvertEditorTextToText(AEditView.Block.Text), StartPos, AEditView.Buffer);
162-
// {$ENDIF}
163-
// AEditView.CursorPos := CnOtaLinePosToEditPos(StartPos + TextLen);
164-
// AEditView.Block.BeginBlock;
165-
// AEditView.CursorPos := CnOtaLinePosToEditPos(EndPos + TextLen);
166-
// AEditView.Block.EndBlock;
167-
//
168-
// AEditView.Paint;
169-
end
152+
Result := TUtilsOTA.GetBlockTextSelect
170153
else
171154
begin
172-
CnOtaGetCurrLineText(LineText, LineNo, CharIndex);
173-
Result := LineText;
174-
175-
//Inc(LineNo);
176-
//CnOtaInsertSingleLine(LineNo, LineText, AEditView);
155+
CnOtaGetCurrLineText(LLineText, LLineNo, LCharIndex);
156+
Result := LLineText;
177157
end;
178158
end;
179159

Src/Utils/DelphiAIDev.Utils.pas

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,23 @@ class procedure TUtils.AddLog(const AMessage: string);
141141
begin
142142
try
143143
if not(DirectoryExists(DIRECTORY)) then
144-
ForceCurrentDirectory(DIRECTORY);
144+
ForceDirectories(DIRECTORY);
145145

146-
LFileName := DIRECTORY + FormatDateTime('yyyy-mm-dd', Now) + 'txt';
146+
LFileName := DIRECTORY + FormatDateTime('yyyy-mm-dd', Now) + '.txt';
147147
AssignFile(LTextFile, LFileName);
148+
if not FileExists(LFileName)then
149+
Rewrite(LTextFile);
148150
Append(LTextFile);
149151
Writeln(LTextFile, AMessage);
150152
CloseFile(LTextFile);
151153
except
154+
// on E: Exception do
155+
// ShowMsg('Unable to generate log. Message: ' + E.Message + sLineBreak + 'Filename: ' + LFileName);
152156
end;
153157
end;
154158

155159
class function TUtils.GetFileName(const AExtension: string): string;
160+
156161
var
157162
LFileName: string;
158163
LSaveDialog: TSaveDialog;

0 commit comments

Comments
 (0)