From 4f41ce00b47e395340ab237552c70aa7266f952f Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sat, 11 Oct 2008 23:45:27 +0300 Subject: [PATCH] big dialogs: draw_dlg_text: no need to pass the term. Instead, make draw_dlg_text read dlg_data->win->term. --- src/bfu/button.c | 26 +++++++++++++------------- src/bfu/checkbox.c | 2 +- src/bfu/dialog.c | 6 +++--- src/bfu/group.c | 8 ++++---- src/bfu/inpfield.c | 2 +- src/bfu/text.c | 2 +- src/terminal/draw.c | 3 ++- src/terminal/draw.h | 2 +- 8 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/bfu/button.c b/src/bfu/button.c index 0f3ccdfc9..03fa8cca7 100644 --- a/src/bfu/button.c +++ b/src/bfu/button.c @@ -213,7 +213,7 @@ display_button(struct dialog_data *dlg_data, struct widget_data *widget_data) } - draw_dlg_text(term, dlg_data, pos->x, pos->y, BUTTON_LEFT, BUTTON_LEFT_LEN, 0, color); + draw_dlg_text(dlg_data, pos->x, pos->y, BUTTON_LEFT, BUTTON_LEFT_LEN, 0, color); if (len > 0) { unsigned char *text = widget_data->widget->text; int hk_pos = widget_data->widget->info.button.hotkey_pos; @@ -238,15 +238,15 @@ display_button(struct dialog_data *dlg_data, struct widget_data *widget_data) NULL); if (hk_pos) - draw_dlg_text(term, dlg_data, x, pos->y, + draw_dlg_text(dlg_data, x, pos->y, text, hk_pos, 0, color); - draw_dlg_text(term, dlg_data, x + cells_to_hk, pos->y, + draw_dlg_text(dlg_data, x + cells_to_hk, pos->y, &text[hk_pos + 1], hk_bytes, attr, shortcut_color); if (right > 1) - draw_dlg_text(term, dlg_data, x+cells_to_hk+hk_cells, + draw_dlg_text(dlg_data, x+cells_to_hk+hk_cells, pos->y, &text[hk_pos + hk_bytes + 1], right - 1, 0, color); @@ -259,11 +259,11 @@ display_button(struct dialog_data *dlg_data, struct widget_data *widget_data) len - hk_width, NULL); - draw_dlg_text(term, dlg_data, x, pos->y, + draw_dlg_text(dlg_data, x, pos->y, text, hk_len, attr, shortcut_color); - draw_dlg_text(term, dlg_data, x + hk_width, pos->y, + draw_dlg_text(dlg_data, x + hk_width, pos->y, &text[hk_len], len_to_display, 0, color); } @@ -273,18 +273,18 @@ display_button(struct dialog_data *dlg_data, struct widget_data *widget_data) int right = widget_data->widget->info.button.truetextlen - hk_pos - 1; if (hk_pos) { - draw_dlg_text(term, dlg_data, x, pos->y, text, hk_pos, 0, color); + draw_dlg_text(dlg_data, x, pos->y, text, hk_pos, 0, color); } - draw_dlg_text(term, dlg_data, x + hk_pos, pos->y, + draw_dlg_text(dlg_data, x + hk_pos, pos->y, &text[hk_pos + 1], 1, attr, shortcut_color); if (right > 1) { - draw_dlg_text(term, dlg_data, x + hk_pos + 1, pos->y, + draw_dlg_text(dlg_data, x + hk_pos + 1, pos->y, &text[hk_pos + 2], right - 1, 0, color); } } else { - draw_dlg_text(term, dlg_data, x, pos->y, text, 1, attr, shortcut_color); - draw_dlg_text(term, dlg_data, x + 1, pos->y, &text[1], len - 1, 0, color); + draw_dlg_text(dlg_data, x, pos->y, text, 1, attr, shortcut_color); + draw_dlg_text(dlg_data, x + 1, pos->y, &text[1], len - 1, 0, color); } } #ifdef CONFIG_UTF8 @@ -292,11 +292,11 @@ display_button(struct dialog_data *dlg_data, struct widget_data *widget_data) int text_cells = utf8_ptr2cells(widget_data->widget->text, NULL); int hk = (widget_data->widget->info.button.hotkey_pos >= 0); - draw_dlg_text(term, dlg_data, x + text_cells - hk, pos->y, + draw_dlg_text(dlg_data, x + text_cells - hk, pos->y, BUTTON_RIGHT, BUTTON_RIGHT_LEN, 0, color); } else #endif /* CONFIG_UTF8 */ - draw_dlg_text(term, dlg_data, x + len, pos->y, BUTTON_RIGHT, + draw_dlg_text(dlg_data, x + len, pos->y, BUTTON_RIGHT, BUTTON_RIGHT_LEN, 0, color); if (sel) { set_dlg_cursor(term, dlg_data, x, pos->y, 1); diff --git a/src/bfu/checkbox.c b/src/bfu/checkbox.c index 5dd58db26..35224af93 100644 --- a/src/bfu/checkbox.c +++ b/src/bfu/checkbox.c @@ -79,7 +79,7 @@ display_checkbox(struct dialog_data *dlg_data, struct widget_data *widget_data) else text = widget_data->widget->info.checkbox.gid ? "( )" : "[ ]"; - draw_dlg_text(term, dlg_data, pos->x, pos->y, text, CHECKBOX_LEN, 0, color); + draw_dlg_text(dlg_data, pos->x, pos->y, text, CHECKBOX_LEN, 0, color); if (selected) { set_dlg_cursor(term, dlg_data, pos->x + 1, pos->y, 1); diff --git a/src/bfu/dialog.c b/src/bfu/dialog.c index c53949f16..2d76dd1af 100644 --- a/src/bfu/dialog.c +++ b/src/bfu/dialog.c @@ -117,9 +117,9 @@ redraw_dialog(struct dialog_data *dlg_data, int layout) y = dlg_data->real_box.y - 1; - draw_dlg_text(term, dlg_data, x - 1, y, " ", 1, 0, title_color); - draw_dlg_text(term, dlg_data, x, y, title, titlelen, 0, title_color); - draw_dlg_text(term, dlg_data, x + titlecells, y, " ", 1, 0, + draw_dlg_text(dlg_data, x - 1, y, " ", 1, 0, title_color); + draw_dlg_text(dlg_data, x, y, title, titlelen, 0, title_color); + draw_dlg_text(dlg_data, x + titlecells, y, " ", 1, 0, title_color); } } diff --git a/src/bfu/group.c b/src/bfu/group.c index 4d404b9f2..09b3212b3 100644 --- a/src/bfu/group.c +++ b/src/bfu/group.c @@ -88,14 +88,14 @@ dlg_format_group(struct dialog_data *dlg_data, text, label_length, NULL); - draw_dlg_text(term, dlg_data, xpos + width + draw_dlg_text(dlg_data, xpos + width + label_padding, *y, text, lb, 0, color); } else #endif /* CONFIG_UTF8 */ { - draw_dlg_text(term, dlg_data, xpos + width + draw_dlg_text(dlg_data, xpos + width + label_padding, *y, text, label_length, 0, @@ -114,12 +114,12 @@ dlg_format_group(struct dialog_data *dlg_data, text, label_length, NULL); - draw_dlg_text(term, dlg_data, xpos, *y, + draw_dlg_text(dlg_data, xpos, *y, text, lb, 0, color); } else #endif /* CONFIG_UTF8 */ { - draw_dlg_text(term, dlg_data, xpos, *y, + draw_dlg_text(dlg_data, xpos, *y, text, label_length, 0, color); } diff --git a/src/bfu/inpfield.c b/src/bfu/inpfield.c index 4a1bd43ab..6c2a1e426 100644 --- a/src/bfu/inpfield.c +++ b/src/bfu/inpfield.c @@ -313,7 +313,7 @@ display_field_do(struct dialog_data *dlg_data, struct widget_data *widget_data, if (term->utf8_cp) w = utf8_cells2bytes(text, w, NULL); #endif /* CONFIG_UTF8 */ - draw_dlg_text(term, dlg_data, widget_data->box.x, widget_data->box.y, + draw_dlg_text(dlg_data, widget_data->box.x, widget_data->box.y, text, w, 0, color); } else { struct box box; diff --git a/src/bfu/text.c b/src/bfu/text.c index 409b1bb3a..a9c67fb27 100644 --- a/src/bfu/text.c +++ b/src/bfu/text.c @@ -257,7 +257,7 @@ dlg_format_text_do(struct dialog_data *dlg_data, assert(cells <= width && shift < width); - draw_dlg_text(term, dlg_data, x + shift, *y, text, line_width, 0, color); + draw_dlg_text(dlg_data, x + shift, *y, text, line_width, 0, color); } } diff --git a/src/terminal/draw.c b/src/terminal/draw.c index 3714ff591..60f60b5e1 100644 --- a/src/terminal/draw.c +++ b/src/terminal/draw.c @@ -560,10 +560,11 @@ draw_text(struct terminal *term, int x, int y, } void -draw_dlg_text(struct terminal *term, struct dialog_data *dlg_data, int x, int y, +draw_dlg_text(struct dialog_data *dlg_data, int x, int y, unsigned char *text, int length, enum screen_char_attr attr, struct color_pair *color) { + struct terminal *term = dlg_data->win->term; struct box *box = &dlg_data->real_box; if (box->height) { diff --git a/src/terminal/draw.h b/src/terminal/draw.h index 4abf77da4..5c7f9c432 100644 --- a/src/terminal/draw.h +++ b/src/terminal/draw.h @@ -282,7 +282,7 @@ void draw_text(struct terminal *term, int x, int y, struct color_pair *color); /** Draws text for dialogs. */ -void draw_dlg_text(struct terminal *term, struct dialog_data *dlg_data, int x, int y, +void draw_dlg_text(struct dialog_data *dlg_data, int x, int y, unsigned char *text, int length, enum screen_char_attr attr, struct color_pair *color);