From 309e8a88021cd32394e0340fa30c7cbce6068449 Mon Sep 17 00:00:00 2001 From: Eric Lawrence Date: Wed, 11 Oct 2023 16:04:18 -0500 Subject: [PATCH] Search as you type --- nmf-view/frmMain.Designer.cs | 219 ++++++++++++++++++----------------- nmf-view/frmMain.cs | 27 ++++- nmf-view/frmMain.resx | 6 +- 3 files changed, 137 insertions(+), 115 deletions(-) diff --git a/nmf-view/frmMain.Designer.cs b/nmf-view/frmMain.Designer.cs index 06f1e4b..6a2932b 100644 --- a/nmf-view/frmMain.Designer.cs +++ b/nmf-view/frmMain.Designer.cs @@ -30,19 +30,28 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { this.components = new System.ComponentModel.Container(); + System.Windows.Forms.ColumnHeader chManifest; System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain)); System.Windows.Forms.ListViewGroup listViewGroup1 = new System.Windows.Forms.ListViewGroup("User-Registered (HKCU)", System.Windows.Forms.HorizontalAlignment.Left); System.Windows.Forms.ListViewGroup listViewGroup2 = new System.Windows.Forms.ListViewGroup("System-Registered (HKLM)", System.Windows.Forms.HorizontalAlignment.Left); - System.Windows.Forms.ColumnHeader chManifest; this.tcApp = new System.Windows.Forms.TabControl(); this.pageMonitor = new System.Windows.Forms.TabPage(); this.txtLog = new System.Windows.Forms.RichTextBox(); + this.panel1 = new System.Windows.Forms.Panel(); + this.txtSearch = new System.Windows.Forms.TextBox(); this.pnlTop = new System.Windows.Forms.Panel(); this.clbOptions = new System.Windows.Forms.CheckedListBox(); this.pbApp = new System.Windows.Forms.PictureBox(); this.pbExt = new System.Windows.Forms.PictureBox(); this.lblArrow = new System.Windows.Forms.Label(); this.pageRegisteredHosts = new System.Windows.Forms.TabPage(); + this.lvHosts = new nmf_view.HostListView(); + this.chName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.colPriority = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chExe = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chDescription = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chBrowsers = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chExtensions = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.pnlConfigureControls = new System.Windows.Forms.Panel(); this.label2 = new System.Windows.Forms.Label(); this.pageInjector = new System.Windows.Forms.TabPage(); @@ -64,18 +73,10 @@ private void InitializeComponent() this.label1 = new System.Windows.Forms.Label(); this.lnkGithub = new System.Windows.Forms.LinkLabel(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); - this.panel1 = new System.Windows.Forms.Panel(); - this.txtSearch = new System.Windows.Forms.TextBox(); - this.lvHosts = new nmf_view.HostListView(); - this.chName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.colPriority = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chExe = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chDescription = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chBrowsers = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chExtensions = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); chManifest = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.tcApp.SuspendLayout(); this.pageMonitor.SuspendLayout(); + this.panel1.SuspendLayout(); this.pnlTop.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pbApp)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pbExt)).BeginInit(); @@ -89,9 +90,13 @@ private void InitializeComponent() this.pageTroubleshooter.SuspendLayout(); this.pageEnvironment.SuspendLayout(); this.pageAbout.SuspendLayout(); - this.panel1.SuspendLayout(); this.SuspendLayout(); // + // chManifest + // + chManifest.Text = "Manifest"; + chManifest.Width = 120; + // // tcApp // this.tcApp.Alignment = System.Windows.Forms.TabAlignment.Bottom; @@ -142,6 +147,28 @@ private void InitializeComponent() this.txtLog.WordWrap = false; this.txtLog.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtLog_KeyDown); // + // panel1 + // + this.panel1.Controls.Add(this.txtSearch); + this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel1.Location = new System.Drawing.Point(3, 749); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(1457, 59); + this.panel1.TabIndex = 4; + // + // txtSearch + // + this.txtSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtSearch.Location = new System.Drawing.Point(8, 10); + this.txtSearch.Margin = new System.Windows.Forms.Padding(10); + this.txtSearch.Name = "txtSearch"; + this.txtSearch.Size = new System.Drawing.Size(1442, 39); + this.txtSearch.TabIndex = 0; + this.txtSearch.TextChanged += new System.EventHandler(this.txtSearch_TextChanged); + this.txtSearch.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtSearch_KeyDown); + // // pnlTop // this.pnlTop.Controls.Add(this.clbOptions); @@ -226,6 +253,67 @@ private void InitializeComponent() this.pageRegisteredHosts.Text = "Configure Hosts"; this.pageRegisteredHosts.UseVisualStyleBackColor = true; // + // lvHosts + // + this.lvHosts.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.chName, + this.colPriority, + chManifest, + this.chExe, + this.chDescription, + this.chBrowsers, + this.chExtensions}); + this.lvHosts.Dock = System.Windows.Forms.DockStyle.Fill; + this.lvHosts.FullRowSelect = true; + this.lvHosts.GridLines = true; + listViewGroup1.Header = "User-Registered (HKCU)"; + listViewGroup1.Name = "lvgHKCU"; + listViewGroup2.Header = "System-Registered (HKLM)"; + listViewGroup2.Name = "lvgHKLM"; + this.lvHosts.Groups.AddRange(new System.Windows.Forms.ListViewGroup[] { + listViewGroup1, + listViewGroup2}); + this.lvHosts.HideSelection = false; + this.lvHosts.Location = new System.Drawing.Point(3, 104); + this.lvHosts.Name = "lvHosts"; + this.lvHosts.ShowItemToolTips = true; + this.lvHosts.Size = new System.Drawing.Size(1457, 704); + this.lvHosts.TabIndex = 0; + this.lvHosts.UseCompatibleStateImageBehavior = false; + this.lvHosts.View = System.Windows.Forms.View.Details; + this.lvHosts.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.lvHosts_ItemCheck); + this.lvHosts.KeyDown += new System.Windows.Forms.KeyEventHandler(this.lvHosts_KeyDown); + this.lvHosts.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.lvHosts_MouseDoubleClick); + // + // chName + // + this.chName.Text = "Name"; + this.chName.Width = 430; + // + // colPriority + // + this.colPriority.Text = "Priority"; + // + // chExe + // + this.chExe.Text = "Exe"; + this.chExe.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.chExe.Width = 200; + // + // chDescription + // + this.chDescription.Text = "Description"; + this.chDescription.Width = 120; + // + // chBrowsers + // + this.chBrowsers.Text = "Browsers"; + this.chBrowsers.Width = 100; + // + // chExtensions + // + this.chExtensions.Text = "Extensions"; + // // pnlConfigureControls // this.pnlConfigureControls.Controls.Add(this.label2); @@ -274,15 +362,15 @@ private void InitializeComponent() this.scInjector.Panel2.Controls.Add(this.btnPokeStdErr); this.scInjector.Panel2.Controls.Add(this.txtSendToExtension); this.scInjector.Panel2.Controls.Add(this.btnSendToExtension); - this.scInjector.Size = new System.Drawing.Size(1463, 819); - this.scInjector.SplitterDistance = 406; + this.scInjector.Size = new System.Drawing.Size(1463, 812); + this.scInjector.SplitterDistance = 402; this.scInjector.TabIndex = 4; // // btnSendToApp // this.btnSendToApp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnSendToApp.Enabled = false; - this.btnSendToApp.Location = new System.Drawing.Point(1013, 346); + this.btnSendToApp.Location = new System.Drawing.Point(1013, 342); this.btnSendToApp.Name = "btnSendToApp"; this.btnSendToApp.Size = new System.Drawing.Size(442, 41); this.btnSendToApp.TabIndex = 5; @@ -299,7 +387,7 @@ private void InitializeComponent() this.txtSendToApp.Location = new System.Drawing.Point(8, 8); this.txtSendToApp.Multiline = true; this.txtSendToApp.Name = "txtSendToApp"; - this.txtSendToApp.Size = new System.Drawing.Size(1447, 332); + this.txtSendToApp.Size = new System.Drawing.Size(1447, 328); this.txtSendToApp.TabIndex = 5; this.txtSendToApp.Text = "{\"example_1\": \"to nmh.exe\", \"field_2\": 2, \"field_3\":false}"; this.txtSendToApp.TextChanged += new System.EventHandler(this.txtSendToApp_TextChanged); @@ -307,7 +395,7 @@ private void InitializeComponent() // btnPokeStdErr // this.btnPokeStdErr.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnPokeStdErr.Location = new System.Drawing.Point(8, 350); + this.btnPokeStdErr.Location = new System.Drawing.Point(8, 347); this.btnPokeStdErr.Name = "btnPokeStdErr"; this.btnPokeStdErr.Size = new System.Drawing.Size(324, 41); this.btnPokeStdErr.TabIndex = 5; @@ -324,7 +412,7 @@ private void InitializeComponent() this.txtSendToExtension.Location = new System.Drawing.Point(8, 3); this.txtSendToExtension.Multiline = true; this.txtSendToExtension.Name = "txtSendToExtension"; - this.txtSendToExtension.Size = new System.Drawing.Size(1447, 341); + this.txtSendToExtension.Size = new System.Drawing.Size(1447, 338); this.txtSendToExtension.TabIndex = 3; this.txtSendToExtension.Text = "{\"example_1\": \"to browser\", \"field_2\": 2, \"field_3\":false}"; this.txtSendToExtension.TextChanged += new System.EventHandler(this.txtSendToExtension_TextChanged); @@ -333,7 +421,7 @@ private void InitializeComponent() // this.btnSendToExtension.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnSendToExtension.Enabled = false; - this.btnSendToExtension.Location = new System.Drawing.Point(1013, 350); + this.btnSendToExtension.Location = new System.Drawing.Point(1013, 347); this.btnSendToExtension.Name = "btnSendToExtension"; this.btnSendToExtension.Size = new System.Drawing.Size(442, 41); this.btnSendToExtension.TabIndex = 4; @@ -361,7 +449,7 @@ private void InitializeComponent() this.rtbTroubleshoot.Location = new System.Drawing.Point(0, 0); this.rtbTroubleshoot.Name = "rtbTroubleshoot"; this.rtbTroubleshoot.ReadOnly = true; - this.rtbTroubleshoot.Size = new System.Drawing.Size(1463, 819); + this.rtbTroubleshoot.Size = new System.Drawing.Size(1463, 812); this.rtbTroubleshoot.TabIndex = 4; this.rtbTroubleshoot.Text = ""; this.rtbTroubleshoot.WordWrap = false; @@ -387,7 +475,7 @@ private void InitializeComponent() this.rtbEnvironment.Location = new System.Drawing.Point(3, 3); this.rtbEnvironment.Name = "rtbEnvironment"; this.rtbEnvironment.ReadOnly = true; - this.rtbEnvironment.Size = new System.Drawing.Size(1457, 813); + this.rtbEnvironment.Size = new System.Drawing.Size(1457, 806); this.rtbEnvironment.TabIndex = 5; this.rtbEnvironment.Text = ""; this.rtbEnvironment.WordWrap = false; @@ -484,93 +572,6 @@ private void InitializeComponent() this.lnkGithub.UseCompatibleTextRendering = true; this.lnkGithub.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkGithub_LinkClicked); // - // panel1 - // - this.panel1.Controls.Add(this.txtSearch); - this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom; - this.panel1.Location = new System.Drawing.Point(3, 749); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(1457, 59); - this.panel1.TabIndex = 4; - // - // txtSearch - // - this.txtSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.txtSearch.Location = new System.Drawing.Point(8, 10); - this.txtSearch.Margin = new System.Windows.Forms.Padding(10); - this.txtSearch.Name = "txtSearch"; - this.txtSearch.Size = new System.Drawing.Size(1442, 39); - this.txtSearch.TabIndex = 0; - this.txtSearch.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtSearch_KeyDown); - // - // lvHosts - // - this.lvHosts.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.chName, - this.colPriority, - chManifest, - this.chExe, - this.chDescription, - this.chBrowsers, - this.chExtensions}); - this.lvHosts.Dock = System.Windows.Forms.DockStyle.Fill; - this.lvHosts.FullRowSelect = true; - this.lvHosts.GridLines = true; - listViewGroup1.Header = "User-Registered (HKCU)"; - listViewGroup1.Name = "lvgHKCU"; - listViewGroup2.Header = "System-Registered (HKLM)"; - listViewGroup2.Name = "lvgHKLM"; - this.lvHosts.Groups.AddRange(new System.Windows.Forms.ListViewGroup[] { - listViewGroup1, - listViewGroup2}); - this.lvHosts.HideSelection = false; - this.lvHosts.Location = new System.Drawing.Point(3, 104); - this.lvHosts.Name = "lvHosts"; - this.lvHosts.ShowItemToolTips = true; - this.lvHosts.Size = new System.Drawing.Size(1457, 711); - this.lvHosts.TabIndex = 0; - this.lvHosts.UseCompatibleStateImageBehavior = false; - this.lvHosts.View = System.Windows.Forms.View.Details; - this.lvHosts.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.lvHosts_ItemCheck); - this.lvHosts.KeyDown += new System.Windows.Forms.KeyEventHandler(this.lvHosts_KeyDown); - this.lvHosts.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.lvHosts_MouseDoubleClick); - // - // chName - // - this.chName.Text = "Name"; - this.chName.Width = 430; - // - // colPriority - // - this.colPriority.Text = "Priority"; - // - // chManifest - // - chManifest.Text = "Manifest"; - chManifest.Width = 120; - // - // chExe - // - this.chExe.Text = "Exe"; - this.chExe.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; - this.chExe.Width = 200; - // - // chDescription - // - this.chDescription.Text = "Description"; - this.chDescription.Width = 120; - // - // chBrowsers - // - this.chBrowsers.Text = "Browsers"; - this.chBrowsers.Width = 100; - // - // chExtensions - // - this.chExtensions.Text = "Extensions"; - // // frmMain // this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F); @@ -589,6 +590,8 @@ private void InitializeComponent() this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.frmMain_KeyDown); this.tcApp.ResumeLayout(false); this.pageMonitor.ResumeLayout(false); + this.panel1.ResumeLayout(false); + this.panel1.PerformLayout(); this.pnlTop.ResumeLayout(false); this.pnlTop.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pbApp)).EndInit(); @@ -607,8 +610,6 @@ private void InitializeComponent() this.pageEnvironment.ResumeLayout(false); this.pageAbout.ResumeLayout(false); this.pageAbout.PerformLayout(); - this.panel1.ResumeLayout(false); - this.panel1.PerformLayout(); this.ResumeLayout(false); } diff --git a/nmf-view/frmMain.cs b/nmf-view/frmMain.cs index c5edbeb..9fb3652 100644 --- a/nmf-view/frmMain.cs +++ b/nmf-view/frmMain.cs @@ -1103,14 +1103,20 @@ private void btnPokeStdErr_Click(object sender, EventArgs e) private void txtSearch_KeyDown(object sender, KeyEventArgs e) { - if ((e.KeyCode == Keys.Escape) || (e.KeyCode== Keys.Back && txtSearch.Text.Length <2)) + if ((e.KeyCode == Keys.Escape) || (e.KeyCode == Keys.Back && txtSearch.Text.Length <2)) { e.Handled = e.SuppressKeyPress = true; txtSearch.Clear(); - txtLog.SelectionLength = 0; - txtLog.SelectionStart = txtLog.TextLength; + txtLog.Select(txtLog.TextLength, 0); return; } + if (e.KeyCode == Keys.X && e.Control) + { + e.Handled = e.SuppressKeyPress = true; + txtLog.Clear(); + return; + } + if (e.KeyCode == Keys.Enter) { if (txtSearch.Text.Length > 0) @@ -1125,5 +1131,20 @@ private void txtSearch_KeyDown(object sender, KeyEventArgs e) return; } } + + private void txtSearch_TextChanged(object sender, EventArgs e) + { + if (txtSearch.Text.Length > 0) + { // Start at 0 if using TAB key for GoNext + txtSearch.BackColor = (txtLog.Find(txtSearch.Text, 0, RichTextBoxFinds.None) > -1) ? + Color.LightGreen : + Color.OrangeRed; + } + else + { + txtSearch.BackColor = Color.FromKnownColor(KnownColor.Window); + txtLog.Select(txtLog.TextLength, 0); + } + } } } diff --git a/nmf-view/frmMain.resx b/nmf-view/frmMain.resx index e0cc5a0..b1e3edb 100644 --- a/nmf-view/frmMain.resx +++ b/nmf-view/frmMain.resx @@ -117,6 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + False + @@ -184,9 +187,6 @@ 17, 17 - - False - QuickStart: Native Messaging allows a web browser extension to send and receive messages from an app running outside of the browser's sandbox. To do so, the browser extension calls connectNative() to launch the Native Host app. After the Host is launched, the extension and Host can communicate by exchanging length-prefixed UTF-8 JSON-encoded messages. This debugger can inject itself into that process, such that the browser will create it instead of the Native Host. This debugger will then spawn that Host and send messages between the extension and the Host, logging each message and optionally modifying it.