Skip to content

Commit 914726c

Browse files
committed
Bugfixes in generating datadictionary csv
Bugfixes in generating datadictionary csv, and make highlighting button wider for issue #80
1 parent af1efd8 commit 914726c

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

CSVLintNppPlugin/CsvLint/CsvGenerateCode.cs

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,22 @@ public static void GenerateDatadictionaryCSV(CsvDefinition csvdef)
211211
INotepadPPGateway notepad = new NotepadPPGateway();
212212
IScintillaGateway editor = new ScintillaGateway(PluginBase.GetCurrentScintilla());
213213

214+
CsvDefinition datadict = new CsvDefinition(',');
215+
216+
datadict.AddColumn("Nr", 8, ColumnType.Integer);
217+
datadict.AddColumn("ColumnName", 1000, ColumnType.String);
218+
datadict.AddColumn("DataType", 1000, ColumnType.String);
219+
datadict.AddColumn("Width", 8, ColumnType.Integer);
220+
datadict.AddColumn("Decimals", 8, ColumnType.Integer);
221+
datadict.AddColumn("Mask", 1000, ColumnType.String);
222+
datadict.AddColumn("Enumeration", 9999, ColumnType.String);
223+
214224
string FILE_NAME = Path.GetFileName(notepad.GetCurrentFilePath());
215225
var separator = (csvdef.Separator == '\0' ? "{fixed-width}" : csvdef.Separator.ToString());
216226
if (separator == "\t") separator = "\\t";
217227

218228
StringBuilder csvmeta = new StringBuilder();
229+
List<string> sl = new List<string>();
219230

220231
// build CSV
221232
csvmeta.Append("Nr,ColumnName,DataType,Width,Decimals,Mask,Enumeration\r\n");
@@ -249,13 +260,20 @@ public static void GenerateDatadictionaryCSV(CsvDefinition csvdef)
249260
};
250261

251262
// enumeration
252-
if (coldef.isCodedValue)
253-
{
254-
enumvals = string.Join("|", coldef.CodedList);
255-
enumvals = string.Format("\"{0}\"", enumvals); // use quotes
256-
}
257-
258-
csvmeta.Append(string.Format("{0},\"{1}\",{2},{3},{4},{5},{6}\r\n", (c + 1), coldef.Name, dattyp, colwid, dec, mask, enumvals));
263+
if (coldef.isCodedValue) enumvals = string.Join("|", coldef.CodedList);
264+
265+
// add values as columns
266+
sl.Clear();
267+
sl.Add((c + 1).ToString()); // Nr
268+
sl.Add(coldef.Name); // ColumnName
269+
sl.Add(dattyp); // DataType
270+
sl.Add(colwid); // Width
271+
sl.Add(dec); // Decimals
272+
sl.Add(mask); // Mask
273+
sl.Add(enumvals); // Enumeration
274+
275+
// Construct/format csv line
276+
csvmeta.Append(string.Format("{0}\r\n", datadict.ConstructLine(sl, false)));
259277
}
260278

261279
// create new file

CSVLintNppPlugin/PluginInfrastructure/SettingsBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ public void ShowDialog()
256256
Name = "Colors",
257257
Text = "Highlighting",
258258
Anchor = AnchorStyles.Bottom | AnchorStyles.Left,
259-
Size = new Size(100, 23),
259+
Size = new Size(128, 23),
260260
Location = new Point(13, DEFAULT_HEIGHT - 23 - 13),
261261
UseVisualStyleBackColor = true,
262262
//ContextMenu = cm
Binary file not shown.
1 KB
Binary file not shown.

0 commit comments

Comments
 (0)