Skip to content

Commit

Permalink
Merge branch 'SICDudesCodeEditor' of https://github.com/ScottPiersall…
Browse files Browse the repository at this point in the history
…/SICVM into SICDudesCodeEditor
  • Loading branch information
Kilo640 committed Nov 28, 2024
2 parents 1592fd8 + 883657e commit 39df520
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
2 changes: 1 addition & 1 deletion SIC Simulator/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 34 additions & 11 deletions SIC Simulator/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -668,21 +668,28 @@ private void tsmOpen_SIC_Object_File_Click(object sender, EventArgs e) {

}

/*
* Loads in SIC assembly code from a file
* Passes the code through an assembler
* Prompts the User for loading preference (absolute or relocating)
*/
private void tsmloadAndAssembleSICSourceFIle_Click(object sender, EventArgs e) {
/// <summary>
/// Event handler for loading a SIC source file.
/// Displays the file content in the code editor tab.
/// Stores the file name for further usage.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">An EventArgs object containing event data.</param>
private void tsmloadSICSourceFIle_Click(object sender, EventArgs e) {
if (loadSICSourceFD.ShowDialog() == DialogResult.OK) {
//Add file text to code editor.
StreamReader fileRead = new StreamReader(loadSICSourceFD.FileName);
this.txtCodeEditor.Text = fileRead.ReadToEnd();
fileRead.Close();
this.LastLoadedFileName = (loadSICSourceFD.FileName);
}
}//END tsmloadAndAssembleSICSourceFIle_Click()
}//END tsmloadSICSourceFIle_Click()

/// <summary>
/// Assembles the SIC source file and prepares it for loading into the virtual machine.
/// Prompts the user for loading preference (absolute or relocating)
/// </summary>
/// <param name="filename">The name of the SIC source file to assemble.</param>
public void assembleSicFile(string filename) {
Assembler assembler = new Assembler(filename);
this.SICVirtualMachine.getSICSource(assembler);
Expand Down Expand Up @@ -720,7 +727,7 @@ public void assembleSicFile(string filename) {

}
this.RefreshCPUDisplays(); // refresh memory after object code is loaded
}
}//END assembleSICFile()

/*
* Handles the portion of the T-record that doesn't corresspond to memory
Expand Down Expand Up @@ -1261,13 +1268,19 @@ private void assembleCurrentFileToolStripMenuItem_Click(object sender, EventArgs
}



/// <summary>
/// Event handler.
/// Saves the current SIC source file from the text editor tab.
/// If no file is was loaded in, prompts the user to save as a new file.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The event arguments.</param>
private void saveSICSourceFileToolStripMenuItem_Click(object sender, EventArgs e) {
if (string.IsNullOrEmpty(this.LastLoadedFileName)) {
// prompt for "Save As" if no file has been loaded
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "SIC Source Files|*.sic";
saveFileDialog.Title = "Save SIC Source File";
saveFileDialog.Title = "Save current SIC Source File";
if (saveFileDialog.ShowDialog() == DialogResult.OK) {
this.LastLoadedFileName = saveFileDialog.FileName;
try {
Expand All @@ -1291,13 +1304,23 @@ private void saveSICSourceFileToolStripMenuItem_Click(object sender, EventArgs e
}
}
}

/// <summary>
/// Writes the contents of the code editor to specified file.
/// </summary>
/// <param name="filename">the file the editor contents will be saved to.</param>
private void saveEditorContents(string filename) {
StreamWriter fileWrite = new StreamWriter(filename);
fileWrite.Write(this.txtCodeEditor.Text);
fileWrite.Close();
}

/// <summary>
/// Event handler from tool strip menu.
/// Used to save the current editor contents as a NEW SIC source file.
/// The user is prompted to specify the file name and locaton.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The event arguments.</param>
private void saveNewSICSourceFileToolStripMenuItem_Click(object sender, EventArgs e) {
// prompt for "Save As"
SaveFileDialog saveFileDialog = new SaveFileDialog();
Expand Down

0 comments on commit 39df520

Please sign in to comment.