chiark / gitweb /
terminal: add helpers to retrieve page dimensions
authorDavid Herrmann <dh.herrmann@gmail.com>
Wed, 1 Oct 2014 09:29:09 +0000 (11:29 +0200)
committerDavid Herrmann <dh.herrmann@gmail.com>
Thu, 2 Oct 2014 06:40:43 +0000 (08:40 +0200)
Allow term users to retrieve the page dimensions of a terminal screen.
This is needed to properly calculate the grid dimensions when rendering.

src/libsystemd-terminal/term-screen.c
src/libsystemd-terminal/term.h

index 67f9056..14c32ac 100644 (file)
@@ -3743,6 +3743,18 @@ static int screen_feed_cmd(term_screen *screen, const term_seq *seq) {
         return 0;
 }
 
+unsigned int term_screen_get_width(term_screen *screen) {
+        assert_return(screen, -EINVAL);
+
+        return screen->page->width;
+}
+
+unsigned int term_screen_get_height(term_screen *screen) {
+        assert_return(screen, -EINVAL);
+
+        return screen->page->height;
+}
+
 int term_screen_feed_text(term_screen *screen, const uint8_t *in, size_t size) {
         const uint32_t *ucs4_str;
         size_t i, j, ucs4_len;
index 2f2bb47..021cf1c 100644 (file)
@@ -137,6 +137,9 @@ term_screen *term_screen_unref(term_screen *screen);
 
 DEFINE_TRIVIAL_CLEANUP_FUNC(term_screen*, term_screen_unref);
 
+unsigned int term_screen_get_width(term_screen *screen);
+unsigned int term_screen_get_height(term_screen *screen);
+
 int term_screen_feed_text(term_screen *screen, const uint8_t *in, size_t size);
 int term_screen_feed_keyboard(term_screen *screen, uint32_t keysym, uint32_t ascii, uint32_t ucs4, unsigned int mods);
 int term_screen_resize(term_screen *screen, unsigned int width, unsigned int height);