Skip to content
ConsoleMonster
Class

CommanderPanel

ConsoleMonster.Apps.Commander

Namespace
ConsoleMonster.Apps.Commander
Assembly
ConsoleMonster
Implements
IDisposable
Modifiers
sealed

One Commander panel: a folder listing with a cursor, sort order, marks, quick search and background folder sizes. It holds no rendering; a data grid binds to CommanderPanel.Entries, CommanderPanel.CursorIndex and the marks.

Inheritance

  • object
  • CommanderPanel

Remarks

The panel belongs to the app thread. The only background work is the folder-size scan, which updates PanelEntry.Size and increments CommanderPanel.Revision; a view repaints when the revision changes. A listing is sorted once, so rows never jump while sizes arrive.

Usage

Explore 6 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Constructors

CommanderPanel 2 overloads
public CommanderPanel(string folder) #

Opens a panel on a folder with the default sort (name, ascending).

Parameters

folder string required
The folder to list.
public CommanderPanel(PanelState state) #

Opens a panel from remembered state. A remembered folder that no longer exists falls back to its nearest existing parent, then the home folder.

Parameters

state ConsoleMonster.Apps.Commander.PanelState required
The state.

Methods

public bool AppendSearch(char character) #

Adds a typed character to the search.

Parameters

character char required
The character.

Returns

bool Whether the longer prefix still matches; if not, the character is not added.
public void BackspaceSearch() #

Removes the last search character, keeping the cursor where it is.

public void CancelSizes() #

Stops the folder-size scan. Sizes already computed stay.

public void ClearMarks() #

Unmarks everything.

public void ClearSearch() #

Ends the search; the cursor stays on the found row.

public void Dispose() #

Stops background work.

public PanelEntry? Find(string id) #

The row with an identity, or null.

Parameters

id string required
The identity.

Returns

PanelEntry? The row.
public bool GoToParent() #

Opens the parent folder with the cursor on the folder just left.

Returns

bool False at the root.
public void InvertMarks(bool includeFolders = false) #

Marks every unmarked row and unmarks every marked one.

Parameters

includeFolders bool = false optional
Whether folders are inverted too; by default only files.
public bool IsMarked(PanelEntry entry) #

Whether a row is marked.

Parameters

entry ConsoleMonster.Apps.Commander.PanelEntry required
The row.

Returns

bool True when marked.
public int MarkPattern(string pattern, bool includeFolders = false) #

Marks the rows whose names match a pattern such as *.cs;*.md (see GlobPattern).

Parameters

pattern string required
The pattern.
includeFolders bool = false optional
Whether folders are marked too; by default only files, as in other commanders.

Returns

int How many rows were newly marked.
public bool MatchesSearch(PanelEntry entry) #

Whether a row matches the current search.

Parameters

entry ConsoleMonster.Apps.Commander.PanelEntry required
The row.

Returns

bool True when a search is active and the name starts with it.
public void MoveCursor(int rows) #

Moves the cursor by a number of rows, stopping at the ends.

Parameters

rows int required
Rows to move; negative moves up.
public bool MoveTo(string id) #

Moves the cursor to a row by identity.

Parameters

id string required
The row's PanelEntry.Id, such as a full path.

Returns

bool Whether the row is listed.
public void MoveToEnd() #

Moves the cursor to the last row.

public void MoveToStart() #

Moves the cursor to the first row.

public bool Navigate(string folder) #

Lists another folder. On failure the panel keeps its listing and sets CommanderPanel.Error.

Parameters

folder string required
The folder; relative paths are relative to the current folder.

Returns

bool Whether the folder was opened.
public bool OpenCurrent() #

Opens the cursor row when it's a folder or ...

Returns

bool True when a folder was opened; false for a file, which the caller opens or runs.
public void PageDown() #

Moves the cursor down one page.

public void PageUp() #

Moves the cursor up one page.

public bool Refresh() #

