From 6e0a46a24ced64678f4fa7c404142abdaf6c3cdb Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sat, 10 Apr 2021 09:43:35 +0200 Subject: [PATCH] Enable previous/next search in debug log --- .../macOS/Base.lproj/Preferences.storyboard | 15 ++++---- .../Preferences/DebugLogViewController.swift | 38 +++++++++++-------- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/Passepartout/App/macOS/Base.lproj/Preferences.storyboard b/Passepartout/App/macOS/Base.lproj/Preferences.storyboard index 17c51221..60e0f250 100644 --- a/Passepartout/App/macOS/Base.lproj/Preferences.storyboard +++ b/Passepartout/App/macOS/Base.lproj/Preferences.storyboard @@ -119,7 +119,7 @@ - - - - + - + diff --git a/Passepartout/App/macOS/Scenes/Preferences/DebugLogViewController.swift b/Passepartout/App/macOS/Scenes/Preferences/DebugLogViewController.swift index 2f8aeef2..bb6ece79 100644 --- a/Passepartout/App/macOS/Scenes/Preferences/DebugLogViewController.swift +++ b/Passepartout/App/macOS/Scenes/Preferences/DebugLogViewController.swift @@ -66,15 +66,8 @@ class DebugLogViewController: NSViewController { labelExchangedCaption.stringValue = L10n.Core.Service.Cells.DataCount.caption.asCaption labelLog.stringValue = L10n.Core.Service.Cells.DebugLog.caption.asCaption -// scrollTextLog.scrollerStyle = .overlay -// scrollTextLog.autohidesScrollers = false - if #available(macOS 10.12.2, *) { - buttonPrevious.image = NSImage(named: NSImage.touchBarRewindTemplateName) - buttonNext.image = NSImage(named: NSImage.touchBarFastForwardTemplateName) - } else { - buttonPrevious.title = L10n.Core.DebugLog.Buttons.previous - buttonNext.title = L10n.Core.DebugLog.Buttons.next - } + buttonPrevious.image = NSImage(named: NSImage.touchBarRewindTemplateName) + buttonNext.image = NSImage(named: NSImage.touchBarFastForwardTemplateName) buttonShare.image = NSImage(named: NSImage.shareTemplateName) let nc = NotificationCenter.default @@ -136,15 +129,30 @@ class DebugLogViewController: NSViewController { } @IBAction private func previousSession(_ sender: Any?) { - // FIXME -// textFinderLog.performAction(.previousMatch) -// textLog.findPrevious(string: GroupConstants.Log.sessionMarker) + let visibleRow = firstVisibleRow() + let viewport = logLines[0.. Int { + let range = tableTextLog.rows(in: tableTextLog.visibleRect) + return range.location + } + + private func lastVisibleRow() -> Int { + let range = tableTextLog.rows(in: tableTextLog.visibleRect) + return range.location + range.length } private func startRefreshingLog() {