Copyright | (c) Frederick Pringle 2023 |
---|---|
License | BSD-3-Clause |
Maintainer | freddyjepringle@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
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
- data Bookmark = Bookmark {}
- newtype Bookmarks = Bookmarks {
- unBookmarks :: [Bookmark]
- data BookmarkSearchTerm
- formatBookmark :: Bool -> Int -> Int -> Bookmark -> Text
- formatBookmarks :: Bool -> [Bookmark] -> [Text]
- data DefaultBookmark = DefaultBookmark {}
- getBookmarks :: HoyoMonad Bookmarks
- searchBookmarks :: BookmarkSearchTerm -> Bookmarks -> ([Bookmark], [Bookmark])
- filterBookmarks :: Maybe Text -> Maybe Text -> Bookmark -> Bool
- filterBookmarkByName :: Maybe Text -> Bookmark -> Bool
- filterBookmarkByDirInfix :: Maybe Text -> Bookmark -> Bool
- bookmarksFromDefault :: MonadIO m => [DefaultBookmark] -> m Bookmarks
- bookmarkCodec :: TomlCodec Bookmark
- bookmarksCodec :: TomlCodec Bookmarks
- defaultBookmarkCodec :: TomlCodec DefaultBookmark
- decodeBookmarks :: Text -> Either HoyoException Bookmarks
- decodeBookmarksFile :: (MonadIO m, MonadCatch m) => FilePath -> m (Either HoyoException Bookmarks)
- encodeBookmarks :: Bookmarks -> Text
- encodeBookmarksFile :: MonadIO m => FilePath -> Bookmarks -> m ()
The Bookmark type
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.
Bookmark | |
|
Wrapper for [
.Bookmark
]
Bookmarks | |
|
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.
Instances
Eq BookmarkSearchTerm Source # | |
Defined in Hoyo.Internal.Types (==) :: BookmarkSearchTerm -> BookmarkSearchTerm -> Bool # (/=) :: BookmarkSearchTerm -> BookmarkSearchTerm -> Bool # | |
Show BookmarkSearchTerm Source # | |
Defined in Hoyo.Internal.Types showsPrec :: Int -> BookmarkSearchTerm -> ShowS # show :: BookmarkSearchTerm -> String # showList :: [BookmarkSearchTerm] -> ShowS # |
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 Bookmark
s. 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.
Instances
Eq DefaultBookmark Source # | |
Defined in Hoyo.Internal.Types (==) :: DefaultBookmark -> DefaultBookmark -> Bool # (/=) :: DefaultBookmark -> DefaultBookmark -> Bool # | |
Show DefaultBookmark Source # | |
Defined in Hoyo.Internal.Types showsPrec :: Int -> DefaultBookmark -> ShowS # show :: DefaultBookmark -> String # showList :: [DefaultBookmark] -> ShowS # |
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
Bookmark
s 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 DefaultBookmark
s to a Bookmarks
, assiging indices and/
creation times on the fly.
Parsing/encoding bookmarks from/to TOML
decodeBookmarks :: Text -> Either HoyoException Bookmarks Source #
Decode a Bookmark
from a Text.
decodeBookmarksFile :: (MonadIO m, MonadCatch m) => FilePath -> m (Either HoyoException Bookmarks) Source #
Decode a Bookmark
from a file.
TODO: catch IO exceptions