mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[color] Removed code related to draw_text_node
This idea failed. Code was slow.
This commit is contained in:
parent
d0537ce3c0
commit
c086cbe26e
@ -184,19 +184,19 @@ static widget_handler_status_T
|
||||
display_button(struct dialog_data *dlg_data, struct widget_data *widget_data)
|
||||
{
|
||||
struct terminal *term = dlg_data->win->term;
|
||||
unsigned int color_node, shortcut_color_node;
|
||||
struct color_pair *color, *shortcut_color;
|
||||
struct el_box *pos = &widget_data->box;
|
||||
int len, x;
|
||||
int sel = is_selected_widget(dlg_data, widget_data);
|
||||
|
||||
if (sel) {
|
||||
shortcut_color_node = get_bfu_color_node(term, "dialog.button-shortcut-selected");
|
||||
color_node = get_bfu_color_node(term, "dialog.button-selected");
|
||||
shortcut_color = get_bfu_color(term, "dialog.button-shortcut-selected");
|
||||
color = get_bfu_color(term, "dialog.button-selected");
|
||||
} else {
|
||||
shortcut_color_node = get_bfu_color_node(term, "dialog.button-shortcut");
|
||||
color_node = get_bfu_color_node(term, "dialog.button");
|
||||
shortcut_color = get_bfu_color(term, "dialog.button-shortcut");
|
||||
color = get_bfu_color(term, "dialog.button");
|
||||
}
|
||||
if (!color_node || !shortcut_color_node) return EVENT_PROCESSED;
|
||||
if (!color || !shortcut_color) return EVENT_PROCESSED;
|
||||
|
||||
#ifdef CONFIG_UTF8
|
||||
if (term->utf8_cp) {
|
||||
@ -215,7 +215,7 @@ display_button(struct dialog_data *dlg_data, struct widget_data *widget_data)
|
||||
}
|
||||
|
||||
|
||||
draw_dlg_text_node(dlg_data, pos->x, pos->y, BUTTON_LEFT, BUTTON_LEFT_LEN, 0, color_node);
|
||||
draw_dlg_text(dlg_data, pos->x, pos->y, BUTTON_LEFT, BUTTON_LEFT_LEN, 0, color);
|
||||
if (len > 0) {
|
||||
char *text = widget_data->widget->text;
|
||||
int hk_pos = widget_data->widget->info.button.hotkey_pos;
|
||||
@ -240,18 +240,18 @@ display_button(struct dialog_data *dlg_data, struct widget_data *widget_data)
|
||||
NULL);
|
||||
|
||||
if (hk_pos)
|
||||
draw_dlg_text_node(dlg_data, x, pos->y,
|
||||
text, hk_pos, 0, color_node);
|
||||
draw_dlg_text(dlg_data, x, pos->y,
|
||||
text, hk_pos, 0, color);
|
||||
|
||||
draw_dlg_text_node(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_node);
|
||||
attr, shortcut_color);
|
||||
|
||||
if (right > 1)
|
||||
draw_dlg_text_node(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_node);
|
||||
right - 1, 0, color);
|
||||
|
||||
} else {
|
||||
int hk_width = utf8_char2cells(text, NULL);
|
||||
@ -261,13 +261,13 @@ display_button(struct dialog_data *dlg_data, struct widget_data *widget_data)
|
||||
len - hk_width,
|
||||
NULL);
|
||||
|
||||
draw_dlg_text_node(dlg_data, x, pos->y,
|
||||
draw_dlg_text(dlg_data, x, pos->y,
|
||||
text, hk_len,
|
||||
attr, shortcut_color_node);
|
||||
attr, shortcut_color);
|
||||
|
||||
draw_dlg_text_node(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_node);
|
||||
0, color);
|
||||
}
|
||||
} else
|
||||
#endif /* CONFIG_UTF8 */
|
||||
@ -275,18 +275,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_node(dlg_data, x, pos->y, text, hk_pos, 0, color_node);
|
||||
draw_dlg_text(dlg_data, x, pos->y, text, hk_pos, 0, color);
|
||||
}
|
||||
draw_dlg_text_node(dlg_data, x + hk_pos, pos->y,
|
||||
&text[hk_pos + 1], 1, attr, shortcut_color_node);
|
||||
draw_dlg_text(dlg_data, x + hk_pos, pos->y,
|
||||
&text[hk_pos + 1], 1, attr, shortcut_color);
|
||||
if (right > 1) {
|
||||
draw_dlg_text_node(dlg_data, x + hk_pos + 1, pos->y,
|
||||
&text[hk_pos + 2], right - 1, 0, color_node);
|
||||
draw_dlg_text(dlg_data, x + hk_pos + 1, pos->y,
|
||||
&text[hk_pos + 2], right - 1, 0, color);
|
||||
}
|
||||
|
||||
} else {
|
||||
draw_dlg_text_node(dlg_data, x, pos->y, text, 1, attr, shortcut_color_node);
|
||||
draw_dlg_text_node(dlg_data, x + 1, pos->y, &text[1], len - 1, 0, color_node);
|
||||
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
|
||||
@ -294,12 +294,12 @@ 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_node(dlg_data, x + text_cells - hk, pos->y,
|
||||
BUTTON_RIGHT, BUTTON_RIGHT_LEN, 0, color_node);
|
||||
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_node(dlg_data, x + len, pos->y, BUTTON_RIGHT,
|
||||
BUTTON_RIGHT_LEN, 0, color_node);
|
||||
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);
|
||||
set_dlg_window_ptr(dlg_data, dlg_data->win, pos->x, pos->y);
|
||||
|
@ -50,11 +50,10 @@ dlg_format_checkbox(struct dialog_data *dlg_data,
|
||||
|
||||
if (text && *text) {
|
||||
if (rw) *rw -= CHECKBOX_LS;
|
||||
dlg_format_text_do_node(dlg_data, text, x + CHECKBOX_LS, y,
|
||||
dlg_format_text_do(dlg_data, text, x + CHECKBOX_LS, y,
|
||||
w - CHECKBOX_LS, rw,
|
||||
get_bfu_color_node(term, "dialog.checkbox-label"),
|
||||
get_bfu_color(term, "dialog.checkbox-label"),
|
||||
align, format_only);
|
||||
|
||||
if (rw) *rw += CHECKBOX_LS;
|
||||
}
|
||||
}
|
||||
@ -63,24 +62,24 @@ static widget_handler_status_T
|
||||
display_checkbox(struct dialog_data *dlg_data, struct widget_data *widget_data)
|
||||
{
|
||||
struct terminal *term = dlg_data->win->term;
|
||||
unsigned int color_node;
|
||||
struct color_pair *color;
|
||||
const char *text;
|
||||
struct el_box *pos = &widget_data->box;
|
||||
int selected = is_selected_widget(dlg_data, widget_data);
|
||||
|
||||
if (selected) {
|
||||
color_node = get_bfu_color_node(term, "dialog.checkbox-selected");
|
||||
color = get_bfu_color(term, "dialog.checkbox-selected");
|
||||
} else {
|
||||
color_node = get_bfu_color_node(term, "dialog.checkbox");
|
||||
color = get_bfu_color(term, "dialog.checkbox");
|
||||
}
|
||||
if (!color_node) return EVENT_PROCESSED;
|
||||
if (!color) return EVENT_PROCESSED;
|
||||
|
||||
if (widget_data->info.checkbox.checked)
|
||||
text = widget_data->widget->info.checkbox.gid ? "(X)" : "[X]";
|
||||
else
|
||||
text = widget_data->widget->info.checkbox.gid ? "( )" : "[ ]";
|
||||
|
||||
draw_dlg_text_node(dlg_data, pos->x, pos->y, text, CHECKBOX_LEN, 0, color_node);
|
||||
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);
|
||||
|
@ -72,7 +72,7 @@ void
|
||||
redraw_dialog(struct dialog_data *dlg_data, int layout)
|
||||
{
|
||||
struct terminal *term = dlg_data->win->term;
|
||||
unsigned int title_color_node;
|
||||
struct color_pair *title_color;
|
||||
|
||||
if (layout) {
|
||||
dlg_data->dlg->layouter(dlg_data);
|
||||
@ -91,12 +91,12 @@ redraw_dialog(struct dialog_data *dlg_data, int layout)
|
||||
dlg_data->box.width - 2 * (DIALOG_LEFT_BORDER + 1),
|
||||
dlg_data->box.height - 2 * (DIALOG_TOP_BORDER + 1));
|
||||
|
||||
draw_border_node(term, &dlg_data->real_box, get_bfu_color_node(term, "dialog.frame"), DIALOG_FRAME);
|
||||
draw_border(term, &dlg_data->real_box, get_bfu_color(term, "dialog.frame"), DIALOG_FRAME);
|
||||
|
||||
assert(dlg_data->dlg->title);
|
||||
|
||||
title_color_node = get_bfu_color_node(term, "dialog.title");
|
||||
if (title_color_node && dlg_data->real_box.width > 2) {
|
||||
title_color = get_bfu_color(term, "dialog.title");
|
||||
if (title_color && dlg_data->real_box.width > 2) {
|
||||
char *title = dlg_data->dlg->title;
|
||||
int titlelen = strlen(title);
|
||||
int titlecells = titlelen;
|
||||
@ -120,10 +120,10 @@ redraw_dialog(struct dialog_data *dlg_data, int layout)
|
||||
y = dlg_data->real_box.y - 1;
|
||||
|
||||
|
||||
draw_text_node(term, x - 1, y, " ", 1, 0, title_color_node);
|
||||
draw_text_node(term, x, y, title, titlelen, 0, title_color_node);
|
||||
draw_text_node(term, x + titlecells, y, " ", 1, 0,
|
||||
title_color_node);
|
||||
draw_text(term, x - 1, y, " ", 1, 0, title_color);
|
||||
draw_text(term, x, y, title, titlelen, 0, title_color);
|
||||
draw_text(term, x + titlecells, y, " ", 1, 0,
|
||||
title_color);
|
||||
}
|
||||
}
|
||||
|
||||
@ -686,13 +686,13 @@ draw_dialog(struct dialog_data *dlg_data, int width, int height)
|
||||
(term->width - dlg_width) / 2, (term->height - dlg_height) / 2,
|
||||
dlg_width, dlg_height);
|
||||
|
||||
draw_box_node(term, &dlg_data->box, ' ', 0,
|
||||
get_bfu_color_node(term, "dialog.generic"));
|
||||
draw_box(term, &dlg_data->box, ' ', 0,
|
||||
get_bfu_color(term, "dialog.generic"));
|
||||
|
||||
if (get_opt_bool("ui.dialogs.shadows", NULL)) {
|
||||
/* Draw shadow */
|
||||
draw_shadow_node(term, &dlg_data->box,
|
||||
get_bfu_color_node(term, "dialog.shadow"), 2, 1);
|
||||
draw_shadow(term, &dlg_data->box,
|
||||
get_bfu_color(term, "dialog.shadow"), 2, 1);
|
||||
#ifdef CONFIG_UTF8
|
||||
if (term->utf8_cp)
|
||||
fix_dwchar_around_box(term, &dlg_data->box, 0, 2, 1);
|
||||
|
@ -28,7 +28,7 @@ dlg_format_group(struct dialog_data *dlg_data,
|
||||
int space_between_widgets = 1;
|
||||
int line_width = 0;
|
||||
int xpos;
|
||||
unsigned int color_node = get_bfu_color_node(term, "dialog.text");
|
||||
struct color_pair *color = get_bfu_color(term, "dialog.text");
|
||||
|
||||
assert(n > 0);
|
||||
if_assert_failed return;
|
||||
@ -88,18 +88,18 @@ dlg_format_group(struct dialog_data *dlg_data,
|
||||
text,
|
||||
label_length,
|
||||
NULL);
|
||||
draw_dlg_text_node(dlg_data, xpos + width
|
||||
draw_dlg_text(dlg_data, xpos + width
|
||||
+ label_padding,
|
||||
*y, text, lb, 0,
|
||||
color_node);
|
||||
color);
|
||||
} else
|
||||
#endif /* CONFIG_UTF8 */
|
||||
{
|
||||
draw_dlg_text_node(dlg_data, xpos + width
|
||||
draw_dlg_text(dlg_data, xpos + width
|
||||
+ label_padding,
|
||||
*y, text,
|
||||
label_length, 0,
|
||||
color_node);
|
||||
color);
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,14 +114,14 @@ dlg_format_group(struct dialog_data *dlg_data,
|
||||
text,
|
||||
label_length,
|
||||
NULL);
|
||||
draw_dlg_text_node(dlg_data, xpos, *y,
|
||||
text, lb, 0, color_node);
|
||||
draw_dlg_text(dlg_data, xpos, *y,
|
||||
text, lb, 0, color);
|
||||
} else
|
||||
#endif /* CONFIG_UTF8 */
|
||||
{
|
||||
draw_dlg_text_node(dlg_data, xpos, *y,
|
||||
draw_dlg_text(dlg_data, xpos, *y,
|
||||
text, label_length,
|
||||
0, color_node);
|
||||
0, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ dlg_format_field(struct dialog_data *dlg_data,
|
||||
static int max_label_width;
|
||||
static int *prev_y; /* Assert the uniqueness of y */ /* TODO: get rid of this !! --Zas */
|
||||
char *label = widget_data->widget->text;
|
||||
unsigned int text_color_node = 0;
|
||||
struct color_pair *text_color = NULL;
|
||||
int label_width = 0;
|
||||
int float_label = widget_data->widget->info.field.flags & (INPFIELD_FLOAT|INPFIELD_FLOAT2);
|
||||
|
||||
@ -131,11 +131,9 @@ dlg_format_field(struct dialog_data *dlg_data,
|
||||
}
|
||||
|
||||
if (label && *label) {
|
||||
if (!format_only) {
|
||||
text_color_node = get_bfu_color_node(term, "dialog.text");
|
||||
}
|
||||
if (!format_only) text_color = get_bfu_color(term, "dialog.text");
|
||||
|
||||
dlg_format_text_do_node(dlg_data, label, x, y, w, rw, text_color_node, ALIGN_LEFT, format_only);
|
||||
dlg_format_text_do(dlg_data, label, x, y, w, rw, text_color, ALIGN_LEFT, format_only);
|
||||
}
|
||||
|
||||
/* XXX: We want the field and label on the same line if the terminal
|
||||
@ -143,9 +141,9 @@ dlg_format_field(struct dialog_data *dlg_data,
|
||||
if (label && *label && float_label) {
|
||||
if (widget_data->widget->info.field.flags & INPFIELD_FLOAT) {
|
||||
(*y) -= INPUTFIELD_HEIGHT;
|
||||
dlg_format_text_do_node(dlg_data, INPUTFIELD_FLOAT_SEPARATOR,
|
||||
dlg_format_text_do(dlg_data, INPUTFIELD_FLOAT_SEPARATOR,
|
||||
x + label_width, y, w, rw,
|
||||
text_color_node, ALIGN_LEFT, format_only);
|
||||
text_color, ALIGN_LEFT, format_only);
|
||||
w -= INPUTFIELD_FLOAT_SEPARATOR_LEN + INPUTFIELD_FLOATLABEL_PADDING;
|
||||
x += INPUTFIELD_FLOAT_SEPARATOR_LEN + INPUTFIELD_FLOATLABEL_PADDING;
|
||||
}
|
||||
@ -267,7 +265,7 @@ display_field_do(struct dialog_data *dlg_data, struct widget_data *widget_data,
|
||||
int hide)
|
||||
{
|
||||
struct terminal *term = dlg_data->win->term;
|
||||
unsigned int color_node;
|
||||
struct color_pair *color;
|
||||
int sel = is_selected_widget(dlg_data, widget_data);
|
||||
#ifdef CONFIG_UTF8
|
||||
int len = 0, left = 0;
|
||||
@ -291,16 +289,12 @@ display_field_do(struct dialog_data *dlg_data, struct widget_data *widget_data,
|
||||
int_lower_bound(&widget_data->info.field.vpos, 0);
|
||||
}
|
||||
|
||||
color_node = get_bfu_color_node(term, "dialog.field");
|
||||
|
||||
if (color_node) {
|
||||
draw_box_node(term, &widget_data->box, ' ', 0, color_node);
|
||||
}
|
||||
|
||||
color_node = get_bfu_color_node(term, "dialog.field-text");
|
||||
if (color_node) {
|
||||
|
||||
color = get_bfu_color(term, "dialog.field");
|
||||
if (color)
|
||||
draw_box(term, &widget_data->box, ' ', 0, color);
|
||||
|
||||
color = get_bfu_color(term, "dialog.field-text");
|
||||
if (color) {
|
||||
char *text = widget_data->cdata + widget_data->info.field.vpos;
|
||||
int len, w;
|
||||
|
||||
@ -319,15 +313,15 @@ 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_node(dlg_data, widget_data->box.x, widget_data->box.y,
|
||||
text, w, 0, color_node);
|
||||
draw_dlg_text(dlg_data, widget_data->box.x, widget_data->box.y,
|
||||
text, w, 0, color);
|
||||
} else {
|
||||
struct el_box box;
|
||||
|
||||
copy_box(&box, &widget_data->box);
|
||||
box.width = w;
|
||||
|
||||
draw_box_node(term, &box, '*', 0, color_node);
|
||||
draw_box(term, &box, '*', 0, color);
|
||||
}
|
||||
}
|
||||
|
||||
@ -601,9 +595,9 @@ kbd_field(struct dialog_data *dlg_data, struct widget_data *widget_data)
|
||||
int cdata_len = strlen(widget_data->cdata);
|
||||
int start = widget_data->info.field.cpos;
|
||||
|
||||
while (start > 0 && isspace((unsigned char)widget_data->cdata[start - 1]))
|
||||
while (start > 0 && isspace(widget_data->cdata[start - 1]))
|
||||
--start;
|
||||
while (start > 0 && !isspace((unsigned char)widget_data->cdata[start - 1]))
|
||||
while (start > 0 && !isspace(widget_data->cdata[start - 1]))
|
||||
--start;
|
||||
|
||||
memmove(widget_data->cdata + start,
|
||||
@ -616,19 +610,19 @@ kbd_field(struct dialog_data *dlg_data, struct widget_data *widget_data)
|
||||
}
|
||||
|
||||
case ACT_EDIT_MOVE_BACKWARD_WORD:
|
||||
while (widget_data->info.field.cpos > 0 && isspace((unsigned char)widget_data->cdata[widget_data->info.field.cpos - 1]))
|
||||
while (widget_data->info.field.cpos > 0 && isspace(widget_data->cdata[widget_data->info.field.cpos - 1]))
|
||||
--widget_data->info.field.cpos;
|
||||
while (widget_data->info.field.cpos > 0 && !isspace((unsigned char)widget_data->cdata[widget_data->info.field.cpos - 1]))
|
||||
while (widget_data->info.field.cpos > 0 && !isspace(widget_data->cdata[widget_data->info.field.cpos - 1]))
|
||||
--widget_data->info.field.cpos;
|
||||
|
||||
goto display_field;
|
||||
|
||||
case ACT_EDIT_MOVE_FORWARD_WORD:
|
||||
while (isspace((unsigned char)widget_data->cdata[widget_data->info.field.cpos]))
|
||||
while (isspace(widget_data->cdata[widget_data->info.field.cpos]))
|
||||
++widget_data->info.field.cpos;
|
||||
while (widget_data->cdata[widget_data->info.field.cpos] && !isspace((unsigned char)widget_data->cdata[widget_data->info.field.cpos]))
|
||||
while (widget_data->cdata[widget_data->info.field.cpos] && !isspace(widget_data->cdata[widget_data->info.field.cpos]))
|
||||
++widget_data->info.field.cpos;
|
||||
while (isspace((unsigned char)widget_data->cdata[widget_data->info.field.cpos]))
|
||||
while (isspace(widget_data->cdata[widget_data->info.field.cpos]))
|
||||
++widget_data->info.field.cpos;
|
||||
|
||||
goto display_field;
|
||||
|
@ -178,7 +178,7 @@ init_led_panel(struct led_panel *leds)
|
||||
}
|
||||
|
||||
static int
|
||||
draw_timer_node(struct terminal *term, int xpos, int ypos, unsigned int node_number)
|
||||
draw_timer(struct terminal *term, int xpos, int ypos, struct color_pair *color)
|
||||
{
|
||||
char s[64];
|
||||
int i, length;
|
||||
@ -187,14 +187,13 @@ draw_timer_node(struct terminal *term, int xpos, int ypos, unsigned int node_num
|
||||
length = strlen(s);
|
||||
|
||||
for (i = length - 1; i >= 0; i--)
|
||||
draw_char_node(term, xpos - (length - i), ypos, s[i], 0, node_number);
|
||||
draw_char(term, xpos - (length - i), ypos, s[i], 0, color);
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
draw_show_ip_node(struct session *ses, int xpos, int ypos, unsigned int node_number)
|
||||
draw_show_ip(struct session *ses, int xpos, int ypos, struct color_pair *color)
|
||||
{
|
||||
if (ses->doc_view && ses->doc_view->document && ses->doc_view->document->ip) {
|
||||
struct terminal *term = ses->tab->term;
|
||||
@ -203,21 +202,19 @@ draw_show_ip_node(struct session *ses, int xpos, int ypos, unsigned int node_num
|
||||
int i;
|
||||
|
||||
for (i = length - 1; i >= 0; i--)
|
||||
draw_char_node(term, xpos - (length - i), ypos, s[i], 0, node_number);
|
||||
draw_char(term, xpos - (length - i), ypos, s[i], 0, color);
|
||||
|
||||
return length;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
draw_temperature_node(struct session *ses, int xpos, int ypos, unsigned int node_number)
|
||||
draw_temperature(struct session *ses, int xpos, int ypos, struct color_pair *color)
|
||||
{
|
||||
struct terminal *term = ses->tab->term;
|
||||
FILE *f;
|
||||
int temp = 0;
|
||||
int ret;
|
||||
struct string text;
|
||||
int i;
|
||||
int length;
|
||||
@ -225,16 +222,9 @@ draw_temperature_node(struct session *ses, int xpos, int ypos, unsigned int node
|
||||
|
||||
f = fopen(get_leds_temperature_filename(), "r");
|
||||
|
||||
if (!f) {
|
||||
return 0;
|
||||
}
|
||||
ret = fscanf(f, "%d", &temp);
|
||||
if (!f) return 0;
|
||||
fscanf(f, "%d", &temp);
|
||||
fclose(f);
|
||||
|
||||
if (ret < 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!init_string(&text)) {
|
||||
return 0;
|
||||
}
|
||||
@ -255,7 +245,7 @@ draw_temperature_node(struct session *ses, int xpos, int ypos, unsigned int node
|
||||
#else
|
||||
unsigned char data = pos[i];
|
||||
#endif
|
||||
draw_char_node(term, xpos - length + i, ypos, data, 0, node_number);
|
||||
draw_char(term, xpos - length + i, ypos, data, 0, color);
|
||||
}
|
||||
done_string(&text);
|
||||
|
||||
@ -264,7 +254,7 @@ draw_temperature_node(struct session *ses, int xpos, int ypos, unsigned int node
|
||||
|
||||
#ifdef HAVE_STRFTIME
|
||||
static int
|
||||
draw_clock_node(struct terminal *term, int xpos, int ypos, unsigned int node_number)
|
||||
draw_clock(struct terminal *term, int xpos, int ypos, struct color_pair *color)
|
||||
{
|
||||
char s[64];
|
||||
time_t curtime = time(NULL);
|
||||
@ -274,7 +264,7 @@ draw_clock_node(struct terminal *term, int xpos, int ypos, unsigned int node_num
|
||||
length = strftime(s, sizeof(s), get_leds_clock_format(), loctime);
|
||||
s[length] = '\0';
|
||||
for (i = length - 1; i >= 0; i--)
|
||||
draw_char_node(term, xpos - (length - i), ypos, s[i], 0, node_number);
|
||||
draw_char(term, xpos - (length - i), ypos, s[i], 0, color);
|
||||
|
||||
return length;
|
||||
}
|
||||
@ -299,7 +289,7 @@ void
|
||||
draw_leds(struct session *ses)
|
||||
{
|
||||
struct terminal *term = ses->tab->term;
|
||||
unsigned int node_number = 0;
|
||||
struct color_pair *led_color = NULL;
|
||||
int i;
|
||||
int xpos = term->width - LEDS_COUNT - 3;
|
||||
int ypos = term->height - 1;
|
||||
@ -309,50 +299,50 @@ draw_leds(struct session *ses)
|
||||
/* This should be done elsewhere, but this is very nice place where we
|
||||
* could do that easily. */
|
||||
if (get_opt_int("ui.timer.enable", NULL) == 2) {
|
||||
node_number = get_bfu_color_node(term, "status.status-text");
|
||||
if (!node_number) goto end;
|
||||
led_color = get_bfu_color(term, "status.status-text");
|
||||
if (!led_color) goto end;
|
||||
|
||||
term->leds_length += draw_timer_node(term, xpos, ypos, node_number);
|
||||
term->leds_length += draw_timer(term, xpos, ypos, led_color);
|
||||
}
|
||||
|
||||
if (!get_leds_panel_enable()) return;
|
||||
|
||||
if (!node_number) {
|
||||
node_number = get_bfu_color_node(term, "status.status-text");
|
||||
if (!node_number) goto end;
|
||||
if (!led_color) {
|
||||
led_color = get_bfu_color(term, "status.status-text");
|
||||
if (!led_color) goto end;
|
||||
}
|
||||
|
||||
#ifdef HAVE_STRFTIME
|
||||
if (get_leds_clock_enable()) {
|
||||
term->leds_length += draw_clock_node(term, xpos - term->leds_length, ypos, node_number);
|
||||
term->leds_length += draw_clock(term, xpos - term->leds_length, ypos, led_color);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (get_leds_temperature_enable()) {
|
||||
unsigned int node_number = get_bfu_color_node(term, "status.status-text");
|
||||
struct color_pair *color = get_bfu_color(term, "status.status-text");
|
||||
|
||||
if (node_number) term->leds_length += draw_temperature_node(ses, xpos - term->leds_length, ypos, node_number);
|
||||
if (color) term->leds_length += draw_temperature(ses, xpos - term->leds_length, ypos, color);
|
||||
}
|
||||
|
||||
if (get_leds_show_ip_enable()) {
|
||||
unsigned int node_number = get_bfu_color_node(term, "status.showip-text");
|
||||
struct color_pair *color = get_bfu_color(term, "status.showip-text");
|
||||
|
||||
if (node_number) term->leds_length += draw_show_ip_node(ses, xpos - term->leds_length, ypos, node_number);
|
||||
if (color) term->leds_length += draw_show_ip(ses, xpos - term->leds_length, ypos, color);
|
||||
}
|
||||
|
||||
/* We must shift the whole thing by one char to left, because we don't
|
||||
* draft the char in the right-down corner :(. */
|
||||
|
||||
draw_char_node(term, xpos, ypos, '[', 0, node_number);
|
||||
draw_char(term, xpos, ypos, '[', 0, led_color);
|
||||
|
||||
for (i = 0; i < LEDS_COUNT; i++) {
|
||||
struct led *led = &ses->status.leds.leds[i];
|
||||
|
||||
draw_char_node(term, xpos + i + 1, ypos, led->value__, 0, node_number);
|
||||
draw_char(term, xpos + i + 1, ypos, led->value__, 0, led_color);
|
||||
led->value_changed__ = 0;
|
||||
}
|
||||
|
||||
draw_char_node(term, xpos + LEDS_COUNT + 1, ypos, ']', 0, node_number);
|
||||
draw_char(term, xpos + LEDS_COUNT + 1, ypos, ']', 0, led_color);
|
||||
|
||||
term->leds_length += LEDS_COUNT + 2;
|
||||
|
||||
|
@ -354,20 +354,20 @@ display_listbox_item(struct listbox_item *item, void *data_, int *offset)
|
||||
{
|
||||
struct listbox_context *data = (struct listbox_context *)data_;
|
||||
int len; /* Length of the current text field. */
|
||||
unsigned int tree_color_node, text_color_node;
|
||||
struct color_pair *tree_color, *text_color;
|
||||
int depth = item->depth + 1;
|
||||
int d;
|
||||
int x, y;
|
||||
|
||||
tree_color_node = get_bfu_color_node(data->term, "menu.normal");
|
||||
tree_color = get_bfu_color(data->term, "menu.normal");
|
||||
if (item == data->box->sel) {
|
||||
text_color_node = get_bfu_color_node(data->term, "menu.selected");
|
||||
text_color = get_bfu_color(data->term, "menu.selected");
|
||||
|
||||
} else if (item->marked) {
|
||||
text_color_node = get_bfu_color_node(data->term, "menu.marked");
|
||||
text_color = get_bfu_color(data->term, "menu.marked");
|
||||
|
||||
} else {
|
||||
text_color_node = tree_color_node;
|
||||
text_color = tree_color;
|
||||
}
|
||||
|
||||
y = data->widget_data->box.y + data->offset;
|
||||
@ -383,13 +383,13 @@ display_listbox_item(struct listbox_item *item, void *data_, int *offset)
|
||||
|
||||
/* XXX */
|
||||
x = data->widget_data->box.x + d * 5;
|
||||
draw_text_node(data->term, x, y, " ", 5, 0, tree_color_node);
|
||||
draw_text(data->term, x, y, " ", 5, 0, tree_color);
|
||||
|
||||
if (root ? root->child.prev == child
|
||||
: data->box->items->prev == child)
|
||||
continue; /* We were the last branch. */
|
||||
|
||||
draw_border_char_node(data->term, x + 1, y, BORDER_SVLINE, tree_color_node);
|
||||
draw_border_char(data->term, x + 1, y, BORDER_SVLINE, tree_color);
|
||||
}
|
||||
|
||||
if (depth) {
|
||||
@ -440,7 +440,7 @@ display_listbox_item(struct listbox_item *item, void *data_, int *offset)
|
||||
|
||||
x = data->widget_data->box.x + (depth - 1) * 5;
|
||||
for (i = 0; i < 5; i++) {
|
||||
draw_border_char_node(data->term, x + i, y, str[i], tree_color_node);
|
||||
draw_border_char(data->term, x + i, y, str[i], tree_color);
|
||||
}
|
||||
}
|
||||
|
||||
@ -451,7 +451,7 @@ display_listbox_item(struct listbox_item *item, void *data_, int *offset)
|
||||
int width = data->widget_data->box.width - depth * 5;
|
||||
|
||||
for (i = 0; i < width; i++) {
|
||||
draw_border_char_node(data->term, x + i, y, BORDER_SHLINE, text_color_node);
|
||||
draw_border_char(data->term, x + i, y, BORDER_SHLINE, text_color);
|
||||
}
|
||||
|
||||
} else if (data->box->ops && data->box->ops->draw) {
|
||||
@ -478,7 +478,7 @@ display_listbox_item(struct listbox_item *item, void *data_, int *offset)
|
||||
#endif /* CONFIG_UTF8 */
|
||||
len_bytes = len;
|
||||
|
||||
draw_text_node(data->term, x, y, text, len_bytes, 0, text_color_node);
|
||||
draw_text(data->term, x, y, text, len_bytes, 0, text_color);
|
||||
|
||||
mem_free(text);
|
||||
}
|
||||
@ -505,8 +505,8 @@ display_listbox(struct dialog_data *dlg_data, struct widget_data *widget_data)
|
||||
|
||||
listbox_sel_move(widget_data, 0);
|
||||
|
||||
draw_box_node(term, &widget_data->box, ' ', 0,
|
||||
get_bfu_color_node(term, "menu.normal"));
|
||||
draw_box(term, &widget_data->box, ' ', 0,
|
||||
get_bfu_color(term, "menu.normal"));
|
||||
|
||||
memset(&data, 0, sizeof(data));
|
||||
data.term = term;
|
||||
|
162
src/bfu/menu.c
162
src/bfu/menu.c
@ -371,8 +371,8 @@ set_menu_selection(struct menu *menu, int pos)
|
||||
* separators). For double-width glyph width == 2.
|
||||
* len - length of text in bytes */
|
||||
static inline void
|
||||
draw_menu_left_text_node(struct terminal *term, char *text, int len,
|
||||
int x, int y, int width, unsigned int color_node)
|
||||
draw_menu_left_text(struct terminal *term, char *text, int len,
|
||||
int x, int y, int width, struct color_pair *color)
|
||||
{
|
||||
int w = width - (L_TEXT_SPACE + R_TEXT_SPACE);
|
||||
int max_len;
|
||||
@ -393,17 +393,17 @@ draw_menu_left_text_node(struct terminal *term, char *text, int len,
|
||||
|
||||
if (len > max_len) len = max_len;
|
||||
|
||||
draw_text_node(term, x + L_TEXT_SPACE, y, text, len, 0, color_node);
|
||||
draw_text(term, x + L_TEXT_SPACE, y, text, len, 0, color);
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
draw_menu_left_text_hk_node(struct terminal *term, char *text,
|
||||
draw_menu_left_text_hk(struct terminal *term, char *text,
|
||||
int hotkey_pos, int x, int y, int width,
|
||||
unsigned int color_node, int selected)
|
||||
struct color_pair *color, int selected)
|
||||
{
|
||||
unsigned int hk_color_node = get_bfu_color_node(term, "menu.hotkey.normal");
|
||||
unsigned int hk_color_sel_node = get_bfu_color_node(term, "menu.hotkey.selected");
|
||||
struct color_pair *hk_color = get_bfu_color(term, "menu.hotkey.normal");
|
||||
struct color_pair *hk_color_sel = get_bfu_color(term, "menu.hotkey.selected");
|
||||
screen_char_attr_T hk_attr = get_opt_bool("ui.dialogs.underline_hotkeys", NULL)
|
||||
? SCREEN_ATTR_UNDERLINE : 0;
|
||||
unsigned char c;
|
||||
@ -424,10 +424,10 @@ draw_menu_left_text_hk_node(struct terminal *term, char *text,
|
||||
if (!hotkey_pos || w <= 0) return;
|
||||
|
||||
if (selected) {
|
||||
unsigned int tmp = hk_color_node;
|
||||
struct color_pair *tmp = hk_color;
|
||||
|
||||
hk_color_node = hk_color_sel_node;
|
||||
hk_color_sel_node = tmp;
|
||||
hk_color = hk_color_sel;
|
||||
hk_color_sel = tmp;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_UTF8
|
||||
@ -442,14 +442,14 @@ draw_menu_left_text_hk_node(struct terminal *term, char *text,
|
||||
|
||||
if (hk_state == 1) {
|
||||
#ifdef CONFIG_DEBUG
|
||||
draw_char_node(term, xbase + x - 1, y, c, hk_attr,
|
||||
(double_hk ? hk_color_sel_node : hk_color_node));
|
||||
draw_char(term, xbase + x - 1, y, c, hk_attr,
|
||||
(double_hk ? hk_color_sel : hk_color));
|
||||
#else
|
||||
draw_char_node(term, xbase + x - 1, y, c, hk_attr, hk_color_node);
|
||||
draw_char(term, xbase + x - 1, y, c, hk_attr, hk_color);
|
||||
#endif /* CONFIG_DEBUG */
|
||||
hk_state = 2;
|
||||
} else {
|
||||
draw_char_node(term, xbase + x - !!hk_state, y, c, 0, color_node);
|
||||
draw_char(term, xbase + x - !!hk_state, y, c, 0, color);
|
||||
}
|
||||
}
|
||||
return;
|
||||
@ -470,30 +470,30 @@ utf8:
|
||||
if (unicode_to_cell(data) == 2) {
|
||||
if (x < w && xbase + x < term->width) {
|
||||
#ifdef CONFIG_DEBUG
|
||||
draw_char_node(term, xbase + x - 1, y,
|
||||
draw_char(term, xbase + x - 1, y,
|
||||
data, hk_attr,
|
||||
(double_hk ? hk_color_sel_node
|
||||
: hk_color_node));
|
||||
(double_hk ? hk_color_sel
|
||||
: hk_color));
|
||||
#else
|
||||
draw_char_node(term, xbase + x - 1, y,
|
||||
data, hk_attr, hk_color_node);
|
||||
draw_char(term, xbase + x - 1, y,
|
||||
data, hk_attr, hk_color);
|
||||
#endif /* CONFIG_DEBUG */
|
||||
x++;
|
||||
draw_char_node(term, xbase + x - 1, y,
|
||||
UCS_NO_CHAR, 0, hk_color_node);
|
||||
draw_char(term, xbase + x - 1, y,
|
||||
UCS_NO_CHAR, 0, hk_color);
|
||||
} else {
|
||||
draw_char_node(term, xbase + x - 1, y,
|
||||
UCS_ORPHAN_CELL, 0, hk_color_node);
|
||||
draw_char(term, xbase + x - 1, y,
|
||||
UCS_ORPHAN_CELL, 0, hk_color);
|
||||
}
|
||||
} else {
|
||||
#ifdef CONFIG_DEBUG
|
||||
draw_char_node(term, xbase + x - 1, y,
|
||||
draw_char(term, xbase + x - 1, y,
|
||||
data, hk_attr,
|
||||
(double_hk ? hk_color_sel_node
|
||||
: hk_color_node));
|
||||
(double_hk ? hk_color_sel
|
||||
: hk_color));
|
||||
#else
|
||||
draw_char_node(term, xbase + x - 1, y,
|
||||
data, hk_attr, hk_color_node);
|
||||
draw_char(term, xbase + x - 1, y,
|
||||
data, hk_attr, hk_color);
|
||||
#endif /* CONFIG_DEBUG */
|
||||
}
|
||||
hk_state = 2;
|
||||
@ -501,18 +501,18 @@ utf8:
|
||||
if (unicode_to_cell(data) == 2) {
|
||||
if (x - !!hk_state + 1 < w &&
|
||||
xbase + x - !!hk_state + 1 < term->width) {
|
||||
draw_char_node(term, xbase + x - !!hk_state,
|
||||
y, data, 0, color_node);
|
||||
draw_char(term, xbase + x - !!hk_state,
|
||||
y, data, 0, color);
|
||||
x++;
|
||||
draw_char_node(term, xbase + x - !!hk_state,
|
||||
y, UCS_NO_CHAR, 0, color_node);
|
||||
draw_char(term, xbase + x - !!hk_state,
|
||||
y, UCS_NO_CHAR, 0, color);
|
||||
} else {
|
||||
draw_char_node(term, xbase + x - !!hk_state,
|
||||
y, UCS_ORPHAN_CELL, 0, color_node);
|
||||
draw_char(term, xbase + x - !!hk_state,
|
||||
y, UCS_ORPHAN_CELL, 0, color);
|
||||
}
|
||||
} else {
|
||||
draw_char_node(term, xbase + x - !!hk_state,
|
||||
y, data, 0, color_node);
|
||||
draw_char(term, xbase + x - !!hk_state,
|
||||
y, data, 0, color);
|
||||
}
|
||||
}
|
||||
|
||||
@ -521,8 +521,8 @@ utf8:
|
||||
}
|
||||
|
||||
static inline void
|
||||
draw_menu_right_text_node(struct terminal *term, char *text, int len,
|
||||
int x, int y, int width, unsigned int color_node)
|
||||
draw_menu_right_text(struct terminal *term, char *text, int len,
|
||||
int x, int y, int width, struct color_pair *color)
|
||||
{
|
||||
int w = width - (L_RTEXT_SPACE + R_RTEXT_SPACE);
|
||||
|
||||
@ -534,17 +534,15 @@ draw_menu_right_text_node(struct terminal *term, char *text, int len,
|
||||
|
||||
x += w - len + L_RTEXT_SPACE + L_TEXT_SPACE;
|
||||
|
||||
draw_text_node(term, x, y, text, len, 0, color_node);
|
||||
draw_text(term, x, y, text, len, 0, color);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
display_menu(struct terminal *term, struct menu *menu)
|
||||
{
|
||||
unsigned int normal_color_node = get_bfu_color_node(term, "menu.normal");
|
||||
unsigned int selected_color_node = get_bfu_color_node(term, "menu.selected");
|
||||
unsigned int frame_color_node = get_bfu_color_node(term, "menu.frame");
|
||||
|
||||
struct color_pair *normal_color = get_bfu_color(term, "menu.normal");
|
||||
struct color_pair *selected_color = get_bfu_color(term, "menu.selected");
|
||||
struct color_pair *frame_color = get_bfu_color(term, "menu.frame");
|
||||
struct el_box box;
|
||||
int p;
|
||||
int menu_height;
|
||||
@ -555,13 +553,13 @@ display_menu(struct terminal *term, struct menu *menu)
|
||||
int_max(0, menu->box.width - MENU_BORDER_SIZE * 2),
|
||||
int_max(0, menu->box.height - MENU_BORDER_SIZE * 2));
|
||||
|
||||
draw_box_node(term, &box, ' ', 0, normal_color_node);
|
||||
draw_border_node(term, &box, frame_color_node, 1);
|
||||
draw_box(term, &box, ' ', 0, normal_color);
|
||||
draw_border(term, &box, frame_color, 1);
|
||||
|
||||
if (get_opt_bool("ui.dialogs.shadows", NULL)) {
|
||||
/* Draw shadow */
|
||||
draw_shadow_node(term, &menu->box,
|
||||
get_bfu_color_node(term, "dialog.shadow"), 2, 1);
|
||||
draw_shadow(term, &menu->box,
|
||||
get_bfu_color(term, "dialog.shadow"), 2, 1);
|
||||
#ifdef CONFIG_UTF8
|
||||
if (term->utf8_cp)
|
||||
fix_dwchar_around_box(term, &box, 1, 2, 1);
|
||||
@ -578,7 +576,7 @@ display_menu(struct terminal *term, struct menu *menu)
|
||||
for (p = menu->first;
|
||||
p < menu->size && p < menu->first + menu_height;
|
||||
p++, box.y++) {
|
||||
unsigned int color_node = normal_color_node;
|
||||
struct color_pair *color = normal_color;
|
||||
struct menu_item *mi = &menu->items[p];
|
||||
int selected = (p == menu->selected);
|
||||
|
||||
@ -590,23 +588,23 @@ display_menu(struct terminal *term, struct menu *menu)
|
||||
|
||||
if (selected) {
|
||||
/* This entry is selected. */
|
||||
color_node = selected_color_node;
|
||||
color = selected_color;
|
||||
|
||||
set_cursor(term, box.x, box.y, 1);
|
||||
set_window_ptr(menu->win, menu->box.x + menu->box.width, box.y);
|
||||
draw_box_node(term, &box, ' ', 0, color_node);
|
||||
draw_box(term, &box, ' ', 0, color);
|
||||
}
|
||||
|
||||
if (mi_is_horizontal_bar(mi)) {
|
||||
/* Horizontal separator */
|
||||
draw_border_char_node(term, menu->box.x, box.y,
|
||||
BORDER_SRTEE, frame_color_node);
|
||||
draw_border_char(term, menu->box.x, box.y,
|
||||
BORDER_SRTEE, frame_color);
|
||||
|
||||
draw_box_node(term, &box, BORDER_SHLINE,
|
||||
SCREEN_ATTR_FRAME, frame_color_node);
|
||||
draw_box(term, &box, BORDER_SHLINE,
|
||||
SCREEN_ATTR_FRAME, frame_color);
|
||||
|
||||
draw_border_char_node(term, box.x + box.width, box.y,
|
||||
BORDER_SLTEE, frame_color_node);
|
||||
draw_border_char(term, box.x + box.width, box.y,
|
||||
BORDER_SLTEE, frame_color);
|
||||
|
||||
continue;
|
||||
}
|
||||
@ -622,29 +620,29 @@ display_menu(struct terminal *term, struct menu *menu)
|
||||
l = 0;
|
||||
|
||||
if (l) {
|
||||
draw_menu_left_text_hk_node(term, text, l,
|
||||
box.x, box.y, box.width, color_node,
|
||||
draw_menu_left_text_hk(term, text, l,
|
||||
box.x, box.y, box.width, color,
|
||||
selected);
|
||||
|
||||
} else {
|
||||
draw_menu_left_text_node(term, text, -1,
|
||||
box.x, box.y, box.width, color_node);
|
||||
draw_menu_left_text(term, text, -1,
|
||||
box.x, box.y, box.width, color);
|
||||
}
|
||||
}
|
||||
|
||||
if (mi_is_submenu(mi)) {
|
||||
draw_menu_right_text_node(term, m_submenu, m_submenu_len,
|
||||
menu->box.x, box.y, box.width, color_node);
|
||||
draw_menu_right_text(term, m_submenu, m_submenu_len,
|
||||
menu->box.x, box.y, box.width, color);
|
||||
} else if (mi->action_id != ACT_MAIN_NONE) {
|
||||
struct string keystroke;
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
/* Help to detect action + right text. --Zas */
|
||||
if (mi_has_right_text(mi)) {
|
||||
if (color_node == selected_color_node)
|
||||
color_node = normal_color_node;
|
||||
if (color == selected_color)
|
||||
color = normal_color;
|
||||
else
|
||||
color_node = selected_color_node;
|
||||
color = selected_color;
|
||||
}
|
||||
#endif /* CONFIG_DEBUG */
|
||||
|
||||
@ -652,10 +650,10 @@ display_menu(struct terminal *term, struct menu *menu)
|
||||
add_keystroke_action_to_string(&keystroke,
|
||||
mi->action_id,
|
||||
KEYMAP_MAIN);
|
||||
draw_menu_right_text_node(term, keystroke.source,
|
||||
draw_menu_right_text(term, keystroke.source,
|
||||
keystroke.length,
|
||||
menu->box.x, box.y,
|
||||
box.width, color_node);
|
||||
box.width, color);
|
||||
done_string(&keystroke);
|
||||
}
|
||||
|
||||
@ -667,9 +665,9 @@ display_menu(struct terminal *term, struct menu *menu)
|
||||
|
||||
if (*rtext) {
|
||||
/* There's a right text, so print it */
|
||||
draw_menu_right_text_node(term, rtext, -1,
|
||||
draw_menu_right_text(term, rtext, -1,
|
||||
menu->box.x,
|
||||
box.y, box.width, color_node);
|
||||
box.y, box.width, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1087,8 +1085,8 @@ do_mainmenu(struct terminal *term, struct menu_item *items,
|
||||
static void
|
||||
display_mainmenu(struct terminal *term, struct menu *menu)
|
||||
{
|
||||
unsigned int normal_color_node = get_bfu_color_node(term, "menu.normal");
|
||||
unsigned int selected_color_node = get_bfu_color_node(term, "menu.selected");
|
||||
struct color_pair *normal_color = get_bfu_color(term, "menu.normal");
|
||||
struct color_pair *selected_color = get_bfu_color(term, "menu.selected");
|
||||
int p = 0;
|
||||
int i;
|
||||
struct el_box box;
|
||||
@ -1117,18 +1115,18 @@ display_mainmenu(struct terminal *term, struct menu *menu)
|
||||
int_bounds(&menu->first, 0, menu->last);
|
||||
|
||||
set_box(&box, 0, 0, term->width, 1);
|
||||
draw_box_node(term, &box, ' ', 0, normal_color_node);
|
||||
draw_box(term, &box, ' ', 0, normal_color);
|
||||
|
||||
if (menu->first != 0) {
|
||||
box.width = L_MAINMENU_SPACE;
|
||||
draw_box_node(term, &box, '<', 0, normal_color_node);
|
||||
draw_box(term, &box, '<', 0, normal_color);
|
||||
}
|
||||
|
||||
p += L_MAINMENU_SPACE;
|
||||
|
||||
for (i = menu->first; i < menu->size; i++) {
|
||||
struct menu_item *mi = &menu->items[i];
|
||||
unsigned int color_node = normal_color_node;
|
||||
struct color_pair *color = normal_color;
|
||||
char *text = mi->text;
|
||||
int l = mi->hotkey_pos;
|
||||
int textlen;
|
||||
@ -1147,7 +1145,7 @@ display_mainmenu(struct terminal *term, struct menu *menu)
|
||||
screencnt = textlen;
|
||||
|
||||
if (selected) {
|
||||
color_node = selected_color_node;
|
||||
color = selected_color;
|
||||
box.x = p;
|
||||
#ifdef CONFIG_UTF8
|
||||
if (term->utf8_cp)
|
||||
@ -1160,7 +1158,7 @@ display_mainmenu(struct terminal *term, struct menu *menu)
|
||||
+ textlen
|
||||
+ R_TEXT_SPACE + R_MAINTEXT_SPACE;
|
||||
|
||||
draw_box_node(term, &box, ' ', 0, color_node);
|
||||
draw_box(term, &box, ' ', 0, color);
|
||||
set_cursor(term, p, 0, 1);
|
||||
set_window_ptr(menu->win, p, 1);
|
||||
}
|
||||
@ -1168,13 +1166,13 @@ display_mainmenu(struct terminal *term, struct menu *menu)
|
||||
p += L_MAINTEXT_SPACE;
|
||||
|
||||
if (l) {
|
||||
draw_menu_left_text_hk_node(term, text, l,
|
||||
draw_menu_left_text_hk(term, text, l,
|
||||
p, 0, textlen + R_TEXT_SPACE + L_TEXT_SPACE,
|
||||
color_node, selected);
|
||||
color, selected);
|
||||
} else {
|
||||
draw_menu_left_text_node(term, text, textlen,
|
||||
draw_menu_left_text(term, text, textlen,
|
||||
p, 0, textlen + R_TEXT_SPACE + L_TEXT_SPACE,
|
||||
color_node);
|
||||
color);
|
||||
}
|
||||
|
||||
p += screencnt;
|
||||
@ -1207,7 +1205,7 @@ display_mainmenu(struct terminal *term, struct menu *menu)
|
||||
set_box(&box,
|
||||
term->width - R_MAINMENU_SPACE, 0,
|
||||
R_MAINMENU_SPACE, 1);
|
||||
draw_box_node(term, &box, '>', 0, normal_color_node);
|
||||
draw_box(term, &box, '>', 0, normal_color);
|
||||
}
|
||||
|
||||
redraw_windows(REDRAW_IN_FRONT_OF_WINDOW, menu->win);
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "util/color.h"
|
||||
|
||||
/* FIXME: For UTF-8 strings we need better function than isspace. */
|
||||
#define is_unsplitable(pos) (*(pos) && *(pos) != '\n' && !isspace((unsigned char)*(pos)))
|
||||
#define is_unsplitable(pos) (*(pos) && *(pos) != '\n' && !isspace(*(pos)))
|
||||
|
||||
void
|
||||
add_dlg_text(struct dialog *dlg, char *text,
|
||||
@ -175,7 +175,7 @@ split_lines(struct widget_data *widget_data, int max_width)
|
||||
int cells = 0;
|
||||
|
||||
/* Skip first leading \n or space. */
|
||||
if (isspace((unsigned char)*text)) text++;
|
||||
if (isspace(*text)) text++;
|
||||
if (!*text) break;
|
||||
|
||||
#ifdef CONFIG_UTF8
|
||||
@ -210,13 +210,12 @@ split_lines(struct widget_data *widget_data, int max_width)
|
||||
return lines;
|
||||
}
|
||||
|
||||
|
||||
/* Format text according to dialog box and alignment. */
|
||||
void
|
||||
dlg_format_text_do_node(struct dialog_data *dlg_data,
|
||||
dlg_format_text_do(struct dialog_data *dlg_data,
|
||||
const char *text,
|
||||
int x, int *y, int width, int *real_width,
|
||||
unsigned int color_node, format_align_T align,
|
||||
struct color_pair *color, format_align_T align,
|
||||
int format_only)
|
||||
{
|
||||
#ifdef CONFIG_UTF8
|
||||
@ -230,7 +229,7 @@ dlg_format_text_do_node(struct dialog_data *dlg_data,
|
||||
int cells = 0;
|
||||
|
||||
/* Skip first leading \n or space. */
|
||||
if (!firstline && isspace((unsigned char)*text))
|
||||
if (!firstline && isspace(*text))
|
||||
text++;
|
||||
else
|
||||
firstline = 0;
|
||||
@ -261,11 +260,10 @@ dlg_format_text_do_node(struct dialog_data *dlg_data,
|
||||
|
||||
assert(cells <= width && shift < width);
|
||||
|
||||
draw_dlg_text_node(dlg_data, x + shift, *y, text, line_width, 0, color_node);
|
||||
draw_dlg_text(dlg_data, x + shift, *y, text, line_width, 0, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
dlg_format_text(struct dialog_data *dlg_data,
|
||||
struct widget_data *widget_data,
|
||||
@ -344,12 +342,11 @@ dlg_format_text(struct dialog_data *dlg_data,
|
||||
widget_data->info.text.current = 0;
|
||||
}
|
||||
|
||||
dlg_format_text_do_node(dlg_data, text,
|
||||
dlg_format_text_do(dlg_data, text,
|
||||
x, y, width, real_width,
|
||||
get_bfu_color_node(term, "dialog.text"),
|
||||
get_bfu_color(term, "dialog.text"),
|
||||
widget_data->widget->info.text.align, format_only);
|
||||
|
||||
|
||||
if (widget_data->widget->info.text.is_label) (*y)--;
|
||||
|
||||
/* If we scrolled and something was trimmed restore it */
|
||||
@ -373,8 +370,8 @@ display_text(struct dialog_data *dlg_data, struct widget_data *widget_data)
|
||||
if (!text_is_scrollable(widget_data) || box.height <= 0)
|
||||
return EVENT_PROCESSED;
|
||||
|
||||
draw_box_node(win->term, &box, ' ', 0,
|
||||
get_bfu_color_node(win->term, "dialog.scrollbar"));
|
||||
draw_box(win->term, &box, ' ', 0,
|
||||
get_bfu_color(win->term, "dialog.scrollbar"));
|
||||
|
||||
current = widget_data->info.text.current;
|
||||
scale = (box.height + 1) * 100 / lines;
|
||||
@ -400,8 +397,8 @@ display_text(struct dialog_data *dlg_data, struct widget_data *widget_data)
|
||||
widget_data->info.text.scroller_y = box.y;
|
||||
#endif
|
||||
|
||||
draw_box_node(win->term, &box, ' ', 0,
|
||||
get_bfu_color_node(win->term, "dialog.scrollbar-selected"));
|
||||
draw_box(win->term, &box, ' ', 0,
|
||||
get_bfu_color(win->term, "dialog.scrollbar-selected"));
|
||||
|
||||
/* Hope this is at least a bit reasonable. Set cursor
|
||||
* and window pointer to start of the first text line. */
|
||||
@ -430,8 +427,8 @@ format_and_display_text(struct widget_data *widget_data,
|
||||
|
||||
widget_data->info.text.current = current;
|
||||
|
||||
draw_box_node(term, &widget_data->box, ' ', 0,
|
||||
get_bfu_color_node(term, "dialog.generic"));
|
||||
draw_box(term, &widget_data->box, ' ', 0,
|
||||
get_bfu_color(term, "dialog.generic"));
|
||||
|
||||
dlg_format_text(dlg_data, widget_data,
|
||||
widget_data->box.x, &y, widget_data->box.width, NULL,
|
||||
|
@ -135,7 +135,7 @@ download_dialog_layouter(struct dialog_data *dlg_data)
|
||||
int url_len;
|
||||
char *url;
|
||||
struct download *download = &file_download->download;
|
||||
unsigned int dialog_text_color_node = get_bfu_color_node(term, "dialog.text");
|
||||
struct color_pair *dialog_text_color = get_bfu_color(term, "dialog.text");
|
||||
char *msg = get_download_msg(download, term, 1, 1, "\n");
|
||||
int show_meter = (download_is_progressing(download)
|
||||
&& download->progress->size >= 0);
|
||||
@ -166,8 +166,8 @@ download_dialog_layouter(struct dialog_data *dlg_data)
|
||||
int_lower_bound(&w, DOWN_DLG_MIN);
|
||||
}
|
||||
|
||||
dlg_format_text_do_node(dlg_data, url, 0, &y, w, &rw,
|
||||
dialog_text_color_node, ALIGN_LEFT, 1);
|
||||
dlg_format_text_do(dlg_data, url, 0, &y, w, &rw,
|
||||
dialog_text_color, ALIGN_LEFT, 1);
|
||||
|
||||
y++;
|
||||
if (show_meter) y += 2;
|
||||
@ -175,8 +175,8 @@ download_dialog_layouter(struct dialog_data *dlg_data)
|
||||
#ifdef CONFIG_BITTORRENT
|
||||
if (bittorrent) y += 2;
|
||||
#endif
|
||||
dlg_format_text_do_node(dlg_data, msg, 0, &y, w, &rw,
|
||||
dialog_text_color_node, ALIGN_LEFT, 1);
|
||||
dlg_format_text_do(dlg_data, msg, 0, &y, w, &rw,
|
||||
dialog_text_color, ALIGN_LEFT, 1);
|
||||
|
||||
y++;
|
||||
dlg_format_buttons(dlg_data, dlg_data->widgets_data,
|
||||
@ -199,25 +199,25 @@ download_dialog_layouter(struct dialog_data *dlg_data)
|
||||
|
||||
y = dlg_data->box.y + DIALOG_TB + 1;
|
||||
x = dlg_data->box.x + DIALOG_LB;
|
||||
dlg_format_text_do_node(dlg_data, url, x, &y, w, NULL,
|
||||
dialog_text_color_node, ALIGN_LEFT, 0);
|
||||
dlg_format_text_do(dlg_data, url, x, &y, w, NULL,
|
||||
dialog_text_color, ALIGN_LEFT, 0);
|
||||
|
||||
if (show_meter) {
|
||||
y++;
|
||||
draw_progress_bar_node(download->progress, term, x, y, w, NULL, 0);
|
||||
draw_progress_bar(download->progress, term, x, y, w, NULL, NULL);
|
||||
y++;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BITTORRENT
|
||||
if (bittorrent) {
|
||||
y++;
|
||||
draw_bittorrent_piece_progress_node(download, term, x, y, w, NULL, 0);
|
||||
draw_bittorrent_piece_progress(download, term, x, y, w, NULL, NULL);
|
||||
y++;
|
||||
}
|
||||
#endif
|
||||
y++;
|
||||
dlg_format_text_do_node(dlg_data, msg, x, &y, w, NULL,
|
||||
dialog_text_color_node, ALIGN_LEFT, 0);
|
||||
dlg_format_text_do(dlg_data, msg, x, &y, w, NULL,
|
||||
dialog_text_color, ALIGN_LEFT, 0);
|
||||
|
||||
y++;
|
||||
dlg_format_buttons(dlg_data, dlg_data->widgets_data,
|
||||
@ -378,7 +378,7 @@ draw_file_download(struct listbox_item *item, struct listbox_context *context,
|
||||
struct file_download *file_download = (struct file_download *)item->udata;
|
||||
struct download *download = &file_download->download;
|
||||
const char *stylename;
|
||||
unsigned int color_node;
|
||||
struct color_pair *color;
|
||||
char *text;
|
||||
int length;
|
||||
int trimmedlen;
|
||||
@ -391,7 +391,7 @@ draw_file_download(struct listbox_item *item, struct listbox_context *context,
|
||||
: ((item->marked) ? "menu.marked"
|
||||
: "menu.normal");
|
||||
|
||||
color_node = get_bfu_color_node(context->term, stylename);
|
||||
color = get_bfu_color(context->term, stylename);
|
||||
|
||||
text = get_file_download_text(item, context->term);
|
||||
if (!text) return;
|
||||
@ -404,9 +404,9 @@ draw_file_download(struct listbox_item *item, struct listbox_context *context,
|
||||
trimmedlen = int_min(length, width - 3);
|
||||
}
|
||||
|
||||
draw_text_node(context->term, x, y, text, trimmedlen, 0, color_node);
|
||||
draw_text(context->term, x, y, text, trimmedlen, 0, color);
|
||||
if (trimmedlen < length) {
|
||||
draw_text_node(context->term, x + trimmedlen, y, "...", 3, 0, color_node);
|
||||
draw_text(context->term, x + trimmedlen, y, "...", 3, 0, color);
|
||||
trimmedlen += 3;
|
||||
}
|
||||
|
||||
@ -427,7 +427,7 @@ draw_file_download(struct listbox_item *item, struct listbox_context *context,
|
||||
|
||||
x += width - meter;
|
||||
|
||||
draw_progress_bar_node(download->progress, context->term, x, y, meter, NULL, 0);
|
||||
draw_progress_bar(download->progress, context->term, x, y, meter, NULL, NULL);
|
||||
}
|
||||
|
||||
static struct listbox_ops_messages download_messages = {
|
||||
|
@ -104,11 +104,10 @@ get_progress_msg(struct progress *progress, struct terminal *term,
|
||||
return get_progress_msg_2(progress, term, wide, full, separator, _("Received", term));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
draw_progress_bar_node(struct progress *progress, struct terminal *term,
|
||||
draw_progress_bar(struct progress *progress, struct terminal *term,
|
||||
int x, int y, int width,
|
||||
char *text, unsigned int meter_color_node)
|
||||
char *text, struct color_pair *meter_color)
|
||||
{
|
||||
/* Note : values > 100% are theorically possible and were seen. */
|
||||
int percent = 0;
|
||||
@ -120,14 +119,14 @@ draw_progress_bar_node(struct progress *progress, struct terminal *term,
|
||||
/* Draw the progress meter part "[### ]" */
|
||||
if (!text && width > 2) {
|
||||
width -= 2;
|
||||
draw_text_node(term, x++, y, "[", 1, 0, 0);
|
||||
draw_text_node(term, x + width, y, "]", 1, 0, 0);
|
||||
draw_text(term, x++, y, "[", 1, 0, NULL);
|
||||
draw_text(term, x + width, y, "]", 1, 0, NULL);
|
||||
}
|
||||
|
||||
if (!meter_color_node) meter_color_node = get_bfu_color_node(term, "dialog.meter");
|
||||
if (!meter_color) meter_color = get_bfu_color(term, "dialog.meter");
|
||||
set_box(&barprogress,
|
||||
x, y, int_min(width * percent / 100, width), 1);
|
||||
draw_box_node(term, &barprogress, ' ', 0, meter_color_node);
|
||||
draw_box(term, &barprogress, ' ', 0, meter_color);
|
||||
|
||||
/* On error, will print '?' only, should not occur. */
|
||||
if (text) {
|
||||
@ -153,5 +152,5 @@ draw_progress_bar_node(struct progress *progress, struct terminal *term,
|
||||
text = s;
|
||||
}
|
||||
|
||||
draw_text_node(term, x, y, text, width, 0, 0);
|
||||
draw_text(term, x, y, text, width, 0, NULL);
|
||||
}
|
||||
|
@ -17,21 +17,12 @@ char *
|
||||
get_upload_progress_msg(struct progress *progress, struct terminal *term,
|
||||
int wide, int full, const char *separator);
|
||||
|
||||
#if 0
|
||||
/* Draws a progress bar meter or progress coloured text depending on whether
|
||||
* @text is NULL. If @meter_color is NULL dialog.meter color is used. */
|
||||
void
|
||||
draw_progress_bar(struct progress *progress, struct terminal *term,
|
||||
int x, int y, int width,
|
||||
char *text, struct color_pair *meter_color);
|
||||
#endif
|
||||
|
||||
/* Draws a progress bar meter or progress coloured text depending on whether
|
||||
* @text is NULL. If @meter_color is NULL dialog.meter color is used. */
|
||||
void
|
||||
draw_progress_bar_node(struct progress *progress, struct terminal *term,
|
||||
int x, int y, int width,
|
||||
char *text, unsigned int meter_color_node);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ display_status_bar(struct session *ses, struct terminal *term, int tabs_count)
|
||||
unsigned int tab_info_len = 0;
|
||||
struct download *download = get_current_download(ses);
|
||||
struct session_status *status = &ses->status;
|
||||
unsigned int text_color_node = 0;
|
||||
struct color_pair *text_color = NULL;
|
||||
int msglen;
|
||||
struct el_box box;
|
||||
|
||||
@ -240,7 +240,7 @@ display_status_bar(struct session *ses, struct terminal *term, int tabs_count)
|
||||
}
|
||||
|
||||
set_box(&box, 0, term->height - 1, term->width, 1);
|
||||
draw_box_node(term, &box, ' ', 0, get_bfu_color_node(term, "status.status-bar"));
|
||||
draw_box(term, &box, ' ', 0, get_bfu_color(term, "status.status-bar"));
|
||||
|
||||
if (!status->show_tabs_bar && tabs_count > 1) {
|
||||
char tab_info[8];
|
||||
@ -251,19 +251,19 @@ display_status_bar(struct session *ses, struct terminal *term, int tabs_count)
|
||||
tab_info[tab_info_len++] = ' ';
|
||||
tab_info[tab_info_len] = '\0';
|
||||
|
||||
text_color_node = get_bfu_color_node(term, "status.status-text");
|
||||
draw_text_node(term, 0, term->height - 1, tab_info, tab_info_len,
|
||||
0, text_color_node);
|
||||
text_color = get_bfu_color(term, "status.status-text");
|
||||
draw_text(term, 0, term->height - 1, tab_info, tab_info_len,
|
||||
0, text_color);
|
||||
}
|
||||
|
||||
if (!msg) return;
|
||||
|
||||
if (!text_color_node)
|
||||
text_color_node = get_bfu_color_node(term, "status.status-text");
|
||||
if (!text_color)
|
||||
text_color = get_bfu_color(term, "status.status-text");
|
||||
|
||||
msglen = strlen(msg);
|
||||
draw_text_node(term, 0 + tab_info_len, term->height - 1,
|
||||
msg, msglen, 0, text_color_node);
|
||||
draw_text(term, 0 + tab_info_len, term->height - 1,
|
||||
msg, msglen, 0, text_color);
|
||||
mem_free(msg);
|
||||
|
||||
if (download_is_progressing(download) && download->progress->size > 0) {
|
||||
@ -278,20 +278,20 @@ display_status_bar(struct session *ses, struct terminal *term, int tabs_count)
|
||||
width = int_max(0, xend - msglen - tab_info_len - 1);
|
||||
if (width < 6) return;
|
||||
int_upper_bound(&width, 20);
|
||||
draw_progress_bar_node(download->progress, term,
|
||||
draw_progress_bar(download->progress, term,
|
||||
xend - width, term->height - 1, width,
|
||||
NULL, 0);
|
||||
NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
display_tab_bar(struct session *ses, struct terminal *term, int tabs_count)
|
||||
{
|
||||
unsigned int normal_color_node = get_bfu_color_node(term, "tabs.normal");
|
||||
unsigned int selected_color_node = get_bfu_color_node(term, "tabs.selected");
|
||||
unsigned int loading_color_node = get_bfu_color_node(term, "tabs.loading");
|
||||
unsigned int fresh_color_node = get_bfu_color_node(term, "tabs.unvisited");
|
||||
unsigned int tabsep_color_node = get_bfu_color_node(term, "tabs.separator");
|
||||
struct color_pair *normal_color = get_bfu_color(term, "tabs.normal");
|
||||
struct color_pair *selected_color = get_bfu_color(term, "tabs.selected");
|
||||
struct color_pair *loading_color = get_bfu_color(term, "tabs.loading");
|
||||
struct color_pair *fresh_color = get_bfu_color(term, "tabs.unvisited");
|
||||
struct color_pair *tabsep_color = get_bfu_color(term, "tabs.separator");
|
||||
struct session_status *status = &ses->status;
|
||||
int tab_width = int_max(1, term->width / tabs_count);
|
||||
int tab_total_width = tab_width * tabs_count;
|
||||
@ -305,7 +305,7 @@ display_tab_bar(struct session *ses, struct terminal *term, int tabs_count)
|
||||
|
||||
for (tab_num = 0; tab_num < tabs_count; tab_num++) {
|
||||
struct download *download = NULL;
|
||||
unsigned int color_node = normal_color_node;
|
||||
struct color_pair *color = normal_color;
|
||||
struct window *tab = get_tab_by_number(term, tab_num);
|
||||
struct document_view *doc_view;
|
||||
struct session *tab_ses = (struct session *)tab->data;
|
||||
@ -331,21 +331,21 @@ display_tab_bar(struct session *ses, struct terminal *term, int tabs_count)
|
||||
}
|
||||
|
||||
if (tab_num) {
|
||||
draw_char_node(term, box.x, box.y, BORDER_SVLINE,
|
||||
SCREEN_ATTR_FRAME, tabsep_color_node);
|
||||
draw_char(term, box.x, box.y, BORDER_SVLINE,
|
||||
SCREEN_ATTR_FRAME, tabsep_color);
|
||||
box.x++;
|
||||
}
|
||||
|
||||
if (tab_num == term->current_tab) {
|
||||
color_node = selected_color_node;
|
||||
color = selected_color;
|
||||
|
||||
} else {
|
||||
download = get_current_download(tab_ses);
|
||||
|
||||
if (download && !is_in_state(download->state, S_OK)) {
|
||||
color_node = loading_color_node;
|
||||
color = loading_color;
|
||||
} else if (!tab_ses || !tab_ses->status.visited) {
|
||||
color_node = fresh_color_node;
|
||||
color = fresh_color;
|
||||
}
|
||||
|
||||
if (!download_is_progressing(download)
|
||||
@ -354,12 +354,12 @@ display_tab_bar(struct session *ses, struct terminal *term, int tabs_count)
|
||||
}
|
||||
|
||||
box.width = actual_tab_width + 1;
|
||||
draw_box_node(term, &box, ' ', 0, color_node);
|
||||
draw_box(term, &box, ' ', 0, color);
|
||||
|
||||
if (download) {
|
||||
draw_progress_bar_node(download->progress, term,
|
||||
draw_progress_bar(download->progress, term,
|
||||
box.x, box.y, actual_tab_width,
|
||||
msg, 0);
|
||||
msg, NULL);
|
||||
} else {
|
||||
int msglen;
|
||||
#ifdef CONFIG_UTF8
|
||||
@ -372,7 +372,7 @@ display_tab_bar(struct session *ses, struct terminal *term, int tabs_count)
|
||||
#endif /* CONFIG_UTF8 */
|
||||
msglen = int_min(strlen(msg), actual_tab_width);
|
||||
|
||||
draw_text_node(term, box.x, box.y, msg, msglen, 0, color_node);
|
||||
draw_text(term, box.x, box.y, msg, msglen, 0, color);
|
||||
}
|
||||
|
||||
tab->xpos = box.x;
|
||||
@ -405,7 +405,7 @@ display_title_bar(struct session *ses, struct terminal *term)
|
||||
struct el_box box;
|
||||
|
||||
set_box(&box, 0, 0, term->width, 1);
|
||||
draw_box_node(term, &box, ' ', 0, get_bfu_color_node(term, "title.title-bar"));
|
||||
draw_box(term, &box, ' ', 0, get_bfu_color(term, "title.title-bar"));
|
||||
}
|
||||
|
||||
doc_view = current_frame(ses);
|
||||
@ -472,8 +472,8 @@ display_title_bar(struct session *ses, struct terminal *term)
|
||||
#endif /* CONFIG_UTF8 */
|
||||
x = int_max(term->width - 1 - title.length, 0);
|
||||
|
||||
draw_text_node(term, x, 0, title.source, title.length, 0,
|
||||
get_bfu_color_node(term, "title.title-text"));
|
||||
draw_text(term, x, 0, title.source, title.length, 0,
|
||||
get_bfu_color(term, "title.title-text"));
|
||||
}
|
||||
|
||||
done_string(&title);
|
||||
|
@ -452,22 +452,14 @@ get_bittorrent_message(struct download *download, struct terminal *term,
|
||||
return string.source;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void
|
||||
draw_bittorrent_piece_progress(struct download *download, struct terminal *term,
|
||||
int x, int y, int width, char *text,
|
||||
struct color_pair *color)
|
||||
#endif
|
||||
void
|
||||
draw_bittorrent_piece_progress_node(struct download *download, struct terminal *term,
|
||||
int x, int y, int width, char *text,
|
||||
unsigned int color_node)
|
||||
|
||||
{
|
||||
struct bittorrent_connection *bittorrent;
|
||||
uint32_t piece;
|
||||
int x_start;
|
||||
unsigned int node_number = 0;
|
||||
|
||||
if (!download->conn || !download->conn->info)
|
||||
return;
|
||||
@ -477,8 +469,8 @@ draw_bittorrent_piece_progress_node(struct download *download, struct terminal *
|
||||
/* Draw the progress meter part "[### ]" */
|
||||
if (!text && width > 2) {
|
||||
width -= 2;
|
||||
draw_text_node(term, x++, y, "[", 1, 0, 0);
|
||||
draw_text_node(term, x + width, y, "]", 1, 0, 0);
|
||||
draw_text(term, x++, y, "[", 1, 0, NULL);
|
||||
draw_text(term, x + width, y, "]", 1, 0, NULL);
|
||||
}
|
||||
|
||||
x_start = x;
|
||||
@ -486,7 +478,7 @@ draw_bittorrent_piece_progress_node(struct download *download, struct terminal *
|
||||
if (width <= 0 || !bittorrent->cache)
|
||||
return;
|
||||
|
||||
if (!color_node) node_number = get_bfu_color_node(term, "dialog.meter");
|
||||
if (!color) color = get_bfu_color(term, "dialog.meter");
|
||||
|
||||
if (bittorrent->meta.pieces <= width) {
|
||||
int chars_per_piece = width / bittorrent->meta.pieces;
|
||||
@ -497,9 +489,8 @@ draw_bittorrent_piece_progress_node(struct download *download, struct terminal *
|
||||
|
||||
set_box(&piecebox, x, y, chars_per_piece + !!remainder, 1);
|
||||
|
||||
if (bittorrent->cache->entries[piece].completed) {
|
||||
draw_box_node(term, &piecebox, ' ', 0, node_number);
|
||||
}
|
||||
if (bittorrent->cache->entries[piece].completed)
|
||||
draw_box(term, &piecebox, ' ', 0, color);
|
||||
|
||||
x += chars_per_piece + !!remainder;
|
||||
if (remainder > 0) remainder--;
|
||||
@ -508,10 +499,13 @@ draw_bittorrent_piece_progress_node(struct download *download, struct terminal *
|
||||
} else {
|
||||
int pieces_per_char = bittorrent->meta.pieces / width;
|
||||
int remainder = bittorrent->meta.pieces % width;
|
||||
unsigned int inverted_node = get_bfu_color_node(term, "dialog.meter"); // must be inverted
|
||||
struct color_pair inverted;
|
||||
uint32_t completed = 0, remaining = 0;
|
||||
int steps = pieces_per_char + !!remainder;
|
||||
|
||||
inverted.background = color->foreground;
|
||||
inverted.foreground = color->background;
|
||||
|
||||
for (piece = 0; piece < bittorrent->meta.pieces; piece++) {
|
||||
if (bittorrent->cache->entries[piece].completed)
|
||||
completed++;
|
||||
@ -524,18 +518,16 @@ draw_bittorrent_piece_progress_node(struct download *download, struct terminal *
|
||||
assert(completed <= pieces_per_char + !!remainder);
|
||||
assert(remaining <= pieces_per_char + !!remainder);
|
||||
|
||||
if (!remaining) /* 100% */ {
|
||||
draw_char_color_node(term, x, y, node_number);
|
||||
}
|
||||
if (!remaining) /* 100% */
|
||||
draw_char_color(term, x, y, color);
|
||||
|
||||
else if (completed > remaining) /* > 50% */ {
|
||||
draw_char_node(term, x, y, BORDER_SVLINE,
|
||||
SCREEN_ATTR_FRAME, node_number);
|
||||
}
|
||||
else if (completed > remaining) /* > 50% */
|
||||
draw_char(term, x, y, BORDER_SVLINE,
|
||||
SCREEN_ATTR_FRAME, color);
|
||||
|
||||
else if (completed) /* > 0% */
|
||||
draw_char_node(term, x, y, BORDER_SVLINE,
|
||||
SCREEN_ATTR_FRAME, inverted_node);
|
||||
draw_char(term, x, y, BORDER_SVLINE,
|
||||
SCREEN_ATTR_FRAME, &inverted);
|
||||
|
||||
x++;
|
||||
if (remainder > 0) remainder--;
|
||||
@ -566,7 +558,7 @@ draw_bittorrent_piece_progress_node(struct download *download, struct terminal *
|
||||
|
||||
assert(slen <= width);
|
||||
|
||||
draw_text_node(term, x_start, y, s, slen, 0, 0);
|
||||
draw_text(term, x_start, y, s, slen, 0, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,18 +19,10 @@ char *
|
||||
get_bittorrent_message(struct download *download, struct terminal *term,
|
||||
int wide, int full, const char *separator);
|
||||
|
||||
#if 0
|
||||
void
|
||||
draw_bittorrent_piece_progress(struct download *download, struct terminal *term,
|
||||
int x, int y, int width, char *text,
|
||||
struct color_pair *meter_color);
|
||||
#endif
|
||||
|
||||
void
|
||||
draw_bittorrent_piece_progress_node(struct download *download, struct terminal *term,
|
||||
int x, int y, int width, char *text,
|
||||
unsigned int meter_color_node);
|
||||
|
||||
|
||||
void set_bittorrent_files_for_deletion(struct download *download);
|
||||
void set_bittorrent_notify_on_completion(struct download *download, struct terminal *term);
|
||||
|
@ -384,7 +384,6 @@ set_term_color(struct screen_char *schar, struct color_pair *pair,
|
||||
|
||||
assert(color_mode >= COLOR_MODE_DUMP && color_mode < COLOR_MODES);
|
||||
|
||||
schar->is_node = 0;
|
||||
/* Options for the various color modes. */
|
||||
switch (color_mode) {
|
||||
|
||||
|
@ -26,10 +26,10 @@
|
||||
|
||||
#if SCREEN_COLOR_SIZE > 1
|
||||
#define clear_screen_char_color(schar) \
|
||||
do { memset((schar)->c.color, 0, SCREEN_COLOR_SIZE); (schar)->is_node = 0;} while (0)
|
||||
do { memset((schar)->c.color, 0, SCREEN_COLOR_SIZE); } while (0)
|
||||
#else
|
||||
#define clear_screen_char_color(schar) \
|
||||
do { (schar)->c.color[0] = 0; (schar)->is_node = 0; } while (0)
|
||||
do { (schar)->c.color[0] = 0; } while (0)
|
||||
#endif
|
||||
|
||||
|
||||
@ -74,46 +74,11 @@ draw_border_cross(struct terminal *term, int x, int y,
|
||||
} else if (screen_char->data == border_trans[d][2 - (dir & 1)]) {
|
||||
screen_char->data = BORDER_SCROSS;
|
||||
}
|
||||
screen_char->is_node = 0;
|
||||
|
||||
set_term_color(screen_char, color, 0,
|
||||
get_opt_int_tree(term->spec, "colors", NULL));
|
||||
}
|
||||
|
||||
void
|
||||
draw_border_cross_node(struct terminal *term, int x, int y,
|
||||
enum border_cross_direction dir, unsigned int node_number)
|
||||
{
|
||||
static const unsigned char border_trans[2][4] = {
|
||||
/* Used for BORDER_X_{RIGHT,LEFT}: */
|
||||
{ BORDER_SVLINE, BORDER_SRTEE, BORDER_SLTEE },
|
||||
/* Used for BORDER_X_{DOWN,UP}: */
|
||||
{ BORDER_SHLINE, BORDER_SDTEE, BORDER_SUTEE },
|
||||
};
|
||||
struct screen_char *screen_char = get_char(term, x, y);
|
||||
unsigned int d;
|
||||
|
||||
if (!screen_char) return;
|
||||
if (!(screen_char->attr & SCREEN_ATTR_FRAME)) return;
|
||||
|
||||
/* First check if there is already a horizontal/vertical line, so that
|
||||
* we will have to replace with a T char. Example: if there is a '|'
|
||||
* and the direction is right, replace with a '|-' T char.
|
||||
*
|
||||
* If this is not the case check if there is a T char and we are adding
|
||||
* the direction so that we end up with a cross. Example : if there is
|
||||
* a '|-' and the direction is left, replace with a '+' (cross) char. */
|
||||
d = dir>>1;
|
||||
if (screen_char->data == border_trans[d][0]) {
|
||||
screen_char->data = border_trans[d][1 + (dir & 1)];
|
||||
|
||||
} else if (screen_char->data == border_trans[d][2 - (dir & 1)]) {
|
||||
screen_char->data = BORDER_SCROSS;
|
||||
}
|
||||
screen_char->c.node_number = node_number;
|
||||
screen_char->is_node = 1;
|
||||
}
|
||||
|
||||
void
|
||||
draw_border_char(struct terminal *term, int x, int y,
|
||||
border_char_T border, struct color_pair *color)
|
||||
@ -124,28 +89,11 @@ draw_border_char(struct terminal *term, int x, int y,
|
||||
|
||||
screen_char->data = (unsigned char) border;
|
||||
screen_char->attr = SCREEN_ATTR_FRAME;
|
||||
screen_char->is_node = 0;
|
||||
set_term_color(screen_char, color, 0,
|
||||
get_opt_int_tree(term->spec, "colors", NULL));
|
||||
set_screen_dirty(term->screen, y, y);
|
||||
}
|
||||
|
||||
void
|
||||
draw_border_char_node(struct terminal *term, int x, int y,
|
||||
border_char_T border, unsigned int node_number)
|
||||
{
|
||||
struct screen_char *screen_char = get_char(term, x, y);
|
||||
|
||||
if (!screen_char) return;
|
||||
|
||||
screen_char->data = (unsigned char) border;
|
||||
screen_char->attr = SCREEN_ATTR_FRAME;
|
||||
screen_char->c.node_number = node_number;
|
||||
screen_char->is_node = 1;
|
||||
set_screen_dirty(term->screen, y, y);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
draw_char_color(struct terminal *term, int x, int y, struct color_pair *color)
|
||||
{
|
||||
@ -155,19 +103,6 @@ draw_char_color(struct terminal *term, int x, int y, struct color_pair *color)
|
||||
|
||||
set_term_color(screen_char, color, 0,
|
||||
get_opt_int_tree(term->spec, "colors", NULL));
|
||||
screen_char->is_node = 0;
|
||||
set_screen_dirty(term->screen, y, y);
|
||||
}
|
||||
|
||||
void
|
||||
draw_char_color_node(struct terminal *term, int x, int y, unsigned int node_number)
|
||||
{
|
||||
struct screen_char *screen_char = get_char(term, x, y);
|
||||
|
||||
if (!screen_char) return;
|
||||
|
||||
screen_char->c.node_number = node_number;
|
||||
screen_char->is_node = 1;
|
||||
set_screen_dirty(term->screen, y, y);
|
||||
}
|
||||
|
||||
@ -206,20 +141,6 @@ draw_char_data(struct terminal *term, int x, int y, unsigned char data)
|
||||
set_screen_dirty(term->screen, y, y);
|
||||
}
|
||||
|
||||
void
|
||||
draw_space(struct terminal *term, int x, int y, struct screen_char *color)
|
||||
{
|
||||
struct screen_char *screen_char = get_char(term, x, y);
|
||||
|
||||
if (!screen_char) return;
|
||||
|
||||
screen_char->data = ' ';
|
||||
if (color) {
|
||||
screen_char->c = color->c;
|
||||
screen_char->is_node = color->is_node;
|
||||
}
|
||||
}
|
||||
|
||||
/*! Used by viewer to copy over a document.
|
||||
* When doing frame drawing @a x can be different than 0. */
|
||||
void
|
||||
@ -338,73 +259,6 @@ draw_border(struct terminal *term, struct el_box *box,
|
||||
set_screen_dirty(term->screen, borderbox.y, borderbox.y + borderbox.height);
|
||||
}
|
||||
|
||||
void
|
||||
draw_border_node(struct terminal *term, struct el_box *box,
|
||||
unsigned int node_number, int width)
|
||||
{
|
||||
static const border_char_T p1[] = {
|
||||
BORDER_SULCORNER,
|
||||
BORDER_SURCORNER,
|
||||
BORDER_SDLCORNER,
|
||||
BORDER_SDRCORNER,
|
||||
BORDER_SVLINE,
|
||||
BORDER_SHLINE,
|
||||
};
|
||||
static const border_char_T p2[] = {
|
||||
BORDER_DULCORNER,
|
||||
BORDER_DURCORNER,
|
||||
BORDER_DDLCORNER,
|
||||
BORDER_DDRCORNER,
|
||||
BORDER_DVLINE,
|
||||
BORDER_DHLINE,
|
||||
};
|
||||
const border_char_T *p = (width > 1) ? p2 : p1;
|
||||
struct el_box borderbox;
|
||||
|
||||
set_box(&borderbox, box->x - 1, box->y - 1,
|
||||
box->width + 2, box->height + 2);
|
||||
|
||||
if (borderbox.width > 2) {
|
||||
struct el_box bbox;
|
||||
|
||||
/* Horizontal top border */
|
||||
set_box(&bbox, box->x, borderbox.y, box->width, 1);
|
||||
draw_box_node(term, &bbox, p[5], SCREEN_ATTR_FRAME, node_number);
|
||||
|
||||
/* Horizontal bottom border */
|
||||
bbox.y += borderbox.height - 1;
|
||||
draw_box_node(term, &bbox, p[5], SCREEN_ATTR_FRAME, node_number);
|
||||
}
|
||||
|
||||
if (borderbox.height > 2) {
|
||||
struct el_box bbox;
|
||||
|
||||
/* Vertical left border */
|
||||
set_box(&bbox, borderbox.x, box->y, 1, box->height);
|
||||
draw_box_node(term, &bbox, p[4], SCREEN_ATTR_FRAME, node_number);
|
||||
|
||||
/* Vertical right border */
|
||||
bbox.x += borderbox.width - 1;
|
||||
draw_box_node(term, &bbox, p[4], SCREEN_ATTR_FRAME, node_number);
|
||||
}
|
||||
|
||||
if (borderbox.width > 1 && borderbox.height > 1) {
|
||||
int right = borderbox.x + borderbox.width - 1;
|
||||
int bottom = borderbox.y + borderbox.height - 1;
|
||||
|
||||
/* Upper left corner */
|
||||
draw_border_char_node(term, borderbox.x, borderbox.y, p[0], node_number);
|
||||
/* Upper right corner */
|
||||
draw_border_char_node(term, right, borderbox.y, p[1], node_number);
|
||||
/* Lower left corner */
|
||||
draw_border_char_node(term, borderbox.x, bottom, p[2], node_number);
|
||||
/* Lower right corner */
|
||||
draw_border_char_node(term, right, bottom, p[3], node_number);
|
||||
}
|
||||
|
||||
set_screen_dirty(term->screen, borderbox.y, borderbox.y + borderbox.height);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_UTF8
|
||||
/** Checks cells left and right to the box for broken double-width chars.
|
||||
* Replace it with UCS_ORPHAN_CELL.
|
||||
@ -497,37 +351,12 @@ draw_char(struct terminal *term, int x, int y,
|
||||
|
||||
screen_char->data = data;
|
||||
screen_char->attr = attr;
|
||||
screen_char->is_node = 0;
|
||||
set_term_color(screen_char, color, 0,
|
||||
get_opt_int_tree(term->spec, "colors", NULL));
|
||||
|
||||
set_screen_dirty(term->screen, y, y);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_UTF8
|
||||
void
|
||||
draw_char_node(struct terminal *term, int x, int y,
|
||||
unicode_val_T data, int attr,
|
||||
unsigned int node_number)
|
||||
#else
|
||||
void
|
||||
draw_char_node(struct terminal *term, int x, int y,
|
||||
unsigned char data, int attr,
|
||||
unsigned int node_number)
|
||||
#endif /* CONFIG_UTF8 */
|
||||
{
|
||||
struct screen_char *screen_char = get_char(term, x, y);
|
||||
|
||||
if (!screen_char) return;
|
||||
|
||||
screen_char->data = data;
|
||||
screen_char->attr = attr;
|
||||
screen_char->is_node = 1;
|
||||
screen_char->c.node_number = node_number;
|
||||
set_screen_dirty(term->screen, y, y);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
draw_box(struct terminal *term, struct el_box *box,
|
||||
unsigned char data, int attr,
|
||||
@ -549,7 +378,6 @@ draw_box(struct terminal *term, struct el_box *box,
|
||||
end->attr = attr;
|
||||
end->data = data;
|
||||
if (color) {
|
||||
end->is_node = 0;
|
||||
set_term_color(end, color, 0,
|
||||
get_opt_int_tree(term->spec, "colors", NULL));
|
||||
} else {
|
||||
@ -572,57 +400,6 @@ draw_box(struct terminal *term, struct el_box *box,
|
||||
set_screen_dirty(term->screen, box->y, box->y + box->height);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_UTF8
|
||||
void
|
||||
draw_box_node(struct terminal *term, struct el_box *box,
|
||||
unicode_val_T data, int attr,
|
||||
unsigned int node_number)
|
||||
#else
|
||||
void
|
||||
draw_box_node(struct terminal *term, struct el_box *box,
|
||||
unsigned char data, int attr,
|
||||
unsigned int node_number)
|
||||
#endif
|
||||
{
|
||||
struct screen_char *line, *pos, *end;
|
||||
int width, height;
|
||||
|
||||
line = get_char(term, box->x, box->y);
|
||||
if (!line) return;
|
||||
|
||||
height = int_min(box->height, term->height - box->y);
|
||||
width = int_min(box->width, term->width - box->x);
|
||||
|
||||
if (height <= 0 || width <= 0) return;
|
||||
|
||||
/* Compose off the ending screen position in the areas first line. */
|
||||
end = &line[width - 1];
|
||||
end->attr = attr;
|
||||
end->data = data;
|
||||
if (node_number) {
|
||||
end->is_node = 1;
|
||||
end->c.node_number = node_number;
|
||||
} else {
|
||||
clear_screen_char_color(end);
|
||||
}
|
||||
|
||||
/* Draw the first area line. */
|
||||
for (pos = line; pos < end; pos++) {
|
||||
copy_screen_chars(pos, end, 1);
|
||||
}
|
||||
|
||||
/* Now make @end point to the last line */
|
||||
/* For the rest of the area use the first area line. */
|
||||
pos = line;
|
||||
while (--height) {
|
||||
pos += term->width;
|
||||
copy_screen_chars(pos, line, width);
|
||||
}
|
||||
|
||||
set_screen_dirty(term->screen, box->y, box->y + box->height);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
draw_shadow(struct terminal *term, struct el_box *box,
|
||||
struct color_pair *color, int width, int height)
|
||||
@ -642,26 +419,6 @@ draw_shadow(struct terminal *term, struct el_box *box,
|
||||
draw_box(term, &dbox, ' ', 0, color);
|
||||
}
|
||||
|
||||
void
|
||||
draw_shadow_node(struct terminal *term, struct el_box *box,
|
||||
unsigned int node_number, int width, int height)
|
||||
{
|
||||
struct el_box dbox;
|
||||
|
||||
/* (horizontal) */
|
||||
set_box(&dbox, box->x + width, box->y + box->height,
|
||||
box->width - width, height);
|
||||
|
||||
draw_box_node(term, &dbox, ' ', 0, node_number);
|
||||
|
||||
/* (vertical) */
|
||||
set_box(&dbox, box->x + box->width, box->y + height,
|
||||
width, box->height);
|
||||
|
||||
draw_box_node(term, &dbox, ' ', 0, node_number);
|
||||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_UTF8
|
||||
static void
|
||||
draw_text_utf8(struct terminal *term, int x, int y,
|
||||
@ -735,79 +492,6 @@ draw_text_utf8(struct terminal *term, int x, int y,
|
||||
set_screen_dirty(term->screen, y, y);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
draw_text_utf8_node(struct terminal *term, int x, int y,
|
||||
const char *text2, int length,
|
||||
int attr, unsigned int node_number)
|
||||
{
|
||||
struct screen_char *start, *pos;
|
||||
char *text = (char *)text2;
|
||||
char *end = text + length;
|
||||
unicode_val_T data;
|
||||
|
||||
assert(text && length >= 0);
|
||||
if_assert_failed return;
|
||||
|
||||
if (length <= 0) return;
|
||||
if (x >= term->width) return;
|
||||
|
||||
data = utf8_to_unicode(&text, end);
|
||||
if (data == UCS_NO_CHAR) return;
|
||||
start = get_char(term, x, y);
|
||||
if (node_number) {
|
||||
start->attr = attr;
|
||||
start->is_node = 1;
|
||||
start->c.node_number = node_number;
|
||||
}
|
||||
|
||||
if (start->data == UCS_NO_CHAR && x - 1 > 0)
|
||||
draw_char_data(term, x - 1, y, UCS_ORPHAN_CELL);
|
||||
|
||||
pos = start;
|
||||
|
||||
if (unicode_to_cell(data) == 2) {
|
||||
/* Is there enough room for whole double-width char? */
|
||||
if (x + 1 < term->width) {
|
||||
pos->data = data;
|
||||
pos++;
|
||||
x++;
|
||||
|
||||
pos->data = UCS_NO_CHAR;
|
||||
pos->attr = 0;
|
||||
} else {
|
||||
pos->data = UCS_ORPHAN_CELL;
|
||||
}
|
||||
} else {
|
||||
pos->data = data;
|
||||
}
|
||||
pos++;
|
||||
x++;
|
||||
|
||||
for (; x < term->width; x++, pos++) {
|
||||
data = utf8_to_unicode(&text, end);
|
||||
if (data == UCS_NO_CHAR) break;
|
||||
if (node_number) copy_screen_chars(pos, start, 1);
|
||||
|
||||
if (unicode_to_cell(data) == 2) {
|
||||
/* Is there enough room for whole double-width char? */
|
||||
if (x + 1 < term->width) {
|
||||
pos->data = data;
|
||||
|
||||
x++;
|
||||
pos++;
|
||||
pos->data = UCS_NO_CHAR;
|
||||
pos->attr = 0;
|
||||
} else {
|
||||
pos->data = UCS_ORPHAN_CELL;
|
||||
}
|
||||
} else {
|
||||
pos->data = data;
|
||||
}
|
||||
}
|
||||
set_screen_dirty(term->screen, y, y);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_UTF8 */
|
||||
|
||||
void
|
||||
@ -876,73 +560,6 @@ draw_text(struct terminal *term, int x, int y,
|
||||
set_screen_dirty(term->screen, y, y);
|
||||
}
|
||||
|
||||
void
|
||||
draw_text_node(struct terminal *term, int x, int y,
|
||||
const char *text, int length,
|
||||
int attr, unsigned int node_number)
|
||||
{
|
||||
int end_pos;
|
||||
struct screen_char *pos, *end;
|
||||
|
||||
assert(text && length >= 0);
|
||||
if_assert_failed return;
|
||||
|
||||
if (x >= term->width || y >= term->height) return;
|
||||
|
||||
#ifdef CONFIG_UTF8
|
||||
if (term->utf8_cp) {
|
||||
draw_text_utf8_node(term, x, y, text, length, attr, node_number);
|
||||
return;
|
||||
}
|
||||
#endif /* CONFIG_UTF8 */
|
||||
|
||||
if (length <= 0) return;
|
||||
pos = get_char(term, x, y);
|
||||
if (!pos) return;
|
||||
|
||||
end_pos = int_min(length, term->width - x) - 1;
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
/* Detect attempt to set @end to a point outside @text,
|
||||
* it may occur in case of bad calculations. --Zas */
|
||||
if (end_pos < 0) {
|
||||
INTERNAL("end_pos < 0 !!");
|
||||
end_pos = 0;
|
||||
} else {
|
||||
int textlen = strlen(text);
|
||||
|
||||
if (end_pos >= textlen) {
|
||||
INTERNAL("end_pos (%d) >= text length (%d) !!", end_pos, textlen);
|
||||
end_pos = textlen - 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
end = &pos[int_max(0, end_pos)];
|
||||
|
||||
if (node_number) {
|
||||
/* Use the last char as template. */
|
||||
end->attr = attr;
|
||||
end->is_node = 1;
|
||||
end->c.node_number = node_number;
|
||||
|
||||
for (; pos < end && *text; text++, pos++) {
|
||||
end->data = *text;
|
||||
copy_screen_chars(pos, end, 1);
|
||||
}
|
||||
|
||||
end->data = *text;
|
||||
|
||||
} else {
|
||||
for (; pos <= end && *text; text++, pos++) {
|
||||
pos->data = *text;
|
||||
}
|
||||
}
|
||||
|
||||
set_screen_dirty(term->screen, y, y);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
draw_dlg_text(struct dialog_data *dlg_data, int x, int y,
|
||||
const char *text, int length,
|
||||
@ -960,23 +577,6 @@ draw_dlg_text(struct dialog_data *dlg_data, int x, int y,
|
||||
draw_text(term, x, y, text, length, attr, color);
|
||||
}
|
||||
|
||||
void
|
||||
draw_dlg_text_node(struct dialog_data *dlg_data, int x, int y,
|
||||
const char *text, int length,
|
||||
int attr, unsigned int node_number)
|
||||
{
|
||||
struct terminal *term = dlg_data->win->term;
|
||||
struct el_box *box = &dlg_data->real_box;
|
||||
|
||||
if (box->height) {
|
||||
int y_max = box->y + box->height;
|
||||
|
||||
y -= dlg_data->y;
|
||||
if (y < box->y || y >= y_max) return;
|
||||
}
|
||||
draw_text_node(term, x, y, text, length, attr, node_number);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
set_cursor(struct terminal *term, int x, int y, int blockable)
|
||||
@ -1021,13 +621,8 @@ void
|
||||
clear_terminal(struct terminal *term)
|
||||
{
|
||||
struct el_box box;
|
||||
int bgchar = get_opt_int("ui.background_char", NULL);
|
||||
|
||||
set_box(&box, 0, 0, term->width, term->height);
|
||||
#ifdef CONFIG_UTF8
|
||||
draw_box_node(term, &box, bgchar, 0, get_bfu_color_node(term, "desktop"));
|
||||
#else
|
||||
draw_box_node(term, &box, (unsigned char)bgchar, 0, get_bfu_color_node(term, "desktop"));
|
||||
#endif
|
||||
draw_box(term, &box, ' ', 0, NULL);
|
||||
set_cursor(term, 0, 0, 1);
|
||||
}
|
||||
|
@ -59,8 +59,6 @@ struct screen_char {
|
||||
/** Attributes are ::screen_char_attr bits. */
|
||||
unsigned char attr;
|
||||
|
||||
unsigned int is_node:1;
|
||||
|
||||
union {
|
||||
/** The fore- and background color. */
|
||||
unsigned char color[SCREEN_COLOR_SIZE];
|
||||
@ -245,8 +243,6 @@ struct screen_char *get_char(struct terminal *, int x, int y);
|
||||
void draw_char_color(struct terminal *term, int x, int y,
|
||||
struct color_pair *color);
|
||||
|
||||
void draw_char_color_node(struct terminal *term, int x, int y, unsigned int node_number);
|
||||
|
||||
/** Sets the data of a screen position. */
|
||||
#ifdef CONFIG_UTF8
|
||||
void draw_char_data(struct terminal *term, int x, int y, unicode_val_T data);
|
||||
@ -258,69 +254,35 @@ void draw_char_data(struct terminal *term, int x, int y, unsigned char data);
|
||||
void draw_border_char(struct terminal *term, int x, int y,
|
||||
border_char_T border, struct color_pair *color);
|
||||
|
||||
void draw_border_char_node(struct terminal *term, int x, int y,
|
||||
border_char_T border, unsigned int node_number);
|
||||
|
||||
/** Sets the cross position of two borders. */
|
||||
void draw_border_cross(struct terminal *, int x, int y,
|
||||
enum border_cross_direction, struct color_pair *color);
|
||||
|
||||
void draw_border_cross_node(struct terminal *, int x, int y,
|
||||
enum border_cross_direction, unsigned int node_number);
|
||||
|
||||
/** Draws a char. */
|
||||
#ifdef CONFIG_UTF8
|
||||
void draw_char(struct terminal *term, int x, int y,
|
||||
unicode_val_T data, int attr,
|
||||
struct color_pair *color);
|
||||
|
||||
void draw_char_node(struct terminal *term, int x, int y,
|
||||
unicode_val_T data, int attr,
|
||||
unsigned int node_number);
|
||||
#else
|
||||
void draw_char(struct terminal *term, int x, int y,
|
||||
unsigned char data, int attr,
|
||||
struct color_pair *color);
|
||||
|
||||
void draw_char_node(struct terminal *term, int x, int y,
|
||||
unsigned char data, int attr,
|
||||
unsigned int node_number);
|
||||
|
||||
#endif /* CONFIG_UTF8 */
|
||||
|
||||
void draw_space(struct terminal *term, int x, int y,
|
||||
struct screen_char *color);
|
||||
|
||||
/** Draws area defined by @a box using the same colors and attributes. */
|
||||
void draw_box(struct terminal *term, struct el_box *box,
|
||||
unsigned char data, int attr,
|
||||
struct color_pair *color);
|
||||
|
||||
#ifdef CONFIG_UTF8
|
||||
void draw_box_node(struct terminal *term, struct el_box *box,
|
||||
unicode_val_T data, int attr,
|
||||
unsigned int node_number);
|
||||
#else
|
||||
void draw_box_node(struct terminal *term, struct el_box *box,
|
||||
unsigned char data, int attr,
|
||||
unsigned int node_number);
|
||||
#endif
|
||||
|
||||
/** Draws a shadow of @a width and @a height with color @a color
|
||||
* around @a box. */
|
||||
void draw_shadow(struct terminal *term, struct el_box *box,
|
||||
struct color_pair *color, int width, int height);
|
||||
|
||||
void draw_shadow_node(struct terminal *term, struct el_box *box,
|
||||
unsigned int node_number, int width, int height);
|
||||
|
||||
/** Draw borders. */
|
||||
void draw_border(struct terminal *term, struct el_box *box,
|
||||
struct color_pair *color, int width);
|
||||
|
||||
void draw_border_node(struct terminal *term, struct el_box *box,
|
||||
unsigned int node_number, int width);
|
||||
|
||||
#ifdef CONFIG_UTF8
|
||||
void fix_dwchar_around_box(struct terminal *term, struct el_box *box, int border,
|
||||
int shadow_width, int shadow_height);
|
||||
@ -332,20 +294,11 @@ void draw_text(struct terminal *term, int x, int y,
|
||||
int attr,
|
||||
struct color_pair *color);
|
||||
|
||||
void draw_text_node(struct terminal *term, int x, int y,
|
||||
const char *text, int length,
|
||||
int attr,
|
||||
unsigned int node_number);
|
||||
|
||||
/** Draws text for dialogs. */
|
||||
void draw_dlg_text(struct dialog_data *dlg_data, int x, int y,
|
||||
const char *text, int length,
|
||||
int attr, struct color_pair *color);
|
||||
|
||||
void draw_dlg_text_node(struct dialog_data *dlg_data, int x, int y,
|
||||
const char *text, int length,
|
||||
int attr, unsigned int node_number);
|
||||
|
||||
|
||||
/** Draws @a length chars from @a line on the screen. */
|
||||
void draw_line(struct terminal *term, int x, int y, int length,
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include "elinks.h"
|
||||
|
||||
#include "bfu/style.h"
|
||||
#include "config/options.h"
|
||||
#include "intl/charsets.h"
|
||||
#include "main/module.h"
|
||||
@ -443,21 +442,6 @@ static const struct screen_driver_opt *const screen_driver_opts[] = {
|
||||
|
||||
static INIT_LIST_OF(struct screen_driver, active_screen_drivers);
|
||||
|
||||
static struct screen_char *get_mono_from_node(struct screen_char *ch);
|
||||
static struct screen_char *get_color16_from_node(struct screen_char *ch);
|
||||
|
||||
#ifdef CONFIG_88_COLORS
|
||||
static struct screen_char *get_color88_from_node(struct screen_char *ch);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_256_COLORS
|
||||
static struct screen_char *get_color256_from_node(struct screen_char *ch);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TRUE_COLOR
|
||||
static struct screen_char *get_true_color_from_node(struct screen_char *ch);
|
||||
#endif
|
||||
|
||||
/** Set screen_driver.opt according to screen_driver.type and @a term_spec.
|
||||
* Other members of @a *driver need not have been initialized.
|
||||
*
|
||||
@ -748,9 +732,9 @@ compare_fg_color_true(unsigned char *a, unsigned char *b)
|
||||
}
|
||||
|
||||
static inline void
|
||||
copy_color_true(unsigned char *dest, unsigned char *src)
|
||||
copy_color_true(unsigned char *a, unsigned char *b)
|
||||
{
|
||||
memcpy(dest, src, 6);
|
||||
memcpy(a, b, 6);
|
||||
}
|
||||
|
||||
static inline int
|
||||
@ -884,52 +868,11 @@ add_char_data(struct string *screen, struct screen_driver *driver,
|
||||
}
|
||||
}
|
||||
|
||||
static struct screen_char *
|
||||
get_mono_from_node(struct screen_char *ch)
|
||||
{
|
||||
unsigned int node_number = ch->c.node_number;
|
||||
|
||||
if (node_number < 1024) {
|
||||
return get_bfu_mono_node(node_number);
|
||||
}
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
static struct screen_char *
|
||||
get_color16_from_node(struct screen_char *ch)
|
||||
{
|
||||
unsigned int node_number = ch->c.node_number;
|
||||
|
||||
if (node_number < 1024) {
|
||||
return get_bfu_color16_node(node_number);
|
||||
}
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
/** Time critical section. */
|
||||
static inline void
|
||||
add_char16(struct string *screen, struct screen_driver *driver,
|
||||
struct screen_char *ch, struct screen_state *state)
|
||||
{
|
||||
struct screen_char copy;
|
||||
|
||||
if (ch->is_node) {
|
||||
copy_struct(©, ch);
|
||||
copy.is_node = 0;
|
||||
if (driver->opt.color_mode == COLOR_MODE_MONO) {
|
||||
struct screen_char *ch2 = get_mono_from_node(ch);
|
||||
|
||||
copy.attr |= ch2->attr;
|
||||
copy.c.color[0] = ch2->c.color[0];
|
||||
} else {
|
||||
struct screen_char *ch2 = get_color16_from_node(ch);
|
||||
copy.c.color[0] = ch2->c.color[0];
|
||||
}
|
||||
ch = ©
|
||||
}
|
||||
|
||||
unsigned char border = (ch->attr & SCREEN_ATTR_FRAME);
|
||||
unsigned char italic = (ch->attr & SCREEN_ATTR_ITALIC);
|
||||
unsigned char underline = (ch->attr & SCREEN_ATTR_UNDERLINE);
|
||||
@ -1121,35 +1064,6 @@ add_char_color(struct string *screen, const struct string *seq, unsigned char co
|
||||
add_bytes_to_string(screen, &seq->source[seq_pos], seq->length - seq_pos);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_256_COLORS
|
||||
static struct screen_char *
|
||||
get_color256_from_node(struct screen_char *ch)
|
||||
{
|
||||
unsigned int node_number = ch->c.node_number;
|
||||
|
||||
if (node_number < 1024) {
|
||||
return get_bfu_color256_node(node_number);
|
||||
}
|
||||
|
||||
return ch;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_88_COLORS
|
||||
static struct screen_char *
|
||||
get_color88_from_node(struct screen_char *ch)
|
||||
{
|
||||
unsigned int node_number = ch->c.node_number;
|
||||
|
||||
if (node_number < 1024) {
|
||||
return get_bfu_color88_node(node_number);
|
||||
}
|
||||
|
||||
return ch;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#define add_background_color(str, seq, chr) add_char_color(str, &(seq)[1], (chr)->c.color[1])
|
||||
#define add_foreground_color(str, seq, chr) add_char_color(str, &(seq)[0], (chr)->c.color[0])
|
||||
|
||||
@ -1158,30 +1072,6 @@ static inline void
|
||||
add_char256(struct string *screen, struct screen_driver *driver,
|
||||
struct screen_char *ch, struct screen_state *state)
|
||||
{
|
||||
struct screen_char copy;
|
||||
|
||||
if (ch->is_node) {
|
||||
struct screen_char *ch2 = NULL;
|
||||
copy_struct(©, ch);
|
||||
copy.is_node = 0;
|
||||
|
||||
#ifdef CONFIG_88_COLORS
|
||||
if (driver->opt.color_mode == COLOR_MODE_88) {
|
||||
ch2 = get_color88_from_node(ch);
|
||||
} else
|
||||
#endif
|
||||
#ifdef CONFIG_256_COLORS
|
||||
{
|
||||
ch2 = get_color256_from_node(ch);
|
||||
}
|
||||
#endif
|
||||
if (ch2) {
|
||||
copy.c.color[0] = ch2->c.color[0];
|
||||
copy.c.color[1] = ch2->c.color[1];
|
||||
}
|
||||
ch = ©
|
||||
}
|
||||
|
||||
unsigned char attr_delta = (ch->attr ^ state->attr);
|
||||
|
||||
if (
|
||||
@ -1292,25 +1182,8 @@ static const struct string color_true_seqs[] = {
|
||||
/* foreground: */ TERM_STRING("\033[0;38;2"),
|
||||
/* background: */ TERM_STRING("\033[48;2"),
|
||||
};
|
||||
|
||||
static struct screen_char *
|
||||
get_true_color_from_node(struct screen_char *ch)
|
||||
{
|
||||
unsigned int node_number = ch->c.node_number;
|
||||
|
||||
if (node_number < 1024) {
|
||||
return get_bfu_true_color_node(node_number);
|
||||
}
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
|
||||
static inline void add_char_true_color(struct string *screen, const struct string *seq, unsigned char *colors);
|
||||
|
||||
#define add_true_background_color(str, seq, chr) add_char_true_color(str, &(seq)[1], &(chr)->c.color[3])
|
||||
#define add_true_foreground_color(str, seq, chr) add_char_true_color(str, &(seq)[0], &(chr)->c.color[0])
|
||||
|
||||
static inline void
|
||||
add_char_true_color(struct string *screen, const struct string *seq, unsigned char *colors)
|
||||
{
|
||||
@ -1363,17 +1236,6 @@ static inline void
|
||||
add_char_true(struct string *screen, struct screen_driver *driver,
|
||||
struct screen_char *ch, struct screen_state *state)
|
||||
{
|
||||
struct screen_char copy;
|
||||
|
||||
if (ch->is_node) {
|
||||
struct screen_char *ch2 = get_true_color_from_node(ch);
|
||||
|
||||
copy_struct(©, ch);
|
||||
copy.is_node = 0;
|
||||
copy_color_true(copy.c.color, ch2->c.color);
|
||||
ch = ©
|
||||
}
|
||||
|
||||
unsigned char attr_delta = (ch->attr ^ state->attr);
|
||||
|
||||
if (
|
||||
@ -1478,6 +1340,11 @@ add_char_true(struct string *screen, struct screen_driver *driver,
|
||||
&& pos->attr == current->attr) \
|
||||
continue; \
|
||||
\
|
||||
/* Else if the color match and the data is
|
||||
* ``space''. */ \
|
||||
if (pos->data <= ' ' && current->data <= ' ' \
|
||||
&& pos->attr == current->attr) \
|
||||
continue; \
|
||||
} \
|
||||
dirty = 1; \
|
||||
break; \
|
||||
|
@ -210,7 +210,7 @@ static void
|
||||
draw_clipboard(struct terminal *term, struct document_view *doc_view)
|
||||
{
|
||||
struct document *document = doc_view->document;
|
||||
unsigned int color_node;
|
||||
struct color_pair *color;
|
||||
int starty, startx, endy, endx, x, y, xoffset, yoffset;
|
||||
|
||||
assert(term && doc_view);
|
||||
@ -220,7 +220,7 @@ draw_clipboard(struct terminal *term, struct document_view *doc_view)
|
||||
return;
|
||||
}
|
||||
|
||||
color_node = get_bfu_color_node(term, "clipboard");
|
||||
color = get_bfu_color(term, "clipboard");
|
||||
xoffset = doc_view->box.x - doc_view->vs->x;
|
||||
yoffset = doc_view->box.y - doc_view->vs->y;
|
||||
|
||||
@ -247,7 +247,7 @@ draw_clipboard(struct terminal *term, struct document_view *doc_view)
|
||||
|
||||
for (y = starty; y <= endy; ++y) {
|
||||
for (x = startx; x <= endx; ++x) {
|
||||
draw_char_color_node(term, x, y, color_node);
|
||||
draw_char_color(term, x, y, color);
|
||||
}
|
||||
}
|
||||
doc_view->last_x = doc_view->last_y = -1;
|
||||
@ -293,8 +293,6 @@ draw_doc(struct session *ses, struct document_view *doc_view, int active)
|
||||
struct view_state *vs;
|
||||
struct terminal *term;
|
||||
struct el_box *box;
|
||||
struct screen_char *last = NULL;
|
||||
|
||||
int vx, vy;
|
||||
int y;
|
||||
|
||||
@ -326,22 +324,12 @@ draw_doc(struct session *ses, struct document_view *doc_view, int active)
|
||||
|
||||
vs = doc_view->vs;
|
||||
if (!vs) {
|
||||
int bgchar = get_opt_int("ui.background_char", ses);
|
||||
#ifdef CONFIG_UTF8
|
||||
draw_box_node(term, box, bgchar, 0, get_bfu_color_node(term, "desktop"));
|
||||
#else
|
||||
draw_box_node(term, box, (unsigned char)bgchar, 0, get_bfu_color_node(term, "desktop"));
|
||||
#endif
|
||||
draw_box(term, box, ' ', 0, &color);
|
||||
return;
|
||||
}
|
||||
|
||||
if (document_has_frames(doc_view->document)) {
|
||||
int bgchar = get_opt_int("ui.background_char", ses);
|
||||
#ifdef CONFIG_UTF8
|
||||
draw_box_node(term, box, bgchar, 0, get_bfu_color_node(term, "desktop"));
|
||||
#else
|
||||
draw_box_node(term, box, (unsigned char)bgchar, 0, get_bfu_color_node(term, "desktop"));
|
||||
#endif
|
||||
draw_box(term, box, ' ', 0, &color);
|
||||
draw_frame_lines(term, doc_view->document->frame_desc, box->x, box->y, &color);
|
||||
if (vs->current_link == -1)
|
||||
vs->current_link = 0;
|
||||
@ -392,12 +380,7 @@ draw_doc(struct session *ses, struct document_view *doc_view, int active)
|
||||
}
|
||||
doc_view->last_x = vx;
|
||||
doc_view->last_y = vy;
|
||||
int bgchar = get_opt_int("ui.background_char", ses);
|
||||
#ifdef CONFIG_UTF8
|
||||
draw_box_node(term, box, bgchar, 0, get_bfu_color_node(term, "desktop"));
|
||||
#else
|
||||
draw_box_node(term, box, (unsigned char)bgchar, 0, get_bfu_color_node(term, "desktop"));
|
||||
#endif
|
||||
draw_box(term, box, ' ', 0, &color);
|
||||
if (!doc_view->document->height) return;
|
||||
|
||||
while (vs->y >= doc_view->document->height) vs->y -= box->height;
|
||||
@ -410,43 +393,13 @@ draw_doc(struct session *ses, struct document_view *doc_view, int active)
|
||||
for (y = int_max(vy, 0);
|
||||
y < int_min(doc_view->document->height, box->height + vy);
|
||||
y++) {
|
||||
struct screen_char *first = NULL;
|
||||
int i, j;
|
||||
int last_index = 0;
|
||||
int st = int_max(vx, 0);
|
||||
int en = int_min(doc_view->document->data[y].length,
|
||||
box->width + vx);
|
||||
int max = int_min(en, st + 200);
|
||||
|
||||
if (en - st > 0) {
|
||||
draw_line(term, box->x + st - vx, box->y + y - vy,
|
||||
en - st,
|
||||
&doc_view->document->data[y].chars[st]);
|
||||
|
||||
for (i = en - 1; i >= 0; --i) {
|
||||
if (doc_view->document->data[y].chars[i].data != ' ') {
|
||||
last = &doc_view->document->data[y].chars[i];
|
||||
last_index = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (i = st; i < max; i++) {
|
||||
if (doc_view->document->data[y].chars[i].data != ' ') {
|
||||
first = &doc_view->document->data[y].chars[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (j = st; j < i; j++) {
|
||||
draw_space(term, box->x + j - vx, box->y + y - vy,
|
||||
first);
|
||||
}
|
||||
|
||||
for (i = last_index; i < box->width + vx; i++) {
|
||||
draw_space(term, box->x + i - vx, box->y + y - vy,
|
||||
last);
|
||||
}
|
||||
if (en - st <= 0) continue;
|
||||
draw_line(term, box->x + st - vx, box->y + y - vy, en - st,
|
||||
&doc_view->document->data[y].chars[st]);
|
||||
}
|
||||
draw_view_status(ses, doc_view, active);
|
||||
if (has_search_word(doc_view))
|
||||
@ -528,16 +481,11 @@ draw_formatted(struct session *ses, int rerender)
|
||||
if (!ses->doc_view || !ses->doc_view->document) {
|
||||
/*INTERNAL("document not formatted");*/
|
||||
struct el_box box;
|
||||
int bgchar = get_opt_int("ui.background_char", ses);
|
||||
|
||||
set_box(&box, 0, 1,
|
||||
ses->tab->term->width,
|
||||
ses->tab->term->height - 2);
|
||||
#ifdef CONFIG_UTF8
|
||||
draw_box_node(ses->tab->term, &box, bgchar, 0, get_bfu_color_node(ses->tab->term, "desktop"));
|
||||
#else
|
||||
draw_box_node(ses->tab->term, &box, (unsigned char)bgchar, 0, get_bfu_color_node(ses->tab->term, "desktop"));
|
||||
#endif
|
||||
draw_box(ses->tab->term, &box, ' ', 0, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -337,7 +337,7 @@ highlight_links_with_prefixes_that_start_with_n(struct terminal *term,
|
||||
struct document_view *doc_view,
|
||||
int n)
|
||||
{
|
||||
unsigned int node_number = get_bfu_color_node(term, "searched");
|
||||
struct color_pair *color = get_bfu_color(term, "searched");
|
||||
int xoffset = doc_view->box.x - doc_view->vs->x;
|
||||
int yoffset = doc_view->box.y - doc_view->vs->y;
|
||||
struct document *document = doc_view->document;
|
||||
@ -357,7 +357,7 @@ highlight_links_with_prefixes_that_start_with_n(struct terminal *term,
|
||||
int y = link->points[i].y + yoffset;
|
||||
|
||||
if (is_in_box(&doc_view->box, x, y)) {
|
||||
draw_char_color_node(term, x, y, node_number);
|
||||
draw_char_color(term, x, y, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -903,7 +903,7 @@ draw_searched(struct terminal *term, struct document_view *doc_view)
|
||||
get_searched(doc_view, &pt, &len, utf8);
|
||||
if (len) {
|
||||
int i;
|
||||
unsigned int node_number = get_bfu_color_node(term, "searched");
|
||||
struct color_pair *color = get_bfu_color(term, "searched");
|
||||
int xoffset = doc_view->box.x - doc_view->vs->x;
|
||||
int yoffset = doc_view->box.y - doc_view->vs->y;
|
||||
|
||||
@ -920,7 +920,7 @@ draw_searched(struct terminal *term, struct document_view *doc_view)
|
||||
co = ((co >> 3) & 0x0700) | ((co << 3) & 0x3800);
|
||||
#endif
|
||||
|
||||
draw_char_color_node(term, x, y, node_number);
|
||||
draw_char_color(term, x, y, color);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1543,8 +1543,7 @@ static void
|
||||
draw_typeahead_match(struct terminal *term, struct document_view *doc_view,
|
||||
int chars, int offset)
|
||||
{
|
||||
unsigned int node_number = get_bfu_color_node(term, "searched");
|
||||
|
||||
struct color_pair *color = get_bfu_color(term, "searched");
|
||||
int xoffset = doc_view->box.x - doc_view->vs->x;
|
||||
int yoffset = doc_view->box.y - doc_view->vs->y;
|
||||
struct link *link = get_current_link(doc_view);
|
||||
@ -1569,7 +1568,7 @@ draw_typeahead_match(struct terminal *term, struct document_view *doc_view,
|
||||
} else if (i >= offset) {
|
||||
/* TODO: We should take in account original colors and
|
||||
* combine them with defined color. */
|
||||
draw_char_color_node(term, xoffset + x, yoffset + y, node_number);
|
||||
draw_char_color(term, xoffset + x, yoffset + y, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user