1
0
mirror of https://github.com/fadden/6502bench.git synced 2025-07-16 03:24:08 +00:00

Implement text export

This feature "exports" the source code in the same format it appears
in on screen.  The five columns on the left are optional, the four
on the right can be resized.  Exported text can span the entire file
or just the current selection.  Output can be plain text or CSV.
(I still haven't figured out a good use for CSV.)

The old copy-to-clipboard function is now implemented via the export
mechanism.

This adds a new clipboard mode that includes all columns.  Potentially
useful for filing bug reports against SourceGen.
This commit is contained in:
Andy McFadden
2019-09-12 13:57:52 -07:00
parent e5104dc2e7
commit 81157b6b47
9 changed files with 638 additions and 112 deletions

View File

@@ -185,7 +185,8 @@ namespace SourceGen {
public enum ClipLineFormat {
Unknown = -1,
AssemblerSource = 0,
Disassembly = 1
Disassembly = 1,
AllColumns = 2
}
/// <summary>
@@ -1291,14 +1292,29 @@ namespace SourceGen {
/// </summary>
public void CopyToClipboard() {
DisplayListSelection selection = mMainWin.CodeDisplayList.SelectedIndices;
if (selection.Count == 0) {
Debug.WriteLine("Selection is empty!");
return;
}
ClipLineFormat format = (ClipLineFormat)AppSettings.Global.GetEnum(
AppSettings.CLIP_LINE_FORMAT,
typeof(ClipLineFormat),
(int)ClipLineFormat.AssemblerSource);
Exporter eport = new Exporter(mProject, CodeLineList, mOutputFormatter);
eport.SelectionToText(selection, format, true,
out string fullText, out string csvText);
int[] rightWidths = new int[] { 9, 8, 11, 100 };
Exporter.ActiveColumnFlags colFlags = Exporter.ActiveColumnFlags.None;
if (format == ClipLineFormat.Disassembly) {
colFlags |= Exporter.ActiveColumnFlags.Address |
Exporter.ActiveColumnFlags.Bytes;
} else if (format == ClipLineFormat.AllColumns) {
colFlags = Exporter.ActiveColumnFlags.ALL;
}
Exporter eport = new Exporter(mProject, CodeLineList, mOutputFormatter,
colFlags, rightWidths);
eport.Selection = selection;
eport.SelectionToString(true, out string fullText, out string csvText);
DataObject dataObject = new DataObject();
dataObject.SetText(fullText.ToString());
@@ -1954,12 +1970,45 @@ namespace SourceGen {
}
public void Export() {
Export dlg = new Export(mMainWin);
string outName;
if (string.IsNullOrEmpty(mProjectPathName)) {
outName = Path.GetFileName(mDataPathName);
} else {
outName = Path.GetFileName(mProjectPathName);
}
Export dlg = new Export(mMainWin, outName);
if (dlg.ShowDialog() == false) {
return;
}
// TODO
int[] rightWidths = new int[] {
dlg.AsmLabelColWidth, dlg.AsmOpcodeColWidth,
dlg.AsmOperandColWidth, dlg.AsmCommentColWidth
};
Exporter eport = new Exporter(mProject, CodeLineList, mOutputFormatter,
dlg.ColFlags, rightWidths);
eport.IncludeNotes = dlg.IncludeNotes;
if (dlg.SelectionOnly) {
DisplayListSelection selection = mMainWin.CodeDisplayList.SelectedIndices;
if (selection.Count == 0) {
// no selection == select all
selection = null;
}
eport.Selection = selection;
}
try {
Mouse.OverrideCursor = Cursors.Wait;
if (dlg.GenType == WpfGui.Export.GenerateFileType.Html) {
eport.OutputToHtml(dlg.PathName, dlg.OverwriteCss);
} else {
eport.OutputToText(dlg.PathName, dlg.TextModeCsv);
}
} finally {
Mouse.OverrideCursor = null;
}
}
public void Find() {