Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue #273 #552

Merged
merged 1 commit into from
Oct 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions SuperPutty/Utils/CommandData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public CommandData(KeyEventArgs e)
public KeyEventArgs KeyData { get; private set; }

public void SendToTerminal(int handle)
{
SendToTerminal(handle, true);
}

public void SendToTerminal(int handle, bool enter)
{
if (!string.IsNullOrEmpty(this.Command))
{
Expand All @@ -30,7 +35,10 @@ public void SendToTerminal(int handle)
{
NativeMethods.SendMessage(handle, NativeMethods.WM_CHAR, (int)c, 0);
}
NativeMethods.SendMessage(handle, NativeMethods.WM_CHAR, (int)Keys.Enter, 0);
if (enter)
{
NativeMethods.SendMessage(handle, NativeMethods.WM_CHAR, (int)Keys.Enter, 0);
}
}
else if (this.KeyData != null)
{
Expand All @@ -44,7 +52,7 @@ public void SendToTerminal(int handle)
if (this.KeyData.Shift) { NativeMethods.PostMessage(handle, NativeMethods.WM_KEYUP, NativeMethods.VK_SHIFT, 0); }
if (this.KeyData.Control) { NativeMethods.PostMessage(handle, NativeMethods.WM_KEYUP, NativeMethods.VK_CONTROL, 0); }
}
else
else if (enter)
{
NativeMethods.SendMessage(handle, NativeMethods.WM_CHAR, (int)Keys.Enter, 0);
}
Expand Down
16 changes: 13 additions & 3 deletions SuperPutty/frmSuperPutty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ private void tsSendCommandCombo_KeyDown(object sender, KeyEventArgs e)
else if (e.KeyCode == Keys.Enter)
{
// send commands
TrySendCommandsFromToolbar(new CommandData(this.tsSendCommandCombo.Text), !this.tbBtnMaskText.Checked);
TrySendCommandsFromToolbar(new CommandData(this.tsSendCommandCombo.Text), !this.tbBtnMaskText.Checked, !e.Shift);
e.Handled = true;
e.SuppressKeyPress = true;
}
Expand Down Expand Up @@ -1047,10 +1047,20 @@ private void tbBtnMaskText_Click(object sender, EventArgs e)

int TrySendCommandsFromToolbar(bool saveHistory)
{
return TrySendCommandsFromToolbar(new CommandData(this.tsSendCommandCombo.Text), saveHistory);
return TrySendCommandsFromToolbar(new CommandData(this.tsSendCommandCombo.Text), saveHistory, true);
}

int TrySendCommandsFromToolbar(bool saveHistory, bool enter)
{
return TrySendCommandsFromToolbar(new CommandData(this.tsSendCommandCombo.Text), saveHistory, enter);
}

int TrySendCommandsFromToolbar(CommandData command, bool saveHistory)
{
return TrySendCommandsFromToolbar(command, saveHistory, true);
}

int TrySendCommandsFromToolbar(CommandData command, bool saveHistory, bool enter)
{
int sent = 0;
if (this.DockPanel.DocumentsCount > 0)
Expand All @@ -1063,7 +1073,7 @@ int TrySendCommandsFromToolbar(CommandData command, bool saveHistory)
int handle = puttyPanel.AppPanel.AppWindowHandle.ToInt32();
Log.InfoFormat("SendCommand: session={0}, command=[{1}], handle={2}", puttyPanel.Session.SessionId, command, handle);

command.SendToTerminal(handle);
command.SendToTerminal(handle, enter);

sent++;
}
Expand Down