Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pure Julia readline-like library #770

Closed
StefanKarpinski opened this issue Apr 28, 2012 · 20 comments
Closed

pure Julia readline-like library #770

StefanKarpinski opened this issue Apr 28, 2012 · 20 comments
Labels
help wanted Indicates that a maintainer wants help on an issue or pull request

Comments

@StefanKarpinski
Copy link
Member

As discussed here. See LineNoise for inspiration: https://github.com/antirez/linenoise.

@ViralBShah
Copy link
Member

@StefanKarpinski Do you think we have the necessary I/O capability to be able to do this and in a platform independent way? It would be really cool to pull this off because one could do other julia specific interesting things as well.

@JeffBezanson
Copy link
Member

Just needs unbuffered reads and writes, and ioctl. But I have no idea about windows. This would really have to be a labor of love. People like emacs/vi keybindings, etc. Maybe we should fork linenoise and start from there.

@pao
Copy link
Member

pao commented May 2, 2012

How does PuTTY provide a text console? Perhaps we can just borrow theirs for Windows. Wonder if it has the right abstractions. License is MIT. https://github.com/Yasushi/putty/ is an unofficial mirror if you want to browse the sources.

@Keno
Copy link
Member

Keno commented May 2, 2012

Windows has their own terminal API that is not too terribly difficult to use. I'll have a look at putty and what we can do with the terminal. That could also solve the terrible color profile problems of the windows command line.

@StefanKarpinski
Copy link
Member Author

I'm not sure it has to be all that hard. I mean, we're just talking key bindings here. If you pick the "actions" correctly, which everyone else has already done, then it's just a matter of implementing them. Then again, there's a lot of other things I can be spending my time on and I'm not sure that rewriting readline in Julia is the best choice.

@Keno
Copy link
Member

Keno commented May 2, 2012

Also, if people don't want to use Readline, there's always the Web REPL.

@Keno
Copy link
Member

Keno commented May 28, 2013

Done: https://github.com/loladiro/Readline.jl
Combining this with https://github.com/loladiro/REPL.jl and https://github.com/loladiro/Terminals.jl gives you a nice REPL that is almost as powerful as the current one and less buggy:

using Terminals
using Readline
using REPL
REPL.run_repl(Terminals.Unix.UnixTerminal(get(ENV,"TERM","xterm"),STDIN,STDOUT,STDERR))

I guess I'll close this issue and specific feature requests can be made over there.

@Keno Keno closed this as completed May 28, 2013
@JeffBezanson
Copy link
Member

Looks awesome. Can't wait to try it out.

@JeffBezanson
Copy link
Member

Of course this will be in Base eventually. Could you briefly say in what way it is "almost" as powerful, i.e. what's missing, so we can plan using it to replace our current repl?

@Keno
Copy link
Member

Keno commented May 28, 2013

Hmm, from the top of my head:

  • Reverse search
  • Custom key bindings
  • Random other stuff Readline did that people like

@timholy
Copy link
Member

timholy commented May 28, 2013

This does sound awesome! I tried it and got this error:

ERROR: could not load module /Users/keno/Documents/src/ncurses-5.9/lib/libncursesw: /Users/keno/Documents/src/ncurses-5.9/lib/libncursesw: cannot open shared object file: No such file or directory

I notice the Users/keno in the path, suggesting there's some hard-coding that you probably didn't intend.

@Keno
Copy link
Member

Keno commented May 28, 2013

Ah, you're right. My bad, I haven't tested on any other machine yet.

@Keno
Copy link
Member

Keno commented May 28, 2013

Fixed! I'll get to adding proper support for finding curses binaries soon, but it's getting later here, so no before tomorrow.

@Keno
Copy link
Member

Keno commented May 28, 2013

Also, you might (will) need my changes in #3229, or you could just hold off until I get to putting this into METADATA and get it tested on other machines.

@Keno
Copy link
Member

Keno commented May 28, 2013

Alright, I have verified that this works on a Linux machine (assuming you have #3229), so I'll call it a night. I'll keep working on this to get it feature complete as soon as possible. The old readline REPL really needs to go.

@simleb
Copy link

simleb commented May 29, 2013

This looks great!
For the reverse search, readline's ^R is pretty handy sometimes but I found Matlab's history search using the up arrow that cycles through the last commands starting with what you already typed to be extremely handy.
I use this feature in zsh too with:

bindkey "^[[A" history-search-backward
bindkey "^[[B" history-search-forward

If you can make this work you're the king!

@ViralBShah
Copy link
Member

This is amazing! Really looking forward to having this in base. I suspect that we will be able to do all kinds of cool things going forward. Tab-completion of keyword argument names, for example.

I use reverse search and forward search all the time. I even have stty -ixon in my .bashrc. I would love to also have partial completion + up/down do Matlab style history search, in addition to reverse and forward search with ctrl-r and ctrl-s.

@StefanKarpinski
Copy link
Member Author

This is really great. The ncurses stuff is a bit nasty but inevitable. The rest is lovely – so much better than the abomination that is our current C repl code.

@Keno
Copy link
Member

Keno commented May 30, 2013

I started out with ncurses, but then I realized I didn't actually need it, so it's optional at this point. I'll move it out to a separate package soon

@Keno
Copy link
Member

Keno commented Jul 11, 2013

Search and custom keybindings now implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Indicates that a maintainer wants help on an issue or pull request
Projects
None yet
Development

No branches or pull requests

7 participants