Show More
@@ -5,50 +5,31 b'' | |||
|
5 | 5 | # This software may be used and distributed according to the terms |
|
6 | 6 | # of the GNU General Public License, incorporated herein by reference. |
|
7 | 7 | # |
|
8 | # To load the extension add it to your .hgrc file | |
|
8 | # To load the extension, add it to your .hgrc file: | |
|
9 | 9 | # |
|
10 | 10 | # [extension] |
|
11 | 11 | # hgext.pager = |
|
12 | 12 | # |
|
13 | # To set the pager that should be used, set the application variable | |
|
14 | # | |
|
15 | # [pager] | |
|
16 | # application = less | |
|
17 | # | |
|
18 | # You can also set environment variables there | |
|
13 | # To set the pager that should be used, set the application variable: | |
|
19 | 14 | # |
|
20 | 15 | # [pager] |
|
21 |
# |
|
|
16 | # pager = LESS='FSRX' less | |
|
22 | 17 | # |
|
23 |
# If no |
|
|
24 |
# variable $PAGER. If neither pager. |
|
|
25 | # $PAGER is set, no pager is used. | |
|
18 | # If no pager is set, the pager extensions uses the environment | |
|
19 | # variable $PAGER. If neither pager.pager, nor $PAGER is set, no pager | |
|
20 | # is used. | |
|
26 | 21 | # |
|
27 | 22 | # If you notice "BROKEN PIPE" error messages, you can disable them |
|
28 | # by setting | |
|
23 | # by setting: | |
|
29 | 24 | # |
|
30 | 25 | # [pager] |
|
31 | 26 | # quiet = True |
|
32 | # | |
|
33 | 27 | |
|
34 | 28 | import sys, os, signal |
|
35 | 29 | |
|
36 | def getpager(ui): | |
|
37 | '''return a pager | |
|
38 | ||
|
39 | We separate this method from the pager class as we don't want to | |
|
40 | instantiate a pager if it is not used at all | |
|
41 | ''' | |
|
42 | if sys.stdout.isatty(): | |
|
43 | return (ui.config("pager", "application") | |
|
44 | or os.environ.get("PAGER")) | |
|
45 | ||
|
46 | 30 | def uisetup(ui): |
|
47 | # disable broken pipe error messages | |
|
48 | if ui.configbool('pager', 'quiet', False): | |
|
31 | p = ui.config("pager", "pager", os.environ.get("PAGER")) | |
|
32 | if p and sys.stdout.isatty(): | |
|
33 | if ui.configbool('pager', 'quiet'): | |
|
49 | 34 | signal.signal(signal.SIGPIPE, signal.SIG_DFL) |
|
50 | ||
|
51 | if getpager(ui): | |
|
52 | pager = os.popen(getpager(ui), 'wb') | |
|
53 | sys.stderr = pager | |
|
54 | sys.stdout = pager | |
|
35 | sys.stderr = sys.stdout = os.popen(p, "wb") |
General Comments 0
You need to be logged in to leave comments.
Login now