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.Top = 2
|
||||||
BorderSpacing.Right = 4
|
BorderSpacing.Right = 4
|
||||||
BorderSpacing.Bottom = 4
|
BorderSpacing.Bottom = 4
|
||||||
OnKeyPress = txtInpKeyPress
|
OnKeyDown = txtInpKeyDown
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
end
|
end
|
||||||
object btnSend: TButton[1]
|
object btnSend: TButton[1]
|
||||||
|
|
|
@ -6,7 +6,7 @@ interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
|
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
|
||||||
Menus, StdCtrls, ce_widget, process;
|
Menus, StdCtrls, ce_widget, process, ce_common;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
|
@ -16,12 +16,16 @@ type
|
||||||
txtInp: TEdit;
|
txtInp: TEdit;
|
||||||
txtExeName: TStaticText;
|
txtExeName: TStaticText;
|
||||||
procedure btnSendClick(Sender: TObject);
|
procedure btnSendClick(Sender: TObject);
|
||||||
procedure txtInpKeyPress(Sender: TObject; var Key: char);
|
procedure txtInpKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||||
private
|
private
|
||||||
|
fMruPos: Integer;
|
||||||
|
fMru: TMRUList;
|
||||||
fProc: TProcess;
|
fProc: TProcess;
|
||||||
procedure sendInput;
|
procedure sendInput;
|
||||||
procedure setProc(const aValue: TProcess);
|
procedure setProc(const aValue: TProcess);
|
||||||
public
|
public
|
||||||
|
constructor create(aOwner: TComponent); override;
|
||||||
|
destructor destroy; override;
|
||||||
property process: TProcess read fProc write setProc;
|
property process: TProcess read fProc write setProc;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -29,7 +33,20 @@ implementation
|
||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
uses
|
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);
|
procedure TCEProcInputWidget.setProc(const aValue: TProcess);
|
||||||
begin
|
begin
|
||||||
|
@ -47,6 +64,8 @@ procedure TCEProcInputWidget.sendInput;
|
||||||
var
|
var
|
||||||
inp: string;
|
inp: string;
|
||||||
begin
|
begin
|
||||||
|
fMru.Insert(0,txtInp.Text);
|
||||||
|
fMruPos := 0;
|
||||||
if txtInp.Text <> '' then
|
if txtInp.Text <> '' then
|
||||||
inp := symbolExpander.get(txtInp.Text) + lineEnding
|
inp := symbolExpander.get(txtInp.Text) + lineEnding
|
||||||
else
|
else
|
||||||
|
@ -55,15 +74,6 @@ begin
|
||||||
txtInp.Text := '';
|
txtInp.Text := '';
|
||||||
end;
|
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);
|
procedure TCEProcInputWidget.btnSendClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if fProc = nil then
|
if fProc = nil then
|
||||||
|
@ -71,4 +81,23 @@ begin
|
||||||
sendInput;
|
sendInput;
|
||||||
end;
|
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.
|
end.
|
||||||
|
|
Loading…
Reference in New Issue