Files
vim-netbeans-server/lib/types.js

67 lines
1.4 KiB
JavaScript

//Return the color in netbeans format
//A color can be a number (RRGGBB), a name or nothing
function color (value) {
"use strict";
return value ? value : "none";
}
//Return the boolean value in ntebeans format
function bool (value) {
"use strict";
return value ? "T" : "F";
}
//Return position in netbeans format.
//A position can be an array containing 1 based line and 0 based column or a 0 based offset
function position (pos) {
"use strict";
if (Array.isArray(pos)) {
return pos[0]+"/"+pos[1];
}
else {
return pos;
}
}
//Return a netbeans formated string
function string (value) {
"use strict";
var buffer = "\"";
for (var i = 0 ; i < value.length ; ++i){
switch (value[i]) {
case "\n" :
buffer += "\\n";
break;
case "\t" :
buffer += "\\t";
break;
case "\r" :
buffer += "\\r";
break;
case "\\" :
buffer += "\\\\";
break;
case "\"" :
buffer += "\\\"";
break;
default :
buffer += value[i];
break;
}
}
buffer += "\"";
return buffer;
}
module.exports.string = string;
module.exports.color = color;
module.exports.position = position;
module.exports.bool = bool;