Skip to content

Commit 28924a6

Browse files
committed
update
1 parent 0921a6c commit 28924a6

File tree

5 files changed

+29
-11
lines changed

5 files changed

+29
-11
lines changed

ShellCat/BatchCmdForm.Designer.cs

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ShellCat/BatchCmdForm.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public BatchCmdForm(MainForm mainForm)
3434

3535
rtbInput.Font = new Font(rtbInput.Font.FontFamily, 10.5f);
3636
rtbOutput.Font = new Font(rtbOutput.Font.FontFamily, 10.5f);
37+
rtbInput.SelectionFont = new Font(rtbInput.Font.FontFamily, 10.5f);
38+
rtbOutput.SelectionFont = new Font(rtbInput.Font.FontFamily, 10.5f);
3739

3840
rtbInput.AppendText("You are using bath cmd mode, all your shell cmd will send to all selected servers.");
3941
rtbInput.AppendText("\n$ ");
@@ -105,13 +107,17 @@ public void AppendOutputText(string content)
105107
{
106108
var rtbSet = new DelegateRichTextBox(delegate (RichTextBox tb, string cnt)
107109
{
110+
// 设置插入点的字体
111+
tb.SelectionFont = new Font(tb.Font.FontFamily, 10.5f);
108112
tb.AppendText(cnt);
109113
tb.ScrollToCaret(); //让滚动条拉到最底处
110114
});
111115
rtbOutput.Invoke(rtbSet, rtbOutput, content);
112116
}
113117
else
114118
{
119+
// 设置插入点的字体
120+
rtbOutput.SelectionFont = new Font(rtbOutput.Font.FontFamily, 10.5f);
115121
rtbOutput.AppendText(content);
116122
rtbOutput.ScrollToCaret(); //让滚动条拉到最底处
117123
}
@@ -149,7 +155,7 @@ private void rtbInput_KeyUp(object sender, KeyEventArgs e)
149155
if (lvwIP.Items[i].Checked)
150156
{
151157
var remote = lvwIP.Items[i].SubItems[1].Text;
152-
_mainForm._server.SendMessageToClient(remote, cmd + "\n");
158+
_mainForm._server.SendMessageToClient(remote, cmd);
153159
}
154160
}
155161

ShellCat/MainForm.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ShellCat/Server.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,10 @@ private void OnReadComplete(IAsyncResult ar)
281281

282282
lock (_mainForm._lockObject)
283283
{
284-
if (_mainForm._showingBatchCmdForm)
284+
if (_mainForm._showingBatchCmdForm && !_mainForm._batchCmdForm.IsDisposed)
285285
{
286286
_mainForm._batchCmdForm.AppendOutputText("......................\n");
287-
_mainForm._batchCmdForm.AppendOutputText($"{_remoteEndPoint}: \n");
287+
_mainForm._batchCmdForm.AppendOutputText($"{_remoteEndPoint}\n");
288288
_mainForm._batchCmdForm.AppendOutputText(msg);
289289
_mainForm._batchCmdForm.AppendOutputText("\n");
290290
}

ShellCat/ShellTab.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,18 @@ public ShellTab(RemoteClient client)
2121
BackColor = Color.Black,
2222
ForeColor = Color.LimeGreen,
2323
};
24-
RtbShell.Font = new Font(RtbShell.Font.FontFamily, 10.5f);
24+
try
25+
{
26+
RtbShell.Font = new Font("Consolas", 10.5f);
27+
}
28+
catch
29+
{
30+
31+
}
32+
33+
RtbShell.SelectionFont = new Font(RtbShell.Font.FontFamily, 10.5f);
2534
this.Controls.Add(RtbShell);
26-
RtbShell.KeyDown += new System.Windows.Forms.KeyEventHandler(this.RtbShell_KeyDown);
35+
RtbShell.KeyUp += new System.Windows.Forms.KeyEventHandler(this.RtbShell_KeyUp);
2736
//RtbShell.KeyUp += new System.Windows.Forms.KeyEventHandler(this.RtbShell_KeyUp);
2837
RtbShell.TextChanged += new System.EventHandler(this.RtbShell_TextChanged);
2938
}
@@ -36,6 +45,8 @@ public void AppendText(string content)
3645
{
3746
var rtbSet = new DelegateRichTextBox(delegate(RichTextBox tb, string cnt)
3847
{
48+
// 设置插入点的字体
49+
tb.SelectionFont = new Font(tb.Font.FontFamily, 10.5f);
3950
tb.AppendText(cnt);
4051
tb.ScrollToCaret(); //让滚动条拉到最底处
4152
_oldLength = tb.TextLength; // 获取richtextbox中已有内容长度
@@ -44,6 +55,8 @@ public void AppendText(string content)
4455
}
4556
else
4657
{
58+
// 设置插入点的字体
59+
RtbShell.SelectionFont = new Font(RtbShell.Font.FontFamily, 10.5f);
4760
RtbShell.AppendText(content);
4861
RtbShell.ScrollToCaret(); //让滚动条拉到最底处
4962
_oldLength = RtbShell.TextLength; // 获取richtextbox中已有内容长度
@@ -65,15 +78,15 @@ private void RtbShell_TextChanged(object sender, EventArgs e)
6578
}
6679
}
6780

68-
private void RtbShell_KeyDown(object sender, KeyEventArgs e)
81+
private void RtbShell_KeyUp(object sender, KeyEventArgs e)
6982
{
7083
if (e.KeyCode == Keys.Enter)
7184
{
7285
if (!ConnectionLost)
7386
{
7487
var cmd = RtbShell.Text.Substring(_oldLength);
7588
_oldLength = RtbShell.TextLength;
76-
_client.SendMessage(cmd + "\n");
89+
_client.SendMessage(cmd);
7790
}
7891
}
7992
}

0 commit comments

Comments
 (0)