On Thu, Nov 27, 2008 at 10:53 PM, nicolas. pouillard
<[EMAIL PROTECTED]> wrote:
>
> Excerpts from Gwern Branwen's message of Thu Nov 27 22:50:31 +0100 2008:
>> > On Thu, Nov 27, 2008 at 3:22 AM, Gwern Branwen <[EMAIL PROTECTED]> wrote:
>> >> On Wed, Nov 26, 2008 at 5:03 PM, Gwern Branwen  wrote:
>> >>> setBufferContents doesn't seem to exist. At least, recursive grep
>> >>> can't find anything but setBuffer.
>> >>
>> >> OK, so I found two ways to do this:
>> >>
>> >>> setBufferContents :: (MonadEditor m) => String -> m BufferRef
>> >>> setBufferContents article = withEditor $ stringToNewBuffer "Ireader 
>> >>> article" (B.fromString article)
>> >
>> > You can use the replaceBufferContent function that I pointed to.
>> >
>> >> [Attempts to read the buffer contents into a String]
>> >
>> >> We really need to make this stuff easier. I vote that we start by
>> >> adding some basic primitives like a getCurrentBuffer :: YiM String...
>> >
>> > It's not difficult if you know where to look. Reading Yi.Buffer.HighLevel
>> > would help you here. In general all the buffer-manipulation API are in
>> > the BufferM monad. You can lift it to YiM by using withBuffer. The function
>> > will then operate on the current buffer.
>>
>> I looked at HighLevel many times; I didn't find it very helpful. For
>> example, the simplest way to write a getBufferContents seems to be
>> something like this:
>>
>> > getBufferContents :: BufferM String
>> > getBufferContents = do topB
>> >                        str <- liftM unlines $ whileB (liftM not $ atEof) 
>> > (readLnB)
>> >                        return str
>>
>> (And I suspect this is less than optimal - presumably this would not
>> respect the user's current position?)
>
> Look at Yi.Buffer.Normal
>
> getBufferContents = regionOfB Document
>

Actually I typed this in my previous message but I deleted it during edits.
I did not mean to be riddling, sorry.

And thanks Nicolas!
-- JP

--~--~---------~--~----~------------~-------~--~----~
Yi development mailing list
yi-devel@googlegroups.com
http://groups.google.com/group/yi-devel
-~----------~----~----~----~------~----~------~--~---

Reply via email to