1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 16:27:59 +01:00

added 'defsearch' setting

This commit is contained in:
Martin Stubenschrott
2007-05-01 17:29:32 +00:00
parent 297f8c2bf0
commit a4d056c583
6 changed files with 87 additions and 17 deletions

View File

@@ -1,4 +1,8 @@
<pre>
date:
* version 0.5
* added 'defsearch' setting for setting default search engine
2007-05-01:
* version 0.4
* extension GUID was changed to 'vimperator@mozdev.net' -> YOU WILL HAVE

View File

@@ -166,13 +166,35 @@ function getSearchEngines()
firefox_engines[i].alias = alias;
}
search_engines.push([firefox_engines[i].alias, firefox_engines[i].description]);
// alert(engines[i].alias);
// alert(engines[i].name);
// alert(engines[i].description);
}
return search_engines;
}
function Search()
{
const search_service = Components.classes["@mozilla.org/browser/search-service;1"].
getService(Components.interfaces.nsIBrowserSearchService);
this.getDefaultEngine = function()
{
return search_service.currentEngine;
}
this.setDefaultEngine = function(alias)
{
var engine = search_service.getEngineByAlias(alias);
if(engine)
search_service.currentEngine = engine;
else
echoerr("Error: Search engine with alias '" + alias + "' does not exist");
}
this.getEngine = function(alias)
{
var engine = search_service.getEngineByAlias(alias);
return engine;
}
}
var search = new Search(); // FIXME, must it really be here? doesn't work in vimperator.js
// vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -439,7 +439,8 @@ var g_commands = [/*{{{*/
["xall", "xa", "wqall", "wqa", "wq"],
["wqa[ll]", "xa[ll]"],
"Save the session and quit",
"Quit Vimperator, no matter how many tabs/windows are open. The session is stored.",
"Quit Vimperator, no matter how many tabs/windows are open. The session is stored.<br/>"+
"<code command>:wq</code> is different as in vim, as it closes the window instead of just one tab by popular demand. Complain on the mailing list, if you want to change that.",
function (args) { quit(true); },
null
],
@@ -1268,9 +1269,11 @@ function openURLs(str)
if (urls.length == 0)
return false;
getWebNavigation().loadURI(urls[0], nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null);
//getWebNavigation().loadURI(urls[0], nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null);
getBrowser().loadURI(urls[0]);
for (var url=1; url < urls.length; url++)
gBrowser.addTab(urls[url]);
getBrowser().addTab(urls[url]);
return true;
}
@@ -1295,9 +1298,6 @@ function openURLsInNewTab(str, activate)
*/
function stringToURLs(str)
{
const search_service = Components.classes["@mozilla.org/browser/search-service;1"].
getService(Components.interfaces.nsIBrowserSearchService);
var urls = str.split(/\s*\|\s*/);
begin: for(var url=0; url < urls.length; url++)
{
@@ -1323,7 +1323,7 @@ function stringToURLs(str)
if (alias)
{
var engine = search_service.getEngineByAlias(alias);
var engine = search.getEngine(alias);
if (engine)
{
if(text)
@@ -1340,8 +1340,8 @@ function stringToURLs(str)
if (urls[url].match(/\s+/) || urls[url].match(/\.|:|\//) == null)
{
// defaultEngine is always the same (Google), therefor let's use the currentEngine
var default_engine = search_service.currentEngine;
//var default_engine = search_service.defaultEngine;
//var default_engine = search_service.currentEngine;
var default_engine = search.getDefaultEngine();
if (default_engine)
{
urls[url] = default_engine.getSubmission(urls[url], null).uri.spec;

View File

@@ -76,6 +76,19 @@ var g_settings = [/*{{{*/
"sfbh",
null
],
[
["defsearch", "ds"],
["defsearch", "ds"],
"Set the default search engine",
"The default search engine is used in the <code class=command>:[tab]open [arg]</code> command "+
"if [arg] neither looks like a URL or like a specified search engine/keyword.",
"string",
function() { return [["foo", "bar"], ["shit", "blub"]]; },
function(value) { search.setDefaultEngine(value); },
function() { return search.getDefaultEngine().alias; },
"google",
null
],
[
["extendedhinttags", "eht"],
["extendedhinttags", "eht"],

View File

@@ -4,6 +4,7 @@
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.6 //
abs_point find.js /^function abs_point (node) {$/;" f
addBookmark bookmarks.js /^function addBookmark(title, uri)$/;" f
addEventListeners vimperator.js /^function addEventListeners()$/;" f
addMode commands.js /^function addMode(mode)$/;" f
@@ -19,6 +20,8 @@ bufshow commands.js /^function bufshow(filter, in_comp_window)$/;" f
build_longest_common_substring completion.js /^function build_longest_common_substring(list, filter)\/*{{{*\/$/;" f
build_longest_starting_substring completion.js /^function build_longest_starting_substring(list, filter)\/*{{{*\/$/;" f
changeHintFocus hints.js /^ function changeHintFocus(linkNumString, oldLinkNumString)$/;" f
clearHighlight find.js /^function clearHighlight()$/;" f
clearSelection find.js /^function clearSelection() {$/;" f
completion_add_to_list completion.js /^function completion_add_to_list(completion_item, at_beginning)\/*{{{*\/$/;" f
completion_fill_list completion.js /^function completion_fill_list(startindex)\/*{{{*\/$/;" f
completion_select_next_item completion.js /^function completion_select_next_item(has_list, has_full, has_longest)\/*{{{*\/$/;" f
@@ -47,10 +50,12 @@ genElemCoords hints.js /^ function genElemCoords(elem)$/;" f
genHintContainer hints.js /^ function genHintContainer(doc)$/;" f
getCurrentLinkLocation commands.js /^function getCurrentLinkLocation()$/;" f
getCurrentLocation commands.js /^function getCurrentLocation()$/;" f
getCurrentTitle commands.js /^function getCurrentTitle()$/;" f
getHintById hints.js /^ function getHintById(id, win)$/;" f
getLinkNodes vimperator.js /^function getLinkNodes(doc)$/;" f
getPageLinkNodes vimperator.js /^function getPageLinkNodes()$/;" f
getProperty bookmarks.js /^function getProperty( aInput, aArc, DS )$/;" f
getSearchEngines bookmarks.js /^function getSearchEngines()$/;" f
get_bookmark_completions completion.js /^function get_bookmark_completions(filter)\/*{{{*\/$/;" f
get_buffer_completions completion.js /^function get_buffer_completions(filter)\/*{{{*\/$/;" f
get_command commands.js /^function get_command(cmd) \/\/ {{{$/;" f
@@ -64,11 +69,12 @@ get_pref settings.js /^function get_pref(name, forced_default)$/;" f
get_search_completions completion.js /^function get_search_completions(filter)\/*{{{*\/$/;" f
get_setting settings.js /^function get_setting(cmd)\/*{{{*\/$/;" f
get_settings_completions completion.js /^function get_settings_completions(filter, unfiltered)\/*{{{*\/$/;" f
get_url_completions completion.js /^function get_url_completions(filter)\/*{{{*\/$/;" f
get_url_completions completion.js /^function get_url_completions(filter, complete)\/*{{{*\/$/;" f
get_url_mark commands.js /^function get_url_mark(mark)$/;" f
goUp commands.js /^function goUp(count)$/;" f
hasMode commands.js /^function hasMode(mode)$/;" f
help help.js /^function help(section, easter)$/;" f
highlightFind find.js /^function highlightFind(str, color, wrapped, dir, pt)$/;" f
historyGoToBeginning commands.js /^function historyGoToBeginning()$/;" f
historyGoToEnd commands.js /^function historyGoToEnd()$/;" f
hit_a_hint hints.js /^function hit_a_hint()$/;" f
@@ -82,6 +88,7 @@ keyToString vimperator.js /^function keyToString(event)$/;" f
load_history completion.js /^function load_history()$/;" f
LocalFile file.js /^function LocalFile(file, mode, perms, tmp)$/;" f
logMessage vimperator.js /^function logMessage(msg)$/;" f
logObject vimperator.js /^function logObject(object)$/;" f
makeHelpString help.js /^ function makeHelpString(commands, color, beg, end, func)$/;" f
makeSettingsHelpString help.js /^ function makeSettingsHelpString(command)$/;" f
multiliner commands.js /^function multiliner(line, prev_match, heredoc)$/;" f
@@ -106,13 +113,15 @@ removeHints hints.js /^ function removeHints(win)$/;" f
removeMode commands.js /^function removeMode(mode)$/;" f
restart commands.js /^function restart()$/;" f
save_history completion.js /^function save_history()$/;" f
scrollBufferAbsolute commands.js /^function scrollBufferAbsolute(horizontal, vertical)$/;" f
scrollBufferRelative commands.js /^function scrollBufferRelative(right, down)$/;" f
Search bookmarks.js /^function Search()$/;" f
searcher find.js /^function searcher () {$/;" f
selectInput commands.js /^function selectInput()$/;" f
set commands.js /^function set(args, special)$/;" f
setCurrentMode commands.js /^function setCurrentMode(mode)$/;" f
setHintStyle hints.js /^ function setHintStyle(hintElem, styleString)$/;" f
setMouseOverElement hints.js /^ function setMouseOverElement(elem)$/;" f
setSelection find.js /^function setSelection(range) {$/;" f
setStatusbarColor vimperator.js /^function setStatusbarColor(color)$/;" f
set_firefox_pref settings.js /^function set_firefox_pref(name, value)$/;" f
set_guioptions settings.js /^function set_guioptions(value)$/;" f
@@ -137,5 +146,3 @@ tokenize_ex commands.js /^function tokenize_ex(string, tag)$/;" f
unload vimperator.js /^function unload()$/;" f
updateStatusbar vimperator.js /^function updateStatusbar(message)$/;" f
yankCurrentLocation commands.js /^function yankCurrentLocation()$/;" f
zoom_in commands.js /^function zoom_in(factor)$/;" f
zoom_to commands.js /^function zoom_to(value)$/;" f

View File

@@ -28,6 +28,9 @@ the terms of any one of the MPL, the GPL or the LGPL.
var g_vimperator_version = "###VERSION### (created: ###DATE###)";
// all our objects
//var search = new Search(); // FIXME, put somewhere else, does not work here
const MODE_NORMAL = 1;
const MODE_INSERT = 2;
const MODE_VISUAL = 4;
@@ -494,9 +497,11 @@ function onCommandBarKeypress(evt)/*{{{*/
try {
[prev_match, heredoc, end] = multiliner(command, prev_match, heredoc);
} catch(e) {
logObject(e);
echoerr(e.name + ": " + e.message);
prev_match = new Array(5);
heredoc = '';
return;
}
if (!end)
command_line.value = "";
@@ -990,6 +995,25 @@ function logMessage(msg)
gConsoleService.logStringMessage('vimperator: ' + msg);
}
function logObject(object)
{
if (typeof object != 'object')
return;
var string = object + '::\n';
for (var i in object)
{
var value;
try {
var value = object[i];
} catch (e) { value = '' }
string += i + ': ' + value + '\n';
}
logMessage(string);
}
////////////////////////////////////////////////////////////////////////
// misc helper functions ////////////////////////////////////////// {{{1
////////////////////////////////////////////////////////////////////////