cleaned out redundant text browser...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2019-09-06 01:16:37 +03:00
parent a3bfda9a29
commit ca7d6cdff6

View File

@ -5416,71 +5416,6 @@ object.Constructor('HTMLBrowser',
//---------------------------------------------------------------------
// Text tree renderer...
//
// This is mainly designed for testing.
//
// XXX Q: how should the header item and it's sub-list be linked???
var TextBrowserClassPrototype = {
__proto__: BaseBrowser,
}
var TextBrowserPrototype = {
__proto__: BaseBrowser.prototype,
options: {
renderIndent: '\t',
},
// NOTE: we do not need .renderGroup(..) here as a group is not
// visible in text...
renderList: function(header, items, footer, options){
var that = this
return this.renderNested(null, items, null, null, options)
.join('\n') },
renderItem: function(item, i, options){
return item.current ?
`[ ${ item.text } ]`
: item.text },
renderNested: function(header, children, context, item, options){
var that = this
var nested = children
&& children
.flat()
.map(function(e){
return e instanceof Array ?
e.map(function(e){
return (that.options.renderIndent || ' ') + e })
: e })
.flat()
return (
// expanded...
header && nested ?
[
...(header == ' ' ?
// blank header...
[]
: ['- ' + header]),
nested,
]
// collapsed...
: header ?
[ '+ ' + header ]
// nested...
: nested )},
}
var TextBrowser =
module.TextBrowser =
object.Constructor('TextBrowser',
TextBrowserClassPrototype,
TextBrowserPrototype)
//--------------------------------------------------------------------- //---------------------------------------------------------------------
// shorthands... // shorthands...