diff --git a/GUI.NET/Config/DebugInfo.cs b/GUI.NET/Config/DebugInfo.cs index 6a49dbb5..f5b068a7 100644 --- a/GUI.NET/Config/DebugInfo.cs +++ b/GUI.NET/Config/DebugInfo.cs @@ -59,7 +59,7 @@ namespace Mesen.GUI.Config config = (DebugWorkspace)xmlSerializer.Deserialize(textReader); } } catch { } - } + } config._filePath = path; @@ -140,7 +140,7 @@ namespace Mesen.GUI.Config public bool BreakInPpuCycles = false; public bool HighlightUnexecutedCode = true; - + public bool FindOccurrencesMatchCase = false; public bool FindOccurrencesMatchWholeWord = false; public string FindOccurrencesLastSearch = string.Empty; @@ -170,6 +170,15 @@ namespace Mesen.GUI.Config public bool AutoReloadScript = false; public int ScriptZoom = 100; + public bool AssemblerCodeHighlighting = true; + public XmlColor AssemblerOpcodeColor = Color.DarkSlateGray; + public XmlColor AssemblerLabelDefinitionColor = Color.Blue; + public XmlColor AssemblerImmediateColor = Color.Chocolate; + public XmlColor AssemblerAddressColor = Color.DarkRed; + public XmlColor AssemblerCommentColor = Color.Green; + public Size AssemblerSize = new Size(0, 0); + public int AssemblerZoom = 100; + public DebugInfo() { LeftView = new DebugViewInfo(); @@ -202,4 +211,43 @@ namespace Mesen.GUI.Config ConfigManager.ApplyChanges(); } } + + public class XmlColor + { + private Color _color = Color.Black; + + public XmlColor() { } + public XmlColor(Color c) { _color = c; } + + [XmlIgnore] + public Color Color + { + get { return _color; } + set { _color = value; } + } + + public static implicit operator Color(XmlColor x) + { + return x.Color; + } + + public static implicit operator XmlColor(Color c) + { + return new XmlColor(c); + } + + [XmlAttribute] + public string ColorString + { + get { return ColorTranslator.ToHtml(_color); } + set + { + try { + _color = ColorTranslator.FromHtml(value); + } catch(Exception) { + _color = Color.Black; + } + } + } + } } diff --git a/GUI.NET/Debugger/FastColoredTextBox/FastColoredTextBox.cs b/GUI.NET/Debugger/FastColoredTextBox/FastColoredTextBox.cs index bde6f859..33b9bcfa 100644 --- a/GUI.NET/Debugger/FastColoredTextBox/FastColoredTextBox.cs +++ b/GUI.NET/Debugger/FastColoredTextBox/FastColoredTextBox.cs @@ -71,7 +71,7 @@ namespace FastColoredTextBoxNS private Color currentLineColor; private Cursor defaultCursor; private Range delayedTextChangedRange; - private string descriptionFile; + private SyntaxDescriptor syntaxDescriptor; private int endFoldingLine = -1; private Color foldingIndicatorColor; protected Dictionary foldingPairs = new Dictionary(); @@ -802,13 +802,12 @@ namespace FastColoredTextBoxNS get { return lines.Styles; } } - /// - /// Hotkeys. Do not use this property in your code, use HotkeysMapping property. - /// - [Description("Here you can change hotkeys for FastColoredTextBox.")] - [Editor(typeof(HotkeysEditor), typeof(UITypeEditor))] - [DefaultValue("Tab=IndentIncrease, Escape=ClearHints, PgUp=GoPageUp, PgDn=GoPageDown, End=GoEnd, Home=GoHome, Left=GoLeft, Up=GoUp, Right=GoRight, Down=GoDown, Ins=ReplaceMode, Del=DeleteCharRight, F3=FindNext, Shift+Tab=IndentDecrease, Shift+PgUp=GoPageUpWithSelection, Shift+PgDn=GoPageDownWithSelection, Shift+End=GoEndWithSelection, Shift+Home=GoHomeWithSelection, Shift+Left=GoLeftWithSelection, Shift+Up=GoUpWithSelection, Shift+Right=GoRightWithSelection, Shift+Down=GoDownWithSelection, Shift+Ins=Paste, Shift+Del=Cut, Ctrl+Back=ClearWordLeft, Ctrl+Space=AutocompleteMenu, Ctrl+End=GoLastLine, Ctrl+Home=GoFirstLine, Ctrl+Left=GoWordLeft, Ctrl+Up=ScrollUp, Ctrl+Right=GoWordRight, Ctrl+Down=ScrollDown, Ctrl+Ins=Copy, Ctrl+Del=ClearWordRight, Ctrl+0=ZoomNormal, Ctrl+A=SelectAll, Ctrl+B=BookmarkLine, Ctrl+C=Copy, Ctrl+E=MacroExecute, Ctrl+F=FindDialog, Ctrl+G=GoToDialog, Ctrl+H=ReplaceDialog, Ctrl+I=AutoIndentChars, Ctrl+M=MacroRecord, Ctrl+N=GoNextBookmark, Ctrl+R=Redo, Ctrl+U=UpperCase, Ctrl+V=Paste, Ctrl+X=Cut, Ctrl+Z=Undo, Ctrl+Add=ZoomIn, Ctrl+Subtract=ZoomOut, Ctrl+OemMinus=NavigateBackward, Ctrl+Shift+End=GoLastLineWithSelection, Ctrl+Shift+Home=GoFirstLineWithSelection, Ctrl+Shift+Left=GoWordLeftWithSelection, Ctrl+Shift+Right=GoWordRightWithSelection, Ctrl+Shift+B=UnbookmarkLine, Ctrl+Shift+C=CommentSelected, Ctrl+Shift+N=GoPrevBookmark, Ctrl+Shift+U=LowerCase, Ctrl+Shift+OemMinus=NavigateForward, Alt+Back=Undo, Alt+Up=MoveSelectedLinesUp, Alt+Down=MoveSelectedLinesDown, Alt+F=FindChar, Alt+Shift+Left=GoLeft_ColumnSelectionMode, Alt+Shift+Up=GoUp_ColumnSelectionMode, Alt+Shift+Right=GoRight_ColumnSelectionMode, Alt+Shift+Down=GoDown_ColumnSelectionMode")] - public string Hotkeys { + /// + /// Hotkeys. Do not use this property in your code, use HotkeysMapping property. + /// + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public string Hotkeys { get { return HotkeysMapping.ToString(); } set { HotkeysMapping = HotkeysMapping.Parse(value); } } @@ -1014,12 +1013,12 @@ namespace FastColoredTextBoxNS [Description( "XML file with description of syntax highlighting. This property works only with Language == Language.Custom." )] - public string DescriptionFile + public SyntaxDescriptor SyntaxDescriptor { - get { return descriptionFile; } + get { return syntaxDescriptor; } set { - descriptionFile = value; + syntaxDescriptor = value; Invalidate(); } } @@ -1466,8 +1465,7 @@ namespace FastColoredTextBoxNS get { return Math.Abs(PlaceToPosition(Selection.Start) - PlaceToPosition(Selection.End)); } set { - if (value > 0) - Selection.End = PositionToPlace(SelectionStart + value); + Selection.End = PositionToPlace(SelectionStart + value); } } @@ -7099,8 +7097,8 @@ namespace FastColoredTextBoxNS if (SyntaxHighlighter != null) { - if (Language == Language.Custom && !string.IsNullOrEmpty(DescriptionFile)) - SyntaxHighlighter.HighlightSyntax(DescriptionFile, range); + if (Language == Language.Custom && SyntaxDescriptor != null) + SyntaxHighlighter.HighlightSyntax(SyntaxDescriptor, range); else SyntaxHighlighter.HighlightSyntax(Language, range); } @@ -7287,6 +7285,9 @@ window.status = ""#print""; if (ToolTip != null) ToolTip.Dispose(); + + if (SyntaxDescriptor != null) + SyntaxDescriptor.Dispose(); } } diff --git a/GUI.NET/Debugger/FastColoredTextBox/Style.cs b/GUI.NET/Debugger/FastColoredTextBox/Style.cs index 08b1833f..5159d628 100644 --- a/GUI.NET/Debugger/FastColoredTextBox/Style.cs +++ b/GUI.NET/Debugger/FastColoredTextBox/Style.cs @@ -210,6 +210,14 @@ namespace FastColoredTextBoxNS return result; } + + public override void Dispose() + { + base.Dispose(); + + if (ForeBrush != null) + ForeBrush.Dispose(); + } } /// diff --git a/GUI.NET/Debugger/FastColoredTextBox/SyntaxHighlighter.cs b/GUI.NET/Debugger/FastColoredTextBox/SyntaxHighlighter.cs index f52f967e..49bcf3fc 100644 --- a/GUI.NET/Debugger/FastColoredTextBox/SyntaxHighlighter.cs +++ b/GUI.NET/Debugger/FastColoredTextBox/SyntaxHighlighter.cs @@ -168,27 +168,6 @@ namespace FastColoredTextBoxNS } } - /// - /// Highlights syntax for given XML description file - /// - public virtual void HighlightSyntax(string XMLdescriptionFile, Range range) - { - SyntaxDescriptor desc = null; - if (!descByXMLfileNames.TryGetValue(XMLdescriptionFile, out desc)) - { - var doc = new XmlDocument(); - string file = XMLdescriptionFile; - if (!File.Exists(file)) - file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Path.GetFileName(file)); - - doc.LoadXml(File.ReadAllText(file)); - desc = ParseXmlDescription(doc); - descByXMLfileNames[XMLdescriptionFile] = desc; - } - - HighlightSyntax(desc, range); - } - public virtual void AutoIndentNeeded(object sender, AutoIndentEventArgs args) { var tb = (sender as FastColoredTextBox); diff --git a/GUI.NET/Debugger/frmAssembler.Designer.cs b/GUI.NET/Debugger/frmAssembler.Designer.cs index 0f8c5b9c..da7739eb 100644 --- a/GUI.NET/Debugger/frmAssembler.Designer.cs +++ b/GUI.NET/Debugger/frmAssembler.Designer.cs @@ -27,6 +27,7 @@ /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.btnOk = new System.Windows.Forms.Button(); this.btnCancel = new System.Windows.Forms.Button(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); @@ -46,12 +47,20 @@ this.lblNoChanges = new System.Windows.Forms.Label(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.panel1 = new System.Windows.Forms.Panel(); - this.txtCode = new Mesen.GUI.Debugger.ZoomlessRichTextBox(); - this.statCode = new System.Windows.Forms.StatusStrip(); - this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); - this.lblLineNumber = new System.Windows.Forms.ToolStripStatusLabel(); + this.txtCode = new FastColoredTextBoxNS.FastColoredTextBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.ctrlHexBox = new Be.Windows.Forms.HexBox(); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuClose = new System.Windows.Forms.ToolStripMenuItem(); + this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.fontSizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuIncreaseFontSize = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuDecreaseFontSize = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuResetFontSize = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuConfigureColors = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator(); + this.mnuEnableSyntaxHighlighting = new System.Windows.Forms.ToolStripMenuItem(); this.tableLayoutPanel1.SuspendLayout(); this.grpSettings.SuspendLayout(); this.tableLayoutPanel2.SuspendLayout(); @@ -62,13 +71,14 @@ this.flowLayoutPanel3.SuspendLayout(); this.groupBox1.SuspendLayout(); this.panel1.SuspendLayout(); - this.statCode.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.txtCode)).BeginInit(); this.groupBox2.SuspendLayout(); + this.menuStrip1.SuspendLayout(); this.SuspendLayout(); // // btnOk // - this.btnOk.Location = new System.Drawing.Point(186, 3); + this.btnOk.Location = new System.Drawing.Point(194, 3); this.btnOk.Name = "btnOk"; this.btnOk.Size = new System.Drawing.Size(75, 23); this.btnOk.TabIndex = 0; @@ -80,7 +90,7 @@ // btnCancel // this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.btnCancel.Location = new System.Drawing.Point(267, 3); + this.btnCancel.Location = new System.Drawing.Point(275, 3); this.btnCancel.Name = "btnCancel"; this.btnCancel.Size = new System.Drawing.Size(75, 23); this.btnCancel.TabIndex = 1; @@ -98,20 +108,21 @@ this.tableLayoutPanel1.Controls.Add(this.groupBox1, 0, 0); this.tableLayoutPanel1.Controls.Add(this.groupBox2, 1, 0); this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 24); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; this.tableLayoutPanel1.RowCount = 2; this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 141F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(835, 557); + this.tableLayoutPanel1.Size = new System.Drawing.Size(835, 440); this.tableLayoutPanel1.TabIndex = 2; // // lstErrors // + this.lstErrors.Dock = System.Windows.Forms.DockStyle.Fill; this.lstErrors.FormattingEnabled = true; - this.lstErrors.Location = new System.Drawing.Point(3, 419); + this.lstErrors.Location = new System.Drawing.Point(3, 302); this.lstErrors.Name = "lstErrors"; - this.lstErrors.Size = new System.Drawing.Size(379, 134); + this.lstErrors.Size = new System.Drawing.Size(369, 135); this.lstErrors.TabIndex = 2; this.lstErrors.DoubleClick += new System.EventHandler(this.lstErrors_DoubleClick); // @@ -119,9 +130,9 @@ // this.grpSettings.Controls.Add(this.tableLayoutPanel2); this.grpSettings.Dock = System.Windows.Forms.DockStyle.Fill; - this.grpSettings.Location = new System.Drawing.Point(388, 419); + this.grpSettings.Location = new System.Drawing.Point(378, 302); this.grpSettings.Name = "grpSettings"; - this.grpSettings.Size = new System.Drawing.Size(444, 135); + this.grpSettings.Size = new System.Drawing.Size(454, 135); this.grpSettings.TabIndex = 3; this.grpSettings.TabStop = false; this.grpSettings.Text = "Settings"; @@ -143,7 +154,7 @@ this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanel2.Size = new System.Drawing.Size(438, 116); + this.tableLayoutPanel2.Size = new System.Drawing.Size(448, 116); this.tableLayoutPanel2.TabIndex = 0; // // btnExecute @@ -169,7 +180,7 @@ this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0); this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0); this.flowLayoutPanel1.Name = "flowLayoutPanel1"; - this.flowLayoutPanel1.Size = new System.Drawing.Size(438, 25); + this.flowLayoutPanel1.Size = new System.Drawing.Size(448, 25); this.flowLayoutPanel1.TabIndex = 3; // // label1 @@ -215,7 +226,7 @@ this.flowLayoutPanel2.Location = new System.Drawing.Point(0, 25); this.flowLayoutPanel2.Margin = new System.Windows.Forms.Padding(0); this.flowLayoutPanel2.Name = "flowLayoutPanel2"; - this.flowLayoutPanel2.Size = new System.Drawing.Size(438, 25); + this.flowLayoutPanel2.Size = new System.Drawing.Size(448, 25); this.flowLayoutPanel2.TabIndex = 4; // // label2 @@ -256,10 +267,10 @@ this.flowLayoutPanel3.Controls.Add(this.lblNoChanges); this.flowLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Bottom; this.flowLayoutPanel3.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; - this.flowLayoutPanel3.Location = new System.Drawing.Point(93, 86); + this.flowLayoutPanel3.Location = new System.Drawing.Point(95, 86); this.flowLayoutPanel3.Margin = new System.Windows.Forms.Padding(0); this.flowLayoutPanel3.Name = "flowLayoutPanel3"; - this.flowLayoutPanel3.Size = new System.Drawing.Size(345, 30); + this.flowLayoutPanel3.Size = new System.Drawing.Size(353, 30); this.flowLayoutPanel3.TabIndex = 5; // // lblNoChanges @@ -268,7 +279,7 @@ this.lblNoChanges.AutoSize = true; this.lblNoChanges.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); this.lblNoChanges.ForeColor = System.Drawing.SystemColors.GrayText; - this.lblNoChanges.Location = new System.Drawing.Point(6, 8); + this.lblNoChanges.Location = new System.Drawing.Point(14, 8); this.lblNoChanges.Name = "lblNoChanges"; this.lblNoChanges.Size = new System.Drawing.Size(174, 13); this.lblNoChanges.TabIndex = 2; @@ -280,7 +291,7 @@ this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; this.groupBox1.Location = new System.Drawing.Point(3, 3); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(379, 410); + this.groupBox1.Size = new System.Drawing.Size(369, 293); this.groupBox1.TabIndex = 4; this.groupBox1.TabStop = false; this.groupBox1.Text = "Code Editor"; @@ -289,68 +300,54 @@ // this.panel1.BackColor = System.Drawing.SystemColors.ControlDark; this.panel1.Controls.Add(this.txtCode); - this.panel1.Controls.Add(this.statCode); this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(3, 16); this.panel1.Name = "panel1"; this.panel1.Padding = new System.Windows.Forms.Padding(1); - this.panel1.Size = new System.Drawing.Size(373, 391); + this.panel1.Size = new System.Drawing.Size(363, 274); this.panel1.TabIndex = 4; // // txtCode // - this.txtCode.AcceptsTab = true; - this.txtCode.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.txtCode.AutoWordSelection = true; - this.txtCode.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.txtCode.DetectUrls = false; - this.txtCode.HideSelection = false; + this.txtCode.AutoCompleteBracketsList = new char[] { + '(', + ')', + '{', + '}', + '[', + ']', + '\"', + '\"', + '\'', + '\''}; + this.txtCode.AutoIndentChars = false; + this.txtCode.AutoIndentExistingLines = false; + this.txtCode.AutoScrollMinSize = new System.Drawing.Size(43, 14); + this.txtCode.BackBrush = null; + this.txtCode.CharHeight = 14; + this.txtCode.CharWidth = 8; + this.txtCode.CurrentLineColor = System.Drawing.Color.Gainsboro; + this.txtCode.Cursor = System.Windows.Forms.Cursors.IBeam; + this.txtCode.DisabledColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(180)))), ((int)(((byte)(180)))), ((int)(((byte)(180))))); + this.txtCode.Dock = System.Windows.Forms.DockStyle.Fill; + this.txtCode.IsReplaceMode = false; this.txtCode.Location = new System.Drawing.Point(1, 1); this.txtCode.Name = "txtCode"; - this.txtCode.Size = new System.Drawing.Size(371, 368); - this.txtCode.TabIndex = 4; - this.txtCode.Text = ""; - this.txtCode.WordWrap = false; - this.txtCode.SelectionChanged += new System.EventHandler(this.txtCode_SelectionChanged); - this.txtCode.TextChanged += new System.EventHandler(this.txtCode_TextChanged); - this.txtCode.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtCode_KeyDown); - // - // statCode - // - this.statCode.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripStatusLabel1, - this.lblLineNumber}); - this.statCode.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Flow; - this.statCode.Location = new System.Drawing.Point(1, 370); - this.statCode.Name = "statCode"; - this.statCode.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; - this.statCode.Size = new System.Drawing.Size(371, 20); - this.statCode.SizingGrip = false; - this.statCode.TabIndex = 5; - // - // toolStripStatusLabel1 - // - this.toolStripStatusLabel1.BackColor = System.Drawing.SystemColors.Control; - this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; - this.toolStripStatusLabel1.Size = new System.Drawing.Size(32, 15); - this.toolStripStatusLabel1.Text = "Line:"; - // - // lblLineNumber - // - this.lblLineNumber.BackColor = System.Drawing.SystemColors.Control; - this.lblLineNumber.Name = "lblLineNumber"; - this.lblLineNumber.Size = new System.Drawing.Size(13, 15); - this.lblLineNumber.Text = "1"; + this.txtCode.Paddings = new System.Windows.Forms.Padding(0); + this.txtCode.ReservedCountOfLineNumberChars = 3; + this.txtCode.SelectionColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(255))))); + this.txtCode.Size = new System.Drawing.Size(361, 272); + this.txtCode.TabIndex = 6; + this.txtCode.Zoom = 100; + this.txtCode.TextChanged += new System.EventHandler(this.txtCode_TextChanged); // // groupBox2 // this.groupBox2.Controls.Add(this.ctrlHexBox); this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox2.Location = new System.Drawing.Point(388, 3); + this.groupBox2.Location = new System.Drawing.Point(378, 3); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(444, 410); + this.groupBox2.Size = new System.Drawing.Size(454, 293); this.groupBox2.TabIndex = 5; this.groupBox2.TabStop = false; this.groupBox2.Text = "Assembled Byte Code"; @@ -367,18 +364,117 @@ this.ctrlHexBox.Name = "ctrlHexBox"; this.ctrlHexBox.ReadOnly = true; this.ctrlHexBox.ShadowSelectionColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(60)))), ((int)(((byte)(188)))), ((int)(((byte)(255))))); - this.ctrlHexBox.Size = new System.Drawing.Size(438, 391); + this.ctrlHexBox.Size = new System.Drawing.Size(448, 274); this.ctrlHexBox.TabIndex = 1; this.ctrlHexBox.UseFixedBytesPerLine = true; this.ctrlHexBox.VScrollBarVisible = true; // + // menuStrip1 + // + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.fileToolStripMenuItem, + this.viewToolStripMenuItem}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(835, 24); + this.menuStrip1.TabIndex = 3; + this.menuStrip1.Text = "menuStrip1"; + // + // fileToolStripMenuItem + // + this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.mnuClose}); + this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; + this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); + this.fileToolStripMenuItem.Text = "File"; + // + // mnuClose + // + this.mnuClose.Image = global::Mesen.GUI.Properties.Resources.Exit; + this.mnuClose.Name = "mnuClose"; + this.mnuClose.Size = new System.Drawing.Size(103, 22); + this.mnuClose.Text = "Close"; + this.mnuClose.Click += new System.EventHandler(this.mnuClose_Click); + // + // viewToolStripMenuItem + // + this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.fontSizeToolStripMenuItem, + this.mnuConfigureColors, + this.toolStripMenuItem1, + this.mnuEnableSyntaxHighlighting}); + this.viewToolStripMenuItem.Name = "viewToolStripMenuItem"; + this.viewToolStripMenuItem.Size = new System.Drawing.Size(44, 20); + this.viewToolStripMenuItem.Text = "View"; + // + // fontSizeToolStripMenuItem + // + this.fontSizeToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.mnuIncreaseFontSize, + this.mnuDecreaseFontSize, + this.mnuResetFontSize}); + this.fontSizeToolStripMenuItem.Image = global::Mesen.GUI.Properties.Resources.Font; + this.fontSizeToolStripMenuItem.Name = "fontSizeToolStripMenuItem"; + this.fontSizeToolStripMenuItem.Size = new System.Drawing.Size(216, 22); + this.fontSizeToolStripMenuItem.Text = "Text Size"; + // + // mnuIncreaseFontSize + // + this.mnuIncreaseFontSize.Name = "mnuIncreaseFontSize"; + this.mnuIncreaseFontSize.ShortcutKeyDisplayString = "Ctrl++"; + this.mnuIncreaseFontSize.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Oemplus))); + this.mnuIncreaseFontSize.Size = new System.Drawing.Size(197, 22); + this.mnuIncreaseFontSize.Text = "Increase"; + this.mnuIncreaseFontSize.Click += new System.EventHandler(this.mnuIncreaseFontSize_Click); + // + // mnuDecreaseFontSize + // + this.mnuDecreaseFontSize.Name = "mnuDecreaseFontSize"; + this.mnuDecreaseFontSize.ShortcutKeyDisplayString = "Ctrl+-"; + this.mnuDecreaseFontSize.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.OemMinus))); + this.mnuDecreaseFontSize.Size = new System.Drawing.Size(197, 22); + this.mnuDecreaseFontSize.Text = "Decrease"; + this.mnuDecreaseFontSize.Click += new System.EventHandler(this.mnuDecreaseFontSize_Click); + // + // mnuResetFontSize + // + this.mnuResetFontSize.Name = "mnuResetFontSize"; + this.mnuResetFontSize.ShortcutKeyDisplayString = "Ctrl+0"; + this.mnuResetFontSize.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.D0))); + this.mnuResetFontSize.Size = new System.Drawing.Size(197, 22); + this.mnuResetFontSize.Text = "Reset to Default"; + this.mnuResetFontSize.Click += new System.EventHandler(this.mnuResetFontSize_Click); + // + // mnuConfigureColors + // + this.mnuConfigureColors.Image = global::Mesen.GUI.Properties.Resources.PipetteSmall; + this.mnuConfigureColors.Name = "mnuConfigureColors"; + this.mnuConfigureColors.Size = new System.Drawing.Size(216, 22); + this.mnuConfigureColors.Text = "Configure Colors"; + this.mnuConfigureColors.Click += new System.EventHandler(this.mnuConfigureColors_Click); + // + // toolStripMenuItem1 + // + this.toolStripMenuItem1.Name = "toolStripMenuItem1"; + this.toolStripMenuItem1.Size = new System.Drawing.Size(213, 6); + // + // mnuEnableSyntaxHighlighting + // + this.mnuEnableSyntaxHighlighting.CheckOnClick = true; + this.mnuEnableSyntaxHighlighting.Name = "mnuEnableSyntaxHighlighting"; + this.mnuEnableSyntaxHighlighting.Size = new System.Drawing.Size(216, 22); + this.mnuEnableSyntaxHighlighting.Text = "Enable Syntax Highlighting"; + this.mnuEnableSyntaxHighlighting.CheckedChanged += new System.EventHandler(this.mnuEnableSyntaxHighlighting_CheckedChanged); + // // frmAssembler // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.btnCancel; - this.ClientSize = new System.Drawing.Size(835, 557); + this.ClientSize = new System.Drawing.Size(835, 464); this.Controls.Add(this.tableLayoutPanel1); + this.Controls.Add(this.menuStrip1); + this.MainMenuStrip = this.menuStrip1; this.MinimumSize = new System.Drawing.Size(851, 502); this.Name = "frmAssembler"; this.Text = "Assembler"; @@ -395,11 +491,12 @@ this.flowLayoutPanel3.PerformLayout(); this.groupBox1.ResumeLayout(false); this.panel1.ResumeLayout(false); - this.panel1.PerformLayout(); - this.statCode.ResumeLayout(false); - this.statCode.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.txtCode)).EndInit(); this.groupBox2.ResumeLayout(false); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); this.ResumeLayout(false); + this.PerformLayout(); } @@ -419,15 +516,23 @@ private System.Windows.Forms.Button btnCancel; private System.Windows.Forms.Button btnOk; private System.Windows.Forms.PictureBox picSizeWarning; - private ZoomlessRichTextBox txtCode; private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Label lblNoChanges; - private System.Windows.Forms.StatusStrip statCode; - private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; - private System.Windows.Forms.ToolStripStatusLabel lblLineNumber; private System.Windows.Forms.PictureBox picStartAddressWarning; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.Button btnExecute; + private FastColoredTextBoxNS.FastColoredTextBox txtCode; + private System.Windows.Forms.MenuStrip menuStrip1; + private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem mnuClose; + private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem mnuEnableSyntaxHighlighting; + private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem mnuConfigureColors; + private System.Windows.Forms.ToolStripMenuItem fontSizeToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem mnuIncreaseFontSize; + private System.Windows.Forms.ToolStripMenuItem mnuDecreaseFontSize; + private System.Windows.Forms.ToolStripMenuItem mnuResetFontSize; } } \ No newline at end of file diff --git a/GUI.NET/Debugger/frmAssembler.cs b/GUI.NET/Debugger/frmAssembler.cs index 6e42579a..09f37e24 100644 --- a/GUI.NET/Debugger/frmAssembler.cs +++ b/GUI.NET/Debugger/frmAssembler.cs @@ -9,6 +9,8 @@ using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows.Forms; using Be.Windows.Forms; +using FastColoredTextBoxNS; +using Mesen.GUI.Config; using Mesen.GUI.Controls; using Mesen.GUI.Forms; @@ -27,6 +29,16 @@ namespace Mesen.GUI.Debugger { InitializeComponent(); + if(!ConfigManager.Config.DebugInfo.AssemblerSize.IsEmpty) { + this.Size = ConfigManager.Config.DebugInfo.AssemblerSize; + } + mnuEnableSyntaxHighlighting.Checked = ConfigManager.Config.DebugInfo.AssemblerCodeHighlighting; + + txtCode.Font = new Font(BaseControl.MonospaceFontFamily, 10); + txtCode.Zoom = ConfigManager.Config.DebugInfo.AssemblerZoom; + + UpdateCodeHighlighting(); + if(!string.IsNullOrWhiteSpace(code)) { _isEditMode = true; _containedRtiRts = ContainsRtiOrRts(code); @@ -35,7 +47,6 @@ namespace Mesen.GUI.Debugger _startAddress = startAddress; _blockLength = blockLength; - txtCode.Font = new Font(BaseControl.MonospaceFontFamily, 10); ctrlHexBox.Font = new Font(BaseControl.MonospaceFontFamily, 10, FontStyle.Regular); ctrlHexBox.SelectionForeColor = Color.White; ctrlHexBox.SelectionBackColor = Color.FromArgb(31, 123, 205); @@ -46,7 +57,6 @@ namespace Mesen.GUI.Debugger txtStartAddress.Text = _startAddress.ToString("X4"); txtCode.Text = code; - txtCode.Select(0, 0); toolTip.SetToolTip(picSizeWarning, "Warning: The new code exceeds the original code's length." + Environment.NewLine + "Applying this modification will overwrite other portions of the code and potentially cause problems."); toolTip.SetToolTip(picStartAddressWarning, "Warning: Start address is invalid. Must be a valid hexadecimal string."); @@ -54,6 +64,32 @@ namespace Mesen.GUI.Debugger UpdateWindow(); } + private void UpdateCodeHighlighting() + { + if(txtCode.SyntaxDescriptor != null) { + SyntaxDescriptor desc = txtCode.SyntaxDescriptor; + txtCode.SyntaxDescriptor = null; + txtCode.ClearStylesBuffer(); + desc.Dispose(); + } + + if(mnuEnableSyntaxHighlighting.Checked) { + SyntaxDescriptor syntax = new SyntaxDescriptor(); + syntax.styles.Add(new TextStyle(new SolidBrush(ConfigManager.Config.DebugInfo.AssemblerOpcodeColor), Brushes.Transparent, FontStyle.Regular)); + syntax.styles.Add(new TextStyle(new SolidBrush(ConfigManager.Config.DebugInfo.AssemblerLabelDefinitionColor), Brushes.Transparent, FontStyle.Regular)); + syntax.styles.Add(new TextStyle(new SolidBrush(ConfigManager.Config.DebugInfo.AssemblerImmediateColor), Brushes.Transparent, FontStyle.Regular)); + syntax.styles.Add(new TextStyle(new SolidBrush(ConfigManager.Config.DebugInfo.AssemblerAddressColor), Brushes.Transparent, FontStyle.Regular)); + syntax.styles.Add(new TextStyle(new SolidBrush(ConfigManager.Config.DebugInfo.AssemblerCommentColor), Brushes.Transparent, FontStyle.Regular)); + syntax.rules.Add(new RuleDesc() { style = syntax.styles[0], pattern = @"^[ \t]*(?[a-zA-Z]{3}[*]{0,1})( |[^:a-zA-Z])", options = RegexOptions.Multiline }); + syntax.rules.Add(new RuleDesc() { style = syntax.styles[1], pattern = @"^[ \t]*(?[a-zA-Z_]*):", options = RegexOptions.Multiline }); + syntax.rules.Add(new RuleDesc() { style = syntax.styles[2], pattern = @"^[ \t]*[a-zA-Z]{3}[*]{0,1}[ \t]+(?#[$]{0,1}([A-Fa-f0-9])+)", options = RegexOptions.Multiline }); + syntax.rules.Add(new RuleDesc() { style = syntax.styles[3], pattern = @"^[ \t]*[a-zA-Z]{3}[*]{0,1}[ \t]+[(]{0,1}(?[$]{0,1}[A-Fa-f0-9]+)[)]{0,1}[ \t]*(,X|,Y|,x|,y){0,1}[)]{0,1}", options = RegexOptions.Multiline }); + syntax.rules.Add(new RuleDesc() { style = syntax.styles[4], pattern = @"^[^;]*(?;.*)", options = RegexOptions.Multiline }); + txtCode.SyntaxDescriptor = syntax; + txtCode.OnTextChanged(); + } + } + private bool ContainsRtiOrRts(string code) { return Regex.IsMatch(code, "^\\s*(RTI|RTS)", RegexOptions.IgnoreCase | RegexOptions.Multiline); @@ -148,25 +184,12 @@ namespace Mesen.GUI.Debugger picStartAddressWarning.Visible = !_startAddressValid; } - - private void txtCode_TextChanged(object sender, EventArgs e) + + private void txtCode_TextChanged(object sender, FastColoredTextBoxNS.TextChangedEventArgs e) { UpdateWindow(); } - private void txtCode_KeyDown(object sender, KeyEventArgs e) - { - if(e.Control && e.KeyCode == Keys.V || e.Shift && e.KeyCode == Keys.Insert) { - txtCode.Paste(DataFormats.GetFormat("Text")); - e.Handled = true; - } - } - - private void txtCode_SelectionChanged(object sender, EventArgs e) - { - lblLineNumber.Text = (txtCode.GetLineFromCharIndex(txtCode.GetFirstCharIndexOfCurrentLine()) + 1).ToString(); - } - private void txtStartAddress_TextChanged(object sender, EventArgs e) { try { @@ -265,6 +288,49 @@ namespace Mesen.GUI.Debugger this.Close(); } + protected override void OnClosing(CancelEventArgs e) + { + base.OnClosing(e); + ConfigManager.Config.DebugInfo.AssemblerSize = this.WindowState == FormWindowState.Maximized ? this.RestoreBounds.Size : this.Size; + ConfigManager.Config.DebugInfo.AssemblerCodeHighlighting = mnuEnableSyntaxHighlighting.Checked; + ConfigManager.Config.DebugInfo.AssemblerZoom = txtCode.Zoom; + ConfigManager.ApplyChanges(); + } + + private void mnuClose_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void mnuConfigureColors_Click(object sender, EventArgs e) + { + using(frmAssemblerColors frm = new frmAssemblerColors()) { + if(frm.ShowDialog() == DialogResult.OK) { + UpdateCodeHighlighting(); + } + } + } + + private void mnuEnableSyntaxHighlighting_CheckedChanged(object sender, EventArgs e) + { + UpdateCodeHighlighting(); + } + + private void mnuIncreaseFontSize_Click(object sender, EventArgs e) + { + txtCode.ChangeFontSize(2); + } + + private void mnuDecreaseFontSize_Click(object sender, EventArgs e) + { + txtCode.ChangeFontSize(-2); + } + + private void mnuResetFontSize_Click(object sender, EventArgs e) + { + txtCode.RestoreFontSize(); + } + enum AssemblerSpecialCodes { OK = 0, @@ -285,13 +351,9 @@ namespace Mesen.GUI.Debugger { if(lstErrors.SelectedItem != null) { int lineNumber = (lstErrors.SelectedItem as ErrorDetail).LineNumber; - int scrollIndex = txtCode.GetFirstCharIndexFromLine(Math.Max(0, lineNumber-1-txtCode.NumberOfVisibleLines/2)); - txtCode.SelectionStart = scrollIndex + 2; - txtCode.ScrollToCaret(); - - int errorIndex = txtCode.GetFirstCharIndexFromLine(lineNumber-1); - txtCode.SelectionStart = errorIndex + 2; - + txtCode.Selection = txtCode.GetLine(lineNumber - 1); + txtCode.SelectionLength = 0; + txtCode.DoCaretVisible(); txtCode.Focus(); } } diff --git a/GUI.NET/Debugger/frmAssembler.resx b/GUI.NET/Debugger/frmAssembler.resx index fdf1f8cc..e83821e0 100644 --- a/GUI.NET/Debugger/frmAssembler.resx +++ b/GUI.NET/Debugger/frmAssembler.resx @@ -120,10 +120,7 @@ 17, 17 - - 107, 17 - - + 107, 17 \ No newline at end of file diff --git a/GUI.NET/Debugger/frmAssemblerColors.Designer.cs b/GUI.NET/Debugger/frmAssemblerColors.Designer.cs new file mode 100644 index 00000000..97687206 --- /dev/null +++ b/GUI.NET/Debugger/frmAssemblerColors.Designer.cs @@ -0,0 +1,222 @@ +namespace Mesen.GUI.Debugger +{ + partial class frmAssemblerColors + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if(disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.picComment = new System.Windows.Forms.PictureBox(); + this.picAddress = new System.Windows.Forms.PictureBox(); + this.picImmediate = new System.Windows.Forms.PictureBox(); + this.picLabelDefinition = new System.Windows.Forms.PictureBox(); + this.lblImmediate = new System.Windows.Forms.Label(); + this.lblLabelDefinition = new System.Windows.Forms.Label(); + this.lblOpcode = new System.Windows.Forms.Label(); + this.lblAddress = new System.Windows.Forms.Label(); + this.lblComment = new System.Windows.Forms.Label(); + this.picOpcode = new System.Windows.Forms.PictureBox(); + this.tableLayoutPanel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.picComment)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.picAddress)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.picImmediate)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.picLabelDefinition)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.picOpcode)).BeginInit(); + this.SuspendLayout(); + // + // baseConfigPanel + // + this.baseConfigPanel.Location = new System.Drawing.Point(0, 210); + this.baseConfigPanel.Size = new System.Drawing.Size(238, 29); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 2; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.Controls.Add(this.picComment, 1, 4); + this.tableLayoutPanel1.Controls.Add(this.picAddress, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.picImmediate, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.picLabelDefinition, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.lblImmediate, 0, 2); + this.tableLayoutPanel1.Controls.Add(this.lblLabelDefinition, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.lblOpcode, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.lblAddress, 0, 3); + this.tableLayoutPanel1.Controls.Add(this.lblComment, 0, 4); + this.tableLayoutPanel1.Controls.Add(this.picOpcode, 1, 0); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 6; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(238, 210); + this.tableLayoutPanel1.TabIndex = 2; + // + // picComment + // + this.picComment.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.picComment.Cursor = System.Windows.Forms.Cursors.Hand; + this.picComment.Location = new System.Drawing.Point(97, 155); + this.picComment.Name = "picComment"; + this.picComment.Size = new System.Drawing.Size(32, 32); + this.picComment.TabIndex = 9; + this.picComment.TabStop = false; + this.picComment.Click += new System.EventHandler(this.picColorPicker_Click); + // + // picAddress + // + this.picAddress.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.picAddress.Cursor = System.Windows.Forms.Cursors.Hand; + this.picAddress.Location = new System.Drawing.Point(97, 117); + this.picAddress.Name = "picAddress"; + this.picAddress.Size = new System.Drawing.Size(32, 32); + this.picAddress.TabIndex = 8; + this.picAddress.TabStop = false; + this.picAddress.Click += new System.EventHandler(this.picColorPicker_Click); + // + // picImmediate + // + this.picImmediate.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.picImmediate.Cursor = System.Windows.Forms.Cursors.Hand; + this.picImmediate.Location = new System.Drawing.Point(97, 79); + this.picImmediate.Name = "picImmediate"; + this.picImmediate.Size = new System.Drawing.Size(32, 32); + this.picImmediate.TabIndex = 7; + this.picImmediate.TabStop = false; + this.picImmediate.Click += new System.EventHandler(this.picColorPicker_Click); + // + // picLabelDefinition + // + this.picLabelDefinition.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.picLabelDefinition.Cursor = System.Windows.Forms.Cursors.Hand; + this.picLabelDefinition.Location = new System.Drawing.Point(97, 41); + this.picLabelDefinition.Name = "picLabelDefinition"; + this.picLabelDefinition.Size = new System.Drawing.Size(32, 32); + this.picLabelDefinition.TabIndex = 6; + this.picLabelDefinition.TabStop = false; + this.picLabelDefinition.Click += new System.EventHandler(this.picColorPicker_Click); + // + // lblImmediate + // + this.lblImmediate.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lblImmediate.AutoSize = true; + this.lblImmediate.Location = new System.Drawing.Point(3, 88); + this.lblImmediate.Name = "lblImmediate"; + this.lblImmediate.Size = new System.Drawing.Size(88, 13); + this.lblImmediate.TabIndex = 4; + this.lblImmediate.Text = "Immediate Value:"; + // + // lblLabelDefinition + // + this.lblLabelDefinition.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lblLabelDefinition.AutoSize = true; + this.lblLabelDefinition.Location = new System.Drawing.Point(3, 50); + this.lblLabelDefinition.Name = "lblLabelDefinition"; + this.lblLabelDefinition.Size = new System.Drawing.Size(83, 13); + this.lblLabelDefinition.TabIndex = 2; + this.lblLabelDefinition.Text = "Label Definition:"; + // + // lblOpcode + // + this.lblOpcode.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lblOpcode.AutoSize = true; + this.lblOpcode.Location = new System.Drawing.Point(3, 12); + this.lblOpcode.Name = "lblOpcode"; + this.lblOpcode.Size = new System.Drawing.Size(48, 13); + this.lblOpcode.TabIndex = 0; + this.lblOpcode.Text = "Opcode:"; + // + // lblAddress + // + this.lblAddress.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lblAddress.AutoSize = true; + this.lblAddress.Location = new System.Drawing.Point(3, 126); + this.lblAddress.Name = "lblAddress"; + this.lblAddress.Size = new System.Drawing.Size(77, 13); + this.lblAddress.TabIndex = 3; + this.lblAddress.Text = "Address value:"; + // + // lblComment + // + this.lblComment.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lblComment.AutoSize = true; + this.lblComment.Location = new System.Drawing.Point(3, 164); + this.lblComment.Name = "lblComment"; + this.lblComment.Size = new System.Drawing.Size(51, 13); + this.lblComment.TabIndex = 1; + this.lblComment.Text = "Comment"; + // + // picOpcode + // + this.picOpcode.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.picOpcode.Cursor = System.Windows.Forms.Cursors.Hand; + this.picOpcode.Location = new System.Drawing.Point(97, 3); + this.picOpcode.Name = "picOpcode"; + this.picOpcode.Size = new System.Drawing.Size(32, 32); + this.picOpcode.TabIndex = 5; + this.picOpcode.TabStop = false; + this.picOpcode.Click += new System.EventHandler(this.picColorPicker_Click); + // + // frmAssemblerColors + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(238, 239); + this.Controls.Add(this.tableLayoutPanel1); + this.Name = "frmAssemblerColors"; + this.Text = "Configure Colors..."; + this.Controls.SetChildIndex(this.baseConfigPanel, 0); + this.Controls.SetChildIndex(this.tableLayoutPanel1, 0); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.picComment)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.picAddress)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.picImmediate)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.picLabelDefinition)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.picOpcode)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label lblImmediate; + private System.Windows.Forms.Label lblLabelDefinition; + private System.Windows.Forms.Label lblOpcode; + private System.Windows.Forms.Label lblAddress; + private System.Windows.Forms.Label lblComment; + private System.Windows.Forms.PictureBox picComment; + private System.Windows.Forms.PictureBox picAddress; + private System.Windows.Forms.PictureBox picImmediate; + private System.Windows.Forms.PictureBox picLabelDefinition; + private System.Windows.Forms.PictureBox picOpcode; + } +} \ No newline at end of file diff --git a/GUI.NET/Debugger/frmAssemblerColors.cs b/GUI.NET/Debugger/frmAssemblerColors.cs new file mode 100644 index 00000000..9dedab85 --- /dev/null +++ b/GUI.NET/Debugger/frmAssemblerColors.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Mesen.GUI.Config; +using Mesen.GUI.Forms; + +namespace Mesen.GUI.Debugger +{ + public partial class frmAssemblerColors : BaseConfigForm + { + public frmAssemblerColors() + { + InitializeComponent(); + + picOpcode.BackColor = ConfigManager.Config.DebugInfo.AssemblerOpcodeColor; + picLabelDefinition.BackColor = ConfigManager.Config.DebugInfo.AssemblerLabelDefinitionColor; + picImmediate.BackColor = ConfigManager.Config.DebugInfo.AssemblerImmediateColor; + picAddress.BackColor = ConfigManager.Config.DebugInfo.AssemblerAddressColor; + picComment.BackColor = ConfigManager.Config.DebugInfo.AssemblerCommentColor; + } + + private void picColorPicker_Click(object sender, EventArgs e) + { + using(ColorDialog cd = new ColorDialog()) { + cd.SolidColorOnly = true; + cd.AllowFullOpen = true; + cd.FullOpen = true; + cd.Color = ((PictureBox)sender).BackColor; + if(cd.ShowDialog() == DialogResult.OK) { + ((PictureBox)sender).BackColor = cd.Color; + } + } + } + + protected override void OnFormClosing(FormClosingEventArgs e) + { + base.OnFormClosing(e); + if(DialogResult == DialogResult.OK) { + ConfigManager.Config.DebugInfo.AssemblerOpcodeColor = picOpcode.BackColor; + ConfigManager.Config.DebugInfo.AssemblerLabelDefinitionColor = picLabelDefinition.BackColor; + ConfigManager.Config.DebugInfo.AssemblerImmediateColor = picImmediate.BackColor; + ConfigManager.Config.DebugInfo.AssemblerAddressColor = picAddress.BackColor; + ConfigManager.Config.DebugInfo.AssemblerCommentColor = picComment.BackColor; + ConfigManager.ApplyChanges(); + } + } + } +} diff --git a/GUI.NET/Debugger/frmAssemblerColors.resx b/GUI.NET/Debugger/frmAssemblerColors.resx new file mode 100644 index 00000000..8766f298 --- /dev/null +++ b/GUI.NET/Debugger/frmAssemblerColors.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/GUI.NET/Debugger/frmScript.Designer.cs b/GUI.NET/Debugger/frmScript.Designer.cs index 18766e3d..bb8d0159 100644 --- a/GUI.NET/Debugger/frmScript.Designer.cs +++ b/GUI.NET/Debugger/frmScript.Designer.cs @@ -32,12 +32,12 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmScript)); this.mnuMain = new System.Windows.Forms.MenuStrip(); this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.mnuNewScript = new System.Windows.Forms.ToolStripMenuItem(); this.mnuOpen = new System.Windows.Forms.ToolStripMenuItem(); this.mnuSave = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuSaveAs = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator(); this.mnuRecentScripts = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator(); @@ -72,7 +72,6 @@ this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); this.lblScriptActive = new System.Windows.Forms.ToolStripStatusLabel(); - this.mnuSaveAs = new System.Windows.Forms.ToolStripMenuItem(); this.mnuMain.SuspendLayout(); this.toolStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.txtScriptContent)).BeginInit(); @@ -109,7 +108,7 @@ this.mnuClose}); this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); - this.fileToolStripMenuItem.Text = "&File"; + this.fileToolStripMenuItem.Text = "File"; // // mnuNewScript // @@ -138,6 +137,13 @@ this.mnuSave.Text = "Save"; this.mnuSave.Click += new System.EventHandler(this.btnSave_Click); // + // mnuSaveAs + // + this.mnuSaveAs.Name = "mnuSaveAs"; + this.mnuSaveAs.Size = new System.Drawing.Size(221, 22); + this.mnuSaveAs.Text = "Save as..."; + this.mnuSaveAs.Click += new System.EventHandler(this.mnuSaveAs_Click); + // // toolStripMenuItem1 // this.toolStripMenuItem1.Name = "toolStripMenuItem1"; @@ -170,7 +176,7 @@ this.mnuShowLogWindow}); this.mnuView.Name = "mnuView"; this.mnuView.Size = new System.Drawing.Size(44, 20); - this.mnuView.Text = "&View"; + this.mnuView.Text = "View"; this.mnuView.DropDownOpening += new System.EventHandler(this.mnuView_DropDownOpening); // // fontSizeToolStripMenuItem @@ -234,7 +240,7 @@ this.mnuAutoReload}); this.scriptToolStripMenuItem.Name = "scriptToolStripMenuItem"; this.scriptToolStripMenuItem.Size = new System.Drawing.Size(49, 20); - this.scriptToolStripMenuItem.Text = "&Script"; + this.scriptToolStripMenuItem.Text = "Script"; // // mnuRun // @@ -347,6 +353,7 @@ '\"', '\'', '\''}; + this.txtScriptContent.AutoIndentChars = false; this.txtScriptContent.AutoIndentCharsPatterns = "\n^\\s*[\\w\\.]+(\\s\\w+)?\\s*(?=)\\s*(?.+)\n"; this.txtScriptContent.AutoIndentExistingLines = false; this.txtScriptContent.AutoScrollMinSize = new System.Drawing.Size(43, 14); @@ -356,7 +363,7 @@ this.txtScriptContent.CharWidth = 8; this.txtScriptContent.CommentPrefix = "--"; this.txtScriptContent.ContextMenuStrip = this.contextMenu; - this.txtScriptContent.CurrentLineColor = System.Drawing.Color.WhiteSmoke; + this.txtScriptContent.CurrentLineColor = System.Drawing.Color.Gainsboro; this.txtScriptContent.Cursor = System.Windows.Forms.Cursors.IBeam; this.txtScriptContent.DisabledColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(180)))), ((int)(((byte)(180)))), ((int)(((byte)(180))))); this.txtScriptContent.Dock = System.Windows.Forms.DockStyle.Fill; @@ -475,13 +482,6 @@ this.lblScriptActive.Text = "Script is running"; this.lblScriptActive.Visible = false; // - // mnuSaveAs - // - this.mnuSaveAs.Name = "mnuSaveAs"; - this.mnuSaveAs.Size = new System.Drawing.Size(221, 22); - this.mnuSaveAs.Text = "Save as..."; - this.mnuSaveAs.Click += new System.EventHandler(this.mnuSaveAs_Click); - // // frmScript // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); diff --git a/GUI.NET/Debugger/frmScript.cs b/GUI.NET/Debugger/frmScript.cs index 5e08197c..c630a907 100644 --- a/GUI.NET/Debugger/frmScript.cs +++ b/GUI.NET/Debugger/frmScript.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using System.Windows.Forms; using FastColoredTextBoxNS; using Mesen.GUI.Config; +using Mesen.GUI.Controls; using Mesen.GUI.Forms; using Mesen.GUI.Properties; @@ -77,6 +78,7 @@ namespace Mesen.GUI.Debugger ctrlSplit.SplitterDistance = ConfigManager.Config.DebugInfo.ScriptCodeWindowHeight; } } + txtScriptContent.Font = new Font(BaseControl.MonospaceFontFamily, 10); txtScriptContent.Zoom = ConfigManager.Config.DebugInfo.ScriptZoom; if(!this.DesignMode) { @@ -106,7 +108,7 @@ namespace Mesen.GUI.Debugger if(_scriptId >= 0) { InteropEmu.DebugRemoveScript(_scriptId); } - ConfigManager.Config.DebugInfo.ScriptWindowSize = this.Size; + ConfigManager.Config.DebugInfo.ScriptWindowSize = this.WindowState == FormWindowState.Maximized ? this.RestoreBounds.Size : this.Size; ConfigManager.Config.DebugInfo.SaveScriptBeforeRun = mnuSaveBeforeRun.Checked; ConfigManager.Config.DebugInfo.AutoReloadScript = mnuAutoReload.Checked; ConfigManager.Config.DebugInfo.ScriptCodeWindowHeight = ctrlSplit.Panel2.Height <= 2 ? Int32.MaxValue : ctrlSplit.SplitterDistance; diff --git a/GUI.NET/GUI.NET.csproj b/GUI.NET/GUI.NET.csproj index 370c5a2c..0b281b96 100644 --- a/GUI.NET/GUI.NET.csproj +++ b/GUI.NET/GUI.NET.csproj @@ -478,6 +478,12 @@ frmAssembler.cs + + Form + + + frmAssemblerColors.cs + Form @@ -834,6 +840,7 @@ + @@ -944,6 +951,9 @@ frmAssembler.cs + + frmAssemblerColors.cs + frmCodeTooltip.cs diff --git a/GUI.NET/Properties/Resources.Designer.cs b/GUI.NET/Properties/Resources.Designer.cs index edfe8513..dafe8a83 100644 --- a/GUI.NET/Properties/Resources.Designer.cs +++ b/GUI.NET/Properties/Resources.Designer.cs @@ -550,6 +550,16 @@ namespace Mesen.GUI.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap PipetteSmall { + get { + object obj = ResourceManager.GetObject("PipetteSmall", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/GUI.NET/Properties/Resources.resx b/GUI.NET/Properties/Resources.resx index 10648711..274f6c25 100644 --- a/GUI.NET/Properties/Resources.resx +++ b/GUI.NET/Properties/Resources.resx @@ -346,4 +346,7 @@ ..\Resources\Enum.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\PipetteSmall.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/GUI.NET/Resources/PipetteSmall.png b/GUI.NET/Resources/PipetteSmall.png new file mode 100644 index 00000000..f621ff97 Binary files /dev/null and b/GUI.NET/Resources/PipetteSmall.png differ