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

Move the completion list above the MOW in REPL mode.

This commit is contained in:
Kris Maglione
2011-04-04 20:59:37 -04:00
parent 2dd8c88898
commit 8f996c79bd
2 changed files with 18 additions and 12 deletions

View File

@@ -301,7 +301,7 @@ var CommandWidgets = Class("CommandWidgets", {
}); });
var CommandMode = Class("CommandMode", { var CommandMode = Class("CommandMode", {
init: function init() { init: function CM_init() {
this.keepCommand = userContext.hidden_option_command_afterimage; this.keepCommand = userContext.hidden_option_command_afterimage;
}, },
@@ -311,7 +311,7 @@ var CommandMode = Class("CommandMode", {
get prompt() this.widgets.prompt, get prompt() this.widgets.prompt,
set prompt(val) this.widgets.prompt = val, set prompt(val) this.widgets.prompt = val,
open: function (command) { open: function CM_open(command) {
dactyl.assert(isinstance(this.mode, modes.COMMAND_LINE), dactyl.assert(isinstance(this.mode, modes.COMMAND_LINE),
/*L*/"Not opening command line in non-command-line mode."); /*L*/"Not opening command line in non-command-line mode.");
@@ -341,7 +341,7 @@ var CommandMode = Class("CommandMode", {
get widgets() commandline.widgets, get widgets() commandline.widgets,
enter: function (stack) { enter: function CM_enter(stack) {
commandline.commandSession = this; commandline.commandSession = this;
if (stack.pop && commandline.command) { if (stack.pop && commandline.command) {
this.onChange(commandline.command); this.onChange(commandline.command);
@@ -350,7 +350,7 @@ var CommandMode = Class("CommandMode", {
} }
}, },
leave: function (stack) { leave: function CM_leave(stack) {
if (!stack.push) { if (!stack.push) {
commandline.commandSession = null; commandline.commandSession = null;
this.input.dactylKeyPress = undefined; this.input.dactylKeyPress = undefined;
@@ -375,7 +375,7 @@ var CommandMode = Class("CommandMode", {
}, },
events: { events: {
input: function onInput(event) { input: function CM_onInput(event) {
if (this.completions) { if (this.completions) {
this.resetCompletions(); this.resetCompletions();
@@ -383,7 +383,7 @@ var CommandMode = Class("CommandMode", {
} }
this.onChange(commandline.command); this.onChange(commandline.command);
}, },
keyup: function onKeyUp(event) { keyup: function CM_onKeyUp(event) {
let key = events.toString(event); let key = events.toString(event);
if (/-?Tab>$/.test(key) && this.completions) if (/-?Tab>$/.test(key) && this.completions)
this.completions.tabTimer.flush(); this.completions.tabTimer.flush();
@@ -392,7 +392,7 @@ var CommandMode = Class("CommandMode", {
keepCommand: false, keepCommand: false,
onKeyPress: function onKeyPress(events) { onKeyPress: function CM_onKeyPress(events) {
if (this.completions) if (this.completions)
this.completions.previewClear(); this.completions.previewClear();
@@ -407,7 +407,7 @@ var CommandMode = Class("CommandMode", {
onSubmit: function (value) {}, onSubmit: function (value) {},
resetCompletions: function resetCompletions() { resetCompletions: function CM_resetCompletions() {
if (this.completions) { if (this.completions) {
this.completions.context.cancelAll(); this.completions.context.cancelAll();
this.completions.wildIndex = -1; this.completions.wildIndex = -1;
@@ -426,11 +426,11 @@ var CommandExMode = Class("CommandExMode", CommandMode, {
prompt: ["Normal", ":"], prompt: ["Normal", ":"],
complete: function complete(context) { complete: function CEM_complete(context) {
context.fork("ex", 0, completion, "ex"); context.fork("ex", 0, completion, "ex");
}, },
onSubmit: function onSubmit(command) { onSubmit: function CEM_onSubmit(command) {
contexts.withContext({ file: /*L*/"[Command Line]", line: 1 }, contexts.withContext({ file: /*L*/"[Command Line]", line: 1 },
function _onSubmit() { function _onSubmit() {
io.withSavedValues(["readHeredoc"], function _onSubmit() { io.withSavedValues(["readHeredoc"], function _onSubmit() {
@@ -443,13 +443,13 @@ var CommandExMode = Class("CommandExMode", CommandMode, {
}); });
var CommandPromptMode = Class("CommandPromptMode", CommandMode, { var CommandPromptMode = Class("CommandPromptMode", CommandMode, {
init: function init(prompt, params) { init: function CPM_init(prompt, params) {
this.prompt = isArray(prompt) ? prompt : ["Question", prompt]; this.prompt = isArray(prompt) ? prompt : ["Question", prompt];
update(this, params); update(this, params);
init.supercall(this); init.supercall(this);
}, },
complete: function (context) { complete: function CPM_complete(context) {
if (this.completer) if (this.completer)
context.forkapply("prompt", 0, this, "completer", Array.slice(arguments, 1)); context.forkapply("prompt", 0, this, "completer", Array.slice(arguments, 1));
}, },
@@ -586,6 +586,9 @@ var CommandLine = Module("commandline", {
get completionList() { get completionList() {
let node = this.widgets.active.commandline; let node = this.widgets.active.commandline;
if (this.commandSession && this.commandSession.completionList)
node = document.getElementById(this.commandSession.completionList);
if (!node.completionList) { if (!node.completionList) {
let elem = document.getElementById("dactyl-completions-" + node.id); let elem = document.getElementById("dactyl-completions-" + node.id);
util.waitFor(bind(this.widgets._ready, null, elem)); util.waitFor(bind(this.widgets._ready, null, elem));

View File

@@ -790,6 +790,7 @@ var JavaScript = Module("javascript", {
this.repl = REPL(this.context); this.repl = REPL(this.context);
}, },
open: function open(context) { open: function open(context) {
modules.mow.echo(this.repl); modules.mow.echo(this.repl);
@@ -807,6 +808,8 @@ var JavaScript = Module("javascript", {
mode: modes.REPL, mode: modes.REPL,
get completionList() this.widgets.statusbar.commandline.id,
accept: function accept() { accept: function accept() {
dactyl.trapErrors(function () { this.repl.addOutput(this.command) }, this); dactyl.trapErrors(function () { this.repl.addOutput(this.command) }, this);