yi-0.6.2.3: The Haskell-Scriptable EditorSource codeContentsIndex
Yi.IReader
Description
This module defines a list type and operations on it; it further provides functions which write in and out the list. The goal is to make it easy for the user to store a large number of text buffers and cycle among them, making edits as she goes. The idea is inspired by "incremental reading", see http://en.wikipedia.org/wiki/Incremental_reading.
Synopsis
type Article = ByteString
type ArticleDB = Seq Article
split :: ArticleDB -> (Article, ArticleDB)
getLatestArticle :: ArticleDB -> Article
removeSetLast :: ArticleDB -> Article -> ArticleDB
shift :: Int -> ArticleDB -> ArticleDB
insertArticle :: ArticleDB -> Article -> ArticleDB
writeDB :: ArticleDB -> YiM ()
readDB :: YiM ArticleDB
dbLocation :: IO FilePath
oldDbNewArticle :: YiM (ArticleDB, Article)
getBufferContents :: BufferM String
setDisplayedArticle :: ArticleDB -> YiM ()
nextArticle :: YiM ()
deleteAndNextArticle :: YiM ()
saveAndNextArticle :: Int -> YiM ()
saveAsNewArticle :: YiM ()
Documentation
type Article = ByteStringSource
type ArticleDB = Seq ArticleSource
split :: ArticleDB -> (Article, ArticleDB)Source
Take an ArticleDB, and return the first Article and an ArticleDB - *without* that article.
getLatestArticle :: ArticleDB -> ArticleSource
Get the first article in the list. We use the list to express relative priority; the first is the most, the last least. We then just cycle through - every article gets equal time.
removeSetLast :: ArticleDB -> Article -> ArticleDBSource
We remove the old first article, and we stick it on the end of the list using the presumably modified version.
shift :: Int -> ArticleDB -> ArticleDBSource
insertArticle :: ArticleDB -> Article -> ArticleDBSource
Insert a new article with top priority (that is, at the front of the list).
writeDB :: ArticleDB -> YiM ()Source
In the background, serialize given ArticleDB out.
readDB :: YiM ArticleDBSource
Read in database from dbLocation and then parse it into an ArticleDB.
dbLocation :: IO FilePathSource
The canonical location. We assume ~/.yi has been set up already.
oldDbNewArticle :: YiM (ArticleDB, Article)Source
Returns the database as it exists on the disk, and the current Yi buffer contents. Note that the Initializable typeclass gives us an empty Seq. So first we try the buffer state in the hope we can avoid a very expensive read from disk, and if we find nothing (that is, if we get an empty Seq), only then do we call readDB.
getBufferContents :: BufferM StringSource
setDisplayedArticle :: ArticleDB -> YiM ()Source
Given an ArticleDB, dump the scheduled article into the buffer (replacing previous contents).
nextArticle :: YiM ()Source
Go to next one. This ignores the buffer, but it doesn't remove anything from the database. However, the ordering does change.
deleteAndNextArticle :: YiM ()Source
Delete current article (the article as in the database), and go to next one.
saveAndNextArticle :: Int -> YiM ()Source
The main action. We fetch the old database, we fetch the modified article from the buffer, then we call the function updateSetLast which removes the first article and pushes our modified article to the end of the list.
saveAsNewArticle :: YiM ()Source
Assume the buffer is an entirely new article just imported this second, and save it. We don't want to use updateSetLast since that will erase an article.
Produced by Haddock version 2.6.1