Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
steam-runtime-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
steamrt
steam-runtime-tools
Commits
08ae6639
Commit
08ae6639
authored
9 years ago
by
Colin Walters
Browse files
Options
Downloads
Patches
Plain Diff
console: Add an API to just emit text
We had this internally, just need to expose it.
parent
8a7943fe
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
glnx-console.c
+31
-18
31 additions, 18 deletions
glnx-console.c
glnx-console.h
+2
-0
2 additions, 0 deletions
glnx-console.h
with
33 additions
and
18 deletions
glnx-console.c
+
31
−
18
View file @
08ae6639
...
@@ -177,22 +177,9 @@ printpad (const char *padbuf,
...
@@ -177,22 +177,9 @@ printpad (const char *padbuf,
fwrite
(
padbuf
,
1
,
r
,
stdout
);
fwrite
(
padbuf
,
1
,
r
,
stdout
);
}
}
/**
static
void
* glnx_console_progress_text_percent:
text_percent_internal
(
const
char
*
text
,
* @text: Show this text before the progress bar
int
percentage
)
* @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
const
char
equals
[]
=
"===================="
;
static
const
char
equals
[]
=
"===================="
;
const
guint
n_equals
=
sizeof
(
equals
)
-
1
;
const
guint
n_equals
=
sizeof
(
equals
)
-
1
;
...
@@ -204,8 +191,6 @@ glnx_console_progress_text_percent (const char *text,
...
@@ -204,8 +191,6 @@ glnx_console_progress_text_percent (const char *text,
guint
textlen
;
guint
textlen
;
guint
barlen
;
guint
barlen
;
g_return_if_fail
(
percentage
>=
0
&&
percentage
<=
100
);
if
(
text
&&
!*
text
)
if
(
text
&&
!*
text
)
text
=
NULL
;
text
=
NULL
;
...
@@ -266,6 +251,34 @@ glnx_console_progress_text_percent (const char *text,
...
@@ -266,6 +251,34 @@ glnx_console_progress_text_percent (const char *text,
fflush
(
stdout
);
fflush
(
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
)
{
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:
* glnx_console_unlock:
*
*
...
...
This diff is collapsed.
Click to expand it.
glnx-console.h
+
2
−
0
View file @
08ae6639
...
@@ -33,6 +33,8 @@ typedef struct GLnxConsoleRef GLnxConsoleRef;
...
@@ -33,6 +33,8 @@ typedef struct GLnxConsoleRef GLnxConsoleRef;
void
glnx_console_lock
(
GLnxConsoleRef
*
ref
);
void
glnx_console_lock
(
GLnxConsoleRef
*
ref
);
void
glnx_console_text
(
const
char
*
text
);
void
glnx_console_progress_text_percent
(
const
char
*
text
,
void
glnx_console_progress_text_percent
(
const
char
*
text
,
guint
percentage
);
guint
percentage
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment