[ros-diffs] [gedmurphy] 41281: - Early stages of improving the console to make behave more like windbg... - Add a separate command line for entering commands - Keep a list of previous commands and traverse through them with up/down keys - Clean the command line with esc

gedmurphy at svn.reactos.org gedmurphy at svn.reactos.org
Thu Jun 4 14:35:13 CEST 2009


Author: gedmurphy
Date: Thu Jun  4 16:35:12 2009
New Revision: 41281

URL: http://svn.reactos.org/svn/reactos?rev=41281&view=rev
Log:
- Early stages of improving the console to make behave more like windbg...
- Add a separate command line for entering commands
- Keep a list of previous commands and traverse through them with up/down keys
- Clean the command line with esc

Modified:
    trunk/tools/reactosdbg/Pipe/namedpipe.cs
    trunk/tools/reactosdbg/RosDBG/Dockable Objects/RawTraffic.Designer.cs
    trunk/tools/reactosdbg/RosDBG/Dockable Objects/RawTraffic.cs
    trunk/tools/reactosdbg/RosDBG/Properties/AssemblyInfo.cs

Modified: trunk/tools/reactosdbg/Pipe/namedpipe.cs
URL: http://svn.reactos.org/svn/reactos/trunk/tools/reactosdbg/Pipe/namedpipe.cs?rev=41281&r1=41280&r2=41281&view=diff
==============================================================================
--- trunk/tools/reactosdbg/Pipe/namedpipe.cs [iso-8859-1] (original)
+++ trunk/tools/reactosdbg/Pipe/namedpipe.cs [iso-8859-1] Thu Jun  4 16:35:12 2009
@@ -229,7 +229,7 @@
             /* only forward a complete line */
             wCommand += str;
 
-            if (str[str.Length-1] == '\r')
+            if (str[str.Length-1] == '\r') //FIXME: remove this
             {
                 cmdList.Add(wCommand);
                 wCommand = null;

Modified: trunk/tools/reactosdbg/RosDBG/Dockable Objects/RawTraffic.Designer.cs
URL: http://svn.reactos.org/svn/reactos/trunk/tools/reactosdbg/RosDBG/Dockable%20Objects/RawTraffic.Designer.cs?rev=41281&r1=41280&r2=41281&view=diff
==============================================================================
--- trunk/tools/reactosdbg/RosDBG/Dockable Objects/RawTraffic.Designer.cs [iso-8859-1] (original)
+++ trunk/tools/reactosdbg/RosDBG/Dockable Objects/RawTraffic.Designer.cs [iso-8859-1] Thu Jun  4 16:35:12 2009
@@ -30,13 +30,22 @@
         {
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RawTraffic));
             this.RawTrafficText = new System.Windows.Forms.TextBox();
-            this.InputLabel = new System.Windows.Forms.Label();
             this.menuStrip1 = new System.Windows.Forms.MenuStrip();
             this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
             this.selectAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.splitContainer1 = new System.Windows.Forms.SplitContainer();
+            this.splitContainer2 = new System.Windows.Forms.SplitContainer();
+            this.label1 = new System.Windows.Forms.Label();
+            this.RawTrafficTextBox = new System.Windows.Forms.TextBox();
             this.menuStrip1.SuspendLayout();
+            this.splitContainer1.Panel1.SuspendLayout();
+            this.splitContainer1.Panel2.SuspendLayout();
+            this.splitContainer1.SuspendLayout();
+            this.splitContainer2.Panel1.SuspendLayout();
+            this.splitContainer2.Panel2.SuspendLayout();
+            this.splitContainer2.SuspendLayout();
             this.SuspendLayout();
             // 
             // RawTrafficText
@@ -48,19 +57,12 @@
             this.RawTrafficText.Multiline = true;
             this.RawTrafficText.Name = "RawTrafficText";
             this.RawTrafficText.ReadOnly = true;
-            this.RawTrafficText.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
-            this.RawTrafficText.Size = new System.Drawing.Size(397, 253);
+            this.RawTrafficText.ScrollBars = System.Windows.Forms.ScrollBars.Both;
+            this.RawTrafficText.Size = new System.Drawing.Size(425, 268);
             this.RawTrafficText.TabIndex = 0;
+            this.RawTrafficText.WordWrap = false;
             this.RawTrafficText.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.RawTrafficText_KeyPress);
             this.RawTrafficText.MouseUp += new System.Windows.Forms.MouseEventHandler(this.RawTrafficText_MouseUp);
