mirror of https://gitlab.com/basile.b/dexed.git
added process input history, controlled with <UP> and <DOWN>
This commit is contained in:
parent
fa3165bd2c
commit
150fed8772
|
@ -26,7 +26,7 @@ inherited CEProcInputWidget: TCEProcInputWidget
|
|||
BorderSpacing.Top = 2
|
||||
BorderSpacing.Right = 4
|
||||
BorderSpacing.Bottom = 4
|
||||
OnKeyPress = txtInpKeyPress
|
||||
OnKeyDown = txtInpKeyDown
|
||||
TabOrder = 0
|
||||
end
|
||||
object btnSend: TButton[1]
|
||||
|
|
|
@ -6,7 +6,7 @@ interface
|
|||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
|
||||
Menus, StdCtrls, ce_widget, process;
|
||||
Menus, StdCtrls, ce_widget, process, ce_common;
|
||||
|
||||
type
|
||||
|
||||
|
@ -16,12 +16,16 @@ type
|
|||
txtInp: TEdit;
|
||||
txtExeName: TStaticText;
|
||||
procedure btnSendClick(Sender: TObject);
|
||||
procedure txtInpKeyPress(Sender: TObject; var Key: char);
|
||||
procedure txtInpKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||
private
|
||||
fMruPos: Integer;
|
||||
fMru: TMRUList;
|
||||
fProc: TProcess;
|
||||
procedure sendInput;
|
||||
procedure setProc(const aValue: TProcess);
|
||||
public
|
||||
constructor create(aOwner: TComponent); override;
|
||||
destructor destroy; override;
|
||||
property process: TProcess read fProc write setProc;
|
||||
end;
|
||||
|
||||
|
@ -29,7 +33,20 @@ implementation
|
|||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
ce_common, ce_symstring;
|
||||
ce_symstring, LCLType;
|
||||
|
||||
constructor TCEProcInputWidget.create(aOwner: TComponent);
|
||||
begin
|
||||
inherited;
|
||||
fMru := TMRUList.Create;
|
||||
fMru.maxCount := 25;
|
||||
end;
|
||||
|
||||
destructor TCEProcInputWidget.destroy;
|
||||
begin
|
||||
fMru.Free;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TCEProcInputWidget.setProc(const aValue: TProcess);
|
||||
begin
|
||||
|
@ -47,6 +64,8 @@ procedure TCEProcInputWidget.sendInput;
|
|||
var
|
||||
inp: string;
|
||||
begin
|
||||
fMru.Insert(0,txtInp.Text);
|
||||
fMruPos := 0;
|
||||
if txtInp.Text <> '' then
|
||||
inp := symbolExpander.get(txtInp.Text) + lineEnding
|
||||
else
|
||||
|
@ -55,15 +74,6 @@ begin
|
|||
txtInp.Text := '';
|
||||
end;
|
||||
|
||||
procedure TCEProcInputWidget.txtInpKeyPress(Sender: TObject; var Key: char);
|
||||
begin
|
||||
if fProc = nil then
|
||||
exit;
|
||||
if key <> #13 then
|
||||
exit;
|
||||
sendInput;
|
||||
end;
|
||||
|
||||
procedure TCEProcInputWidget.btnSendClick(Sender: TObject);
|
||||
begin
|
||||
if fProc = nil then
|
||||
|
@ -71,4 +81,23 @@ begin
|
|||
sendInput;
|
||||
end;
|
||||
|
||||
procedure TCEProcInputWidget.txtInpKeyDown(Sender: TObject; var Key: Word;
|
||||
Shift: TShiftState);
|
||||
begin
|
||||
case Key of
|
||||
VK_RETURN:
|
||||
if fProc <> nil then sendInput;
|
||||
VK_UP: begin
|
||||
fMruPos += 1;
|
||||
if fMruPos > fMru.Count-1 then fMruPos := 0;
|
||||
txtInp.Text := fMru.Strings[fMruPos];
|
||||
end;
|
||||
VK_DOWN: begin
|
||||
fMruPos -= 1;
|
||||
if fMruPos < 0 then fMruPos := fMru.Count-1;
|
||||
txtInp.Text := fMru.Strings[fMruPos];
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
|
Loading…
Reference in New Issue