Interesting. I had this in mind since a long time but had not thought about bridging a native text editor. One obvious downside is that this would kinda be unix specific ...
Now, as to your questions, you're going into dark areas here. You've been warned ;-) On Sun, Dec 2, 2012 at 6:40 PM, Ioannis Canellos <[email protected]> wrote: > Hi guys, > > One feature I've always liked to have in the karaf console is the ability > to edit text files. See https://issues.apache.org/jira/browse/KARAF-2044 > > I took a stub last night, to integrate existing editors that might be > present in the system with the Karaf console (e.g. vi, nano or edit in > windows). > To my surprise starting the editor as a new Process and wiring input and > output seems to just work. > > There are just a few things I'd like to solve before committing and I > wanted some ideas: > > i) I can pass the terminal height and width to the process, but how do I > get those values get updated if I resize while the editor is open? > If the connection is done through ssh, the native terminal on the other side will send events that could be intercepted. However, when using a locale console, there's no easy way to be notified afaik. > ii) Some editor don't take kindly the delete character and prefer backspace > (changing ascii 127 to ascii 8). Is this safe to do. Is there a better way > to handle it? > iii) After closing the editor, the console sometimes gets "flaky" arrow > keys might stop working etc. > When creating a shell through ssh, the terminal configuration is passed through ssh. Those parameters are available at org.apache.sshd.server.Environment#getPtyModes() Now, the problem is to pass those terminal settings to the native process and this should be done by calling stty to configure the terminal. However, I'm not sure really what would happen when not using a real terminal, i.e. when calling from ssh. I suppose we'd have to create a pseudo-terminal and use it, but i fear this kinda rely on fork/exec unix stuff. I initially had in mind rewriting the editor, but given the huge task, I alwasy deferred it. Interfacing with a real native terminal is certainly easier, but the problems may be largely more difficult to solve, because java is not really the best way to interface with unix executable. Anyway, good work so far ... > > Thoughts? > > -- > *Ioannis Canellos* > * > > ** > Blog: http://iocanel.blogspot.com > ** > Twitter: iocanel > * > -- ------------------------ Guillaume Nodet ------------------------ Blog: http://gnodet.blogspot.com/ ------------------------ FuseSource, Integration everywhere http://fusesource.com
