1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-09 07:25:45 +01:00

merge new <C-g> and g<C-g> mappings and improved :pageinfo

This commit is contained in:
Doug Kearns
2007-10-30 08:48:09 +00:00
parent a712bf01ea
commit 4c799598a4
3 changed files with 46 additions and 26 deletions

2
NEWS
View File

@@ -1,7 +1,7 @@
<pre>
2007-XX-XX:
* version 0.5.3
* new :pa[geinfo] command (thanks Marco Candrian)
* new :pa[geinfo] command, and ctrl-g and g, ctrl-g mappings (thanks Marco Candrian)
* IMPORTANT! options are no longer automatically stored - use the
~/.vimperatorrc file instead for persistent options
* added new :mkvimperatorc command

View File

@@ -445,8 +445,8 @@ vimperator.Buffer = function() //{{{
bumpZoomLevel(-steps);
}
this.pageInfo = function(verbose)
{
this.pageInfo = function(verbose)
{
// to get the file size later (from pageInfo.js) (setup cacheEntryDescriptor)
const nsICacheService = Components.interfaces.nsICacheService;
const ACCESS_READ = Components.interfaces.nsICache.ACCESS_READ;
@@ -469,23 +469,21 @@ vimperator.Buffer = function() //{{{
catch (ex2) { }
}
if (!verbose)
if (!verbose)
{
// TODO: strip off any component after &
var file = window.content.document.location.pathname.split('/').pop();
if (!file)
file = "[No Name]";
var title = window.content.document.title;
if (title.length > 60)
title = title.substr(0,57) + "... ";
else if (!title.length)
title = "[No Title]";
var title = window.content.document.title || "[No Title]";
if (cacheEntryDescriptor)
if (cacheEntryDescriptor)
var pageSize = Math.round(cacheEntryDescriptor.dataSize / 1024 * 100) / 100 + "KB";
var pageInfoText = "" + file + ": " + title + " (" + pageSize + ", other cool things)";
var lastmod = window.content.document.lastModified.slice(0, -3);
var pageInfoText = '"' + file + '" [' + pageSize + ", " + lastmod + "] " + title;
vimperator.echo(pageInfoText, vimperator.commandline.FORCE_SINGLELINE);
return;
@@ -495,42 +493,45 @@ vimperator.Buffer = function() //{{{
var pageMeta = []; // keeps meta infos
// get general infos
pageGeneral.push(["Title", window.content.document.title]);
pageGeneral.push(["URL", '<a class="hl-URL" href="' + window.content.document.location.toString() + '">' +
pageGeneral.push(["Title", window.content.document.title]);
pageGeneral.push(["URL", '<a class="hl-URL" href="' + window.content.document.location.toString() + '">' +
window.content.document.location.toString() + '</a>']);
pageGeneral.push(["Referrer", ("referrer" in window.content.document && window.content.document.referrer)]);
pageGeneral.push(["Mime-Type", window.content.document.contentType]);
pageGeneral.push(["Encoding", window.content.document.characterSet]);
if (cacheEntryDescriptor) {
if (cacheEntryDescriptor)
{
var pageSize = cacheEntryDescriptor.dataSize;
pageGeneral.push(["File Size", (Math.round(pageSize / 1024 * 100) / 100) + "KB (" + pageSize + " bytes)"]);
var bytes = pageSize + '';
for (var u = bytes.length - 3; u > 0; u -= 3) // make a 1400 -> 1'400
bytes = bytes.slice(0, u) + "," + bytes.slice(u, bytes.length);
pageGeneral.push(["File Size", (Math.round(pageSize / 1024 * 100) / 100) + "KB (" + bytes + " bytes)"]);
}
pageGeneral.push(["Compatibility", content.document.compatMode == "BackCompat" ?
"Quirks Mode" : "Full/Almost Standard Mode"]);
pageGeneral.push(["Compatibility", content.document.compatMode == "BackCompat" ?
"Quirks Mode" : "Full/Almost Standards Mode"]);
pageGeneral.push(["Last Modified", window.content.document.lastModified]);
// get meta tag infos info and sort and put into pageMeta[]
// get meta tag data, sort and put into pageMeta[]
var metaNodes = window.content.document.getElementsByTagName("meta");
var length = metaNodes.length;
if (length)
{
if (length)
{
var tmpSort = [];
var tmpDict = [];
for (var i = 0; i < length; i++)
{
var tmpTag = metaNodes[i].name || metaNodes[i].httpEquiv;// +
var tmpTag = metaNodes[i].name || metaNodes[i].httpEquiv;// +
//'<span style="font-weight: normal; font-size: 90%;">-eq</span>'; // XXX: really important?
var tmpTagNr = tmpTag + "-" + i; // allows multiple (identical) meta names
tmpDict[tmpTagNr] = [tmpTag, metaNodes[i].content];
tmpSort.push(tmpTagNr); // array for sorting
}
// sort: ignore-case
tmpSort.sort(function (a,b){return a.toLowerCase() > b.toLowerCase() ? 1 : -1;});
// sort: ignore-case
tmpSort.sort(function (a,b){return a.toLowerCase() > b.toLowerCase() ? 1 : -1;});
for (var i=0; i < tmpSort.length; i++)
{
@@ -550,7 +551,7 @@ vimperator.Buffer = function() //{{{
for (var i = 0; i < pageGeneral.length; i++)
{
if (pageGeneral[i][1])
pageInfoText += "<tr><td style='font-weight: bold;'> " + pageGeneral[i][0] + ":&nbsp;</td><td>" + pageGeneral[i][1] + "</td></tr>";
pageInfoText += "<tr><td style='font-weight: bold;'> " + pageGeneral[i][0] + ": </td><td>" + pageGeneral[i][1] + "</td></tr>";
}
pageInfoText += "</table>";
break;
@@ -560,7 +561,7 @@ vimperator.Buffer = function() //{{{
{
for (var i = 0; i < pageMeta.length; i++)
{
pageInfoText += "<tr><td style='font-weight: bold;'> " + pageMeta[i][0] + ":&nbsp;</td><td>" + pageMeta[i][1] + "</td></tr>";
pageInfoText += "<tr><td style='font-weight: bold;'> " + pageMeta[i][0] + ": </td><td>" + pageMeta[i][1] + "</td></tr>";
}
}
else

View File

@@ -835,6 +835,25 @@ vimperator.Mappings = function() //{{{
}
));
// page info
addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["<C-g>"],
function(count) { vimperator.buffer.pageInfo(false); },
{
short_help: "Print the current file name",
help: "Also shows some additional file information like file size or the last modified date. " +
"If <code class='argument'>{count}</code> is given print the current file name with full path.",
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["g<C-g>"],
function(count) { vimperator.buffer.pageInfo(true); },
{
short_help: "Print file information",
help: "Same as <code class='command'>:pa[geinfo]</code>."
}
));
// history manipulation and jumplist
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["<C-o>"],
function(count) { vimperator.history.stepTo(-(count > 1 ? count : 1)); },