author | David Soria Parra <dsp <at> php.net> |
Thu, 03 Apr 2008 10:49:42 +0200 | |
changeset 6455 | fb76d58f5fee |
parent 6324 | ee1077b41d5c |
child 6456 | db5324d3c257 |
permissions | -rw-r--r-- |
6323
6e1308a09ffd
Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff
changeset
|
1 |
# pager.py - display output using a pager |
6e1308a09ffd
Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff
changeset
|
2 |
# |
6e1308a09ffd
Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff
changeset
|
3 |
# Copyright 2008 David Soria Parra <dsp@php.net> |
6e1308a09ffd
Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff
changeset
|
4 |
# |
6e1308a09ffd
Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff
changeset
|
5 |
# This software may be used and distributed according to the terms |
6e1308a09ffd
Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff
changeset
|
6 |
# of the GNU General Public License, incorporated herein by reference. |
6e1308a09ffd
Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff
changeset
|
7 |
# |
6324
ee1077b41d5c
pager: further simplify code, clean up comments
Matt Mackall <mpm@selenic.com>
parents:
6323
diff
changeset
|
8 |
# To load the extension, add it to your .hgrc file: |
6323
6e1308a09ffd
Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff
changeset
|
9 |
# |
6e1308a09ffd
Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff
changeset
|
10 |
# [extension] |
6e1308a09ffd
Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff
changeset
|
11 |
# hgext.pager = |
6e1308a09ffd
Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff
changeset
|
12 |
# |
6324
ee1077b41d5c
pager: further simplify code, clean up comments
Matt Mackall <mpm@selenic.com>
parents:
6323
diff
changeset
|
13 |
# To set the pager that should be used, set the application variable: |
6323
6e1308a09ffd
Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff
changeset
|
14 |
# |
6e1308a09ffd
Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff
changeset
|
15 |
# [pager] |
6324
ee1077b41d5c
pager: further simplify code, clean up comments
Matt Mackall <mpm@selenic.com>
parents:
6323
diff
changeset
|
16 |
# pager = LESS='FSRX' less |
6323
6e1308a09ffd
Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff
changeset
|
17 |
# |
6324
ee1077b41d5c
pager: further simplify code, clean up comments
Matt Mackall <mpm@selenic.com>
parents:
6323
diff
changeset
|
18 |
# If no pager is set, the pager extensions uses the environment |
ee1077b41d5c
pager: further simplify code, clean up comments
Matt Mackall <mpm@selenic.com>
parents:
6323
diff
changeset
|
19 |
# variable $PAGER. If neither pager.pager, nor $PAGER is set, no pager |
ee1077b41d5c
pager: further simplify code, clean up comments
Matt Mackall <mpm@selenic.com>
parents:
6323
diff
changeset
|
20 |
# is used. |
6323
6e1308a09ffd
Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff
changeset
|
21 |
# |
6e1308a09ffd
Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff
changeset
|
22 |
# If you notice "BROKEN PIPE" error messages, you can disable them |
6324
ee1077b41d5c
pager: further simplify code, clean up comments
Matt Mackall <mpm@selenic.com>
parents:
6323
diff
changeset
|
23 |
# by setting: |
6323
6e1308a09ffd
Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff
changeset
|
24 |
# |
6324
ee1077b41d5c
pager: further simplify code, clean up comments
Matt Mackall <mpm@selenic.com>
parents:
6323
diff
changeset
|
25 |
# [pager] |
ee1077b41d5c
pager: further simplify code, clean up comments
Matt Mackall <mpm@selenic.com>
parents:
6323
diff
changeset
|
26 |
# quiet = True |
6323
6e1308a09ffd
Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff
changeset
|
27 |
|
6e1308a09ffd
Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff
changeset
|
28 |
import sys, os, signal |
6e1308a09ffd
Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff
changeset
|
29 |
|
6e1308a09ffd
Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff
changeset
|
30 |
def uisetup(ui): |
6324
ee1077b41d5c
pager: further simplify code, clean up comments
Matt Mackall <mpm@selenic.com>
parents:
6323
diff
changeset
|
31 |
p = ui.config("pager", "pager", os.environ.get("PAGER")) |
6455
fb76d58f5fee
Pager extension: switch it off if --debugger is set
David Soria Parra <dsp <at> php.net>
parents:
6324
diff
changeset
|
32 |
if p and sys.stdout.isatty() and not ui.debugflag: |
6324
ee1077b41d5c
pager: further simplify code, clean up comments
Matt Mackall <mpm@selenic.com>
parents:
6323
diff
changeset
|
33 |
if ui.configbool('pager', 'quiet'): |
ee1077b41d5c
pager: further simplify code, clean up comments
Matt Mackall <mpm@selenic.com>
parents:
6323
diff
changeset
|
34 |
signal.signal(signal.SIGPIPE, signal.SIG_DFL) |
ee1077b41d5c
pager: further simplify code, clean up comments
Matt Mackall <mpm@selenic.com>
parents:
6323
diff
changeset
|
35 |
sys.stderr = sys.stdout = os.popen(p, "wb") |