mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 02:17:59 +01:00
move the hsshow(), stepInHistory(), historyGoToBeginning(), and
historyGoToStart() global functions to vimperator.history
This commit is contained in:
@@ -349,6 +349,58 @@ function History() //{{{
|
||||
history.unshift([url, title]);
|
||||
return true;
|
||||
};
|
||||
|
||||
// TODO: better names?
|
||||
this.stepTo = function(steps)
|
||||
{
|
||||
var index = getWebNavigation().sessionHistory.index + steps;
|
||||
if (index >= 0 && index < getWebNavigation().sessionHistory.count)
|
||||
{
|
||||
getWebNavigation().gotoIndex(index);
|
||||
}
|
||||
else
|
||||
{
|
||||
vimperator.beep();
|
||||
if (index < 0)
|
||||
vimperator.echo("Cannot go past beginning of history");
|
||||
else
|
||||
vimperator.echo("Cannot go past end of history");
|
||||
}
|
||||
}
|
||||
|
||||
this.goToStart = function()
|
||||
{
|
||||
var index = getWebNavigation().sessionHistory.index;
|
||||
if (index == 0)
|
||||
{
|
||||
vimperator.echo("Already at beginning of history");
|
||||
return;
|
||||
}
|
||||
getWebNavigation().gotoIndex(0);
|
||||
}
|
||||
|
||||
this.goToEnd = function()
|
||||
{
|
||||
var index = getWebNavigation().sessionHistory.index;
|
||||
var max = getWebNavigation().sessionHistory.count -1;
|
||||
if (index == max)
|
||||
{
|
||||
vimperator.echo("Already at end of history");
|
||||
return;
|
||||
}
|
||||
getWebNavigation().gotoIndex(max);
|
||||
}
|
||||
|
||||
this.list = function(filter, fullmode)
|
||||
{
|
||||
if (fullmode)
|
||||
openURLsInNewTab("chrome://browser/content/history/history-panel.xul", true);
|
||||
else
|
||||
{
|
||||
var items = vimperator.history.get(filter);
|
||||
vimperator.previewwindow.show(items);
|
||||
}
|
||||
}
|
||||
//}}}
|
||||
} //}}}
|
||||
|
||||
|
||||
@@ -54,10 +54,10 @@ var g_hint_mappings = [ //{{{
|
||||
["<C-n>", "vimperator.tabs.select('+1', true)", true, true], // same as gt, but no count supported
|
||||
["<C-p>", "vimperator.tabs.select('-1', true)", true, true],
|
||||
/* navigation */
|
||||
["<C-o>", "stepInHistory(g_count > 0 ? -1 * g_count : -1);", false, true],
|
||||
["<C-i>", "stepInHistory(g_count > 0 ? g_count : 1);", false, true],
|
||||
["<C-h>", "stepInHistory(g_count > 0 ? -1 * g_count : -1);", false, true],
|
||||
["<C-l>", "stepInHistory(g_count > 0 ? g_count : 1);", false, true],
|
||||
["<C-o>", "vimperator.history.stepTo(g_count > 0 ? -1 * g_count : -1);", false, true],
|
||||
["<C-i>", "vimperator.history.stepTo(g_count > 0 ? g_count : 1);", false, true],
|
||||
["<C-h>", "vimperator.history.stepTo(g_count > 0 ? -1 * g_count : -1);", false, true],
|
||||
["<C-l>", "vimperator.history.stepTo(g_count > 0 ? g_count : 1);", false, true],
|
||||
["<C-d>", "vimperator.tabs.remove(getBrowser().mCurrentTab, g_count, false, 0);", true, true],
|
||||
/* cancel hint mode keys */
|
||||
["<C-c>", "", true, true],
|
||||
@@ -248,9 +248,9 @@ function Commands() //{{{
|
||||
function(args, special, count)
|
||||
{
|
||||
if (special)
|
||||
historyGoToBeginning();
|
||||
vimperator.history.goToStart();
|
||||
else
|
||||
stepInHistory(count > 0 ? -1 * count : -1);
|
||||
vimperator.history.stepTo(count > 0 ? -1 * count : -1);
|
||||
},
|
||||
{
|
||||
usage: ["{count}ba[ck][!]"],
|
||||
@@ -424,9 +424,9 @@ function Commands() //{{{
|
||||
function(args, special, count)
|
||||
{
|
||||
if (special)
|
||||
historyGoToEnd();
|
||||
vimperator.history.goToEnd();
|
||||
else
|
||||
stepInHistory(count > 0 ? count : 1);
|
||||
vimperator.history.stepTo(count > 0 ? count : 1);
|
||||
},
|
||||
{
|
||||
usage: ["{count}fo[rward][!]"],
|
||||
@@ -460,7 +460,7 @@ function Commands() //{{{
|
||||
}
|
||||
));
|
||||
addDefaultCommand(new Command(["hist[ory]", "hs"],
|
||||
hsshow,
|
||||
function() { vimperator.history.list(); },
|
||||
{
|
||||
usage: ["hist[ory] {filter}"],
|
||||
short_help: "Show recently visited URLs",
|
||||
@@ -475,9 +475,12 @@ function Commands() //{{{
|
||||
if (special) // open javascript console
|
||||
openURLsInNewTab("chrome://global/content/console.xul", true);
|
||||
else
|
||||
try {
|
||||
try
|
||||
{
|
||||
eval(args);
|
||||
} catch(e) {
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
vimperator.echoerr(e.name + ": " + e.message);
|
||||
}
|
||||
},
|
||||
@@ -1025,48 +1028,6 @@ function execute(string)
|
||||
return execute_command.apply(this, tokens);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////}}}
|
||||
// navigation functions ////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
function stepInHistory(steps)
|
||||
{
|
||||
var index = getWebNavigation().sessionHistory.index + steps;
|
||||
if (index >= 0 && index < getWebNavigation().sessionHistory.count)
|
||||
{
|
||||
getWebNavigation().gotoIndex(index);
|
||||
}
|
||||
else
|
||||
{
|
||||
vimperator.beep();
|
||||
if(index < 0)
|
||||
vimperator.echo("Cannot go past beginning of history");
|
||||
else
|
||||
vimperator.echo("Cannot go past end of history");
|
||||
}
|
||||
}
|
||||
function historyGoToBeginning()
|
||||
{
|
||||
var index = getWebNavigation().sessionHistory.index;
|
||||
if (index == 0)
|
||||
{
|
||||
vimperator.echo("Already at beginning of history");
|
||||
return;
|
||||
}
|
||||
getWebNavigation().gotoIndex(0);
|
||||
}
|
||||
function historyGoToEnd()
|
||||
{
|
||||
var index = getWebNavigation().sessionHistory.index;
|
||||
var max = getWebNavigation().sessionHistory.count -1;
|
||||
if (index == max)
|
||||
{
|
||||
vimperator.echo("Already at end of history");
|
||||
return;
|
||||
}
|
||||
getWebNavigation().gotoIndex(max);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////}}}
|
||||
// url functions ///////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////{{{
|
||||
@@ -1409,16 +1370,6 @@ function bmshow(filter, fullmode)
|
||||
vimperator.previewwindow.show(items);
|
||||
}
|
||||
}
|
||||
function hsshow(filter, fullmode)
|
||||
{
|
||||
if (fullmode)
|
||||
openURLsInNewTab("chrome://browser/content/history/history-panel.xul", true);
|
||||
else
|
||||
{
|
||||
var items = vimperator.history.get(filter);
|
||||
vimperator.previewwindow.show(items);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////}}}
|
||||
// tab/buffer related functions ////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user