Commit 0ba079d8 authored by Alexander Dietsch's avatar Alexander Dietsch

MainSimulator:

-Set default option for Syntax Highlightint to 0 on Unix-systems
-Fixed issues with modifying registers on Unix-systems not working

Dissertation:
-Wrote Chapter 3.1 Basics
parent a22e599c
......@@ -311,7 +311,7 @@ namespace LWSimulatorCons
/// <param name="newState">The new state of the simulator</param>
private static void notifyRunningStateChanged(byte newState)
{
if (newState == 0)
if (newState == 0 || newState == 2)
{
waitForFinish.Set();
}
......
......@@ -29,9 +29,9 @@
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainGUI));
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
this.mSMainMenu = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
......@@ -40,6 +40,9 @@
this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.preferencesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.undoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.redoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator();
this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.cutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.pasteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
......@@ -79,9 +82,6 @@
this.bRevertAllReg = new System.Windows.Forms.Button();
this.bRevertReg = new System.Windows.Forms.Button();
this.checkSyntaxToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.undoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.redoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator();
this.mSMainMenu.SuspendLayout();
this.tSMainToolStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.spCMainGUI)).BeginInit();
......@@ -176,6 +176,28 @@
this.editToolStripMenuItem.Size = new System.Drawing.Size(39, 20);
this.editToolStripMenuItem.Text = "Edit";
//
// undoToolStripMenuItem
//
this.undoToolStripMenuItem.Name = "undoToolStripMenuItem";
this.undoToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z)));
this.undoToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
this.undoToolStripMenuItem.Text = "Undo";
this.undoToolStripMenuItem.Click += new System.EventHandler(this.undoToolStripMenuItem_Click);
//
// redoToolStripMenuItem
//
this.redoToolStripMenuItem.Name = "redoToolStripMenuItem";
this.redoToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
| System.Windows.Forms.Keys.Z)));
this.redoToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
this.redoToolStripMenuItem.Text = "Redo";
this.redoToolStripMenuItem.Click += new System.EventHandler(this.redoToolStripMenuItem_Click);
//
// toolStripSeparator6
//
this.toolStripSeparator6.Name = "toolStripSeparator6";
this.toolStripSeparator6.Size = new System.Drawing.Size(184, 6);
//
// copyToolStripMenuItem
//
this.copyToolStripMenuItem.Name = "copyToolStripMenuItem";
......@@ -458,7 +480,7 @@
this.rTBLineNumbers.Name = "rTBLineNumbers";
this.rTBLineNumbers.ReadOnly = true;
this.rTBLineNumbers.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None;
this.rTBLineNumbers.Size = new System.Drawing.Size(38, 470);
this.rTBLineNumbers.Size = new System.Drawing.Size(39, 470);
this.rTBLineNumbers.TabIndex = 1;
this.rTBLineNumbers.TabStop = false;
this.rTBLineNumbers.Text = "";
......@@ -497,14 +519,14 @@
this.dGVRegisters.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.cRegisters,
this.cValues});
dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle6.BackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle6.ForeColor = System.Drawing.SystemColors.ControlText;
dataGridViewCellStyle6.SelectionBackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle6.SelectionForeColor = System.Drawing.SystemColors.ControlText;
dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dGVRegisters.DefaultCellStyle = dataGridViewCellStyle6;
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.ControlText;
dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.ControlText;
dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dGVRegisters.DefaultCellStyle = dataGridViewCellStyle3;
this.dGVRegisters.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter;
this.dGVRegisters.Location = new System.Drawing.Point(0, 0);
this.dGVRegisters.MultiSelect = false;
......@@ -520,8 +542,8 @@
// cRegisters
//
this.cRegisters.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
this.cRegisters.DefaultCellStyle = dataGridViewCellStyle4;
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
this.cRegisters.DefaultCellStyle = dataGridViewCellStyle1;
this.cRegisters.HeaderText = "Register";
this.cRegisters.MaxInputLength = 10;
this.cRegisters.Name = "cRegisters";
......@@ -533,8 +555,8 @@
// cValues
//
this.cValues.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
this.cValues.DefaultCellStyle = dataGridViewCellStyle5;
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
this.cValues.DefaultCellStyle = dataGridViewCellStyle2;
this.cValues.HeaderText = "Value";
this.cValues.MaxInputLength = 15;
this.cValues.Name = "cValues";
......@@ -568,28 +590,6 @@
this.checkSyntaxToolStripMenuItem.Size = new System.Drawing.Size(32, 19);
this.checkSyntaxToolStripMenuItem.Text = "Check Syntax";
//
// undoToolStripMenuItem
//
this.undoToolStripMenuItem.Name = "undoToolStripMenuItem";
this.undoToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z)));
this.undoToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
this.undoToolStripMenuItem.Text = "Undo";
this.undoToolStripMenuItem.Click += new System.EventHandler(this.undoToolStripMenuItem_Click);
//
// redoToolStripMenuItem
//
this.redoToolStripMenuItem.Name = "redoToolStripMenuItem";
this.redoToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
| System.Windows.Forms.Keys.Z)));
this.redoToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
this.redoToolStripMenuItem.Text = "Redo";
this.redoToolStripMenuItem.Click += new System.EventHandler(this.redoToolStripMenuItem_Click);
//
// toolStripSeparator6
//
this.toolStripSeparator6.Name = "toolStripSeparator6";
this.toolStripSeparator6.Size = new System.Drawing.Size(184, 6);
//
// MainGUI
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
......
......@@ -489,7 +489,7 @@ namespace LWSimulatorGUI
int currentSelect = fCTBProgram.SelectionStart;
int currentSelectLength = fCTBProgram.SelectionLength;
this.SuspendLayout();
/*
// Incredibly complicated replacement because "fCTBProgram.rtf = tmpRTB.rtf;" does change the rtf in Mono
// (e.g. adds a newline to the very end and "succ(0)" would mark "succ(0" in blue instead of the correct "succ")
tmpRTB.AcceptsTab = true;
......@@ -518,17 +518,19 @@ namespace LWSimulatorGUI
fCTBProgram.TextChanged -= fCTBProgram_TextChanged;
this.spCMainGUI.Panel1.Controls.Remove(this.fCTBProgram);
fCTBProgram = tmpRTB;
this.spCMainGUI.Panel1.Controls.Add(fCTBProgram);
this.spCMainGUI.Panel1.Controls.Add(fCTBProgram);*/
this.PerformLayout();
this.ResumeLayout();
fCTBProgram.SuspendLayout();
if (focused)
fCTBProgram.Focus();
fCTBProgram.Rtf = tmpRTB.Rtf;
fCTBProgram.Select(currentSelect, currentSelectLength);
AddLineNumbers();
fCTBProgram.PerformLayout();
fCTBProgram.ResumeLayout();
this.PerformLayout();
this.ResumeLayout();
dirty = dirtyTmp;
refreshTitle();
}
......@@ -598,6 +600,7 @@ namespace LWSimulatorGUI
currentIndex = matches[i].Item1.Index + matches[i].Item1.Length;
}
tmpRTB.AppendText(currentProgram.Substring(currentIndex));
//File.WriteAllText("./DebugInfo.deb", EscapeForCSharp(tmpRTB.Rtf));
bool dirtyTmp = dirty;
bool focused = fCTBProgram.Focused;
/*int toScrollChar;
......@@ -627,8 +630,7 @@ namespace LWSimulatorGUI
tmpRTB.PerformLayout();
int currentSelect = fCTBProgram.SelectionStart;
int currentSelectLength = fCTBProgram.SelectionLength;
// Mono automatically scrolls the selected line to the very bottom if "Select" is used
// Change size, so the line we want is the bottom line
Point line = tmpRTB.GetPositionFromCharIndex(tmpRTB.SelectionStart);
......@@ -656,15 +658,20 @@ namespace LWSimulatorGUI
fCTBProgram = tmpRTB;
this.spCMainGUI.Panel1.Controls.Add(fCTBProgram);
this.PerformLayout();
this.ResumeLayout();
fCTBProgram.SuspendLayout();*/
*/
int currentSelect = fCTBProgram.SelectionStart;
int currentSelectLength = fCTBProgram.SelectionLength;
this.SuspendLayout();
fCTBProgram.SuspendLayout();
fCTBProgram.Rtf = tmpRTB.Rtf;
fCTBProgram.Select(currentSelect, currentSelectLength);
if (focused)
fCTBProgram.Focus();
AddLineNumbers();
fCTBProgram.PerformLayout();
fCTBProgram.ResumeLayout();
this.PerformLayout();
this.ResumeLayout();
dirty = dirtyTmp;
refreshTitle();
}
......
......@@ -113,11 +113,13 @@ namespace LWSimulatorGUI
if(!simulator.setLogDir(tBDirPath.Text))
unableOptions.Add("-Path to where to save logs");
if (nUDSteps.Enabled)
if(!simulator.setOptionVal("maxStepAm", (long)nUDSteps.Value))
{
if (!simulator.setOptionVal("maxStepAm", (long)nUDSteps.Value))
unableOptions.Add("-Maximum numbers of step before automatic pause");
}
else
if(!simulator.setOptionVal("maxStepAm", -(long)nUDSteps.Value))
unableOptions.Add("-Maximum numbers of step before automatic pause");
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()));
......
......@@ -14,6 +14,7 @@ namespace MainLWSimulator
private volatile Dictionary<string, long> optionVals = new Dictionary<string, long>();
private volatile string logDirectory = String.Empty;
private bool enableSaveOptions = true;
internal bool onUnix;
// Hard limit for options
private Dictionary<string, bool> ALLOWRUNNINGCHANGE = new Dictionary<string, bool>(); // allow changing the value during run
......@@ -108,6 +109,9 @@ namespace MainLWSimulator
public LWCoordinator(bool saveOptEnabled)
{
int platform = (int)Environment.OSVersion.Platform;
if (platform == 4 || platform == 6 || platform == 128)
onUnix = true;
enableSaveOptions = saveOptEnabled;
optionFilePath = AppDomain.CurrentDomain.BaseDirectory + "lwsimulator_options";
setHardLimits();
......
......@@ -21,7 +21,7 @@ namespace MainLWSimulator
this.parent = parent;
defVal = parent.getOptionVal("defRegVal");
int amReg = Math.Min(30, (int)parent.getOptionVal("maxRegAm"));
registers = Enumerable.Repeat<long>(defVal, amReg).ToList();
registers = Enumerable.Repeat<long>(defVal, amReg).ToList();
}
internal LWRegisters(LWCoordinator parent, long maxVal) : this(parent)
......@@ -285,8 +285,18 @@ namespace MainLWSimulator
parent.writeLogMessage("ERROR: When inserting Registers, the total number of registers would have been greater than allowed.");
return false;
}
registers.InsertRange(position,Enumerable.Repeat<long>(value, count).ToList());
if (parent.onUnix)
{
for (int i = 0; i < count; i++)
{
registers.Insert(position + i, value);
registers[position + i] = value;
}
}
else
{
registers.InsertRange(position, Enumerable.Repeat<long>(value, count));
}
updateRange(position, registers.Count + count - position);
}
return true;
......@@ -332,9 +342,18 @@ namespace MainLWSimulator
return true;
List<long> tempList = registers.GetRange(position, amountRegisters);
parent.writeLogMessage(tempList.Count.ToString());
registers.RemoveRange(position, amountRegisters);
registers.InsertRange(position + shiftAmount, tempList);
if (parent.onUnix)
{
for (int i = 0; i < amountRegisters; i++)
{
registers[position + shiftAmount + i] = tempList[i];
}
}
int startUpdatePos = position;
if (shiftAmount < 0)
startUpdatePos = position + shiftAmount;
......
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