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

ECMAScript: added writeonly property window.status

This commit is contained in:
Witold Filipczyk 2006-10-24 20:41:25 +02:00 committed by Witold Filipczyk
parent 6e08e1bf5d
commit f4e66f1fc6
8 changed files with 39 additions and 3 deletions

View File

@ -194,7 +194,13 @@ display_status_bar(struct session *ses, struct terminal *term, int tabs_count)
if (ses->kbdprefix.repeat_count) {
msg = msg_text(term, N_("Keyboard prefix: %d"),
ses->kbdprefix.repeat_count);
} else if (download) {
}
#ifdef CONFIG_ECMASCRIPT
else if (ses->status.window_status) {
msg = stracpy(ses->status.window_status);
}
#endif
else if (download) {
struct document_view *doc_view = current_frame(ses);
/* Show S_INTERRUPTED message *once* but then show links

View File

@ -96,6 +96,7 @@ struct SEE_string *s_hidden;
struct SEE_string *s_timeout;
struct SEE_string *s_setTimeout;
struct SEE_string *s_status;
void
init_intern_strings(void)
@ -195,4 +196,5 @@ init_intern_strings(void)
s_timeout = SEE_intern_global("timeout");
s_setTimeout = SEE_intern_global("setTimeout");
s_status = SEE_intern_global("status");
}

View File

@ -101,4 +101,5 @@ extern struct SEE_string *s_hidden;
extern struct SEE_string *s_timeout;
extern struct SEE_string *s_setTimeout;
extern struct SEE_string *s_status;
#endif

View File

@ -103,7 +103,7 @@ window_get(struct SEE_interpreter *interp, struct SEE_object *o,
if (p == s_closed) {
SEE_SET_BOOLEAN(res, 0);
} else if (p == s_self || p == s_parent || p == s_top) {
} else if (p == s_self || p == s_parent || p == s_top || p == s_status) {
SEE_SET_OBJECT(res, o);
#if 0
} else if (p == s_parent || p == s_top) {
@ -169,6 +169,16 @@ window_put(struct SEE_interpreter *interp, struct SEE_object *o,
location_goto(doc_view, str);
mem_free(str);
}
} else if (p == s_status) {
struct global_object *g = (struct global_object *)interp;
struct js_window_object *win = g->win;
struct view_state *vs = win->vs;
struct document_view *doc_view = vs->doc_view;
struct session *ses = doc_view->session;
unsigned char *stat = SEE_value_to_unsigned_char(interp, val);
mem_free_set(&ses->status.window_status, stat);
print_screen_status(ses);
}
}
@ -176,7 +186,7 @@ static int
window_canput(struct SEE_interpreter *interp, struct SEE_object *o,
struct SEE_string *p)
{
if (p == s_location)
if (p == s_location || p == s_status)
return 1;
return 0;
}

View File

@ -60,6 +60,7 @@ enum window_prop {
JSP_WIN_CLOSED,
JSP_WIN_PARENT,
JSP_WIN_SELF,
JSP_WIN_STATUS,
JSP_WIN_TOP,
};
/* "location" is special because we need to simulate "location.href"
@ -72,6 +73,7 @@ const JSPropertySpec window_props[] = {
{ "closed", JSP_WIN_CLOSED, JSPROP_ENUMERATE | JSPROP_READONLY },
{ "parent", JSP_WIN_PARENT, JSPROP_ENUMERATE | JSPROP_READONLY },
{ "self", JSP_WIN_SELF, JSPROP_ENUMERATE | JSPROP_READONLY },
{ "status", JSP_WIN_STATUS, JSPROP_ENUMERATE },
{ "top", JSP_WIN_TOP, JSPROP_ENUMERATE | JSPROP_READONLY },
{ "window", JSP_WIN_SELF, JSPROP_ENUMERATE | JSPROP_READONLY },
{ NULL }
@ -251,6 +253,10 @@ window_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
return JS_TRUE;
switch (JSVAL_TO_INT(id)) {
case JSP_WIN_STATUS:
mem_free_set(&vs->doc_view->session->status.window_status, stracpy(jsval_to_string(ctx, vp)));
print_screen_status(vs->doc_view->session);
return JS_TRUE;
default:
INTERNAL("Invalid ID %d in window_set_property().", JSVAL_TO_INT(id));
return JS_TRUE;

View File

@ -1171,6 +1171,9 @@ destroy_session(struct session *ses)
mem_free_if(ses->search_word);
mem_free_if(ses->last_search_word);
mem_free_if(ses->status.last_title);
#ifdef CONFIG_ECMASCRIPT
mem_free_if(ses->status.window_status);
#endif
del_from_list(ses);
}

View File

@ -92,6 +92,9 @@ struct session_status {
unsigned int set_window_title:1;
unsigned char *last_title;
#ifdef CONFIG_ECMASCRIPT
unsigned char *window_status;
#endif
#ifdef CONFIG_LEDS
unsigned int show_leds:1;

View File

@ -67,6 +67,11 @@ detach_formatted(struct document_view *doc_view)
assert(doc_view);
if_assert_failed return;
#ifdef CONFIG_ECMASCRIPT
if (doc_view->session) {
mem_free_set(&doc_view->session->status.window_status, NULL);
}
#endif
if (doc_view->document) {
release_document(doc_view->document);
doc_view->document = NULL;