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

Merge branch 'master' into vimperator-2.1

Conflicts:
	vimperator/NEWS
	vimperator/locale/en-US/starting.txt
This commit is contained in:
Doug Kearns
2009-02-26 22:11:12 +11:00
58 changed files with 911 additions and 733 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) $(wildcard locale/*/*.t2t)
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
@@ -16,7 +17,7 @@ JAR_DIRS = content skin locale
JAR_TEXTS = js css dtd xml xul html xhtml
JAR_BINS = png
JAR = chrome/${NAME}.jar
JAR = chrome/$(NAME).jar
XPI_BASES = $(JAR_BASES) $(TOP)/..
XPI_FILES = install.rdf TODO AUTHORS Donators NEWS License.txt
@@ -24,32 +25,38 @@ XPI_DIRS = modules components chrome
XPI_TEXTS = js jsm
XPI_BINS = jar
XPI_NAME = ${NAME}_${VERSION}
XPI_PATH = ../downloads/${XPI_NAME}
XPI = $(XPI_PATH).xpi
XPI_NAME = $(NAME)_$(VERSION)
XPI_PATH = ../downloads/$(XPI_NAME)
XPI = $(XPI_PATH).xpi
RDF = ../downloads/update.rdf
RDF_IN = ${RDF}.in
RDF_IN = $(RDF).in
BUILD_DIR = build.${VERSION}.${OS}
BUILD_DIR = build.$(VERSION).$(OS)
ASCIIDOC = asciidoc
AWK = awk
.SILENT:
#### rules
.PHONY: all help info doc jar xpi install clean distclean $(JAR)
TARGETS = all help info doc jar xpi install clean distclean $(JAR)
$(TARGETS:%=\%.%):
echo MAKE $* $(@:$*.%=%)
$(MAKE) -C $* $(@:$*.%=%)
.PHONY: $(TARGETS)
all: help
help:
@echo "${NAME} ${VERSION} build"
@echo "$(NAME) $(VERSION) build"
@echo
@echo " make help - display this help"
@echo " make info - show some info about the system"
@echo " make doc - build doc files"
@echo " make jar - build a JAR (${JAR})"
@echo " make xpi - build an XPI (${XPI_NAME})"
@echo " make jar - build a JAR ($(JAR))"
@echo " make xpi - build an XPI ($(XPI_NAME))"
@echo " make release - updates update.rdf (this is not for you)"
@echo " make clean - clean up"
@echo " make distclean - clean up more"
@@ -57,39 +64,37 @@ help:
@echo "running some commands with V=1 will show more build details"
info:
@echo "version ${VERSION}"
@echo "release file ${XPI}"
@echo "doc files ${DOC_SRC_FILES}"
@echo -e "jar files $(shell echo ${JAR_FILES} | sed 's/ /\\n /g' )"
@echo "xpi files ${XPI_FILES}"
@echo "version $(VERSION)"
@echo "release file $(XPI)"
@echo "doc files $(DOC_SRC_FILES)"
@echo "xpi files $(XPI_FILES)"
xpi: ${XPI}
jar: ${JAR}
xpi: $(XPI)
jar: $(JAR)
release: ${XPI} ${RDF}
release: $(XPI) $(RDF)
${RDF}: ${RDF_IN} Makefile
$(RDF): $(RDF_IN) Makefile
@echo "Preparing release..."
${Q}${SED} -e "s,###VERSION###,${VERSION},g" \
-e "s,###DATE###,${BUILD_DATE},g" \
$(SED) -e "s,###VERSION###,$(VERSION),g" \
-e "s,###DATE###,$(BUILD_DATE),g" \
< $< > $@
@echo "SUCCESS: $@"
clean:
@echo "Cleanup..."
rm -f ${JAR} ${XPI}
clean: $(LOCALEDIR)/$(LOCALES:%=%.clean)
@echo "General $(NAME) cleanup..."
rm -f $(JAR) $(XPI)
distclean: clean
@echo "More cleanup..."
@set -e; for locale in $(LOCALES); do $(MAKE) -C clean; doc; done
rm -rf ${BUILD_DIR}
distclean: $(LOCALEDIR)/$(LOCALES:%=%.distclean) clean
@echo "More $(NAME) cleanup..."
rm -rf $(BUILD_DIR)
#### xpi
$(XPI): $(JAR)
@echo "Building XPI..."
mkdir -p $(XPI_PATH)
awk -v 'name=$(NAME)' -f $(BASE)/process_manifest.awk $(TOP)/chrome.manifest >$(XPI_PATH)/chrome.manifest
$(AWK) -v 'name=$(NAME)' -f $(BASE)/process_manifest.awk $(TOP)/chrome.manifest >$(XPI_PATH)/chrome.manifest
$(MAKE_JAR) "$(XPI)" "$(XPI_BASES)" "$(XPI_DIRS)" "$(XPI_TEXTS)" "$(XPI_BINS)" "$(XPI_FILES)"
@echo "SUCCESS: $@"
@@ -102,5 +107,4 @@ $(JAR): doc
#### doc (see Makefile.doc)
doc:
@set -e; for locale in $(LOCALES); do $(MAKE) -C $$locale doc; done
doc: $(foreach localetgt,$(LOCALES:%=%.doc),$(addprefix $(LOCALEDIR)/,$(localetgt))) ;

View File

@@ -1,28 +1,18 @@
# Symlink me to locale/*/Makefile
# Symlink me to (or include me from) locale/*/Makefile
#### configuration
BASE = ../../../common
ASCIIDOC = asciidoc
AWK = awk
THIS_LOCALE = $(notdir $(shell pwd))
THIS_LANG = $(firstword $(subst -, ,$(THIS_LOCALE)))
ifneq ($(strip $(shell echo -n $(THIS_LANG) | wc -c)),2)
THIS_LANG = en
endif
LOCALE = $(shell basename `pwd`)
LANG = $(shell basename `pwd` | $(AWK) -F- '{ print ($$1 ~ /^[a-z][a-z]$$/) ? $$1 : "en" }')
ADC_SRC_FILES = $(wildcard *.txt)
ADC_FILES = $(ADC_SRC_FILES:%.txt=%.html)
ADC_DEPS = $(wildcard asciidoc.conf lang-$(THIS_LANG).conf)
ADC_DEPS = $(wildcard asciidoc.conf lang-$(LANG).conf)
T2T_SRC_FILES = $(wildcard *.t2t)
T2T_FILES = $(T2T_SRC_FILES:%.t2t=%.xhtml)
T2T_DEPS = $(wildcard config.t2t)
DOC_FILES = $(ADC_FILES) $(T2T_FILES)
ASCIIDOC = asciidoc
TXT2TAGS = txt2tags
AWK = awk
DOC_FILES = $(ADC_FILES) version.html
.SILENT:
@@ -31,49 +21,42 @@ AWK = awk
.PHONY: all help doc asciidoc check-asciidoc clean distclean
all: doc
doc: asciidoc t2t
doc: asciidoc
help:
@echo "${NAME} ${VERSION} build"
@echo "$(NAME) $(VERSION) build"
@echo
@echo " make help - display this help"
@echo " make doc - build doc files"
@echo " make asciidoc - build asciidoc'd files only"
@echo " make t2t - build txt2tags'd files only"
@echo " make clean - clean up"
@echo " make distclean - clean up more"
clean:
@echo "Cleanup..."
@echo "Cleanup of $(LOCALE) documentation..."
distclean: clean
@echo "More cleanup..."
@echo "More cleanup of $(LOCALE) documentation..."
rm -f $(DOC_FILES)
#### Makes single-file makes easier to type
%: %.html %.t2t %.xhtml %.t2t ;
%: %.html %.txt ;
%: %.xhtml %.t2t ;
#### asciidoc
asciidoc: check-asciidoc $(ADC_FILES)
asciidoc: check-asciidoc $(DOC_FILES)
check-asciidoc:
@$(ASCIIDOC) --version | $(AWK) '{ exit $$2 !~ /^8\.2\./ }' || \
echo >&2 "Warning: asciidoc versions other than 8.2.x are unsupported"
$(ADC_FILES): %.html: %.txt $(BASE)/Makefile.doc $(ADC_DEPS)
@echo "DOC locale/$(THIS_LOCALE)/$@"
$(ASCIIDOC) --unsafe -a linkcss -a quirks! -a lang=$(THIS_LANG) -a doctitle="$(shell basename $@)" -o $@ $<
@echo "DOC locale/$(LOCALE)/$@"
$(ASCIIDOC) --unsafe -a linkcss -a quirks! -a lang=$(LANG) -a doctitle="$(shell basename $@)" -o $@ $<
#### txt2tags
t2t: $(T2T_FILES)
$(T2T_FILES): %.xhtml: %.t2t $(BASE)/Makefile.doc $(T2T_DEPS)
@echo "T2T locale/$(THIS_LOCALE)/$@"
txt2tags --quiet $<
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

@@ -867,9 +867,16 @@ function Buffer() //{{{
/**
* @property {string} The current top-level document's URL.
*/
get URL()
get URL() window.content.location.href,
/**
* @property {string} The current top-level document's URL, sans any
* fragment identifier.
*/
get URI()
{
return window.content.document.location.href;
let loc = window.content.location;
return loc.href.substr(0, loc.href.length - loc.hash.length);
},
/**
@@ -1044,7 +1051,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");
@@ -1065,16 +1077,10 @@ function Buffer() //{{{
let res = buffer.evaluateXPath(options["hinttags"], frame.document);
for (let [,regex] in Iterator(regexps))
{
for (let i in util.range(res.snapshotLength, 0, true))
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;
@@ -1462,7 +1468,7 @@ function Buffer() //{{{
*/
viewSource: function (url, useExternalEditor)
{
url = url || buffer.URL;
url = url || buffer.URI;
if (useExternalEditor)
editor.editFileExternally(url);
@@ -1625,7 +1631,7 @@ function Marks() //{{{
function (args)
{
let special = args.bang;
let args = args.string;
args = args.string;
if (!special && !args)
{

View File

@@ -573,7 +573,7 @@ function Commands() //{{{
count++; // to compensate the "=" character
}
else if (!/\s/.test(sep)) // this isn't really an option as it has trailing characters, parse it as an argument
else if (!/\s/.test(sep) && sep != undefined) // this isn't really an option as it has trailing characters, parse it as an argument
{
invalid = true;
}

View File

@@ -220,6 +220,12 @@ function CompletionContext(editor, name, offset) //{{{
: item.item[key];
}
CompletionContext.Sort = {
number: function (a, b) parseInt(b) - parseInt(a) || String.localeCompare(a, b),
unsorted: null
};
CompletionContext.prototype = {
// Temporary
/**
@@ -554,10 +560,10 @@ CompletionContext.prototype = {
{
let self = this;
let items = this.items;
let reverse = start > end;
let step = start > end ? -1 : 1;
start = Math.max(0, start || 0);
end = Math.min(items.length, end ? end : items.length);
return util.map(util.range(start, end, reverse), function (i) items[i]);
return util.map(util.range(start, end, step), function (i) items[i]);
},
getRows: function getRows(start, end, doc)
@@ -565,10 +571,10 @@ CompletionContext.prototype = {
let self = this;
let items = this.items;
let cache = this.cache.rows;
let reverse = start > end;
let step = start > end ? -1 : 1;
start = Math.max(0, start || 0);
end = Math.min(items.length, end != null ? end : items.length);
for (let i in util.range(start, end, reverse))
for (let i in util.range(start, end, step))
yield [i, cache[i] = cache[i] || util.xmlToDom(self.createRow(items[i]), doc)];
},
@@ -720,22 +726,22 @@ function Completion() //{{{
this.completers = {};
// Some object members are only accessible as function calls
function getKey(obj, key)
{
try
{
return obj[key];
}
catch (e)
{
return undefined;
}
}
this.iter = function iter(obj)
{
let iterator = (function objIter()
{
for (let k in obj)
{
// Some object members are only accessible as function calls
try
{
yield [k, obj[k]];
continue;
}
catch (e) {}
yield [k, <>inaccessable</>]
}
})();
let iterator = ([k, getKey(obj, k)] for (k in obj));
try
{
// The point of 'for k in obj' is to get keys
@@ -775,21 +781,21 @@ function Completion() //{{{
// available in the object itself.
let orig = obj;
// v[0] in orig and orig[v[0]] catch different cases. XPCOM
// objects are problematic, to say the least.
if (modules.isPrototypeOf(obj))
compl = [v for (v in Iterator(obj))];
else
{
if (obj.wrappedJSObject)
if (getKey(obj, 'wrappedJSObject'))
obj = obj.wrappedJSObject;
// v[0] in orig and orig[v[0]] catch different cases. XPCOM
// objects are problematic, to say the least.
compl = [v for (v in this.iter(obj))
if ((typeof orig == "object" && v[0] in orig) || orig[v[0]] !== undefined)];
if ((typeof orig == "object" && v[0] in orig) || getKey(orig, v[0]) !== undefined)];
}
// And if wrappedJSObject happens to be available,
// return that, too.
if (orig.wrappedJSObject)
if (getKey(orig, 'wrappedJSObject'))
compl.push(["wrappedJSObject", obj]);
// Add keys for sorting later.
@@ -1381,6 +1387,7 @@ function Completion() //{{{
context.anchored = false;
context.title = ["Buffer", "URL"];
context.keys = { text: "text", description: "url", icon: "icon" };
context.compare = CompletionContext.Sort.number;
let process = context.process[0];
context.process = [function (item, text)
<>
@@ -1560,7 +1567,7 @@ function Completion() //{{{
{
context.format = history.format;
context.title = ["History"]
context.compare = null;
context.compare = CompletionContext.Sort.unsorted;
//context.background = true;
if (context.maxItems == null)
context.maxItems = 100;
@@ -1584,7 +1591,7 @@ function Completion() //{{{
context.hasItems = context.completions.length > 0; // XXX
context.filterFunc = null;
context.cancel = function () services.get("autoCompleteSearch").stopSearch();
context.compare = null;
context.compare = CompletionContext.Sort.unsorted;
let timer = new Timer(50, 100, function (result) {
context.incomplete = result.searchResult >= result.RESULT_NOMATCH_ONGOING;
context.completions = [
@@ -1655,7 +1662,8 @@ function Completion() //{{{
completer = function () [["true", ""], ["false", ""]];
break;
case "stringlist":
len = newValues.pop().length;
let target = newValues.pop();
len = target ? target.length : 0;
break;
case "charlist":
len = 0;
@@ -1716,7 +1724,7 @@ function Completion() //{{{
context.format = history.format;
context.title = [keyword + " Quick Search"];
// context.background = true;
context.compare = null;
context.compare = CompletionContext.Sort.unsorted;
context.generate = function () {
let [begin, end] = item.url.split("%s");
@@ -1751,7 +1759,7 @@ function Completion() //{{{
let ctxt = context.fork(name, 0);
ctxt.title = [engine.description + " Suggestions"];
ctxt.compare = null;
ctxt.compare = CompletionContext.Sort.unsorted;
ctxt.incomplete = true;
bookmarks.getSuggestions(name, ctxt.filter, function (compl) {
ctxt.incomplete = false;

View File

@@ -204,7 +204,7 @@ function Editor() //{{{
function (args)
{
let matches = args.string.match(RegExp("^\\s*($|" + abbrevmatch + ")(?:\\s*$|\\s+(.*))"));
if (! matches)
if (!matches)
{
liberator.echoerr("E474: Invalid argument");
return false;
@@ -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

@@ -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")
@@ -1033,6 +1035,37 @@ function Events() //{{{
}
}
}
// [Ctrl-Bug] special handling of mysterious <C-[>, <C-\\>, <C-]>, <C-^>, <C-_> bugs (OS/X)
// (i.e., cntrl codes 27--31)
// ---
// For more information, see:
// [*] Vimp FAQ: http://vimperator.org/trac/wiki/Vimperator/FAQ#WhydoesntC-workforEscMacOSX
// [*] Referenced mailing list msg: http://www.mozdev.org/pipermail/vimperator/2008-May/001548.html
// [*] Mozilla bug 416227: event.charCode in keypress handler has unexpected values on Mac for Ctrl with chars in "[ ] _ \"
// https://bugzilla.mozilla.org/show_bug.cgi?query_format=specific&order=relevance+desc&bug_status=__open__&id=416227
// [*] Mozilla bug 432951: Ctrl+'foo' doesn't seem same charCode as Meta+'foo' on Cocoa
// https://bugzilla.mozilla.org/show_bug.cgi?query_format=specific&order=relevance+desc&bug_status=__open__&id=432951
// ---
//
// The following fixes are only activated if liberator.has("MacUnix").
// Technically, they prevent mappings from <C-Esc> (and
// <C-C-]> if your fancy keyboard permits such things<?>), but
// these <C-control> mappings are probably pathological (<C-Esc>
// certainly is on Windows), and so it is probably
// harmless to remove the has("MacUnix") if desired.
//
else if (liberator.has("MacUnix") && event.ctrlKey && event.charCode >= 27 && event.charCode <= 31)
{
if (event.charCode == 27) // [Ctrl-Bug 1/5] the <C-[> bug
{
key = "Esc";
modifier = modifier.replace("C-", "");
}
else // [Ctrl-Bug 2,3,4,5/5] the <C-\\>, <C-]>, <C-^>, <C-_> bugs
{
key = String.fromCharCode(event.charCode + 64);
}
}
// special handling of the Space key
else if (event.charCode == 32)
{
@@ -1089,7 +1122,7 @@ function Events() //{{{
waitForPageLoad: function ()
{
liberator.dump("start waiting in loaded state: " + buffer.loaded);
//liberator.dump("start waiting in loaded state: " + buffer.loaded);
liberator.threadYield(true); // clear queue
if (buffer.loaded == 1)
@@ -1102,8 +1135,8 @@ function Events() //{{{
while (now = Date.now(), now < end)
{
liberator.threadYield();
if ((now - start) % 1000 < 10)
liberator.dump("waited: " + (now - start) + " ms");
//if ((now - start) % 1000 < 10)
// liberator.dump("waited: " + (now - start) + " ms");
if (!events.feedingKeys)
return false;
@@ -1122,7 +1155,7 @@ function Events() //{{{
let ret = (buffer.loaded == 1);
if (!ret)
liberator.echoerr("Page did not load completely in " + maxWaitTime + " seconds. Macro stopped.");
liberator.dump("done waiting: " + ret);
//liberator.dump("done waiting: " + ret);
// sometimes the input widget had focus when replaying a macro
// maybe this call should be moved somewhere else?
@@ -1186,7 +1219,7 @@ function Events() //{{{
{
if (config.isComposeWindow)
{
liberator.dump("Compose editor got focus");
//liberator.dump("Compose editor got focus");
modes.set(modes.INSERT, modes.TEXTAREA);
}
else if (liberator.mode != modes.MESSAGE)

View File

@@ -399,87 +399,51 @@ function Hints() //{{{
let wordSplitRegex = RegExp(options["wordseparators"]);
// What the **** does this do? --Kris
//
// This function matches hintStrings like 'hekho' to links like 'Hey Kris, how are you?' -> [HE]y [K]ris [HO]w are you --Daniel
function charsAtBeginningOfWords(chars, words, allowWordOverleaping)
{
let charIdx = 0;
let numMatchedWords = 0;
for (let [,word] in Iterator(words))
function charMatches(charIdx, chars, wordIdx, words, inWordIdx, allowWordOverleaping)
{
if (word.length == 0)
continue;
let wcIdx = 0;
// Check if the current word matches same characters as the previous word.
// Each already matched word has matched at least one character.
if (charIdx > numMatchedWords)
let matches = (chars[charIdx] == words[wordIdx][inWordIdx]);
if ((matches == false && allowWordOverleaping) || words[wordIdx].length == 0)
{
let matchingStarted = false;
for (let i in util.range(numMatchedWords, charIdx))
{
if (chars[i] == word[wcIdx])
{
matchingStarted = true;
wcIdx++;
}
else if (matchingStarted)
{
wcIdx = 0;
break;
}
}
let nextWordIdx = wordIdx + 1;
if (nextWordIdx == words.length)
return false;
return charMatches(charIdx, chars, nextWordIdx, words, 0, allowWordOverleaping);
}
// the current word matches same characters as the previous word
let prevCharIdx;
if (wcIdx > 0)
if (matches)
{
prevCharIdx = charIdx;
// now check if it matches additional characters
for (; wcIdx < word.length && charIdx < chars.length; wcIdx++, charIdx++)
{
if (word[wcIdx] != chars[charIdx])
break;
}
let nextCharIdx = charIdx + 1;
if (nextCharIdx == chars.length)
return true;
// the word doesn't match additional characters, now check if the
// already matched characters are equal to the next characters for matching,
// if yes, then consume them
if (prevCharIdx == charIdx)
{
for (let i = 0; i < wcIdx && charIdx < chars.length; i++, charIdx++)
{
if (word[i] != chars[charIdx])
break;
}
}
let nextWordIdx = wordIdx + 1;
let beyondLastWord = (nextWordIdx == words.length);
let charMatched = false;
if (beyondLastWord == false)
charMatched = charMatches(nextCharIdx, chars, nextWordIdx, words, 0, allowWordOverleaping)
numMatchedWords++;
}
// the current word doesn't match same characters as the previous word, just
// try to match the next characters
else
{
prevCharIdx = charIdx;
for (let i = 0; i < word.length && charIdx < chars.length; i++, charIdx++)
{
if (word[i] != chars[charIdx])
break;
}
if (charMatched)
return true;
if (prevCharIdx == charIdx)
if (charMatched == false || beyondLastWord == true)
{
if (!allowWordOverleaping)
let nextInWordIdx = inWordIdx + 1;
if (nextInWordIdx == words[wordIdx].length)
return false;
return charMatches(nextCharIdx, chars, wordIdx, words, nextInWordIdx, allowWordOverleaping);
}
else
numMatchedWords++;
}
if (charIdx == chars.length)
return true;
return false;
}
return (charIdx == chars.length);
return charMatches(0, chars, 0, words, 0, allowWordOverleaping);
}
function stringsAtBeginningOfWords(strings, words, allowWordOverleaping)
@@ -510,8 +474,6 @@ function Hints() //{{{
return function (linkText)
{
liberator.dump(hintStrings);
if (hintStrings.length == 1 && hintStrings[0].length == 0)
return true;
@@ -613,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)
@@ -621,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

@@ -121,7 +121,7 @@ const liberator = (function () //{{{
let class = dir.map(function (dir) "html|html > xul|scrollbar[orient=" + dir + "]");
if (class.length)
styles.addSheet(true, "scrollbar", "*", class.join(", ") + " { visibility: collapse !important; }");
styles.addSheet(true, "scrollbar", "*", class.join(", ") + " { visibility: collapse !important; }", true);
else
styles.removeSheet(true, "scrollbar");
options.safeSetPref("layout.scrollbar.side", opts.indexOf("l") >= 0 ? 3 : 2);
@@ -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);
@@ -1422,7 +1426,6 @@ window.liberator = liberator;
// FIXME: Ugly, etc.
window.addEventListener("liberatorHelpLink", function (event) {
let elem = event.target;
liberator.dump(String(elem));
if (/^(option|mapping|command)$/.test(elem.className))
var tag = elem.textContent.replace(/\s.*/, "");
if (elem.className == "command")

View File

@@ -80,7 +80,7 @@ Option.prototype = {
parseValues: function (value)
{
if (this.type == "stringlist")
return value.split(",");
return (value === "") ? [] : value.split(",");
if (this.type == "charlist")
return Array.slice(value);
return value;
@@ -203,9 +203,9 @@ Option.prototype = {
break;
case "number":
let value = parseInt(values); // deduce radix
let value = Number(values); // deduce radix
if (isNaN(value))
if (isNaN(value) || value != parseInt(value))
return "E521: Number required";
switch (operator)
@@ -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

@@ -182,7 +182,7 @@ function Highlights(name, store, serial)
{
css = style.selector + " { " + css + " }";
let error = styles.addSheet(true, style.selector, style.filter, css);
let error = styles.addSheet(true, style.selector, style.filter, css, true);
if (error)
return error;
}
@@ -235,6 +235,7 @@ function Highlights(name, store, serial)
this.set(class);
}
};
this.reload();
}
/**
@@ -257,7 +258,7 @@ function Styles(name, store, serial)
const namespace = '@namespace html "' + XHTML + '";\n' +
'@namespace xul "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";\n' +
'@namespace liberator "' + NS.uri + '";\n';
const Sheet = new Struct("name", "sites", "css", "ref");
const Sheet = new Struct("name", "sites", "css", "ref", "agent");
let cssUri = function (css) "chrome-data:text/css," + window.encodeURI(css);
@@ -285,7 +286,7 @@ function Styles(name, store, serial)
* "*" is matched as a prefix.
* @param {string} css The CSS to be applied.
*/
this.addSheet = function (system, name, filter, css)
this.addSheet = function (system, name, filter, css, agent)
{
let sheets = system ? systemSheets : userSheets;
let names = system ? systemNames : userNames;
@@ -294,7 +295,7 @@ function Styles(name, store, serial)
let sheet = sheets.filter(function (s) s.sites.join(",") == filter && s.css == css)[0];
if (!sheet)
sheet = new Sheet(name, filter.split(",").filter(util.identity), css, null);
sheet = new Sheet(name, filter.split(",").filter(util.identity), css, null, agent);
if (sheet.ref == null) // Not registered yet
{
@@ -302,7 +303,8 @@ function Styles(name, store, serial)
try
{
this.registerSheet(cssUri(wrapCSS(sheet)));
this.registerAgentSheet(cssUri(wrapCSS(sheet)))
if (sheet.agent)
this.registerAgentSheet(cssUri(wrapCSS(sheet)))
}
catch (e)
{
@@ -410,7 +412,7 @@ function Styles(name, store, serial)
{
let sites = sheet.sites.filter(function (f) f != filter);
if (sites.length)
this.addSheet(system, name, sites.join(","), css);
this.addSheet(system, name, sites.join(","), css, sheet.agent);
}
}
return matches.length;
@@ -514,8 +516,11 @@ const styles = storage.newObject("styles", Styles, false);
*/
const highlight = storage.newObject("highlight", Highlights, false);
highlight.CSS = Highlights.prototype.CSS;
highlight.reload();
if (highlight.CSS != Highlights.prototype.CSS)
{
highlight.CSS = Highlights.prototype.CSS;
highlight.reload();
}
liberator.triggerObserver("load_styles", "styles");
liberator.triggerObserver("load_highlight", "highlight");

View File

@@ -133,9 +133,9 @@ const template = {
highlight: function highlight(arg, processStrings, clip)
{
// some objects like window.JSON or getBrowsers()._browsers need the try/catch
let str = clip ? util.clip(String(arg), clip) : String(arg);
try
{
let str = clip ? util.clip(String(arg), clip) : String(arg);
switch (arg == null ? "undefined" : typeof arg)
{
case "number":

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;
@@ -1008,10 +1016,9 @@ function CommandLine() //{{{
set silent(val)
{
silent = val;
if (silent)
storage.styles.addSheet(true, "silent-mode", "chrome://*", "#liberator-commandline > * { opacity: 0 }");
else
storage.styles.removeSheet(true, "silent-mode");
Array.forEach(document.getElementById("liberator-commandline").childNodes, function (node) {
node.style.opacity = silent ? "0" : "";
});
},
runSilently: function (fn, self)
@@ -1214,6 +1221,7 @@ function CommandLine() //{{{
submit: callback,
change: extra.onChange,
complete: extra.completer,
cancel: extra.onCancel,
};
modes.push(modes.COMMAND_LINE, modes.PROMPT);
@@ -1285,7 +1293,8 @@ function CommandLine() //{{{
}
else if (event.type == "input")
{
//this.resetCompletions(); -> already handled by "keypress" below (hopefully), so don't do it twice
//liberator.dump("input: " + command);
this.resetCompletions();
liberator.triggerCallback("change", currentExtendedMode, command);
}
else if (event.type == "keypress")
@@ -1333,7 +1342,7 @@ function CommandLine() //{{{
else if (key == "<BS>")
{
// reset the tab completion
this.resetCompletions();
//this.resetCompletions();
// and blur the command line if there is no text left
if (command.length == 0)
@@ -1344,7 +1353,7 @@ function CommandLine() //{{{
}
else // any other key
{
this.resetCompletions();
//this.resetCompletions();
}
return true; // allow this event to be handled by Firefox
}
@@ -1769,7 +1778,7 @@ function ItemList(id) //{{{
</div>
</div>, divNodes);
doc.body.replaceChild(div, doc.body.firstChild);
div.scrollIntoView(true);
//div.scrollIntoView(true);
items.contextList.forEach(function init_eachContext(context) {
delete context.cache.nodes;
@@ -1952,7 +1961,7 @@ function ItemList(id) //{{{
if (index >= 0)
{
getCompletion(index).setAttribute("selected", "true");
getCompletion(index).scrollIntoView(false);
//getCompletion(index).scrollIntoView(false);
}
//if (index == 0)

View File

@@ -519,25 +519,28 @@ const util = { //{{{
},
/**
* A generator that returns the values between <b>start</b> and <b>end</b>.
* If <b>reverse</b> is true then the values are returned in reverse order.
* A generator that returns the values between <b>start</b> and <b>end</b>,
* in <b>step</b> increments.
*
* @param {number} start The interval's start value.
* @param {number} end The interval's end value.
* @param {boolean} reverse Reverse the order in which the values are produced.
* @param {boolean} step The value to step the range by. May be
* negative. @default 1
* @returns {Iterator(Object)}
*/
range: function range(start, end, reverse)
range: function range(start, end, step)
{
if (!reverse)
if (!step)
step = 1;
if (step > 0)
{
while (start < end)
yield start++;
for (; start < end; start += step)
yield start;
}
else
{
while (start > end)
yield --start;
yield start += step;
}
},
@@ -669,6 +672,13 @@ const util = { //{{{
xmlToDom: function xmlToDom(node, doc, nodes)
{
XML.prettyPrinting = false;
if (node.length() != 1)
{
let domnode = doc.createDocumentFragment();
for each (let child in node)
domnode.appendChild(arguments.callee(child, doc, nodes));
return domnode;
}
switch (node.nodeKind())
{
case "text":