1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-04-03 01:23:31 +02: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> <pre>
2007-XX-XX: 2007-XX-XX:
* version 0.5.3 * 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 * IMPORTANT! options are no longer automatically stored - use the
~/.vimperatorrc file instead for persistent options ~/.vimperatorrc file instead for persistent options
* added new :mkvimperatorc command * added new :mkvimperatorc command

View File

@@ -476,16 +476,14 @@ vimperator.Buffer = function() //{{{
if (!file) if (!file)
file = "[No Name]"; file = "[No Name]";
var title = window.content.document.title; var title = window.content.document.title || "[No Title]";
if (title.length > 60)
title = title.substr(0,57) + "... ";
else if (!title.length)
title = "[No Title]";
if (cacheEntryDescriptor) if (cacheEntryDescriptor)
var pageSize = Math.round(cacheEntryDescriptor.dataSize / 1024 * 100) / 100 + "KB"; 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); vimperator.echo(pageInfoText, vimperator.commandline.FORCE_SINGLELINE);
return; return;
@@ -502,17 +500,20 @@ vimperator.Buffer = function() //{{{
pageGeneral.push(["Mime-Type", window.content.document.contentType]); pageGeneral.push(["Mime-Type", window.content.document.contentType]);
pageGeneral.push(["Encoding", window.content.document.characterSet]); pageGeneral.push(["Encoding", window.content.document.characterSet]);
if (cacheEntryDescriptor)
if (cacheEntryDescriptor) { {
var pageSize = cacheEntryDescriptor.dataSize; 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" ? pageGeneral.push(["Compatibility", content.document.compatMode == "BackCompat" ?
"Quirks Mode" : "Full/Almost Standard Mode"]); "Quirks Mode" : "Full/Almost Standards Mode"]);
pageGeneral.push(["Last Modified", window.content.document.lastModified]); 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 metaNodes = window.content.document.getElementsByTagName("meta");
var length = metaNodes.length; var length = metaNodes.length;
if (length) if (length)
@@ -550,7 +551,7 @@ vimperator.Buffer = function() //{{{
for (var i = 0; i < pageGeneral.length; i++) for (var i = 0; i < pageGeneral.length; i++)
{ {
if (pageGeneral[i][1]) 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>"; pageInfoText += "</table>";
break; break;
@@ -560,7 +561,7 @@ vimperator.Buffer = function() //{{{
{ {
for (var i = 0; i < pageMeta.length; i++) 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 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 // history manipulation and jumplist
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["<C-o>"], addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["<C-o>"],
function(count) { vimperator.history.stepTo(-(count > 1 ? count : 1)); }, function(count) { vimperator.history.stepTo(-(count > 1 ? count : 1)); },