-            // 
-            // InputLabel
-            // 
-            this.InputLabel.AutoSize = true;
-            this.InputLabel.Location = new System.Drawing.Point(91, 236);
-            this.InputLabel.Name = "InputLabel";
-            this.InputLabel.Size = new System.Drawing.Size(0, 13);
-            this.InputLabel.TabIndex = 1;
             // 
             // menuStrip1
             // 
@@ -107,15 +109,73 @@
             this.selectAllToolStripMenuItem.Text = "&Select all";
             this.selectAllToolStripMenuItem.Click += new System.EventHandler(this.selectAllToolStripMenuItem_Click);
             // 
+            // splitContainer1
+            // 
+            this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
+            this.splitContainer1.Location = new System.Drawing.Point(0, 0);
+            this.splitContainer1.Margin = new System.Windows.Forms.Padding(3, 0, 3, 3);
+            this.splitContainer1.Name = "splitContainer1";
+            this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
+            // 
+            // splitContainer1.Panel1
+            // 
+            this.splitContainer1.Panel1.Controls.Add(this.RawTrafficText);
+            // 
+            // splitContainer1.Panel2
+            // 
+            this.splitContainer1.Panel2.Controls.Add(this.splitContainer2);
+            this.splitContainer1.Size = new System.Drawing.Size(425, 294);
+            this.splitContainer1.SplitterDistance = 268;
+            this.splitContainer1.SplitterWidth = 1;
+            this.splitContainer1.TabIndex = 5;
+            // 
+            // splitContainer2
+            // 
+            this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.splitContainer2.Location = new System.Drawing.Point(0, 0);
+            this.splitContainer2.Name = "splitContainer2";
+            // 
+            // splitContainer2.Panel1
+            // 
+            this.splitContainer2.Panel1.Controls.Add(this.label1);
+            // 
+            // splitContainer2.Panel2
+            // 
+            this.splitContainer2.Panel2.Controls.Add(this.RawTrafficTextBox);
+            this.splitContainer2.Size = new System.Drawing.Size(425, 25);
+            this.splitContainer2.SplitterDistance = 39;
+            this.splitContainer2.SplitterWidth = 1;
+            this.splitContainer2.TabIndex = 0;
+            // 
+            // label1
+            // 
+            this.label1.Anchor = System.Windows.Forms.AnchorStyles.Right;
+            this.label1.AutoSize = true;
+            this.label1.Location = new System.Drawing.Point(2, 3);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(34, 13);
+            this.label1.TabIndex = 0;
+            this.label1.Text = "kdb:>";
+            // 
+            // RawTrafficTextBox
+            // 
+            this.RawTrafficTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.RawTrafficTextBox.Location = new System.Drawing.Point(0, 0);
+            this.RawTrafficTextBox.Name = "RawTrafficTextBox";
+            this.RawTrafficTextBox.Size = new System.Drawing.Size(385, 20);
+            this.RawTrafficTextBox.TabIndex = 0;
+            this.RawTrafficTextBox.Tag = "0";
+            this.RawTrafficTextBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.RawTrafficTextBox_KeyUp);
+            // 
             // RawTraffic
             // 
             this.AllowEndUserDocking = false;
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(397, 253);
+            this.ClientSize = new System.Drawing.Size(425, 294);
+            this.Controls.Add(this.splitContainer1);
             this.Controls.Add(this.menuStrip1);
-            this.Controls.Add(this.InputLabel);
-            this.Controls.Add(this.RawTrafficText);
             this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
             this.HideOnClose = true;
             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
@@ -123,6 +183,15 @@
             this.Text = "Console";
             this.menuStrip1.ResumeLayout(false);
             this.menuStrip1.PerformLayout();
+            this.splitContainer1.Panel1.ResumeLayout(false);
+            this.splitContainer1.Panel1.PerformLayout();
+            this.splitContainer1.Panel2.ResumeLayout(false);
+            this.splitContainer1.ResumeLayout(false);
+            this.splitContainer2.Panel1.ResumeLayout(false);
+            this.splitContainer2.Panel1.PerformLayout();
+            this.splitContainer2.Panel2.ResumeLayout(false);
+            this.splitContainer2.Panel2.PerformLayout();
+            this.splitContainer2.ResumeLayout(false);
             this.ResumeLayout(false);
             this.PerformLayout();
 
@@ -131,11 +200,14 @@
         #endregion
 
         private System.Windows.Forms.TextBox RawTrafficText;
-        private System.Windows.Forms.Label InputLabel;
         private System.Windows.Forms.MenuStrip menuStrip1;
         private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
         private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem;
         private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
         private System.Windows.Forms.ToolStripMenuItem selectAllToolStripMenuItem;
