mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Bug 1027, SMJS: make null mean "none" in elinks.keymaps
elinks.keymaps.main["/"] = null; used to crash ELinks with a segfault in JS_ObjectIsFunction. Fix that by recognizing JSVAL_NULL explicitly and treating it as "none". Likewise, if keymap_get_property would return "none" to ECMAScript, return JSVAL_NULL instead.
This commit is contained in:
parent
5251441fdc
commit
fd27acf784
2
NEWS
2
NEWS
@ -181,6 +181,8 @@ ELinks 0.11.4.GIT now:
|
||||
|
||||
To be released as 0.11.5.
|
||||
|
||||
* critical bug 1027 in user SMJS: make elinks.keymaps treat null and
|
||||
"none" as equivalent actions, avoiding a segfault
|
||||
* build bug 1021: fixed uninitialized variable in http_got_header
|
||||
|
||||
ELinks 0.11.4:
|
||||
|
@ -244,12 +244,21 @@ rather than save it in a variable and call it later.
|
||||
Currently, there are three: 'elinks.keymaps.main', 'elinks.keymaps.edit',
|
||||
and 'elinks.keymaps.menu'. These elements are also hashes, the elements of
|
||||
which correspond to bindings. For example, `elinks.keymaps.main["q"]` is
|
||||
the binding to the ``q'' key in the main map. These bindings can be red,
|
||||
to get the name of the action to which the key is bound, or set, either
|
||||
to a string with the name of the ELinks action or to a function, which will
|
||||
thenceforth be called when the key is pressed. For example,
|
||||
the binding to the ``q'' key in the main map. These bindings can be read,
|
||||
to get the name of the action to which the key is bound, or set to one of:
|
||||
+
|
||||
--
|
||||
- A string with the name of the ELinks action.
|
||||
- A function, which will thenceforth be called when the key is pressed.
|
||||
- The string `"none"`, to unbind the key. You can also use the `null`
|
||||
value for this purpose, but that crashes ELinks 0.11.4 and 0.12pre1
|
||||
(http://bugzilla.elinks.cz/show_bug.cgi?id=1027[bug 1027]),
|
||||
so it may be best to use the string for now.
|
||||
--
|
||||
+
|
||||
--
|
||||
For example,
|
||||
|
||||
----------------------------------------------------------------------
|
||||
elinks.keymaps.main["!"] = function () { elinks.alert("Hello!"); }
|
||||
----------------------------------------------------------------------
|
||||
@ -264,7 +273,7 @@ elinks.keymaps.main["/"] = "search-typeahead-text";
|
||||
changes the ``/'' key to use the nice typeahead search function instead of
|
||||
opening that ugly old search dialogue box.
|
||||
|
||||
*Compatibility:* ELinks 0.11.0
|
||||
*Compatibility:* ELinks 0.11.0, unless you use `null`.
|
||||
|
||||
NOTE: Do not read a function from <<smjs-elinks.action,'elinks.action'>>,
|
||||
e.g. `elinks.action.search_typeahead_text`, and place it in a keymap.
|
||||
|
@ -37,7 +37,7 @@ keymap_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
|
||||
action_str = get_action_name_from_keystroke((enum keymap_id) *data,
|
||||
keystroke_str);
|
||||
if (!action_str) goto ret_null;
|
||||
if (!action_str || !strcmp(action_str, "none")) goto ret_null;
|
||||
|
||||
*vp = STRING_TO_JSVAL(JS_NewStringCopyZ(ctx, action_str));
|
||||
|
||||
@ -106,6 +106,12 @@ keymap_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
|
||||
return JS_TRUE;
|
||||
|
||||
} else if (JSVAL_IS_NULL(*vp)) { /* before JSVAL_IS_OBJECT */
|
||||
if (bind_do(keymap_str, keystroke_str, "none", 0))
|
||||
return JS_FALSE;
|
||||
|
||||
return JS_TRUE;
|
||||
|
||||
} else if (JSVAL_IS_OBJECT(*vp)) {
|
||||
unsigned char *err = NULL;
|
||||
int event_id;
|
||||
|
Loading…
Reference in New Issue
Block a user