Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Over 20 years ago now I wrote a state machine around readline that meant you could use it as a multi-line editor. Not "multi-line" as in a single line can wrap, but a true editor that lets you move up and down, but is windowless.

Here's a video:

    https://github.com/colmmacc/jot/raw/master/jot-demo.mp4
and the CVS repository for the Unix terminal IM client it is part of is at:

    https://c-hey.redbrick.dcu.ie/src/c-hey_cvs_latest/
It tracks and redraws your cursor when you move up and down between lines, and also pays attention to SIGWINCH to redraw things when the terminal size changes. I've never had the time to rewrite it in Rust, but I'd like to and then release it as a small library.

It's always surprised me that nobody else has done this.



That's pretty cool, gonna steal the idea.

I can implement that specific case with a couple of lines in zsh. Something like:

    autoload -Uz zed
    icommit() {
      () {
        zed $1
        git commit -F $1  # -a too, if you must ;)
      } =(:)  # Or maybe even =(< commit_template.txt)
    }
Then icommit, via zed¹, will initiate an inline editor with all the power of ZLE available. Hit C-x C-w to write and commit, or C-c to abort. Obviously, you'd want some error checking and the like².

Beauty of this basic implementation is that the keymap is fully controllable in zed as it is simply a new ZLE widget. It works with emacs or vi mode out of the box, and is fully customisable beyond that.

You could make the interface generic by writing your own ZLE widget, so that it can be called directly from within the line editor and remove the need for wrapping commands like I did above.

¹ https://github.com/zsh-users/zsh/blob/master/Functions/Misc/...

² This at least uses, and cleans up, a temp file to handle the commit message so it isn't completely useless.


This was fascinating!! Please do consider bringing it back to life as a library and sharing with HN.

I had no idea how much better such an editing experience is until your video, and completely agree about the benefit of not having to context-switch a la git commit "interactive mode". The "inline typewriter" effect is also really cool


Yeah. That's how rio's text windows [0] look like in hold mode, except that it has a much simpler design and better support of mouse.

[0] https://p9f.org/magic/man2html/1/rio


Oh, that looks really cool! Is the current iteration of the program stable?


Checked out the video. Looks cool!


Thanks for the screencast. Another +1 for bringing it back to life!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: