1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-01-03 14:57:44 -05:00

Indicate backgrounded downloads using an unused led.

The sixth position (the last led from the left) is used.
This commit is contained in:
Laurent MONIN 2007-11-06 12:51:24 +01:00
parent 5079d5abcf
commit d14f79eb2c
5 changed files with 44 additions and 3 deletions

View File

@ -38,7 +38,7 @@
* 2 - JavaScript Error indicator
* 3 - JavaScript pop-up blocking indicator
* 4 - unused, reserved for Lua
* 5 - unused */
* 5 - download in progress */
/* XXX: Currently, the leds toggling is quite hackish, some more work should go
* to it (ie. some led hooks called in sync_leds() to light the leds
@ -129,6 +129,12 @@ set_led_value(struct led *led, unsigned char value)
}
}
unsigned char
get_led_value(struct led *led)
{
return led->value__;
}
void
unset_led_value(struct led *led)
{
@ -268,6 +274,25 @@ sync_leds(struct session *ses)
return 0;
}
static void
update_download_led(struct session *ses)
{
struct session_status *status = &ses->status;
if (status->downloads_in_progress) {
unsigned char led = get_led_value(status->download_led);
switch (led) {
case '-' : led = '\\'; break;
case '\\': led = '|'; break;
case '|' : led = '/'; break;
default: led = '-';
}
set_led_value(status->download_led, led);
}
}
/* Timer callback for @redraw_timer. As explained in @install_timer,
* this function must erase the expired timer ID from all variables. */
static void
@ -288,6 +313,7 @@ redraw_leds(void *xxx)
drawing = 1;
foreach (ses, sessions) {
update_download_led(ses);
if (!sync_leds(ses))
continue;
redraw_terminal(ses->tab->term);
@ -306,7 +332,7 @@ menu_leds_info(struct terminal *term, void *xxx, void *xxxx)
msg_text(term, N_("What the different LEDs indicate:\n"
"\n"
"[SIJP--]\n"
" |||||`- Unused\n"
" |||||`- Download in progress\n"
" ||||`-- Unused\n"
" |||`--- A JavaScript pop-up window was blocked\n"
" ||`---- A JavaScript error has occured\n"

View File

@ -46,6 +46,7 @@ void menu_leds_info(struct terminal *term, void *xxx, void *xxxx);
struct led *register_led(struct session *ses, int number);
void unregister_led(struct led *);
void set_led_value(struct led *led, unsigned char value);
unsigned char get_led_value(struct led *led);
void unset_led_value(struct led *led);
#endif

View File

@ -136,6 +136,10 @@ abort_download(struct file_download *file_download)
* download dialog code potentially could access free()d memory. */
assert(!is_object_used(file_download));
#endif
struct session *ses = file_download->ses;
struct session_status *status = &ses->status;
status->downloads_in_progress = 0;
done_download_display(file_download);
@ -336,19 +340,25 @@ static void
download_data_store(struct download *download, struct file_download *file_download)
{
struct terminal *term = file_download->term;
struct session *ses = file_download->ses;
struct session_status *status = &ses->status;
if (!term) {
/* No term here, so no beep. --Zas */
abort_download(file_download);
return;
}
if (is_in_progress_state(download->state)) {
status->downloads_in_progress = 1;
if (file_download->dlg_data)
redraw_dialog(file_download->dlg_data, 1);
return;
}
status->downloads_in_progress = 0;
if (download->state != S_OK) {
unsigned char *url = get_uri_string(file_download->uri, URI_PUBLIC);
enum connection_state state = download->state;

View File

@ -873,6 +873,8 @@ init_session(struct session *base_session, struct terminal *term,
ses->status.insert_mode_led = register_led(ses, 1);
ses->status.ecmascript_led = register_led(ses, 2);
ses->status.popup_led = register_led(ses, 3);
ses->status.download_led = register_led(ses, 5);
#endif
ses->status.force_show_status_bar = -1;
ses->status.force_show_title_bar = -1;

View File

@ -103,6 +103,7 @@ struct session_status {
struct led *insert_mode_led;
struct led *ecmascript_led;
struct led *popup_led;
struct led *download_led;
#endif
/** Has the tab been visited yet. */
unsigned int visited:1;
@ -110,6 +111,7 @@ struct session_status {
/** Is processing file requests. */
unsigned int processing_file_requests:1;
unsigned int show_tabs_bar_at_top:1;
unsigned int downloads_in_progress:1;
};
enum insert_mode {