1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-28 01:35:32 +00:00
Commit Graph

280 Commits

Author SHA1 Message Date
Olivier El Mekki
edaf66fc60
[lua] expose reload() and goto_url() to lua api
Two api methods for lua scripting has been added.

`reload()` allows to refresh the document without triggering a new
html request. This commits expose that existing internal function to the
lua api.

One example where it is useful : making a lua hook that allows to edit a
local file we're browsing and see the change without having to perform a
full reload (thus losing the scrolling position). Or anything else that
allows to interactively modify the currently loaded document.

`goto_url()` allows to navigate to given url long after the page has been
loaded (so follow_url_hooks can't be used).

Example where it's useful : binding a key to load the latest archive.org
snapshot for current page (especially useful when using tor and being
constantly harassed by cloudflare).
2021-11-13 13:57:52 +01:00
Witold Filipczyk
30d4eb36ff [smjs] Error Reporting with open_memstream 2021-09-06 20:36:10 +02:00
Witold Filipczyk
024f4f44b6 [smjs] Report errors to stderr 2021-09-06 19:46:09 +02:00
Witold Filipczyk
f692389917 [smjs] Compilation fixes. 2021-09-05 17:50:41 +02:00
Witold Filipczyk
47224921de [spidermonkey] jsval_to_string everywhere
Replace JS_EncodeString by jsval_to_string. It will allow easier
changes in the future. In smjs nullptr everywhere.
In ecmascript arrays don't work. For example
document.getElementsByTagName("H1")[0]

smjs even does not start.

Plan is to bump mozjs version, and later back to fixing bugs.
2021-08-27 19:46:05 +02:00
Witold Filipczyk
630696da59 [smjs] nullptr for ClassOps 2021-08-26 18:39:03 +02:00
Witold Filipczyk
34e878a0da [ecmascript] nullptr everywhere 2021-08-26 15:44:32 +02:00
Witold Filipczyk
b825f4abf1 [js] Start to adjust code for mozjs-60. 2021-08-25 20:08:02 +02:00
Witold Filipczyk
ee49c80061 [meson] ruby dependency: ruby not ruby-2.6
Also initialize error, because rb_load_protect, does not change it.
2021-08-17 16:09:05 +02:00
Witold Filipczyk
66305fcb50 [gettext] try system gettext. Refs #62
Now, only meson was changed.
-Dnls=true -Dgettext=true
2021-08-08 21:25:08 +02:00
Witold Filipczyk
73c632f00c [lua] called tempname. 2021-04-03 21:14:21 +02:00
Witold Filipczyk
f351fbcf6a [dump] Experiment with pre_format_hook in dump. Refs #103 2021-03-07 22:07:34 +01:00
Witold Filipczyk
ccc7ca3653 [python] http/1.1 spec says that default codepage is ISO-8859-1. 2021-01-16 21:05:02 +01:00
Witold Filipczyk
0fea79cc8f [cflags] Removed -Wno-pointer-sign
Likely some new bugs were introduced by this change.
The long term goal is clean compilation by g++.
2021-01-02 16:20:27 +01:00
Witold Filipczyk
085a93d544 [spidermonkey] JS_PS_END 2020-11-21 17:54:47 +01:00
Witold Filipczyk
477e56eb43 [smjs] Maybe it is not correct, but spidermonkey and smjs work together. 2020-11-17 18:46:27 +01:00
Witold Filipczyk
d1ecd45828 [mozjs52] It compiles, but often segfaults. No idea yet how to fix it. 2020-10-27 14:53:24 +01:00
Witold Filipczyk
a5b68a25a1 [mozjs45] Code is unstable, but at least compiles. 2020-10-23 22:34:58 +02:00
Witold Filipczyk
01c511f52d [mozjs38] ELinks is compilable, was not heavily tested. 2020-10-16 19:54:02 +02:00
Witold Filipczyk
ca24054cc6 [mozjs31] scripting smjs
It was not heavily tested.
2020-10-12 18:55:48 +02:00
Witold Filipczyk
1f57e72212 [mozjs24] Allow build elinks with g++
SpiderMonkey was updated to mozjs24. If you want to build elinks
with ecmascript support, you must compile using g++ with -fpermissive .
There is a lot of warnings.
There are some memleaks in ecmascript code, especially related to JSAutoCompartment.
I don't know yet, where and how to free it.

Debian does not support mozjs24, so I'm going to gradually update SpiderMonkey version.
2020-10-05 20:14:55 +02:00
Witold Filipczyk
5f87bdbcb2 [meson] meson build scripts.
Not finished yet, but I added to motivate myself and others.
The goal is to get a few seconds faster builds.

autotools still will be available.
2020-09-05 22:06:01 +02:00
Witold Filipczyk
f2557c9885 [python] Compilation warning 2020-08-09 19:50:19 +02:00
Witold Filipczyk
8b8f57ed75 [python] If page encoding is not "utf-8", encode it twice in pre_format_html_hook.
Once to utf-8 before pre_format_html_hook, and second time to the original encoding after python
script execution. I know it is inefficient, but computers are quite fast nowadays.
2020-08-09 17:45:22 +02:00
Felix Janda
f88e7c6081 Fix compilation with gcc-10
Fixes the errors

x86_64-pc-linux-gnu-ld: hooks.o:(.bss+0x0): multiple definition of `erb_module'; core.o:(.bss+0x0): first defined here
x86_64-pc-linux-gnu-ld: ruby.o:(.bss+0x0): multiple definition of `erb_module'; core.o:(.bss+0x0): first defined here

Bug: https://bugs.gentoo.org/730658
2020-08-02 17:42:47 -04:00
Witold Filipczyk
9e71d7f3c8 [scripting] lua_rawlen. Refs #46 2020-05-22 20:46:35 +02:00
Witold Filipczyk
b3e01b3298 [scripting] python scripting with Python3.
Only utf-8 encoding is supported.
2019-11-11 13:33:37 +01:00
Witold Filipczyk
3d96b0d7d7 Revert "Compile with C++."
This reverts commit 4f4df33638.
2019-04-21 12:27:40 +02:00
Witold Filipczyk
8d7112c27d Revert "Fix some issues with js."
This reverts commit 6322d2936a.
2019-04-21 12:26:27 +02:00
Witold Filipczyk
6322d2936a Fix some issues with js. 2019-02-17 23:33:12 +01:00
Witold Filipczyk
4f4df33638 Compile with C++.
Weak points:
- alignof
- js problems

Todo:
- make js work with C++ and mozjs-17
- then mozjs-24
- then mozjs-52
- then mozjs-60
- decrease number of warnings
2019-02-17 20:46:16 +01:00
Witold Filipczyk
25dd2ecae9 Changed ecmascript engine to mozjs-17.0.
Was not tested, especially smjs is likely buggy.
2019-02-10 21:00:37 +01:00
Witold Filipczyk
00d34fd0ed ruby: missing change PTR to LEN 2018-03-10 10:27:46 +01:00
Felix Janda
7a403ef735 Fix compatibility with Ruby >= 1.9
Based on patch by Ian Abbott

Bug: https://bugs.gentoo.org/424789
2018-03-09 17:34:30 -05:00
Witold Filipczyk
0dd3aaabe6 int -> size_t 2018-02-25 17:14:46 +01:00
Felix Janda
254f440de4 Remove references to internal-hooks.scm 2018-02-24 15:08:17 -05:00
Felix Janda
cec24f11a4 guile: update deprecated string functions 2018-02-24 15:05:45 -05:00
Felix Janda
a0a063f784 guile: replace discouraged SCM_FALSEP, SCM_NULLP, SCM_STRINGP 2018-02-24 14:18:25 -05:00
Marco Migliori
f1fb95835a display lua hooks errors 2017-05-16 20:54:56 +02:00
Witold Filipczyk
52d6f37c8e Explicit cast to (const char *) for strchr function (C++) 2016-04-20 19:43:37 +02:00
Witold Filipczyk
c84dfd7e18 mem_free_if where aplicable. Initialised memory in encoding/* 2015-05-10 17:27:55 +02:00
M. Levinson
a229adb19a A more nuanced approach to Python warnings.
By default some Python warning messages would be written to standard error
by the interpreter. To prevent these warnings from making a mess of the
ELinks screen, all warnings were turned into exceptions so they could be
caught and displayed through the usual report_scripting_error() mechanism.

With Python 3.2, this approach backfires: A new class of ResourceWarnings
that are filtered by default (and hence would *not* have been written to
standard error) are now turned into exceptions, and these exceptions can't
be caught because they're emitted from the interpreter's cleanup code. As
a result, the uncaught exceptions would make a mess of the ELinks screen.

The new solution is to replace Python's standard library function
warnings.showwarning() with one that turns warning messages into exceptions.
This means we'll wait until a warning would have been written to standard
error before turning it into an exception, so other warnings that would
never have reached that point because they're filtered will remain unseen.

(The behavior of warning messages is described in the documentation for
the "warnings" module from Python's standard library.)
2013-07-05 12:29:58 +02:00
Kalle Olavi Niemitalo
c4a23543fd SMJS: verbose comment about JS_AddNamedStringRoot 2012-11-25 21:06:09 +02:00
Kalle Olavi Niemitalo
d3022aa7be SMJS bookmark_set_property: Don't use JS_ValueToId.
Partially revert commits
a1c5fe51 (2011-05-08) bookmark_folder_get_property: xulrunner-2.0 fix
e86ec567 (2012-03-04) Compilation fixes (--enable-debug)

jsval_to_bookmark_string once again takes jsval val, rather than jsid id.
This way, bookmark_set_property does not have to call JS_ValueToId,
which would needlessly intern the new string value of the property,
i.e. the title or the URI.  Instead, bookmark_folder_get_property
has to call JS_IdToValue.
2012-11-19 02:53:14 +02:00
Kalle Olavi Niemitalo
380d910ad8 SMJS: Use JS_THIS_OBJECT and JS_CALLEE, not argv[-1] and argv[-2]
https://developer.mozilla.org/en-US/docs/SpiderMonkey/1.8.5 mentions
that JSNative functions must not use negative indices of argv in
SpiderMonkey 1.8.5.  Use the JS_THIS_OBJECT and JS_CALLEE macros
instead.  They are documented in
https://developer.mozilla.org/en-US/docs/SpiderMonkey/JSAPI_Reference/JSNative
2012-11-19 00:39:51 +02:00
Kalle Olavi Niemitalo
9e11e30fe3 bug 764, LUA: option_types[OPT_INT].set needs long *
l_set_option() was passing the address of an int to
option_types[OPT_INT].set and option_types[OPT_BOOL].set.
That looks correct but is not: both function pointers
point to num_set(), which actually reads *(long *) str.
Change l_set_option() to pass the address of a long instead,
and add comments about this dependency.
(cherry picked from elinks-0.11 commit 8766e3829f)
(cherry picked from elinks-0.12 commit 0797f04921)
2012-11-03 23:01:28 +02:00
Kalle Olavi Niemitalo
6f4c95cc7f Bug 943: Refuse user JS actions in unfocused tabs
(cherry picked from elinks-0.12 commit 51dc3beee7)

Conflicts:
	NEWS: Both 0.12pre5.GIT and 0.13.GIT had inserted a new section.
	src/terminal/window.c: Both had inserted a new function.
2012-11-03 22:10:27 +02:00
witekfl
e86ec567f2 Compilation fixes (--enable-debug) 2012-03-04 18:11:18 +01:00
Miciah Dashiel Butler Masters
c74ddb29c5 SMJS: add terminal object
Add terminal_class, which defines a JSObject wrapper for struct terminal.

Add terminal_array_class, which defines a JSObject wrapper for accessing
the "terminals" linked list of struct terminal.

Add session_array_class, which defines a JSObject wrapper for accessing the
tabs (sessions) of a terminal.

Add pointers from struct terminal to the terminal_class object and
the session_array_class object.

Add terminal_props and terminal_get_property for terminal_class.

Add terminal_finalize, which clears the pointers between a struct terminal
and the JSObject wrapper in question.

Add smjs_init_terminal_interface, which creates a terminal_array_class
instance and assigns it to  the "terminal" property on the "elinks" object.
Call smjs_init_terminal_interface from smjs_init_elinks_object.

Add smjs_get_terminal_object and smjs_get_session_array_object to get
the wrapper objects for a given struct terminal, and add
smjs_get_terminal_array_object to get a terminal_array_class object.

Add smjs_detach_terminal_object and smjs_detach_session_array_object, which
clear the pointers between a given struct terminal and its JSObject
wrappers.

Add terminal_array_get_property for terminal_array_class.

Add session_array_get_property for session_array_class.
2011-11-14 04:34:51 +00:00
Miciah Dashiel Butler Masters
cdad9adf19 SMJS: add session object
Add session_class, which defines a JSObject wrapper for struct session.

Add location_array_class, which defines a JSObject wrapper for struct
ses_history.  The "history" member of struct session is a struct
ses_history, which is a linked list of struct location.

Add a pointer from struct session to the session_class object and the
location_array object.

Add smjs_get_session_object to return a session_class JSObject wrapper for
a given struct session.

Add smjs_get_session_location_array_object to return a location_array_class
JSObject wrapper for a given struct session.

Add "session" property to the "elinks" object, which uses
smjs_get_session_object to get a JSObject wrapper for smjs_ses.

Add smjs_location_array_get_property, which allows indexing
a location_array object using a positive number for history forward or
a negative number for history backward.

Add session_props, session_get_property, session_set_property,
session_funcs, smjs_session_goto_url (which implements the "goto" method),
and smjs_init_session_interface for session_class.

Add session_construct, which creates a new tab and returns the JSObject
session_class wrapper.

Add session_finalize and smjs_location_array_finalize, which clear the
pointers between struct session and the JSObject wrappers in question.

Add smjs_detach_session_object, which clears the pointers between a given
struct session and the corresponding JSObject wrappers.

In destroy_session, call smjs_detach_session_object.

Add jsval_to_object helper in ecmascript/spidermonkey/util.h;
jsval_to_object is used in smjs_session_goto_url.

Modify delayed_goto_uri_frame to allow the target to be NULL.
smjs_session_goto_url needs this modification.
2011-11-14 04:34:51 +00:00