1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00
Commit Graph

344 Commits

Author SHA1 Message Date
Laurent MONIN
4b2b5798ab 2006-01-11 14:07:17 +01:00
Laurent MONIN
f7a2dfc12a CONFIG_LUA -> CONFIG_SCRIPTING_LUA 2006-01-11 14:06:13 +01:00
Jonas Fonseca
ccc6527bba Fix smjs scripting #ifdefs to use CONFIG_SM_SCRIPTING 2006-01-11 01:55:24 +01:00
Kalle Olavi Niemitalo
93714a3e35 Merge with http://elinks.cz/elinks.git 2006-01-06 02:13:11 +02:00
Miciah Dashiel Butler Masters
97b5b9cfe1 Check for hooks.js before trying to load it.
Check file_exists(path) before calling smjs_do_file(path)
in smjs_load_hooks to fix an error message when there is no hooks.js,
reported by zas.
2006-01-02 18:53:13 +00:00
Laurent MONIN
54997c506f Drop trailing whitespaces. 2006-01-02 00:15:20 +01:00
Kalle Olavi Niemitalo
345ba7afcd Merge with http://elinks.cz/elinks.git 2006-01-01 19:05:44 +02:00
Kalle Olavi Niemitalo
4c2831677a Here is a framework that detects cases where a PO file assigns
the same accelerator key to multiple buttons in a dialog box or
to multiple items in a menu.  ELinks already has some support for
this but it requires the translator to run ELinks and manually
scan through all menus and dialogs.  The attached changes make it
possible to quickly detect and list any conflicts, including ones
that can only occur on operating systems or configurations that
the translator is not currently using.

The changes have no immediate effect on the elinks executable or
the MO files.  PO files become larger, however.

The scheme works like this:

- Like before, accelerator keys in translatable strings are
  tagged with the tilde (~) character.

- Whenever a C source file defines an accelerator key, it must
  assign one or more named "contexts" to it.  The translations in
  the PO files inherit these contexts.  If multiple strings use
  the same accelerator (case insensitive) in the same context,
  that's a conflict and can be detected automatically.

- The contexts are defined with "gettext_accelerator_context"
  comments in source files.  These comments delimit regions where
  all translatable strings containing tildes are given the same
  contexts.  There must be one special comment at the top of the
  region; it lists the contexts assigned to that region.  The
  region automatically ends at the end of the function (found
  with regexp /^\}/), but it can also be closed explicitly with
  another special comment.  The comments are formatted like this:

    /* [gettext_accelerator_context(foo, bar, baz)]
         begins a region that uses the contexts "foo", "bar", and "baz".
         The comma is the delimiter; whitespace is optional.

       [gettext_accelerator_context()]
         ends the region.  */

  The scripts don't currently check whether this syntax occurs
  inside or outside comments.

- The names of contexts consist of C identifiers delimited with
  periods.  I typically used the name of a function that sets
  up a dialog, or the name of an array where the items of a
  menu are listed.  There is a special feature for static
  functions: if the name begins with a period, then the period
  will be replaced with the name of the source file and a colon.

- If a menu is programmatically generated from multiple parts,
  of which some are never used together, so that it is safe to
  use the same accelerators in them, then it is necessary to
  define multiple contexts for the same menu.  link_menu() in
  src/viewer/text/link.c is the most complex example of this.

