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

48 lines
1.1 KiB
JavaScript
Raw Normal View History

2016-03-12 19:30:33 +00:00
(function(){
var ns = __namespace( "Components.Vim" );
var messages = {
"INSERT": "-- INSERT --"
2016-03-13 00:35:29 +00:00
, "REPLACE": "-- REPLACE --"
2016-03-12 19:30:33 +00:00
, "MORE": "-- MORE --"
2016-03-13 12:26:26 +00:00
, "VISLINE": "-- VISUAL LINE --"
2016-03-12 19:30:33 +00:00
, "WRITE": "\"%1\" %2L, %3C written"
, "CONTINUE": "Press ENTER or type command to continue"
, "SEARCH_HIT_BOTTOM": "Seach hit BOTTOM, contining at TOP"
, "TOP": "Top"
, "BOTTOM": "Bot"
, "ALL": "All"
, "EXIT": "Type :quit<Enter> to exit Vim"
};
var errors = {
"E486": "E486: Pattern not found: %1"
};
2016-03-13 18:15:24 +00:00
var GetString = function( arr, key, restArgs )
2016-03-12 19:30:33 +00:00
{
2016-03-13 18:15:24 +00:00
if( arr[ key ] == undefined ) return key;
2016-03-12 19:30:33 +00:00
var i = 0;
2016-03-13 18:15:24 +00:00
return arr[ key ].replace( /%\d+/g, function( e )
2016-03-12 19:30:33 +00:00
{
return restArgs[ i ++ ];
} );
};
2016-03-13 18:15:24 +00:00
var Message = function( key )
{
var restArgs = Array.prototype.slice.call( arguments, 1 );
return GetString( messages, key, restArgs );
};
var Error = function( key )
{
var restArgs = Array.prototype.slice.call( arguments, 1 );
return GetString( errors, key, restArgs );
};
2016-03-12 19:30:33 +00:00
ns[ NS_EXPORT ]( EX_FUNC, "Message", Message );
2016-03-13 18:15:24 +00:00
ns[ NS_EXPORT ]( EX_FUNC, "Error", Error );
2016-03-12 19:30:33 +00:00
})();