mirror of
https://github.com/embarklabs/neo-blessed.git
synced 2025-01-10 19:16:20 +00:00
fix ritems handling. debug.
This commit is contained in:
parent
bcb248b768
commit
096869d82e
@ -486,17 +486,12 @@ Screen.prototype.postEnter = function() {
|
|||||||
top: 'center',
|
top: 'center',
|
||||||
width: '30%',
|
width: '30%',
|
||||||
height: '30%',
|
height: '30%',
|
||||||
border: 'bg',
|
border: 'line',
|
||||||
label: ' {bold}Debug Log{/bold} ',
|
label: ' {bold}Debug Log{/bold} ',
|
||||||
tags: true,
|
tags: true,
|
||||||
keys: true,
|
keys: true,
|
||||||
vi: true,
|
vi: true,
|
||||||
mouse: true,
|
mouse: true,
|
||||||
style: {
|
|
||||||
border: {
|
|
||||||
bg: 'red'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
scrollbar: {
|
scrollbar: {
|
||||||
ch: ' ',
|
ch: ' ',
|
||||||
track: {
|
track: {
|
||||||
@ -5382,18 +5377,18 @@ List.prototype.fuzzyFind = function(search, back) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!back) {
|
if (!back) {
|
||||||
for (var i = start; i < this.items.length; i++){
|
for (var i = start; i < this.ritems.length; i++){
|
||||||
if (test(this.items[i].getText())) return i;
|
if (test(helpers.cleanTags(this.ritems[i]))) return i;
|
||||||
}
|
}
|
||||||
for (var i = 0; i < start; 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 {
|
} else {
|
||||||
for (var i = start; i >= 0; i--){
|
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--){
|
for (var i = this.ritems.length - 1; i > start; i--){
|
||||||
if (test(this.items[i].getText())) return i;
|
if (test(helpers.cleanTags(this.ritems[i]))) return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5406,8 +5401,8 @@ List.prototype.getItemIndex = function(child) {
|
|||||||
} else if (typeof child === 'string') {
|
} else if (typeof child === 'string') {
|
||||||
var i = this.ritems.indexOf(child);
|
var i = this.ritems.indexOf(child);
|
||||||
if (~i) return i;
|
if (~i) return i;
|
||||||
for (i = 0; i < this.items.length; i++) {
|
for (i = 0; i < this.ritems.length; i++) {
|
||||||
if (this.items[i].getText() === child) {
|
if (helpers.cleanTags(this.ritems[i]) === child) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5497,7 +5492,7 @@ List.prototype.select = function(index) {
|
|||||||
this._listInitialized = true;
|
this._listInitialized = true;
|
||||||
|
|
||||||
this.selected = index;
|
this.selected = index;
|
||||||
this.value = this.items[this.selected].getText();
|
this.value = helpers.cleanTags(this.ritems[this.selected]);
|
||||||
if (!this.parent) return;
|
if (!this.parent) return;
|
||||||
this.scrollTo(this.selected);
|
this.scrollTo(this.selected);
|
||||||
};
|
};
|
||||||
@ -5545,7 +5540,7 @@ List.prototype.pick = function(label, callback) {
|
|||||||
self.hide();
|
self.hide();
|
||||||
self.screen.render();
|
self.screen.render();
|
||||||
if (!el) return callback();
|
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);
|
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.merge = merge;
|
||||||
helpers.asort = asort;
|
helpers.asort = asort;
|
||||||
helpers.findFile = findFile;
|
helpers.findFile = findFile;
|
||||||
|
@ -18,7 +18,7 @@ screen = blessed.screen({
|
|||||||
screen.debugLog.parseTags = true;
|
screen.debugLog.parseTags = true;
|
||||||
var logs = '';
|
var logs = '';
|
||||||
require('./tail')(__dirname + '/logs/widget.log').on('line', function(line) {
|
require('./tail')(__dirname + '/logs/widget.log').on('line', function(line) {
|
||||||
if (!screen.debugLog.hidden) return;
|
// if (!screen.debugLog.hidden) return;
|
||||||
logs += line + '\n';
|
logs += line + '\n';
|
||||||
});
|
});
|
||||||
screen.debugLog.on('show', function() {
|
screen.debugLog.on('show', function() {
|
||||||
@ -26,6 +26,7 @@ screen.debugLog.on('show', function() {
|
|||||||
screen.debug(logs);
|
screen.debug(logs);
|
||||||
logs = '';
|
logs = '';
|
||||||
}
|
}
|
||||||
|
screen.render();
|
||||||
});
|
});
|
||||||
|
|
||||||
screen.append(blessed.text({
|
screen.append(blessed.text({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user