diff --git a/core/button_view.js b/core/button_view.js index 8e8d6ebc..edb32e12 100644 --- a/core/button_view.js +++ b/core/button_view.js @@ -15,7 +15,7 @@ function ButtonView(options) { TextView.call(this, options); - this.dimens.width = this.dimens.width || Math.min(10, this.client.term.termWidth - this.position.col); + this.initDefaultWidth(); } util.inherits(ButtonView, TextView); diff --git a/core/edit_text_view.js b/core/edit_text_view.js index 05868e92..db01b9f5 100644 --- a/core/edit_text_view.js +++ b/core/edit_text_view.js @@ -19,6 +19,8 @@ function EditTextView(options) { TextView.call(this, options); + this.initDefaultWidth(); + this.cursorPos = { row : 0, col : 0 }; this.clientBackspace = function() { diff --git a/core/mask_edit_text_view.js b/core/mask_edit_text_view.js index 6cdf40b0..dbc782a0 100644 --- a/core/mask_edit_text_view.js +++ b/core/mask_edit_text_view.js @@ -35,6 +35,8 @@ function MaskEditTextView(options) { TextView.call(this, options); + this.initDefaultWidth(); + this.cursorPos = { x : 0 }; this.patternArrayPos = 0; diff --git a/core/multi_line_edit_text_view.js b/core/multi_line_edit_text_view.js index 1d16e201..bd49a73f 100644 --- a/core/multi_line_edit_text_view.js +++ b/core/multi_line_edit_text_view.js @@ -97,6 +97,8 @@ function MultiLineEditTextView(options) { View.call(this, options); + this.initDefaultWidth(); + var self = this; // diff --git a/core/spinner_menu_view.js b/core/spinner_menu_view.js index e6be1232..7c38b195 100644 --- a/core/spinner_menu_view.js +++ b/core/spinner_menu_view.js @@ -17,6 +17,8 @@ function SpinnerMenuView(options) { MenuView.call(this, options); + this.initDefaultWidth(); + var self = this; /* diff --git a/core/toggle_menu_view.js b/core/toggle_menu_view.js index ae163bd7..aadfe9c3 100644 --- a/core/toggle_menu_view.js +++ b/core/toggle_menu_view.js @@ -14,6 +14,8 @@ function ToggleMenuView (options) { MenuView.call(this, options); + this.initDefaultWidth(); + var self = this; /* diff --git a/core/vertical_menu_view.js b/core/vertical_menu_view.js index e91e86f2..1837b718 100644 --- a/core/vertical_menu_view.js +++ b/core/vertical_menu_view.js @@ -20,7 +20,7 @@ function VerticalMenuView(options) { MenuView.call(this, options); - this.dimens.width = this.dimens.width || Math.min(15, this.client.term.termWidth - this.position.col); + this.initDefaultWidth(); const self = this; diff --git a/core/view.js b/core/view.js index e32b402b..7d3c5693 100644 --- a/core/view.js +++ b/core/view.js @@ -100,6 +100,10 @@ function View(options) { //this.client.term.write(ansi.setCursorStyle(this.cursorStyle)); this.client.term.rawWrite('show' === this.cursor ? ansi.showCursor() : ansi.hideCursor()); }; + + this.initDefaultWidth = function(width = 15) { + this.dimens.width = this.dimens.width || Math.min(width, this.client.term.termWidth - this.position.col); + }; } util.inherits(View, events.EventEmitter);