mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
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 <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Kim Phillips <[email protected]> Cc: Namhyung Kim <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
This commit is contained in:
parent
c12e039d12
commit
03a1f49f26
2 changed files with 11 additions and 1 deletions
|
|
@ -23,6 +23,13 @@ void pager_init(const char *pager_env)
|
|||
subcmd_config.pager_env = pager_env;
|
||||
}
|
||||
|
||||
static const char *forced_pager;
|
||||
|
||||
void force_pager(const char *pager)
|
||||
{
|
||||
forced_pager = pager;
|
||||
}
|
||||
|
||||
static void pager_preexec(void)
|
||||
{
|
||||
/*
|
||||
|
|
@ -66,7 +73,9 @@ void setup_pager(void)
|
|||
const char *pager = getenv(subcmd_config.pager_env);
|
||||
struct winsize sz;
|
||||
|
||||
if (!isatty(1))
|
||||
if (forced_pager)
|
||||
pager = forced_pager;
|
||||
if (!isatty(1) && !forced_pager)
|
||||
return;
|
||||
if (ioctl(1, TIOCGWINSZ, &sz) == 0)
|
||||
pager_columns = sz.ws_col;
|
||||
|
|
|
|||
|
|
@ -7,5 +7,6 @@ extern void pager_init(const char *pager_env);
|
|||
extern void setup_pager(void);
|
||||
extern int pager_in_use(void);
|
||||
extern int pager_get_columns(void);
|
||||
extern void force_pager(const char *);
|
||||
|
||||
#endif /* __SUBCMD_PAGER_H */
|
||||
|
|
|
|||
Loading…
Reference in a new issue