fix ritems handling. debug.
This commit is contained in:
parent
bcb248b768
commit
096869d82e
|
@ -486,17 +486,12 @@ Screen.prototype.postEnter = function() {
|
|||
top: 'center',
|
||||
width: '30%',
|
||||
height: '30%',
|
||||
border: 'bg',
|
||||
border: 'line',
|
||||
label: ' {bold}Debug Log{/bold} ',
|
||||
tags: true,
|
||||
keys: true,
|
||||
vi: true,
|
||||
mouse: true,
|
||||
style: {
|
||||
border: {
|
||||
bg: 'red'
|
||||
}
|
||||
},
|
||||
scrollbar: {
|
||||
ch: ' ',
|
||||
track: {
|
||||
|
@ -5382,18 +5377,18 @@ List.prototype.fuzzyFind = function(search, back) {
|
|||
}
|
||||
|
||||
if (!back) {
|
||||
for (var i = start; i < this.items.length; i++){
|
||||
if (test(this.items[i].getText())) return i;
|
||||
for (var i = start; i < this.ritems.length; i++){
|
||||
if (test(helpers.cleanTags(this.ritems[i]))) return i;
|
||||
}
|
||||
for (var i = 0; i < start; i++){
|
||||
if (test(this.items[i].getText())) return i;
|
||||
if (test(helpers.cleanTags(this.ritems[i]))) return i;
|
||||
}
|
||||
} else {
|
||||
for (var i = start; i >= 0; i--){
|
||||
if (test(this.items[i].getText())) return i;
|
||||
if (test(helpers.cleanTags(this.ritems[i]))) return i;
|
||||
}
|
||||
for (var i = this.items.length - 1; i > start; i--){
|
||||
if (test(this.items[i].getText())) return i;
|
||||
for (var i = this.ritems.length - 1; i > start; i--){
|
||||
if (test(helpers.cleanTags(this.ritems[i]))) return i;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5406,8 +5401,8 @@ List.prototype.getItemIndex = function(child) {
|
|||
} else if (typeof child === 'string') {
|
||||
var i = this.ritems.indexOf(child);
|
||||
if (~i) return i;
|
||||
for (i = 0; i < this.items.length; i++) {
|
||||
if (this.items[i].getText() === child) {
|
||||
for (i = 0; i < this.ritems.length; i++) {
|
||||
if (helpers.cleanTags(this.ritems[i]) === child) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
@ -5497,7 +5492,7 @@ List.prototype.select = function(index) {
|
|||
this._listInitialized = true;
|
||||
|
||||
this.selected = index;
|
||||
this.value = this.items[this.selected].getText();
|
||||
this.value = helpers.cleanTags(this.ritems[this.selected]);
|
||||
if (!this.parent) return;
|
||||
this.scrollTo(this.selected);
|
||||
};
|
||||
|
@ -5545,7 +5540,7 @@ List.prototype.pick = function(label, callback) {
|
|||
self.hide();
|
||||
self.screen.render();
|
||||
if (!el) return callback();
|
||||
return callback(null, self.items[selected].getText());
|
||||
return callback(null, helpers.cleanTags(self.items[selected]));
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -9120,6 +9115,13 @@ helpers.attrToBinary = function(style, element) {
|
|||
return Element.prototype.sattr.call(element || {}, style);
|
||||
};
|
||||
|
||||
helpers.cleanTags = function(text) {
|
||||
return text
|
||||
.replace(/{(\/?)([\w\-,;!#]*)}/g, '')
|
||||
.replace(/\x1b\[[\d;]*m/g, '')
|
||||
.trim();
|
||||
};
|
||||
|
||||
helpers.merge = merge;
|
||||
helpers.asort = asort;
|
||||
helpers.findFile = findFile;
|
||||
|
|
|
@ -18,7 +18,7 @@ screen = blessed.screen({
|
|||
screen.debugLog.parseTags = true;
|
||||
var logs = '';
|
||||
require('./tail')(__dirname + '/logs/widget.log').on('line', function(line) {
|
||||
if (!screen.debugLog.hidden) return;
|
||||
// if (!screen.debugLog.hidden) return;
|
||||
logs += line + '\n';
|
||||
});
|
||||
screen.debugLog.on('show', function() {
|
||||
|
@ -26,6 +26,7 @@ screen.debugLog.on('show', function() {
|
|||
screen.debug(logs);
|
||||
logs = '';
|
||||
}
|
||||
screen.render();
|
||||
});
|
||||
|
||||
screen.append(blessed.text({
|
||||
|
|
Loading…
Reference in New Issue