tonylukasavage / triple

REPL for Titanium
MIT License
96 stars 21 forks source link

#8 tab completion #29

Closed jhaynie closed 10 years ago

jhaynie commented 10 years ago

read api.jsca to perform tab completion for Ti api.

tonylukasavage commented 10 years ago

The sdk find, read, and load into namespaces looks great, exactly how I was planning to do it given Titanium's limitations. It would have been very slick to do it like I wanted to originally, by evaling the last part of the expression and returning the properties of it back to the REPL (would work for anything then, not just Titanium objects), but that wouldn't work for Ti namespaces or proxies since you can't read there properties or functions like normal JS objects. And with that I continue to long for Ti.Next...

There is a problem with the completer though. A minor one where it dumps all possible matches whenever it doesn't find a match. This seems like an odd UX. I'm going to change it to only do that if the line is empty.

The real problem is that the completion only works when the Titanium namespace is the first and only thing in the line. For example, you get no help typing this and then a tab:

$ triple
> var win = Ti.UI.create

It only works if Ti.UI.create was at the beginning of the line. There's some good code in node.js's own REPL server that handles this. It's a bit more complex than we need, but I think the relevant regexs can be lifted and used to better identify where this auto-complete can occur anywhere in the statement.

tonylukasavage commented 10 years ago

I merged this in and created #32 to address the shortcoming in auto-completion. Thanks again.