lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 14 September 2012 19:01, Matthew Wild <mwild1@gmail.com> wrote:
> On 13 September 2012 10:21, Mason Larobina <mason.larobina@gmail.com> wrote:
>> Hi list,
>>
>> A new luakit version has been released, changelog can be found here:
>>
>>   http://mason-larobina.github.com/luakit/news/luakit-2012.09.13.html
>
> Great to know the project is still going well! This is definitely one
> of my favourite uses of Lua in an everyday user application.

Thanks, it's certainly been fun to build & use (apart from libwebkit
annoyances).

> The changelog says you can now call into Lua from Javascript. Is it
> possible to go the other way, and also to override existing JS APIs?

Yes but I wouldn't recommend replacing any DOM API functions.

To illustrate, in a luakit instance run:

    :lua w.view:register_function("string_format", string.format);

Which will eval the given argument as Lua code & set the variable
`string_format` to the Lua library function `string.format` in the
global context on the currently focused tab.

An easy way to interactively test this is opening the
WebKitWebInspector (`:inspect`) and in the console tab run:

    > string_format("A number %d, a string %s", 100, "called Wanda.")
    "A number 100, a string called Wanda."

> Regards,
> Matthew