Extend last column to end of line
If a line in the menu has fewer columns than the others, the last one is deemed to extend to the right margin, and does not count toward the maximum width of that column. Also, revert the change to NetHack.font_menu.
This commit is contained in:
committed by
Pasi Kallinen
parent
cadde6d317
commit
db32a639a7
+1
-1
@@ -31,7 +31,7 @@ NetHack*text*borderWidth: 0
|
||||
! These correspond to the .nethackrc settings font_map, font_menu,
|
||||
! font_message, font_status and font_text
|
||||
NetHack.font_map: mono-10
|
||||
NetHack.font_menu: sans-10
|
||||
NetHack.font_menu: mono-10
|
||||
NetHack.font_message: sans-10
|
||||
NetHack.font_status: sans-10
|
||||
NetHack.font_text: mono-10
|
||||
|
||||
+5
-5
@@ -185,11 +185,11 @@ X11_set_column_widths(Widget w, const int *col_widths, unsigned num_cols)
|
||||
WidgetData *data = get_widget_data(w);
|
||||
if (data != NULL) {
|
||||
free(data->columns);
|
||||
data->columns = (int *) alloc(sizeof(data->columns[0]) * num_cols);
|
||||
data->columns = (int *) alloc(sizeof(data->columns[0]) * (num_cols + 1));
|
||||
data->columns[0] = 0;
|
||||
if (num_cols != 0) {
|
||||
data->columns[0] = 0;
|
||||
for (unsigned i = 1; i < num_cols; ++i) {
|
||||
data->columns[i] = data->columns[i-1] + col_widths[i-1];
|
||||
for (unsigned i = 0; i < num_cols; ++i) {
|
||||
data->columns[i+1] = data->columns[i] + col_widths[i];
|
||||
}
|
||||
}
|
||||
data->num_cols = num_cols;
|
||||
@@ -421,7 +421,7 @@ update_label(Widget w, WidgetData *data)
|
||||
pos = 0;
|
||||
} else {
|
||||
line3 = min(strcspn(label + i + j, "\t\n"), line2);
|
||||
pos = data->columns[min(col, data->num_cols-1)];
|
||||
pos = data->columns[min(col, data->num_cols)];
|
||||
}
|
||||
#ifdef USE_XFT
|
||||
XftDrawString8(draw, &fgcolor, font, x + pos, y,
|
||||
|
||||
+7
-5
@@ -1471,13 +1471,15 @@ menu_create_entries(struct xwindow *wp, struct menu *curr_menu)
|
||||
}
|
||||
|
||||
/* Determine widths of columns */
|
||||
/* The last column is deemed to extend to the right margin, and is not included
|
||||
in the returned array */
|
||||
static unsigned
|
||||
get_col_widths(Widget w, X11_Font *font, const char *str, int **col_widths)
|
||||
{
|
||||
int col_spacing = X11_column_width(XtDisplay(w), font, "# ", 2);
|
||||
|
||||
/* Determine the number of columns */
|
||||
unsigned num_cols = 1;
|
||||
unsigned num_cols = 0;
|
||||
size_t i = 0;
|
||||
while (str[i] != '\0') {
|
||||
size_t len = strcspn(str + i, "\t");
|
||||
@@ -1497,16 +1499,16 @@ get_col_widths(Widget w, X11_Font *font, const char *str, int **col_widths)
|
||||
i = 0;
|
||||
while (str[i] != '\0') {
|
||||
size_t len = strcspn(str + i, "\t");
|
||||
if (str[i+len] == '\0') {
|
||||
break;
|
||||
}
|
||||
cwidths[col] = X11_column_width(XtDisplay(w), font, str + i, len);
|
||||
if (len > 1) {
|
||||
col_spacing = X11_font_height(font) * 2;
|
||||
}
|
||||
cwidths[col] += col_spacing;
|
||||
++col;
|
||||
i += len;
|
||||
if (str[i] == '\t') {
|
||||
++i;
|
||||
}
|
||||
i += len + 1;
|
||||
}
|
||||
|
||||
/* Return */
|
||||
|
||||
Reference in New Issue
Block a user