[libglnx] console: Add an API to just emit text
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libglnx] console: Add an API to just emit text
- Date: Thu, 10 Mar 2016 19:23:26 +0000 (UTC)
commit 08ae6639e522e9b11765245fbecdbbe474ccde98
Author: Colin Walters <walters verbum org>
Date: Thu Mar 10 13:51:13 2016 -0500
console: Add an API to just emit text
We had this internally, just need to expose it.
glnx-console.c | 49 +++++++++++++++++++++++++++++++------------------
glnx-console.h | 2 ++
2 files changed, 33 insertions(+), 18 deletions(-)
---
diff --git a/glnx-console.c b/glnx-console.c
index f9d8baa..016f62c 100644
--- a/glnx-console.c
+++ b/glnx-console.c
@@ -177,22 +177,9 @@ printpad (const char *padbuf,
fwrite (padbuf, 1, r, stdout);
}
-/**
- * glnx_console_progress_text_percent:
- * @text: Show this text before the progress bar
- * @percentage: An integer in the range of 0 to 100
- *
- * On a tty, print to the console @text followed by an ASCII art
- * progress bar whose percentage is @percentage. If stdout is not a
- * tty, a more basic line by line change will be printed.
- *
- * You must have called glnx_console_lock() before invoking this
- * function.
- *
- */
-void
-glnx_console_progress_text_percent (const char *text,
- guint percentage)
+static void
+text_percent_internal (const char *text,
+ int percentage)
{
static const char equals[] = "====================";
const guint n_equals = sizeof (equals) - 1;
@@ -204,8 +191,6 @@ glnx_console_progress_text_percent (const char *text,
guint textlen;
guint barlen;
- g_return_if_fail (percentage >= 0 && percentage <= 100);
-
if (text && !*text)
text = NULL;
@@ -267,6 +252,34 @@ glnx_console_progress_text_percent (const char *text,
}
/**
+ * glnx_console_progress_text_percent:
+ * @text: Show this text before the progress bar
+ * @percentage: An integer in the range of 0 to 100
+ *
+ * On a tty, print to the console @text followed by an ASCII art
+ * progress bar whose percentage is @percentage. If stdout is not a
+ * tty, a more basic line by line change will be printed.
+ *
+ * You must have called glnx_console_lock() before invoking this
+ * function.
+ *
+ */
+void
+glnx_console_progress_text_percent (const char *text,
+ guint percentage)
+{
+ g_return_if_fail (percentage >= 0 && percentage <= 100);
+
+ text_percent_internal (text, percentage);
+}
+
+void
+glnx_console_text (const char *text)
+{
+ text_percent_internal (text, -1);
+}
+
+/**
* glnx_console_unlock:
*
* Print a newline, and reset all cached console progress state.
diff --git a/glnx-console.h b/glnx-console.h
index 8fc3865..8c1d811 100644
--- a/glnx-console.h
+++ b/glnx-console.h
@@ -33,6 +33,8 @@ typedef struct GLnxConsoleRef GLnxConsoleRef;
void glnx_console_lock (GLnxConsoleRef *ref);
+void glnx_console_text (const char *text);
+
void glnx_console_progress_text_percent (const char *text,
guint percentage);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]