Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ install -m 644 wdx/mediainfo/luajit/*.lua release/wdx/mediainfo/
install -m 644 wdx/translitwdx/translitwdx.lua release/wdx/translitwdx/
install -m 644 wdx/translitwdx/readme.txt release/wdx/translitwdx/


# logview
mkdir -p release/wlx/logview
mkdir -p wlx/logview/build
(cd wlx/logview/build && cmake .. && make)
install -m 644 wlx/logview/build/logviewer_wlx.wlx release/wlx/logview/
install -m 644 wlx/logview/*.md release/wlx/logview/
install -m 644 wlx/logview/*.png release/wlx/logview/

pushd release
tar -czpf ../plugins-$(date +%y.%m.%d)-$ARCH.tar.gz *
popd
41 changes: 41 additions & 0 deletions wlx/logview/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
cmake_minimum_required(VERSION 3.16)
project(wlx-log-viewer LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Required for Q_OBJECT macro — generates moc files for vtable/signal-slot metadata
set(CMAKE_AUTOMOC ON)

# Visibility hidden by default as requested in spec
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)

find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
find_package(re2 REQUIRED)

# Need Qt6::WaylandClient? If not just Widgets and Core
# For inotify, it's native linux.

# Build the shared library (WLX plugin)
add_library(logviewer_wlx SHARED
src/wlx_plugin.cpp
src/LogViewerWidget.cpp
src/LogModel.cpp
)

set_target_properties(logviewer_wlx PROPERTIES
PREFIX ""
SUFFIX ".wlx"
)

target_link_libraries(logviewer_wlx PRIVATE
Qt6::Core
Qt6::Gui
Qt6::Widgets
re2::re2
)

# Only export specific functions
# This is usually handled by `extern "C" __attribute__((visibility("default")))` in the code,
# combined with the hidden preset.
55 changes: 55 additions & 0 deletions wlx/logview/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# WLX Log Viewer Plugin for Double Commander

A high-performance, Wayland-compatible WLX (Lister) log viewer plugin for Double Commander, built with Qt6 and C++20. Designed specifically to handle large log files seamlessly while providing fast searching and filtering capabilities without freezing the host application.

![Screenshot](logviewer.png)

## Features

- **Zero-Copy File Loading**: Utilizes `mmap` and line-offset indexing to instantly load massive log files with extremely low memory overhead.
- **Fast Regex Searching**: Powered by Google's `RE2` regex engine. Searches are offloaded to a background `std::jthread` to keep the UI fully responsive.
- **Timestamp Range Filtering**: Automatically detects and parses common timestamp formats (ISO 8601, nginx, syslog). Allows filtering log lines within a specific date/time range.
- **Live Tailing (Follow Mode)**: Monitors the file for changes using `QFileSystemWatcher` (inotify-based) and automatically updates and scrolls to new entries.
- **Advanced Filtering**: Implements `QSortFilterProxyModel` for combining regex matches and timestamp ranges efficiently.
- **Native Interactions**: Supports standard file manager interactions, including multi-row selection (Ctrl+click, Shift+click) and copying (Ctrl+C, Right-click context menu).
- **Wayland Focus Isolation**: Implements a robust 4-layer focus defense architecture to resolve Wayland focus-hijacking bugs typical when embedding Qt components into Lazarus applications:
- **Layer 0**: Deferred `show()` execution to prevent the plugin from trapping the host's `MouseRelease` event (fixes the "phantom-drag" issue).
- **Layer 1**: Aggressive `Qt::NoFocus` policy applied to the base container.
- **Layer 2**: Recursive focus guard that strips focus capabilities from all non-input child widgets.
- **Layer 3**: Cross-load focus preservation (saves the currently focused Double Commander widget state and restores it after loading completes).
- **Layer 4**: Global `FocusIn` event interceptor that immediately yanks stolen focus back to Double Commander, unless an input field is explicitly clicked by the user.

## Dependencies

To build this plugin, the following packages and libraries are required:

- **C++20** compatible compiler (GCC or Clang)
- **CMake** (3.16 or higher)
- **Qt 6** development packages (Core, Gui, Widgets)
- **RE2** regular expression library (`libre2-dev` on Debian/Ubuntu)

## Build Instructions

1. Clone or navigate to the plugin directory.
2. Create a build directory and configure with CMake:
```bash
mkdir build
cd build
cmake ..
```
3. Compile the plugin:
```bash
make -j$(nproc)
```
4. Install the compiled `.wlx` file to your Double Commander WLX plugins directory:
```bash
cp logviewer_wlx.wlx ~/.config/doublecmd/plugins/wlx/
```

## Installation in Double Commander

1. Open Double Commander.
2. Go to **Configuration** > **Options** > **Plugins** > **WLX (Lister)**.
3. Click **Add** and select the installed `logviewer_wlx.wlx` file.
4. The plugin automatically registers the following extensions: `.log`, `.out`, `.err`, `.ndjson`, `.jsonl`, `.1`, `.2`, and `.old`. You can adjust this "Detect string" in Double Commander's options if you want it to automatically trigger on other extensions.
5. Apply and close. Select a log file and press `F3` or `Ctrl+Q` (Quick View) to use. For files without an extension (like `/var/log/syslog`), select the file and press `F3`.
Loading