From: Giacomo Fiorin (giacomo.fiorin_at_gmail.com)
Date: Wed May 20 2020 - 10:06:50 CDT

Hi John, I just built VMD using the -DVMDLINENOISE flag and linenoise.c
added to the Makefile, and manually edited the "vmd" launcher script after
building to remove rlwrap.

I can confirm that with linenoise I can access the history of VMD commands
by using the up and down arrows, and move the cursor left or right using
the corresponding arrows. Two of the most basic readline keys (Ctrl-a and
Crtr-e, equivalent to Home and End) are able to navigate at the beginning
and the end of the current line. Also, Ctrl-h and Backspace delete the
last character and Ctrl-l correctly clears the screen.

Here are several things that differ from readline (details may be specific
to my build on CentOS 7 with gcc 4.8):

   - Word navigation (Alt-f and Alt-b, or Ctrl-Left and Ctrl-Right) is not
   supported.
   - Ctrl-k (kill aka cut) is supported, but not Ctrl-y (yank, aka paste).
   - Tab inserts a tab, and does not autocomplete. There may be something
   wrong in my build, since this is actually an advertised feature in the
   linenoise README.
   - There is no persistent history (people's opinions on the importance of
   this feature may differ).

I used vmd -dispdev text, both with TERM=xterm-256color (default in
gnome-terminal) and with TERM=xterm set by hand.

Assuming that tab completion can be fixed, I'm frustrated by the lack of an
explicit list of supported features: IMO, "the usual key bindings" is not
sufficient. Also IMO, word navigation and copy/paste are essential
features of command-line editing.

Overall, I would still prefer using rlwrap over linenoise given the choice.

I would definitely welcome the ability to turn rlwrap on/off based on an
environment variable, the default value of which should be based on most
people's preference. One quirk that I noticed was that rlwrap was
interfering with the input/output channels handled by GNU parallel, which I
use sometimes to process a bunch of trajectory files using the same
script. Using a custom vmd script where I stripped the rlwrap part fixed
that problem for me, but I would very much welcome an environment variable
for this.

Thanks for pointing out this feature to us, please let me know if I can
provide anything else.
Giacomo

On Wed, May 20, 2020 at 3:55 AM John Stone <johns_at_ks.uiuc.edu> wrote:

> Axel, et al.,
> Since people have recently been begging me to include
> 'rlwrap' with VMD by default I revisited the current crop
> of GNU readline alternatives unencumbered by problematic
> licenses.
>
> To my delight, I managed to find an input editing library
> that is very minimalistic-but-usable, with a BSD license,
> called "linenoise":
> https://github.com/antirez/linenoise
>
> I've made initial modifications to VMD to support it,
> and thought I'd see what people think about this as an
> alternative to our current strategy of 'rlwrap' autodetection.
> It's in the current publically accessible VMD CVS tree, but I've
> also attached the current TclTextInterp.[Ch] files.
>
> If people think this is as good as rlwrap, and it holds up in testing,
> I would like to consider changing the behavior of the VMD
> startup scripts to use rlwrap only when the user requests it
> specifically (e.g. via a special env variable), which would
> also disable the built-in command editing at the same time.
>
> I've made an effort to maintain proper special handling of
> console redirection, MPI builds of VMD, and other cases by
> integrating the new console support with our existing code,
> but I need to run tests on several parallel MPI platforms and
> such to validate that it works as expected in these special cases.
>
> The new code is enabled by compiling with -DVMDLINENOISE
> and hacking in linenoise.c to the generated VMD
> Makefile manually at present.
>
> I haven't yet done a Windows build with this library,
> so that remains a future challenge when I get myh Windows x64
> build system completely setup.
>
> Best,
> John
>
> --
> NIH Center for Macromolecular Modeling and Bioinformatics
> Beckman Institute for Advanced Science and Technology
> University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
> http://www.ks.uiuc.edu/~johns/ Phone: 217-244-3349
> http://www.ks.uiuc.edu/Research/vmd/
>

-- 
Giacomo Fiorin
Associate Professor of Research, Temple University, Philadelphia, PA
Research collaborator, National Institutes of Health, Bethesda, MD
http://goo.gl/Q3TBQU
https://github.com/giacomofiorin