1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 02:37:58 +01:00

move the hsshow(), stepInHistory(), historyGoToBeginning(), and

historyGoToStart() global functions to vimperator.history
This commit is contained in:
Doug Kearns
2007-07-02 14:48:31 +00:00
parent 3ca1ee8651
commit 39878db0da
2 changed files with 83 additions and 80 deletions

View File

@@ -349,6 +349,58 @@ function History() //{{{
history.unshift([url, title]); history.unshift([url, title]);
return true; 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);
}
}
//}}} //}}}
} //}}} } //}}}

View File

@@ -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-n>", "vimperator.tabs.select('+1', true)", true, true], // same as gt, but no count supported
["<C-p>", "vimperator.tabs.select('-1', true)", true, true], ["<C-p>", "vimperator.tabs.select('-1', true)", true, true],
/* navigation */ /* navigation */
["<C-o>", "stepInHistory(g_count > 0 ? -1 * g_count : -1);", false, true], ["<C-o>", "vimperator.history.stepTo(g_count > 0 ? -1 * g_count : -1);", false, true],
["<C-i>", "stepInHistory(g_count > 0 ? g_count : 1);", false, true], ["<C-i>", "vimperator.history.stepTo(g_count > 0 ? g_count : 1);", false, true],
["<C-h>", "stepInHistory(g_count > 0 ? -1 * g_count : -1);", false, true], ["<C-h>", "vimperator.history.stepTo(g_count > 0 ? -1 * g_count : -1);", false, true],
["<C-l>", "stepInHistory(g_count > 0 ? 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], ["<C-d>", "vimperator.tabs.remove(getBrowser().mCurrentTab, g_count, false, 0);", true, true],
/* cancel hint mode keys */ /* cancel hint mode keys */
["<C-c>", "", true, true], ["<C-c>", "", true, true],
@@ -248,9 +248,9 @@ function Commands() //{{{
function(args, special, count) function(args, special, count)
{ {
if (special) if (special)
historyGoToBeginning(); vimperator.history.goToStart();
else else
stepInHistory(count > 0 ? -1 * count : -1); vimperator.history.stepTo(count > 0 ? -1 * count : -1);
}, },
{ {
usage: ["{count}ba[ck][!]"], usage: ["{count}ba[ck][!]"],
@@ -424,9 +424,9 @@ function Commands() //{{{
function(args, special, count) function(args, special, count)
{ {
if (special) if (special)
historyGoToEnd(); vimperator.history.goToEnd();
else else
stepInHistory(count > 0 ? count : 1); vimperator.history.stepTo(count > 0 ? count : 1);
}, },
{ {
usage: ["{count}fo[rward][!]"], usage: ["{count}fo[rward][!]"],
@@ -460,7 +460,7 @@ function Commands() //{{{
} }
)); ));
addDefaultCommand(new Command(["hist[ory]", "hs"], addDefaultCommand(new Command(["hist[ory]", "hs"],
hsshow, function() { vimperator.history.list(); },
{ {
usage: ["hist[ory] {filter}"], usage: ["hist[ory] {filter}"],
short_help: "Show recently visited URLs", short_help: "Show recently visited URLs",
@@ -475,9 +475,12 @@ function Commands() //{{{
if (special) // open javascript console if (special) // open javascript console
openURLsInNewTab("chrome://global/content/console.xul", true); openURLsInNewTab("chrome://global/content/console.xul", true);
else else
try { try
{
eval(args); eval(args);
} catch(e) { }
catch (e)
{
vimperator.echoerr(e.name + ": " + e.message); vimperator.echoerr(e.name + ": " + e.message);
} }
}, },
@@ -1025,48 +1028,6 @@ function execute(string)
return execute_command.apply(this, tokens); 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 /////////////////////////////////////////////////////// // url functions ///////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////{{{
@@ -1409,16 +1370,6 @@ function bmshow(filter, fullmode)
vimperator.previewwindow.show(items); 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 //////////////////////////////////////// // tab/buffer related functions ////////////////////////////////////////