CC: Tweaked

CC: Tweaked

57M Downloads

Select/cut/copy/paste Functionality in Edit

Flexico opened this issue ยท 7 comments

commented

As much as I like the immersion of programming right on my computer/turtle; when writing longer programs I often need to open the file in Notepad++ to move things around or something.

I think it should work like holding Shift and using the arrow keys like works in most text editing programs. Thanks for reading!

commented

This is something I'd love to do, but it's really hard to do in a consistent manner.

The issue here is with pasting - users can already paste from their system clipboard, so if we have one internal to the editor it gets a little more confusing.

I really don't want computers to be able to modify the system keyboard (that gets really weird on multiplayer), so I guess the alternative is to have a different keybinding for paste (such as Shift+Insert).

Don't know if other people have ideas on how to better to do this?

commented

I'd go with Ctrl+Shift+X/C/V myself! That's how you do it in the Linux terminal. OH wait -- the Ctrl key already has a job in Edit. Maybe use Alt instead?

And another thought, how does CC handle Unicode characters? And what about removing formatting? Is that hard to implement?

commented

Maybe ^V could paste from the system clipboard when nothing is present in the edit clipboard, and paste from the edit clipboard otherwise. I'm a bit concerned with using Insert, as there are many keyboards (Apple) that don't have an Insert key, which would make this keybind inaccessible. nano uses ^K and ^U to cut and un-cut, respectively, but these may be a bit more vague/unfamiliar to non-nano-users. Pasting could also be done by right-clicking as the Windows console uses.

And another thought, how does CC handle Unicode characters? And what about removing formatting? Is that hard to implement?

For the most part, CC does not handle Unicode inside Lua. Lua itself stores strings as an unformatted byte string, so it only supports 8-bit characters without doing extra processing. The FS API automatically converts character codes 128-255 between UTF-8 and Lua strings in text mode, but that's about it. Any characters outside the 0-255 range are converted to ?. There's also the utf8 API, but I don't think I've seen this used anywhere except for the JSON parser.

commented

I'm a bit concerned with using Insert, as there are many keyboards (Apple) that don't have an Insert key

Huh, that's interesting. IIRC OpenComputers uses it (although it's rebindable), so had assumed there weren't any problems.

Pasting could also be done by right-clicking as the Windows console uses.

Yep, or middle click, which is also a fairly common binding. Gah, if only there was a standard one.

I don't actually think Ctrl+Shift+X/C/V is that bad an option though either - we can definitely do it so it won't conflict with the main menu. That said, complex bindings are annoying to wrangle in CC, as you need to track the current up/down state.

commented

That said, complex bindings are annoying to wrangle in CC, as you need to track the current up/down state.

Sounds like we need a built-in module for that, I wonder if Metris might go the same way as Plethora?

commented

I wonder if Metris might go the same way as Plethora?

Buggy and largely unmaintained? ๐Ÿ˜›

commented

I actually have an old edit program which (maybe?) supports copy and paste - https://pastebin.com/guNvJcZ9

It also supports selections, I think. But I also think it's really slow, and, obviously, hasn't been updated in a while. It also has some outdated assumptions, like that the edit program uses 2 spaces as tab (it doesn't anymore afaik). It also requires an advanced computer I think. I have plenty of gripes with it but it's probably close to what you want