From 924aba8f54529221cb6000aa8fa4a03d9fa4ecdc Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 16 Mar 2009 12:28:34 +0000 Subject: [PATCH 1/4] Commandline completion for hinted file inputs When an is selected with hints, it will cause an "Upload file: " prompt in the commandline. (Selection with tab and mouse is left unchanged and will cause the firefox dialog to display) --- common/content/buffer.js | 10 ++++++++++ common/content/ui.js | 2 ++ vimperator/NEWS | 2 ++ 3 files changed, 14 insertions(+) diff --git a/common/content/buffer.js b/common/content/buffer.js index 7f535692..458daa21 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -1019,6 +1019,11 @@ function Buffer() //{{{ elem.contentWindow.focus(); return; } + else if (elemTagName == "input" && elem.getAttribute('type').toLowerCase() == "file") + { + commandline.input("Upload file: ", function (file) elem.value = file, {completer: completion.file, default: elem.value}); + return; + } elem.focus(); @@ -1124,6 +1129,11 @@ function Buffer() //{{{ offsetX = Number(coords[0]) + 1; offsetY = Number(coords[1]) + 1; } + else if (localName == "input" && elem.getAttribute('type').toLowerCase() == "file") + { + commandline.input("Upload file: ", function (file) elem.value = file, {completer: completion.file, default: elem.value}); + return; + } let ctrlKey = false, shiftKey = false; switch (where) diff --git a/common/content/ui.js b/common/content/ui.js index 18cb7059..d01f2a2c 100644 --- a/common/content/ui.js +++ b/common/content/ui.js @@ -1201,6 +1201,8 @@ function CommandLine() //{{{ * for the user's input. * @... {string} promptHighlight - The HighlightGroup used for the * prompt. @default "Question" + * @... {string} default - The initial value that will be returned + * if the user presses straightaway. @default "" */ input: function _input(prompt, callback, extra) { diff --git a/vimperator/NEWS b/vimperator/NEWS index 8cd7d8b1..c33ef4b9 100644 --- a/vimperator/NEWS +++ b/vimperator/NEWS @@ -21,6 +21,8 @@ * IMPORTANT: 'verbose' is now by default at 1, set to 0 to not show any status messages. * IMPORTANT: $VIMPERATOR_HOME is no longer used. + * Selecting an with hints now causes the commandline to prompt + for file input (instead of doing nothing). * [count] now goes to the [count]th next tab rather than the [count]th tab. * add ~/.vimperator/info/{profile}/, similar to viminfo * add $VIMPERATOR_RUNTIME, $VIMPERATOR_INIT From 238e45482cf928d89093043948a1c37a56ae961a Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Wed, 18 Mar 2009 00:45:47 +0000 Subject: [PATCH 2/4] Fix bug #189, now uses first completion On discussion with maxauthority this is probably the best way of doing things for now. --- common/content/ui.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/content/ui.js b/common/content/ui.js index d01f2a2c..a23e5de7 100644 --- a/common/content/ui.js +++ b/common/content/ui.js @@ -1298,8 +1298,15 @@ function CommandLine() //{{{ // user pressed ENTER to carry out a command // user pressing ESCAPE is handled in the global onEscape // FIXME: should trigger "cancel" event + // FIXME: This should not be waiting, some kind of callback mechanism on completion would be better. if (events.isAcceptKey(key)) { + while (completions.context.incomplete) + { + liberator.threadYield(true); + command = this.command; + } + let mode = currentExtendedMode; // save it here, as modes.pop() resets it keepCommand = true; currentExtendedMode = null; // Don't let modes.pop trigger "cancel" From 202975b3f1eb63ca768ae18f795527f97473ff64 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Tue, 17 Mar 2009 00:29:16 +1100 Subject: [PATCH 3/4] Add extension ID update reminder to TODO. --- vimperator/TODO | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vimperator/TODO b/vimperator/TODO index c2175204..d6f0d711 100644 --- a/vimperator/TODO +++ b/vimperator/TODO @@ -39,6 +39,8 @@ BUGS: - URLs in :ls output are no longer hyperlinks FEATURES: +9 change the extension ID to vimperator@vimperator.org rather than + vimperator@mozdev.org 9 finish :help TODOs 9 fix local options 9 adaptive timeout for auto-completions, :set completions can be updated more often than From 79ef0f67eb89d240f448afa614d5ffee5048088f Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Wed, 18 Mar 2009 20:32:41 +1100 Subject: [PATCH 4/4] Don't bother forking colorscheme completion. It was an attempt to improve on Vim's colorscheme completion, across multiple runtime paths, but that's more buggy than useful. --- common/content/completion.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/common/content/completion.js b/common/content/completion.js index ee86368d..5c8e9d2d 100644 --- a/common/content/completion.js +++ b/common/content/completion.js @@ -1426,15 +1426,17 @@ function Completion() //{{{ colorScheme: function colorScheme(context) { - // TODO: use path for the description? + let colors = []; + io.getRuntimeDirectories("colors").forEach(function (dir) { - context.fork(dir.path, 0, null, function (context) { - context.filter = dir.path + io.pathSeparator + context.filter; - completion.file(context); - context.title = ["Color Scheme"]; - context.quote = ["", function (text) text.replace(/\.vimp$/, ""), ""]; + io.readDirectory(dir).forEach(function (file) { + if (/\.vimp$/.test(file.leafName) && !colors.some(function (c) c.leafName == file.leafName)) + colors.push(file); }); }); + + context.title = ["Color Scheme", "Runtime Path"]; + context.completions = [[c.leafName.replace(/\.vimp$/, ""), c.parent.path] for ([,c] in Iterator(colors))] }, command: function command(context)