mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 13:22:28 +01:00
added :b# for switching to alternative buffer, also finally commited Kipling's patch to use getShortcutOrURI
This commit is contained in:
1
AUTHORS
1
AUTHORS
@@ -12,6 +12,7 @@ Inactive/former developers:
|
|||||||
* Viktor Kojouharov (Виктор Кожухаров)
|
* Viktor Kojouharov (Виктор Кожухаров)
|
||||||
|
|
||||||
Patches (in no special order):
|
Patches (in no special order):
|
||||||
|
* Dominik Meister (:b# support)
|
||||||
* Konstantin Stepanov (:%foo support, :tabduplicate)
|
* Konstantin Stepanov (:%foo support, :tabduplicate)
|
||||||
* Lukas Mai
|
* Lukas Mai
|
||||||
* Guido Van Hoecke
|
* Guido Van Hoecke
|
||||||
|
|||||||
1
Donators
1
Donators
@@ -2,6 +2,7 @@
|
|||||||
<b>Note:</b> If you don't wish to appear on this list when making a donation, please tell me.
|
<b>Note:</b> If you don't wish to appear on this list when making a donation, please tell me.
|
||||||
|
|
||||||
2008:
|
2008:
|
||||||
|
* John Lusth
|
||||||
* Thomas Svensen
|
* Thomas Svensen
|
||||||
* Ryan McBride
|
* Ryan McBride
|
||||||
* Brian Clark
|
* Brian Clark
|
||||||
|
|||||||
1
NEWS
1
NEWS
@@ -10,6 +10,7 @@
|
|||||||
generous donation which made this behavior possible)
|
generous donation which made this behavior possible)
|
||||||
* IMPORTANT: ctrl-x/a never take possible negative URLs into account, it was just
|
* IMPORTANT: ctrl-x/a never take possible negative URLs into account, it was just
|
||||||
too unpredictable
|
too unpredictable
|
||||||
|
* add :b# to select the alternate buffer
|
||||||
* add :tabduplicate command
|
* add :tabduplicate command
|
||||||
* new 'urlseparator' option for specifying the regexp used to split the arg to
|
* new 'urlseparator' option for specifying the regexp used to split the arg to
|
||||||
:open, :tabopen and :winopen
|
:open, :tabopen and :winopen
|
||||||
|
|||||||
@@ -383,53 +383,22 @@ liberator.Bookmarks = function () //{{{
|
|||||||
return keywords;
|
return keywords;
|
||||||
},
|
},
|
||||||
|
|
||||||
// if @param engineName is null, it uses the default search engine
|
// full search string including engine name as first word in @param text
|
||||||
|
// if @param useDefSearch is true, it uses the default search engine
|
||||||
// @returns the url for the search string
|
// @returns the url for the search string
|
||||||
// if the search also requires a postData, [url, postData] is returned
|
// if the search also requires a postData, [url, postData] is returned
|
||||||
getSearchURL: function (text, engineName)
|
getSearchURL: function (text, useDefsearch)
|
||||||
{
|
{
|
||||||
var url = null;
|
var url = null;
|
||||||
var postData = null;
|
var aPostDataRef = {};
|
||||||
if (!engineName)
|
var searchString = (useDefsearch? liberator.options["defsearch"] + " " : "") + text;
|
||||||
engineName = liberator.options["defsearch"];
|
|
||||||
|
|
||||||
// we need to make sure our custom alias have been set, even if the user
|
url = getShortcutOrURI(searchString, aPostDataRef);
|
||||||
// did not :open <tab> once before
|
if (url == searchString)
|
||||||
this.getSearchEngines();
|
url = null;
|
||||||
|
|
||||||
// first checks the search engines for a match
|
if (aPostDataRef && aPostDataRef.value)
|
||||||
var engine = searchService.getEngineByAlias(engineName);
|
return [url, aPostDataRef.value];
|
||||||
if (engine)
|
|
||||||
{
|
|
||||||
if (text)
|
|
||||||
{
|
|
||||||
var submission = engine.getSubmission(text, null);
|
|
||||||
url = submission.uri.spec;
|
|
||||||
postData = submission.postData;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
url = engine.searchForm;
|
|
||||||
}
|
|
||||||
else // check for keyword urls
|
|
||||||
{
|
|
||||||
if (!keywords)
|
|
||||||
load();
|
|
||||||
|
|
||||||
for (var i in keywords)
|
|
||||||
{
|
|
||||||
if (keywords[i][0] == engineName)
|
|
||||||
{
|
|
||||||
if (text == null)
|
|
||||||
text = "";
|
|
||||||
url = keywords[i][2].replace(/%s/g, encodeURIComponent(text));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we came here, the engineName is neither a search engine or URL
|
|
||||||
if (postData)
|
|
||||||
return [url, postData];
|
|
||||||
else
|
else
|
||||||
return url; // can be null
|
return url; // can be null
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -238,26 +238,7 @@ liberator.Tabs = function () //{{{
|
|||||||
|
|
||||||
liberator.mappings.add([liberator.modes.NORMAL], ["<C-^>", "<C-6>"],
|
liberator.mappings.add([liberator.modes.NORMAL], ["<C-^>", "<C-6>"],
|
||||||
"Select the alternate tab",
|
"Select the alternate tab",
|
||||||
function ()
|
function () { liberator.tabs.selectAlternateTab(); });
|
||||||
{
|
|
||||||
if (liberator.tabs.alternate == null || liberator.tabs.getTab() == liberator.tabs.alternate)
|
|
||||||
{
|
|
||||||
liberator.echoerr("E23: No alternate page");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: this currently relies on v.tabs.index() returning the
|
|
||||||
// currently selected tab index when passed null
|
|
||||||
var index = liberator.tabs.index(liberator.tabs.alternate);
|
|
||||||
|
|
||||||
// TODO: since a tab close is more like a bdelete for us we
|
|
||||||
// should probably reopen the closed tab when a 'deleted'
|
|
||||||
// alternate is selected
|
|
||||||
if (index == -1)
|
|
||||||
liberator.echoerr("E86: Buffer does not exist"); // TODO: This should read "Buffer N does not exist"
|
|
||||||
else
|
|
||||||
liberator.tabs.select(index);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
@@ -748,10 +729,9 @@ liberator.Tabs = function () //{{{
|
|||||||
switchTo: function (buffer, allowNonUnique, count, reverse)
|
switchTo: function (buffer, allowNonUnique, count, reverse)
|
||||||
{
|
{
|
||||||
if (buffer == "")
|
if (buffer == "")
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
else if (buffer != null)
|
if (buffer != null)
|
||||||
{
|
{
|
||||||
// store this command, so it can be repeated with "B"
|
// store this command, so it can be repeated with "B"
|
||||||
lastBufferSwitchArgs = buffer;
|
lastBufferSwitchArgs = buffer;
|
||||||
@@ -764,6 +744,12 @@ liberator.Tabs = function () //{{{
|
|||||||
allowNonUnique = lastBufferSwitchSpecial;
|
allowNonUnique = lastBufferSwitchSpecial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (buffer == "#")
|
||||||
|
{
|
||||||
|
liberator.tabs.selectAlternateTab();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!count || count < 1)
|
if (!count || count < 1)
|
||||||
count = 1;
|
count = 1;
|
||||||
if (typeof reverse != "boolean")
|
if (typeof reverse != "boolean")
|
||||||
@@ -829,6 +815,29 @@ liberator.Tabs = function () //{{{
|
|||||||
return newTab;
|
return newTab;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
selectAlternateTab: function ()
|
||||||
|
{
|
||||||
|
if (liberator.tabs.alternate == null || liberator.tabs.getTab() == liberator.tabs.alternate)
|
||||||
|
{
|
||||||
|
liberator.echoerr("E23: No alternate page");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: this currently relies on v.tabs.index() returning the
|
||||||
|
// currently selected tab index when passed null
|
||||||
|
var index = liberator.tabs.index(liberator.tabs.alternate);
|
||||||
|
|
||||||
|
// TODO: since a tab close is more like a bdelete for us we
|
||||||
|
// should probably reopen the closed tab when a 'deleted'
|
||||||
|
// alternate is selected
|
||||||
|
if (index == -1)
|
||||||
|
liberator.echoerr("E86: Buffer does not exist"); // TODO: This should read "Buffer N does not exist"
|
||||||
|
else
|
||||||
|
liberator.tabs.select(index);
|
||||||
|
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
|
||||||
// TODO: when restarting a session FF selects the first tab and then the
|
// TODO: when restarting a session FF selects the first tab and then the
|
||||||
// tab that was selected when the session was created. As a result the
|
// tab that was selected when the session was created. As a result the
|
||||||
// alternate after a restart is often incorrectly tab 1 when there
|
// alternate after a restart is often incorrectly tab 1 when there
|
||||||
|
|||||||
@@ -285,40 +285,27 @@ liberator.util = { //{{{
|
|||||||
// strip each 'URL' - makes things simpler later on
|
// strip each 'URL' - makes things simpler later on
|
||||||
urls[url] = urls[url].replace(/^\s+/, "").replace(/\s+$/, "");
|
urls[url] = urls[url].replace(/^\s+/, "").replace(/\s+$/, "");
|
||||||
|
|
||||||
// first check if it is an existing local file but NOT a search url/keyword
|
|
||||||
// NOTE: the test for being a file is done first, because it's faster than getSearchURL
|
|
||||||
var file = liberator.io.getFile(urls[url]);
|
|
||||||
if (file.exists() && file.isReadable() && !liberator.bookmarks.getSearchURL("", urls[url]))
|
|
||||||
{
|
|
||||||
urls[url] = file.path;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the string doesn't look like a valid URL (i.e. contains a space
|
// if the string doesn't look like a valid URL (i.e. contains a space
|
||||||
// or does not contain any of: .:/) try opening it with a search engine
|
// or does not contain any of: .:/) try opening it with a search engine
|
||||||
// or keyword bookmark
|
// or keyword bookmark
|
||||||
if (liberator.has("bookmarks") && (/\s/.test(urls[url]) || !/[.:\/]/.test(urls[url])))
|
if (/\s/.test(urls[url]) || !/[.:\/]/.test(urls[url]))
|
||||||
{
|
{
|
||||||
var matches = urls[url].match(/^(\S+)(?:\s+(.+))?$/);
|
|
||||||
var alias = matches[1];
|
|
||||||
var text = matches[2] || null;
|
|
||||||
|
|
||||||
// TODO: it would be clearer if the appropriate call to
|
// TODO: it would be clearer if the appropriate call to
|
||||||
// getSearchURL was made based on whether or not the first word was
|
// getSearchURL was made based on whether or not the first word was
|
||||||
// indeed an SE alias rather than seeing if getSearchURL can
|
// indeed an SE alias rather than seeing if getSearchURL can
|
||||||
// process the call usefully and trying again if it fails - much
|
// process the call usefully and trying again if it fails - much
|
||||||
// like the comments below ;-)
|
// like the comments below ;-)
|
||||||
|
|
||||||
// check if the first word is a search engine
|
// check for a search engine match in the string
|
||||||
var searchURL = liberator.bookmarks.getSearchURL(text, alias);
|
var searchURL = liberator.bookmarks.getSearchURL(urls[url], false);
|
||||||
if (searchURL)
|
if (searchURL)
|
||||||
{
|
{
|
||||||
urls[url] = searchURL;
|
urls[url] = searchURL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else // the first word was not a search engine, search for the whole string in the default engine
|
else // no search engine match, search for the whole string in the default engine
|
||||||
{
|
{
|
||||||
searchURL = liberator.bookmarks.getSearchURL(urls[url], null);
|
searchURL = liberator.bookmarks.getSearchURL(urls[url], true);
|
||||||
if (searchURL)
|
if (searchURL)
|
||||||
{
|
{
|
||||||
urls[url] = searchURL;
|
urls[url] = searchURL;
|
||||||
@@ -327,6 +314,13 @@ liberator.util = { //{{{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var file = liberator.io.getFile(urls[url]);
|
||||||
|
if (file.exists() && file.isReadable())
|
||||||
|
{
|
||||||
|
urls[url] = file.path;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// if we are here let Firefox handle the url and hope it does
|
// if we are here let Firefox handle the url and hope it does
|
||||||
// something useful with it :)
|
// something useful with it :)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -682,6 +682,8 @@ If argument is neither a full URL nor an index but uniquely identifies a
|
|||||||
buffer, it is selected. With [!] the next buffer matching the argument is
|
buffer, it is selected. With [!] the next buffer matching the argument is
|
||||||
selected, even if it cannot be identified uniquely. Use [m]b[m] as a
|
selected, even if it cannot be identified uniquely. Use [m]b[m] as a
|
||||||
shortcut to open this prompt.
|
shortcut to open this prompt.
|
||||||
|
|
||||||
|
If argument is #, the alternate buffer will be selected (see [m]<C-6>[m]).
|
||||||
________________________________________________________________________________
|
________________________________________________________________________________
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user