diff --git a/core/database.js b/core/database.js index 23d64ae8..da37b2c7 100644 --- a/core/database.js +++ b/core/database.js @@ -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)' + ');' ); diff --git a/core/edit_text_view.js b/core/edit_text_view.js index bb7d4777..9a424712 100644 --- a/core/edit_text_view.js +++ b/core/edit_text_view.js @@ -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); -}; -*/ \ No newline at end of file diff --git a/core/horizontal_menu_view.js b/core/horizontal_menu_view.js new file mode 100644 index 00000000..fee5cdb6 --- /dev/null +++ b/core/horizontal_menu_view.js @@ -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!!!!! + // ^^^^^^^ + + +}; \ No newline at end of file diff --git a/core/string_util.js b/core/string_util.js index 82c87cd2..0a70d680 100644 --- a/core/string_util.js +++ b/core/string_util.js @@ -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, ' '); diff --git a/core/text_view.js b/core/text_view.js index 3ddd6b3f..621d5848 100644 --- a/core/text_view.js +++ b/core/text_view.js @@ -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); diff --git a/core/vertical_menu_view.js b/core/vertical_menu_view.js index 46f4e9c8..19939dfc 100644 --- a/core/vertical_menu_view.js +++ b/core/vertical_menu_view.js @@ -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); diff --git a/mods/fse.js b/mods/fse.js index 646531df..9c6952f8 100644 --- a/mods/fse.js +++ b/mods/fse.js @@ -68,7 +68,7 @@ function FullScreenEditorModule(options) { this.menuMethods = { editorEscPressed : function(formData, extraArgs) { - + } }; } diff --git a/mods/menu.json b/mods/menu.json index f44f6426..edfee06a 100644 --- a/mods/menu.json +++ b/mods/menu.json @@ -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" ] }