[Conkeror] Scrolling eye guide

marting at gmx.ch marting at gmx.ch
Tue Aug 12 13:43:19 PDT 2008


Hi all,

In the firefox based conkeror there was a command called
"toggle-eod-space" "that should help you read articles more smoothly"
(see content/help.html where it is still documented). As far as I know
there's no equivalent functionality in the xulrunner based conkeror so
far. That's why I wrote the function below named after the similar
feature in GNU gv. It scrolls down a page and draws a temporary
horizontal line where you supposedly were reading before
scrolling. The options are documented.

I'm not familiar with the conkeror source nor xul (and not much with
javascript either) so the code could be bad; please tell me if you
think this is the case.

*** start code ***

define_variable("scr_eye_gui_interval", 800, 
 "Interval during which the scrolling eye guide line is visible (in ms)");
define_variable("scr_eye_gui_color", "#000000",
 "Color of the scrolling eye guide line");
define_variable("scr_eye_gui_opt", "end",
 "'on'/'off'/'end', where 'end' means that the scrolling eye guide line" +
 "becomes visible only when scrolling not a whole page, i.e. at the end" +
 "of the buffer; while 'on' means that it becomes visible in any case; " +
 "'off' (or anything else) disables the scrolling eye guide");

interactive("scroll-with-eye-guide", function(I) {
    var win = I.window.buffers.current.focused_frame;
    var old_y = win.scrollY;
    win.scrollBy(0, win.innerHeight - 50);
    var new_y = win.scrollY;
    if (new_y > old_y && (scr_eye_gui_opt == "on" ||
			  (scr_eye_gui_opt == "end" && 
			   new_y < old_y + win.innerHeight - 50))){
        //mostly copied from hints.js:
	var scr_eye_gui = win.document.createElementNS(XHTML_NS, "span");
	scr_eye_gui.className = "__conkeror_img_hint";
	scr_eye_gui.style.width = (win.innerWidth - 16) + "px";
	scr_eye_gui.style.height = "1px";
	scr_eye_gui.style.backgroundColor = scr_eye_gui_color;
	scr_eye_gui.style.left = "0px";
	scr_eye_gui.style.top = (old_y + win.innerHeight) + "px";
	//notice that the line is 16px off if there is a horizontal
	//scrollbar; I don't know if there is a reliable method to
	//detect a scrollbar
	win.document.documentElement.appendChild(scr_eye_gui);
	scr_eye_gui.textContent = "";
	scr_eye_gui.style.display = "inline";
        win.setInterval(function () {
		scr_eye_gui.style.display="none";
	    }, scr_eye_gui_interval);
    }});

*** end code ***

You can then bind it as usual, e.g. to space:

define_key(content_buffer_normal_keymap, "space", "scroll-with-eye-guide");

--
Martin


More information about the Conkeror mailing list