AstroJS/botanjs/src/Components/Vim/StatusBar.js

45 lines
874 B
JavaScript
Raw Normal View History

2016-03-13 18:15:24 +00:00
(function(){
var ns = __namespace( "Components.Vim" );
2016-03-12 19:30:33 +00:00
2016-03-14 19:38:05 +00:00
var debug = __import( "System.Debug" );
2016-03-12 19:30:33 +00:00
/** @type {Components.VimArea.LineFeeder} */
var LineFeeder = ns[ NS_INVOKE ]( "LineFeeder" );
var StatusBar = function( cols )
{
this.cols = cols;
this.statStamp = {};
};
StatusBar.prototype.stamp = function( pos, func )
{
this.statStamp[ pos ] = func;
};
__readOnly( StatusBar.prototype, "statusText", function()
{
var display = "";
var l = this.cols;
for( var i = 0; i < l; i ++ )
{
var avail = l - i;
var text = this.statStamp[ i ] || this.statStamp[ - avail ];
if( text )
{
text = text();
2016-03-14 19:06:16 +00:00
if( text == undefined || text === "" ) continue;
2016-03-12 19:30:33 +00:00
display += text.substr( 0, avail );
i = display.length;
2016-03-12 19:30:33 +00:00
}
else display += " ";
}
return display;
} );
ns[ NS_EXPORT ]( EX_CLASS, "StatusBar", StatusBar );
})();