+        private System.Windows.Forms.SplitContainer splitContainer1;
+        private System.Windows.Forms.SplitContainer splitContainer2;
+        private System.Windows.Forms.TextBox RawTrafficTextBox;
+        private System.Windows.Forms.Label label1;
     }
 }

Modified: trunk/tools/reactosdbg/RosDBG/Dockable Objects/RawTraffic.cs
URL: http://svn.reactos.org/svn/reactos/trunk/tools/reactosdbg/RosDBG/Dockable%20Objects/RawTraffic.cs?rev=41281&r1=41280&r2=41281&view=diff
==============================================================================
--- trunk/tools/reactosdbg/RosDBG/Dockable Objects/RawTraffic.cs [iso-8859-1] (original)
+++ trunk/tools/reactosdbg/RosDBG/Dockable Objects/RawTraffic.cs [iso-8859-1] Thu Jun  4 16:35:12 2009
@@ -20,11 +20,22 @@
         private int totalPages;
         private int pageNumber;
         private string strPrintText;
+        private List<string> prevCommand;
+        private int maxCommands = 10;
         PrintDialog pd;
         PrintDocument printDoc;
-
         DebugConnection mConnection;
         List<string> textToAdd = new List<string>();
+
+
+
+        public RawTraffic()
+        {
+            InitializeComponent();
+
+            prevCommand = new List<string>(maxCommands);
+            RawTrafficTextBox.Tag = 0;
+        }
 
         protected override void OnLoad(EventArgs e)
         {
@@ -48,11 +59,8 @@
                 //TODO: skip backspace signs
             }
             RawTrafficText.AppendText(toAdd.ToString());
-            InputLabel.Location = RawTrafficText.GetPositionFromCharIndex(RawTrafficText.Text.Length -1);
-            InputLabel.Top += 2;
-            InputLabel.Left += 2;
-        }
-
+        }
+        
         void DebugRawTrafficEvent(object sender, DebugRawTrafficEventArgs args)
         {
             lock (textToAdd)
@@ -62,57 +70,36 @@
             Invoke(Delegate.CreateDelegate(typeof(NoParamsDelegate), this, "UpdateText"));
         }
 
-        public RawTraffic()
-        {
-            InitializeComponent();
-            InputLabel.Location = new Point(2, 2);
-        }
-
-        private void RawTrafficText_KeyPress(object sender, KeyPressEventArgs e)
-        {
-            if ((mConnection.ConnectionMode != DebugConnection.Mode.ClosedMode) && (!mConnection.Running))
-            {
-                switch ((int)e.KeyChar)
+        private void AddCommandToList(string cmd)
+        {
+            if (prevCommand.Count == maxCommands)
+            {
+                for (int i = 0; i < prevCommand.Count; i++)
                 {
-                    case 8: /* Backspace */
-                        if (InputLabel.Text.Length > 0)
-                            InputLabel.Text = InputLabel.Text.Substring(0, InputLabel.Text.Length - 1);
-                        break;
-                    case 13: /* Return */
-                        if (InputLabel.Text.ToLower().CompareTo("cont") == 0)
-                            mConnection.Running = true; 
-                        InputLabel.Text = "";
-                        break;
-                    default:
-                        InputLabel.Text += e.KeyChar;
-                        break;
+                    if (i < prevCommand.Count - 1)
+                        prevCommand[i] = prevCommand[i + 1];
                 }
 
-                mConnection.Debugger.Write("" + e.KeyChar);
-            }
-        }
-
-        private void RawTrafficText_MouseUp(object sender, MouseEventArgs e)
-        {
-            copyToolStripMenuItem.Enabled = (RawTrafficText.SelectionLength > 0);
-        }
-
-        private void copyToolStripMenuItem_Click(object sender, EventArgs e)
-        {
-            if (RawTrafficText.SelectionLength != 0)
-                Clipboard.SetText(RawTrafficText.SelectedText);
-        }
-
-        private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
-        {
-            RawTrafficText.SelectAll(); 
-        }
-
-        private void editToolStripMenuItem_Click(object sender, EventArgs e)
-        {
-            selectAllToolStripMenuItem.Enabled = (RawTrafficText.Text.Length != 0);
-        }
-
+                prevCommand.RemoveAt(prevCommand.Count - 1);
+            }
+
+            prevCommand.Add(cmd);
+
+            RawTrafficTextBox.Tag = prevCommand.Count;
+        }
+
+
+        private void SendCommandToDebugger()
+        {
+            if (RawTrafficTextBox.Text.Length > 0)
+            {
+                //AddCommandToList(RawTrafficTextBox.Text);
+                mConnection.Debugger.Write(RawTrafficTextBox.Text);
+            }
+        }
+
+
+        #region override methods
         public override bool IsCmdEnabled(Commands Cmd)
         {
             switch (Cmd)
@@ -171,71 +158,154 @@
                     printDoc.Print();
                 }
         }
