* Fix TextEditView when 'text' set by default
* Fix TextEditView row vs col * Start skeleton on HorizontalMenuView
This commit is contained in:
parent
670bf0fd6e
commit
541be2d65a
|
@ -72,16 +72,18 @@ function createUserTables() {
|
|||
|
||||
function createMessageBaseTables() {
|
||||
dbs.message.run(
|
||||
'CREATE TABLE IF NOT EXISTS message (' +
|
||||
' message_id INTEGER PRIMARY KEY,' +
|
||||
' area_id INTEGER NOT NULL,' +
|
||||
' message_uuid VARCHAR(36) NOT NULL,' +
|
||||
' reply_to_id INTEGER,' +
|
||||
' to_user_name VARCHAR NOT NULL,' +
|
||||
' from_user_name VARCHAR NOT NULL,' +
|
||||
' subject,' + // FTS
|
||||
' message,' + // FTS
|
||||
' modified_timestamp DATETIME' +
|
||||
'CREATE TABLE IF NOT EXISTS message (' +
|
||||
' message_id INTEGER PRIMARY KEY,' +
|
||||
' area_id INTEGER NOT NULL,' +
|
||||
' message_uuid VARCHAR(36) NOT NULL,' +
|
||||
' reply_to_id INTEGER,' +
|
||||
' to_user_name VARCHAR NOT NULL,' +
|
||||
' from_user_name VARCHAR NOT NULL,' +
|
||||
' subject,' + // FTS @ message_fts
|
||||
' message,' + // FTS @ message_fts
|
||||
' modified_timestamp DATETIME NOT NULL,' +
|
||||
' UNIQUE(message_id, area_id),' +
|
||||
' UNIQUE(message_uuid)' +
|
||||
');'
|
||||
);
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@ EditTextView.prototype.onKeyPress = function(ch, key) {
|
|||
if(this.text.length >= this.dimens.width) {
|
||||
this.redraw();
|
||||
} else {
|
||||
this.cursorPos.row -= 1;
|
||||
if(this.cursorPos.row >= 0) {
|
||||
this.cursorPos.col -= 1;
|
||||
if(this.cursorPos.col >= 0) {
|
||||
this.clientBackspace();
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ EditTextView.prototype.onKeyPress = function(ch, key) {
|
|||
return;
|
||||
} else if(this.isSpecialKeyMapped('clearLine', key.name)) {
|
||||
this.text = '';
|
||||
this.cursorPos.row = 0;
|
||||
this.cursorPos.col = 0;
|
||||
this.setFocus(true); // resetting focus will redraw & adjust cursor
|
||||
|
||||
return;
|
||||
|
@ -66,7 +66,7 @@ EditTextView.prototype.onKeyPress = function(ch, key) {
|
|||
// no shortcuts - redraw the view
|
||||
this.redraw();
|
||||
} else {
|
||||
this.cursorPos.row += 1;
|
||||
this.cursorPos.col += 1;
|
||||
|
||||
if(this.textMaskChar) {
|
||||
this.client.term.write(this.textMaskChar);
|
||||
|
@ -80,57 +80,10 @@ EditTextView.prototype.onKeyPress = function(ch, key) {
|
|||
EditTextView.super_.prototype.onKeyPress.call(this, ch, key);
|
||||
};
|
||||
|
||||
/*
|
||||
EditTextView.prototype.onKeyPress = function(key, isSpecial) {
|
||||
if(isSpecial) {
|
||||
return;
|
||||
}
|
||||
EditTextView.prototype.setText = function(text) {
|
||||
// draw & set |text|
|
||||
EditTextView.super_.prototype.setText.call(this, text);
|
||||
|
||||
assert(1 === key.length);
|
||||
|
||||
if(this.text.length < this.maxLength) {
|
||||
key = strUtil.stylizeString(key, this.textStyle);
|
||||
|
||||
this.text += key;
|
||||
|
||||
if(this.text.length > this.dimens.width) {
|
||||
// no shortcuts - redraw the view
|
||||
this.redraw();
|
||||
} else {
|
||||
this.cursorPos.row += 1;
|
||||
|
||||
if(this.textMaskChar) {
|
||||
this.client.term.write(this.textMaskChar);
|
||||
} else {
|
||||
this.client.term.write(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EditTextView.super_.prototype.onKeyPress.call(this, key, isSpecial);
|
||||
// adjust local cursor tracking
|
||||
this.cursorPos = { row : 0, col : text.length };
|
||||
};
|
||||
|
||||
EditTextView.prototype.onSpecialKeyPress = function(keyName) {
|
||||
if(this.isSpecialKeyMapped('backspace', keyName)) {
|
||||
if(this.text.length > 0) {
|
||||
this.text = this.text.substr(0, this.text.length - 1);
|
||||
|
||||
if(this.text.length >= this.dimens.width) {
|
||||
this.redraw();
|
||||
} else {
|
||||
this.cursorPos.row -= 1;
|
||||
if(this.cursorPos.row >= 0) {
|
||||
this.clientBackspace();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(this.isSpecialKeyMapped('clearLine', keyName)) {
|
||||
this.text = '';
|
||||
this.cursorPos.row = 0;
|
||||
this.setFocus(true); // resetting focus will redraw & adjust cursor
|
||||
}
|
||||
|
||||
|
||||
EditTextView.super_.prototype.onSpecialKeyPress.call(this, keyName);
|
||||
};
|
||||
*/
|
|
@ -0,0 +1,50 @@
|
|||
/* jslint node: true */
|
||||
'use strict';
|
||||
|
||||
var MenuView = require('./menu_view.js').MenuView;
|
||||
var ansi = require('./ansi_term.js');
|
||||
var strUtil = require('./string_util.js');
|
||||
|
||||
function HorizontalMenuView = function(options) {
|
||||
options.cursor = options.cursor || 'hide';
|
||||
|
||||
MenuView.call(this, options);
|
||||
|
||||
var self = this;
|
||||
}
|
||||
|
||||
require('util').inherits(HorizontalMenuView, MenuView);
|
||||
|
||||
HorizontalMenuView.prototype.redraw = function() {
|
||||
HorizontalMenuView.super_.prototype.redraw.call(this);
|
||||
};
|
||||
|
||||
HorizontalMenuView.prototype.setPosition = function(pos) {
|
||||
HorizontalMenuView.super_.prototype.setPosition.call(this, pos);
|
||||
|
||||
|
||||
};
|
||||
|
||||
HorizontalMenuView.prototype.setFocus = function(focused) {
|
||||
HorizontalMenuView.super_.prototype.setFocus.call(this, focused);
|
||||
|
||||
this.redraw();
|
||||
};
|
||||
|
||||
HorizontalMenuView.prototype.setItems = function(items) {
|
||||
HorizontalMenuView.super_.prototype.setItems.call(this, items);
|
||||
|
||||
//
|
||||
// Styles:
|
||||
// * itemPadding: n
|
||||
// *
|
||||
//
|
||||
//
|
||||
// item1 item2 itemThree itemfour!!!!!
|
||||
// ^^^^^^^^^
|
||||
//
|
||||
// item1 item2 itemThree item!!!!!
|
||||
// ^^^^^^^
|
||||
|
||||
|
||||
};
|
|
@ -115,6 +115,7 @@ function stylizeString(s, style) {
|
|||
}
|
||||
|
||||
// Based on http://www.webtoolkit.info/
|
||||
// :TODO: Look into lodash padLeft, padRight, etc.
|
||||
function pad(s, len, padChar, dir, stringSGR, padSGR) {
|
||||
len = miscUtil.valueWithDefault(len, 0);
|
||||
padChar = miscUtil.valueWithDefault(padChar, ' ');
|
||||
|
|
|
@ -24,7 +24,7 @@ function TextView(options) {
|
|||
if(options.maxLength) {
|
||||
this.maxLength = options.maxLength;
|
||||
} else {
|
||||
this.maxLength = this.client.term.termWidth - this.position.row;
|
||||
this.maxLength = this.client.term.termWidth - this.position.col;
|
||||
}
|
||||
|
||||
this.fillChar = miscUtil.valueWithDefault(options.fillChar, ' ').substr(0, 1);
|
||||
|
|
|
@ -14,7 +14,7 @@ exports.VerticalMenuView = VerticalMenuView;
|
|||
|
||||
function VerticalMenuView(options) {
|
||||
options.cursor = options.cursor || 'hide';
|
||||
options.justify = options.justify || 'right';
|
||||
options.justify = options.justify || 'right'; // :TODO: default to center
|
||||
|
||||
MenuView.call(this, options);
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ function FullScreenEditorModule(options) {
|
|||
|
||||
this.menuMethods = {
|
||||
editorEscPressed : function(formData, extraArgs) {
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -442,17 +442,16 @@
|
|||
"ET1ET2MT3" : {
|
||||
"mci" : {
|
||||
"ET1" : {
|
||||
"width" : 20,
|
||||
"text" : "FIXME: to"
|
||||
"width" : 20,
|
||||
"placeholder" : "TODO support this",
|
||||
"focus" : true
|
||||
},
|
||||
"ET2" : {
|
||||
"width" : 20,
|
||||
"text" : "FIXME: from"
|
||||
"width" : 20
|
||||
},
|
||||
"MT3" : {
|
||||
"width" : 79,
|
||||
"height" : 17,
|
||||
"focus" : true,
|
||||
"text" : "",
|
||||
"submit" : [ "escape" ]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue