From 36aa6f0883dcae55283991d6a65fcd81da0fa87c Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Thu, 23 Jan 2025 17:58:12 +0100 Subject: [PATCH] improve smart_diff_utrace.html Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- devtools/smart_diff_utrace.html | 55 ++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/devtools/smart_diff_utrace.html b/devtools/smart_diff_utrace.html index 61a92e7165..d53663e765 100644 --- a/devtools/smart_diff_utrace.html +++ b/devtools/smart_diff_utrace.html @@ -8,7 +8,7 @@ font-family: monospace; padding: 20px; background-color: #f5f5f5; - max-width: 1200px; + max-width: 2000px; margin: 0 auto; } @@ -18,11 +18,13 @@ } #input-area { + display: flex; + gap: 20px; margin-bottom: 20px; } #input-area textarea { - width: 100%; + flex: 1; height: 150px; margin-bottom: 10px; font-family: monospace; @@ -30,13 +32,15 @@ } button { + display: block; + width: 200px; + margin: 0 auto 20px; padding: 8px 16px; background-color: #4CAF50; color: white; border: none; border-radius: 4px; cursor: pointer; - margin-bottom: 20px; } button:hover { @@ -57,6 +61,25 @@ box-shadow: 0 2px 4px rgba(0,0,0,0.1); white-space: pre; overflow-x: auto; + position: relative; + } + + .line-numbers { + position: absolute; + left: 0; + top: 0; + bottom: 0; + width: 30px; + background-color: #f0f0f0; + border-right: 1px solid #ddd; + text-align: right; + padding: 5px 5px 5px 0; + color: #666; + user-select: none; + } + + .content-area { + margin-left: 35px; } .function-block { @@ -126,8 +149,8 @@
-
+
@@ -138,23 +161,27 @@ function processTrace(trace, otherTrace, resultId) { const lines = trace.trim().split('\n'); const otherLines = otherTrace.trim().split('\n'); - let html = ''; + let contentHtml = ''; + let lineNumbersHtml = ''; let indentLevel = 0; let blockStartLine = -1; + // Generate line numbers + for (let i = 1; i <= lines.length; i++) { + lineNumbersHtml += `${i}\n`; + } + for (let i = 0; i < lines.length; i++) { const line = lines[i].trim(); const shouldHighlight = !otherLines.some(otherLine => otherLine.trim() === line); const highlightClass = shouldHighlight ? 'highlight' : ''; - // Check if this line is the start of a block that has content const isBlockStart = line.endsWith('{') && i < lines.length - 1; if (isBlockStart) { blockStartLine = i; - // Start of a function block with content const functionName = line; - html += `
+ contentHtml += `
${functionName} @@ -162,25 +189,23 @@
`; indentLevel++; } else if (line.includes('}')) { - // End of a block if (indentLevel > 0) { indentLevel--; - html += `
${line}
`; + contentHtml += `
${line}
`; } else { - html += `
${line}
`; + contentHtml += `
${line}
`; } } else { - // Regular line or a line ending with { at the end of input const isLastLineBlock = line.endsWith('{') && i === lines.length - 1; if (isLastLineBlock) { - html += `
${line}
`; + contentHtml += `
${line}
`; } else { - html += `
${line}
`; + contentHtml += `
${line}
`; } } } - return html; + return `
${lineNumbersHtml}
${contentHtml}
`; } function initializeCollapsible(containerId) {