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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
gdk-pixbuf2 glycin libheif libwebp librsvg libpng \
tomlplusplus acl libarchive xz curl libxml2 \
nlohmann-json stb \
python ffmpeg ffmpegthumbnailer poppler 7zip \
python ffmpeg ffmpegthumbnailer poppler 7zip bat \
just clang

- uses: actions/checkout@v6
Expand Down
1 change: 1 addition & 0 deletions PACKAGING.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ In addition to linked-library runtime packages, ship or recommend the following
| `ffmpeg`, `ffprobe` | Media thumbnails and metadata. |
| `ffmpegthumbnailer` | Recommended for shared video-thumbnail filmstrips; executable/runtime closure only, no development headers. |
| `pdftoppm`, `pdfinfo` | PDF support, usually from Poppler utilities. |
| `bat` or `batcat` | Optional syntax highlighting in text previews. |
| `bwrap` (Bubblewrap) | Optional sandbox for installed XDG `.thumbnailer` helpers. Requires working namespace isolation. |
| `7zz`, `7z` or `7za` | Encrypted 7z input; searched in that order. `LUCIOLE_7Z` can select an absolute executable path. |
| `xdg-terminal-exec` | Recommended for automatic terminal selection; configured commands and supported terminals can also be used directly. |
Expand Down
5 changes: 5 additions & 0 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2305,7 +2305,9 @@
"file-preview-view": {
"calculating": "Calculating…",
"close-preview": "Close preview",
"collapse-text-preview": "Collapse text preview",
"contents": "Contents",
"expand-text-preview": "Expand text preview",
"file-size": "File Size",
"open-with": "Open With…",
"partial-result": "Partial result",
Expand Down Expand Up @@ -2533,6 +2535,7 @@
"clearing": "Clearing…",
"clearing-cache": "Clearing cache…",
"color-scheme": "Color Scheme",
"colors-for-syntax-highlighted-file-previews": "Colors for syntax-highlighted file previews",
"column-order": "Column Order",
"column-view": "Column View",
"column-width": "Column Width",
Expand Down Expand Up @@ -2579,6 +2582,7 @@
"folder-size-limit": "Folder Size Limit",
"folders-and-links-to-them-before": "Folders, and links to them, before files",
"folders-first": "Folders First",
"follow-app-theme": "Follow App Theme",
"for-example-foot-or-kitty-leave": "For example: foot or kitty. Leave empty to use $TERMINAL, then automatic discovery.",
"general": "General",
"generation": "Generation",
Expand Down Expand Up @@ -2692,6 +2696,7 @@
"start-folder": "Start Folder",
"super-shortcuts-are-reserved-by-compositor": "Super shortcuts are reserved by the compositor.",
"switch-to-new-folder-tabs": "Switch to New Folder Tabs",
"syntax-color-scheme": "Syntax Color Scheme",
"tabs-and-windows": "Tabs and Windows",
"taskbars-and-window-lists-show-folder": "Taskbars and window lists show the folder name",
"terminal": "Terminal",
Expand Down
1 change: 1 addition & 0 deletions docs/user/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ All keys belong in `[browser]`. Dimensions are logical pixels. View, zoom, sorti
| `folder_size_limit` | `1000000` | Items counted per folder for the Size column and preview while `calculate_folder_sizes` is on: `10000`, `100000`, `1000000`, `10000000`, or `0` for no limit. Larger folders show a partial size marked `≥` |
| `disk_usage_limit` | `2000000` | Items one [Disk Usage](disk-usage.md) scan covers: `10000`, `100000`, `1000000`, `2000000`, `10000000`, or `0` for no limit. A larger folder shows a partial result, and every scanned item stays in memory while the view is open |
| `show_preview` | `true` | Show the side preview when space permits |
| `preview_color_scheme` | `"auto"` | Colors for side and quick text previews. `"auto"` follows the app theme. `"dark"` and `"light"` use Luciole's built-in palettes. A theme name from `bat --list-themes` uses that theme's colors when available. Applies live |
| `chooser_show_preview` | `false` | Show the side preview in file picker windows; toggling it there changes only this key |
| `chooser_start_folder` | `"home"` | `"home"`, `"last"`: where a file picker opens when the application suggests no folder. `"last"` reopens the folder of the last accepted pick; a suggested folder always wins |
| `chooser_view_mode` | `"list"` | `"list"`, `"grid"`, `"miller"`; kept apart from `view_mode`. In Columns, a selected folder is what a folder picker returns and where a save goes |
Expand Down
1 change: 1 addition & 0 deletions docs/user/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ Missing helpers leave ordinary local browsing available. [PACKAGING.md](../../PA
| Image formats | Installed GdkPixbuf image loaders (Glycin loaders when GdkPixbuf is built with Glycin) |
| Video and audio thumbnails and metadata | FFmpeg |
| PDF thumbnails and metadata | Poppler utilities |
| Syntax highlighting in text previews | `bat` (also packaged as `batcat`) |
| [Installed `.thumbnailer` helpers](preview-and-properties.md#use-custom-thumbnailers) | Bubblewrap (`bwrap`) and the helper for each format |
| Encrypted 7z archives | A system 7-Zip executable |
| Terminal actions | `xdg-terminal-exec` and a suitable terminal |
Expand Down
8 changes: 7 additions & 1 deletion docs/user/preview-and-properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Select one item and press `Space`. Press `Space` or `Escape` to close it.

In the quick preview, `Left` and `Right` step one item. `Up` and `Down` step one list item or one grid row.

For text files, use **Expand text preview** in the header to give the text more room. Use the same button to collapse it.

Images, video stills or embedded video covers, the first PDF page and embedded audio artwork depend on available decoders and helpers. Video previews are still images, not playback. See [optional features](installation.md#optional-features).

## Use custom thumbnailers
Expand All @@ -26,7 +28,11 @@ Luciole reuses valid shared thumbnails first, then tries its built-in providers

## Preview text and desktop entries

Readable local UTF-8 text formats, including YAML and desktop-entry contents, have text previews. Desktop entries also show their localized application or link name and description in the preview and in Properties.
Readable local UTF-8 text formats, including YAML and desktop-entry contents, have text previews. With `bat` or `batcat` installed, recognized languages are syntax highlighted in both the side and quick preview. Desktop entries also show their localized application or link name and description in the preview and in Properties.

Choose **Settings → Appearance → Preview → Syntax Color Scheme** to follow the app theme, use a fixed dark or light palette, or select a theme bundled with your installed `bat`.

Drag over text to select it in either preview. Press `Ctrl+A` with the text focused to select the whole excerpt and `Ctrl+C` to copy the selection.

## Check file types

Expand Down
6 changes: 6 additions & 0 deletions lib/render/core/renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ class Renderer {
std::string_view text, float fontSize, const std::vector<std::size_t>& byteOffsets, float maxWidth,
std::vector<TextCursorStop>& outStops, const TextFont& font = {}
) = 0;
// Maps a point relative to the drawn text's first baseline to a UTF-8 byte offset in its literal content.
virtual std::size_t textIndexAtPoint(
std::string_view /*text*/, float /*fontSize*/, const TextFont& /*font*/, float /*maxWidth*/, Vec2 /*point*/
) {
return 0;
}
// Horizontal extent of each character on screen: span i covers the bytes from byteOffsets[i] to
// byteOffsets[i + 1], laid out on one line like measureTextCursorStops. Right-to-left runs put the
// spans out of byte order. Leaves outSpans empty when the renderer cannot shape text.
Expand Down
6 changes: 6 additions & 0 deletions lib/render/render_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,12 @@ void RenderContext::measureTextCharSpansScaled(
m_textRenderer.measureCharSpans(scale, text, fontSize, byteOffsets, outSpans, font);
}

std::size_t RenderContext::textIndexAtPointScaled(
float scale, std::string_view text, float fontSize, const TextFont& font, float maxWidth, Vec2 point
) {
return m_textRenderer.indexAtPoint(scale, text, fontSize, font, maxWidth, point);
}

TextMetrics RenderContext::measureGlyphScaled(float scale, char32_t codepoint, float fontSize) {
auto m = m_glyphRenderer.measureGlyph(scale, codepoint, fontSize);
return TextMetrics{
Expand Down
3 changes: 3 additions & 0 deletions lib/render/render_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ class RenderContext {
float scale, std::string_view text, float fontSize, const std::vector<std::size_t>& byteOffsets, float maxWidth,
std::vector<TextCursorStop>& outStops, const TextFont& font
);
std::size_t textIndexAtPointScaled(
float scale, std::string_view text, float fontSize, const TextFont& font, float maxWidth, Vec2 point
);
void measureTextCharSpansScaled(
float scale, std::string_view text, float fontSize, const std::vector<std::size_t>& byteOffsets,
std::vector<TextCharSpan>& outSpans, const TextFont& font
Expand Down
7 changes: 7 additions & 0 deletions lib/render/render_target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ void ScaledRenderer::measureTextCharSpans(
);
}

std::size_t ScaledRenderer::textIndexAtPoint(
std::string_view text, float fontSize, const TextFont& font, float maxWidth, Vec2 point
) {
assert(m_context != nullptr && "ScaledRenderer text hit test without a bound RenderContext");
return m_context->textIndexAtPointScaled(currentScale(), text, fontSize * currentTextScale(), font, maxWidth, point);
}

TextMetrics ScaledRenderer::measureGlyph(char32_t codepoint, float fontSize) {
assert(m_context != nullptr && "ScaledRenderer measureGlyph without a bound RenderContext");
return m_context->measureGlyphScaled(currentScale(), codepoint, fontSize);
Expand Down
2 changes: 2 additions & 0 deletions lib/render/render_target.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class ScaledRenderer final : public Renderer {
std::string_view text, float fontSize, const std::vector<std::size_t>& byteOffsets, float maxWidth,
std::vector<TextCursorStop>& outStops, const TextFont& font = {}
) override;
std::size_t
textIndexAtPoint(std::string_view text, float fontSize, const TextFont& font, float maxWidth, Vec2 point) override;
void measureTextCharSpans(
std::string_view text, float fontSize, const std::vector<std::size_t>& byteOffsets,
std::vector<TextCharSpan>& outSpans, const TextFont& font = {}
Expand Down
52 changes: 49 additions & 3 deletions lib/render/text/cairo_text_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <functional>
#include <hb-ot.h>
#include <limits>
#include <memory>
#include <pango/pango-attributes.h>
#include <pango/pangocairo.h>
#include <pango/pangofc-fontmap.h>
Expand Down Expand Up @@ -111,6 +112,26 @@ namespace {
return false;
}

bool containsColorAttributes(PangoLayout* layout) {
auto* attrs = pango_layout_get_attributes(layout);
if (attrs == nullptr) {
return false;
}
const std::unique_ptr<PangoAttrIterator, decltype(&pango_attr_iterator_destroy)> iterator(
pango_attr_list_get_iterator(attrs), &pango_attr_iterator_destroy
);
do {
for (const auto type :
{PANGO_ATTR_FOREGROUND, PANGO_ATTR_BACKGROUND, PANGO_ATTR_UNDERLINE_COLOR, PANGO_ATTR_STRIKETHROUGH_COLOR,
PANGO_ATTR_OVERLINE_COLOR}) {
if (pango_attr_iterator_get(iterator.get(), type) != nullptr) {
return true;
}
}
} while (pango_attr_iterator_next(iterator.get()));
return false;
}

struct VerticalExtents {
float top = 0.0F;
float bottom = 0.0F;
Expand Down Expand Up @@ -683,6 +704,31 @@ void CairoTextRenderer::measureCursorStopsWrapped(
g_object_unref(layout);
}

std::size_t CairoTextRenderer::indexAtPoint(
float contentScale, std::string_view text, float fontSize, const TextFont& font, float maxWidth, Vec2 point
) {
maybeSyncFontConfig();
if (m_pangoContext == nullptr || text.empty()) {
return 0;
}
auto* layout = buildLayout(contentScale, text, fontSize, font, maxWidth * contentScale, 0, TextAlign::Start);
PangoRectangle logical{};
pango_layout_get_extents(layout, nullptr, &logical);
// Draw crops the horizontal layout origin to a whole raster pixel and positions it by the first baseline.
const int left = logical.x / PANGO_SCALE * PANGO_SCALE;
const int baseline = pango_layout_get_baseline(layout);
int index = 0, trailing = 0;
pango_layout_xy_to_index(
layout, left + static_cast<int>(point.x * contentScale * PANGO_SCALE),
baseline + static_cast<int>(point.y * contentScale * PANGO_SCALE), &index, &trailing
);
// Pango's trailing edge counts code points within the grapheme, whereas index is a byte offset.
const char* start = pango_layout_get_text(layout);
const auto byte = static_cast<std::size_t>(g_utf8_offset_to_pointer(start + index, trailing) - start);
g_object_unref(layout);
return byte;
}

void CairoTextRenderer::measureCharSpans(
float contentScale, std::string_view text, float fontSize, const std::vector<std::size_t>& byteOffsets,
std::vector<TextCharSpan>& outSpans, const TextFont& font
Expand Down Expand Up @@ -853,7 +899,7 @@ void CairoTextRenderer::rasterizeLayout(
// color applied in shader (u_tint). Color-independent → one cache entry per
// string serves every color animation state.
// Untinted path: CAIRO_FORMAT_ARGB32 with `color` baked in, BGRA->RGBA
// swizzle, RGBA upload. Used for COLR color emoji.
// swizzle, RGBA upload. Used for color markup and COLR color emoji.
const int bytesPerPixel = tinted ? 1 : 4;
const int tightRowBytes = pxWidth * bytesPerPixel;
std::vector<unsigned char> tight;
Expand Down Expand Up @@ -973,7 +1019,7 @@ CairoTextRenderer::CacheEntry* CairoTextRenderer::lookupOrRasterize(
) {
// Tinted (A8 coverage) entries are color-independent — the shader applies
// u_tint at draw time, so one cache entry serves every color. RGBA entries
// (mixed content with COLR emoji) bake non-emoji ink color into the Cairo
// (color markup or COLR emoji) bake default ink color into the Cairo
// surface, so rgb must be part of the key. Alpha is normalized to 1.0 in
// the key AND in the rasterized source so opacity animations on mixed
// strings still reuse one entry.
Expand Down Expand Up @@ -1002,7 +1048,7 @@ CairoTextRenderer::CacheEntry* CairoTextRenderer::lookupOrRasterize(

PangoLayout* layout =
buildLayout(contentScale, text, fontSize, font, maxWidth * contentScale, maxLines, align, ellipsize, useMarkup);
const bool tinted = !containsColorGlyph(layout);
const bool tinted = !(useMarkup && containsColorAttributes(layout)) && !containsColorGlyph(layout);
if (tinted) {
key.colorRgba = 0U;
}
Expand Down
7 changes: 5 additions & 2 deletions lib/render/text/cairo_text_renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ class CairoTextRenderer {
float contentScale, std::string_view text, float fontSize, const std::vector<std::size_t>& byteOffsets,
float maxWidth, std::vector<TextCursorStop>& outStops, const TextFont& font = {}
);
std::size_t indexAtPoint(
float contentScale, std::string_view text, float fontSize, const TextFont& font, float maxWidth, Vec2 point
);
void measureCharSpans(
float contentScale, std::string_view text, float fontSize, const std::vector<std::size_t>& byteOffsets,
std::vector<TextCharSpan>& outSpans, const TextFont& font = {}
Expand Down Expand Up @@ -195,8 +198,8 @@ class CairoTextRenderer {
// Render a layout into a new GL texture; fills out fields of `entry`.
// When `tinted` is true, rasterizes as CAIRO_FORMAT_A8 and uploads alpha
// coverage so the color is applied via u_tint at draw time. When false,
// rasterizes as CAIRO_FORMAT_ARGB32 with `color` baked in (for COLR emoji
// content).
// rasterizes as CAIRO_FORMAT_ARGB32 with `color` as the default ink for
// color markup and COLR emoji content.
void rasterizeLayout(float contentScale, PangoLayout* layout, const Color& color, bool tinted, CacheEntry& entry);
// Extract logical metrics from a laid-out PangoLayout, dividing by PANGO_SCALE and by scale.
TextMetrics metricsFromLayout(float contentScale, PangoLayout* layout) const;
Expand Down
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ thumbnails_lib = static_library('luciole-thumbnails',
files(
'src/thumbnails/file_icon_cache.cpp',
'src/thumbnails/installed_thumbnailers.cpp',
'src/thumbnails/preview_highlight.cpp',
'src/thumbnails/preview_service.cpp',
'src/thumbnails/preview_metadata.cpp',
'src/thumbnails/metadata_probe.cpp',
Expand Down Expand Up @@ -395,6 +396,7 @@ ui_lib = static_library('luciole-ui',
'src/ui/controls/sunburst_program.cpp',
'src/ui/controls/operations_view.cpp',
'src/ui/controls/file_preview_view.cpp',
'src/ui/controls/preview_text.cpp',
'src/ui/controls/file_metadata_view.cpp',
'src/ui/controls/folder_totals_view.cpp',
'src/ui/controls/glyph_picker.cpp',
Expand Down
1 change: 1 addition & 0 deletions nix/devshell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pkgs.mkShell {
xdg-terminal-exec
ffmpeg
ffmpegthumbnailer
bat
bubblewrap
poppler-utils
_7zz
Expand Down
2 changes: 2 additions & 0 deletions nix/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
stb,
ffmpeg,
ffmpegthumbnailer,
bat,
bubblewrap,
poppler-utils,
_7zz,
Expand Down Expand Up @@ -185,6 +186,7 @@ stdenv.mkDerivation (finalAttrs: {
xdg-terminal-exec
ffmpeg
ffmpegthumbnailer
bat
bubblewrap
poppler-utils
_7zz
Expand Down
5 changes: 4 additions & 1 deletion src/app/page/browser_page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,9 @@ void BrowserPage::keyboard(const KeyboardEvent& event) {
m_dragDrop.updateDrag();
return;
}
if (m_previewController.selectionKey(event)) {
return;
}
if (m_popupSurface != nullptr) {
if (m_trashController.key(event)) {
return;
Expand Down Expand Up @@ -3573,7 +3576,7 @@ float BrowserPage::dialogWidth(DialogWidth width) const {

popup_chrome::Geometry BrowserPage::dialogGeometry(Flex& content) {
auto& renderer = (m_popupSurface ? m_popupSurface->renderTarget() : m_surface->renderTarget()).renderer();
const float width = dialogWidth(*m_dialogTier);
const float width = dialogWidth(m_previewController.quickPreviewExpanded() ? DialogWidth::Large : *m_dialogTier);
// A width change moves an open dropdown's anchor.
if (width != content.width()) {
m_dialogDropdown.closeSelectDropdown();
Expand Down
Loading