Selkie--Widget--FileBrowser

NAME

Selkie::Widget::FileBrowser - Shell-style file picker modal

SYNOPSIS

use Selkie::Widget::FileBrowser;

my $browser = Selkie::Widget::FileBrowser.new;
my $modal = $browser.build(
    extensions    => <png jpg json>,
    show-dotfiles => False,
    width-ratio   => 0.7,
    height-ratio  => 0.7,
);

$browser.on-select.tap: -> Str $path {
    $app.close-modal;
    $app.store.dispatch('file/open', :$path);
};

$app.show-modal($modal);
$app.focus($browser.focusable-widget);

DESCRIPTION

A modal file picker built on top of Modal, ListView, and TextInput. Behaves like a shell prompt:

  • The path input shows the current directory + filename prefix

  • Typing filters the list below to matching entries

  • Tab autocompletes to the longest common prefix

  • Enter on a directory descends into it; on a file selects it

  • Up/Down navigate the list

  • Esc cancels without selecting

  • Single-click on a list row positions the cursor; double-click descends/selects (same path Enter takes)

Extension filtering is optional — pass extensions = ()> or omit to show everything. Hidden files (.name) are excluded unless show-dotfiles is True.

EXAMPLES

Import dialog

sub show-import-dialog() {
    my $browser = Selkie::Widget::FileBrowser.new;
    my $modal = $browser.build(extensions => <png json>);

    $browser.on-select.tap: -> Str $path {
        $app.close-modal;
        import-character($path);
    };

    $app.show-modal($modal);
    $app.focus($browser.focusable-widget);
}

SEE ALSO

method on-select

method on-select() returns Supply

Supply that emits the selected absolute path (Str) when the user activates a file. Esc cancels and never emits — handle close-on-Esc via the Modal's standard dismissal.

method build

method build(
    Str :$start-dir = Code.new,
    :@extensions,
    Bool :$show-dotfiles = Bool::False,
    Rat :$width-ratio = 0.6,
    Rat :$height-ratio = 0.7
) returns Selkie::Widget::Modal

Build the file picker modal. Returns the underlying Modal so the caller can pass it directly to $app.show-modal. :extensions filters by suffix (case-insensitive); empty array shows all files. :show-dotfiles includes hidden files. Re-callable to rebuild at a different start directory.

method focusable-widget

method focusable-widget() returns Selkie::Widget::TextInput

The widget to pass to $app.focus after show-modal. Returns the path TextInput — typing filters the list, Tab autocompletes, Up/Down navigate, Enter selects.

method list

method list() returns Selkie::Widget::ListView

The internal ListView, exposed for callers that want to override selection logic or read the visible items.

method path-input

method path-input() returns Selkie::Widget::TextInput

The internal path TextInput, exposed for callers that want to pre-fill it or attach extra on-key handlers.

Selkie v0.10.0

High-level TUI framework built on Notcurses

Authors

  • Matt Doughty

License

Artistic-2.0

Dependencies

Notcurses::Native:ver<0.4.0+>:auth<zef:apogee>

Test Dependencies

Provides

  • Selkie
  • Selkie::App
  • Selkie::App::Internal::Dispatch
  • Selkie::App::Internal::ErrorLog
  • Selkie::App::Internal::FocusTree
  • Selkie::App::Internal::HitTest
  • Selkie::App::Internal::IdleBudget
  • Selkie::App::Internal::OverlayTree
  • Selkie::App::Internal::RenderLoop
  • Selkie::App::Internal::ScreenModalLifecycle
  • Selkie::App::Internal::Terminal
  • Selkie::App::Internal::TerminalSequences
  • Selkie::Container
  • Selkie::EffectiveBounds
  • Selkie::Event
  • Selkie::Layout::Allocate
  • Selkie::Layout::HBox
  • Selkie::Layout::Split
  • Selkie::Layout::VBox
  • Selkie::Plot::Palette
  • Selkie::Plot::Scaler
  • Selkie::Plot::Ticks
  • Selkie::ScreenManager
  • Selkie::Sizing
  • Selkie::Store
  • Selkie::Style
  • Selkie::Test::Focus
  • Selkie::Test::Keys
  • Selkie::Test::Snapshot
  • Selkie::Test::Snapshot::Harness
  • Selkie::Test::Store
  • Selkie::Test::Supply
  • Selkie::Test::Tree
  • Selkie::Theme
  • Selkie::Trace
  • Selkie::Tree
  • Selkie::Widget
  • Selkie::Widget::Axis
  • Selkie::Widget::BarChart
  • Selkie::Widget::Border
  • Selkie::Widget::Button
  • Selkie::Widget::CardList
  • Selkie::Widget::Checkbox
  • Selkie::Widget::CommandPalette
  • Selkie::Widget::ConfirmModal
  • Selkie::Widget::FileBrowser
  • Selkie::Widget::FocusableByDefault
  • Selkie::Widget::Heatmap
  • Selkie::Widget::HelpOverlay
  • Selkie::Widget::Histogram
  • Selkie::Widget::Image
  • Selkie::Widget::Legend
  • Selkie::Widget::LineChart
  • Selkie::Widget::ListView
  • Selkie::Widget::Modal
  • Selkie::Widget::MultiLineInput
  • Selkie::Widget::PasswordStrength
  • Selkie::Widget::Plot
  • Selkie::Widget::ProgressBar
  • Selkie::Widget::RadioGroup
  • Selkie::Widget::RichText
  • Selkie::Widget::RichText::Span
  • Selkie::Widget::ScatterPlot
  • Selkie::Widget::ScrollView
  • Selkie::Widget::Select
  • Selkie::Widget::Sparkline
  • Selkie::Widget::Spinner
  • Selkie::Widget::TabBar
  • Selkie::Widget::Table
  • Selkie::Widget::Text
  • Selkie::Widget::TextInput
  • Selkie::Widget::TextInput::HighlightSpan
  • Selkie::Widget::TextStream
  • Selkie::Widget::Toast
  • Selkie::Widget::ViewportedCardList

Documentation

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.