aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/interface-curses/curses-utils.c
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2025-08-25 14:32:38 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2025-08-26 21:33:40 +0300
commitd1c20b8388105fd1027ea2aaf65dad772f9fe16f (patch)
tree2de220dd1c20fcbf11d4781d76380b55d66fdc2a /src/interface-curses/curses-utils.c
parentf525d8f09ec0e60effe70623a19c700a3a202db0 (diff)
downloadsciteco-libxcurses.tar.gz
This is mostly for XDG/4 compatibility.
Diffstat (limited to 'src/interface-curses/curses-utils.c')
-rw-r--r--src/interface-curses/curses-utils.c22
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;
}