Skip to content

Instantly share code, notes, and snippets.

@mooz
Created January 25, 2010 07:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mooz/285701 to your computer and use it in GitHub Desktop.
Save mooz/285701 to your computer and use it in GitHub Desktop.
// サジェスト付き検索
// Google, Wikipedia などが使用可能
// s を入力するとエンジン選択画面が開く。 j/k で上下へ。 Enter や s で決定。
// エンジンを決定したら検索語句を入力する画面へ。ここで文字を入力して TAB を押すとサジェストの結果で補完される。
key.setViewKey('s', function (ev, arg) {
let engines = util.suggest.getEngines();
// If you want to use all available suggest engines,
// change suggestEngines value to util.suggest.filterEngines(engines);
let suggestEngines = [util.suggest.ss.getEngineByName("Google")];
let collection = engines.map(
function (engine) [(engine.iconURI || {spec:""}).spec, engine.name, engine.description]
);
prompt.selector(
{
message : "engine:",
collection : collection,
flags : [ICON | IGNORE, 0, 0],
header : ["Name", "Description"],
keymap : {
"s" : "prompt-decide",
"j" : "prompt-next-completion",
"k" : "prompt-previous-completion"
},
callback : function (i) {
if (i >= 0)
util.suggest.searchWithSuggest(engines[i], suggestEngines, "tab");
}
});
}, "Search With Suggest", true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment