Copy entirety of a created buffer

Post Reply
dicene
Posts: 47
Joined: Thu Sep 25, 2014 7:36 am

Copy entirety of a created buffer

Post by dicene » Wed Dec 14, 2016 11:57 am

Currently, I have my map capture triggers copying the map that the MUD is sending me and then appending it to a window. I'd like to save that map information though, so I've decided to use pasteBuffer() as well to send it to a buffer where I could use it later.

Problem is, I'm not seeing any correct way to copy that information back out of the buffer. This is because there is no copyBuffer() function and copy() only copies the selected portion, meaning you'd have to manually select the entire buffer and then use copy("lastMap") to get it to your clipboard to paste it again.

Is there a better way that I'm maybe missing that would enable you to easily select/copy that entire buffer, or is this possibly prime functionality for me to add into Mudlet? :D

User avatar
Vadi
Posts: 4641
Joined: Sat Mar 14, 2009 3:13 pm

Re: Copy entirety of a created buffer

Post by Vadi » Tue Feb 14, 2017 9:02 pm

I don't think there is a function for that - you'd have to loop through and select the lines you'd and and copy them over one by one.

Here's some sample code to copy the last line of a miniconsole in case it helps anyone else:
Code: [show] | [select all] lua
    moveCursor("svo_prompt",0,getLastLineNumber("svo_prompt")-1)
    selectCurrentLine("svo_prompt")
    copy("svo_prompt")

dicene
Posts: 47
Joined: Thu Sep 25, 2014 7:36 am

Re: Copy entirety of a created buffer

Post by dicene » Tue Feb 14, 2017 10:05 pm

Yeah. That's what I thought. I might add in a copyBuffer() function for that purpose, so you don't have to manually select the entire buffer with selectSection.

On a very similar subject, getCurrentLine() doesn't allow you to specify a window name, meaning there is no simple way to read the contents of a miniconsole. I'll also hopefully have a PR to implement that up soon.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest