Add filter functionality to debug log screen.

This commit is contained in:
lisa-signal
2025-08-05 15:05:18 -04:00
committed by Cody Henthorne
parent f8b18b6ea9
commit 57454a2661
4 changed files with 100 additions and 19 deletions

View File

@@ -52,11 +52,13 @@ editor.session.on("changeScrollLeft", showScrollBar);
const Range = ace.require("ace/range").Range;
const session = editor.getSession();
let logLines = ""; // Original logLines
let input = ""; // Search query input
let markers = []; // IDs of highlighted search markers
let matchRanges = []; // Ranges of all search matches
let matchCount = 0; // Total number of matches
let isCaseSensitive = false;
let isFiltered = false;
// Clear all search markers and match info
function clearMarkers() {
@@ -139,10 +141,34 @@ function onSearchClose() {
function onToggleCaseSensitive() {
isCaseSensitive = !isCaseSensitive;
highlightAllMatches(input);
(isFiltered) ? onFilter() : highlightAllMatches(input);
}
function onSearchInput(value) {
input = value;
}
function onSearch() {
highlightAllMatches(input);
}
function onFilter() {
isFiltered = true;
editor.getSelection().clearSelection();
clearMarkers();
const filtered = logLines
.split("\n")
.filter((line) => {
const newLine = isCaseSensitive ? line : line.toLowerCase();
return newLine.includes(isCaseSensitive ? input : input.toLowerCase());
})
.join("\n");
editor.setValue(filtered, -1);
}
function onFilterClose() {
isFiltered = false;
editor.setValue(logLines, -1);
highlightAllMatches(input);
}

View File

@@ -47,7 +47,7 @@ object DebugLogsViewer {
fun presentLines(webview: WebView, lines: String) {
// Set the debug log lines
val escaped = JSONObject.quote(lines)
webview.evaluateJavascript("editor.insert($escaped);", null)
webview.evaluateJavascript("editor.insert($escaped); logLines=$escaped;", null)
}
@JvmStatic
@@ -61,10 +61,25 @@ object DebugLogsViewer {
}
@JvmStatic
fun onSearch(webview: WebView, query: String) {
fun onSearchInput(webview: WebView, query: String) {
webview.evaluateJavascript("onSearchInput('$query')", null)
}
@JvmStatic
fun onSearch(webview: WebView) {
webview.evaluateJavascript("onSearch()", null)
}
@JvmStatic
fun onFilter(webview: WebView) {
webview.evaluateJavascript("onFilter()", null)
}
@JvmStatic
fun onFilterClose(webview: WebView) {
webview.evaluateJavascript("onFilterClose()", null)
}
@JvmStatic
fun onSearchUp(webview: WebView) {
webview.evaluateJavascript("onSearchUp();", null)
@@ -90,10 +105,6 @@ object DebugLogsViewer {
webview.evaluateJavascript("onSearchClose();", null)
}
@JvmStatic
fun onFilter(webview: WebView) {
}
@JvmStatic
fun onEdit(webview: WebView) {
readOnly = !readOnly