diff options
Diffstat (limited to 'src/interface-curses/curses-utils.c')
-rw-r--r-- | src/interface-curses/curses-utils.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/interface-curses/curses-utils.c b/src/interface-curses/curses-utils.c index f94b6dc..39d9b3f 100644 --- a/src/interface-curses/curses-utils.c +++ b/src/interface-curses/curses-utils.c @@ -59,11 +59,12 @@ teco_curses_format_str(WINDOW *win, const gchar *str, gsize len, gint max_width) short pair = 0; wattr_get(win, &attrs, &pair, NULL); - int old_x, old_y; + G_GNUC_UNUSED gint old_x, old_y, max_x, max_y; getyx(win, old_y, old_x); + getmaxyx(win, max_y, max_x); if (max_width < 0) - max_width = getmaxx(win) - old_x; + max_width = max_x - old_x; while (len > 0) { /* @@ -133,7 +134,9 @@ teco_curses_format_str(WINDOW *win, const gchar *str, gsize len, gint max_width) len -= clen; } - return getcurx(win) - old_x; + G_GNUC_UNUSED gint cur_x, cur_y; + getyx(win, cur_y, cur_x); + return cur_x - old_x; truncate: if (max_width >= truncate_len) { @@ -153,7 +156,8 @@ truncate: } } - return getcurx(win) - old_x; + getyx(win, cur_y, cur_x); + return cur_x - old_x; } /** @@ -174,13 +178,15 @@ guint teco_curses_format_filename(WINDOW *win, const gchar *filename, gint max_width) { gint truncate_len = teco_ed & TECO_ED_ICONS ? 1 : 3; - int old_x = getcurx(win); + G_GNUC_UNUSED gint old_x, old_y, max_x, max_y; + getyx(win, old_y, old_x); + getmaxyx(win, max_y, max_x); g_autofree gchar *filename_printable = teco_string_echo(filename, strlen(filename)); glong filename_len = g_utf8_strlen(filename_printable, -1); if (max_width < 0) - max_width = getmaxx(win) - old_x; + max_width = max_x - old_x; if (filename_len <= max_width) { /* @@ -217,5 +223,7 @@ teco_curses_format_filename(WINDOW *win, const gchar *filename, gint max_width) waddstr(win, keep_post); } - return getcurx(win) - old_x; + G_GNUC_UNUSED gint cur_x, cur_y; + getyx(win, cur_y, cur_x); + return cur_x - old_x; } |