lots of work fixing bugs with the command line, also removal of useless console.log

This commit is contained in:
Joe Walker 2010-12-11 19:01:02 +00:00
commit 9cff2e0908
10 changed files with 385 additions and 240 deletions

View file

@ -19,13 +19,13 @@
padding: 8px;
}
.cptCompletion.VALID { background: rgba(210, 255, 210, 1); }
.cptCompletion.INCOMPLETE { background: rgba(255, 230, 210, 1); }
.cptCompletion.INVALID { background: rgba(255, 210, 210, 1); }
.cptCompletion.VALID { background: #FFF; }
.cptCompletion.INCOMPLETE { background: #DDD; }
.cptCompletion.INVALID { background: #DDD; }
.cptCompletion span { color: #FFF; }
.cptCompletion span.INCOMPLETE { text-shadow: 0px 0px 2px #ff8800; }
.cptCompletion span.INVALID { text-shadow: 0px 0px 5px #ff0000; }
.cptCompletion span.INCOMPLETE { text-shadow: 0px 0px 2px #F80; }
.cptCompletion span.INVALID { text-shadow: 0px 0px 5px #F00; }
#cockpit, .cptCompletion {

View file

@ -59,9 +59,10 @@ var Status = require('pilot/types').Status;
* 2. Attach a set of events so the command line works
*/
exports.startup = function(data, reason) {
// TODO: We should probably cut this up into an object
var settings = data.env.settings;
var doc = document;
var win = doc.defaultView;
var cli = new CliRequisition();
// TODO: we should have a better way to specify command lines???
@ -71,7 +72,7 @@ exports.startup = function(data, reason) {
return;
}
var templates = doc.createElement('dic');
var templates = doc.createElement('div');
templates.innerHTML = plainRow;
var row = templates.firstChild;
@ -88,12 +89,22 @@ exports.startup = function(data, reason) {
input.parentNode.insertBefore(output, input);
function resizer() {
var style = win.getComputedStyle(input, null);
var top, height, left, width;
var top = parseInt(style.getPropertyValue('top'), 10);
var height = parseInt(style.getPropertyValue('height'), 10);
var left = parseInt(style.getPropertyValue('left'), 10);
var width = parseInt(style.getPropertyValue('width'), 10);
if (input.getClientRects) {
var rect = input.getClientRects()[0];
top = rect.top;
height = rect.height;
left = rect.left;
width = rect.width;
}
else {
var style = win.getComputedStyle(input, null);
top = parseInt(style.getPropertyValue('top'), 10);
height = parseInt(style.getPropertyValue('height'), 10);
left = parseInt(style.getPropertyValue('left'), 10);
width = parseInt(style.getPropertyValue('width'), 10);
}
completer.style.top = top + 'px';
completer.style.height = height + 'px';
@ -125,6 +136,20 @@ exports.startup = function(data, reason) {
}, this);
}.bind(this));
var showHint = settings.getSetting('showHint');
function hintShower() {
if (showHint.get()) {
hinter.style.display = 'block';
}
else {
hinter.style.display = 'none';
}
}
hintShower();
showHint.addEventListener('change', hintShower.bind(this));
var outputHeight = settings.getSetting('outputHeight');
/*
// All this does is to kill TABs normal use. I wonder if we can train
// people to use right arrow? Probably not? but ...
@ -210,10 +235,10 @@ exports.startup = function(data, reason) {
}
}
worst = Hint.worst(hints) || NO_HINT;
worst = (hints.length > 0) ? hints[0] : NO_HINT;
var message = worst.message;
if (worst.predictions && worst.predictions.length > 0) {
message += ' [ ';
message += ': [ ';
worst.predictions.forEach(function(prediction) {
if (prediction.name) {
message += prediction.name + ' | ';

View file

@ -0,0 +1,66 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Skywriter.
*
* The Initial Developer of the Original Code is
* Mozilla.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Joe Walker (jwalker@mozilla.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
var showHintSetting = {
name: "showHint",
description: "Do we display hints while we type?",
type: "bool",
defaultValue: true
};
var outputHeightSetting = {
name: "outputHeight",
description: "What height should the output panel be?",
type: "number",
defaultValue: 300
};
exports.startup = function(data, reason) {
data.env.settings.addSetting(showHintSetting);
data.env.settings.addSetting(outputHeightSetting);
};
exports.shutdown = function(data, reason) {
data.env.settings.removeSetting(showHintSetting);
data.env.settings.removeSetting(outputHeightSetting);
};
});