Lists the folder again, keeping the cursor on the same row and the marks on rows that still exist.

Returns

bool Whether the folder could be read. A folder that disappeared opens its nearest existing parent.
public bool Search(string text) #

Searches for the first row whose name starts with the text and moves the cursor there.

Parameters

text string required
The prefix; empty clears the search.

Returns

bool Whether a row matched. Without a match the search text and cursor stay as they were.
public bool SearchNext() #

Moves to the next row matching the search, wrapping at the end.

Returns

bool Whether there is a match.
public void SetMark(PanelEntry entry, bool marked) #

Marks or unmarks a row. The .. row can't be marked.

Parameters

entry ConsoleMonster.Apps.Commander.PanelEntry required
The row.
marked bool required
Whether it's marked.
public void SetShowHidden(bool showHidden) #

Shows or hides hidden files and lists the folder again.

Parameters

showHidden bool required
Whether hidden files are listed.
public void Sort(PanelSortColumn column, bool descending) #

Sorts by a column. The cursor stays on the same row.

Parameters

column ConsoleMonster.Apps.Commander.PanelSortColumn required
The column.
descending bool required
Whether to sort descending.
public Task StartFolderSizes() #

Computes folder sizes in the background, cursor-near rows first. A new listing cancels the scan. It's started automatically after each listing when CommanderPanel.ComputeFolderSizes is on.

Returns

Task The scan, which completes when every folder is sized or the scan is cancelled.
public void ToggleMark() #

Flips the cursor row's mark and moves down, as Insert does.

public void ToggleSort(PanelSortColumn column) #

Sorts by a column, or flips the direction when it's already the sort column.

Parameters

column ConsoleMonster.Apps.Commander.PanelSortColumn required
The column.
public int UnmarkPattern(string pattern, bool includeFolders = true) #

Unmarks the rows whose names match a pattern.

Parameters

pattern string required
The pattern.
includeFolders bool = true optional
Whether folders are unmarked too.

Returns

int How many rows were unmarked.

Properties

public string Folder { get; private set; } #

The listed folder.

public PanelSortColumn SortColumn { get; private set; } #

The sort column.

public bool SortDescending { get; private set; } #

Whether the sort is descending.

public bool ShowHidden { get; private set; } #

Whether hidden files are listed. Change it with CommanderPanel.SetShowHidden.

public bool ComputeFolderSizes { get; set; } #

Whether folder sizes are computed in the background after each listing; on unless the state turned it off. Turning it off stops a running scan, and turning it on starts one.

public IReadOnlyList<PanelEntry> Entries { get; } #

The rows in display order: .., then folders, then files.

public int CursorIndex { get; set; } #

The cursor row's index.

public PanelEntry? Current { get; } #

The cursor row, or null for an empty listing.

public int PageSize { get; set; } #

Rows per page for CommanderPanel.PageDown and CommanderPanel.PageUp; the view sets it from its height.

public long Revision { get; } #

Increments on every change, including folder sizes arriving from the background, so a view knows when to repaint.

public string? Error { get; private set; } #

Why the last navigation or refresh failed, or null when it succeeded.

public string QuickSearch { get; private set; } #

The quick-search text; empty when no search is active.

public Task FolderSizes { get; private set; } #

The current folder-size scan, or a completed task when none is running.

public PanelState State { get; } #

The state worth remembering: folder, sort and view settings.

public int MarkedCount { get; } #

How many rows are marked.

public long MarkedSize { get; } #

The marked rows' total size: files plus folders whose size is known.

public bool MarkedSizeIsComplete { get; } #

Whether CommanderPanel.MarkedSize includes every marked folder, or some are still being sized.

public IReadOnlyList<PanelEntry> MarkedEntries { get; } #

The marked rows in display order.

public IReadOnlyList<PanelEntry> Targets { get; } #

What an operation acts on: the marked rows, or the cursor row when nothing is marked. Never the .. row.