|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From dda57d9143644d39091207b287f142f91f55d0ad Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From: David Herrmann <dh.herrmann@gmail.com>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Date: Wed, 1 Oct 2014 11:29:09 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] terminal: add helpers to retrieve page dimensions
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Allow term users to retrieve the page dimensions of a terminal screen.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
This is needed to properly calculate the grid dimensions when rendering.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd-terminal/term-screen.c | 12 ++++++++++++
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd-terminal/term.h | 3 +++
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
2 files changed, 15 insertions(+)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd-terminal/term-screen.c b/src/libsystemd-terminal/term-screen.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 67f9056d57..14c32aceb9 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd-terminal/term-screen.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd-terminal/term-screen.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -3743,6 +3743,18 @@ static int screen_feed_cmd(term_screen *screen, const term_seq *seq) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+unsigned int term_screen_get_width(term_screen *screen) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ assert_return(screen, -EINVAL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ return screen->page->width;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+unsigned int term_screen_get_height(term_screen *screen) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ assert_return(screen, -EINVAL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ return screen->page->height;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int term_screen_feed_text(term_screen *screen, const uint8_t *in, size_t size) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
const uint32_t *ucs4_str;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
size_t i, j, ucs4_len;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd-terminal/term.h b/src/libsystemd-terminal/term.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 2f2bb479cb..021cf1c42b 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd-terminal/term.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd-terminal/term.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -137,6 +137,9 @@ term_screen *term_screen_unref(term_screen *screen);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
DEFINE_TRIVIAL_CLEANUP_FUNC(term_screen*, term_screen_unref);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+unsigned int term_screen_get_width(term_screen *screen);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+unsigned int term_screen_get_height(term_screen *screen);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int term_screen_feed_text(term_screen *screen, const uint8_t *in, size_t size);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int term_screen_feed_keyboard(term_screen *screen, uint32_t keysym, uint32_t ascii, uint32_t ucs4, unsigned int mods);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int term_screen_resize(term_screen *screen, unsigned int width, unsigned int height);
|