Skip to content

Commit db32919

Browse files
Add: Auto-renumber settings for BASIC
1 parent 583f690 commit db32919

File tree

10 files changed

+609
-33
lines changed

10 files changed

+609
-33
lines changed

C64Models/Parser/BasicFileParser.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2651,7 +2651,8 @@ public string EncodeToLabels()
26512651
lineLengthOffset = lineInfo.Value.Tokens[1].StartIndex;
26522652
}
26532653

2654-
if ( lineNumberReference.ContainsKey( lineInfo.Value.LineNumber ) )
2654+
if ( ( lineNumberReference.ContainsKey( lineInfo.Value.LineNumber ) )
2655+
&& ( lineInfo.Value.Tokens[0].TokenType != Token.Type.HARD_COMMENT ) )
26552656
{
26562657
// something is referencing this line
26572658
sb.AppendLine();
@@ -2817,12 +2818,14 @@ private int FindNextToken( List<Token> Tokens, int StartIndex )
28172818

28182819

28192820

2820-
public string DecodeFromLabels()
2821+
public string DecodeFromLabels( int StartLineNumber = 10, int LineStep = 10 )
28212822
{
28222823
StringBuilder sb = new StringBuilder();
28232824
GR.Collections.Map<string,int> labelToNumber = new GR.Collections.Map<string, int>();
28242825

2825-
int lineNumber = 10;
2826+
int startLineNumber = StartLineNumber;
2827+
int lineNumberStep = LineStep;
2828+
int lineNumber = startLineNumber;
28262829

28272830
// collect labels
28282831
foreach ( KeyValuePair<int,LineInfo> lineInfo in m_LineInfos )
@@ -2852,9 +2855,9 @@ public string DecodeFromLabels()
28522855
}
28532856
continue;
28542857
}
2855-
lineNumber += 10;
2858+
lineNumber += lineNumberStep;
28562859
}
2857-
lineNumber = 10;
2860+
lineNumber = startLineNumber;
28582861
foreach ( KeyValuePair<int, LineInfo> lineInfo in m_LineInfos )
28592862
{
28602863
if ( ( lineInfo.Value.Tokens.Count == 1 )
@@ -2993,7 +2996,7 @@ public string DecodeFromLabels()
29932996
}
29942997
}
29952998
sb.Append( "\r\n" );
2996-
lineNumber += 10;
2999+
lineNumber += lineNumberStep;
29973000
}
29983001
return sb.ToString();
29993002
}

C64Studio/C64Studio.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@
223223
<Compile Update="Dialogs\FormRenameSolution.cs">
224224
<SubType>Form</SubType>
225225
</Compile>
226+
<Compile Update="Dialogs\FormRenumberBASICLabelMode.cs">
227+
<SubType>Form</SubType>
228+
</Compile>
226229
<Compile Update="Dialogs\Preferences\PrefAssembler.cs">
227230
<SubType>UserControl</SubType>
228231
</Compile>

C64Studio/Controls/MenuButton.cs

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.ComponentModel;
55
using System.Windows.Forms;
66
using System.Drawing;
7+
using System.Drawing.Drawing2D;
78

89
namespace RetroDevStudio.Controls
910
{
@@ -18,22 +19,64 @@ public ContextMenuStrip Menu
1819

1920

2021

22+
[DefaultValue( true )]
23+
public bool ShowDropDownArrow { get; set; }
24+
25+
[DefaultValue( false )]
26+
public bool ShowSplitBar { get; set; }
27+
28+
[DefaultValue( false )]
29+
public bool Checked { get; set; }
30+
31+
32+
33+
public event EventHandler CheckedChanged;
34+
35+
36+
2137
protected override void OnMouseDown( MouseEventArgs mevent )
2238
{
2339
base.OnMouseDown( mevent );
2440

41+
bool hitMenu = false;
42+
int lineX = ClientRectangle.Width - 18;
43+
int menuShowX = 0;
44+
45+
if ( ShowSplitBar )
46+
{
47+
if ( mevent.X >= lineX )
48+
{
49+
hitMenu = true;
50+
menuShowX = lineX;
51+
}
52+
}
53+
else
54+
{
55+
hitMenu = true;
56+
}
57+
58+
59+
2560
if ( ( Menu != null )
61+
&& ( hitMenu )
2662
&& ( mevent.Button == MouseButtons.Left ) )
2763
{
28-
System.Drawing.Point ptMenu = new Point( 0, Height );
29-
64+
System.Drawing.Point ptMenu = new Point( menuShowX, Height );
3065

3166
if ( ptMenu.Y + Menu.Height >= Screen.FromControl( this ).WorkingArea.Height )
3267
{
33-
ptMenu = PointToScreen( new Point( 0, -Menu.Height ) );
68+
ptMenu = PointToScreen( new Point( menuShowX, -Menu.Height ) );
3469
}
3570
Menu.Show( this, ptMenu );
3671
}
72+
else
73+
{
74+
if ( CheckedChanged != null )
75+
{
76+
CheckedChanged( this, new EventArgs() );
77+
}
78+
OnClick( new EventArgs() );
79+
}
3780
}
3881

3982

@@ -45,9 +88,27 @@ protected override void OnPaint( PaintEventArgs pevent )
4588
int arrowX = ClientRectangle.Width - 14;
4689
int arrowY = ClientRectangle.Height / 2 - 1;
4790

48-
Brush brush = Enabled ? SystemBrushes.ControlText : SystemBrushes.ButtonShadow;
49-
Point[] arrows = new Point[] { new Point( arrowX, arrowY ), new Point( arrowX + 7, arrowY ), new Point( arrowX + 3, arrowY + 4 ) };
50-
pevent.Graphics.FillPolygon( brush, arrows );
91+
if ( ShowDropDownArrow )
92+
{
93+
Brush brush = Enabled ? SystemBrushes.ControlText : SystemBrushes.ButtonShadow;
94+
Point[] arrows = new Point[] { new Point( arrowX, arrowY ), new Point( arrowX + 7, arrowY ), new Point( arrowX + 3, arrowY + 4 ) };
95+
pevent.Graphics.FillPolygon( brush, arrows );
96+
}
97+
98+
if ( ShowSplitBar )
99+
{
100+
// Draw a dashed separator on the left of the arrow
101+
int lineX = ClientRectangle.Width - 18;
102+
int lineYFrom = 4;
103+
int lineYTo = ClientRectangle.Height - 5;
104+
using ( var separatorPen = new Pen( Brushes.DarkGray ) )
105+
{
106+
pevent.Graphics.DrawLine( separatorPen, lineX, lineYFrom, lineX, lineYTo );
107+
}
108+
}
51109
}
110+
111+
112+
52113
}
53114
}

C64Studio/Dialogs/FormRenumberBASICLabelMode.Designer.cs

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

0 commit comments

Comments
 (0)