diff --git a/NEWS b/NEWS index fdbcba63..0f12f958 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,7 @@
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
diff --git a/content/buffers.js b/content/buffers.js
index 4d585cfd..885e539b 100644
--- a/content/buffers.js
+++ b/content/buffers.js
@@ -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", '' +
+ pageGeneral.push(["Title", window.content.document.title]);
+ pageGeneral.push(["URL", '' +
window.content.document.location.toString() + '']);
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;// +
//'-eq'; // 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 += " " + pageGeneral[i][0] + ": " + pageGeneral[i][1] + " ";
+ pageInfoText += " " + pageGeneral[i][0] + ": " + pageGeneral[i][1] + " ";
}
pageInfoText += "";
break;
@@ -560,7 +561,7 @@ vimperator.Buffer = function() //{{{
{
for (var i = 0; i < pageMeta.length; i++)
{
- pageInfoText += " " + pageMeta[i][0] + ": " + pageMeta[i][1] + " ";
+ pageInfoText += " " + pageMeta[i][0] + ": " + pageMeta[i][1] + " ";
}
}
else
diff --git a/content/mappings.js b/content/mappings.js
index 859a06ca..e1f5ba11 100644
--- a/content/mappings.js
+++ b/content/mappings.js
@@ -835,6 +835,25 @@ vimperator.Mappings = function() //{{{
}
));
+ // page info
+ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], [""],
+ 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 {count} is given print the current file name with full path.",
+ flags: vimperator.Mappings.flags.COUNT
+ }
+ ));
+ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["g"],
+ function(count) { vimperator.buffer.pageInfo(true); },
+ {
+ short_help: "Print file information",
+ help: "Same as :pa[geinfo]."
+ }
+ ));
+
+
// history manipulation and jumplist
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, [""],
function(count) { vimperator.history.stepTo(-(count > 1 ? count : 1)); },