- During make update-po:

  - A Perl script (po/gather-accelerator-contexts.pl) reads
    po/elinks.pot, scans the source files listed in it for
    "gettext_accelerator_context" comments, and rewrites
    po/elinks.pot with "accelerator_context" comments that
    indicate the contexts of each msgid: the union of all
    contexts of all of its uses in the source files.  It also
    removes any "gettext_accelerator_context" comments that
    xgettext --add-comments has copied to elinks.pot.

  - If po/gather-accelerator-contexts.pl does not find any
    contexts for some use of an msgid that seems to contain an
    accelerator (because it contains a tilde), it warns.  If the
    tilde refers to e.g. "~/.elinks" and does not actually mark
    an accelerator, the warning can be silenced by specifying the
    special context "IGNORE", which the script otherwise ignores.

  - msgmerge copies the "accelerator_context" comments from
    po/elinks.pot to po/*.po.  Translators do not edit those
    comments.

- During make check-po:

  - Another Perl script (po/check-accelerator-contexts.pl) reads
    po/*.po and keeps track of which accelerators have been bound
    in each context.  It warns about any conflicts it finds.
    This script does not access the C source files; thus it does
    not matter if the line numbers in "#:" lines are out of date.

This implementation is not perfect and I am not proposing to
add it to the main source tree at this time.  Specifically:

- It introduces compile-time dependencies on Perl and Locale::PO.
  There should be a configure-time or compile-time check so that
  the new features are skipped if the prerequisites are missing.

- When the scripts include msgstr strings in warnings, they
  should transcode them from the charset of the PO file to the
  one specified by the user's locale.

- It is not adequately documented (well, except perhaps here).

- po/check-accelerator-contexts.pl reports the same conflict
  multiple times if it occurs in multiple contexts.

- The warning messages should include line numbers, so that users
  of Emacs could conveniently edit the conflicting part of the PO
  file.  This is not feasible with the current version of
  Locale::PO.

- Locale::PO does not understand #~ lines and spews warnings
  about them.  There is an ugly hack to hide these warnings.

- Jonas Fonseca suggested the script could propose accelerators
  that are still available.  This has not been implemented.

There are three files attached:

- po/gather-accelerator-contexts.pl: Augments elinks.pot with
  context information.

- po/check-accelerator-contexts.pl: Checks conflicts.

- accelerator-contexts.diff: Makes po/Makefile run the scripts,
  and adds special comments to source files.
2006-01-01 18:55:18 +02:00
Miciah Dashiel Butler Masters
6a44d5192d Fix a typo in an error message in cache_entry_set_property: s/get/set/ 2005-12-29 22:31:25 +00:00
Miciah Dashiel Butler Masters
7f1711471f Drop an extra object_lock in bookmark_folder_get_property:
smjs_get_bookmark_object will lock the bookmark for us.
2005-12-29 22:19:19 +00:00
Miciah Dashiel Butler Masters
9e06b709d4 Return NULL when a script tries to get a bookmark that does not exist
in the given folder. (What was I thinking before?)
2005-12-29 22:18:45 +00:00
Miciah Dashiel Butler Masters
684bac3b22 Define do_file before loading hooks.js in case hooks.js wants to use
do_file immediately.
2005-12-29 14:24:00 +00:00
Miciah Dashiel Butler Masters
ae42c586f8 Add elinks.home property. 2005-12-29 14:19:09 +00:00
Miciah Dashiel Butler Masters
a4be153703 Generalise the error message from smjs_do_file by dropping 'default'
from 'error loading default script file'.
2005-12-29 13:54:26 +00:00
Miciah Dashiel Butler Masters
b52a29f8c0 Let smjs_do_file return 0 to indicate failure and 1 to indicate
success. Add smjs_do_file_wrapper and let ECMAScript load files with
do_file(path).
2005-12-29 13:48:02 +00:00
Miciah Dashiel Butler Masters
cb506ea412 Factor smjs_do_file out of smjs_load_hooks. 2005-12-29 13:27:12 +00:00
Miciah Dashiel Butler Masters
9d4893e384 Mark smjs_load_hooks static. 2005-12-29 13:26:38 +00:00
Miciah Dashiel Butler Masters
79cf499cf9 Use JS_PropertyStub instead of NULL where applicable in JSClass
definitions.
2005-12-29 07:25:04 +00:00
Miciah Dashiel Butler Masters
46b1db47a2 Check JS_TRUE == ... instead of JS_FALSE != ... in smjs_get_keymap_object. 2005-12-29 07:20:33 +00:00
Miciah Dashiel Butler Masters
1ba2b6931a Don't check CACHE_ENTRY_LENGTH in cache_entry_set_property since, as
Jonas pointed out, .length is read-only, so SpiderMonkey will never
pass the setter CACHE_ENTRY_LENGTH. Anyway, .uri is also read-only and
is not handled in the setter.
2005-12-29 07:19:15 +00:00
Miciah Dashiel Butler Masters
17b7ffc7df Add elinks.bookmarks interface for reading bookmarks. 2005-12-29 07:05:31 +00:00
Miciah Dashiel Butler Masters
81be17108b Understand a boolean true from elinks.goto_url_hook and
elinks.follow_url_hook to mean that the URI should be unchanged and that
further hooks should be permitted to run.
2005-12-28 07:12:09 +00:00
Miciah Dashiel Butler Masters
76d9b9de91 Add elinks.follow_url_hook. 2005-12-28 07:07:21 +00:00
Miciah Dashiel Butler Masters
d7c7736008 Add elinks.goto_url_hook. 2005-12-28 07:06:42 +00:00
Miciah Dashiel Butler Masters
c0fd25b368 Add a read-only .uri property to the cache_entry class. 2005-12-28 06:37:00 +00:00
Miciah Dashiel Butler Masters
1602bd5d29 Factor intdup out of smjs_get_keymap_object. 2005-12-26 11:07:15 +00:00
Jonas Fonseca
61185ff34e Make ECMAScript browser scripting configurable
Either set CONFIG_SM_SCRIPTING in features.conf or pass to ./configure the
option --disable-sm-scripting. Now scripting is also enabled when needed
and not only if some other scripting backend is enabled.

Remove some remnants of SEE scripting backend.
2005-12-25 02:23:54 +01:00
Miciah Dashiel Butler Masters
309f3d26f3 In smjs_get_keymap_object, free the private data JS_SetPrivate fails,
per fonseca's suggestion.
2005-12-24 18:07:55 +00:00
Miciah Dashiel Butler Masters
f46cdd8f03 Add elinks.location property to get and set the current URL. 2005-12-24 18:05:32 +00:00
Miciah Dashiel Butler Masters
d44a24050c Undo in favour of a nicer API... 2005-12-24 07:17:36 +00:00
Miciah Dashiel Butler Masters
054fb15ff0 Add an elinks.goto_url method. 2005-12-24 07:14:51 +00:00
Miciah Dashiel Butler Masters
330cd6b7ce Assign the given ses to smjs_ses while the ECMAScript callback runs in
smjs_keybinding_action_callback.
2005-12-24 07:01:17 +00:00
Miciah Dashiel Butler Masters
80a5467b8d Introduce get_action_from_keystroke and get_action_name_from_keystroke.
Introduce smjs_init_keybinding_interface, which creates elinks.keymaps.<map>
for <map> in "main", "edit", and "menu". elinks.keymaps.<map> is a hash
indexed by string representations of keystrokes, and can be used to get the
current action for a key and to set the action either to an internal ELinks
action or to an ECMAScript function.
2005-12-24 06:54:01 +00:00
Miciah Dashiel Butler Masters
92da153e13 Lock the struct cache_entry when creating the corresponding ECMAScript
object in smjs_get_cache_entry_object and unlock it in the new finalizer
cache_entry_finalize.
2005-12-24 04:07:32 +00:00
Miciah Dashiel Butler Masters
f8de70b8f6 Comment smjs_elinks_object. 2005-12-24 03:49:06 +00:00
Miciah Dashiel Butler Masters
9b645f9b66 Move smjs_elinks_object to elinks_object.h. 2005-12-24 03:48:57 +00:00
Miciah Dashiel Butler Masters
8743ec74d8 Factor the initialisation of smjs_elinks_global out of init_smjs and
into the new smjs_init_elinks_object.
2005-12-24 03:47:34 +00:00
Miciah Dashiel Butler Masters
60dd7515f9 Change smjs_get_elinks_object to use smjs_global_object instead of
an argument.
2005-12-24 03:43:53 +00:00
Miciah Dashiel Butler Masters
d6ecf895ce Make global_object a global with the new name smjs_global_object and
create smjs_init_global_object to initialise the global.
2005-12-24 03:40:59 +00:00
Miciah Dashiel Butler Masters
3174c533b0 Factor smjs_get_global_object out of init_smjs. 2005-12-24 03:39:24 +00:00
Miciah Dashiel Butler Masters
2a0653a9f2 Fix the comment heading to say ECMAScript instead of Ruby. 2005-12-22 23:45:12 +00:00
Miciah Dashiel Butler Masters
f6ce6c84f7 Rename get_cache_entry_object to smjs_get_cache_entry_object for great
consistency.
2005-12-20 22:13:29 +00:00
Miciah Dashiel Butler Masters
9e15d09340 NULL-terminate cache_entry_props. This and the last change resolves
crashes with GCC 2.x and 3.x reported by zas.
2005-12-20 22:10:59 +00:00
Miciah Dashiel Butler Masters
bb4f08172b In init_smjs, mark global_class static. 2005-12-20 22:09:56 +00:00
Miciah Dashiel Butler Masters
be76bed022 Check the return values of JS_SetPrivate and JS_DefineProperties in
get_cache_entry_object.
2005-12-20 10:44:51 +00:00
Miciah Dashiel Butler Masters
71fb9a1db7 Move smjs_invoke_elinks_object_method from hooks.c to elinks_object.c. 2005-12-20 05:26:55 +00:00
Miciah Dashiel Butler Masters
3302baca35 Rename call_script_hook to smjs_invoke_elinks_object_method and rename
its hook parameter to method.
2005-12-20 05:25:36 +00:00
Miciah Dashiel Butler Masters
f5b102cfea Assert smjs_ctx in get_cache_entry_object. 2005-12-19 21:33:10 +00:00
Miciah Dashiel Butler Masters
2e0907ff8d In script_hook_pre_format_html, check whether get_cache_entry_object
returns NULL.
2005-12-19 21:28:52 +00:00
Miciah Dashiel Butler Masters
2b6ef067be In init_smjs, destroy the runtime if JS_NewContext returns NULL. 2005-12-19 21:26:05 +00:00
Miciah Dashiel Butler Masters
fcd13e35cb Do nothing in cleanup_smjs is smjs_ctx is NULL. 2005-12-19 21:24:54 +00:00
Miciah Dashiel Butler Masters
11c90e7205 Add some assertions. 2005-12-19 21:24:27 +00:00
Miciah Dashiel Butler Masters
5ca5381fbc Rework smjs_load_hooks not to free path until it is done and to always
call done_string on the script string, even when add_file_to_string fails.
2005-12-19 19:08:34 +00:00
Jonas Fonseca
9bc71ec8a9 Retire the SEE-based *.js scripting backend 2005-12-19 01:22:32 +01:00
Miciah Dashiel Butler Masters
9fb9e8700d Predicate the SpiderMonkey scripting backend on CONFIG_SPIDERMONKEY
rather than on CONFIG_ECMASCRIPT.
2005-12-18 22:51:47 +00:00
Jonas Fonseca
fa124d0988 Merge with git+ssh://pasky.or.cz/srv/git/elinks.git 2005-12-18 23:49:15 +01:00
Miciah Dashiel Butler Masters
2fef4bd531 In cache_entry_get_property and cache_entry_set_property, use
cache_entry_is_valid to check that the reference to the struct cache_entry
is still valid. Thanks to fonseca for the reminder.
2005-12-18 22:47:58 +00:00
Jonas Fonseca
8ea7f202b1 #include "src/scripting/smjs/cache_object.h" 2005-12-18 22:17:48 +01:00
Jonas Fonseca
838e2ea0c9 Make all global variables exported by src/scripting/smjs/core.h extern 2005-12-18 19:57:03 +01:00
Miciah Dashiel Butler Masters
51322649fe Load the default script. 2005-12-18 18:02:32 +00:00
Miciah Dashiel Butler Masters
e3fed7e19e Add a pre-format-html hook. 2005-12-18 17:58:42 +00:00
Miciah Dashiel Butler Masters
30ccbaaf21 Add the elinks.alert method. 2005-12-18 17:49:21 +00:00
Miciah Dashiel Butler Masters
6e0d4374c1 Add the "elinks" object. 2005-12-18 17:47:54 +00:00
Miciah Dashiel Butler Masters
acb2bb80be Create a global object. 2005-12-18 17:40:13 +00:00
Miciah Dashiel Butler Masters
60d40b7f50 Initial skeleton for SpiderMonkey scripting backend. 2005-12-18 17:40:00 +00:00
Miciah Dashiel Butler Masters
dc29fa0a0b Add a missing bracket in report_scripting_error. 2005-12-18 15:32:11 +00:00
Jonas Fonseca
3dadc0ad46 Fix order of args passed to SEE_string_sprintf("%.*s") 2005-12-17 19:19:42 +01:00
Jonas Fonseca
6251884765 One more compile fix for evhook_use_param() macro usage 2005-12-17 18:36:46 +01:00
Jonas Fonseca
1e60feacb4 Compile fix for arg usage macro 2005-12-17 18:27:49 +01:00
Miciah Dashiel Butler Masters
5145ae266a Follow-up for commit fdacffd113: change
the Python, Ruby, and SEE hooks for pre-format-html to work properly
now that they are given a non-NUL-terminated string. Thanks to fonseca
for noticing this problem as well as that fixed by the previous commit.
2005-12-17 16:38:24 +00:00
Miciah Dashiel Butler Masters
fdacffd113 Change the pre-format event so that hooks are given the cache entry
instead of the URI, content, and length of the entry. Change the hooks
to use add_fragment. This should fix the memory leakage when multiple
hooks change the same document, closing bug 703.
2005-12-17 06:32:08 +00:00
Miciah Dashiel Butler Masters
35aa8119e3 In run_lua_func, pass handle_ref 0 for the unref flag so that bindings
will work more than once.
2005-12-17 01:42:20 +00:00
Miciah Dashiel Butler Masters
717b440f62 Add an unref flag to handle_ref so that the unreferencing is optional. 2005-12-17 01:36:26 +00:00
Miciah Dashiel Butler Masters
8edcb292cb In l_set_option, use lua_toboolean for boolean options instead of
lua_tonumber. Now set_option(opt, not get_option(opt)) will always work
to toggle a boolean option.
2005-12-17 00:31:45 +00:00
Laurent MONIN
3dd81f003e Fix trailing whitespaces. 2005-11-25 09:38:32 +01:00
Jonas Fonseca
acf2ec806b Remove empty lines in start of header files
A left over from the CVS Id removal. Also, for a few files, normalize the
order in which things are declared in headers.
2005-11-15 11:33:27 +01:00
Jonas Fonseca
aa07c4d848 Tidy up a bit 2005-10-26 22:39:12 +02:00
Jonas Fonseca
d7f002c8a1 Move code for the SEE object interface 2005-10-26 22:11:34 +02:00
Jonas Fonseca
1f69d4b931 Add support for navigator.preference() and navigator.savePreferences()
It required that the 'context' session was saved in see_ses (similarly to
the lua_ses variable)

Anyway, now you can use

	var opt_value = navigator.preference("ui.window_title)
	navigator.preference("ui.window_title", false)
	navigator.savePreferences()

to get and set optinos + save the changes.
2005-10-25 19:13:33 +02:00
Jonas Fonseca
7659f284ac Try to comply to the client-side javascript interface and not our own
Renames the following things:
ELinks.write() -> alert() or navigator.alert()
ELinks.version -> navigator.appVersion
ELinks.home    -> navigator.appHome

The last one is not defined by the client-side javascript interface.
2005-10-25 17:43:33 +02:00
Jonas Fonseca
bc0cc67fd9 Cleanup and improve error messaging
Script errors are now reported either with WDBG() at startup, ERROR()
if SEE decides to abort and using info_box() for everything else, including
script runtime errors.
2005-10-24 00:57:47 +02:00
Laurent MONIN
df065ead80 Remove now useless $Id: lines. 2005-10-21 09:14:07 +02:00
Jonas Fonseca
03118059ee Move and make sense of the common code 2005-10-21 04:07:43 +02:00
Jonas Fonseca
0ba773e7a5 Add the basics for _browser_ (ecma)scripting ELinks with SEE
SEE is David Leonard's Simple Ecmascript Engine.  The SEE scripting backend
is very raw and not tested very much. The idea was to see what kind of
creature SEE is (and contradict pasky's aired opinion that no new features
are added anymore ;).

echo 'function goto_url() { return 'localhost'; }' > ~/.elinks/hooks.js
and get local for maximum security ...

FYI: SEE is smaller than Spidermonkey but doesn't have the same kind of
data-driven interface, although it looks like it is possible to build that.
2005-10-20 20:38:01 +02:00
Jonas Fonseca
c88afeb1c2 path_to_top -> top_builddir 2005-10-20 04:00:35 +02:00
Jonas Fonseca
e39a4342d6 Include $(top_srcdir)/Makefile.lib instead of $(path_to_top)/Makefile.lib
A step towards out of tree builds ...
2005-10-20 01:11:47 +02:00
Jonas Fonseca
c76586e6b8 Simplify the conditional building
Use the very cool 'VAR-$(CONFIG_FOO) += foo.o' feature instead of the more
verbose current ifeq($(CONFIG_FOO),yes) wrapping.
2005-09-27 22:49:47 +02:00
Jonas Fonseca
68de9e35d3 Automagically link in subdir lib.o files
It is a little ugly since I couldn't get $(wildcard) to expand *.o files
so it just checks if there are any *.c files and then link in the lib.o
based on that.
2005-09-27 22:38:00 +02:00
Jonas Fonseca
1efab31581 Simplify building of and linking with directories
Ditch the building of an archive (.a) in favour of linking all objects in a
directory into a lib.o file. This makes it easy to link in subdirectories
and more importantly keeps the build logic in the local subdirectories.

Note: after updating you will have to rm **/*.a if you do not make clean
before updating.
2005-09-27 21:38:58 +02:00
Jonas Fonseca
b30064c0d0 Rename targets: *-l -> *-local 2005-09-27 21:11:28 +02:00
Petr Baudis
c89190e0bf ELBuildized scripting/. 2005-09-16 13:29:06 +02:00
Petr Baudis
1f0cd14e91 Converted another bunch of submakefiles to ELBuild 2005-09-16 04:07:37 +02:00
Jonas Fonseca
7462f22635 Remove now obsolete .cvsignore files. 2005-09-15 18:33:20 +02:00
Petr Baudis
0f6d4310ad Initial commit of the HEAD branch of the ELinks CVS repository, as of
Thu Sep 15 15:57:07 CEST 2005. The previous history can be added to this
by grafting.
2005-09-15 15:58:31 +02:00