diff options
| author | 2013-02-11 23:04:53 +0100 | |
|---|---|---|
| committer | 2013-02-11 23:04:53 +0100 | |
| commit | 6fdc8f2f5ab88b0ce0077a2450af215992e1d23c (patch) | |
| tree | ec948d8789f1720b67972d64ef1d20169a0bbe25 /conkeror | |
| parent | d5dbe8ed273d93bec205d664e7b3d390bcdfbaab (diff) | |
| download | markam-6fdc8f2f5ab88b0ce0077a2450af215992e1d23c.tar.gz markam-6fdc8f2f5ab88b0ce0077a2450af215992e1d23c.zip | |
Add url lookup for conkeror
Add simple url lookup for conkeror. Currently loads all bookmarks into
the completion buffer, but this will be changed.
Diffstat (limited to 'conkeror')
| -rw-r--r-- | conkeror/markam.js | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/conkeror/markam.js b/conkeror/markam.js index 2151b17..8c7c2f1 100644 --- a/conkeror/markam.js +++ b/conkeror/markam.js @@ -1,5 +1,5 @@ /* markam -- Store/retrieve/manage bookmarks - Copyright (C) 2012 Tom Willemsen <tom at ryuslash dot org> + Copyright (C) 2012,2013 Tom Willemsen <tom at ryuslash dot org> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,6 +25,17 @@ define_variable("markam_program", "markam", "The location of the markam executable."); +define_browser_object_class( + "markam-bookmark", null, + function (I, prompt) { + check_buffer(I.buffer, content_buffer); + var result = yield I.buffer.window.minibuffer.read( + $prompt = prompt, $completer = markam_complete + ); + yield co_return(result); + } +); + function markam_add_url(I, url, title) { // Add URL to markam, ask for a title (provide TITLE as a // default), description and any number of tags. @@ -74,4 +85,45 @@ interactive("markam-add-link", "Select and bookmark a link in markam", markam_add_link); +function markam_complete(input, pos, conservative) +{ + if (pos == 0 && conservative) + yield co_return(undefined); + + let str = input.substring(0, pos); + + var data = "", error = "", ret = []; + var result = yield shell_command( + markam_program + " --script", + $fds = [{ output: async_binary_string_writer("") }, + { input: async_binary_reader(function (s) data += s || "") }, + { input: async_binary_reader(function (s) error += s || "") }]); + + if (result != 0 || error != "") + throw new interactive_exception("result: " + result + + ", error: " + error); + else if (data != "") { + data.split('').forEach(function (row) { + ret.push(row.split('')); + }); + + let c = { count: ret.length, + get_string: function (i) ret[i][0], + get_description: function (i) ret[i][1], + // get_value: function (i) ret[i][2], + get_input_state: function (i) [ret[i][2]] }; + yield co_return(c); + } +} + +interactive("markam-find-url", + "Find a page from markam in the current buffer", + "find-url", + $browser_object = browser_object_markam_bookmark); +interactive("markam-find-url-new-buffer", + "Find a page from markam in a new buffer", + "find-url-new-buffer", + $browser_object = browser_object_markam_bookmark); + + provide("markam"); |
