Commit dc077841 authored by Alexander Dietsch's avatar Alexander Dietsch

-Added option for cursor to be in the next executed line similiar to other

debugger
parent cc508db6
......@@ -58,6 +58,9 @@
this.bPrefCancel = new System.Windows.Forms.Button();
this.bPrefOK = new System.Windows.Forms.Button();
this.fBDiaExportLog = new System.Windows.Forms.FolderBrowserDialog();
this.lCursorPos = new System.Windows.Forms.Label();
this.rCurrentLine = new System.Windows.Forms.RadioButton();
this.rNextLine = new System.Windows.Forms.RadioButton();
this.pPreferences.SuspendLayout();
this.gBEditor.SuspendLayout();
this.gBSimulation.SuspendLayout();
......@@ -85,13 +88,13 @@
this.pPreferences.Controls.Add(this.gBRegisters);
this.pPreferences.Location = new System.Drawing.Point(13, 13);
this.pPreferences.Name = "pPreferences";
this.pPreferences.Size = new System.Drawing.Size(439, 395);
this.pPreferences.Size = new System.Drawing.Size(437, 466);
this.pPreferences.TabIndex = 0;
//
// gBEditor
//
this.gBEditor.Controls.Add(this.chBHighlight);
this.gBEditor.Location = new System.Drawing.Point(4, 331);
this.gBEditor.Location = new System.Drawing.Point(3, 404);
this.gBEditor.Name = "gBEditor";
this.gBEditor.Size = new System.Drawing.Size(427, 59);
this.gBEditor.TabIndex = 3;
......@@ -103,14 +106,17 @@
this.chBHighlight.AutoSize = true;
this.chBHighlight.Location = new System.Drawing.Point(10, 19);
this.chBHighlight.Name = "chBHighlight";
this.chBHighlight.Size = new System.Drawing.Size(473, 17);
this.chBHighlight.Size = new System.Drawing.Size(273, 30);
this.chBHighlight.TabIndex = 8;
this.chBHighlight.Text = "Highlight code after 2 seconds of no input \n(may cause unexpected behaviour on Uni" +
"x Systems)";
this.chBHighlight.Text = "Highlight code after 2 seconds of no input \n(may cause unexpected behaviour on Un" +
"ix Systems)";
this.chBHighlight.UseVisualStyleBackColor = true;
//
// gBSimulation
//
this.gBSimulation.Controls.Add(this.rNextLine);
this.gBSimulation.Controls.Add(this.rCurrentLine);
this.gBSimulation.Controls.Add(this.lCursorPos);
this.gBSimulation.Controls.Add(this.lSteps);
this.gBSimulation.Controls.Add(this.nUDSteps);
this.gBSimulation.Controls.Add(this.chBMaxSteps);
......@@ -118,7 +124,7 @@
this.gBSimulation.Controls.Add(this.lTime);
this.gBSimulation.Location = new System.Drawing.Point(4, 232);
this.gBSimulation.Name = "gBSimulation";
this.gBSimulation.Size = new System.Drawing.Size(428, 93);
this.gBSimulation.Size = new System.Drawing.Size(428, 134);
this.gBSimulation.TabIndex = 2;
this.gBSimulation.TabStop = false;
this.gBSimulation.Text = "Simulation";
......@@ -408,7 +414,7 @@
// bPrefCancel
//
this.bPrefCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.bPrefCancel.Location = new System.Drawing.Point(377, 414);
this.bPrefCancel.Location = new System.Drawing.Point(375, 485);
this.bPrefCancel.Name = "bPrefCancel";
this.bPrefCancel.Size = new System.Drawing.Size(75, 23);
this.bPrefCancel.TabIndex = 2;
......@@ -419,7 +425,7 @@
// bPrefOK
//
this.bPrefOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.bPrefOK.Location = new System.Drawing.Point(296, 414);
this.bPrefOK.Location = new System.Drawing.Point(294, 485);
this.bPrefOK.Name = "bPrefOK";
this.bPrefOK.Size = new System.Drawing.Size(75, 23);
this.bPrefOK.TabIndex = 3;
......@@ -431,11 +437,42 @@
//
this.fBDiaExportLog.RootFolder = System.Environment.SpecialFolder.MyComputer;
//
// lCursorPos
//
this.lCursorPos.AutoSize = true;
this.lCursorPos.Location = new System.Drawing.Point(10, 97);
this.lCursorPos.Name = "lCursorPos";
this.lCursorPos.Size = new System.Drawing.Size(76, 13);
this.lCursorPos.TabIndex = 11;
this.lCursorPos.Text = "Cursor position";
//
// rCurrentLine
//
this.rCurrentLine.AutoSize = true;
this.rCurrentLine.Checked = true;
this.rCurrentLine.Location = new System.Drawing.Point(92, 89);
this.rCurrentLine.Name = "rCurrentLine";
this.rCurrentLine.Size = new System.Drawing.Size(143, 17);
this.rCurrentLine.TabIndex = 12;
this.rCurrentLine.TabStop = true;
this.rCurrentLine.Text = "at currently executed line";
this.rCurrentLine.UseVisualStyleBackColor = true;
//
// rNextLine
//
this.rNextLine.AutoSize = true;
this.rNextLine.Location = new System.Drawing.Point(92, 105);
this.rNextLine.Name = "rNextLine";
this.rNextLine.Size = new System.Drawing.Size(154, 17);
this.rNextLine.TabIndex = 13;
this.rNextLine.Text = "at line that is executed next";
this.rNextLine.UseVisualStyleBackColor = true;
//
// Preferences
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(464, 449);
this.ClientSize = new System.Drawing.Size(462, 520);
this.Controls.Add(this.bPrefOK);
this.Controls.Add(this.bPrefCancel);
this.Controls.Add(this.pPreferences);
......@@ -498,5 +535,8 @@
private System.Windows.Forms.CheckBox chBMaxSteps;
private System.Windows.Forms.GroupBox gBEditor;
private System.Windows.Forms.CheckBox chBHighlight;
private System.Windows.Forms.RadioButton rNextLine;
private System.Windows.Forms.RadioButton rCurrentLine;
private System.Windows.Forms.Label lCursorPos;
}
}
\ No newline at end of file
......@@ -31,6 +31,8 @@ namespace LWSimulatorGUI
chBHighlight.Checked = (simul.getOptionVal("doHighlight") != 0);
nUDTime.Value = simul.getOptionVal("timePerStep");
chBExportAfterTerm.Checked = (simul.getOptionVal("alwaysSaveLog") != 0);
rCurrentLine.Checked = (simul.getOptionVal("cursorAtCurrent") != 0);
rNextLine.Checked = !rCurrentLine.Checked;
tBDirPath.Text = simul.getLogDir();
tBDirPath.Enabled = chBExportAfterTerm.Checked;
bDefineDirExport.Enabled = chBExportAfterTerm.Checked;
......@@ -94,6 +96,8 @@ namespace LWSimulatorGUI
unableOptions.Add("-Option to show debug log");
if(!simulator.setOptionVal("timePerStep", (long)nUDTime.Value))
unableOptions.Add("-Number of milliseconds between steps");
if (!simulator.setOptionVal("cursorAtCurrent", rCurrentLine.Checked ? 1 : 0))
unableOptions.Add("-Position of Cursor when simulating");
if (validDir)
{
if (!simulator.setOptionVal("alwaysSaveLog", chBExportAfterTerm.Checked ? 1 : 0))
......@@ -120,6 +124,7 @@ namespace LWSimulatorGUI
else
if (!simulator.setOptionVal("maxStepAm", -(long)nUDSteps.Value))
unableOptions.Add("-Maximum numbers of step before automatic pause");
if(unableOptions.Count > 0)
{
string errorMsg = String.Format("Unable to set following options:\n\t{0}\nPlease make sure they are valid and simulator is not running.",String.Join("\n\t",unableOptions.ToArray()));
......
......@@ -15,6 +15,7 @@ namespace MainLWSimulator
private volatile string logDirectory = String.Empty;
private bool enableSaveOptions = true;
internal bool onUnix;
private const uint OPTIONS_AM = 11;
// Hard limit for options
private Dictionary<string, byte> ALLOWRUNNINGCHANGE = new Dictionary<string, byte>(); // allow changing the value during run; 0 - no changing, 1 - only when paused, 2 - always
......@@ -148,6 +149,7 @@ namespace MainLWSimulator
HARDLIMITVALSHIGH.Add("advancedLog", long.MaxValue);
HARDLIMITVALSHIGH.Add("alwaysSaveLog", long.MaxValue);
HARDLIMITVALSHIGH.Add("doHighlight", long.MaxValue);
HARDLIMITVALSHIGH.Add("cursorAtCurrent", long.MaxValue);
HARDLIMITVALSLOW.Add("maxRegAm", 1);
HARDLIMITVALSLOW.Add("maxStepAm", long.MinValue);
......@@ -158,6 +160,7 @@ namespace MainLWSimulator
HARDLIMITVALSLOW.Add("advancedLog", long.MinValue);
HARDLIMITVALSLOW.Add("alwaysSaveLog", long.MinValue);
HARDLIMITVALSLOW.Add("doHighlight", long.MinValue);
HARDLIMITVALSLOW.Add("cursorAtCurrent", long.MinValue);
ALLOWRUNNINGCHANGE.Add("maxRegAm", 0);
ALLOWRUNNINGCHANGE.Add("maxStepAm", 1);
......@@ -168,6 +171,7 @@ namespace MainLWSimulator
ALLOWRUNNINGCHANGE.Add("advancedLog", 2);
ALLOWRUNNINGCHANGE.Add("alwaysSaveLog", 0);
ALLOWRUNNINGCHANGE.Add("doHighlight", 2);
ALLOWRUNNINGCHANGE.Add("cursorAtCurrent", 1);
}
/// <summary>
......@@ -182,7 +186,7 @@ namespace MainLWSimulator
try
{
string[] lines = File.ReadAllLines(optionFilePath);
if (lines.Length == 10)
if (lines.Length == OPTIONS_AM)
defVals = !parseOptions(lines);
}
catch(Exception e)
......@@ -207,6 +211,7 @@ namespace MainLWSimulator
optionVals.Add("doHighlight", 0);
else
optionVals.Add("doHighlight", 1);
optionVals.Add("cursorAtCurrent", 1);
saveOptions();
}
}
......@@ -273,8 +278,14 @@ namespace MainLWSimulator
return false;
optionVals.Add("doHighlight", tmp);
if (!String.IsNullOrEmpty(loadedOpts[9]) && Directory.Exists(loadedOpts[9]))
setLogDir(loadedOpts[9]);
if (!long.TryParse(loadedOpts[9], out tmp))
return false;
if (tmp < HARDLIMITVALSLOW["cursorAtCurrent"] || tmp > HARDLIMITVALSHIGH["cursorAtCurrent"])
return false;
optionVals.Add("cursorAtCurrent", tmp);
if (!String.IsNullOrEmpty(loadedOpts[10]) && Directory.Exists(loadedOpts[10]))
setLogDir(loadedOpts[10]);
return true;
}
......@@ -289,7 +300,7 @@ namespace MainLWSimulator
return false;
try
{
string[] tmp = new string[10];
string[] tmp = new string[OPTIONS_AM];
tmp[0] = optionVals["maxRegAm"].ToString();
tmp[1] = optionVals["maxStepAm"].ToString();
tmp[2] = optionVals["defRegVal"].ToString();
......@@ -299,7 +310,8 @@ namespace MainLWSimulator
tmp[6] = optionVals["advancedLog"].ToString();
tmp[7] = optionVals["alwaysSaveLog"].ToString();
tmp[8] = optionVals["doHighlight"].ToString();
tmp[9] = logDirectory;
tmp[9] = optionVals["cursorAtCurrent"].ToString();
tmp[10] = logDirectory;
File.WriteAllLines(optionFilePath, tmp);
}
catch(Exception e)
......
......@@ -277,9 +277,12 @@ namespace MainLWSimulator
endOfCode = true;
else
{
updateCharInd();
if(parent.getOptionVal("cursorAtCurrent") != 0)
updateCharInd();
if (!interpreteNextNode())
error = true;
if (parent.getOptionVal("cursorAtCurrent") == 0)
updateCharInd();
if (nodeStack.Count == 0)
endOfCode = true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment