CommanderPanel
ConsoleMonster.Apps.Commander
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.
Returned or exposed by 6
- Property CommanderContext.Active
- Method CommanderModel.Panel
- Property CommanderModel.Active
- Property CommanderModel.Left
- Property CommanderModel.Other
- Property CommanderModel.Right
Constructors
public CommanderPanel(string folder) #Opens a panel on a folder with the default sort (name, ascending).
Parameters
- folder string
- 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
- The state.
Methods
public bool AppendSearch(char character) #Adds a typed character to the search.
Parameters
- character char
- 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 PanelEntry? Find(string id) #The row with an identity, or null.
Parameters
- id string
- The identity.
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
- 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
- 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
- The pattern.
- includeFolders bool = false
- 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
- 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
- Rows to move; negative moves up.
public bool MoveTo(string id) #Moves the cursor to a row by identity.
Parameters
- id string
- The row's PanelEntry.Id, such as a full path.
Returns
bool Whether the row is listed.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 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
- 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
- The row.
- marked bool
- Whether it's marked.
public void Sort(PanelSortColumn column, bool descending) #Sorts by a column. The cursor stays on the same row.
Parameters
- column ConsoleMonster.Apps.Commander.PanelSortColumn
- The column.
- descending bool
- 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
- The column.
public int UnmarkPattern(string pattern, bool includeFolders = true) #Unmarks the rows whose names match a pattern.
Parameters
- pattern string
- The pattern.
- includeFolders bool = true
- Whether folders are unmarked too.
Returns
int How many rows were unmarked.Inherited Methods
Properties
public bool SortDescending { get; private set; } #Whether the sort is descending.
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 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 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.