Giter Site home page Giter Site logo

Clipboard about splat HOT 8 CLOSED

reactiveui avatar reactiveui commented on May 5, 2024
Clipboard

from splat.

Comments (8)

anaisbetts avatar anaisbetts commented on May 5, 2024

@rzhw Meh, who cares about Windows Phone. What I'm on the fence about is, should the clipboard be at the ViewModel layer (i.e. Splat is a library primarily for writing platform-independent ViewModel code). I could be swayed either way. Thoughts?

from splat.

rzhw avatar rzhw commented on May 5, 2024

Good point. My need for clipboard support isn’t too big, so thoughts:

  • Idea of vm is to be layer between view + model(s); clipboard could be thought of another model, so it shouldn't be part of helper code for vms
  • But there already is image loading/saving. Could also argue images on FS/bundle are also a model. So clipboard is another model that can be supported
  • Problem of common interface; Cocoa has multiple pasteboards, WinRT + WPF have different clipboard APIs, there's different data formats that need support, WinPho can't be supported. Needing feature checking = :(
  • But images already has a common interface. For clipboard baseline of get+set text, img, richtext, binary should be fine. Throw exceptions instead of requiring feature checks?

from splat.

anaisbetts avatar anaisbetts commented on May 5, 2024

How about something like:

public enum ClipboardContentType {
    Text,
    Html,
    Url,
    Image,
    Binary,
}

public interface IClipboard 
{
    ClipboardContentType? ContentType { get; }   // returns null if clipboard empty

    Task<byte[]> Get();
    Task Set(byte[] data, ClipboardContentType = Binary);
};

On top of Get and Set, you could make extension methods for strings, images, etc etc.

from splat.

rzhw avatar rzhw commented on May 5, 2024

Hm, base of just byte[]/Stream might not be possible, looking through docs for the WPF Clipboard class it looks like it's only possible to get data in predefined formats, seems to be same for WinRT (GetContent/DataPackageView)

from splat.

rzhw avatar rzhw commented on May 5, 2024

From some quick reading, looks possible for Cocoa

From the selection, identify or obtain the object or the binary data corresponding to the object.

Binary data must be encapsulated in an NSData object. If you’re going to write another type of object to the pasteboard, it must be a property-list object—that is, an object of one of the following classes: NSString, NSArray, NSDictionary, NSDate, NSNumber, or NSURL. (For more on property-list objects, see Property List Programming Guide.)

and Android

Quickview

A clipboard-based framework for copying and pasting data.
Supports both simple and complex data, including text strings, complex data structures, text and binary stream data, and application assets.

from splat.

anaisbetts avatar anaisbetts commented on May 5, 2024

Hm, base of just byte[]/Stream might not be possible, looking through docs for the WPF Clipboard class it looks like it's only possible to get data in predefined formats

You should be able to roll through all of the possible binary formats via "ContainsFormat" and see if any of them can be represented as binary (most of them can be).

from splat.

anaisbetts avatar anaisbetts commented on May 5, 2024

If not, I'd extend it to either text or binary

from splat.

rzhw avatar rzhw commented on May 5, 2024

I think coming back to this, it might be better suited to a separate library since doing all the abstraction looks like quite a big task, or at least until something usable comes out.

from splat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.