diff options
author | Evan Welsh <contact@evanwelsh.com> | 2021-06-29 01:07:13 -0700 |
---|---|---|
committer | Philip Chimento <philip.chimento@gmail.com> | 2021-08-16 20:31:59 -0700 |
commit | e24c054839170a1c08d130120ca2a5ea3c913198 (patch) | |
tree | 2c5ea122174249d7cd102fa6fa34f6a4006c276f /libgjs-private | |
parent | f06a570a069409ad0ebfd163fe1de263d898d09e (diff) | |
download | gjs-e24c054839170a1c08d130120ca2a5ea3c913198.tar.gz |
modules: Implement console.clear()
Diffstat (limited to 'libgjs-private')
-rw-r--r-- | libgjs-private/gjs-util.c | 13 | ||||
-rw-r--r-- | libgjs-private/gjs-util.h | 3 |
2 files changed, 16 insertions, 0 deletions
diff --git a/libgjs-private/gjs-util.c b/libgjs-private/gjs-util.c index 1edbdd7d..5ca54a3e 100644 --- a/libgjs-private/gjs-util.c +++ b/libgjs-private/gjs-util.c @@ -17,6 +17,7 @@ #include <glib/gi18n.h> /* for bindtextdomain, bind_textdomain_codeset, textdomain */ #include "libgjs-private/gjs-util.h" +#include "util/console.h" char * gjs_format_int_alternative_output(int n) @@ -329,3 +330,15 @@ void gjs_log_set_writer_func(GjsGLogWriterFunc func, void* user_data, g_log_set_writer_func(gjs_log_writer_func_wrapper, func, NULL); } + +/** + * gjs_clear_terminal: + * + * Clears the terminal, if possible. + */ +void gjs_clear_terminal(void) { + if (!gjs_console_is_tty(stdout_fd)) + return; + + gjs_console_clear(); +} diff --git a/libgjs-private/gjs-util.h b/libgjs-private/gjs-util.h index 06114751..e1213600 100644 --- a/libgjs-private/gjs-util.h +++ b/libgjs-private/gjs-util.h @@ -137,6 +137,9 @@ void gjs_gtk_container_child_set_property(GObject* container, GObject* child, const char* property, const GValue* value); +GJS_EXPORT +void gjs_clear_terminal(void); + G_END_DECLS #endif /* LIBGJS_PRIVATE_GJS_UTIL_H_ */ |