[Vimperator] Print preview and page setup plugin

Itai Fiat itai.fiat at gmail.com
Mon Apr 7 08:04:17 PDT 2008


This is my first post on this mailing list, and, first and foremost, I
would like to say that that vimperator is awesome. In light of my
dependence on it, I've been toying with creating a plugin (see below,
or attachment) to allow print preview and print page setup. It mostly
works - :psetup opens the page setup dialog, and :preview toggles
preview mode. Both a question and an issue remain, however:
* Should the print preview toolbar be hidden when preview mode is
toggled using vimperator? Should this depend on guioptions?
* How can one disable all vimperator commands, except movement, during
preview mode? Calling :tabnext or :quit, for example, when in preview
mode, has unexpected results. This is also an issue when print preview
is toggled using the GUI, so it might be worth tackling outside this
plugin.

Itai


Code:

(function(){
    vimperator.commands.add(
        new vimperator.Command(
            ["psetup"],
            function() {
                PrintUtils.showPageSetup();
            },
            {
                usage: ["psetup"],
                shortHelp: 'Print page setup',
                help: "Opens page setup dialog.",
            }
        )
    );

    vimperator.commands.add(
        new vimperator.Command(
            ["preview"],
            function() {
                if(!document.getElementById("print-preview-toolbar")) {
                    PrintUtils.printPreview();
                } else {
                    PrintUtils.exitPrintPreview();
                };
            },
            {
                usage: ["preview"],
                shortHelp: 'Toggle print preview',
                help: "Toggles print preview."
            }
        )
    );
})();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: printing.js
Type: application/x-javascript
Size: 885 bytes
Desc: not available
Url : http://www.mozdev.org/pipermail/vimperator/attachments/20080407/cb5018cc/attachment.js 


More information about the Vimperator mailing list