mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 11:48:00 +01:00
Fix completions, among other things (sorry)
This commit is contained in:
@@ -45,6 +45,11 @@ function Bookmarks() //{{{
|
|||||||
|
|
||||||
const Bookmark = new Struct("url", "title", "icon", "keyword", "tags", "id");
|
const Bookmark = new Struct("url", "title", "icon", "keyword", "tags", "id");
|
||||||
const Keyword = new Struct("keyword", "title", "icon", "url");
|
const Keyword = new Struct("keyword", "title", "icon", "url");
|
||||||
|
Bookmark.defaultValue("icon", function () getFavicon(this.url));
|
||||||
|
Bookmark.prototype.__defineGetter__("extra", function () [
|
||||||
|
['keyword', this.keyword, "hl-Keyword"],
|
||||||
|
['tags', this.tags.join(', '), "hl-Tag"]
|
||||||
|
].filter(function (item) item[1]));
|
||||||
|
|
||||||
const storage = modules.storage;
|
const storage = modules.storage;
|
||||||
function Cache(name, store, serial)
|
function Cache(name, store, serial)
|
||||||
@@ -68,8 +73,7 @@ function Bookmarks() //{{{
|
|||||||
let uri = ioService.newURI(node.uri, null, null);
|
let uri = ioService.newURI(node.uri, null, null);
|
||||||
let keyword = bookmarksService.getKeywordForBookmark(node.itemId);
|
let keyword = bookmarksService.getKeywordForBookmark(node.itemId);
|
||||||
let tags = taggingService.getTagsForURI(uri, {}) || [];
|
let tags = taggingService.getTagsForURI(uri, {}) || [];
|
||||||
let icon = faviconService.getFaviconImageForPage(uri).spec; // for performance reasons, use this rather than getFavicon
|
return bookmarks.push(new Bookmark(node.uri, node.title, null, keyword, tags, node.itemId));
|
||||||
return bookmarks.push(new Bookmark(node.uri, node.title, icon, keyword, tags, node.itemId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function readBookmark(id)
|
function readBookmark(id)
|
||||||
@@ -529,15 +533,7 @@ function Bookmarks() //{{{
|
|||||||
if (openItems)
|
if (openItems)
|
||||||
return liberator.open([i.url for each (i in items)], liberator.NEW_TAB);
|
return liberator.open([i.url for each (i in items)], liberator.NEW_TAB);
|
||||||
|
|
||||||
let list = template.bookmarks("title", (
|
let list = template.bookmarks("title", items);
|
||||||
{
|
|
||||||
url: item.url,
|
|
||||||
title: item.title,
|
|
||||||
icon: getFavicon(item.url),
|
|
||||||
extra: [['keyword', item.keyword, "hl-Keyword"],
|
|
||||||
['tags', item.tags.join(', '), "hl-Tag"]
|
|
||||||
].filter(function (i) i[1])
|
|
||||||
} for each ([i, item] in Iterator(items)) if (i < 1000)));
|
|
||||||
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
|
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -553,6 +549,10 @@ function History() //{{{
|
|||||||
const historyService = Components.classes["@mozilla.org/browser/nav-history-service;1"]
|
const historyService = Components.classes["@mozilla.org/browser/nav-history-service;1"]
|
||||||
.getService(Components.interfaces.nsINavHistoryService);
|
.getService(Components.interfaces.nsINavHistoryService);
|
||||||
|
|
||||||
|
const History = new Struct("url", "title", "icon");
|
||||||
|
History.defaultValue("title", function () "[No Title]");
|
||||||
|
History.defaultValue("icon", function () bookmarks.getFavicon(this.url));
|
||||||
|
|
||||||
var placesHistory;
|
var placesHistory;
|
||||||
var cachedHistory = []; // add pages here after loading the initial Places history
|
var cachedHistory = []; // add pages here after loading the initial Places history
|
||||||
|
|
||||||
@@ -575,7 +575,7 @@ function History() //{{{
|
|||||||
var node = rootNode.getChild(i);
|
var node = rootNode.getChild(i);
|
||||||
// liberator.dump("History child " + node.itemId + ": " + node.title + " - " + node.type);
|
// liberator.dump("History child " + node.itemId + ": " + node.title + " - " + node.type);
|
||||||
if (node.type == node.RESULT_TYPE_URI) // just make sure it's a bookmark
|
if (node.type == node.RESULT_TYPE_URI) // just make sure it's a bookmark
|
||||||
placesHistory.push([node.uri, node.title || "[No title]"]);
|
placesHistory.push(History(node.uri, node.title))
|
||||||
}
|
}
|
||||||
|
|
||||||
// close a container after using it!
|
// close a container after using it!
|
||||||
@@ -766,7 +766,7 @@ function History() //{{{
|
|||||||
if (placesHistory.some(function (h) h[0] == url))
|
if (placesHistory.some(function (h) h[0] == url))
|
||||||
placesHistory = placesHistory.filter(filter);
|
placesHistory = placesHistory.filter(filter);
|
||||||
|
|
||||||
cachedHistory.unshift([url, title || "[No title]"]);
|
cachedHistory.unshift(History(url, title));
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -831,12 +831,7 @@ function History() //{{{
|
|||||||
return liberator.open([i[0] for each (i in items)], liberator.NEW_TAB);
|
return liberator.open([i[0] for each (i in items)], liberator.NEW_TAB);
|
||||||
|
|
||||||
// TODO: is there a faster way to limit to max. 1000 items?
|
// TODO: is there a faster way to limit to max. 1000 items?
|
||||||
let list = template.bookmarks("title", (
|
let list = template.bookmarks("title", items);
|
||||||
{
|
|
||||||
url: item[0],
|
|
||||||
title: item[1],
|
|
||||||
icon: bookmarks.getFavicon(item[0])
|
|
||||||
} for each ([i, item] in Iterator(items)) if (i < 1000)));
|
|
||||||
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
|
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ function Buffer() //{{{
|
|||||||
{
|
{
|
||||||
if (mappings.repeat)
|
if (mappings.repeat)
|
||||||
{
|
{
|
||||||
for (let i in util.rangeInterruptable(0, count > 1 ? count : 1, 100))
|
for (let i in util.rangeInterruptable(0, Math.max(count, 1), 100))
|
||||||
mappings.repeat();
|
mappings.repeat();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -529,13 +529,6 @@ function Completion() //{{{
|
|||||||
};
|
};
|
||||||
let javascript = new Javascript();
|
let javascript = new Javascript();
|
||||||
|
|
||||||
// FIXME: unused, remove? If not, document, what it does.
|
|
||||||
// Those one liners might be convinient to write, but not to read --mst
|
|
||||||
function filterFavicon(array, want)
|
|
||||||
{
|
|
||||||
return want ? array : [a[2] ? a.slice(0, 2) : a for ([i, a] in Iterator(array))];
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildSubstrings(str, filter)
|
function buildSubstrings(str, filter)
|
||||||
{
|
{
|
||||||
if (filter == "")
|
if (filter == "")
|
||||||
|
|||||||
@@ -71,17 +71,20 @@ function IO() //{{{
|
|||||||
|
|
||||||
function expandPathList(list) list.split(",").map(io.expandPath).join(",")
|
function expandPathList(list) list.split(",").map(io.expandPath).join(",")
|
||||||
|
|
||||||
|
function replacePathSep(path)
|
||||||
|
{
|
||||||
|
if (WINDOWS)
|
||||||
|
return path.replace("/", "\\");
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: why are we passing around so many strings? I know that the XPCOM
|
// TODO: why are we passing around so many strings? I know that the XPCOM
|
||||||
// file API is limited but...
|
// file API is limited but...
|
||||||
function joinPaths(head, tail)
|
function joinPaths(head, tail)
|
||||||
{
|
{
|
||||||
let pathSeparator = WINDOWS ? "\\" : "/";
|
let path = ioManager.getFile(head);
|
||||||
let sep = pathSeparator.replace("\\", "\\\\");
|
path.appendRelativePath(tail);
|
||||||
|
return path;
|
||||||
head = head.replace(RegExp(sep + "$"), "");
|
|
||||||
tail = tail.replace(RegExp("^" + sep), "");
|
|
||||||
|
|
||||||
return head + pathSeparator + tail;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var downloadListener = {
|
var downloadListener = {
|
||||||
@@ -170,7 +173,7 @@ function IO() //{{{
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var directories = options["cdpath"].replace(/^,$|^,,|,,$/, "").split(",");
|
var directories = options["cdpath"].split(",");
|
||||||
|
|
||||||
// empty 'cdpath' items mean the current directory
|
// empty 'cdpath' items mean the current directory
|
||||||
directories = directories.map(
|
directories = directories.map(
|
||||||
@@ -179,9 +182,9 @@ function IO() //{{{
|
|||||||
|
|
||||||
var directoryFound = false;
|
var directoryFound = false;
|
||||||
|
|
||||||
for (let i = 0; i < directories.length; i++)
|
for (let [,dir] in Iterator(directories))
|
||||||
{
|
{
|
||||||
var dir = joinPaths(directories[i], args);
|
dir = joinPaths(dir, args).path;
|
||||||
if (io.setCurrentDirectory(dir))
|
if (io.setCurrentDirectory(dir))
|
||||||
{
|
{
|
||||||
// FIXME: we're just overwriting the error message from
|
// FIXME: we're just overwriting the error message from
|
||||||
@@ -372,20 +375,19 @@ function IO() //{{{
|
|||||||
home = environmentService.get("USERPROFILE") ||
|
home = environmentService.get("USERPROFILE") ||
|
||||||
environmentService.get("HOMEDRIVE") + environmentService.get("HOMEPATH");
|
environmentService.get("HOMEDRIVE") + environmentService.get("HOMEPATH");
|
||||||
|
|
||||||
path = path.replace("~", home);
|
path = home + path.substr(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// expand any $ENV vars - this is naive but so is Vim and we like to be compatible
|
// expand any $ENV vars - this is naive but so is Vim and we like to be compatible
|
||||||
// TODO: Vim does not expand variables set to an empty string, nor does it recognise
|
// TODO: Vim does not expand variables set to an empty string, nor does it recognise
|
||||||
// ${VAR} on WINDOWS - are we just matching bugs?
|
// ${VAR} on WINDOWS - are we just matching bugs?
|
||||||
|
// Yes. --Kris
|
||||||
path = path.replace(
|
path = path.replace(
|
||||||
RegExp("(?:\\$(\\w+)\\b|" + (WINDOWS ? "%(\\w+)%" : "\\${(\\w+)}") + ")", "g"),
|
WINDOWS ? /\$(\w+)\b|%(\w+)%/g : /\$(\w+)\b|\${(\w+)}/g,
|
||||||
function (m, n1, n2, i, s) environmentService.get((n1 || n2), "$1")
|
function (m, n1, n2, i, s) environmentService.get((n1 || n2), "$1")
|
||||||
);
|
);
|
||||||
|
|
||||||
path = path.replace("\\ ", " ", "g");
|
return path.replace("\\ ", " ", "g");
|
||||||
|
|
||||||
return path;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: there seems to be no way, short of a new component, to change
|
// TODO: there seems to be no way, short of a new component, to change
|
||||||
@@ -430,9 +432,8 @@ function IO() //{{{
|
|||||||
{
|
{
|
||||||
let dirs = options["runtimepath"].split(",");
|
let dirs = options["runtimepath"].split(",");
|
||||||
|
|
||||||
dirs = dirs.map(function (dir) io.getFile(joinPaths(dir, specialDirectory)))
|
dirs = dirs.map(function (dir) joinPaths(dir, specialDirectory))
|
||||||
.filter(function (dir) dir.exists() && dir.isDirectory() && dir.isReadable());
|
.filter(function (dir) dir.exists() && dir.isDirectory() && dir.isReadable());
|
||||||
|
|
||||||
return dirs;
|
return dirs;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -440,8 +441,8 @@ function IO() //{{{
|
|||||||
{
|
{
|
||||||
dir = dir || "~";
|
dir = dir || "~";
|
||||||
|
|
||||||
let rcFile1 = ioManager.getFile(joinPaths(dir, "/." + EXTENSION_NAME + "rc"));
|
let rcFile1 = joinPaths(dir, "." + EXTENSION_NAME + "rc");
|
||||||
let rcFile2 = ioManager.getFile(joinPaths(dir, "/_" + EXTENSION_NAME + "rc"));
|
let rcFile2 = joinPaths(dir, "_" + EXTENSION_NAME + "rc");
|
||||||
|
|
||||||
if (WINDOWS)
|
if (WINDOWS)
|
||||||
[rcFile1, rcFile2] = [rcFile2, rcFile1];
|
[rcFile1, rcFile2] = [rcFile2, rcFile1];
|
||||||
@@ -457,7 +458,7 @@ function IO() //{{{
|
|||||||
// return a nsILocalFile for path where you can call isDirectory(), etc. on
|
// return a nsILocalFile for path where you can call isDirectory(), etc. on
|
||||||
// caller must check with .exists() if the returned file really exists
|
// caller must check with .exists() if the returned file really exists
|
||||||
// also expands relative paths
|
// also expands relative paths
|
||||||
getFile: function (path)
|
getFile: function (path, noCheckPWD)
|
||||||
{
|
{
|
||||||
let file = Components.classes["@mozilla.org/file/local;1"]
|
let file = Components.classes["@mozilla.org/file/local;1"]
|
||||||
.createInstance(Components.interfaces.nsILocalFile);
|
.createInstance(Components.interfaces.nsILocalFile);
|
||||||
@@ -472,9 +473,9 @@ function IO() //{{{
|
|||||||
{
|
{
|
||||||
let expandedPath = ioManager.expandPath(path);
|
let expandedPath = ioManager.expandPath(path);
|
||||||
|
|
||||||
if (!/^([a-zA-Z]:|\/)/.test(expandedPath)) // doesn't start with /, C:
|
if (!/^([a-zA-Z]:|\/)/.test(expandedPath) && !noCheckPWD) // doesn't start with /, C:
|
||||||
expandedPath = joinPaths(ioManager.getCurrentDirectory().path, expandedPath);
|
file = joinPaths(ioManager.getCurrentDirectory().path, expandedPath);
|
||||||
|
else
|
||||||
file.initWithPath(expandedPath);
|
file.initWithPath(expandedPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -603,9 +604,6 @@ function IO() //{{{
|
|||||||
|
|
||||||
run: function (program, args, blocking)
|
run: function (program, args, blocking)
|
||||||
{
|
{
|
||||||
var file = Components.classes["@mozilla.org/file/local;1"]
|
|
||||||
.createInstance(Components.interfaces.nsILocalFile);
|
|
||||||
|
|
||||||
if (!args)
|
if (!args)
|
||||||
args = [];
|
args = [];
|
||||||
|
|
||||||
@@ -614,18 +612,17 @@ function IO() //{{{
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
file.initWithPath(program);
|
var file = ioManager.getFile(program, !WINDOWS);
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
var dirs = environmentService.get("PATH").split(WINDOWS ? ";" : ":");
|
var dirs = environmentService.get("PATH").split(WINDOWS ? ";" : ":");
|
||||||
lookup:
|
lookup:
|
||||||
for (let i = 0; i < dirs.length; i++)
|
for (let [,dir] in Iterator(dirs))
|
||||||
{
|
{
|
||||||
var path = joinPaths(dirs[i], program);
|
file = joinPaths(dir, program);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
file.initWithPath(path);
|
|
||||||
if (file.exists())
|
if (file.exists())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -633,11 +630,10 @@ lookup:
|
|||||||
// automatically try to add the executable path extensions on windows
|
// automatically try to add the executable path extensions on windows
|
||||||
if (WINDOWS)
|
if (WINDOWS)
|
||||||
{
|
{
|
||||||
var extensions = environmentService.get("PATHEXT").split(";");
|
let extensions = environmentService.get("PATHEXT").split(";");
|
||||||
for (let j = 0; j < extensions.length; j++)
|
for (let [,extension] in Iterator(extension))
|
||||||
{
|
{
|
||||||
path = joinPaths(dirs[i], program) + extensions[j];
|
file = joinPaths(dir, program + extension);
|
||||||
file.initWithPath(path);
|
|
||||||
if (file.exists())
|
if (file.exists())
|
||||||
break lookup;
|
break lookup;
|
||||||
}
|
}
|
||||||
@@ -726,7 +722,7 @@ lookup:
|
|||||||
{
|
{
|
||||||
for (let [,path] in Iterator(paths))
|
for (let [,path] in Iterator(paths))
|
||||||
{
|
{
|
||||||
let file = io.getFile(joinPaths(runtimeDir, path));
|
let file = joinPaths(runtimeDir, path);
|
||||||
|
|
||||||
liberator.echomsg("Searching for \"" + file.path, 3);
|
liberator.echomsg("Searching for \"" + file.path, 3);
|
||||||
|
|
||||||
@@ -778,7 +774,7 @@ lookup:
|
|||||||
liberator.echomsg("sourcing \"" + filename + "\"", 2);
|
liberator.echomsg("sourcing \"" + filename + "\"", 2);
|
||||||
|
|
||||||
let str = ioManager.readFile(file);
|
let str = ioManager.readFile(file);
|
||||||
let uri = util.createURI(file.path);
|
let uri = makeFileURI(file);
|
||||||
|
|
||||||
// handle pure javascript files specially
|
// handle pure javascript files specially
|
||||||
if (/\.js$/.test(filename))
|
if (/\.js$/.test(filename))
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ function Highlights(name, store, serial)
|
|||||||
|
|
||||||
Bell,#liberator-visualbell border: none; background-color: black;
|
Bell,#liberator-visualbell border: none; background-color: black;
|
||||||
Hint,.liberator-hint,* {
|
Hint,.liberator-hint,* {
|
||||||
z-index: 5000;
|
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
@@ -76,10 +75,8 @@ function Highlights(name, store, serial)
|
|||||||
border-width: 0px;
|
border-width: 0px;
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
padding: 0px 1px 0px 1px;
|
padding: 0px 1px 0px 1px;
|
||||||
position: absolute;
|
|
||||||
}
|
}
|
||||||
Search,.liberator-search,* {
|
Search,.liberator-search,* {
|
||||||
display: inline;
|
|
||||||
font-size: inherit;
|
font-size: inherit;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
color: black;
|
color: black;
|
||||||
|
|||||||
@@ -1387,8 +1387,8 @@ function ItemList(id) //{{{
|
|||||||
|
|
||||||
let dom = util.xmlToDom(div, doc);
|
let dom = util.xmlToDom(div, doc);
|
||||||
completionBody = dom.getElementsByClassName("hl-Completions")[0];
|
completionBody = dom.getElementsByClassName("hl-Completions")[0];
|
||||||
//completionElements = completionBody.childNodes;
|
completionElements = completionBody.childNodes;
|
||||||
completionElements = dom.getElementsByClassName("hl-CompItem");
|
//completionElements = dom.getElementsByClassName("hl-CompItem");
|
||||||
doc.body.replaceChild(dom, doc.body.firstChild);
|
doc.body.replaceChild(dom, doc.body.firstChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -505,7 +505,7 @@ function Struct()
|
|||||||
ConStructor.defaultValue = function (key, val)
|
ConStructor.defaultValue = function (key, val)
|
||||||
{
|
{
|
||||||
let i = args.indexOf(key);
|
let i = args.indexOf(key);
|
||||||
ConStructor.prototype.__defineGetter__(i, val);
|
ConStructor.prototype.__defineGetter__(i, function () this[i] = val.call(this));
|
||||||
ConStructor.prototype.__defineSetter__(i, function (val) {
|
ConStructor.prototype.__defineSetter__(i, function (val) {
|
||||||
let value = val;
|
let value = val;
|
||||||
this.__defineGetter__(i, function () value);
|
this.__defineGetter__(i, function () value);
|
||||||
|
|||||||
Reference in New Issue
Block a user