diff --git a/ChangeLog b/ChangeLog index b679f770..2016686b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,8 @@
+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
diff --git a/chrome/content/vimperator/bookmarks.js b/chrome/content/vimperator/bookmarks.js
index b8d4ffd4..ec5d82d3 100644
--- a/chrome/content/vimperator/bookmarks.js
+++ b/chrome/content/vimperator/bookmarks.js
@@ -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:
diff --git a/chrome/content/vimperator/commands.js b/chrome/content/vimperator/commands.js
index 93b7f648..7f2471cd 100644
--- a/chrome/content/vimperator/commands.js
+++ b/chrome/content/vimperator/commands.js
@@ -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.
"+
+ ":wq 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;
diff --git a/chrome/content/vimperator/settings.js b/chrome/content/vimperator/settings.js
index ce9d6dce..d1a3e19e 100644
--- a/chrome/content/vimperator/settings.js
+++ b/chrome/content/vimperator/settings.js
@@ -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 :[tab]open [arg] 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"],
diff --git a/chrome/content/vimperator/tags b/chrome/content/vimperator/tags
index 76fd25db..e9aea5d6 100644
--- a/chrome/content/vimperator/tags
+++ b/chrome/content/vimperator/tags
@@ -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
diff --git a/chrome/content/vimperator/vimperator.js b/chrome/content/vimperator/vimperator.js
index 1dd75125..2b139bed 100644
--- a/chrome/content/vimperator/vimperator.js
+++ b/chrome/content/vimperator/vimperator.js
@@ -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
////////////////////////////////////////////////////////////////////////