1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-03-06 06:45:45 +01:00
This commit is contained in:
Kris Maglione
2009-03-12 22:05:38 -04:00
46 changed files with 406 additions and 350 deletions

View File

@@ -3,10 +3,11 @@
TOP = $(shell pwd)
OS = $(shell uname -s)
BUILD_DATE = $(shell date "+%Y/%m/%d %H:%M:%S")
BASE = $(TOP)/../common
BASE = $(TOP)/../common
DOC_SRC_FILES = $(wildcard locale/*/*.txt)
LOCALES = $(wildcard locale/*)
LOCALEDIR = locale
DOC_SRC_FILES = $(wildcard $(LOCALEDIR)/*/*.txt)
LOCALES = $(foreach locale,$(wildcard $(LOCALEDIR)/*),$(word 2,$(subst /, ,$(locale))))
MAKE_JAR = VERSION="$(VERSION)" DATE="$(BUILD_DATE)" sh $(BASE)/make_jar.sh
@@ -26,7 +27,7 @@ XPI_BINS = jar
XPI_NAME = $(NAME)_$(VERSION)
XPI_PATH = ../downloads/$(XPI_NAME)
XPI = $(XPI_PATH).xpi
XPI = $(XPI_PATH).xpi
RDF = ../downloads/update.rdf
RDF_IN = $(RDF).in
@@ -80,11 +81,11 @@ $(RDF): $(RDF_IN) Makefile
< $< > $@
@echo "SUCCESS: $@"
clean: $(LOCALES:%=%.clean)
clean: $(LOCALEDIR)/$(LOCALES:%=%.clean)
@echo "General $(NAME) cleanup..."
rm -f $(JAR) $(XPI)
distclean: $(LOCALES:%=%.distclean) clean
distclean: $(LOCALEDIR)/$(LOCALES:%=%.distclean) clean
@echo "More $(NAME) cleanup..."
rm -rf $(BUILD_DIR)
@@ -106,4 +107,4 @@ $(JAR): doc
#### doc (see Makefile.doc)
doc: $(LOCALES:%=%.doc) ;
doc: $(foreach localetgt,$(LOCALES:%=%.doc),$(addprefix $(LOCALEDIR)/,$(localetgt))) ;

View File

@@ -1,4 +1,4 @@
# Symlink or me to (or include me from) locale/*/Makefile
# Symlink me to (or include me from) locale/*/Makefile
#### configuration
@@ -12,7 +12,7 @@ ADC_SRC_FILES = $(wildcard *.txt)
ADC_FILES = $(ADC_SRC_FILES:%.txt=%.html)
ADC_DEPS = $(wildcard asciidoc.conf lang-$(LANG).conf)
DOC_FILES = $(ADC_FILES)
DOC_FILES = $(ADC_FILES) version.html
.SILENT:
@@ -44,7 +44,7 @@ distclean: clean
#### asciidoc
asciidoc: check-asciidoc $(ADC_FILES)
asciidoc: check-asciidoc $(DOC_FILES)
check-asciidoc:
@$(ASCIIDOC) --version | $(AWK) '{ exit $$2 !~ /^8\.2\./ }' || \
@@ -54,3 +54,9 @@ $(ADC_FILES): %.html: %.txt $(BASE)/Makefile.doc $(ADC_DEPS)
@echo "DOC locale/$(LOCALE)/$@"
$(ASCIIDOC) --unsafe -a linkcss -a quirks! -a lang=$(LANG) -a doctitle="$(shell basename $@)" -o $@ $<
version.html: ../../NEWS $(BASE)/Makefile.doc $(ADC_DEPS)
@echo "DOC locale/$(LOCALE)/$@"
# NOTE: asciidoc doesn't source the conf file implicitly when processing stdin
sed -e '1i\
HEADER' -e '/^[0-9]/d' -e '/^ \+\* version /s/.*version \+\([0-9.]\+\).*/section:Version{nbsp}\1[version-\1]\
/' ../../NEWS | ${ASCIIDOC} -f asciidoc.conf -a doctitle=version.html -o version.html -

View File

@@ -1050,7 +1050,12 @@ function Buffer() //{{{
function followFrame(frame)
{
function iter(elems) (e for ([i, e] in Iterator(elems)) if (e.rel.toLowerCase() == rel || e.rev.toLowerCase() == rel));
function iter(elems)
{
for (let i = 0; i < elems.length; i++)
if (elems[i].rel.toLowerCase() == rel || elems[i].rev.toLowerCase() == rel)
yield elems[i];
}
// <link>s have higher priority than normal <a> hrefs
let elems = frame.document.getElementsByTagName("link");
@@ -1074,13 +1079,7 @@ function Buffer() //{{{
for (let i in util.range(res.snapshotLength, 0, -1))
{
let elem = res.snapshotItem(i);
if (regex.test(elem.textContent))
{
buffer.followLink(elem, liberator.CURRENT_TAB);
return true;
}
// images with alt text being href
if (Array.some(elem.childNodes, function (child) regex.test(child.alt)))
if (regex.test(elem.textContent) || Array.some(elem.childNodes, function (child) regex.test(child.alt)))
{
buffer.followLink(elem, liberator.CURRENT_TAB);
return true;

View File

@@ -607,8 +607,12 @@ function Editor() //{{{
unselectText: function ()
{
let elem = window.document.commandDispatcher.focusedElement;
if (elem && elem.selectionEnd)
elem.selectionEnd = elem.selectionStart;
// A error occurs if the element has been removed when "elem.selectionStart" is executed.
try {
if (elem && elem.selectionEnd)
elem.selectionEnd = elem.selectionStart;
}
catch (e) {}
},
selectedText: function ()

View File

@@ -639,7 +639,7 @@ function Events() //{{{
{
for (let [,dir] in Iterator(dirs))
{
liberator.echomsg('Searching for "macros/*" in ' + dir.path.quote(), 2);
liberator.echomsg('Searching for "macros/*" in "' + dir.path + '"', 2);
liberator.log("Sourcing macros directory: " + dir.path + "...", 3);
@@ -932,6 +932,8 @@ function Events() //{{{
{
if (!ctrl && !alt && !shift && !meta)
return false; // an invalid key like <a>
else if (shift)
keyname = keyname.toUpperCase();
charCode = keyname.charCodeAt(0);
}
else if (keyname.toLowerCase() == "space")
@@ -1054,7 +1056,7 @@ function Events() //{{{
//
else if (liberator.has("MacUnix") && event.ctrlKey && event.charCode >= 27 && event.charCode <= 31)
{
if(event.charCode == 27) // [Ctrl-Bug 1/5] the <C-[> bug
if (event.charCode == 27) // [Ctrl-Bug 1/5] the <C-[> bug
{
key = "Esc";
modifier = modifier.replace("C-", "");
@@ -1373,8 +1375,11 @@ function Events() //{{{
if (key == "<C-c>" && !event.isMacro)
{
events.feedingKeys = false;
if (lastMacro)
if (modes.isReplaying)
{
modes.isReplaying = false;
setTimeout(function () { liberator.echomsg("Canceled playback of macro '" + lastMacro + "'"); }, 100);
}
event.preventDefault();
event.stopPropagation();
return true;

View File

@@ -575,7 +575,7 @@ function Hints() //{{{
function (count)
{
extendedhintCount = count;
commandline.input(";", function (arg) { setTimeout(function () hints.show(arg), 0); },
commandline.input(";", null,
{
promptHighlight: "Normal",
completer: function (context)
@@ -583,7 +583,8 @@ function Hints() //{{{
context.compare = function () 0;
context.completions = [[k, v.prompt] for ([k, v] in Iterator(hintModes))];
},
onChange: function () { modes.pop() }
onChange: function () { modes.pop() },
onCancel: function (arg) { arg && setTimeout(function () hints.show(arg), 0); },
});
}, { flags: Mappings.flags.COUNT });

View File

@@ -250,7 +250,7 @@ function IO() //{{{
if (!found)
{
liberator.echoerr("E344: Can't find directory " + arg.quote() + " in cdpath\n"
liberator.echoerr("E344: Can't find directory \"" + arg + "\" in cdpath\n"
+ "E472: Command failed");
}
}
@@ -283,7 +283,7 @@ function IO() //{{{
if (file.exists() && !args.bang)
{
liberator.echoerr("E189: " + filename.quote() + " exists (add ! to override)");
liberator.echoerr("E189: \"" + filename + "\" exists (add ! to override)");
return;
}
@@ -302,7 +302,7 @@ function IO() //{{{
}
catch (e)
{
liberator.echoerr("E190: Cannot open " + filename.quote() + " for writing");
liberator.echoerr("E190: Cannot open \"" + filename + "\" for writing");
liberator.log("Could not write to " + file.path + ": " + e.message); // XXX
}
},
@@ -524,7 +524,7 @@ function IO() //{{{
if (!dir.exists() || !dir.isDirectory())
{
liberator.echoerr("E344: Can't find directory " + dir.path.quote() + " in path");
liberator.echoerr("E344: Can't find directory \"" + dir.path + "\" in path");
return null;
}
@@ -842,7 +842,7 @@ lookup:
let found = false;
// FIXME: should use original arg string
liberator.echomsg("Searching for " + paths.join(" ").quote() + " in " + options["runtimepath"].quote(), 2);
liberator.echomsg("Searching for \"" + paths.join(" ") + "\" in \"" + options["runtimepath"] + "\"", 2);
outer:
for (let [,dir] in Iterator(dirs))
@@ -851,7 +851,7 @@ lookup:
{
let file = joinPaths(dir, path);
liberator.echomsg("Searching for " + file.path.quote(), 3);
liberator.echomsg("Searching for \"" + file.path + "\"", 3);
if (file.exists() && file.isFile() && file.isReadable())
{
@@ -865,7 +865,7 @@ lookup:
}
if (!found)
liberator.echomsg("not found in 'runtimepath': " + paths.join(" ").quote(), 1); // FIXME: should use original arg string
liberator.echomsg("not found in 'runtimepath': \"" + paths.join(" ") + "\"", 1); // FIXME: should use original arg string
return found;
},
@@ -892,9 +892,9 @@ lookup:
if (!silent)
{
if (file.exists() && file.isDirectory())
liberator.echomsg("Cannot source a directory: " + filename.quote(), 0);
liberator.echomsg("Cannot source a directory: \"" + filename + "\"", 0);
else
liberator.echomsg("could not source: " + filename.quote(), 1);
liberator.echomsg("could not source: \"" + filename + "\"", 1);
liberator.echoerr("E484: Can't open file " + filename);
}
@@ -902,7 +902,7 @@ lookup:
return;
}
liberator.echomsg("sourcing " + filename.quote(), 2);
liberator.echomsg("sourcing \"" + filename + "\"", 2);
let str = self.readFile(file);
let uri = services.get("io").newFileURI(file);
@@ -1012,7 +1012,7 @@ lookup:
if (scriptNames.indexOf(file.path) == -1)
scriptNames.push(file.path);
liberator.echomsg("finished sourcing " + filename.quote(), 2);
liberator.echomsg("finished sourcing \"" + filename + "\"", 2);
liberator.log("Sourced: " + filename, 3);
}

View File

@@ -264,7 +264,7 @@ const liberator = (function () //{{{
for (let [,dialog] in Iterator(dialogs))
{
if (arg == dialog[0])
if (util.compareIgnoreCase(arg, dialog[0]) == 0)
{
dialog[2]();
return;
@@ -281,7 +281,11 @@ const liberator = (function () //{{{
{
argCount: "1",
bang: true,
completer: function (context, args) completion.dialog(context)
completer: function (context)
{
context.ignoreCase = true;
return completion.dialog(context);
}
});
commands.add(["em[enu]"],
@@ -601,7 +605,7 @@ const liberator = (function () //{{{
forceNewTab: false,
// ###VERSION### and ###DATE### are replaced by the Makefile
// these VERSION and DATE tokens are replaced by the Makefile
version: "###VERSION### (created: ###DATE###)",
// NOTE: services.get("profile").selectedProfile.name is not rightness.
@@ -842,7 +846,7 @@ const liberator = (function () //{{{
// Number
else if (matches = string.match(/^(\d+)$/))
{
return parseInt(match[1], 10);
return parseInt(matches[1], 10);
}
let reference = this.variableReference(string);
@@ -1025,11 +1029,11 @@ const liberator = (function () //{{{
return;
}
liberator.echomsg('Searching for "plugin/**/*.{js,vimp}" in '
+ [dir.path.replace(/.plugin$/, "") for each (dir in dirs)].join(",").quote(), 2);
liberator.echomsg('Searching for "plugin/**/*.{js,vimp}" in "'
+ [dir.path.replace(/.plugin$/, "") for each (dir in dirs)].join(",") + '"', 2);
dirs.forEach(function (dir) {
liberator.echomsg("Searching for " + (dir.path + "/**/*.{js,vimp}").quote(), 3);
liberator.echomsg("Searching for \"" + (dir.path + "/**/*.{js,vimp}") + "\"", 3);
sourceDirectory(dir);
});
},
@@ -1417,16 +1421,24 @@ window.liberator = liberator;
// FIXME: Ugly, etc.
window.addEventListener("liberatorHelpLink", function (event) {
let elem = event.target;
if (/^(option|mapping|command)$/.test(elem.className))
var tag = elem.textContent.replace(/\s.*/, "");
if (/^(mapping|command)$/.test(elem.className))
tag = tag.replace(/^\d+/, "");
if (elem.className == "command")
tag = tag.replace(/\[.*?\]/g, "");
tag = tag.replace(/\[.*?\]/g, "").replace(/!$/, "");
if (tag)
var page = liberator.findHelp(tag);
if (page)
{
elem.href = "chrome://liberator/locale/" + page;
},
true, true);
if (buffer.URL.replace(/#.*/, "") == elem.href.replace(/#.*/, "")) // XXX
setTimeout(function () { content.postMessage("fragmentChange", "*"); }, 0);
}
}, true, true);
// called when the chrome is fully loaded and before the main window is shown
window.addEventListener("load", liberator.startup, false);

View File

@@ -335,7 +335,11 @@ function Options() //{{{
{
case "string":
if (type == Ci.nsIPrefBranch.PREF_INVALID || type == Ci.nsIPrefBranch.PREF_STRING)
services.get("pref").setCharPref(name, value);
{
let supportString = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
supportString.data = value;
services.get("pref").setComplexValue(name, Ci.nsISupportsString, supportString);
}
else if (type == Ci.nsIPrefBranch.PREF_INT)
liberator.echoerr("E521: Number required after =: " + name + "=" + value);
else

View File

@@ -224,6 +224,7 @@ const template = {
return s + <>{str.substr(start)}</>;
},
// FIXME: why is href="#"?
highlightURL: function highlightURL(str, force)
{
if (force || /^[a-zA-Z]+:\/\//.test(str))
@@ -263,7 +264,7 @@ const template = {
<td class="indicator">{idx == index ? ">" : ""}</td>
<td>{Math.abs(idx - index)}</td>
<td style="width: 250px; max-width: 500px; overflow: hidden;">{val.title}</td>
<td><a href="#" highlight="URL jump-list">{val.URI.spec}</a></td>
<td><a href={val.URI.spec} highlight="URL jump-list">{val.URI.spec}</a></td>
</tr>)
}
</table>);

View File

@@ -529,7 +529,7 @@ function CommandLine() //{{{
autocompleteTimer.tell(false);
});
liberator.registerCallback("cancel", modes.PROMPT, closePrompt);
liberator.registerCallback("cancel", modes.PROMPT, cancelPrompt);
liberator.registerCallback("submit", modes.PROMPT, closePrompt);
liberator.registerCallback("change", modes.PROMPT, function (str) {
if (input.complete)
@@ -542,6 +542,14 @@ function CommandLine() //{{{
context.fork("input", 0, commandline, input.complete);
});
function cancelPrompt(value)
{
let callback = input.cancel;
input = {};
if (callback)
callback.call(commandline, value != null ? value : commandline.command);
}
function closePrompt(value)
{
let callback = input.submit;
@@ -1202,6 +1210,7 @@ function CommandLine() //{{{
submit: callback,
change: extra.onChange,
complete: extra.completer,
cancel: extra.onCancel
};
modes.push(modes.COMMAND_LINE, modes.PROMPT);
@@ -1400,25 +1409,53 @@ function CommandLine() //{{{
let closeWindow = false;
let passEvent = false;
function isScrollable() !win.scrollMaxY == 0;
function atEnd() win.scrollY / win.scrollMaxY >= 1;
let key = events.toString(event);
if (event.type == "click")
// TODO: Wouldn't multiple handlers be cleaner? --djk
if (event.type == "click" && event.target instanceof HTMLAnchorElement)
{
if (event.target instanceof HTMLAnchorElement && event.button < 2)
function openLink(where)
{
event.preventDefault();
let target = event.button == 0 ? liberator.CURRENT_TAB : liberator.NEW_TAB;
// FIXME: Why is this needed? --djk
if (event.target.getAttribute("href") == "#")
liberator.open(event.target.textContent, target);
liberator.open(event.target.textContent, where);
else
liberator.open(event.target.href, target);
liberator.open(event.target.href, where);
}
switch (key)
{
case "<LeftMouse>":
// FIXME: the :ls output no longer wraps the buffer URL in an anchor element
if (event.originalTarget.getAttributeNS(NS.uri, "highlight") == "URL buffer-list")
{
event.preventDefault();
tabs.select(parseInt(event.originalTarget.parentNode.parentNode.firstChild.textContent, 10) - 1);
}
else
{
openLink(liberator.CURRENT_TAB);
}
break;
case "<MiddleMouse>":
case "<C-LeftMouse>":
case "<C-M-LeftMouse>":
openLink(liberator.NEW_BACKGROUND_TAB);
break;
case "<S-MiddleMouse>":
case "<C-S-LeftMouse>":
case "<C-M-S-LeftMouse>":
openLink(liberator.NEW_TAB);
break;
case "<S-LeftMouse>":
openLink(liberator.NEW_WINDOW);
break;
}
return;
}
let key = events.toString(event);
if (startHints)
{
statusline.updateInputBuffer("");
@@ -1427,6 +1464,9 @@ function CommandLine() //{{{
return;
}
function isScrollable() !win.scrollMaxY == 0;
function atEnd() win.scrollY / win.scrollMaxY >= 1;
switch (key)
{
case "<Esc>":
@@ -1476,34 +1516,6 @@ function CommandLine() //{{{
break;
// TODO: <LeftMouse> on the prompt line should scroll one page
case "<LeftMouse>":
if (event.originalTarget.getAttributeNS(NS.uri, "highlight") == "URL buffer-list")
{
tabs.select(parseInt(event.originalTarget.parentNode.parentNode.firstChild.textContent, 10) - 1);
closeWindow = true;
break;
}
else if (event.originalTarget.localName.toLowerCase() == "a")
{
liberator.open(event.originalTarget.textContent);
break;
}
case "<A-LeftMouse>": // for those not owning a 3-button mouse
case "<MiddleMouse>":
if (event.originalTarget.localName.toLowerCase() == "a")
{
let where = /\btabopen\b/.test(options["activate"]) ?
liberator.NEW_TAB : liberator.NEW_BACKGROUND_TAB;
liberator.open(event.originalTarget.textContent, where);
}
break;
// let Firefox handle those to select table cells or show a context menu
case "<C-LeftMouse>":
case "<RightMouse>":
case "<C-S-LeftMouse>":
break;
// page down
case "f":
if (options["more"] && isScrollable())
@@ -1594,7 +1606,7 @@ function CommandLine() //{{{
if (passEvent)
events.onKeyPress(event);
}
else // set update the prompt string
else
{
commandline.updateMorePrompt(showMorePrompt, showMoreHelpPrompt);
}
@@ -1698,7 +1710,7 @@ function ItemList(id) //{{{
if (!iframe)
{
liberator.log("No iframe with id: " + id + " found, strange things may happen!"); // "The truth is out there..." -- djk
return;
return; // XXX
}
function dom(xml, map) util.xmlToDom(xml, doc, map);

View File

@@ -577,7 +577,7 @@ const util = { //{{{
*/
readFromClipboard: function readFromClipboard()
{
let url;
let str;
try
{
@@ -599,12 +599,12 @@ const util = { //{{{
if (data)
{
data = data.value.QueryInterface(Ci.nsISupportsString);
url = data.data.substring(0, dataLen.value / 2);
str = data.data.substring(0, dataLen.value / 2);
}
}
catch (e) {}
return url;
return str;
},
/**