Skip to content

Commit

Permalink
Trim text in TEdit's on session manager dialog, to prevent leading an…
Browse files Browse the repository at this point in the history
…d trailing spaces after pasting. Closes #797
  • Loading branch information
ansgarbecker committed Dec 11, 2019
1 parent 8b21b0d commit a40fd22
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
11 changes: 11 additions & 0 deletions source/connections.dfm
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ object connform: Tconnform
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
TabOrder = 5 TabOrder = 5
OnChange = Modification OnChange = Modification
OnExit = editTrim
end end
object editHost: TEdit object editHost: TEdit
Left = 120 Left = 120
Expand All @@ -336,6 +337,7 @@ object connform: Tconnform
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
TabOrder = 2 TabOrder = 2
OnChange = editHostChange OnChange = editHostChange
OnExit = editTrim
end end
object comboNetType: TComboBox object comboNetType: TComboBox
Left = 120 Left = 120
Expand Down Expand Up @@ -502,6 +504,7 @@ object connform: Tconnform
Text = 'editSSHUser' Text = 'editSSHUser'
TextHint = 'Your secure shell username' TextHint = 'Your secure shell username'
OnChange = Modification OnChange = Modification
OnExit = editTrim
end end
object editSSHPassword: TEdit object editSSHPassword: TEdit
Left = 120 Left = 120
Expand Down Expand Up @@ -529,6 +532,7 @@ object connform: Tconnform
TextHint = 'Doubleclick to select plink.exe ...' TextHint = 'Doubleclick to select plink.exe ...'
OnChange = editSSHPlinkExeChange OnChange = editSSHPlinkExeChange
OnDblClick = PickFile OnDblClick = PickFile
OnExit = editTrim
OnRightButtonClick = PickFile OnRightButtonClick = PickFile
end end
object editSSHhost: TEdit object editSSHhost: TEdit
Expand All @@ -540,6 +544,7 @@ object connform: Tconnform
TabOrder = 1 TabOrder = 1
Text = 'editSSHhost' Text = 'editSSHhost'
OnChange = Modification OnChange = Modification
OnExit = editTrim
end end
object editSSHport: TEdit object editSSHport: TEdit
Left = 356 Left = 356
Expand All @@ -566,6 +571,7 @@ object connform: Tconnform
TextHint = 'PuTTY private key (*.ppk)' TextHint = 'PuTTY private key (*.ppk)'
OnChange = Modification OnChange = Modification
OnDblClick = PickFile OnDblClick = PickFile
OnExit = editTrim
OnRightButtonClick = PickFile OnRightButtonClick = PickFile
end end
object editSSHTimeout: TEdit object editSSHTimeout: TEdit
Expand Down Expand Up @@ -668,6 +674,7 @@ object connform: Tconnform
TextHint = 'Path to key file' TextHint = 'Path to key file'
OnChange = Modification OnChange = Modification
OnDblClick = PickFile OnDblClick = PickFile
OnExit = editTrim
OnRightButtonClick = PickFile OnRightButtonClick = PickFile
end end
object editSSLCACertificate: TButtonedEdit object editSSLCACertificate: TButtonedEdit
Expand All @@ -683,6 +690,7 @@ object connform: Tconnform
TextHint = 'Path to certificate authority file' TextHint = 'Path to certificate authority file'
OnChange = Modification OnChange = Modification
OnDblClick = PickFile OnDblClick = PickFile
OnExit = editTrim
OnRightButtonClick = PickFile OnRightButtonClick = PickFile
end end
object editSSLCertificate: TButtonedEdit object editSSLCertificate: TButtonedEdit
Expand All @@ -698,6 +706,7 @@ object connform: Tconnform
TextHint = 'Path to certificate file' TextHint = 'Path to certificate file'
OnChange = Modification OnChange = Modification
OnDblClick = PickFile OnDblClick = PickFile
OnExit = editTrim
OnRightButtonClick = PickFile OnRightButtonClick = PickFile
end end
object chkWantSSL: TCheckBox object chkWantSSL: TCheckBox
Expand Down Expand Up @@ -746,6 +755,7 @@ object connform: Tconnform
TabOrder = 5 TabOrder = 5
OnChange = Modification OnChange = Modification
OnDblClick = PickFile OnDblClick = PickFile
OnExit = editTrim
OnRightButtonClick = PickFile OnRightButtonClick = PickFile
end end
object chkFullTableStatus: TCheckBox object chkFullTableStatus: TCheckBox
Expand Down Expand Up @@ -790,6 +800,7 @@ object connform: Tconnform
TabOrder = 4 TabOrder = 4
TextHint = 'List of permissible ciphers to use for SSL encryption' TextHint = 'List of permissible ciphers to use for SSL encryption'
OnChange = Modification OnChange = Modification
OnExit = editTrim
end end
object editKeepAlive: TEdit object editKeepAlive: TEdit
Left = 120 Left = 120
Expand Down
16 changes: 16 additions & 0 deletions source/connections.pas
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ Tconnform = class(TExtForm)
procedure TimerButtonAnimationTimer(Sender: TObject); procedure TimerButtonAnimationTimer(Sender: TObject);
procedure ColorBoxBackgroundColorGetColors(Sender: TCustomColorBox; procedure ColorBoxBackgroundColorGetColors(Sender: TCustomColorBox;
Items: TStrings); Items: TStrings);
procedure editTrim(Sender: TObject);
private private
{ Private declarations } { Private declarations }
FLoaded: Boolean; FLoaded: Boolean;
Expand Down Expand Up @@ -990,6 +991,21 @@ procedure Tconnform.editHostChange(Sender: TObject);
end; end;




procedure Tconnform.editTrim(Sender: TObject);
var
Edit: TCustomEdit;
Trimmed: String;
begin
// Trim input
Edit := Sender as TCustomEdit;
Trimmed := Edit.Text;
Trimmed := Trimmed.Trim([' ', #9]);
if Edit.Text <> Trimmed then begin
Edit.Text := Trimmed;
end;
end;


procedure Tconnform.chkLoginPromptClick(Sender: TObject); procedure Tconnform.chkLoginPromptClick(Sender: TObject);
var var
Checked: Boolean; Checked: Boolean;
Expand Down

0 comments on commit a40fd22

Please sign in to comment.