pastemps

Is it possible to convert pasted text to node(s)


I have a user that wants to be able to copy a comma separated list of values and paste them into the editor in MPS. When pasting, the text would need to be split and each item in the list would need to be inserted as a separate node.

The structure of my nodes StringLiteralList Concept

So the copied text "123,456,789" when pasted into MPS should generate

node<StringLiteralList>
    node<StringLiteral> value = 123
    node<StringLiteral> value = 456
    node<StringLiteral> value = 789

Solution

  • Sure thing. You just read the data from the clipboard, parse it yourself and create the required nodes using the smodel language. The editor actions provide probably the best mechanism to trigger the action on Control + V.

    The PasteHandler in the j.m.lang.text language can serve as an example.