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.
- 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 ()
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.
We remove the old first article, and we stick it on the end of the list using the presumably modified version.
Insert a new article with top priority (that is, at the front of the list).
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
ArticleDB, dump the scheduled article into the buffer (replacing previous contents).
Go to next one. This ignores the buffer, but it doesn't remove anything from the database. However, the ordering does change.
Delete current article (the article as in the database), and go to next one.
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.