463 posts
Location
Star Wars
Posted 27 May 2016 - 11:32 PM
Something like:
(io/os).setClipboard(string/any value, mode)
mode = 'a' – Like fs.open(path, 'a')
mode = 'w' – Like fs.open(path, 'w')
EDIT:
I skimmed all the answers, what's about to implement CTRL + C and
(io/os).setClipboard(strinh/any toCopy)
Sets the string, which can be copied with CTRL + C.
The top brass programs (bios.lua[, cc.jar?]) knows, who sends the copy command and sets to their clipboard.
Edited on 29 May 2016 - 11:44 AM
2679 posts
Location
You will never find me, muhahahahahaha
Posted 28 May 2016 - 12:06 AM
How are you going to know which user's clipboard? More than one people can use a CC computer at the same time.
3057 posts
Location
United States of America
Posted 28 May 2016 - 12:13 AM
Why would I want CC to be able to overwrite the contents of my clipboard without my permission?
276 posts
Location
Fairbanks, Alaska
Posted 28 May 2016 - 12:57 AM
Why would I want CC to be able to overwrite the contents of my clipboard without my permission?
That could be a settings() function somehow.
818 posts
Location
Wherever you want me to be
Posted 28 May 2016 - 01:20 AM
Why would I want CC to be able to overwrite the contents of my clipboard without my permission?
That could be a settings() function somehow.
which could be off by default
7083 posts
Location
Tasmania (AU)
Posted 28 May 2016 - 01:36 AM
The point is that the setting shouldn't be defined by the computer - if you don't want a given system messing with your clipboard, then what's the point in giving that system a function which anyone can use to make it write to your clipboard anyway?
That leaves ComputerCraft.cfg, but even if such a setting were implemented… that still doesn't answer Creator's question. How can you ever be sure you're writing to the correct user's clipboard?
276 posts
Location
Fairbanks, Alaska
Posted 28 May 2016 - 06:39 AM
The point is that the setting shouldn't be defined by the computer - if you don't want a given system messing with your clipboard, then what's the point in giving that system a function which anyone can use to make it write to your clipboard anyway?
That leaves ComputerCraft.cfg, but even if such a setting were implemented… that still doesn't answer Creator's question. How can you ever be sure you're writing to the correct user's clipboard?
Maybe some sort of user environment table that you could use. Maybe something like _players.originalPlayer or _players.index[some number representing a player]
724 posts
Posted 28 May 2016 - 06:43 PM
How are you going to know which user's clipboard? More than one people can use a CC computer at the same time.
Why would I want CC to be able to overwrite the contents of my clipboard without my permission?
Player should initiate process.
One way for it is to add couple of keys to bind couple of actions:
1.Copy action, initiating special event and allowing special function to send info to clipboard.
2.Paste action, initiating special event with clipboard info as a parameter.
So player would be able to map those actions on his keyboard and know when his clipboard is used.
Lua program would be able to use Copy and Paste actions without any knowledge about affected player and only when the player initiate it.
1080 posts
Location
In the Matrix
Posted 28 May 2016 - 07:59 PM
But given that more than one player can be inside a computer's screen at one time, how could the computer differentiate between different users? What if user A wanted to copy something, but user B had something incredibly important on his clipboard. If person A copied something, how would cc know not to put it onto player B's clipboard?
While I'm a fan of the concept, in practice it would cause more harm than good, and IF Dan were to implement this, then he'd have to create more than just a function to set clipboards, he'd have to differentiate between users and that's just not feasible.
818 posts
Location
Wherever you want me to be
Posted 29 May 2016 - 03:17 AM
But given that more than one player can be inside a computer's screen at one time, how could the computer differentiate between different users? What if user A wanted to copy something, but user B had something incredibly important on his clipboard. If person A copied something, how would cc know not to put it onto player B's clipboard?
While I'm a fan of the concept, in practice it would cause more harm than good, and IF Dan were to implement this, then he'd have to create more than just a function to set clipboards, he'd have to differentiate between users and that's just not feasible.
isn't this pretty much what creator said but in a lot more detail…
How are you going to know which user's clipboard? More than one people can use a CC computer at the same time.
130 posts
Posted 29 May 2016 - 05:46 AM
What about if there was a buffer that was copied from…
So when you select text in a program, the buffer would be set to the contents of the selection (via a setSelection function or something).
Then when a client tries to copy from that computer it reads from the buffer (which could be synced or requested).
724 posts
Posted 29 May 2016 - 07:34 AM
But given that more than one player can be inside a computer's screen at one time, how could the computer differentiate between different users? What if user A wanted to copy something, but user B had something incredibly important on his clipboard. If person A copied something, how would cc know not to put it onto player B's clipboard?
It was directly after my post and answer in my post already. Player, activated Copy action, would get copy, not the others.
What about if there was a buffer that was copied from…
So when you select text in a program, the buffer would be set to the contents of the selection (via a setSelection function or something).
Then when a client tries to copy from that computer it reads from the buffer (which could be synced or requested).
This can work too.
For Copy action Player get copy of buffer (and create event for program to know).
For Paste action Player set buffer and create event for program to make actual paste.
For Cut action Player get copy of buffer and create event to clear buffer and make actual cut.
2679 posts
Location
You will never find me, muhahahahahaha
Posted 29 May 2016 - 08:41 AM
What about if there was a buffer that was copied from…
So when you select text in a program, the buffer would be set to the contents of the selection (via a setSelection function or something).
Then when a client tries to copy from that computer it reads from the buffer (which could be synced or requested).
As I was reading through the responses, this is the xact solution that came to my mind too. The PC has a function os.toClipboard(), then when a user presses ctrl+c the minecraft client copies the selected text into the clipboard of the user who pressed the keys. A copy event is fired, but this part is not obligatory.
463 posts
Location
Star Wars
Posted 29 May 2016 - 01:43 PM
I have edited my question.