diff options
author | Andi Kleen <ak@linux.intel.com> | 2018-09-18 08:32:07 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-09-19 14:16:19 -0400 |
commit | 03a1f49f26482cf832e7f0157ae5da716d927701 (patch) | |
tree | 1fea29677b382df9bdc75af292fe9bf5c9ab673b /tools | |
parent | c12e039d1233f24ab2726945f883037f47b26f1d (diff) |
tools lib subcmd: Support overwriting the pager
Add an interface to the auto pager code that allows callers to overwrite
the pager.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Kim Phillips <kim.phillips@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20180918123214.26728-3-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/lib/subcmd/pager.c | 11 | ||||
-rw-r--r-- | tools/lib/subcmd/pager.h | 1 |
2 files changed, 11 insertions, 1 deletions
diff --git a/tools/lib/subcmd/pager.c b/tools/lib/subcmd/pager.c index 9997a8805a82..e3d47b59b14d 100644 --- a/tools/lib/subcmd/pager.c +++ b/tools/lib/subcmd/pager.c | |||
@@ -23,6 +23,13 @@ void pager_init(const char *pager_env) | |||
23 | subcmd_config.pager_env = pager_env; | 23 | subcmd_config.pager_env = pager_env; |
24 | } | 24 | } |
25 | 25 | ||
26 | static const char *forced_pager; | ||
27 | |||
28 | void force_pager(const char *pager) | ||
29 | { | ||
30 | forced_pager = pager; | ||
31 | } | ||
32 | |||
26 | static void pager_preexec(void) | 33 | static void pager_preexec(void) |
27 | { | 34 | { |
28 | /* | 35 | /* |
@@ -66,7 +73,9 @@ void setup_pager(void) | |||
66 | const char *pager = getenv(subcmd_config.pager_env); | 73 | const char *pager = getenv(subcmd_config.pager_env); |
67 | struct winsize sz; | 74 | struct winsize sz; |
68 | 75 | ||
69 | if (!isatty(1)) | 76 | if (forced_pager) |
77 | pager = forced_pager; | ||
78 | if (!isatty(1) && !forced_pager) | ||
70 | return; | 79 | return; |
71 | if (ioctl(1, TIOCGWINSZ, &sz) == 0) | 80 | if (ioctl(1, TIOCGWINSZ, &sz) == 0) |
72 | pager_columns = sz.ws_col; | 81 | pager_columns = sz.ws_col; |
diff --git a/tools/lib/subcmd/pager.h b/tools/lib/subcmd/pager.h index f1a53cf29880..a818964693ab 100644 --- a/tools/lib/subcmd/pager.h +++ b/tools/lib/subcmd/pager.h | |||
@@ -7,5 +7,6 @@ extern void pager_init(const char *pager_env); | |||
7 | extern void setup_pager(void); | 7 | extern void setup_pager(void); |
8 | extern int pager_in_use(void); | 8 | extern int pager_in_use(void); |
9 | extern int pager_get_columns(void); | 9 | extern int pager_get_columns(void); |
10 | extern void force_pager(const char *); | ||
10 | 11 | ||
11 | #endif /* __SUBCMD_PAGER_H */ | 12 | #endif /* __SUBCMD_PAGER_H */ |