summaryrefslogtreecommitdiff
path: root/pager.c
diff options
context:
space:
mode:
Diffstat (limited to 'pager.c')
-rw-r--r--pager.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/pager.c b/pager.c
index a768797fcf..ee435de675 100644
--- a/pager.c
+++ b/pager.c
@@ -68,7 +68,7 @@ const char *git_pager(int stdout_is_tty)
return pager;
}
-static void setup_pager_env(struct argv_array *env)
+static void setup_pager_env(struct strvec *env)
{
const char **argv;
int i;
@@ -88,7 +88,7 @@ static void setup_pager_env(struct argv_array *env)
*cp = '\0';
if (!getenv(argv[i])) {
*cp = '=';
- argv_array_push(env, argv[i]);
+ strvec_push(env, argv[i]);
}
}
free(pager_env);
@@ -97,9 +97,10 @@ static void setup_pager_env(struct argv_array *env)
void prepare_pager_args(struct child_process *pager_process, const char *pager)
{
- argv_array_push(&pager_process->args, pager);
+ strvec_push(&pager_process->args, pager);
pager_process->use_shell = 1;
setup_pager_env(&pager_process->env_array);
+ pager_process->trace2_child_class = "pager";
}
void setup_pager(void)
@@ -125,7 +126,7 @@ void setup_pager(void)
/* spawn the pager */
prepare_pager_args(&pager_process, pager);
pager_process.in = -1;
- argv_array_push(&pager_process.env_array, "GIT_PAGER_IN_USE");
+ strvec_push(&pager_process.env_array, "GIT_PAGER_IN_USE");
if (start_command(&pager_process))
return;
@@ -177,6 +178,26 @@ int term_columns(void)
}
/*
+ * Clear the entire line, leave cursor in first column.
+ */
+void term_clear_line(void)
+{
+ if (is_terminal_dumb())
+ /*
+ * Fall back to print a terminal width worth of space
+ * characters (hoping that the terminal is still as wide
+ * as it was upon the first call to term_columns()).
+ */
+ fprintf(stderr, "\r%*s\r", term_columns(), "");
+ else
+ /*
+ * On non-dumb terminals use an escape sequence to clear
+ * the whole line, no matter how wide the terminal.
+ */
+ fputs("\r\033[K", stderr);
+}
+
+/*
* How many columns do we need to show this number in decimal?
*/
int decimal_width(uintmax_t number)