mirror of
https://github.com/rkd77/elinks.git
synced 2025-02-02 15:09:23 -05:00
[mujs] unibar.c
and missing screen.c
This commit is contained in:
parent
64171195ad
commit
505ca35cbc
@ -1,6 +1,6 @@
|
||||
top_builddir=../../../..
|
||||
include $(top_builddir)/Makefile.config
|
||||
|
||||
OBJS = attr.o attributes.o collection.o console.o forms.o history.o implementation.o keyboard.o localstorage.o mapa.obj message.o navigator.o nodelist.o screen.o
|
||||
OBJS = attr.o attributes.o collection.o console.o forms.o history.o implementation.o keyboard.o localstorage.o mapa.obj message.o navigator.o nodelist.o screen.o unibar.o
|
||||
|
||||
include $(top_srcdir)/Makefile.lib
|
||||
|
@ -1 +1 @@
|
||||
srcs += files('attr.c', 'attributes.c', 'collection.c', 'console.c', 'forms.c', 'history.c', 'implementation.c', 'keyboard.c', 'localstorage.c', 'mapa.cpp', 'message.c', 'navigator.c', 'nodelist.c', 'screen.c')
|
||||
srcs += files('attr.c', 'attributes.c', 'collection.c', 'console.c', 'forms.c', 'history.c', 'implementation.c', 'keyboard.c', 'localstorage.c', 'mapa.cpp', 'message.c', 'navigator.c', 'nodelist.c', 'screen.c', 'unibar.c')
|
||||
|
135
src/ecmascript/libdom/mujs/screen.c
Normal file
135
src/ecmascript/libdom/mujs/screen.c
Normal file
@ -0,0 +1,135 @@
|
||||
/* The MuJS screen object implementation. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "elinks.h"
|
||||
|
||||
#include "document/view.h"
|
||||
#include "ecmascript/ecmascript.h"
|
||||
#include "ecmascript/mujs.h"
|
||||
#include "ecmascript/mujs/screen.h"
|
||||
#include "ecmascript/mujs/window.h"
|
||||
#include "session/session.h"
|
||||
#include "viewer/text/vs.h"
|
||||
|
||||
static void
|
||||
mjs_screen_get_property_availHeight(js_State *J)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)js_getcontext(J);
|
||||
|
||||
assert(interpreter);
|
||||
struct view_state *vs = interpreter->vs;
|
||||
struct document_view *doc_view = vs->doc_view;
|
||||
|
||||
if (!doc_view) {
|
||||
js_pushundefined(J);
|
||||
return;
|
||||
}
|
||||
js_pushnumber(J, doc_view->box.height * 16);
|
||||
}
|
||||
|
||||
static void
|
||||
mjs_screen_get_property_availWidth(js_State *J)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)js_getcontext(J);
|
||||
|
||||
assert(interpreter);
|
||||
struct view_state *vs = interpreter->vs;
|
||||
struct document_view *doc_view = vs->doc_view;
|
||||
|
||||
if (!doc_view) {
|
||||
js_pushundefined(J);
|
||||
return;
|
||||
}
|
||||
js_pushnumber(J, doc_view->box.width * 8);
|
||||
}
|
||||
|
||||
static void
|
||||
mjs_screen_get_property_height(js_State *J)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)js_getcontext(J);
|
||||
|
||||
assert(interpreter);
|
||||
struct view_state *vs = interpreter->vs;
|
||||
struct document_view *doc_view = vs->doc_view;
|
||||
|
||||
if (!doc_view) {
|
||||
js_pushundefined(J);
|
||||
return;
|
||||
}
|
||||
struct session *ses = doc_view->session;
|
||||
|
||||
if (!ses) {
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s %d\n", __FILE__, __FUNCTION__, __LINE__);
|
||||
#endif
|
||||
js_pushundefined(J);
|
||||
return;
|
||||
}
|
||||
js_pushnumber(J, ses->tab->term->height * 16);
|
||||
}
|
||||
|
||||
static void
|
||||
mjs_screen_get_property_width(js_State *J)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)js_getcontext(J);
|
||||
|
||||
assert(interpreter);
|
||||
struct view_state *vs = interpreter->vs;
|
||||
struct document_view *doc_view = vs->doc_view;
|
||||
|
||||
if (!doc_view) {
|
||||
js_pushundefined(J);
|
||||
return;
|
||||
}
|
||||
struct session *ses = doc_view->session;
|
||||
|
||||
if (!ses) {
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s %d\n", __FILE__, __FUNCTION__, __LINE__);
|
||||
#endif
|
||||
js_pushundefined(J);
|
||||
return;
|
||||
}
|
||||
js_pushnumber(J, ses->tab->term->width * 8);
|
||||
}
|
||||
|
||||
static void
|
||||
mjs_screen_toString(js_State *J)
|
||||
{
|
||||
js_pushstring(J, "[screen object]");
|
||||
}
|
||||
|
||||
int
|
||||
mjs_screen_init(js_State *J)
|
||||
{
|
||||
js_newobject(J);
|
||||
{
|
||||
addmethod(J, "screen.toString", mjs_screen_toString, 0);
|
||||
addproperty(J, "screen.availHeight", mjs_screen_get_property_availHeight, NULL);
|
||||
addproperty(J, "screen.availWidth", mjs_screen_get_property_availWidth, NULL);
|
||||
addproperty(J, "screen.height", mjs_screen_get_property_height, NULL);
|
||||
addproperty(J, "screen.width", mjs_screen_get_property_width, NULL);
|
||||
}
|
||||
js_defglobal(J, "screen", JS_DONTENUM);
|
||||
|
||||
return 0;
|
||||
}
|
155
src/ecmascript/libdom/mujs/unibar.c
Normal file
155
src/ecmascript/libdom/mujs/unibar.c
Normal file
@ -0,0 +1,155 @@
|
||||
/* The quickjs unibar objects implementation. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "elinks.h"
|
||||
|
||||
#include "dialogs/status.h"
|
||||
#include "document/view.h"
|
||||
#include "ecmascript/ecmascript.h"
|
||||
#include "ecmascript/mujs.h"
|
||||
#include "ecmascript/mujs/unibar.h"
|
||||
#include "main/select.h"
|
||||
#include "session/session.h"
|
||||
#include "viewer/text/vs.h"
|
||||
|
||||
static void
|
||||
mjs_menubar_get_property_visible(js_State *J)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)js_getcontext(J);
|
||||
|
||||
assert(interpreter);
|
||||
struct view_state *vs = interpreter->vs;
|
||||
struct document_view *doc_view = vs->doc_view;
|
||||
|
||||
if (!doc_view) {
|
||||
js_pushundefined(J);
|
||||
return;
|
||||
}
|
||||
struct session_status *status = &doc_view->session->status;
|
||||
|
||||
js_pushboolean(J, status->force_show_title_bar >= 0
|
||||
? status->force_show_title_bar
|
||||
: status->show_title_bar);
|
||||
}
|
||||
|
||||
static void
|
||||
mjs_statusbar_get_property_visible(js_State *J)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)js_getcontext(J);
|
||||
|
||||
assert(interpreter);
|
||||
struct view_state *vs = interpreter->vs;
|
||||
struct document_view *doc_view = vs->doc_view;
|
||||
|
||||
if (!doc_view) {
|
||||
js_pushundefined(J);
|
||||
return;
|
||||
}
|
||||
struct session_status *status = &doc_view->session->status;
|
||||
|
||||
js_pushboolean(J, status->force_show_status_bar >= 0
|
||||
? status->force_show_status_bar
|
||||
: status->show_status_bar);
|
||||
}
|
||||
|
||||
static void
|
||||
mjs_menubar_set_property_visible(js_State *J)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)js_getcontext(J);
|
||||
struct view_state *vs = interpreter->vs;
|
||||
struct document_view *doc_view = vs->doc_view;
|
||||
int val = js_toboolean(J, 1);
|
||||
|
||||
if (!doc_view) {
|
||||
js_pushundefined(J);
|
||||
return;
|
||||
}
|
||||
struct session_status *status = &doc_view->session->status;
|
||||
status->force_show_title_bar = val;
|
||||
|
||||
register_bottom_half(update_status, NULL);
|
||||
|
||||
js_pushundefined(J);
|
||||
}
|
||||
|
||||
static void
|
||||
mjs_statusbar_set_property_visible(js_State *J)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)js_getcontext(J);
|
||||
struct view_state *vs = interpreter->vs;
|
||||
struct document_view *doc_view = vs->doc_view;
|
||||
int val = js_toboolean(J, 1);
|
||||
|
||||
if (!doc_view) {
|
||||
js_pushundefined(J);
|
||||
return;
|
||||
}
|
||||
struct session_status *status = &doc_view->session->status;
|
||||
status->force_show_status_bar = val;
|
||||
|
||||
register_bottom_half(update_status, NULL);
|
||||
|
||||
js_pushundefined(J);
|
||||
}
|
||||
|
||||
static void
|
||||
mjs_menubar_toString(js_State *J)
|
||||
{
|
||||
js_pushstring(J, "[menubar object]");
|
||||
}
|
||||
|
||||
static void
|
||||
mjs_statusbar_toString(js_State *J)
|
||||
{
|
||||
js_pushstring(J, "[statusbar object]");
|
||||
}
|
||||
|
||||
static void
|
||||
mjs_menubar_init(js_State *J)
|
||||
{
|
||||
js_newobject(J);
|
||||
{
|
||||
addmethod(J, "menubar.toString", mjs_menubar_toString, 0);
|
||||
addproperty(J, "menubar.visible", mjs_menubar_get_property_visible, mjs_menubar_set_property_visible);
|
||||
}
|
||||
js_defglobal(J, "menubar", JS_DONTENUM);
|
||||
}
|
||||
|
||||
static void
|
||||
mjs_statusbar_init(js_State *J)
|
||||
{
|
||||
js_newobject(J);
|
||||
{
|
||||
addmethod(J, "statusbar.toString", mjs_statusbar_toString, 0);
|
||||
addproperty(J, "statusbar.visible", mjs_statusbar_get_property_visible, mjs_statusbar_set_property_visible);
|
||||
}
|
||||
js_defglobal(J, "statusbar", JS_DONTENUM);
|
||||
}
|
||||
|
||||
int
|
||||
mjs_unibar_init(js_State *J)
|
||||
{
|
||||
mjs_menubar_init(J);
|
||||
mjs_statusbar_init(J);
|
||||
|
||||
return 0;
|
||||
}
|
@ -42,6 +42,8 @@
|
||||
#include "viewer/text/link.h"
|
||||
#include "viewer/text/vs.h"
|
||||
|
||||
#ifndef CONFIG_LIBDOM
|
||||
|
||||
static void
|
||||
mjs_menubar_get_property_visible(js_State *J)
|
||||
{
|
||||
@ -176,3 +178,4 @@ mjs_unibar_init(js_State *J)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -3,6 +3,14 @@
|
||||
|
||||
#include <mujs.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int mjs_unibar_init(js_State *J);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user