Several bug fixes.
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
### KNOWN BUGS
|
||||
* startAtomic behaves like startDocumentListen
|
||||
* endAtomic does nothing (maybe because startAtomic don't works)
|
||||
* unguard does nothing (but guard works)
|
||||
* setExitDelay
|
||||
* controler seems attached to the first socket, even if already ended
|
||||
|
||||
@@ -13,23 +13,62 @@ server.createServer(3219, "127.0.0.1", function (password) {
|
||||
console.log("Ready to serve");
|
||||
|
||||
process.stdin.on("data", function(data) {
|
||||
if (data.toString() !== "exit"){
|
||||
try {
|
||||
var cmd = data.toString();
|
||||
console.log("CMD "+cmd);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
switch(cmd) {
|
||||
case "exit\n" :
|
||||
controler.detach();
|
||||
process.exit();
|
||||
break;
|
||||
case "getCursor\n" :
|
||||
controler.getCursor(function (buffer, lnum, col, pos) {
|
||||
console.log("=> id:"+buffer+" l:"+lnum+" c:"+col+" off:"+pos);
|
||||
});
|
||||
break;
|
||||
case "getLength\n" :
|
||||
controler.getBuffer(1).getLength(function (length) {
|
||||
console.log("=> length:"+length);
|
||||
});
|
||||
break;
|
||||
case "getAnno\n" :
|
||||
controler.getBuffer(1).getAnno(1, function(line){
|
||||
console.log("=> line:"+line);
|
||||
});
|
||||
break;
|
||||
case "getModified\n" :
|
||||
controler.getModified(function (flag) {
|
||||
console.log("=> modified:"+flag);
|
||||
});
|
||||
break;
|
||||
case "getText\n" :
|
||||
controler.getBuffer(1).getText(function (text){
|
||||
console.log("=> "+text);
|
||||
});
|
||||
break;
|
||||
case "insert\n" :
|
||||
controler.getBuffer(1).insert(5, "Insert Test\nInsert Test",
|
||||
function (error){
|
||||
console.log("=> "+error);
|
||||
});
|
||||
break;
|
||||
case "remove\n" :
|
||||
controler.getBuffer(1).remove(2,4,function(error){
|
||||
console.log("=> "+error);
|
||||
});
|
||||
break;
|
||||
default :
|
||||
console.log("CMD : "+data.toString());
|
||||
console.log("RETURNED : "+eval(data.toString()));
|
||||
}
|
||||
catch (ex) {
|
||||
console.log("Erreur : "+ex.message)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
controler.detach();
|
||||
catch (ex) {
|
||||
console.log("Erreur : "+ex.message);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -59,10 +59,22 @@ function Buffer (client, buffId) {
|
||||
};
|
||||
|
||||
//Tell Vim that the buffer is owned by the controler
|
||||
//Réception d'événéments si vrai
|
||||
this.netbeansBuffer = function (isNetBeansBuffer) {
|
||||
client.sendCommand("netbeansBuffer", buffId, Types.bool(isNetBeansBuffer));
|
||||
};
|
||||
|
||||
//Start an atomic opperation. Vim screen is not updated untill endAtomic is called
|
||||
//BUG : Interprété comme un startDocumentListen
|
||||
this.startAtomic = function () {
|
||||
client.sendCommand("startAtomic", buffId);
|
||||
};
|
||||
|
||||
//End an atomic opperation.
|
||||
//BUG : Ne fais rien du tout
|
||||
this.endAtomic = function() {
|
||||
client.sendCommand("endAtmoic", buffId );
|
||||
};
|
||||
//Remove and anno
|
||||
this.removeAnno = function (serNum) {
|
||||
client.sendCommand("removeAnno",buffId,serNum);
|
||||
@@ -119,6 +131,7 @@ function Buffer (client, buffId) {
|
||||
};
|
||||
|
||||
//Ungard the text. off is the starting position, len the length of the text
|
||||
//BUG : Doesn't works at all, text area keeps guard
|
||||
this.unguard = function (off, len) {
|
||||
client.sendCommand("unguard", buffId, Types.position(off), len);
|
||||
};
|
||||
@@ -128,23 +141,10 @@ function Buffer (client, buffId) {
|
||||
client.sendCommand("editFile", buffId, Types.string(pathName));
|
||||
};
|
||||
|
||||
//Start an atomic opperation. Vim screen is not updated untill endAtomic is called
|
||||
this.startAtomic = function () {
|
||||
client.sendCommand("startAtomic", buffId);
|
||||
};
|
||||
|
||||
//End an atomic opperation.
|
||||
this.endAtomic = function() {
|
||||
client.sendCommand("endAtmoic", buffId);
|
||||
};
|
||||
|
||||
|
||||
/* FUNCTIONS */
|
||||
|
||||
//Get cursor position. Callback function get the line, column and offset
|
||||
this.getCursor = function (callback) {
|
||||
client.callFunction("getCursor", buffId, callback);
|
||||
};
|
||||
|
||||
//Get the length of current buffer.
|
||||
this.getLength = function (callback) {
|
||||
|
||||
@@ -114,7 +114,7 @@ function NetbeansClient(socket, authentication, onEvent, onError, onDisconnected
|
||||
if (message[i] === "\\") {
|
||||
i += 1;
|
||||
|
||||
if (i < message.length) {
|
||||
if (i === message.length) {
|
||||
throw "Unfinished string in message";
|
||||
}
|
||||
else {
|
||||
@@ -155,11 +155,11 @@ function NetbeansClient(socket, authentication, onEvent, onError, onDisconnected
|
||||
i += 1;
|
||||
}
|
||||
|
||||
if (i - argStartOffset === 1 && (message[i] === "T" || message[i] === "F")) {
|
||||
args.push(message[i] === "T");
|
||||
if (i - argStartOffset === 1 && (message[i - 1] === "T" || message[i - 1] === "F")) {
|
||||
args.push(message[i - 1] === "T");
|
||||
}
|
||||
else {
|
||||
var argument = message.substr(argStartOffset, i);
|
||||
var argument = message.substring(argStartOffset, i);
|
||||
|
||||
if (Number.isNaN(argument)) {
|
||||
if (argument.contains("/")) {
|
||||
@@ -170,10 +170,13 @@ function NetbeansClient(socket, authentication, onEvent, onError, onDisconnected
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.log("ARG : "+argument);
|
||||
args.push(parseInt(argument));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
argStartOffset = ++i;
|
||||
}
|
||||
|
||||
if (isEvent) {
|
||||
@@ -237,18 +240,20 @@ function NetbeansClient(socket, authentication, onEvent, onError, onDisconnected
|
||||
var lastArg = arguments.length - 1;
|
||||
|
||||
if (typeof(arguments[lastArg]) === "function") {
|
||||
Object.defineProperty(callbacks, currentSeqno, {value: arguments[lastArg]});
|
||||
Object.defineProperty(callbacks, seqno, {value: arguments[lastArg], configurable: true});
|
||||
lastArg -= 1;
|
||||
}
|
||||
|
||||
var data = buffer + ":" + name + "/" + seqno;
|
||||
|
||||
for (var i = 2 ; i < lastArg ; ++i) {
|
||||
for (var i = 2 ; i <= lastArg ; ++i) {
|
||||
data += " " + arguments[i];
|
||||
}
|
||||
|
||||
data += "\n";
|
||||
|
||||
console.log("CALL : "+data);
|
||||
|
||||
socket.write(data);
|
||||
|
||||
};
|
||||
@@ -303,10 +308,10 @@ function Controler(socket, authentication) {
|
||||
var buffId = 0;
|
||||
var buffers = {};
|
||||
|
||||
function getBuffer() {
|
||||
function newBuffer() {
|
||||
buffId += 1;
|
||||
var buffer = new Buffer(client, buffId);
|
||||
Object.defineProperty(buffers, buffId, {value: buffer});
|
||||
Object.defineProperty(buffers, buffId, {value: buffer, configurable: true});
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@@ -330,7 +335,7 @@ function Controler(socket, authentication) {
|
||||
|
||||
//Create a new buffer. Return the buffer created
|
||||
this.create = function() {
|
||||
var buffer = getBuffer();
|
||||
var buffer = newBuffer();
|
||||
client.sendCommand("create", buffId);
|
||||
return buffer;
|
||||
};
|
||||
@@ -338,7 +343,7 @@ function Controler(socket, authentication) {
|
||||
//Associate already opened buffer on Vim to a controler owned buffer
|
||||
//Return the newly created buffer
|
||||
this.putBufferNumber = function (pathname) {
|
||||
var buffer = getBuffer();
|
||||
var buffer = newBuffer();
|
||||
client.sendCommand("putBufferNumber", buffId, Types.string(pathname)); //TODO : May be better on the buffer
|
||||
return buffer;
|
||||
};
|
||||
@@ -346,11 +351,12 @@ function Controler(socket, authentication) {
|
||||
//Associate already opened buffer on Vim to a controler owned buffer and bring it to front
|
||||
//Return the newly created buffer
|
||||
this.setBufferNumber = function (pathname) {
|
||||
var buffer = getBuffer();
|
||||
var buffer = newBuffer();
|
||||
client.sendCommand("setBufferNumber", buffId, Types.string(pathname));
|
||||
return buffer;
|
||||
};
|
||||
|
||||
|
||||
/* GLOBAL FUNCTIONS */
|
||||
|
||||
//Ask Vim to save and exit
|
||||
@@ -363,6 +369,10 @@ function Controler(socket, authentication) {
|
||||
client.callFunction("getModified", 0, callback);
|
||||
};
|
||||
|
||||
//Get cursor position. Callback function get the line, column and offset
|
||||
this.getCursor = function (callback) {
|
||||
client.callFunction("getCursor", 0, callback);
|
||||
};
|
||||
|
||||
/* CONNTROLER CONTROL */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user