[PyCrust] New command history retrieval features
Brought to you by:
pobrien
From: Patrick K. O'B. <po...@or...> - 2001-09-03 22:20:53
|
The cvs version of PyCrust now has some command history retrieval features submitted by Richie Hindle that are quite handy to have until I revamp the underlying structure of the shell session. And even then, the implementation may change but the features themselves probably will not. Richie has done a very nice job of giving us most of the command retrieval functionality that users expect. Attached is part of his email to me, which explains in detail how the new features work. In a nutshell, Control-Up and Control-Down scroll through the buffer of previous commands. If you select one in the middle of the list it remembers that position so you can get subsequent commands with Control-Down, making it very easy to get back a sequence of commands that form a code block, such as a block starting with "for n in range(10):". Another cool feature is that typing a few letters and hitting F8 does a search to find previous commands that start with those letters. See the message below for details. Thanks a bunch, Richie. P.S. I'm sticking with binding the retrieval commands to Control-Up and Control-Down until we have a proper way to allow user configuration of these things, or until I get a bunch of flame mail. I have two reasons for this: first, I like these key bindings and second, that's the way PythonWin does it. Feel free to disagree, or, better, design a really cool way to do user configurations. <wink> --- Patrick K. O'Brien Orbtech (http://www.orbtech.com) "I am, therefore I think." -----Original Message----- From: Richie Hindle [mailto:ri...@en...] Sent: Monday, September 03, 2001 2:46 PM To: po...@or... Subject: Re: Command history for PyCrust Hi Patrick, Thanks for the quick feedback, and thanks for incorporating my edits! > I bound it to the Control-Up and Control-Down keys [...] Did you have > a reason for wanting the Alt-key combos? Only that the Control-modified keys were already in use, for scrolling the window. (In fact there's now a bugette in there whereby Control-Up will revert to scrolling the window when you get to the top end of the history; easily fixed, but maybe Alt-Up/Down would be better?) > How does it handle multi-line commands? It doesn't - it's not Python-savvy. However, attached is another patch (against the CVS version this time) which has support for recall of groups of commands, which is also useful for multi-line commands. It works like the NT command prompt: if you go Up-Up-Up-Enter, then go Down, it takes you to the command following the one you just went back Up to. Hence repeating a group of commands over and over again becomes as easy as going Down-Enter-Down-Enter-Down-Enter. It's hard to visualise if you haven't used it before - have a go. It's designed for sequences that you tend to repeat over and over again while developing, like "reload( module ) // x = module.Foo() // x.bar()", but it works well for multi-line commands like "for i in range( 10 ): // print i". The patch also includes searching of the history - hitting F8 searches the history for commands starting with the text up to the cursor. Hitting it again repeats the search, and when it falls off the end it loops round. This is based on the NT command prompt as well, hence the choice of the F8 key. These two features together mean that recalling the above "reload..." sequence from anywhere in the recent history takes about eight keystrokes: "<r> <e> <F8> <enter> <control-down> <enter> <control-down> <enter>" |