1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

big dialogs: draw_dlg_text: no need to pass the term.

Instead, make draw_dlg_text read dlg_data->win->term.
This commit is contained in:
Kalle Olavi Niemitalo 2008-10-11 23:45:27 +03:00 committed by Kalle Olavi Niemitalo
parent 1b589beb81
commit 4f41ce00b4
8 changed files with 26 additions and 25 deletions

View File

@ -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) { if (len > 0) {
unsigned char *text = widget_data->widget->text; unsigned char *text = widget_data->widget->text;
int hk_pos = widget_data->widget->info.button.hotkey_pos; 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); NULL);
if (hk_pos) 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); 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, &text[hk_pos + 1], hk_bytes,
attr, shortcut_color); attr, shortcut_color);
if (right > 1) 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, pos->y,
&text[hk_pos + hk_bytes + 1], &text[hk_pos + hk_bytes + 1],
right - 1, 0, color); right - 1, 0, color);
@ -259,11 +259,11 @@ display_button(struct dialog_data *dlg_data, struct widget_data *widget_data)
len - hk_width, len - hk_width,
NULL); NULL);
draw_dlg_text(term, dlg_data, x, pos->y, draw_dlg_text(dlg_data, x, pos->y,
text, hk_len, text, hk_len,
attr, shortcut_color); 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, &text[hk_len], len_to_display,
0, color); 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; int right = widget_data->widget->info.button.truetextlen - hk_pos - 1;
if (hk_pos) { 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); &text[hk_pos + 1], 1, attr, shortcut_color);
if (right > 1) { 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); &text[hk_pos + 2], right - 1, 0, color);
} }
} else { } else {
draw_dlg_text(term, dlg_data, x, pos->y, text, 1, attr, shortcut_color); draw_dlg_text(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 + 1, pos->y, &text[1], len - 1, 0, color);
} }
} }
#ifdef CONFIG_UTF8 #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 text_cells = utf8_ptr2cells(widget_data->widget->text, NULL);
int hk = (widget_data->widget->info.button.hotkey_pos >= 0); 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); BUTTON_RIGHT, BUTTON_RIGHT_LEN, 0, color);
} else } else
#endif /* CONFIG_UTF8 */ #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); BUTTON_RIGHT_LEN, 0, color);
if (sel) { if (sel) {
set_dlg_cursor(term, dlg_data, x, pos->y, 1); set_dlg_cursor(term, dlg_data, x, pos->y, 1);

View File

@ -79,7 +79,7 @@ display_checkbox(struct dialog_data *dlg_data, struct widget_data *widget_data)
else else
text = widget_data->widget->info.checkbox.gid ? "( )" : "[ ]"; 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) { if (selected) {
set_dlg_cursor(term, dlg_data, pos->x + 1, pos->y, 1); set_dlg_cursor(term, dlg_data, pos->x + 1, pos->y, 1);

View File

@ -117,9 +117,9 @@ redraw_dialog(struct dialog_data *dlg_data, int layout)
y = dlg_data->real_box.y - 1; y = dlg_data->real_box.y - 1;
draw_dlg_text(term, dlg_data, x - 1, y, " ", 1, 0, title_color); draw_dlg_text(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(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 + titlecells, y, " ", 1, 0,
title_color); title_color);
} }
} }

View File

@ -88,14 +88,14 @@ dlg_format_group(struct dialog_data *dlg_data,
text, text,
label_length, label_length,
NULL); NULL);
draw_dlg_text(term, dlg_data, xpos + width draw_dlg_text(dlg_data, xpos + width
+ label_padding, + label_padding,
*y, text, lb, 0, *y, text, lb, 0,
color); color);
} else } else
#endif /* CONFIG_UTF8 */ #endif /* CONFIG_UTF8 */
{ {
draw_dlg_text(term, dlg_data, xpos + width draw_dlg_text(dlg_data, xpos + width
+ label_padding, + label_padding,
*y, text, *y, text,
label_length, 0, label_length, 0,
@ -114,12 +114,12 @@ dlg_format_group(struct dialog_data *dlg_data,
text, text,
label_length, label_length,
NULL); NULL);
draw_dlg_text(term, dlg_data, xpos, *y, draw_dlg_text(dlg_data, xpos, *y,
text, lb, 0, color); text, lb, 0, color);
} else } else
#endif /* CONFIG_UTF8 */ #endif /* CONFIG_UTF8 */
{ {
draw_dlg_text(term, dlg_data, xpos, *y, draw_dlg_text(dlg_data, xpos, *y,
text, label_length, text, label_length,
0, color); 0, color);
} }

View File

@ -313,7 +313,7 @@ display_field_do(struct dialog_data *dlg_data, struct widget_data *widget_data,
if (term->utf8_cp) if (term->utf8_cp)
w = utf8_cells2bytes(text, w, NULL); w = utf8_cells2bytes(text, w, NULL);
#endif /* CONFIG_UTF8 */ #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); text, w, 0, color);
} else { } else {
struct box box; struct box box;

View File

@ -257,7 +257,7 @@ dlg_format_text_do(struct dialog_data *dlg_data,
assert(cells <= width && shift < width); 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);
} }
} }

View File

@ -560,10 +560,11 @@ draw_text(struct terminal *term, int x, int y,
} }
void 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, unsigned char *text, int length,
enum screen_char_attr attr, struct color_pair *color) enum screen_char_attr attr, struct color_pair *color)
{ {
struct terminal *term = dlg_data->win->term;
struct box *box = &dlg_data->real_box; struct box *box = &dlg_data->real_box;
if (box->height) { if (box->height) {

View File

@ -282,7 +282,7 @@ void draw_text(struct terminal *term, int x, int y,
struct color_pair *color); struct color_pair *color);
/** Draws text for dialogs. */ /** 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, unsigned char *text, int length,
enum screen_char_attr attr, struct color_pair *color); enum screen_char_attr attr, struct color_pair *color);