You are not logged in.
quigybo wrote:- can we get text zoom as well as page zoom?
As for text zooming check out the "full-content-zoom" webview property here.
For the lazy: text zoom & full content zoom binds.
Offline
Why not make searchopen return the uri to load and then do this:
cmd({"tabopen", "t" }, function (w, a) w:new_tab(searchopen(a)) end),
Jolly good idea .
searchopen = function (a)
local sep = string.find(a, " ") or #a+1
local engine = string.sub(a, 1, sep-1)
local search = string.sub(a, sep+1)
if string.match(engine, "%.") then
return a
elseif search_engines[engine] then
proto = search_engines[engine]
else
proto = search_engines["google"]
search = engine .. " " .. search
end
search = string.gsub(search, "^%s*(.-)%s*$", "%1")
local uri = string.gsub(proto, "{%d}", search)
return uri
end
Works nicely with open, tabopen and winopen now . It simply returns a uri, what you do with it is up to you. It is basically the bastardised love child of my original searchopen and your websearch functions.
Offline
Really nice browser! Thanks for sharing.
What I personally would love to see is the possibility to have character hints (instead of numbers) and still be able to search through links labels like the char-hints-plugin for vimperator does.
Offline
Really nice browser! Thanks for sharing.
What I personally would love to see is the possibility to have character hints (instead of numbers) and still be able to search through links labels like the char-hints-plugin for vimperator does.
I've heard this comment a few times but I'm not sure how to integrate that into our current following script (which already supports partial link label matching).
On the topic of following: I've just added Tab & Return bindings to the following script which allow you to cycle through the remaining following tags and follow the currently focused tag (exactly like vimperator)[0]
Offline
I've run into the problem where a page was using framesets, and I can't scroll the text, for example http://www.r-project.org. For some reason, the stock hint follow script doesn't seem to work with framesets either. Any way to give focus to the main frame?
Offline
I've run into the problem where a page was using framesets, and I can't scroll the text, for example http://www.r-project.org. For some reason, the stock hint follow script doesn't seem to work with framesets either. Any way to give focus to the main frame?
Ok I've found a partial solution. Using the following patch all javascript is evaluated on the currently focused frame by default (instead of the main frame). This fixes the link hinting following problem however you still need to focus the correct frame initially. This patch would work well with an `auto-focus-frame` script (if we can source one then I'll push this patch).
diff --git a/config/webview.lua b/config/webview.lua
index fa6dc26..7efa9c5 100644
--- a/config/webview.lua
+++ b/config/webview.lua
@@ -217,17 +217,17 @@ webview.methods = {
end,
-- evaluate javascript code and return string result
- eval_js = function (view, w, script, file)
- return view:eval_js(script, file or "(inline)")
+ eval_js = function (view, w, script, file, on_focused)
+ return view:eval_js(script, file or "(inline)", (on_focused == nil and true) or on_focused)
end,
-- evaluate javascript code from file and return string result
- eval_js_from_file = function (view, w, file)
+ eval_js_from_file = function (view, w, file, on_focused)
local fh, err = io.open(file)
if not fh then return error(err) end
local script = fh:read("*a")
fh:close()
- return view:eval_js(script, file)
+ return view:eval_js(script, file, (on_focused == nil and true) or on_focused)
end,
-- Toggle source view
diff --git a/widgets/webview.c b/widgets/webview.c
index dd3e27b..510181c 100644
--- a/widgets/webview.c
+++ b/widgets/webview.c
@@ -147,8 +147,7 @@ webview_init_properties() {
}
static const gchar*
-webview_eval_js(WebKitWebView *view, const gchar *script, const gchar *file) {
- WebKitWebFrame *frame;
+webview_eval_js(WebKitWebFrame *frame, const gchar *script, const gchar *file) {
JSGlobalContextRef context;
JSObjectRef globalobject;
JSStringRef js_file;
@@ -159,7 +158,6 @@ webview_eval_js(WebKitWebView *view, const gchar *script, const gchar *file) {
GString *result = g_string_new(NULL);
size_t js_result_size;
- frame = webkit_web_view_get_main_frame(WEBKIT_WEB_VIEW(view));
context = webkit_web_frame_get_global_context(frame);
globalobject = JSContextGetGlobalObject(context);
@@ -231,13 +229,21 @@ webview_eval_js(WebKitWebView *view, const gchar *script, const gchar *file) {
static gint
luaH_webview_eval_js(lua_State *L)
{
+ WebKitWebFrame *frame = NULL;
widget_t *w = luaH_checkudata(L, 1, &widget_class);
WebKitWebView *view = WEBKIT_WEB_VIEW(g_object_get_data(G_OBJECT(w->widget), "webview"));
const gchar *script = luaL_checkstring(L, 2);
const gchar *filename = luaL_checkstring(L, 3);
+ /* Check if js should be run on currently focused frame (default) */
+ if (lua_gettop(L) < 4 || luaH_checkboolean(L, 4))
+ frame = webkit_web_view_get_focused_frame(view);
+ /* Fall back on main frame */
+ if (!frame)
+ frame = webkit_web_view_get_main_frame(WEBKIT_WEB_VIEW(view));
+
/* evaluate javascript script and push return result onto lua stack */
- const gchar *result = webview_eval_js(view, script, filename);
+ const gchar *result = webview_eval_js(frame, script, filename);
lua_pushstring(L, result);
return 1;
}
Offline
Thanks mason!
Offline
Let's suppose I want to use the chromium engine (instead of webkit) with the luakit framework. Is there any possibility to do that?
You may wonder why... 2 reasons:
1. Learning
2. Chrome Extensions
Thanks!
Offline
I think it's impossible for the moment, even though chromium is based on webkit it doesn't provide a separated library.
A Chromium extension is javascript, isn't it ? You can have few of them working on luakit I think (but maybe I'm wrong).
Sorry in advance for my poor english...
Offline
I think it's impossible for the moment, even though chromium is based on webkit it doesn't provide a separated library.
A Chromium extension is javascript, isn't it ? You can have few of them working on luakit I think (but maybe I'm wrong).
Chromium has a working isolated worlds feature in their webkit fork which is something that the webkit-gtk guys to not have. This means it is almost impossible to have bidirectional communication from javascript <-> lua securely in luakit (this is why uzbl had to remove the Uzbl.run method which allowed arbitrary code execution from javascript).
Offline
Chippeur wrote:I think it's impossible for the moment, even though chromium is based on webkit it doesn't provide a separated library.
A Chromium extension is javascript, isn't it ? You can have few of them working on luakit I think (but maybe I'm wrong).
Chromium has a working isolated worlds feature in their webkit fork which is something that the webkit-gtk guys to not have. This means it is almost impossible to have bidirectional communication from javascript <-> lua securely in luakit (this is why uzbl had to remove the Uzbl.run method which allowed arbitrary code execution from javascript).
Then... what about firefox engine? Would be awesome to have a luafox!
Offline
mason.larobina wrote:Chippeur wrote:I think it's impossible for the moment, even though chromium is based on webkit it doesn't provide a separated library.
A Chromium extension is javascript, isn't it ? You can have few of them working on luakit I think (but maybe I'm wrong).
Chromium has a working isolated worlds feature in their webkit fork which is something that the webkit-gtk guys to not have. This means it is almost impossible to have bidirectional communication from javascript <-> lua securely in luakit (this is why uzbl had to remove the Uzbl.run method which allowed arbitrary code execution from javascript).
Then... what about firefox engine? Would be awesome to have a luafox!
There is nothing stopping you, the only hard-limitation is gtk+ (unless you replace all the files in the widgets folders with their XXX equivalents). Can gecko interface with gtk widgets?
The only webkit specific code is inside widgets/webview.c, you can replace that with anything you like (provided you can reproduce most of the functionality). If done correctly with either the chromium engine (which is just a modified webkit) or gecko you might not have to modify the default config at all (aside from `sed -i -e "s/webview/other/g" config/*.lua`).
But why?
Offline
Let's say I'm just curious about lua capabilities and browser engines!
I will try to do something later. Thanks for your help!
Offline
Holy crap luakit has made leaps and bounds in terms of usability in the last week. I am loving that most of vimperators day-to-day features are here now, especially [[, ]], gu, gU and the extended link following modes. Tab and enter in follow mode were awesome enough, but the new "F*" are incredible. Being able to follow images is something I have wished vimperator did for a very long time. Thanks!
One minor gripe though, I use "F" (follow in new tab) alot so I changed the key bindings a little ("Ff" probably could have been ";f" but ";;" is rather ingrained from vimperator - change as you see fit):
diff --git a/follow.lua b/follow.lua
index 95dfadb..299b88f 100755
--- a/follow.lua
+++ b/follow.lua
@@ -364,17 +364,18 @@ local mode_binds, join, buf, key = binds.mode_binds, lousy.util.table.join, lous
mode_binds.normal = join(mode_binds.normal or {}, {
-- w:start_follow(mode, prompt, callback)
buf("^f$", function (w) w:start_follow("follow", nil, function (sig) return sig end) end),
- buf("^Ff$", function (w) w:start_follow("focus", "focus", function (sig) return sig end) end),
- buf("^Fy$", function (w) w:start_follow("uri", "yank", function (uri) w:set_selection(uri) return "root-active" end) end),
- buf("^FY$", function (w) w:start_follow("desc", "yank description", function (desc) w:set_selection(desc) return "root-active" end) end),
- buf("^Fs$", function (w) w:start_follow("uri", "download", function (uri) w:download(uri) return "root-active" end) end),
- buf("^Fi$", function (w) w:start_follow("image", "open image", function (src) w:navigate(src) return "root-active" end) end),
- buf("^Fo$", function (w) w:start_follow("uri", "open", function (uri) w:navigate(uri) return "root-active" end) end),
- buf("^Ft$", function (w) w:start_follow("uri", "new tab", function (uri) w:new_tab(uri) return "root-active" end) end),
- buf("^Fw$", function (w) w:start_follow("uri", "new window", function (uri) window.new{uri} return "root-active" end) end),
- buf("^FO$", function (w) w:start_follow("uri", "open cmd", function (uri) w:enter_cmd(":open "..uri) end) end),
- buf("^FT$", function (w) w:start_follow("uri", "tabopen cmd", function (uri) w:enter_cmd(":tabopen "..uri) end) end),
- buf("^FW$", function (w) w:start_follow("uri", "winopen cmd", function (uri) w:enter_cmd(":winopen "..uri) end) end),
+ buf("^F$", function (w) w:start_follow("uri", "new tab", function (uri) w:new_tab(uri) return "root-active" end) end),
+ buf("^;;$", function (w) w:start_follow("focus", "focus", function (sig) return sig end) end),
+ buf("^;y$", function (w) w:start_follow("uri", "yank", function (uri) w:set_selection(uri) return "root-active" end) end),
+ buf("^;Y$", function (w) w:start_follow("desc", "yank description", function (desc) w:set_selection(desc) return "root-active" end) end),
+ buf("^;s$", function (w) w:start_follow("uri", "download", function (uri) w:download(uri) return "root-active" end) end),
+ buf("^;i$", function (w) w:start_follow("image", "open image", function (src) w:navigate(src) return "root-active" end) end),
+ buf("^;o$", function (w) w:start_follow("uri", "open", function (uri) w:navigate(uri) return "root-active" end) end),
+ buf("^;t$", function (w) w:start_follow("uri", "new tab", function (uri) w:new_tab(uri) return "root-active" end) end),
+ buf("^;w$", function (w) w:start_follow("uri", "new window", function (uri) window.new{uri} return "root-active" end) end),
+ buf("^;O$", function (w) w:start_follow("uri", "open cmd", function (uri) w:enter_cmd(":open "..uri) end) end),
+ buf("^;T$", function (w) w:start_follow("uri", "tabopen cmd", function (uri) w:enter_cmd(":tabopen "..uri) end) end),
+ buf("^;W$", function (w) w:start_follow("uri", "winopen cmd", function (uri) w:enter_cmd(":winopen "..uri) end) end),
})
-- Add follow mode binds
mode_binds.follow = join(mode_binds.follow or {}, {
You had to expect somebody to do it? Out of curiousity, why are these defined in lib/follow.lua instead of binds.lua?
One minor request: in vimperator in follow mode, when typing out the first few letters of a link, once a unique match has been found the next few keystrokes are caught and not interpreted. This allows you to type more than needed for a match without worrying about accidentally typing any commands. Is some kind of a timeout feasible/reasonable to implement?
One more: when a link is focussed using "Ff"/";;" can the uri of that link be printed somewhere temporarily? I used this a lot in vimperator to check the validity of a link before following it. I had a quick play but follow.evaluators["focus"] returns "{root,form}-active" instead of a uri, but wasn't too sure if I could change that...
Offline
Holy crap luakit has made leaps and bounds in terms of usability in the last week. I am loving that most of vimperators day-to-day features are here now, especially [[, ]], gu, gU and the extended link following modes. Tab and enter in follow mode were awesome enough, but the new "F*" are incredible. Being able to follow images is something I have wished vimperator did for a very long time. Thanks!
One minor gripe though, I use "F" (follow in new tab) alot so I changed the key bindings a little ("Ff" probably could have been ";f" but ";;" is rather ingrained from vimperator - change as you see fit):
diff --git a/follow.lua b/follow.lua index 95dfadb..299b88f 100755 --- a/follow.lua +++ b/follow.lua @@ -364,17 +364,18 @@ local mode_binds, join, buf, key = binds.mode_binds, lousy.util.table.join, lous mode_binds.normal = join(mode_binds.normal or {}, { -- w:start_follow(mode, prompt, callback) buf("^f$", function (w) w:start_follow("follow", nil, function (sig) return sig end) end), - buf("^Ff$", function (w) w:start_follow("focus", "focus", function (sig) return sig end) end), - buf("^Fy$", function (w) w:start_follow("uri", "yank", function (uri) w:set_selection(uri) return "root-active" end) end), - buf("^FY$", function (w) w:start_follow("desc", "yank description", function (desc) w:set_selection(desc) return "root-active" end) end), - buf("^Fs$", function (w) w:start_follow("uri", "download", function (uri) w:download(uri) return "root-active" end) end), - buf("^Fi$", function (w) w:start_follow("image", "open image", function (src) w:navigate(src) return "root-active" end) end), - buf("^Fo$", function (w) w:start_follow("uri", "open", function (uri) w:navigate(uri) return "root-active" end) end), - buf("^Ft$", function (w) w:start_follow("uri", "new tab", function (uri) w:new_tab(uri) return "root-active" end) end), - buf("^Fw$", function (w) w:start_follow("uri", "new window", function (uri) window.new{uri} return "root-active" end) end), - buf("^FO$", function (w) w:start_follow("uri", "open cmd", function (uri) w:enter_cmd(":open "..uri) end) end), - buf("^FT$", function (w) w:start_follow("uri", "tabopen cmd", function (uri) w:enter_cmd(":tabopen "..uri) end) end), - buf("^FW$", function (w) w:start_follow("uri", "winopen cmd", function (uri) w:enter_cmd(":winopen "..uri) end) end), + buf("^F$", function (w) w:start_follow("uri", "new tab", function (uri) w:new_tab(uri) return "root-active" end) end), + buf("^;;$", function (w) w:start_follow("focus", "focus", function (sig) return sig end) end), + buf("^;y$", function (w) w:start_follow("uri", "yank", function (uri) w:set_selection(uri) return "root-active" end) end), + buf("^;Y$", function (w) w:start_follow("desc", "yank description", function (desc) w:set_selection(desc) return "root-active" end) end), + buf("^;s$", function (w) w:start_follow("uri", "download", function (uri) w:download(uri) return "root-active" end) end), + buf("^;i$", function (w) w:start_follow("image", "open image", function (src) w:navigate(src) return "root-active" end) end), + buf("^;o$", function (w) w:start_follow("uri", "open", function (uri) w:navigate(uri) return "root-active" end) end), + buf("^;t$", function (w) w:start_follow("uri", "new tab", function (uri) w:new_tab(uri) return "root-active" end) end), + buf("^;w$", function (w) w:start_follow("uri", "new window", function (uri) window.new{uri} return "root-active" end) end), + buf("^;O$", function (w) w:start_follow("uri", "open cmd", function (uri) w:enter_cmd(":open "..uri) end) end), + buf("^;T$", function (w) w:start_follow("uri", "tabopen cmd", function (uri) w:enter_cmd(":tabopen "..uri) end) end), + buf("^;W$", function (w) w:start_follow("uri", "winopen cmd", function (uri) w:enter_cmd(":winopen "..uri) end) end), }) -- Add follow mode binds mode_binds.follow = join(mode_binds.follow or {}, {
Thanks, I'll change these around to make it friendlier for vimperator users.
You had to expect somebody to do it? Out of curiousity, why are these defined in lib/follow.lua instead of binds.lua?
Because the user can remove following support entirely or switch and change out following scripts with a simple `require "my_follow"` without having to update ~200 or so lines in other files (notice the mode configuration also below the table of modes). In this way everything following related is self contained and we will be continuing this trend with other luakit scripts/libs.
One minor request: in vimperator in follow mode, when typing out the first few letters of a link, once a unique match has been found the next few keystrokes are caught and not interpreted. This allows you to type more than needed for a match without worrying about accidentally typing any commands. Is some kind of a timeout feasible/reasonable to implement?
This has also been annoying me. I have a few ideas how to fix it, I'll get back to you.
One more: when a link is focussed using "Ff"/";;" can the uri of that link be printed somewhere temporarily? I used this a lot in vimperator to check the validity of a link before following it. I had a quick play but follow.evaluators["focus"] returns "{root,form}-active" instead of a uri, but wasn't too sure if I could change that...
I suggest creating a custom set of following binds using the "uri" follow mode (which returns the uri of the "followed" element) then use the uri given to the callback function however you wish. For example:
buf("^f$", function (w) w:start_follow("uri", "check open", function (uri)
if check_uri(uri) then
w:navigate(uri)
return "root-active"
end
end) end),
Last edited by mason.larobina (2010-09-11 22:52:20)
Offline
Hi,
just wanted to say big thank you for such a great browser. What in Vimperator bothered me a lot is its slugishness and uzbl was not as usable and dynamic as I wanted it to be, especially the tabbing implementation. So thank you very much for such a great browser.
One thing though that I miss is a possibility to open urls in a new tab in a running instance of luakit. I search in the issues page on luakit.org, but could not find anything related. Would it be very hard to implement? A command line switch should be enough, I guess.
Thanks again
Offline
Liuutas
A middle click will open url's in new tab and if you are using follow it was JUST added to use new tabs.
See http://luakit.org/issues/10. to get it you may need to be using the develop-git branch from AUR
PLEASE read and try to FIX/FILE BUGS instead of assuming other have/will.
Offline
Liuutas
A middle click will open url's in new tab and if you are using follow it was JUST added to use new tabs.
See http://luakit.org/issues/10. to get it you may need to be using the develop-git branch from AUR
I think Liuuutas was talking about the ability to call `luakit -u google.com` and have it detect any running instances and open a new tab in that instance otherwise launch a new window.
Offline
Upon re-reading his post I'm sure you are correct. Too early, that what I get for posting before coffee.
PLEASE read and try to FIX/FILE BUGS instead of assuming other have/will.
Offline
Precicely, but I guess the following behaviour would be better:
luakit -u google.com - opens link in the most recent instance of luakit (default)
luakit -un google.com - opens link in new instance of luakit
As of precise names for command-line switches it does not matter, but I think, that it would be great for the user to decide whether he wants to open the URI in a new instance of luakit or not. However, I think that the default behaviour should be to open links in the "freshest" (opened most recently) instance of luakit and that the behaviour which is observed now should be optional.
Last edited by Liuuutas (2010-09-12 14:16:45)
Offline
I have a little problem! When pressing f (or the new Ff, Ft, ...) I don't get any numbers on the links in the current page. In short, hinting doesn't work. I use a clean luakit with all configs etc removed, but it doesn't work. I tried luakit-git and luakit-develop-git, same problem. Am I missing something or is there something really broken?
Offline
I have a little problem! When pressing f (or the new Ff, Ft, ...) I don't get any numbers on the links in the current page. In short, hinting doesn't work. I use a clean luakit with all configs etc removed, but it doesn't work. I tried luakit-git and luakit-develop-git, same problem. Am I missing something or is there something really broken?
Have you tried different pages? Because on some pages I found it not working as well (usually when there were any frames on the page).
Offline
Well I tried it on the start page luakit.org and several others, it works on none of them. But typing random numbers actually causes an action, which means, the numbers aren't visible, but the hinting works.
Offline
I use a clean luakit with all configs etc removed,
I ASSume you mean you have NO configs in ~/.config/luakit/*.lua, correct? If that is the case next thing I would try is manually rm /etc/xdg/luakit/* and then re-install luakit-develop-git just in case something is STUCK there. Not sure what else it could be but wonky config.
If it persists from there perhaps some WM issue?? (just guessing off hand)
PLEASE read and try to FIX/FILE BUGS instead of assuming other have/will.
Offline
I also don't get any numbers with libkit-git, but stable version works fine
Offline