sidebar

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 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

func TogglePinnedDirectory

func TogglePinnedDirectory(dir string) error

TogglePinnedDirectory adds or removes a directory from the pinned directories list

Types

type Model

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

func New

func New() Model

New creates a new sidebar model with the given parameters

func (*Model) CancelSidebarRename

func (s *Model) CancelSidebarRename()

Cancel rename pinned directory

func (*Model) ConfirmSidebarRename

func (s *Model) ConfirmSidebarRename()

Confirm rename pinned directory

func (*Model) GetCurrentDirectoryLocation

func (s *Model) GetCurrentDirectoryLocation() string

GetCurrentDirectoryLocation returns the location of the currently selected directory

func (*Model) HandleSearchBarKey

func (s *Model) HandleSearchBarKey(msg string)

HandleSearchBarKey handles key events for the sidebar 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(mainPanelHeight int)

func (*Model) ListUp

func (s *Model) ListUp(mainPanelHeight int)

func (*Model) NoActualDir

func (s *Model) NoActualDir() bool

True if only dividers are in directories slice, but no actual directories This will be pretty quick. But we can replace it with len(s.directories) <= 2 - More hacky and hardcoded-like, but faster

func (*Model) PinnedItemRename

func (s *Model) PinnedItemRename()

Rename file where the cursor is located

func (*Model) Render

func (s *Model) Render(mainPanelHeight int, sidebarFocussed 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) UpdateDirectories

func (s *Model) UpdateDirectories()

UpdateDirectories updates the directories list based on search value This is a bit inefficient, as we already had the directories when we initialized the sidebar. We call the directory fetching logic many times which is a disk heavy operation.

func (*Model) UpdateState

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

UpdateState handles the sidebar's state updates

Jump to

Keyboard shortcuts

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