benanders / LuaIDE

An in-game IDE for ComputerCraft
MIT License
43 stars 10 forks source link

Duplication issue #18

Closed theoriginalbit closed 11 years ago

theoriginalbit commented 11 years ago

Your code completion is causing duplication issues. ideally when you press ' and there is a ' after the cursor it should just move the position and not actually add in another '.

When copy/pasting text in all the auto added characters are added, you should not do this to pasted text example

benanders commented 11 years ago

I fixed the duplication issue, how do you suppose I detect a copy and paste from a user input?

theoriginalbit commented 11 years ago

well I'm not too sure because I haven't read your code thoroughly but I'm assuming when you have user input you pass it to a function that deals with duplicating the appropriate symbols? If so then just have the paste bypass that and just do a straight concat?

benanders commented 11 years ago

Yeah, but how do I detect a paste? :P How do I tell the difference between the user typing something, and CC typing something as a paste?

EDIT: hang on, were you talking about pasting lines, or when control+v is pressed?

superaxander commented 11 years ago

You can detect pasting with ctrl+v or when the char event gets multiple chars inside the string

benanders commented 11 years ago

o.O so that's why the edit program does x = x+char:len() instead of x = x+1...

But if that's the case, then this shouldn't cause problems (I think). I'll look into it.

theoriginalbit commented 11 years ago

I've had a look and I can't see it... where do you actually handle the paste?

benanders commented 11 years ago

BIT: I don't handle pastes. CC just converts every letter of the paste into a char event.

superaxander: a paste isn't treated as a single char event. I just tested it. http://i.imgur.com/aXsOwpF.png

So basically there's no way for me to differentiate between the user pressing a key and CC pasting something in, so I can't actually do this BIT :( (that is, the part about stopping pasting from triggering the double "") Also, this won't happen when using the built in paste line function.

superaxander commented 11 years ago

Ok. But I still recommend using the length cause I know many auto-typers that use multiples letters in one char event and it makes it easier for my os to copy paste into your program :+1:

benanders commented 11 years ago

Added that and fixed the first part of BIT's post.