aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSan Jacobs2025-06-06 16:54:45 +0200
committerSan Jacobs2025-06-06 16:54:45 +0200
commitae16415f838b08ab5ebe1c39717981c1fd31201e (patch)
treec2abc9c768f549f4444ca4b8510add1e5ae99c48
parentae05fbb170dc316a0404783edecf62c0c9565150 (diff)
downloadbetter-report-ae16415f838b08ab5ebe1c39717981c1fd31201e.tar.gz
better-report-ae16415f838b08ab5ebe1c39717981c1fd31201e.tar.bz2
better-report-ae16415f838b08ab5ebe1c39717981c1fd31201e.zip
Automatically move redundant columns to info lines
-rw-r--r--.gitignore3
-rwxr-xr-xmain.odin50
-rwxr-xr-xparts/start2.html2
3 files changed, 43 insertions, 12 deletions
diff --git a/.gitignore b/.gitignore
index 5a6bb77..6bc84f3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
*.pdb
-*.exe \ No newline at end of file
+*.exe
+*.html \ No newline at end of file
diff --git a/main.odin b/main.odin
index 7887b67..139bfb5 100755
--- a/main.odin
+++ b/main.odin
@@ -7,7 +7,7 @@ import "core:sys/windows"
import "core:strings"
/*
-TODO: Move info that stays the same throughout the table up to the info header
+TODO: Support Sound Devices CSVs again
*/
VERBOSE :: false
@@ -41,6 +41,7 @@ Report :: struct {
table : [][]string,
column_count : int,
row_count : int,
+ info_line_count : int,
tc_column_index : int,
}
@@ -139,7 +140,10 @@ parse :: proc(path : string, device : Device = .UNSET) -> (Report, bool) {
// Measuring content for allocation
if device == .ZOOM {
output.column_count = 21 // Ugly magic number, could be fucked by firmware update
- output.info_lines = make([]Info_Line, 2, context.temp_allocator)
+
+ // Padded for expanding info lines from unchanging columns
+ output.info_lines = make([]Info_Line, 2+output.column_count, context.temp_allocator)
+ output.info_line_count = 2
output.row_count = strings.count(string(data), "\n") - 7 // Ugly magic number, could be fucked by firmware update
output.table = make([][]string, output.row_count, context.temp_allocator)
@@ -262,8 +266,10 @@ parse :: proc(path : string, device : Device = .UNSET) -> (Report, bool) {
}
}
+
// Cleaning out unused columns
touched := make([]bool, output.column_count, context.temp_allocator)
+ // Finding them
for line, l in output.table {
for field, f in line {
if touched[f] do continue
@@ -272,10 +278,37 @@ parse :: proc(path : string, device : Device = .UNSET) -> (Report, bool) {
}
}
}
+
+ // Turning unchanging columns into info line
+ changed := make([]bool, output.column_count, context.temp_allocator)
+ prev_line : []string = nil
+ for line, l in output.table {
+ if l>0 {
+ prev_line = output.table[l - 1]
+ for field, f in line {
+ if (prev_line[f] != field) ||
+ (first_channel_index <= f && f <= last_channel_index) ||
+ (f == output.tc_column_index) {
+ changed[f] = true
+ }
+ }
+ }
+ }
+ for did_change, i in changed {
+ if (!did_change) && touched[i] {
+ field := fmt.aprintf("{}: ", output.header[i], allocator=context.temp_allocator)
+ entry := prev_line[i]
+ output.info_lines[output.info_line_count] = {field=field, entry=entry}
+ output.info_line_count += 1
+ }
+ }
+
+
+ // Removing unused and static
for &line, l in output.table {
stacking_index := 0
for &field, f in line {
- if touched[f] {
+ if touched[f] && changed[f] {
line[stacking_index] = field
stacking_index += 1
}
@@ -286,7 +319,7 @@ parse :: proc(path : string, device : Device = .UNSET) -> (Report, bool) {
}
stacking_index := 0
for &field, f in output.header {
- if touched[f] {
+ if touched[f] && changed[f] {
output.header[stacking_index] = field
stacking_index += 1
}
@@ -294,11 +327,8 @@ parse :: proc(path : string, device : Device = .UNSET) -> (Report, bool) {
for &field, f in output.header[stacking_index:] {
field = ""
}
- new_column_count := 0
- for b in touched {
- if b do new_column_count+=1
- }
- output.column_count = new_column_count
+
+ output.column_count = stacking_index
if VERBOSE do fmt.printf("Struct before output:\n%#v\n", output)
@@ -317,7 +347,7 @@ render :: proc(report : Report, path : string) {
strings.write_string(&builder, PART_TWO)
- for line, l in report.info_lines {
+ for line, l in report.info_lines[:report.info_line_count] {
strings.write_string(&builder, " <p><b>")
strings.write_string(&builder, line.field)
strings.write_string(&builder, "</b> ")
diff --git a/parts/start2.html b/parts/start2.html
index 825bde9..a357cb7 100755
--- a/parts/start2.html
+++ b/parts/start2.html
@@ -98,6 +98,6 @@
</svg>
</a>
<h1 style="width:max-content;margin:auto;">Lydrapport</h1>
- <h6 style="width:max-content;margin:auto;">Version 0.6</h6>
+ <h6 style="width:max-content;margin:auto;">Version 0.8</h6>
</div>
<div class="info-section">