oeed / CraftOS-Standards

Community standard file formats, communication systems, etc. for ComputerCraft and CraftOS 2.0
Other
20 stars 16 forks source link

Clipboard #68

Open JakobDev opened 6 years ago

JakobDev commented 6 years ago

I have seen, that there are now standard for a Clipboard, so I have develop a Standard. It is very easy to use and allow multiple types of informations like text or image.

oeed commented 6 years ago

I can see this being useful. I think that maybe an API is the way to go over just a table, but I'm interested to hear what people think. One other thing you might want to add is whether is was cut or copy and if cut then clear it when pasted. I made an API for this for OneOS: https://github.com/oeed/OneOS/blob/master/System/APIs/Clipboard.lua

You do also have the issue of the real clipboard interfering.

SquidDev commented 6 years ago

I can see the use of a sane clipboard system, but a couple of thoughts:

I'm personally thinking of something like:

-- Get an entry of a particular type
function clipboard.get(name:string) end

-- Set the clipboard contents, where entries is a MIME type -> contents lookup
function clipboard.set(entries) end

-- Clear the clipboard
function clipboard.clear() end

If cut then clear it when pasted

Is this a mac-specific thing, as this seems rather weird to me - I'd expect to be able to paste a cut object multiple times.

You do also have the issue of the real clipboard interfering.

I guess you could check if the paste event is equal to the last string pasted and ignore it if so. Though that isn't really ideal. I don't think how programs should interface with the API is something which should be defined by the standard though.

viluon commented 6 years ago

Is this a mac-specific thing, as this seems rather weird to me - I'd expect to be able to paste a cut object multiple times.

I'm not sure if the behaviour @SquidDev seems to have in mind is a thing on certain systems, it does indeed sound more like a bug than a feature. However, what I think @oeed might have meant is the action a program has to perform e.g. when a file has been cut and then pasted. The file isn't moved anywhere from the directory it resides in until the user actually pastes it somewhere else - which might not even happen at all.

I'm not sure how the API should handle these cases...

oeed commented 6 years ago

Is this a mac-specific thing, as this seems rather weird to me - I'd expect to be able to paste a cut object multiple times.

Thinking about it, you're right, it's not universal. In some programs and situations (i.e. Excel, cutting files) it is the case though. I guess we'd want some way to tell the source that the cut occurred... maybe? Any ideas? It seems a little messy having to do that, but at the very least you'd expect cut files to be moved rather than copied. Perhaps we leave that up to the destination though.

It would be nice to support multiple clipboard types at once.

Definitely like that.

the data structure added MUST be serialisable and immutable

Agreed.