xF: adjust layouting to be more like nncmpp
Alpine 3.24 Success
Arch Linux AUR Success
OpenBSD 7.8 Success

This commit is contained in:
2026-08-08 06:05:41 +02:00
parent 57e2163bac
commit e816ddb32a
+30 -27
View File
@@ -2242,18 +2242,23 @@ app_push (struct layout *l, struct widget *w)
}
static struct widget *
app_label_attrs (chtype attrs, unsigned extended, const char *text, bool fill)
app_push_fill (struct layout *l, struct widget *w)
{
struct widget *w = g_xui.ui->label (attrs, extended, text ? text : "");
if (fill)
w->width = -1;
w->width = -1;
LIST_APPEND_WITH_TAIL (l->head, l->tail, w);
return w;
}
static struct widget *
app_label (enum app_attribute attribute, const char *text, bool fill)
app_label_attrs (chtype attrs, unsigned extended, const char *text)
{
return app_label_attrs (g_attrs[attribute].attrs, 0, text, fill);
return g_xui.ui->label (attrs, extended, text ? text : "");
}
static struct widget *
app_label (enum app_attribute attribute, const char *text)
{
return app_label_attrs (g_attrs[attribute].attrs, 0, text);
}
static struct widget *
@@ -2394,13 +2399,14 @@ app_make_line_item_widget (chtype base, bool leaked,
attrs |= link;
}
struct widget *w
= app_label_attrs (attrs, extended, text, flexible && !link);
struct widget *w = app_label_attrs (attrs, extended, text);
if (link)
{
w->widget_id = WIDGET_LINK;
w->userdata = item->style;
}
else if (flexible)
w->width = -1;
return w;
}
@@ -2428,7 +2434,7 @@ app_append_line_span (struct layout *row, chtype base,
if (wrap->overflow && last)
last->width = -1;
else
app_push (row, app_label_attrs (base, 0, "", true));
app_push_fill (row, app_label_attrs (base, 0, ""));
}
static void
@@ -2442,7 +2448,7 @@ app_append_line_items (struct layout *row, chtype base,
// We don't want the "hitbox" of links to extend until the end of line.
if (!line->items_tail
|| line->items_tail->style & BUFFER_LINE_ITEM_LINK)
app_push (row, app_label_attrs (base, 0, "", true));
app_push_fill (row, app_label_attrs (base, 0, ""));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -2502,7 +2508,7 @@ app_wrap_buffer_line (struct buffer_line *line, int first_width,
static struct widget *
app_make_activity_indicator (void)
{
struct widget *indicator = app_label (ATTRIBUTE_CHROME, "", false);
struct widget *indicator = app_label (ATTRIBUTE_CHROME, "");
if (g.relay.pending_commands)
return indicator;
@@ -2521,7 +2527,7 @@ app_make_title (void)
app_append_line_items (&row, g_attrs[ATTRIBUTE_CHROME].attrs,
&g.buffer_current->topic);
else
app_push (&row, app_label (ATTRIBUTE_CHROME, "", true));
app_push_fill (&row, app_label (ATTRIBUTE_CHROME, ""));
app_push (&row, app_padding (ATTRIBUTE_CHROME, 0.5));
app_push (&row, app_make_activity_indicator ());
@@ -2549,7 +2555,7 @@ app_make_buffer_row (struct buffer *b, int index)
struct layout row = {};
app_push (&row, app_padding (attribute, 0.25));
app_push (&row, app_label (attribute, label, true));
app_push_fill (&row, app_label (attribute, label));
app_push (&row, app_padding (attribute, 0.25));
free (label);
@@ -2643,7 +2649,7 @@ app_make_mark (const struct buffer_line *line)
? g_attrs[ATTRIBUTE_EXTERNAL].attrs
: g_attrs[app_mark_attribute (line->rendition)].attrs;
return app_label_attrs (attrs, XUI_ATTR_MONOSPACE,
app_line_mark (line->rendition), false);
app_line_mark (line->rendition));
}
static const char *
@@ -2663,8 +2669,8 @@ app_make_date_change_marker (time_t when)
{
struct layout row = {};
app_push (&row, app_padding (ATTRIBUTE_NORMAL, 0.25));
app_push (&row, app_label (ATTRIBUTE_DATE_CHANGE,
app_format_date (when), true));
app_push_fill (&row,
app_label (ATTRIBUTE_DATE_CHANGE, app_format_date (when)));
app_push (&row, app_padding (ATTRIBUTE_NORMAL, 0.25));
struct widget *w = xui_hbox (row.head);
@@ -2688,8 +2694,7 @@ app_format_line_timestamp (const struct buffer_line *line)
static struct widget *
app_make_line_timestamp (const struct buffer_line *line)
{
return app_label (ATTRIBUTE_TIMESTAMP, app_format_line_timestamp (line),
false);
return app_label (ATTRIBUTE_TIMESTAMP, app_format_line_timestamp (line));
}
static void
@@ -2767,12 +2772,10 @@ app_make_line (struct buffer_line *line)
app_push (&row, app_padding (ATTRIBUTE_NORMAL, 0.25));
app_push (&rows, xui_hbox (row.head));
}
struct widget *content = xui_vbox (rows.head);
content->width = -1;
struct layout timestamps = {};
app_push (&timestamps, app_make_line_timestamp (line));
struct widget *filler = app_label (ATTRIBUTE_TIMESTAMP, "", false);
struct widget *filler = app_label (ATTRIBUTE_TIMESTAMP, "");
filler->height = -1;
app_push (&timestamps, filler);
@@ -2780,7 +2783,7 @@ app_make_line (struct buffer_line *line)
app_push (&columns, app_padding (ATTRIBUTE_TIMESTAMP, 0.25));
app_push (&columns, xui_vbox (timestamps.head));
app_push (&columns, app_padding (ATTRIBUTE_TIMESTAMP, 0.25));
app_push (&columns, content);
app_push_fill (&columns, xui_vbox (rows.head));
return xui_hbox (columns.head);
}
@@ -3051,12 +3054,12 @@ app_make_status (void)
struct layout row = {};
app_push (&row, app_padding (ATTRIBUTE_CHROME, 0.25));
app_push (&row, app_label (ATTRIBUTE_CHROME, status.str, true));
app_push_fill (&row, app_label (ATTRIBUTE_CHROME, status.str));
int *scroll_offset = app_content_scroll_offset ();
if (g.relay.state == RELAY_CONNECTED
&& scroll_offset && *scroll_offset)
{
app_push (&row, app_label (ATTRIBUTE_CHROME, "", false));
app_push (&row, app_label (ATTRIBUTE_CHROME, ""));
}
app_push (&row, app_padding (ATTRIBUTE_CHROME, 0.5));
app_push (&row, app_button (ATTRIBUTE_CHROME, "B", ACTION_FORMAT_BOLD))
@@ -3110,10 +3113,10 @@ app_make_input (void)
if (g.editor_running_for)
{
app_push (&row, app_padding (ATTRIBUTE_NORMAL, 0.25));
app_push (&row, app_label (ATTRIBUTE_NORMAL,
app_push_fill (&row, app_label (ATTRIBUTE_NORMAL,
g.editor_shows_transcript
? "Running external transcript viewer"
: "Running external input editor", true));
: "Running external input editor"));
app_push (&row, app_padding (ATTRIBUTE_NORMAL, 0.25));
return xui_hbox (row.head);
}
@@ -3122,7 +3125,7 @@ app_make_input (void)
if (*prompt)
{
app_push (&row, app_padding (ATTRIBUTE_PROMPT, 0.25));
app_push (&row, app_label (ATTRIBUTE_PROMPT, prompt, false));
app_push (&row, app_label (ATTRIBUTE_PROMPT, prompt));
app_push (&row, app_padding (ATTRIBUTE_PROMPT, 0.25));
app_push (&row, app_padding (ATTRIBUTE_NORMAL, 0.5));
}