hoyo-0.6.0.0: Bookmark directories for cd
Copyright(c) Frederick Pringle 2023
LicenseBSD-3-Clause
Maintainerfreddyjepringle@gmail.com
Safe HaskellNone
LanguageHaskell2010

Hoyo.Bookmark

Description

The Bookmark type provides a representation of bookmarks saved and used by the hoyo program. This module exports some utility datatypes and functions used for working with bookmarks.

Synopsis

The Bookmark type

data Bookmark Source #

Bookmark a directory for easy cd. A bookmark remembers the directory, the index, the creation time, and optionally a user-specified nickname for the bookmark.

Instances

Instances details
Eq Bookmark Source # 
Instance details

Defined in Hoyo.Internal.Types

Show Bookmark Source # 
Instance details

Defined in Hoyo.Internal.Types

newtype Bookmarks Source #

Wrapper for [Bookmark].

Constructors

Bookmarks 

Fields

Instances

Instances details
Show Bookmarks Source # 
Instance details

Defined in Hoyo.Internal.Types

data BookmarkSearchTerm Source #

Data-type for represting a bookmark search. You can either search by index or by name. Used by the delete and move commands.

formatBookmark :: Bool -> Int -> Int -> Bookmark -> Text Source #

Format a Bookmark. Used for the "list" command and error reporting during other commands.

formatBookmark displayTime numberWidth bm returns a pretty representation of bm, optionally showing the creation time, and padding the index and directory to a certain width.

formatBookmarks :: Bool -> [Bookmark] -> [Text] Source #

Format a list of Bookmarks. Used for the "list" command and error reporting during other commands

formatBookmark displayTime bms returns a pretty representation of bms, optionally showing the creation time, and padding the indices to line up.

data DefaultBookmark Source #

Default bookmarks to save at init. A default bookmark remembers the directory and optionally a user-specified nickname for the bookmark.

Working with bookmarks

getBookmarks :: HoyoMonad Bookmarks Source #

Get the bookmarks from the currently used bookmark file.

searchBookmarks :: BookmarkSearchTerm -> Bookmarks -> ([Bookmark], [Bookmark]) Source #

searchBookmarks searchTerm bookmarks partitions bookmarks into a list of Bookmarks that match the search term and a list of those that do not.

filterBookmarks :: Maybe Text -> Maybe Text -> Bookmark -> Bool Source #

Given a bookmark name and a bookmark directory, test if a bookmark matches those filters.

filterBookmarkByName :: Maybe Text -> Bookmark -> Bool Source #

A predicate used by filterBookmarks - match on the bookmark name. Note that matching is case-sensitive.

filterBookmarkByDirInfix :: Maybe Text -> Bookmark -> Bool Source #

A predicate used by filterBookmarks - match on the bookmark directory.

bookmarksFromDefault :: MonadIO m => [DefaultBookmark] -> m Bookmarks Source #

Convert a list of DefaultBookmarks to a Bookmarks, assiging indices and/ creation times on the fly.

Parsing/encoding bookmarks from/to TOML

bookmarkCodec :: TomlCodec Bookmark Source #

A TomlCodec for encoding and decoding Bookmarks.

decodeBookmarksFile :: (MonadIO m, MonadCatch m) => FilePath -> m (Either HoyoException Bookmarks) Source #

Decode a Bookmark from a file. TODO: catch IO exceptions

encodeBookmarks :: Bookmarks -> Text Source #

Encode a Bookmark to a Text.

encodeBookmarksFile :: MonadIO m => FilePath -> Bookmarks -> m () Source #

Encode a Bookmark to a file.