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

Merge branch 'top/0.13/witekfl-scroll-dialog' (early part) into elinks-0.13

Conflicts:
	NEWS
This commit is contained in:
Kalle Olavi Niemitalo 2008-10-15 23:31:17 +03:00 committed by Kalle Olavi Niemitalo
commit 6c0fffb958
23 changed files with 245 additions and 109 deletions

2
NEWS
View File

@ -56,6 +56,8 @@ Miscellaneous:
been allocated for documents in the Resources dialog.
* Fedora enhancement 346861: Add support for nss_compat_ossl library
(OpenSSL replacement).
* enhancement: Scrolling the entire contents of dialog boxes.
Especially useful for multi-file BitTorrent downloads.
//////////////////////////////////////////////////////////////////////
The following changes should be removed from NEWS before ELinks 0.13.0

View File

@ -115,10 +115,11 @@ buttons_width(struct widget_data *widget_data, int n,
}
void
dlg_format_buttons(struct terminal *term,
dlg_format_buttons(struct dialog_data *dlg_data,
struct widget_data *widget_data, int n,
int x, int *y, int w, int *rw, enum format_align align, int format_only)
{
struct terminal *term = dlg_data->win->term;
int i1 = 0;
while (i1 < n) {
@ -212,7 +213,7 @@ display_button(struct dialog_data *dlg_data, struct widget_data *widget_data)
}
draw_text(term, pos->x, pos->y, BUTTON_LEFT, BUTTON_LEFT_LEN, 0, color);
draw_dlg_text(dlg_data, pos->x, pos->y, BUTTON_LEFT, BUTTON_LEFT_LEN, 0, color);
if (len > 0) {
unsigned char *text = widget_data->widget->text;
int hk_pos = widget_data->widget->info.button.hotkey_pos;
@ -237,15 +238,15 @@ display_button(struct dialog_data *dlg_data, struct widget_data *widget_data)
NULL);
if (hk_pos)
draw_text(term, x, pos->y,
draw_dlg_text(dlg_data, x, pos->y,
text, hk_pos, 0, color);
draw_text(term, x + cells_to_hk, pos->y,
draw_dlg_text(dlg_data, x + cells_to_hk, pos->y,
&text[hk_pos + 1], hk_bytes,
attr, shortcut_color);
if (right > 1)
draw_text(term, 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);
@ -258,11 +259,11 @@ display_button(struct dialog_data *dlg_data, struct widget_data *widget_data)
len - hk_width,
NULL);
draw_text(term, x, pos->y,
draw_dlg_text(dlg_data, x, pos->y,
text, hk_len,
attr, shortcut_color);
draw_text(term, x + hk_width, pos->y,
draw_dlg_text(dlg_data, x + hk_width, pos->y,
&text[hk_len], len_to_display,
0, color);
}
@ -272,18 +273,18 @@ display_button(struct dialog_data *dlg_data, struct widget_data *widget_data)
int right = widget_data->widget->info.button.truetextlen - hk_pos - 1;
if (hk_pos) {
draw_text(term, x, pos->y, text, hk_pos, 0, color);
draw_dlg_text(dlg_data, x, pos->y, text, hk_pos, 0, color);
}
draw_text(term, x + hk_pos, pos->y,
draw_dlg_text(dlg_data, x + hk_pos, pos->y,
&text[hk_pos + 1], 1, attr, shortcut_color);
if (right > 1) {
draw_text(term, x + hk_pos + 1, pos->y,
draw_dlg_text(dlg_data, x + hk_pos + 1, pos->y,
&text[hk_pos + 2], right - 1, 0, color);
}
} else {
draw_text(term, x, pos->y, text, 1, attr, shortcut_color);
draw_text(term, x + 1, pos->y, &text[1], len - 1, 0, color);
draw_dlg_text(dlg_data, x, pos->y, text, 1, attr, shortcut_color);
draw_dlg_text(dlg_data, x + 1, pos->y, &text[1], len - 1, 0, color);
}
}
#ifdef CONFIG_UTF8
@ -291,15 +292,15 @@ 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_text(term, x + text_cells - hk, pos->y,
draw_dlg_text(dlg_data, x + text_cells - hk, pos->y,
BUTTON_RIGHT, BUTTON_RIGHT_LEN, 0, color);
} else
#endif /* CONFIG_UTF8 */
draw_text(term, x + len, pos->y, BUTTON_RIGHT,
draw_dlg_text(dlg_data, x + len, pos->y, BUTTON_RIGHT,
BUTTON_RIGHT_LEN, 0, color);
if (sel) {
set_cursor(term, x, pos->y, 1);
set_window_ptr(dlg_data->win, pos->x, pos->y);
set_dlg_cursor(term, dlg_data, x, pos->y, 1);
set_dlg_window_ptr(dlg_data, dlg_data->win, pos->x, pos->y);
}
return EVENT_PROCESSED;
}

View File

@ -5,6 +5,7 @@
#include "util/align.h"
struct dialog;
struct dialog_data;
struct terminal;
struct widget_data;
@ -48,6 +49,6 @@ void add_dlg_button_do(struct dialog *dlg, unsigned char *text, int flags, widge
#endif
extern const struct widget_ops button_ops;
void dlg_format_buttons(struct terminal *, struct widget_data *, int, int, int *, int, int *, enum format_align, int);
void dlg_format_buttons(struct dialog_data *, struct widget_data *, int, int, int *, int, int *, enum format_align, int);
#endif

View File

@ -36,11 +36,12 @@ add_dlg_radio_do(struct dialog *dlg, unsigned char *text,
}
void
dlg_format_checkbox(struct terminal *term,
dlg_format_checkbox(struct dialog_data *dlg_data,
struct widget_data *widget_data,
int x, int *y, int w, int *rw,
enum format_align align, int format_only)
{
struct terminal *term = dlg_data->win->term;
unsigned char *text = widget_data->widget->text;
set_box(&widget_data->box, x, *y, CHECKBOX_LEN, CHECKBOX_HEIGHT);
@ -49,7 +50,7 @@ dlg_format_checkbox(struct terminal *term,
if (text && *text) {
if (rw) *rw -= CHECKBOX_LS;
dlg_format_text_do(term, text, x + CHECKBOX_LS, y,
dlg_format_text_do(dlg_data, text, x + CHECKBOX_LS, y,
w - CHECKBOX_LS, rw,
get_bfu_color(term, "dialog.checkbox-label"),
align, format_only);
@ -78,11 +79,11 @@ display_checkbox(struct dialog_data *dlg_data, struct widget_data *widget_data)
else
text = widget_data->widget->info.checkbox.gid ? "( )" : "[ ]";
draw_text(term, pos->x, pos->y, text, CHECKBOX_LEN, 0, color);
draw_dlg_text(dlg_data, pos->x, pos->y, text, CHECKBOX_LEN, 0, color);
if (selected) {
set_cursor(term, pos->x + 1, pos->y, 1);
set_window_ptr(dlg_data->win, pos->x, pos->y);
set_dlg_cursor(term, dlg_data, pos->x + 1, pos->y, 1);
set_dlg_window_ptr(dlg_data, dlg_data->win, pos->x, pos->y);
}
return EVENT_PROCESSED;
@ -128,7 +129,6 @@ mouse_checkbox(struct dialog_data *dlg_data, struct widget_data *widget_data)
static widget_handler_status_T
select_checkbox(struct dialog_data *dlg_data, struct widget_data *widget_data)
{
if (!widget_data->widget->info.checkbox.gid) {
/* Checkbox. */
int *cdata = (int *) widget_data->cdata;
@ -159,8 +159,8 @@ select_checkbox(struct dialog_data *dlg_data, struct widget_data *widget_data)
}
widget_data->info.checkbox.checked = 1;
}
display_widget(dlg_data, widget_data);
return EVENT_PROCESSED;
}

View File

@ -2,6 +2,7 @@
#define EL__BFU_CHECKBOX_H
struct dialog;
struct dialog_data;
struct terminal;
struct widget_data;
@ -30,7 +31,7 @@ void add_dlg_radio_do(struct dialog *dlg, unsigned char *text, int groupid, int
extern const struct widget_ops checkbox_ops;
void
dlg_format_checkbox(struct terminal *term,
dlg_format_checkbox(struct dialog_data *dlg_data,
struct widget_data *widget_data,
int x, int *y, int w, int *rw,
enum format_align align, int format_only);

View File

@ -82,20 +82,18 @@ redraw_dialog(struct dialog_data *dlg_data, int layout)
}
if (!dlg_data->dlg->layout.only_widgets) {
struct box box;
set_box(&box,
set_box(&dlg_data->real_box,
dlg_data->box.x + (DIALOG_LEFT_BORDER + 1),
dlg_data->box.y + (DIALOG_TOP_BORDER + 1),
dlg_data->box.width - 2 * (DIALOG_LEFT_BORDER + 1),
dlg_data->box.height - 2 * (DIALOG_TOP_BORDER + 1));
draw_border(term, &box, get_bfu_color(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 = get_bfu_color(term, "dialog.title");
if (title_color && box.width > 2) {
if (title_color && dlg_data->real_box.width > 2) {
unsigned char *title = dlg_data->dlg->title;
int titlelen = strlen(title);
int titlecells = titlelen;
@ -107,7 +105,7 @@ redraw_dialog(struct dialog_data *dlg_data, int layout)
&title[titlelen]);
#endif /* CONFIG_UTF8 */
titlecells = int_min(box.width - 2, titlecells);
titlecells = int_min(dlg_data->real_box.width - 2, titlecells);
#ifdef CONFIG_UTF8
if (term->utf8_cp)
@ -115,20 +113,20 @@ redraw_dialog(struct dialog_data *dlg_data, int layout)
NULL);
#endif /* CONFIG_UTF8 */
x = (box.width - titlecells) / 2 + box.x;
y = box.y - 1;
x = (dlg_data->real_box.width - titlecells) / 2 + dlg_data->real_box.x;
y = dlg_data->real_box.y - 1;
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,
draw_dlg_text(dlg_data, x - 1, y, " ", 1, 0, title_color);
draw_dlg_text(dlg_data, x, y, title, titlelen, 0, title_color);
draw_dlg_text(dlg_data, x + titlecells, y, " ", 1, 0,
title_color);
}
}
update_all_widgets(dlg_data);
redraw_from_window(dlg_data->win);
redraw_windows(REDRAW_IN_FRONT_OF_WINDOW, dlg_data->win);
}
static void
@ -181,6 +179,23 @@ init_widget(struct dialog_data *dlg_data, int i)
return widget_data;
}
static int
check_range(struct dialog_data *dlg_data, struct widget_data *widget_data)
{
if (!dlg_data->dlg->layout.only_widgets) {
struct box *box = &widget_data->box;
struct box *dlgbox = &dlg_data->real_box;
int y = box->y - dlgbox->y;
if ((y < dlg_data->y) || (y >= dlg_data->y + dlgbox->height)) {
/* This calculates the offset of the window's top. */
dlg_data->y = (y / dlgbox->height) * dlgbox->height;
return 1;
}
}
return 0;
}
void
select_widget(struct dialog_data *dlg_data, struct widget_data *widget_data)
{
@ -190,6 +205,11 @@ select_widget(struct dialog_data *dlg_data, struct widget_data *widget_data)
dlg_data->selected_widget_id = widget_data - dlg_data->widgets_data;
if (check_range(dlg_data, widget_data)) {
redraw_windows(REDRAW_WINDOW_AND_FRONT, dlg_data->win);
return;
}
display_widget(dlg_data, previously_selected_widget);
display_widget(dlg_data, widget_data);
}
@ -228,9 +248,14 @@ cycle_widget_focus(struct dialog_data *dlg_data, int direction)
} while (!widget_is_focusable(selected_widget(dlg_data))
&& dlg_data->selected_widget_id != prev_selected);
if (check_range(dlg_data, selected_widget(dlg_data))) {
redraw_windows(REDRAW_WINDOW_AND_FRONT, dlg_data->win);
return;
}
display_widget(dlg_data, previously_selected_widget);
display_widget(dlg_data, selected_widget(dlg_data));
redraw_from_window(dlg_data->win);
redraw_windows(REDRAW_IN_FRONT_OF_WINDOW, dlg_data->win);
}
static void
@ -238,6 +263,7 @@ dialog_ev_init(struct dialog_data *dlg_data)
{
int i;
dlg_data->y = 0;
/* TODO: foreachback_widget() */
for (i = dlg_data->number_of_widgets - 1; i >= 0; i--) {
struct widget_data *widget_data;
@ -421,6 +447,7 @@ dialog_ev_abort(struct dialog_data *dlg_data)
}
freeml(dlg_data->ml);
dlg_data->y = 0;
}
/* TODO: use EVENT_PROCESSED/EVENT_NOT_PROCESSED. */
@ -554,17 +581,17 @@ format_widgets(struct terminal *term, struct dialog_data *dlg_data,
switch (wdata->widget->type) {
case WIDGET_FIELD_PASS:
case WIDGET_FIELD:
dlg_format_field(term, wdata, x, y, w, rw, ALIGN_LEFT,
dlg_format_field(dlg_data, wdata, x, y, w, rw, ALIGN_LEFT,
format_only);
break;
case WIDGET_LISTBOX:
dlg_format_listbox(term, wdata, x, y, w, h, rw,
dlg_format_listbox(dlg_data, wdata, x, y, w, h, rw,
ALIGN_LEFT, format_only);
break;
case WIDGET_TEXT:
dlg_format_text(term, wdata, x, y, w, rw, h,
dlg_format_text(dlg_data, wdata, x, y, w, rw, h,
format_only);
break;
@ -583,7 +610,7 @@ format_widgets(struct terminal *term, struct dialog_data *dlg_data,
break;
}
dlg_format_group(term, wdata, size, x, y, w, rw,
dlg_format_group(dlg_data, wdata, size, x, y, w, rw,
format_only);
wdata += size - 1;
@ -591,7 +618,7 @@ format_widgets(struct terminal *term, struct dialog_data *dlg_data,
/* No horizontal space between checkboxes belonging to
* the same group. */
dlg_format_checkbox(term, wdata, x, y, w, rw,
dlg_format_checkbox(dlg_data, wdata, x, y, w, rw,
ALIGN_LEFT, format_only);
if (widgets > 1
&& group == widget_has_group(&wdata[1]))
@ -603,7 +630,7 @@ format_widgets(struct terminal *term, struct dialog_data *dlg_data,
/* We assume that the buttons are all stuffed at the very end
* of the dialog. */
case WIDGET_BUTTON:
dlg_format_buttons(term, wdata, widgets,
dlg_format_buttons(dlg_data, wdata, widgets,
x, y, w, rw, ALIGN_CENTER, format_only);
return;
}

View File

@ -99,7 +99,25 @@ struct dialog_data {
struct dialog *dlg;
struct memory_list *ml;
/** Size and location of the dialog box, excluding the drop shadow.
* This includes the outer border and the frame.
* The coordinates are relative to the terminal. */
struct box box;
/** Size and location of the widget area and the inner border.
* This is the area in which widgets can be drawn.
* The frame of the dialog box is drawn around this area,
* and the outer border is around the frame.
* The coordinates are relative to the terminal. */
struct box real_box;
/** Vertical scrolling of the widget area of the dialog box.
* Widget Y screen coordinate = widget_data.box.y - dialog_data.y.
* Initially, this is 0 and the coordinate system of the widget area
* matches the coordinate system of the terminal.
* Horizontal scrolling of dialog boxes has not been implemented. */
int y;
int number_of_widgets;
int selected_widget_id;
struct term_event *term_event;

View File

@ -20,10 +20,11 @@
#define CHECKBOX_LEN 3 /* "[X]" or "(X)" */
void
dlg_format_group(struct terminal *term,
dlg_format_group(struct dialog_data *dlg_data,
struct widget_data *widget_data,
int n, int x, int *y, int w, int *rw, int format_only)
{
struct terminal *term = dlg_data->win->term;
int space_between_widgets = 1;
int line_width = 0;
int xpos;
@ -87,14 +88,14 @@ dlg_format_group(struct terminal *term,
text,
label_length,
NULL);
draw_text(term, xpos + width
draw_dlg_text(dlg_data, xpos + width
+ label_padding,
*y, text, lb, 0,
color);
} else
#endif /* CONFIG_UTF8 */
{
draw_text(term, xpos + width
draw_dlg_text(dlg_data, xpos + width
+ label_padding,
*y, text,
label_length, 0,
@ -113,12 +114,12 @@ dlg_format_group(struct terminal *term,
text,
label_length,
NULL);
draw_text(term, xpos, *y,
draw_dlg_text(dlg_data, xpos, *y,
text, lb, 0, color);
} else
#endif /* CONFIG_UTF8 */
{
draw_text(term, xpos, *y,
draw_dlg_text(dlg_data, xpos, *y,
text, label_length,
0, color);
}
@ -155,11 +156,11 @@ group_layouter(struct dialog_data *dlg_data)
#endif /* CONFIG_UTF8 */
rw = int_min(w, strlen(dlg_data->dlg->title));
dlg_format_group(term, dlg_data->widgets_data, n,
dlg_format_group(dlg_data, dlg_data->widgets_data, n,
0, &y, w, &rw, 1);
y++;
dlg_format_buttons(term, dlg_data->widgets_data + n, 2, 0, &y, w,
dlg_format_buttons(dlg_data, dlg_data->widgets_data + n, 2, 0, &y, w,
&rw, ALIGN_CENTER, 1);
w = rw;
@ -167,10 +168,10 @@ group_layouter(struct dialog_data *dlg_data)
draw_dialog(dlg_data, w, y);
y = dlg_data->box.y + DIALOG_TB + 1;
dlg_format_group(term, dlg_data->widgets_data, n,
dlg_format_group(dlg_data, dlg_data->widgets_data, n,
dlg_data->box.x + DIALOG_LB, &y, w, NULL, 0);
y++;
dlg_format_buttons(term, dlg_data->widgets_data + n, 2,
dlg_format_buttons(dlg_data, dlg_data->widgets_data + n, 2,
dlg_data->box.x + DIALOG_LB, &y, w, &rw, ALIGN_CENTER, 0);
}

View File

@ -5,7 +5,7 @@ struct dialog_data;
struct terminal;
struct widget_data;
void dlg_format_group(struct terminal *term,
void dlg_format_group(struct dialog_data *dlg_data,
struct widget_data *widget_data,
int n, int x, int *y, int w, int *rw, int format_only);

View File

@ -30,7 +30,7 @@ update_hierbox_browser(struct hierbox_browser *browser)
struct hierbox_dialog_list_item *item;
foreach (item, browser->dialogs) {
redraw_from_window(item->dlg_data->win->next);
redraw_windows(REDRAW_WINDOW_AND_FRONT, item->dlg_data->win);
}
}

View File

@ -103,10 +103,11 @@ check_nonempty(struct dialog_data *dlg_data, struct widget_data *widget_data)
}
void
dlg_format_field(struct terminal *term,
dlg_format_field(struct dialog_data *dlg_data,
struct widget_data *widget_data,
int x, int *y, int w, int *rw, enum format_align align, int format_only)
{
struct terminal *term = dlg_data->win->term;
static int max_label_width;
static int *prev_y; /* Assert the uniqueness of y */ /* TODO: get rid of this !! --Zas */
unsigned char *label = widget_data->widget->text;
@ -132,7 +133,7 @@ dlg_format_field(struct terminal *term,
if (label && *label) {
if (!format_only) text_color = get_bfu_color(term, "dialog.text");
dlg_format_text_do(term, label, x, y, w, rw, text_color, 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
@ -140,7 +141,7 @@ dlg_format_field(struct terminal *term,
if (label && *label && float_label) {
if (widget_data->widget->info.field.flags & INPFIELD_FLOAT) {
(*y) -= INPUTFIELD_HEIGHT;
dlg_format_text_do(term, INPUTFIELD_FLOAT_SEPARATOR,
dlg_format_text_do(dlg_data, INPUTFIELD_FLOAT_SEPARATOR,
x + label_width, y, w, rw,
text_color, ALIGN_LEFT, format_only);
w -= INPUTFIELD_FLOAT_SEPARATOR_LEN + INPUTFIELD_FLOATLABEL_PADDING;
@ -312,7 +313,7 @@ display_field_do(struct dialog_data *dlg_data, struct widget_data *widget_data,
if (term->utf8_cp)
w = utf8_cells2bytes(text, w, NULL);
#endif /* CONFIG_UTF8 */
draw_text(term, widget_data->box.x, widget_data->box.y,
draw_dlg_text(dlg_data, widget_data->box.x, widget_data->box.y,
text, w, 0, color);
} else {
struct box box;
@ -718,7 +719,7 @@ kbd_field(struct dialog_data *dlg_data, struct widget_data *widget_data)
display_field:
display_widget(dlg_data, widget_data);
redraw_from_window(dlg_data->win);
redraw_windows(REDRAW_IN_FRONT_OF_WINDOW, dlg_data->win);
return EVENT_PROCESSED;
}
@ -765,7 +766,7 @@ input_line_layouter(struct dialog_data *dlg_data)
- ses->status.show_status_bar
- ses->status.show_tabs_bar;
dlg_format_field(win->term, dlg_data->widgets_data, 0,
dlg_format_field(dlg_data, dlg_data->widgets_data, 0,
&y, win->term->width, NULL, ALIGN_LEFT, 0);
}

View File

@ -62,7 +62,7 @@ extern const struct widget_ops field_pass_ops;
widget_handler_status_T check_number(struct dialog_data *, struct widget_data *);
widget_handler_status_T check_nonempty(struct dialog_data *, struct widget_data *);
void dlg_format_field(struct terminal *, struct widget_data *, int, int *, int, int *, enum format_align, int format_only);
void dlg_format_field(struct dialog_data *, struct widget_data *, int, int *, int, int *, enum format_align, int format_only);
void input_field(struct terminal *, struct memory_list *, int, unsigned char *,
unsigned char *, unsigned char *, unsigned char *, void *,

View File

@ -41,7 +41,8 @@ get_listbox_widget_data(struct widget_data *widget_data)
/* Layout for generic boxes */
void
dlg_format_listbox(struct terminal *term, struct widget_data *widget_data,
dlg_format_listbox(struct dialog_data *dlg_data,
struct widget_data *widget_data,
int x, int *y, int w, int max_height, int *rw,
enum format_align align, int format_only)
{

View File

@ -133,7 +133,7 @@ struct listbox_item {
extern const struct widget_ops listbox_ops;
void dlg_format_listbox(struct terminal *, struct widget_data *, int, int *, int, int, int *, enum format_align, int format_only);
void dlg_format_listbox(struct dialog_data *, struct widget_data *, int, int *, int, int, int *, enum format_align, int format_only);
struct listbox_item *traverse_listbox_items_list(struct listbox_item *, struct listbox_data *, int, int, int (*)(struct listbox_item *, void *, int *), void *);

View File

@ -672,7 +672,7 @@ display_menu(struct terminal *term, struct menu *menu)
}
}
redraw_from_window(menu->win);
redraw_windows(REDRAW_IN_FRONT_OF_WINDOW, menu->win);
}
@ -1185,7 +1185,7 @@ display_mainmenu(struct terminal *term, struct menu *menu)
draw_box(term, &box, '>', 0, normal_color);
}
redraw_from_window(menu->win);
redraw_windows(REDRAW_IN_FRONT_OF_WINDOW, menu->win);
}

View File

@ -211,11 +211,13 @@ split_lines(struct widget_data *widget_data, int max_width)
/* Format text according to dialog box and alignment. */
void
dlg_format_text_do(struct terminal *term, unsigned char *text,
dlg_format_text_do(struct dialog_data *dlg_data,
unsigned char *text,
int x, int *y, int width, int *real_width,
struct color_pair *color, enum format_align align,
int format_only)
{
struct terminal *term = dlg_data->win->term;
int line_width;
int firstline = 1;
@ -255,15 +257,17 @@ dlg_format_text_do(struct terminal *term, unsigned char *text,
assert(cells <= width && shift < width);
draw_text(term, x + shift, *y, text, line_width, 0, color);
draw_dlg_text(dlg_data, x + shift, *y, text, line_width, 0, color);
}
}
void
dlg_format_text(struct terminal *term, struct widget_data *widget_data,
dlg_format_text(struct dialog_data *dlg_data,
struct widget_data *widget_data,
int x, int *y, int width, int *real_width, int max_height,
int format_only)
{
struct terminal *term = dlg_data->win->term;
unsigned char *text = widget_data->widget->text;
unsigned char saved = 0;
unsigned char *saved_pos = NULL;
@ -335,7 +339,7 @@ dlg_format_text(struct terminal *term, struct widget_data *widget_data,
widget_data->info.text.current = 0;
}
dlg_format_text_do(term, text,
dlg_format_text_do(dlg_data, text,
x, y, width, real_width,
get_bfu_color(term, "dialog.text"),
widget_data->widget->info.text.align, format_only);
@ -395,8 +399,8 @@ display_text(struct dialog_data *dlg_data, struct widget_data *widget_data)
/* Hope this is at least a bit reasonable. Set cursor
* and window pointer to start of the first text line. */
set_cursor(win->term, widget_data->box.x, widget_data->box.y, 1);
set_window_ptr(win, widget_data->box.x, widget_data->box.y);
set_dlg_cursor(win->term, dlg_data, widget_data->box.x, widget_data->box.y, 1);
set_dlg_window_ptr(dlg_data, win, widget_data->box.x, widget_data->box.y);
return EVENT_PROCESSED;
}
@ -423,12 +427,12 @@ format_and_display_text(struct widget_data *widget_data,
draw_box(term, &widget_data->box, ' ', 0,
get_bfu_color(term, "dialog.generic"));
dlg_format_text(term, widget_data,
dlg_format_text(dlg_data, widget_data,
widget_data->box.x, &y, widget_data->box.width, NULL,
height, 0);
display_text(dlg_data, widget_data);
redraw_from_window(dlg_data->win);
redraw_windows(REDRAW_IN_FRONT_OF_WINDOW, dlg_data->win);
}
static widget_handler_status_T

View File

@ -4,6 +4,7 @@
#include "util/color.h"
struct dialog;
struct dialog_data;
struct terminal;
struct widget_info_text {
@ -45,12 +46,12 @@ void add_dlg_text(struct dialog *dlg, unsigned char *text,
enum format_align align, int bottom_pad);
extern const struct widget_ops text_ops;
void dlg_format_text_do(struct terminal *term,
void dlg_format_text_do(struct dialog_data *dlg_data,
unsigned char *text, int x, int *y, int w, int *rw,
struct color_pair *scolor, enum format_align align, int format_only);
void
dlg_format_text(struct terminal *term, struct widget_data *widget_data,
dlg_format_text(struct dialog_data *dlg_data, struct widget_data *widget_data,
int x, int *y, int dlg_width, int *real_width, int height, int format_only);
#define text_is_scrollable(widget_data) \

View File

@ -144,7 +144,7 @@ download_dialog_layouter(struct dialog_data *dlg_data)
&& (show_meter || is_in_state(download->state, S_RESUME)));
#endif
redraw_below_window(dlg_data->win);
redraw_windows(REDRAW_BEHIND_WINDOW, dlg_data->win);
file_download->dlg_data = dlg_data;
if (!msg) return;
@ -166,7 +166,7 @@ download_dialog_layouter(struct dialog_data *dlg_data)
int_lower_bound(&w, DOWN_DLG_MIN);
}
dlg_format_text_do(term, url, 0, &y, w, &rw,
dlg_format_text_do(dlg_data, url, 0, &y, w, &rw,
dialog_text_color, ALIGN_LEFT, 1);
y++;
@ -175,11 +175,11 @@ download_dialog_layouter(struct dialog_data *dlg_data)
#if CONFIG_BITTORRENT
if (bittorrent) y += 2;
#endif
dlg_format_text_do(term, msg, 0, &y, w, &rw,
dlg_format_text_do(dlg_data, msg, 0, &y, w, &rw,
dialog_text_color, ALIGN_LEFT, 1);
y++;
dlg_format_buttons(term, dlg_data->widgets_data,
dlg_format_buttons(dlg_data, dlg_data->widgets_data,
dlg_data->number_of_widgets, 0, &y, w,
&rw, ALIGN_CENTER, 1);
@ -199,7 +199,7 @@ 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(term, url, x, &y, w, NULL,
dlg_format_text_do(dlg_data, url, x, &y, w, NULL,
dialog_text_color, ALIGN_LEFT, 0);
if (show_meter) {
@ -216,11 +216,11 @@ download_dialog_layouter(struct dialog_data *dlg_data)
}
#endif
y++;
dlg_format_text_do(term, msg, x, &y, w, NULL,
dlg_format_text_do(dlg_data, msg, x, &y, w, NULL,
dialog_text_color, ALIGN_LEFT, 0);
y++;
dlg_format_buttons(term, dlg_data->widgets_data,
dlg_format_buttons(dlg_data, dlg_data->widgets_data,
dlg_data->number_of_widgets, x, &y, w,
NULL, ALIGN_CENTER, 0);

View File

@ -567,5 +567,5 @@ print_screen_status(struct session *ses)
display_tab_bar(ses, term, tabs_count);
}
redraw_from_window(ses->tab);
redraw_windows(REDRAW_IN_FRONT_OF_WINDOW, ses->tab);
}

View File

@ -7,6 +7,7 @@
#include "elinks.h"
#include "bfu/dialog.h"
#include "config/options.h"
#include "intl/charsets.h"
#include "terminal/color.h"
@ -558,6 +559,24 @@ draw_text(struct terminal *term, int x, int y,
set_screen_dirty(term->screen, y, y);
}
void
draw_dlg_text(struct dialog_data *dlg_data, int x, int y,
unsigned char *text, int length,
enum screen_char_attr attr, struct color_pair *color)
{
struct terminal *term = dlg_data->win->term;
struct 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(term, x, y, text, length, attr, color);
}
void
set_cursor(struct terminal *term, int x, int y, int blockable)
{
@ -579,6 +598,24 @@ set_cursor(struct terminal *term, int x, int y, int blockable)
}
}
void
set_dlg_cursor(struct terminal *term, struct dialog_data *dlg_data, int x, int y, int blockable)
{
struct box *box = &dlg_data->real_box;
assert(term && term->screen);
if_assert_failed return;
if (box->height) {
int y_max = box->y + box->height;
y -= dlg_data->y;
if (y < box->y || y >= y_max) return;
}
set_cursor(term, x, y, blockable);
}
void
clear_terminal(struct terminal *term)
{

View File

@ -4,6 +4,7 @@
#include "intl/charsets.h" /* unicode_val_T */
struct color_pair;
struct dialog_data;
struct box;
struct terminal;
@ -280,6 +281,12 @@ void draw_text(struct terminal *term, int x, int y,
enum screen_char_attr attr,
struct color_pair *color);
/** Draws text for dialogs. */
void draw_dlg_text(struct dialog_data *dlg_data, int x, int y,
unsigned char *text, int length,
enum screen_char_attr attr, struct color_pair *color);
/** Draws @a length chars from @a line on the screen. */
void draw_line(struct terminal *term, int x, int y, int length,
struct screen_char *line);
@ -289,6 +296,9 @@ void draw_line(struct terminal *term, int x, int y, int length,
* bottom right corner of the screen. */
void set_cursor(struct terminal *term, int x, int y, int blockable);
/* set cursor for dialogs */
void set_dlg_cursor(struct terminal *term, struct dialog_data *dlg_data, int x, int y, int blockable);
/** Blanks the screen. */
void clear_terminal(struct terminal *);

View File

@ -7,6 +7,7 @@
#include "elinks.h"
#include "bfu/dialog.h"
#include "bfu/menu.h"
#include "terminal/event.h"
#include "terminal/tab.h"
@ -17,36 +18,35 @@
void
redraw_from_window(struct window *win)
redraw_windows(enum windows_to_redraw which, struct window *win)
{
struct terminal *term = win->term;
struct term_event ev;
struct window *end = (struct window *) &term->windows;
if (term->redrawing != TREDRAW_READY) return;
set_redraw_term_event(&ev, term->width, term->height);
term->redrawing = TREDRAW_BUSY;
for (win = win->prev; win != end; win = win->prev) {
if (!inactive_tab(win))
win->handler(win, &ev);
}
term->redrawing = TREDRAW_READY;
}
void
redraw_below_window(struct window *win)
{
struct terminal *term = win->term;
struct term_event ev;
struct window *end = win;
struct window *end;
enum term_redrawing_state saved_redraw_state = term->redrawing;
switch (which) {
case REDRAW_IN_FRONT_OF_WINDOW:
win = win->prev;
/* fall through */
case REDRAW_WINDOW_AND_FRONT:
end = (struct window *) &term->windows;
if (term->redrawing != TREDRAW_READY) return;
term->redrawing = TREDRAW_BUSY;
break;
case REDRAW_BEHIND_WINDOW:
end = win;
win = (struct window *) term->windows.prev;
if (term->redrawing == TREDRAW_DELAYED) return;
term->redrawing = TREDRAW_DELAYED;
break;
default:
ERROR("invalid enum windows_to_redraw: which==%d", (int) which);
return;
}
set_redraw_term_event(&ev, term->width, term->height);
term->redrawing = TREDRAW_DELAYED;
for (win = term->windows.prev; win != end; win = win->prev) {
for (; win != end; win = win->prev) {
if (!inactive_tab(win))
win->handler(win, &ev);
}
@ -205,3 +205,17 @@ assert_window_stacking(struct terminal *term)
}
}
#endif /* CONFIG_DEBUG */
void
set_dlg_window_ptr(struct dialog_data *dlg_data, struct window *window, int x, int y)
{
struct 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;
}
set_window_ptr(window, x, y);
}

View File

@ -3,6 +3,7 @@
#include "util/lists.h"
struct dialog_data;
struct term_event;
struct terminal;
struct window;
@ -67,12 +68,28 @@ struct window {
unsigned int resize:1;
};
void redraw_from_window(struct window *);
void redraw_below_window(struct window *);
/** Which windows redraw_windows() should redraw. */
enum windows_to_redraw {
/** Redraw the windows in front of the specified window,
* but not the specified window itself. */
REDRAW_IN_FRONT_OF_WINDOW,
/** Redraw the specified window, and the windows in front of
* it. */
REDRAW_WINDOW_AND_FRONT,
/** Redraw the windows behind the specified window,
* but not the specified window itself.
* Do that even if terminal.redrawing is TREDRAW_BUSY. */
REDRAW_BEHIND_WINDOW,
};
void redraw_windows(enum windows_to_redraw, struct window *);
void add_window(struct terminal *, window_handler_T, void *);
void delete_window(struct window *);
void delete_window_ev(struct window *, struct term_event *ev);
#define set_window_ptr(window, x_, y_) do { (window)->x = (x_); (window)->y = (y_); } while (0)
void set_dlg_window_ptr(struct dialog_data *dlg_data, struct window *window, int x, int y);
void get_parent_ptr(struct window *, int *, int *);
void add_empty_window(struct terminal *, void (*)(void *), void *);