mirror of
https://github.com/slap-editor/slap.git
synced 2024-10-26 05:03:00 +03:00
Refactor out label class
This commit is contained in:
parent
61bf6bb11f
commit
6421872572
@ -6,6 +6,7 @@ var util = require('slap-util');
|
||||
var BaseWidget = require('base-widget');
|
||||
var Slap = require('./Slap');
|
||||
var BaseFindForm = require('./BaseFindForm');
|
||||
var Label = require('./Label');
|
||||
|
||||
FindForm._label = " find (/.*/ for regex): ";
|
||||
FindForm._regExpRegExp = /^\/(.+)\/(\w*)$/i;
|
||||
@ -19,15 +20,13 @@ function FindForm (opts) {
|
||||
findField: {left: FindForm._label.length}
|
||||
}, Slap.global.options.form.find, opts));
|
||||
|
||||
self.findLabel = new BaseWidget(_.merge({
|
||||
self.findLabel = new Label(_.merge({
|
||||
parent: self,
|
||||
tags: true,
|
||||
content: FindForm._label,
|
||||
top: 0,
|
||||
height: 1,
|
||||
left: 0,
|
||||
width: FindForm._label.length,
|
||||
style: self.options.style
|
||||
}, self.options.findLabel));
|
||||
}
|
||||
FindForm.prototype.__proto__ = BaseFindForm.prototype;
|
||||
|
@ -4,6 +4,7 @@ var BaseWidget = require('base-widget');
|
||||
|
||||
var Slap = require('./Slap');
|
||||
var BaseFindForm = require('./BaseFindForm');
|
||||
var Label = require('./Label');
|
||||
|
||||
GoLineForm._label = " line number: ";
|
||||
function GoLineForm (opts) {
|
||||
@ -15,15 +16,13 @@ function GoLineForm (opts) {
|
||||
findField: {left: GoLineForm._label.length}
|
||||
}, Slap.global.options.form.goLine, opts));
|
||||
|
||||
self.goLineLabel = new BaseWidget(_.merge({
|
||||
self.goLineLabel = new Label(_.merge({
|
||||
parent: self,
|
||||
tags: true,
|
||||
content: GoLineForm._label,
|
||||
top: 0,
|
||||
height: 1,
|
||||
left: 0,
|
||||
width: GoLineForm._label.length,
|
||||
style: self.options.style
|
||||
}, self.options.goLineLabel));
|
||||
}
|
||||
GoLineForm.prototype.__proto__ = BaseFindForm.prototype;
|
||||
|
24
lib/ui/Label.js
Normal file
24
lib/ui/Label.js
Normal file
@ -0,0 +1,24 @@
|
||||
var blessed = require('blessed');
|
||||
var _ = require('lodash');
|
||||
|
||||
var util = require('slap-util');
|
||||
|
||||
var BaseWidget = require('base-widget');
|
||||
var Slap = require('./Slap');
|
||||
|
||||
function Label (opts) {
|
||||
var self = this;
|
||||
|
||||
if (!(self instanceof Label)) return new Label(opts);
|
||||
|
||||
opts = _.merge({
|
||||
height: 1
|
||||
}, Slap.global.options.label, opts);
|
||||
|
||||
BaseWidget.blessed.Text.call(self, opts);
|
||||
BaseWidget.call(self, opts);
|
||||
}
|
||||
|
||||
Label.prototype.__proto__ = BaseWidget.blessed.Text.prototype;
|
||||
|
||||
module.exports = Label;
|
@ -4,6 +4,7 @@ var BaseWidget = require('base-widget');
|
||||
var Field = require('editor-widget').Field;
|
||||
var Slap = require('./Slap');
|
||||
var BaseForm = require('./BaseForm');
|
||||
var Label = require('./Label');
|
||||
|
||||
SaveAsForm._label = " save as: ";
|
||||
function SaveAsForm (opts) {
|
||||
@ -15,15 +16,13 @@ function SaveAsForm (opts) {
|
||||
field: {left: SaveAsForm._label.length}
|
||||
}, Slap.global.options.form.saveAs, opts));
|
||||
|
||||
self.saveAsLabel = new BaseWidget(_.merge({
|
||||
self.saveAsLabel = new Label(_.merge({
|
||||
parent: self,
|
||||
tags: true,
|
||||
content: SaveAsForm._label,
|
||||
top: 0,
|
||||
height: 1,
|
||||
left: 0,
|
||||
width: SaveAsForm._label.length,
|
||||
style: self.options.style
|
||||
}, self.options.saveAsLabel));
|
||||
|
||||
self.pathField = new Field(_.merge({
|
||||
|
Loading…
Reference in New Issue
Block a user