[MERGE] Shelf 5 / 5

Vincent Ladeuil v.ladeuil+lp at free.fr
Wed Oct 29 07:26:18 GMT 2008


>>>>> "aaron" == Aaron Bentley <aaron at aaronbentley.com> writes:

<snip/>
 
    aaron> -
    aaron> +if sys.platform == "win32":
    aaron> +    import msvcrt
    aaron> +    def getchar():
    aaron> +        return msvcrt.getch()
    aaron> +else:
    aaron> +    import tty
    aaron> +    import termios
    aaron> +    def getchar():
    aaron> +        fd = sys.stdin.fileno()
    aaron> +        settings = termios.tcgetattr(fd)
    aaron> +        try:
    aaron> +            tty.setraw(fd)
    aaron> +            ch = sys.stdin.read(1)
    aaron> +        finally:
    aaron> +            termios.tcsetattr(fd, termios.TCSADRAIN, settings)
    aaron> +        return ch

Eerk ! Am I right in inferring from the above that the input
handling will be character based ?

This implies that it can't be used under emacs where input is
line buffered (i.e. you can't read a character at a time, only a
'\n' terminated line).

    aaron> === added file 'bzrlib/shelf_ui.py'
    aaron> --- bzrlib/shelf_ui.py	1970-01-01 00:00:00 +0000
    aaron> +++ bzrlib/shelf_ui.py	2008-10-27 19:34:38 +0000

<snip/>

    aaron> +    def prompt(self, message):
    aaron> +        sys.stdout.write(message)
    aaron> +        char = osutils.getchar()
    aaron> +        sys.stdout.write("\r" + ' ' * len(message) + '\r')
    aaron> +        sys.stdout.flush()
    aaron> +        return char

Or can this single method be overridden to address the issue ?

If I remember correctly the shelf-1 implementation didn't provide
a single point to change that behavior but it's been a while
since I last used it.

I don't have time to review all but this single point is
certainly the most important for me
so  BB:(overriding_is_enough_for_emacs_needs)?approve:veto :-)

Not at the beginning of line to avoid BB trying to catch it :)

    Vincent



More information about the bazaar mailing list