1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 20:37:58 +01:00

Reset progress indicator on location change.

This commit is contained in:
Kris Maglione
2011-02-04 20:24:50 -05:00
parent 6a3d5dcfce
commit e9fd99dafa
9 changed files with 57 additions and 44 deletions

View File

@@ -252,7 +252,7 @@ var AutoCommands = Module("autocommands", {
"List of autocommand event names which should be ignored", "List of autocommand event names which should be ignored",
"stringlist", "", "stringlist", "",
{ {
completer: function () Iterator(update({ all: "All Events" }, config.autocommands)), values: iter(update({ all: "All Events" }, config.autocommands)).toArray(),
has: Option.has.toggleAll has: Option.has.toggleAll
}); });
} }

View File

@@ -270,7 +270,7 @@ var Buffer = Module("buffer", {
// This fires when the load event is initiated // This fires when the load event is initiated
// only thrown for the current tab, not when another tab changes // only thrown for the current tab, not when another tab changes
if (flags & Ci.nsIWebProgressListener.STATE_START) { if (flags & Ci.nsIWebProgressListener.STATE_START) {
statusline.updateProgress(0); statusline.progress = 0;
buffer._triggerLoadAutocmd("PageLoadPre", webProgress.DOMWindow.document); buffer._triggerLoadAutocmd("PageLoadPre", webProgress.DOMWindow.document);
@@ -307,7 +307,9 @@ var Buffer = Module("buffer", {
}, },
onProgressChange: function onProgressChange(webProgress, request, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress) { onProgressChange: function onProgressChange(webProgress, request, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress) {
onProgressChange.superapply(this, arguments); onProgressChange.superapply(this, arguments);
statusline.updateProgress(curTotalProgress / maxTotalProgress); if (webProgress.DOMWindow)
webProgress.DOMWindow.dactylProgress = curTotalProgress / maxTotalProgress;
statusline.progress = curTotalProgress / maxTotalProgress;
}, },
// happens when the users switches tabs // happens when the users switches tabs
onLocationChange: function onLocationChange(webProgress, request, uri) { onLocationChange: function onLocationChange(webProgress, request, uri) {
@@ -316,10 +318,11 @@ var Buffer = Module("buffer", {
delete mappings.hives; delete mappings.hives;
statusline.updateUrl(); statusline.updateUrl();
statusline.progress = "";
let win = webProgress.DOMWindow; let win = webProgress.DOMWindow;
if (win && uri) { if (win && uri) {
statusline.updateProgress(win); statusline.progress = win.dactylProgress;
let oldURI = webProgress.document.dactylURI; let oldURI = webProgress.document.dactylURI;
if (webProgress.document.dactylLoadIdx === webProgress.loadedTransIndex if (webProgress.document.dactylLoadIdx === webProgress.loadedTransIndex
@@ -1924,7 +1927,7 @@ var Buffer = Module("buffer", {
options.add(["pageinfo", "pa"], options.add(["pageinfo", "pa"],
"Define which sections are shown by the :pageinfo command", "Define which sections are shown by the :pageinfo command",
"charlist", "gfm", "charlist", "gfm",
{ completer: function (context) [[k, v[1]] for ([k, v] in Iterator(buffer.pageInfo))] }); { get values() [[k, v[1]] for ([k, v] in Iterator(buffer.pageInfo))] });
options.add(["scroll", "scr"], options.add(["scroll", "scr"],
"Number of lines to scroll with <C-u> and <C-d> commands", "Number of lines to scroll with <C-u> and <C-d> commands",
@@ -1935,7 +1938,7 @@ var Buffer = Module("buffer", {
"Where to show the destination of the link under the cursor", "Where to show the destination of the link under the cursor",
"string", "status", "string", "status",
{ {
completer: function (context) [ values: [
["", "Don't show link destinations"], ["", "Don't show link destinations"],
["status", "Show link destinations in the status line"], ["status", "Show link destinations in the status line"],
["command", "Show link destinations in the command line"] ["command", "Show link destinations in the command line"]

View File

@@ -1559,8 +1559,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
"r" + [k for ([k, v] in iter(groups[1].opts)) "r" + [k for ([k, v] in iter(groups[1].opts))
if (!document.getElementById(v[1][0]).collapsed)].join(""), if (!document.getElementById(v[1][0]).collapsed)].join(""),
completer: function (context) values: array(groups).map(function (g) [[k, v[0]] for ([k, v] in Iterator(g.opts))]).flatten(),
array(groups).map(function (g) [[k, v[0]] for ([k, v] in Iterator(g.opts))]).flatten(),
setter: function (value) { setter: function (value) {
for (let group in values(groups)) for (let group in values(groups))
group.setter(value); group.setter(value);

View File

@@ -1181,7 +1181,7 @@ var Hints = Module("hints", {
"The keys used to label and select hints", "The keys used to label and select hints",
"string", "0123456789", "string", "0123456789",
{ {
completer: function () [ values: [
["0123456789", "Numbers"], ["0123456789", "Numbers"],
["asdfg;lkjh", "Home Row"]], ["asdfg;lkjh", "Home Row"]],
validator: function (value) { validator: function (value) {
@@ -1202,7 +1202,7 @@ var Hints = Module("hints", {
"Change the behavior of <Return> in hint mode", "Change the behavior of <Return> in hint mode",
"number", 0, "number", 0,
{ {
completer: function () [ values: [
["0", "Follow the first hint as soon as typed text uniquely identifies it. Follow the selected hint on <Return>."], ["0", "Follow the first hint as soon as typed text uniquely identifies it. Follow the selected hint on <Return>."],
["1", "Follow the selected hint on <Return>."], ["1", "Follow the selected hint on <Return>."],
["2", "Follow the selected hint on <Return> only it's been <Tab>-selected."] ["2", "Follow the selected hint on <Return> only it's been <Tab>-selected."]
@@ -1213,7 +1213,7 @@ var Hints = Module("hints", {
"How hints are filtered", "How hints are filtered",
"stringlist", "contains", "stringlist", "contains",
{ {
completer: function (context) [ values: [
["contains", "The typed characters are split on whitespace. The resulting groups must all appear in the hint."], ["contains", "The typed characters are split on whitespace. The resulting groups must all appear in the hint."],
["custom", "Delegate to a custom function: dactyl.plugins.customHintMatcher(hintString)"], ["custom", "Delegate to a custom function: dactyl.plugins.customHintMatcher(hintString)"],
["firstletters", "Behaves like wordstartswith, but all groups must match a sequence of words."], ["firstletters", "Behaves like wordstartswith, but all groups must match a sequence of words."],
@@ -1233,7 +1233,7 @@ var Hints = Module("hints", {
"Which text is used to filter hints for input elements", "Which text is used to filter hints for input elements",
"stringlist", "label,value", "stringlist", "label,value",
{ {
completer: function (context) [ values: [
["value", "Match against the value of the input field"], ["value", "Match against the value of the input field"],
["label", "Match against the text of a label for the input field, if one can be found"], ["label", "Match against the text of a label for the input field, if one can be found"],
["name", "Match against the name of the input field"] ["name", "Match against the name of the input field"]

View File

@@ -163,10 +163,6 @@ var Option = Class("Option", {
setValues: deprecated("Option#set", "set"), setValues: deprecated("Option#set", "set"),
joinValues: deprecated("Option#stringify", "stringify"), joinValues: deprecated("Option#stringify", "stringify"),
parseValues: deprecated("Option#parse", "parse"), parseValues: deprecated("Option#parse", "parse"),
values: deprecated("Option#value", {
get: function values() this.value,
set: function values(val) this.value = val
}),
/** /**
* @property {value} The option's current value. The option's local value, * @property {value} The option's current value. The option's local value,
@@ -283,7 +279,16 @@ var Option = Class("Option", {
* @property {function(CompletionContext, Args)} This option's completer. * @property {function(CompletionContext, Args)} This option's completer.
* @see CompletionContext * @see CompletionContext
*/ */
completer: null, completer: function (context) {
if (this.values)
context.completions = this.values;
},
/**
* @property {[[string, string]]} This option's possible values.
* @see CompletionContext
*/
values: null,
/** /**
* @property {function(host, values)} A function which should return a list * @property {function(host, values)} A function which should return a list
@@ -340,7 +345,7 @@ var Option = Class("Option", {
* when set. * when set.
*/ */
validator: function () { validator: function () {
if (this.completer) if (this.values || this.completer !== Option.prototype.completer)
return Option.validateCompleter.apply(this, arguments); return Option.validateCompleter.apply(this, arguments);
return true; return true;
}, },
@@ -601,13 +606,17 @@ var Option = Class("Option", {
* @returns {boolean} * @returns {boolean}
*/ */
validateCompleter: function (values) { validateCompleter: function (values) {
let context = CompletionContext(""); if (this.values)
let res = context.fork("", 0, this, this.completer); var acceptable = this.values;
if (!res) else {
res = context.allItems.items.map(function (item) [item.text]); let context = CompletionContext("");
acceptable = context.fork("", 0, this, this.completer);
if (!acceptable)
acceptable = context.allItems.items.map(function (item) [item.text]);
}
if (this.type == "regexpmap") if (this.type == "regexpmap")
return Array.concat(values).every(function (re) res.some(function (item) item[0] == re.result)); return Array.concat(values).every(function (re) acceptable.some(function (item) item[0] == re.result));
return Array.concat(values).every(function (value) res.some(function (item) item[0] == value)); return Array.concat(values).every(function (value) acceptable.some(function (item) item[0] == value));
}, },
validateXPath: function (values) { validateXPath: function (values) {

View File

@@ -979,7 +979,7 @@ var Tabs = Module("tabs", {
config.tabbrowser.tabContainer._positionPinnedTabs(); config.tabbrowser.tabContainer._positionPinnedTabs();
return value; return value;
}, },
completer: function (context) [ values: [
["never", "Never show the tab bar"], ["never", "Never show the tab bar"],
["multitab", "Show the tab bar when there are multiple tabs"], ["multitab", "Show the tab bar when there are multiple tabs"],
["always", "Always show the tab bar"] ["always", "Always show the tab bar"]
@@ -1005,7 +1005,7 @@ var Tabs = Module("tabs", {
"Define when newly created tabs are automatically activated", "Define when newly created tabs are automatically activated",
"stringlist", [g[0] for (g in values(activateGroups.slice(1))) if (!g[2] || !prefs.get("browser.tabs." + g[2]))].join(","), "stringlist", [g[0] for (g in values(activateGroups.slice(1))) if (!g[2] || !prefs.get("browser.tabs." + g[2]))].join(","),
{ {
completer: function (context) activateGroups, values: activateGroups,
has: Option.has.toggleAll, has: Option.has.toggleAll,
setter: function (newValues) { setter: function (newValues) {
let valueSet = set(newValues); let valueSet = set(newValues);
@@ -1022,7 +1022,7 @@ var Tabs = Module("tabs", {
"Define which commands should output in a new tab by default", "Define which commands should output in a new tab by default",
"stringlist", "", "stringlist", "",
{ {
completer: function (context) [ values: [
["all", "All commands"], ["all", "All commands"],
["addons", ":addo[ns] command"], ["addons", ":addo[ns] command"],
["downloads", ":downl[oads] command"], ["downloads", ":downl[oads] command"],
@@ -1056,7 +1056,7 @@ var Tabs = Module("tabs", {
"See 'popups' option."); "See 'popups' option.");
return values; return values;
}, },
completer: function (context) [ values: [
["tab", "Open popups in a new tab"], ["tab", "Open popups in a new tab"],
["window", "Open popups in a new window"], ["window", "Open popups in a new window"],
["resized", "Open resized popups in a new window"] ["resized", "Open resized popups in a new window"]

View File

@@ -1015,7 +1015,7 @@ var Completion = Module("completion", {
options: function (dactyl, modules, window) { options: function (dactyl, modules, window) {
const { completion, options } = modules; const { completion, options } = modules;
let wildmode = { let wildmode = {
completer: function (context) [ values: [
// Why do we need ""? // Why do we need ""?
// Because its description is useful during completion. --Kris // Because its description is useful during completion. --Kris
["", "Complete only the first match"], ["", "Complete only the first match"],
@@ -1047,7 +1047,7 @@ var Completion = Module("completion", {
options.add(["complete", "cpt"], options.add(["complete", "cpt"],
"Items which are completed at the :open prompts", "Items which are completed at the :open prompts",
"charlist", config.defaults.complete == null ? "slf" : config.defaults.complete, "charlist", config.defaults.complete == null ? "slf" : config.defaults.complete,
{ completer: function (context) values(completion.urlCompleters) }); { get values() values(completion.urlCompleters) });
options.add(["wildanchor", "wia"], options.add(["wildanchor", "wia"],
"Define which completion groups only match at the beginning of their text", "Define which completion groups only match at the beginning of their text",
@@ -1057,7 +1057,7 @@ var Completion = Module("completion", {
"Completion case matching mode", "Completion case matching mode",
"regexpmap", ".?:smart", "regexpmap", ".?:smart",
{ {
completer: function () [ values: [
["smart", "Case is significant when capital letters are typed"], ["smart", "Case is significant when capital letters are typed"],
["match", "Case is always significant"], ["match", "Case is always significant"],
["ignore", "Case is never significant"] ["ignore", "Case is never significant"]

View File

@@ -262,7 +262,7 @@ var RangeFinder = Module("rangefinder", {
"Find case matching mode", "Find case matching mode",
"string", "smart", "string", "smart",
{ {
completer: function () [ values: [
["smart", "Case is significant when capital letters are typed"], ["smart", "Case is significant when capital letters are typed"],
["match", "Case is always significant"], ["match", "Case is always significant"],
["ignore", "Case is never significant"] ["ignore", "Case is never significant"]

View File

@@ -562,7 +562,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
"The default list of private items to sanitize", "The default list of private items to sanitize",
"stringlist", "all", "stringlist", "all",
{ {
completer: function (value) values(sanitizer.itemMap), get values() values(sanitizer.itemMap),
has: modules.Option.has.toggleAll, has: modules.Option.has.toggleAll,
validator: function (values) values.length && validator: function (values) values.length &&
values.every(function (val) val === "all" || set.has(sanitizer.itemMap, val)) values.every(function (val) val === "all" || set.has(sanitizer.itemMap, val))
@@ -573,7 +573,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
"stringlist", "", "stringlist", "",
{ {
initialValue: true, initialValue: true,
completer: function () [i for (i in values(sanitizer.itemMap)) if (i.persistent || i.builtin)], get values() [i for (i in values(sanitizer.itemMap)) if (i.persistent || i.builtin)],
getter: function () !sanitizer.runAtShutdown ? [] : [ getter: function () !sanitizer.runAtShutdown ? [] : [
item.name for (item in values(sanitizer.itemMap)) item.name for (item in values(sanitizer.itemMap))
if (item.shouldSanitize(true)) if (item.shouldSanitize(true))
@@ -598,36 +598,37 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
{ {
completer: function (context) { completer: function (context) {
context.compare = context.constructor.Sort.Unsorted; context.compare = context.constructor.Sort.Unsorted;
return [ context.completions = this.values;
},
values: [
["all", "Everything"], ["all", "Everything"],
["session", "The current session"], ["session", "The current session"],
["10m", "Last ten minutes"], ["10m", "Last ten minutes"],
["1h", "Past hour"], ["1h", "Past hour"],
["1d", "Past day"], ["1d", "Past day"],
["1w", "Past week"] ["1w", "Past week"]
]; ],
},
validator: function (value) /^(a(ll)?|s(ession)|\d+[mhdw])$/.test(value) validator: function (value) /^(a(ll)?|s(ession)|\d+[mhdw])$/.test(value)
}); });
options.add(["cookies", "ck"], options.add(["cookies", "ck"],
"The default mode for newly added cookie permissions", "The default mode for newly added cookie permissions",
"stringlist", "session", "stringlist", "session",
{ completer: function (context) iter(Sanitizer.COMMANDS) }); { get values() iter(Sanitizer.COMMANDS) });
options.add(["cookieaccept", "ca"], options.add(["cookieaccept", "ca"],
"When to accept cookies", "When to accept cookies",
"string", "all", "string", "all",
{ {
PREF: "network.cookie.cookieBehavior", PREF: "network.cookie.cookieBehavior",
completer: function (context) [ values: [
["all", "Accept all cookies"], ["all", "Accept all cookies"],
["samesite", "Accept all non-third-party cookies"], ["samesite", "Accept all non-third-party cookies"],
["none", "Accept no cookies"] ["none", "Accept no cookies"]
], ],
getter: function () (this.completer()[prefs.get(this.PREF)] || ["all"])[0], getter: function () (this.values[prefs.get(this.PREF)] || ["all"])[0],
setter: function (val) { setter: function (val) {
prefs.set(this.PREF, this.completer().map(function (i) i[0]).indexOf(val)); prefs.set(this.PREF, this.values.map(function (i) i[0]).indexOf(val));
return val; return val;
}, },
initialValue: true, initialValue: true,
@@ -639,14 +640,14 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
"string", "default", { "string", "default", {
PREF: "network.cookie.lifetimePolicy", PREF: "network.cookie.lifetimePolicy",
PREF_DAYS: "network.cookie.lifetime.days", PREF_DAYS: "network.cookie.lifetime.days",
completer: function (context) [ values: [
["default", "The lifetime requested by the setter"], ["default", "The lifetime requested by the setter"],
["prompt", "Always prompt for a lifetime"], ["prompt", "Always prompt for a lifetime"],
["session", "The current session"] ["session", "The current session"]
], ],
getter: function () (this.completer()[prefs.get(this.PREF)] || [prefs.get(this.PREF_DAYS)])[0], getter: function () (this.values[prefs.get(this.PREF)] || [prefs.get(this.PREF_DAYS)])[0],
setter: function (value) { setter: function (value) {
let val = this.completer().map(function (i) i[0]).indexOf(value); let val = this.values.map(function (i) i[0]).indexOf(value);
if (val > -1) if (val > -1)
prefs.set(this.PREF, val); prefs.set(this.PREF, val);
else { else {