+        #endregion
+
+        #region events
+        private void RawTrafficTextBox_KeyUp(object sender, KeyEventArgs e)
+        {
+            switch (e.KeyCode)
+            {
+                case Keys.Enter:
+                    AddCommandToList(RawTrafficTextBox.Text);
+                    RawTrafficTextBox.Text += '\r'; //FIXME: remove this
+                    SendCommandToDebugger();
+                    RawTrafficTextBox.Text = string.Empty;
+                    break;
+
+                case Keys.Up:
+                case Keys.Down:
+                    int prevCmd = (int)RawTrafficTextBox.Tag;
+
+                    if (e.KeyCode == Keys.Up)
+                        prevCmd--;
+                    else
+                        prevCmd++;
+
+                    if (prevCmd >= 0 && prevCmd < prevCommand.Count)
+                    {
+                        RawTrafficTextBox.Text = prevCommand[prevCmd];
+                        RawTrafficTextBox.Tag = prevCmd;
+                        RawTrafficTextBox.SelectionStart = RawTrafficTextBox.Text.Length;
+                    }
+                    break;
+
+                case Keys.Escape:
+                    RawTrafficTextBox.Text = string.Empty;
+                    RawTrafficTextBox.Tag = prevCommand.Count;
+                    break;
+            }
+
+        }
+
+        private void RawTrafficText_KeyPress(object sender, KeyPressEventArgs e)
+        {
+            if ((mConnection.ConnectionMode != DebugConnection.Mode.ClosedMode) && (!mConnection.Running))
+            {
+                switch ((int)e.KeyChar)
+                {
+                    case 8: /* Backspace */
+                        if (RawTrafficTextBox.Text.Length > 0)
+                            RawTrafficTextBox.Text = RawTrafficTextBox.Text.Substring(0, RawTrafficTextBox.Text.Length - 1);
+                        break;
+                    case 13: /* Return */
+                        if (RawTrafficTextBox.Text.ToLower().CompareTo("cont") == 0)
+                            mConnection.Running = true;
+                        RawTrafficTextBox.Text += e.KeyChar;
+                        SendCommandToDebugger();
+                        break;
+                    default:
+                        RawTrafficTextBox.Text += e.KeyChar;
+                        break;
+                }
+            }
+        }
+
+        private void RawTrafficText_MouseUp(object sender, MouseEventArgs e)
+        {
+            copyToolStripMenuItem.Enabled = (RawTrafficText.SelectionLength > 0);
+        }
+
+        private void copyToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            if (RawTrafficText.SelectionLength != 0)
+                Clipboard.SetText(RawTrafficText.SelectedText);
+        }
+
+        private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            RawTrafficText.SelectAll();
+        }
+
+        private void editToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            selectAllToolStripMenuItem.Enabled = (RawTrafficText.Text.Length != 0);
+        }
 
         private void printDoc_PrintPage(object sender, PrintPageEventArgs e)
         {
-                StringFormat stringFormat = new StringFormat();
-                RectangleF rectFPaper, rectFText;
-                int intChars, intLines;
-
-                rectFPaper = e.MarginBounds;
-                rectFText = RectangleF.Inflate(rectFPaper, 0,
-                                    -2 * RawTrafficText.Font.GetHeight(e.Graphics));
-                int totalLines = (int)Math.Floor(rectFText.Height /
-                                         RawTrafficText.Font.GetHeight(e.Graphics));
-                rectFText.Height = totalLines *
-                                          RawTrafficText.Font.GetHeight(e.Graphics);
-                stringFormat.Trimming = StringTrimming.Word;
-
-                while ((pageNumber < startPage) && (strPrintText.Length > 0))
-                {
-                    e.Graphics.MeasureString(strPrintText, RawTrafficText.Font,
-                                         rectFText.Size, stringFormat,
-                                         out intChars, out intLines);
-                    strPrintText = strPrintText.Substring(intChars);
-                    pageNumber++;
-                }
-
-                // Cancel job when nothing to print is left
-                if (strPrintText.Length == 0)
-                {
-                    e.Cancel = true;
-                    return;
-                }
-
-                e.Graphics.DrawString(strPrintText, RawTrafficText.Font, Brushes.Black, rectFText, stringFormat);
+            StringFormat stringFormat = new StringFormat();
+            RectangleF rectFPaper, rectFText;
+            int intChars, intLines;
+
+            rectFPaper = e.MarginBounds;
+            rectFText = RectangleF.Inflate(rectFPaper, 0,
+                                -2 * RawTrafficText.Font.GetHeight(e.Graphics));
+            int totalLines = (int)Math.Floor(rectFText.Height /
+                                     RawTrafficText.Font.GetHeight(e.Graphics));
+            rectFText.Height = totalLines *
+                                      RawTrafficText.Font.GetHeight(e.Graphics);
+            stringFormat.Trimming = StringTrimming.Word;
+
+            while ((pageNumber < startPage) && (strPrintText.Length > 0))
+            {
                 e.Graphics.MeasureString(strPrintText, RawTrafficText.Font,
-                                         rectFText.Size, stringFormat,
-                                         out intChars, out intLines);
+                                     rectFText.Size, stringFormat,
+                                     out intChars, out intLines);
                 strPrintText = strPrintText.Substring(intChars);
-                stringFormat = new StringFormat();
-
-                // show filename in header
-                stringFormat.Alignment = StringAlignment.Center;
-
-                e.Graphics.DrawString(printDoc.DocumentName, RawTrafficText.Font,
-                                      Brushes.Black, rectFPaper, stringFormat);
-
-                // show page number in footer
-                stringFormat.LineAlignment = StringAlignment.Far;
-
-                e.Graphics.DrawString("Page " + pageNumber, RawTrafficText.Font,
-                                     Brushes.Black, rectFPaper, stringFormat);
-
                 pageNumber++;
-                e.HasMorePages = (strPrintText.Length > 0) &&
-                                 (pageNumber < startPage + totalPages);
-
-                //re-init
-                if (!e.HasMorePages)
-                {
-                    strPrintText = RawTrafficText.Text;
-                    startPage = 1;
-                    totalPages = pd.PrinterSettings.MaximumPage;
-                    pageNumber = 1;
-                }
-            
-        }
+            }
+
+            // Cancel job when nothing to print is left
+            if (strPrintText.Length == 0)
+            {
+                e.Cancel = true;
+                return;
+            }
+
+            e.Graphics.DrawString(strPrintText, RawTrafficText.Font, Brushes.Black, rectFText, stringFormat);
+            e.Graphics.MeasureString(strPrintText, RawTrafficText.Font,
+                                     rectFText.Size, stringFormat,
+                                     out intChars, out intLines);
+            strPrintText = strPrintText.Substring(intChars);
+            stringFormat = new StringFormat();
+
+            // show filename in header
+            stringFormat.Alignment = StringAlignment.Center;
+
+            e.Graphics.DrawString(printDoc.DocumentName, RawTrafficText.Font,
+                                  Brushes.Black, rectFPaper, stringFormat);
+
+            // show page number in footer
+            stringFormat.LineAlignment = StringAlignment.Far;
+
+            e.Graphics.DrawString("Page " + pageNumber, RawTrafficText.Font,
+                                 Brushes.Black, rectFPaper, stringFormat);
+
+            pageNumber++;
+            e.HasMorePages = (strPrintText.Length > 0) &&
+                             (pageNumber < startPage + totalPages);
+
+            //re-init
+            if (!e.HasMorePages)
+            {
+                strPrintText = RawTrafficText.Text;
+                startPage = 1;
+                totalPages = pd.PrinterSettings.MaximumPage;
+                pageNumber = 1;
+            }
+
+        }
+        #endregion
 
     }
 }

Modified: trunk/tools/reactosdbg/RosDBG/Properties/AssemblyInfo.cs
URL: http://svn.reactos.org/svn/reactos/trunk/tools/reactosdbg/RosDBG/Properties/AssemblyInfo.cs?rev=41281&r1=41280&r2=41281&view=diff
==============================================================================
--- trunk/tools/reactosdbg/RosDBG/Properties/AssemblyInfo.cs [iso-8859-1] (original)
+++ trunk/tools/reactosdbg/RosDBG/Properties/AssemblyInfo.cs [iso-8859-1] Thu Jun  4 16:35:12 2009
@@ -39,5 +39,5 @@
 // will be increased as well. MSI installers must not be generated with the same Build Number
 // otherwise they won't upgrade the old installation!
 
-[assembly: AssemblyVersion("1.0.2.56")]
-[assembly: AssemblyFileVersion("1.0.2.56")]
+[assembly: AssemblyVersion("1.0.2.59")]
+[assembly: AssemblyFileVersion("1.0.2.59")]



More information about the Ros-diffs mailing list