On Tue, Jun 16, 2009 at 05:38, Isaac
Dupree<[email protected]> wrote:
>> There is http://codespeak.net/pyrepl/ that implemented multi-line editing
>> in pure Python, whose implementation might give you some ideas.
>
> Interesting; do you know if it works well?
>
It does, though I didn't use it a lot (it has an annoyingly slow
startup, and I prefer IDLE to terminal anyway).
I did manage to crash it with a backtrace twice in the last few
minutes when trying to stress-test it.

It pulls off the uniquely nice trick of updating completions while you
type and completely removing them from the screen once you are done
with them, which we might want emulate in fish (<...> added by me to
show interaction):

->>
->> fo<cursor>

<press TAB>

->>
[ complete but not unique ]
->> for<cursor>

<press TAB>

->>
[ for    ][ format ]
->> for<cursor>

<press 'm'>

->>
[ format ]
->> form<cursor>

<press TAB>

->>
[ format ]
->> format<cursor>

<press '('>

->>
->> format(<cursor>

See how the list reduces while typing and disappears when you are done
with this word?

Completion during multi-line entry is located a bit inconveniently
above current line:

/>> for i in range(10):
|..   print i<cursor>
\__   print i

<press TAB>

/>> for i in range(10):
[ id         ][ if         ][ import     ][ in         ][ input
][ int        ][ intern     ][ is         ][ isinstance ][ issubclass
]
[ iter       ]
|..   print i<cursor>
\__   print i

I love the way paging works (takes whole screen, middle part snipped):

/>> for i in range(10):
[ ArithmeticError           ][ AssertionError            ][
AttributeError            ][ BaseException             ]
[ BufferError               ][ BytesWarning              ][
DeprecationWarning        ][ EOFError                  ]
<snip...>
[ is                        ][ isinstance                ][ issubclass
               ][ iter                      ]
[ lambda                    ][ len                       ][ license
               ][ list                      ]
   45 more...
|..   print <cursor>

and repeated <TAB> presses replace the completions area with next
pages (cyclic).
And when you continue typing, the completions list reduces automatically

This is IMHO much better than fish's current full-screen pager,
because it makes it clear that you can continue editing your command.
After couple a year, I still press 'q' every time the fish pager pops
up!

P.S. When I said I'd like to see a "readmultiline" library extracted
from fish to use it in Python,
that's a weak motivation because hacking to pyrepl is the easiest way
to achieve it for Python.
But I do believe that a library bringing state-of-the-art [multi]line
editing to all C program that
currently use readline would greatly advance the unix terminal experience.

That means its API should be as compatible to readline as possible.
(To accept multi-line input in a useful way, the program would have to
provide a function that
check if given input is a complete command; to support syntax
highlight the program would have
to provide some kind of parser, which is harder.)
And it's possible, that it'd be easier to implement by hacking on
readline code (with fish and pyrepl
as reference) than by directly using fish code.

-- 
Beni <[email protected]>

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to