diff --git a/C64Models/Parser/BasicFileParser.cs b/C64Models/Parser/BasicFileParser.cs index e9c6fec0..8dc610bf 100644 --- a/C64Models/Parser/BasicFileParser.cs +++ b/C64Models/Parser/BasicFileParser.cs @@ -2651,7 +2651,8 @@ public string EncodeToLabels() lineLengthOffset = lineInfo.Value.Tokens[1].StartIndex; } - if ( lineNumberReference.ContainsKey( lineInfo.Value.LineNumber ) ) + if ( ( lineNumberReference.ContainsKey( lineInfo.Value.LineNumber ) ) + && ( lineInfo.Value.Tokens[0].TokenType != Token.Type.HARD_COMMENT ) ) { // something is referencing this line sb.AppendLine(); @@ -2817,12 +2818,14 @@ private int FindNextToken( List Tokens, int StartIndex ) - public string DecodeFromLabels() + public string DecodeFromLabels( int StartLineNumber = 10, int LineStep = 10 ) { StringBuilder sb = new StringBuilder(); GR.Collections.Map labelToNumber = new GR.Collections.Map(); - int lineNumber = 10; + int startLineNumber = StartLineNumber; + int lineNumberStep = LineStep; + int lineNumber = startLineNumber; // collect labels foreach ( KeyValuePair lineInfo in m_LineInfos ) @@ -2852,9 +2855,9 @@ public string DecodeFromLabels() } continue; } - lineNumber += 10; + lineNumber += lineNumberStep; } - lineNumber = 10; + lineNumber = startLineNumber; foreach ( KeyValuePair lineInfo in m_LineInfos ) { if ( ( lineInfo.Value.Tokens.Count == 1 ) @@ -2993,7 +2996,7 @@ public string DecodeFromLabels() } } sb.Append( "\r\n" ); - lineNumber += 10; + lineNumber += lineNumberStep; } return sb.ToString(); } diff --git a/C64Studio/C64Studio.csproj b/C64Studio/C64Studio.csproj index e191a372..fe5f96e1 100644 --- a/C64Studio/C64Studio.csproj +++ b/C64Studio/C64Studio.csproj @@ -223,6 +223,9 @@ Form + + Form + UserControl diff --git a/C64Studio/Controls/MenuButton.cs b/C64Studio/Controls/MenuButton.cs index 41d78a93..183d213c 100644 --- a/C64Studio/Controls/MenuButton.cs +++ b/C64Studio/Controls/MenuButton.cs @@ -4,6 +4,7 @@ using System.ComponentModel; using System.Windows.Forms; using System.Drawing; +using System.Drawing.Drawing2D; namespace RetroDevStudio.Controls { @@ -18,22 +19,64 @@ public ContextMenuStrip Menu + [DefaultValue( true )] + public bool ShowDropDownArrow { get; set; } + + [DefaultValue( false )] + public bool ShowSplitBar { get; set; } + + [DefaultValue( false )] + public bool Checked { get; set; } + + + + public event EventHandler CheckedChanged; + + + protected override void OnMouseDown( MouseEventArgs mevent ) { base.OnMouseDown( mevent ); + bool hitMenu = false; + int lineX = ClientRectangle.Width - 18; + int menuShowX = 0; + + if ( ShowSplitBar ) + { + if ( mevent.X >= lineX ) + { + hitMenu = true; + menuShowX = lineX; + } + } + else + { + hitMenu = true; + } + + + if ( ( Menu != null ) + && ( hitMenu ) && ( mevent.Button == MouseButtons.Left ) ) { - System.Drawing.Point ptMenu = new Point( 0, Height ); - + System.Drawing.Point ptMenu = new Point( menuShowX, Height ); if ( ptMenu.Y + Menu.Height >= Screen.FromControl( this ).WorkingArea.Height ) { - ptMenu = PointToScreen( new Point( 0, -Menu.Height ) ); + ptMenu = PointToScreen( new Point( menuShowX, -Menu.Height ) ); } Menu.Show( this, ptMenu ); } + else + { + if ( CheckedChanged != null ) + { + CheckedChanged( this, new EventArgs() ); + } + OnClick( new EventArgs() ); + } } @@ -45,9 +88,27 @@ protected override void OnPaint( PaintEventArgs pevent ) int arrowX = ClientRectangle.Width - 14; int arrowY = ClientRectangle.Height / 2 - 1; - Brush brush = Enabled ? SystemBrushes.ControlText : SystemBrushes.ButtonShadow; - Point[] arrows = new Point[] { new Point( arrowX, arrowY ), new Point( arrowX + 7, arrowY ), new Point( arrowX + 3, arrowY + 4 ) }; - pevent.Graphics.FillPolygon( brush, arrows ); + if ( ShowDropDownArrow ) + { + Brush brush = Enabled ? SystemBrushes.ControlText : SystemBrushes.ButtonShadow; + Point[] arrows = new Point[] { new Point( arrowX, arrowY ), new Point( arrowX + 7, arrowY ), new Point( arrowX + 3, arrowY + 4 ) }; + pevent.Graphics.FillPolygon( brush, arrows ); + } + + if ( ShowSplitBar ) + { + // Draw a dashed separator on the left of the arrow + int lineX = ClientRectangle.Width - 18; + int lineYFrom = 4; + int lineYTo = ClientRectangle.Height - 5; + using ( var separatorPen = new Pen( Brushes.DarkGray ) ) + { + pevent.Graphics.DrawLine( separatorPen, lineX, lineYFrom, lineX, lineYTo ); + } + } } + + + } } diff --git a/C64Studio/Dialogs/FormRenumberBASICLabelMode.Designer.cs b/C64Studio/Dialogs/FormRenumberBASICLabelMode.Designer.cs new file mode 100644 index 00000000..42ec6daf --- /dev/null +++ b/C64Studio/Dialogs/FormRenumberBASICLabelMode.Designer.cs @@ -0,0 +1,154 @@ +namespace RetroDevStudio.Dialogs +{ + partial class FormRenumberBASICLabelMode + { + /// + /// 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.label1 = new System.Windows.Forms.Label(); + this.editStartLine = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.editLineStep = new System.Windows.Forms.TextBox(); + this.btnCancel = new System.Windows.Forms.Button(); + this.btnOK = new System.Windows.Forms.Button(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.labelRenumberInfo = new System.Windows.Forms.Label(); + this.groupBox1.SuspendLayout(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(11, 22); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(111, 13); + this.label1.TabIndex = 0; + this.label1.Text = "Start with line number:"; + // + // editStartLine + // + this.editStartLine.Location = new System.Drawing.Point(128, 19); + this.editStartLine.Name = "editStartLine"; + this.editStartLine.Size = new System.Drawing.Size(136, 20); + this.editStartLine.TabIndex = 0; + this.editStartLine.TextChanged += new System.EventHandler(this.editStartLine_TextChanged); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(11, 48); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(100, 13); + this.label2.TabIndex = 0; + this.label2.Text = "Step by Line Count:"; + // + // editLineStep + // + this.editLineStep.Location = new System.Drawing.Point(128, 45); + this.editLineStep.Name = "editLineStep"; + this.editLineStep.Size = new System.Drawing.Size(136, 20); + this.editLineStep.TabIndex = 1; + this.editLineStep.TextChanged += new System.EventHandler(this.editLineStep_TextChanged); + // + // btnCancel + // + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(219, 169); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 23); + this.btnCancel.TabIndex = 3; + this.btnCancel.Text = "&Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + // + // btnOK + // + this.btnOK.Enabled = false; + this.btnOK.Location = new System.Drawing.Point(138, 169); + this.btnOK.Name = "btnOK"; + this.btnOK.Size = new System.Drawing.Size(75, 23); + this.btnOK.TabIndex = 2; + this.btnOK.Text = "&OK"; + this.btnOK.UseVisualStyleBackColor = true; + this.btnOK.Click += new System.EventHandler(this.btnOK_Click); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.editStartLine); + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Controls.Add(this.label2); + this.groupBox1.Controls.Add(this.editLineStep); + this.groupBox1.Location = new System.Drawing.Point(10, 12); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(284, 84); + this.groupBox1.TabIndex = 4; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Renumber Settings"; + // + // labelRenumberInfo + // + this.labelRenumberInfo.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelRenumberInfo.Location = new System.Drawing.Point(10, 105); + this.labelRenumberInfo.Name = "labelRenumberInfo"; + this.labelRenumberInfo.Size = new System.Drawing.Size(282, 61); + this.labelRenumberInfo.TabIndex = 5; + this.labelRenumberInfo.Text = "label3"; + // + // FormRenumberBASICLabelMode + // + this.AcceptButton = this.btnOK; + 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(304, 204); + this.Controls.Add(this.labelRenumberInfo); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.btnOK); + this.Controls.Add(this.btnCancel); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "FormRenumberBASICLabelMode"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.Text = "Auto Renumber settings for label mode"; + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox editStartLine; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox editLineStep; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.Button btnOK; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.Label labelRenumberInfo; + } +} \ No newline at end of file diff --git a/C64Studio/Dialogs/FormRenumberBASICLabelMode.cs b/C64Studio/Dialogs/FormRenumberBASICLabelMode.cs new file mode 100644 index 00000000..dbd497c1 --- /dev/null +++ b/C64Studio/Dialogs/FormRenumberBASICLabelMode.cs @@ -0,0 +1,102 @@ +using RetroDevStudio.Documents; +using RetroDevStudio.Tasks; +using System; +using System.Windows.Forms; + + + +namespace RetroDevStudio.Dialogs +{ + public partial class FormRenumberBASICLabelMode : Form + { + SourceBasicEx m_Basic = null; + StudioCore m_Core = null; + + + + public FormRenumberBASICLabelMode( StudioCore Core, SourceBasicEx Basic ) + { + m_Basic = Basic; + m_Core = Core; + + InitializeComponent(); + + editStartLine.Text = Basic.m_LastLabelAutoRenumberStartLine; + editLineStep.Text = Basic.m_LastLabelAutoRenumberLineStep; + + Core.Theming.ApplyTheme( this ); + + CheckRenumbering(); + } + + + + private void editStartLine_TextChanged( object sender, EventArgs e ) + { + CheckRenumbering(); + } + + + + private void editLineStep_TextChanged( object sender, EventArgs e ) + { + CheckRenumbering(); + } + + + + private void CheckRenumbering() + { + int lineStart = GR.Convert.ToI32( editStartLine.Text ); + int lineStep = GR.Convert.ToI32( editLineStep.Text ); + + if ( ( lineStart < 0 ) + || ( lineStart >= 64000 )) + { + labelRenumberInfo.Text = "Starting line number is invalid, must be greater or equal zero and less than 64000"; + btnOK.Enabled = false; + return; + } + if ( lineStep <= 0 ) + { + labelRenumberInfo.Text = "Line Step must be greater than zero"; + btnOK.Enabled = false; + return; + } + + labelRenumberInfo.Text = "Renumber values are good"; + btnOK.Enabled = true; + } + + + + private void btnOK_Click( object sender, EventArgs e ) + { + int lineStart = GR.Convert.ToI32( editStartLine.Text ); + int lineStep = GR.Convert.ToI32( editLineStep.Text ); + + m_Basic.m_LastLabelAutoRenumberStartLine = lineStart.ToString(); + m_Basic.m_LastLabelAutoRenumberLineStep = lineStep.ToString(); + DialogResult = DialogResult.OK; + + Close(); + } + + + + private void editLastLineNumber_TextChanged( object sender, EventArgs e ) + { + CheckRenumbering(); + } + + + + private void editFirstLineNumber_TextChanged( object sender, EventArgs e ) + { + CheckRenumbering(); + } + + + + } +} diff --git a/C64Studio/Dialogs/FormRenumberBASICLabelMode.resx b/C64Studio/Dialogs/FormRenumberBASICLabelMode.resx new file mode 100644 index 00000000..ff31a6db --- /dev/null +++ b/C64Studio/Dialogs/FormRenumberBASICLabelMode.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/C64Studio/Documents/LabelExplorer.cs b/C64Studio/Documents/LabelExplorer.cs index 290319d3..be773c85 100644 --- a/C64Studio/Documents/LabelExplorer.cs +++ b/C64Studio/Documents/LabelExplorer.cs @@ -149,12 +149,6 @@ public void RefreshFromDocument( BaseDocument Doc ) } _FileInfoPerFileCache.Add( Doc.DocumentInfo.FullPath, Doc.DocumentInfo.ASMFileInfo ); - if ( InvokeRequired ) - { - Invoke( new MainForm.DocCallback( RefreshFromDocument ), new object[] { Doc } ); - return; - } - StoreOpenNodes(); ActiveDocumentInfo = Doc.DocumentInfo; diff --git a/C64Studio/Documents/SourceBasicEx.Designer.cs b/C64Studio/Documents/SourceBasicEx.Designer.cs index 2d7c6812..b52977d4 100644 --- a/C64Studio/Documents/SourceBasicEx.Designer.cs +++ b/C64Studio/Documents/SourceBasicEx.Designer.cs @@ -1,4 +1,6 @@ -namespace RetroDevStudio.Documents +using RetroDevStudio.Controls; + +namespace RetroDevStudio.Documents { partial class SourceBasicEx { @@ -37,7 +39,12 @@ private void InitializeComponent() this.pasteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.renumberToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.btnToggleLabelMode = new System.Windows.Forms.CheckBox(); + this.btnToggleLabelMode = new RetroDevStudio.Controls.MenuButton(); + this.contextMenuLabelButton = new System.Windows.Forms.ContextMenuStrip(this.components); + this.autoRenumberWithLastValuesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.autoRenumberWith1010ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.autoRenumberWith11ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.autoRenumberSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuBASIC = new System.Windows.Forms.MenuStrip(); this.bASICToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.renumberToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -52,6 +59,7 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.m_FileWatcher)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.editSource)).BeginInit(); this.contextSource.SuspendLayout(); + this.contextMenuLabelButton.SuspendLayout(); this.menuBASIC.SuspendLayout(); this.SuspendLayout(); // @@ -140,16 +148,57 @@ private void InitializeComponent() // // btnToggleLabelMode // - this.btnToggleLabelMode.Appearance = System.Windows.Forms.Appearance.Button; this.btnToggleLabelMode.Location = new System.Drawing.Point(0, 27); + this.btnToggleLabelMode.Menu = this.contextMenuLabelButton; this.btnToggleLabelMode.Name = "btnToggleLabelMode"; - this.btnToggleLabelMode.Size = new System.Drawing.Size(100, 23); + this.btnToggleLabelMode.ShowDropDownArrow = false; + this.btnToggleLabelMode.ShowSplitBar = true; + this.btnToggleLabelMode.Size = new System.Drawing.Size(130, 23); this.btnToggleLabelMode.TabIndex = 2; this.btnToggleLabelMode.Text = "To Label Mode"; this.toolTip1.SetToolTip(this.btnToggleLabelMode, "To Label Mode (Line Number Mode is active)"); this.btnToggleLabelMode.UseVisualStyleBackColor = true; this.btnToggleLabelMode.CheckedChanged += new System.EventHandler(this.btnToggleLabelMode_CheckedChanged); // + // contextMenuLabelButton + // + this.contextMenuLabelButton.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.autoRenumberWithLastValuesToolStripMenuItem, + this.autoRenumberWith1010ToolStripMenuItem, + this.autoRenumberWith11ToolStripMenuItem, + this.autoRenumberSettingsToolStripMenuItem}); + this.contextMenuLabelButton.Name = "contextMenuLabelButton"; + this.contextMenuLabelButton.Size = new System.Drawing.Size(239, 114); + this.contextMenuLabelButton.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuLabelButton_Opening); + // + // autoRenumberWithLastValuesToolStripMenuItem + // + this.autoRenumberWithLastValuesToolStripMenuItem.Name = "autoRenumberWithLastValuesToolStripMenuItem"; + this.autoRenumberWithLastValuesToolStripMenuItem.Size = new System.Drawing.Size(238, 22); + this.autoRenumberWithLastValuesToolStripMenuItem.Text = "Auto renumber with last values"; + this.autoRenumberWithLastValuesToolStripMenuItem.Click += new System.EventHandler(this.autoRenumberWithLastValuesToolStripMenuItem_Click); + // + // autoRenumberWith1010ToolStripMenuItem + // + this.autoRenumberWith1010ToolStripMenuItem.Name = "autoRenumberWith1010ToolStripMenuItem"; + this.autoRenumberWith1010ToolStripMenuItem.Size = new System.Drawing.Size(238, 22); + this.autoRenumberWith1010ToolStripMenuItem.Text = "Auto renumber with 10,10"; + this.autoRenumberWith1010ToolStripMenuItem.Click += new System.EventHandler(this.autoRenumberWith1010ToolStripMenuItem_Click); + // + // autoRenumberWith11ToolStripMenuItem + // + this.autoRenumberWith11ToolStripMenuItem.Name = "autoRenumberWith11ToolStripMenuItem"; + this.autoRenumberWith11ToolStripMenuItem.Size = new System.Drawing.Size(238, 22); + this.autoRenumberWith11ToolStripMenuItem.Text = "Auto renumber with 1,1"; + this.autoRenumberWith11ToolStripMenuItem.Click += new System.EventHandler(this.autoRenumberWith11ToolStripMenuItem_Click); + // + // autoRenumberSettingsToolStripMenuItem + // + this.autoRenumberSettingsToolStripMenuItem.Name = "autoRenumberSettingsToolStripMenuItem"; + this.autoRenumberSettingsToolStripMenuItem.Size = new System.Drawing.Size(238, 22); + this.autoRenumberSettingsToolStripMenuItem.Text = "Auto renumber settings..."; + this.autoRenumberSettingsToolStripMenuItem.Click += new System.EventHandler(this.autoRenumberSettingsToolStripMenuItem_Click); + // // menuBASIC // this.menuBASIC.ImageScalingSize = new System.Drawing.Size(20, 20); @@ -181,7 +230,7 @@ private void InitializeComponent() this.btnToggleSymbolMode.Appearance = System.Windows.Forms.Appearance.Button; this.btnToggleSymbolMode.AutoSize = true; this.btnToggleSymbolMode.Image = ((System.Drawing.Image)(resources.GetObject("btnToggleSymbolMode.Image"))); - this.btnToggleSymbolMode.Location = new System.Drawing.Point(106, 27); + this.btnToggleSymbolMode.Location = new System.Drawing.Point(136, 27); this.btnToggleSymbolMode.Name = "btnToggleSymbolMode"; this.btnToggleSymbolMode.Size = new System.Drawing.Size(22, 22); this.btnToggleSymbolMode.TabIndex = 2; @@ -194,7 +243,7 @@ private void InitializeComponent() this.btnToggleUpperLowerCase.Appearance = System.Windows.Forms.Appearance.Button; this.btnToggleUpperLowerCase.AutoSize = true; this.btnToggleUpperLowerCase.Image = ((System.Drawing.Image)(resources.GetObject("btnToggleUpperLowerCase.Image"))); - this.btnToggleUpperLowerCase.Location = new System.Drawing.Point(134, 27); + this.btnToggleUpperLowerCase.Location = new System.Drawing.Point(164, 27); this.btnToggleUpperLowerCase.Name = "btnToggleUpperLowerCase"; this.btnToggleUpperLowerCase.Size = new System.Drawing.Size(22, 22); this.btnToggleUpperLowerCase.TabIndex = 2; @@ -207,7 +256,7 @@ private void InitializeComponent() this.btnToggleStringEntryMode.Appearance = System.Windows.Forms.Appearance.Button; this.btnToggleStringEntryMode.AutoSize = true; this.btnToggleStringEntryMode.Image = ((System.Drawing.Image)(resources.GetObject("btnToggleStringEntryMode.Image"))); - this.btnToggleStringEntryMode.Location = new System.Drawing.Point(162, 27); + this.btnToggleStringEntryMode.Location = new System.Drawing.Point(192, 27); this.btnToggleStringEntryMode.Name = "btnToggleStringEntryMode"; this.btnToggleStringEntryMode.Size = new System.Drawing.Size(22, 22); this.btnToggleStringEntryMode.TabIndex = 2; @@ -217,7 +266,7 @@ private void InitializeComponent() // // editBASICStartAddress // - this.editBASICStartAddress.Location = new System.Drawing.Point(277, 29); + this.editBASICStartAddress.Location = new System.Drawing.Point(307, 29); this.editBASICStartAddress.MaxLength = 7; this.editBASICStartAddress.Name = "editBASICStartAddress"; this.editBASICStartAddress.Size = new System.Drawing.Size(65, 20); @@ -228,7 +277,7 @@ private void InitializeComponent() // labelStartAddress // this.labelStartAddress.AutoSize = true; - this.labelStartAddress.Location = new System.Drawing.Point(198, 32); + this.labelStartAddress.Location = new System.Drawing.Point(228, 32); this.labelStartAddress.Name = "labelStartAddress"; this.labelStartAddress.Size = new System.Drawing.Size(73, 13); this.labelStartAddress.TabIndex = 5; @@ -237,7 +286,7 @@ private void InitializeComponent() // labelBASICVersion // this.labelBASICVersion.AutoSize = true; - this.labelBASICVersion.Location = new System.Drawing.Point(360, 32); + this.labelBASICVersion.Location = new System.Drawing.Point(390, 32); this.labelBASICVersion.Name = "labelBASICVersion"; this.labelBASICVersion.Size = new System.Drawing.Size(79, 13); this.labelBASICVersion.TabIndex = 5; @@ -247,7 +296,7 @@ private void InitializeComponent() // this.comboBASICVersion.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBASICVersion.FormattingEnabled = true; - this.comboBASICVersion.Location = new System.Drawing.Point(445, 28); + this.comboBASICVersion.Location = new System.Drawing.Point(475, 28); this.comboBASICVersion.Name = "comboBASICVersion"; this.comboBASICVersion.Size = new System.Drawing.Size(150, 21); this.comboBASICVersion.TabIndex = 6; @@ -272,6 +321,7 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.m_FileWatcher)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.editSource)).EndInit(); this.contextSource.ResumeLayout(false); + this.contextMenuLabelButton.ResumeLayout(false); this.menuBASIC.ResumeLayout(false); this.menuBASIC.PerformLayout(); this.ResumeLayout(false); @@ -283,7 +333,8 @@ private void InitializeComponent() public FastColoredTextBoxNS.FastColoredTextBox editSource; private System.Windows.Forms.ContextMenuStrip contextSource; - private System.Windows.Forms.CheckBox btnToggleLabelMode; + //private System.Windows.Forms.CheckBox btnToggleLabelMode; + MenuButton btnToggleLabelMode; private System.Windows.Forms.MenuStrip menuBASIC; private System.Windows.Forms.ToolStripMenuItem bASICToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem renumberToolStripMenuItem; @@ -300,5 +351,10 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem cutToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripMenuItem renumberToolStripMenuItem1; + private System.Windows.Forms.ContextMenuStrip contextMenuLabelButton; + private System.Windows.Forms.ToolStripMenuItem autoRenumberWith1010ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem autoRenumberWith11ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem autoRenumberSettingsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem autoRenumberWithLastValuesToolStripMenuItem; } } diff --git a/C64Studio/Documents/SourceBasicEx.cs b/C64Studio/Documents/SourceBasicEx.cs index 8378025d..34a43d37 100644 --- a/C64Studio/Documents/SourceBasicEx.cs +++ b/C64Studio/Documents/SourceBasicEx.cs @@ -42,6 +42,9 @@ public partial class SourceBasicEx : CompilableDocument private bool m_InsideLoad = false; private bool m_InsideToggleSymbolHandler = false; + public string m_LastLabelAutoRenumberStartLine = "10"; + public string m_LastLabelAutoRenumberLineStep = "10"; + public override int CursorLine @@ -746,6 +749,14 @@ public override bool Load() UpdateCaseButtonCaption(); } } + if ( metaParams.Length >= 4 ) + { + m_LastLabelAutoRenumberStartLine = metaParams[3]; + } + if ( metaParams.Length >= 5 ) + { + m_LastLabelAutoRenumberLineStep = metaParams[4]; + } } // quick compatibility hack with petcat @@ -899,11 +910,17 @@ protected override bool PerformSave( string FullPath ) string content = GetContent(); // add "meta data" in front - string metaData = "#RetroDevStudio.MetaData.BASIC:" + m_StartAddress + "," + m_BASICDialectName; + string metaData = $"#RetroDevStudio.MetaData.BASIC:{m_StartAddress},{m_BASICDialectName}"; if ( m_LowerCaseMode ) { metaData += ",lowercase"; } + else + { + metaData += ",uppercase"; + } + metaData += $",{m_LastLabelAutoRenumberStartLine},{m_LastLabelAutoRenumberLineStep}"; + metaData += "\r\n"; @@ -1716,13 +1733,19 @@ private void UpdateLabelModeText() { if ( m_LabelMode ) { - toolTip1.SetToolTip( btnToggleLabelMode, "To Line Number Mode (Label Mode is active)" ); + toolTip1.SetToolTip( btnToggleLabelMode, $"To Line Number Mode (Label Mode is active), start line {m_LastLabelAutoRenumberStartLine}, line step {m_LastLabelAutoRenumberLineStep}" ); btnToggleLabelMode.Text = "To Number Mode"; + btnToggleLabelMode.ShowDropDownArrow = true; + btnToggleLabelMode.ShowSplitBar = true; + btnToggleLabelMode.Menu = contextMenuLabelButton; } else { toolTip1.SetToolTip( btnToggleLabelMode, "To Label Mode (Line Number Mode is active)" ); btnToggleLabelMode.Text = "To Label Mode"; + btnToggleLabelMode.ShowDropDownArrow = false; + btnToggleLabelMode.ShowSplitBar = false; + btnToggleLabelMode.Menu = null; } } @@ -1777,7 +1800,7 @@ public bool PerformLabelModeToggle( out string Result ) } else { - Result = parser.DecodeFromLabels(); + Result = parser.DecodeFromLabels( GR.Convert.ToI32( m_LastLabelAutoRenumberStartLine ), GR.Convert.ToI32( m_LastLabelAutoRenumberLineStep ) ); } /* @@ -2340,5 +2363,62 @@ public override void HighlightText( int LineIndex, int CharPos, int Length ) + private void autoRenumberWith1010ToolStripMenuItem_Click( object sender, EventArgs e ) + { + if ( m_InsideLoad ) + { + return; + } + m_LastLabelAutoRenumberLineStep = "10"; + m_LastLabelAutoRenumberStartLine = "10"; + ToggleLabelMode(); + } + + + + private void autoRenumberWith11ToolStripMenuItem_Click( object sender, EventArgs e ) + { + if ( m_InsideLoad ) + { + return; + } + m_LastLabelAutoRenumberLineStep = "1"; + m_LastLabelAutoRenumberStartLine = "1"; + ToggleLabelMode(); + } + + + + private void autoRenumberSettingsToolStripMenuItem_Click( object sender, EventArgs e ) + { + var formRenumberSettings = new FormRenumberBASICLabelMode( Core, this ); + + if ( formRenumberSettings.ShowDialog() == DialogResult.OK ) + { + UpdateLabelModeText(); + } + } + + + + private void autoRenumberWithLastValuesToolStripMenuItem_Click( object sender, EventArgs e ) + { + if ( m_InsideLoad ) + { + return; + } + + ToggleLabelMode(); + } + + + + private void contextMenuLabelButton_Opening( object sender, CancelEventArgs e ) + { + autoRenumberWithLastValuesToolStripMenuItem.Text = $"Auto renumber with last values {m_LastLabelAutoRenumberStartLine}, {m_LastLabelAutoRenumberLineStep}"; + } + + + } } diff --git a/C64Studio/Documents/SourceBasicEx.resx b/C64Studio/Documents/SourceBasicEx.resx index e97b5fec..65ccb946 100644 --- a/C64Studio/Documents/SourceBasicEx.resx +++ b/C64Studio/Documents/SourceBasicEx.resx @@ -141,6 +141,9 @@ CgAAAAAAAAAAjQABAAH4/////P///woAAAAAAAAAAKQAAQAB9/////z///8KAAAAAAAAAACWAAEACw== + + 633, 17 + 536, 17