sidebar

package
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 18 Imported by: 0

README

sidebar package

This is for the sidebar UI, and for fetching and updating sidebar directories

To-dos

  • Add missing unit tests
  • Separate out implementation of file I/O operations. (Disk listing, Reading and Updating pinned.json) This package should only be concerned with UI/UX.
  • Implementing a proper state transitioning for the sidebar's different modes (normal, search, rename)
  • Some methods could be made more pure by reducing side effects

Coverage

cd /path/to/ui/sidebar
go test -cover

Current coverage is 29.3%.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {
	// contains filtered or unexported fields
}

func New

func New() Model

New initializes and returns a new Model for the sidebar correctly set up with configuration.

func (*Model) CancelSidebarRename

func (s *Model) CancelSidebarRename()

CancelSidebarRename aborts the rename process for a pinned directory.

func (*Model) ConfirmSidebarRename

func (s *Model) ConfirmSidebarRename()

ConfirmSidebarRename finalizes the rename process and saves changes to the pinned directories file.

func (*Model) Disabled added in v1.5.0

func (m *Model) Disabled() bool

Disabled returns true if the sidebar is currently disabled.

func (*Model) GetCurrentDirectoryLocation

func (s *Model) GetCurrentDirectoryLocation() string

GetCurrentDirectoryLocation returns the location of the currently selected directory

func (*Model) GetHeight added in v1.5.0

func (m *Model) GetHeight() int

GetHeight returns the current height of the sidebar.

func (*Model) GetWidth added in v1.5.0

func (m *Model) GetWidth() int

GetWidth returns the current width of the sidebar.

func (*Model) HandleSearchBarKey

func (s *Model) HandleSearchBarKey(msg string)

HandleSearchBarKey processes key events specifically for the sidebar's search bar.

func (*Model) IsRenaming

func (s *Model) IsRenaming() bool

IsRenaming returns whether the sidebar is currently in renaming mode

func (*Model) ListDown

func (s *Model) ListDown()

func (*Model) ListUp

func (s *Model) ListUp()

func (*Model) NoActualDir

func (s *Model) NoActualDir() bool

NoActualDir returns true if the sidebar contains only dividers and no actual directories.

func (*Model) PinnedItemRename

func (s *Model) PinnedItemRename()

PinnedItemRename initiates the rename process for the currently selected pinned directory.

func (*Model) Render

func (s *Model) Render(sidebarFocused bool, currentFilePanelLocation string) string

Render returns the rendered sidebar string.

func (*Model) SearchBarBlur

func (s *Model) SearchBarBlur()

SearchBarBlur removes focus from the search bar

func (*Model) SearchBarFocus

func (s *Model) SearchBarFocus()

SearchBarFocus sets focus on the search bar

func (*Model) SearchBarFocused

func (s *Model) SearchBarFocused() bool

SearchBarFocused returns whether the search bar is focused

func (*Model) SetHeight added in v1.5.0

func (m *Model) SetHeight(height int)

SetHeight updates the height of the sidebar, ensuring it meets the minimum requirement.

func (*Model) TogglePinnedDirectory added in v1.4.0

func (s *Model) TogglePinnedDirectory(dir string) error

TogglePinnedDirectory adds or removes a directory from the pinned list.

func (*Model) UpdateDirectories

func (s *Model) UpdateDirectories()

UpdateDirectories refreshes the list of directories based on the search query or section configuration.

func (*Model) UpdateState

func (s *Model) UpdateState(msg tea.Msg) tea.Cmd

UpdateState handles the sidebar's state updates in response to Bubble Tea messages.

type PinnedManager added in v1.4.0

type PinnedManager struct {
	// contains filtered or unexported fields
}

func NewPinnedFileManager added in v1.4.0

func NewPinnedFileManager(filePath string) PinnedManager

func (*PinnedManager) Clean added in v1.4.0

func (mgr *PinnedManager) Clean(dirs []directory) []directory

Clean removes non-existing directories and optionally saves the updated list

func (*PinnedManager) Load added in v1.4.0

func (mgr *PinnedManager) Load() []directory

Load reads the pinned directories from file and cleans non-existing ones

func (*PinnedManager) Save added in v1.4.0

func (mgr *PinnedManager) Save(dirs []directory) error

Save marshals and writes the pinned directories to file.

func (*PinnedManager) Toggle added in v1.4.0

func (mgr *PinnedManager) Toggle(dir string) error

Toggle adds or removes a directory from the pinned directories list

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL