Removing ugly looking jsdoc comment
This commit is contained in:
163
lib/buffer.js
163
lib/buffer.js
@@ -1,12 +1,6 @@
|
|||||||
var Types = require("types.js");
|
var Types = require("types.js");
|
||||||
|
|
||||||
|
//A controler owned buffer representation
|
||||||
/**
|
|
||||||
* Represents a buffer
|
|
||||||
* @class
|
|
||||||
* @param {InternalClient} client The vim client linked to the buffer
|
|
||||||
* @param {number} buffId Id of the buffer
|
|
||||||
*/
|
|
||||||
function Buffer (client, buffId) {
|
function Buffer (client, buffId) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
@@ -15,240 +9,169 @@ function Buffer (client, buffId) {
|
|||||||
|
|
||||||
/* COMMANDS */
|
/* COMMANDS */
|
||||||
|
|
||||||
/**
|
//Add an annotation into buffer. annoType is obtained through defineAnnoType. off is the position
|
||||||
* Place an annotation
|
//The anno id is returned by the call
|
||||||
* @function
|
|
||||||
* @param {number} annoType Returned annoType by defineAnnoType
|
|
||||||
* @param {number|number[]} offset Position of the annotation
|
|
||||||
* @return {number} Serial number of the anno
|
|
||||||
*/
|
|
||||||
this.addAnno = function (annoType, off) {
|
this.addAnno = function (annoType, off) {
|
||||||
serNum += 1;
|
serNum += 1;
|
||||||
client.sendCommand("addAnno", buffId, serNum, annoType,Types.position(off), 0 );
|
client.sendCommand("addAnno", buffId, serNum, annoType,Types.position(off), 0 );
|
||||||
return serNum;
|
return serNum;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
//Close the buffer
|
||||||
* Close the buffer.
|
|
||||||
* @function
|
|
||||||
*/
|
|
||||||
this.close = function(){
|
this.close = function(){
|
||||||
client.sendCommand("close", buffId);
|
client.sendCommand("close", buffId);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
//Define an annotation type. typename : friendly name, glyphFile : icon, fg and bg are the colors
|
||||||
* Define a type of annotation for this buffer
|
//The anno type id is returned by the call
|
||||||
* @function
|
|
||||||
* @param {string} typeName Name that identifies this annotation type
|
|
||||||
* @param {string} glyphFile Name of icon file
|
|
||||||
* @param {string|number} fg Foreground color
|
|
||||||
* @param {string|number} bg Background color
|
|
||||||
* @return {number} Identifier of the annotation type
|
|
||||||
*/
|
|
||||||
this.defineAnnoType = function (typeName, glyphFile, fg, bg) {
|
this.defineAnnoType = function (typeName, glyphFile, fg, bg) {
|
||||||
typeNum += 1;
|
typeNum += 1;
|
||||||
client.sendCommand("defineAnnoType", buffId, typeNum, Types.string(typeName), Types.string(""), Types.string(glyphFile), Types.color(fg), Types.color(bg));
|
client.sendCommand("defineAnnoType", buffId, typeNum, Types.string(typeName), Types.string(""), Types.string(glyphFile), Types.color(fg), Types.color(bg));
|
||||||
return typeNum;
|
return typeNum;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
//Start listening for insert and remove events on buffer
|
||||||
* Mark the buffer to report changes with "insert" and "remove" events
|
|
||||||
* @function
|
|
||||||
*/
|
|
||||||
this.startDocumentListen = function () {
|
this.startDocumentListen = function () {
|
||||||
client.sendCommand("startDocumentListen", buffId);
|
client.sendCommand("startDocumentListen", buffId);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Stop listening for insert and remove events on buffer
|
||||||
/**
|
|
||||||
* Mark the buffer to stop reporting changes
|
|
||||||
* @function
|
|
||||||
*/
|
|
||||||
this.stopDocumentListen = function () {
|
this.stopDocumentListen = function () {
|
||||||
client.sendCommand("stopDocumentListen", buffId);
|
client.sendCommand("stopDocumentListen", buffId);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
//Guard an area of the buffer. off is the position, len the length of text
|
||||||
* Mark an area in the buffer as guarded
|
|
||||||
* @function
|
|
||||||
* @param {number|number[]} off Starting position
|
|
||||||
* @param {number} len Length of the area
|
|
||||||
*/
|
|
||||||
this.guard = function (off, len) {
|
this.guard = function (off, len) {
|
||||||
client.sendCommand("guard",buffId, Types.position(off), len);
|
client.sendCommand("guard",buffId, Types.position(off), len);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
//Tell Vim that the buffer is ready to be used
|
||||||
* Tell Vim that the buffer is ready to be used and make it the current buffer
|
|
||||||
* Fire the BufReadPost autocommand event
|
|
||||||
* @function
|
|
||||||
*/
|
|
||||||
this.initDone = function () {
|
this.initDone = function () {
|
||||||
client.sendCommand("initdone", buffId);
|
client.sendCommand("initdone", buffId);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Tell Vim that inserts are done
|
||||||
/**
|
|
||||||
* Tell Vim an initial insert is done
|
|
||||||
* Trigger a read message being printed
|
|
||||||
* @function
|
|
||||||
*/
|
|
||||||
this.insertDone = function () {
|
this.insertDone = function () {
|
||||||
client.sendCommand("insertDone", buffId);
|
client.sendCommand("insertDone", buffId);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Tell Vim that the buffer is owned by the controler
|
||||||
/**
|
|
||||||
* Tell Vim that the buffer is owned by the controller
|
|
||||||
* @function
|
|
||||||
* @param isNetBeansBuffer
|
|
||||||
*/
|
|
||||||
this.netbeansBuffer = function (isNetBeansBuffer) {
|
this.netbeansBuffer = function (isNetBeansBuffer) {
|
||||||
client.sendCommand("netbeansBuffer", buffId, Types.bool(isNetBeansBuffer));
|
client.sendCommand("netbeansBuffer", buffId, Types.bool(isNetBeansBuffer));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Remove and anno
|
||||||
/**
|
|
||||||
* Removes a previously added annotation
|
|
||||||
* @function
|
|
||||||
* @param {number} serNum Identifier of the annotation to remove
|
|
||||||
*/
|
|
||||||
this.removeAnno = function (serNum) {
|
this.removeAnno = function (serNum) {
|
||||||
client.sendCommand("removeAnno",buffId,serNum);
|
client.sendCommand("removeAnno",buffId,serNum);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
//Tell Vim to save the buffer
|
||||||
* Tell Vim to save the buffer
|
|
||||||
* Vim fire a setModified event when done
|
|
||||||
* @function
|
|
||||||
**/
|
|
||||||
this.save = function () {
|
this.save = function () {
|
||||||
client.sendCommand("save", buffId);
|
client.sendCommand("save", buffId);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
//Tell Vim that the controler have saved the buffer
|
||||||
* Tell Vim the buffer has been saved
|
|
||||||
* @function
|
|
||||||
*/
|
|
||||||
this.saveDone = function () {
|
this.saveDone = function () {
|
||||||
client.sendCommand("saveDone", buffId);
|
client.sendCommand("saveDone", buffId);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Set the cursor position (and make the buffer the current buffer)
|
||||||
/**
|
|
||||||
* Set Vim cursor position and set the buffer as current buffer
|
|
||||||
* @function
|
|
||||||
* @param {number|number[]} off Position of the cursor
|
|
||||||
*/
|
|
||||||
this.setDot = function (off) {
|
this.setDot = function (off) {
|
||||||
client.sendCommand("setDot", buffId, Types.position(off));
|
client.sendCommand("setDot", buffId, Types.position(off));
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
//Set the filename of a buffer. It does not actually feed the buffer with file content, use insert for that
|
||||||
* Set the name of the buffer.
|
|
||||||
* It does not read the file content
|
|
||||||
* @function
|
|
||||||
* @param {string} pathName Name of the buffer
|
|
||||||
*/
|
|
||||||
this.setFullName = function (pathName) {
|
this.setFullName = function (pathName) {
|
||||||
client.sendCommand("setFullName", buffId, Types.string(pathName));
|
client.sendCommand("setFullName", buffId, Types.string(pathName));
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
//Set the modified flag
|
||||||
* Toggle the buffer modified mark
|
|
||||||
* @function
|
|
||||||
* @param {bool} modified Value of the modified flag
|
|
||||||
*/
|
|
||||||
this.setModified = function (modified) {
|
this.setModified = function (modified) {
|
||||||
client.sendCommand("setModified", buffId, Types.bool(modified));
|
client.sendCommand("setModified", buffId, Types.bool(modified));
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
//Set the modtime
|
||||||
* Update a buffer modification time
|
|
||||||
* @function
|
|
||||||
* @param {number} time Modification time to set
|
|
||||||
*/
|
|
||||||
this.setModtime = function (time) {
|
this.setModtime = function (time) {
|
||||||
client.sendCommand("setModtime", buffId, time);
|
client.sendCommand("setModtime", buffId, time);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
//Set the file as read-only
|
||||||
* Mark the buffer as readonly
|
|
||||||
* @function
|
|
||||||
*/
|
|
||||||
this.setReadOnly = function () {
|
this.setReadOnly = function () {
|
||||||
client.sendCommand("setReadOnly", buffId);
|
client.sendCommand("setReadOnly", buffId);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
//Set the title of the buffer. The title is just an internal name, it's not visible by the user
|
||||||
* Set the title of the function (used by controller only)
|
|
||||||
* @function
|
|
||||||
* @param {string} name Name of the buffer
|
|
||||||
*/
|
|
||||||
this.setTitle = function (name) {
|
this.setTitle = function (name) {
|
||||||
client.sendCommand("setTitle", buffId, Types.string(name));
|
client.sendCommand("setTitle", buffId, Types.string(name));
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
//Show the buffer
|
||||||
* Goto the buffer
|
|
||||||
* @function
|
|
||||||
*/
|
|
||||||
this.setVisible = function () {
|
this.setVisible = function () {
|
||||||
client.sendCommand("setVisible", buffId, Types.bool(true));
|
client.sendCommand("setVisible", buffId, Types.bool(true));
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
//Show a balloon containing the text around the cursor (GVim only)
|
||||||
* Display a balloon containing the text (GVim only)
|
|
||||||
* @function
|
|
||||||
* @param {string} text Text to show
|
|
||||||
*/
|
|
||||||
this.showBalloon = function (text) {
|
this.showBalloon = function (text) {
|
||||||
client.sendCommand("showBalloon", buffId,Types.string(text));
|
client.sendCommand("showBalloon", buffId,Types.string(text));
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
//Ungard the text. off is the starting position, len the length of the text
|
||||||
* Ungard the text
|
|
||||||
* @function
|
|
||||||
* @param {number|number[]} off Start position of the text to unguard
|
|
||||||
* @param {number} len Length of the text to unguard
|
|
||||||
*/
|
|
||||||
this.unguard = function (off, len) {
|
this.unguard = function (off, len) {
|
||||||
client.sendCommand("unguard", buffId, Types.position(off), len);
|
client.sendCommand("unguard", buffId, Types.position(off), len);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Edit the file in the current buffer
|
||||||
this.editFile = function (pathName){
|
this.editFile = function (pathName){
|
||||||
client.sendCommand("editFile", buffId, Types.string(pathName));
|
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 */
|
/* FUNCTIONS */
|
||||||
|
|
||||||
|
//Get cursor position. Callback function get the line, column and offset
|
||||||
this.getCursor = function (callback) {
|
this.getCursor = function (callback) {
|
||||||
client.callFunction("getCursor", buffId, callback);
|
client.callFunction("getCursor", buffId, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Get the length of current buffer.
|
||||||
this.getLength = function (callback) {
|
this.getLength = function (callback) {
|
||||||
client.callFunction("getLength", buffId, callback);
|
client.callFunction("getLength", buffId, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Get the line position of an anno
|
||||||
this.getAnno = function (serNum, callback) {
|
this.getAnno = function (serNum, callback) {
|
||||||
client.callFunction("getAnno", buffId, serNum, callback);
|
client.callFunction("getAnno", buffId, serNum, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Get the status of modified flag
|
||||||
this.getModified = function (callback) {
|
this.getModified = function (callback) {
|
||||||
client.callFunction("getModified", buffId, callback);
|
client.callFunction("getModified", buffId, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Return the content of the buffer as string
|
||||||
this.getText = function (callback) {
|
this.getText = function (callback) {
|
||||||
client.callFunction("getText", buffId, callback);
|
client.callFunction("getText", buffId, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Insert text at the position. Callback get nothing if everything went good, the error otherwise
|
||||||
this.insert = function (off, text, callback){
|
this.insert = function (off, text, callback){
|
||||||
client.callFunction("insert", buffId, Types.position(off), Types.string(text), callback);
|
client.callFunction("insert", buffId, Types.position(off), Types.string(text), callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Remove text at the position. Callback get nothing if everything went good, the error otherwise
|
||||||
this.remove = function (off, length, callback) {
|
this.remove = function (off, length, callback) {
|
||||||
client.callFunction("remove", buffId, Types.position(off), length, callback);
|
client.callFunction("remove", buffId, Types.position(off), length, callback);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports = Buffer;
|
||||||
|
|||||||
111
lib/controler.js
111
lib/controler.js
@@ -4,24 +4,13 @@ var Types = require("types");
|
|||||||
var Buffer = require("buffer");
|
var Buffer = require("buffer");
|
||||||
|
|
||||||
|
|
||||||
/**
|
//A stream Transform implementation returning full netbeans messages
|
||||||
* A Transform Stream implementation that output full VNB protocol messages
|
|
||||||
* @constructor
|
|
||||||
* @param {object} opts Options passed to the Transform constructor
|
|
||||||
*/
|
|
||||||
function MessageTransform(opts) {
|
function MessageTransform(opts) {
|
||||||
"use strict";
|
"use strict";
|
||||||
Transform.call(this,opts);
|
Transform.call(this,opts);
|
||||||
|
|
||||||
var buffer;
|
var buffer;
|
||||||
|
|
||||||
/**
|
|
||||||
* Transform stream Write implementation
|
|
||||||
* @function
|
|
||||||
* @param {string} data Upstream data already converted as string
|
|
||||||
* @param {string} encoding String encoding (should be utf8, but should be checked upward)
|
|
||||||
* @param {function} callback Downstream Stream receiving only full VNB messages
|
|
||||||
**/
|
|
||||||
this._transform = function(data, encoding, callback) {
|
this._transform = function(data, encoding, callback) {
|
||||||
var endpos = data.indexOf("\n");
|
var endpos = data.indexOf("\n");
|
||||||
|
|
||||||
@@ -45,31 +34,14 @@ function MessageTransform(opts) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Flush still data. Remaining data is lost since it can only be an incomplete message
|
|
||||||
* @function
|
|
||||||
* @param {function} callback Callback to call when data has been flushed
|
|
||||||
**/
|
|
||||||
this._flush = function (callback) {
|
this._flush = function (callback) {
|
||||||
buffer = undefined;
|
buffer = undefined;
|
||||||
callback();
|
callback();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
//Main netbeans object. Needs the socket of the incomming connexion and an authentication callback
|
||||||
* Authentication callback
|
//This callback just get the password sent by Vim. It must return true to allow connexion
|
||||||
* @callback authenticationCallback
|
|
||||||
* @param {string} password Password given by the authenticating client
|
|
||||||
* @return {bool} Result of the authentication
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Client implementation for vim netbeans protocol (communication from vim to the netbeans server)
|
|
||||||
* @constructor
|
|
||||||
* @param {Socket} socket Incomming stream
|
|
||||||
* @param {authenticationCallback} authentication Callback function called when the AUTH message is received
|
|
||||||
*/
|
|
||||||
function Controler(socket, authentication) {
|
function Controler(socket, authentication) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
@@ -80,14 +52,14 @@ function Controler(socket, authentication) {
|
|||||||
var currentSeqno = 0;
|
var currentSeqno = 0;
|
||||||
var connected = false;
|
var connected = false;
|
||||||
|
|
||||||
//TODO check if this is needed
|
/* TODO check if this is needed */
|
||||||
socket.setEncoding("utf8");
|
socket.setEncoding("utf8");
|
||||||
|
|
||||||
var messageTransform = new MessageTransform();
|
var messageTransform = new MessageTransform();
|
||||||
|
|
||||||
messageTransform.on("data",function (message) {
|
messageTransform.on("data",function (message) {
|
||||||
|
|
||||||
//The first message must be an authentication one
|
/* The first message must be an authentication one */
|
||||||
if (message.startsWith("AUTH ") && authentication(message.substring(message.indexOf(" ") + 1))) {
|
if (message.startsWith("AUTH ") && authentication(message.substring(message.indexOf(" ") + 1))) {
|
||||||
connected = true;
|
connected = true;
|
||||||
|
|
||||||
@@ -95,10 +67,10 @@ function Controler(socket, authentication) {
|
|||||||
messageTransform.on("data", function(message) {
|
messageTransform.on("data", function(message) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var iName = 0; //Index of the name separator in case of an Event
|
var iName = 0; /*Index of the name separator in case of an Event */
|
||||||
var iSeqno = 0; //Index of the seqno separator in case of an Event
|
var iSeqno = 0; /*Index of the seqno separator in case of an Event */
|
||||||
|
|
||||||
//Header of the message
|
/* Header of the message */
|
||||||
for (var i = 0 ; i < message.length && message[i] !== " "; ++i) {
|
for (var i = 0 ; i < message.length && message[i] !== " "; ++i) {
|
||||||
if (message[i] === ":") {
|
if (message[i] === ":") {
|
||||||
iName = i;
|
iName = i;
|
||||||
@@ -236,13 +208,8 @@ function Controler(socket, authentication) {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
//Send a command message.
|
||||||
* Send a command message
|
//Needs the name of the buffer, the buffer id and the parameters of the command
|
||||||
* @function sendCommand
|
|
||||||
* @param {string} name Name of the command
|
|
||||||
* @param {number} buffer Name of the buffer
|
|
||||||
* @param {...string} arguments Parameters of the command
|
|
||||||
*/
|
|
||||||
this.sendCommand = function(name, buffer) {
|
this.sendCommand = function(name, buffer) {
|
||||||
let seqno = currentSeqno;
|
let seqno = currentSeqno;
|
||||||
currentSeqno += 1;
|
currentSeqno += 1;
|
||||||
@@ -258,23 +225,14 @@ function Controler(socket, authentication) {
|
|||||||
socket.write(data);
|
socket.write(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
//Call a function.
|
||||||
* Send a function message
|
//Needs the name of the function, the bufferid, the parametres of the command and the callback to retreive the reply
|
||||||
* @function callFunction
|
|
||||||
* @param {string} name Name of the function
|
|
||||||
* @param {number} buffer ID of the buffer
|
|
||||||
* @param {...string} arguments Parameters of the function. Use the string, bool, color and position function
|
|
||||||
* of the method to convert javascript types to string
|
|
||||||
* @param {function} callback Callback function called with reply value
|
|
||||||
* */
|
|
||||||
this.callFunction = function(name, buffer) {
|
this.callFunction = function(name, buffer) {
|
||||||
let seqno = currentSeqno;
|
let seqno = currentSeqno;
|
||||||
currentSeqno += 1;
|
currentSeqno += 1;
|
||||||
|
|
||||||
var lastArg = arguments.length - 1;
|
var lastArg = arguments.length - 1;
|
||||||
|
|
||||||
//If the function is called with a callback (wich should always be the case)
|
|
||||||
//add the calback to the map so it's fired when the reply is received
|
|
||||||
if (typeof(arguments[lastArg]) === "function") {
|
if (typeof(arguments[lastArg]) === "function") {
|
||||||
callbacks[currentSeqno] = arguments[lastArg];
|
callbacks[currentSeqno] = arguments[lastArg];
|
||||||
lastArg -= 1;
|
lastArg -= 1;
|
||||||
@@ -297,12 +255,8 @@ function Controler(socket, authentication) {
|
|||||||
|
|
||||||
InternalClient.prototype = EventEmitter;
|
InternalClient.prototype = EventEmitter;
|
||||||
|
|
||||||
/**
|
//Wrapper around the controler exposing functions and commands as methods
|
||||||
* Connexion with a vim client
|
//Needs the incomming connexon socket and an authentication callback that get the password and return true to allow connexion
|
||||||
* @constructor
|
|
||||||
* @param {Socket} socket Connexion's socket
|
|
||||||
* @param {authenticationCallback} authentication Callback used to authenticate the client
|
|
||||||
*/
|
|
||||||
function Client(socket, authentication) {
|
function Client(socket, authentication) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
@@ -311,26 +265,22 @@ function Client(socket, authentication) {
|
|||||||
|
|
||||||
/* GLOBAL COMMANDS */
|
/* GLOBAL COMMANDS */
|
||||||
|
|
||||||
this.startAtomic = function () {
|
//Bring Vim to the front (GVim only)
|
||||||
client.sendCommand("startAtomic", 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.endAtomic = function() {
|
|
||||||
client.sendCommand("endAtmoic", 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.raise = function () {
|
this.raise = function () {
|
||||||
client.sendCommand("raise", 0);
|
client.sendCommand("raise", 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Set an exiting delay, allowing the controler to handle things
|
||||||
this.setExitDelay = function (seconds) {
|
this.setExitDelay = function (seconds) {
|
||||||
client.sendCommand("setExitDelay", 0, seconds);
|
client.sendCommand("setExitDelay", 0, seconds);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Set key binding. Absolutely not documented feature...
|
||||||
this.specialKeys = function (keys) {
|
this.specialKeys = function (keys) {
|
||||||
client.sendCommand("specialKeys", 0,Types.string(keys)); //TODO : Wild guess, no documentation about this one
|
client.sendCommand("specialKeys", 0,Types.string(keys));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Create a new buffer. Return the buffer created
|
||||||
this.create = function() {
|
this.create = function() {
|
||||||
var buffer = new Buffer(client, buffId);
|
var buffer = new Buffer(client, buffId);
|
||||||
buffId += 1;
|
buffId += 1;
|
||||||
@@ -338,12 +288,8 @@ function Client(socket, authentication) {
|
|||||||
return buffer;
|
return buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
//Associate already opened buffer on Vim to a controler owned buffer
|
||||||
* putBufferNumber
|
//Return the newly created buffer
|
||||||
* @function
|
|
||||||
* @param {string} pathname Path of the file whose buffer is identified
|
|
||||||
* @return {undefined}
|
|
||||||
*/
|
|
||||||
this.putBufferNumber = function (pathname) {
|
this.putBufferNumber = function (pathname) {
|
||||||
var buffer = new Buffer(client, buffId);
|
var buffer = new Buffer(client, buffId);
|
||||||
buffId += 1;
|
buffId += 1;
|
||||||
@@ -351,11 +297,8 @@ function Client(socket, authentication) {
|
|||||||
return buffer;
|
return buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
//Associate already opened buffer on Vim to a controler owned buffer and bring it to front
|
||||||
* Set a buffer number to a file opened by Vim and sets its buffer as current buffer
|
//Return the newly created buffer
|
||||||
* @function
|
|
||||||
* @param {string} pathname Path of the file
|
|
||||||
*/
|
|
||||||
this.setBufferNumber = function (pathname) {
|
this.setBufferNumber = function (pathname) {
|
||||||
var buffer = new Buffer(client, buffId);
|
var buffer = new Buffer(client, buffId);
|
||||||
buffId += 1;
|
buffId += 1;
|
||||||
@@ -365,16 +308,12 @@ function Client(socket, authentication) {
|
|||||||
|
|
||||||
/* GLOBAL FUNCTIONS */
|
/* GLOBAL FUNCTIONS */
|
||||||
|
|
||||||
/**
|
//Ask Vim to save and exit
|
||||||
* saveAndExit
|
|
||||||
*
|
|
||||||
* @param callback
|
|
||||||
* @return {undefined}
|
|
||||||
*/
|
|
||||||
this.saveAndExit = function (callback) {
|
this.saveAndExit = function (callback) {
|
||||||
client.callFunction("saveAndExit", 0, callback);
|
client.callFunction("saveAndExit", 0, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Get the numbr of modified buffers
|
||||||
this.getModified = function (callback) {
|
this.getModified = function (callback) {
|
||||||
client.callFunction("getModified", 0, callback);
|
client.callFunction("getModified", 0, callback);
|
||||||
};
|
};
|
||||||
|
|||||||
31
lib/types.js
31
lib/types.js
@@ -1,34 +1,20 @@
|
|||||||
/**
|
//Return the color in netbeans format
|
||||||
* Convert a color to message string
|
//A color can be a number (RRGGBB), a name or nothing
|
||||||
* @function color
|
|
||||||
* @param {string|number} value Color to convert
|
|
||||||
* @return {string} Converted color
|
|
||||||
*/
|
|
||||||
function color (value) {
|
function color (value) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
return value ? value : "none";
|
return value ? value : "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
//Return the boolean value in ntebeans format
|
||||||
* Convert a boolean value to message string
|
|
||||||
* @function bool
|
|
||||||
* @param {bool} value Boolean to convert
|
|
||||||
* @return {string} Converted boolean
|
|
||||||
*/
|
|
||||||
function bool (value) {
|
function bool (value) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
return value ? "T" : "F";
|
return value ? "T" : "F";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
//Return position in netbeans format.
|
||||||
* Convert a position to message string
|
//A position can be an array containing 1 based line and 0 based column or a 0 based offset
|
||||||
* @function position
|
|
||||||
* @param {number} line Line of position starting with 1
|
|
||||||
* @param {number} col Column of position starting with 0
|
|
||||||
* @return {string} Converted position
|
|
||||||
*/
|
|
||||||
function position (pos) {
|
function position (pos) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
@@ -40,12 +26,7 @@ function position (pos) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
//Return a netbeans formated string
|
||||||
* Convert a string to message string
|
|
||||||
* @function string
|
|
||||||
* @param {string} value String to convert
|
|
||||||
* @return {string} Converted string
|
|
||||||
*/
|
|
||||||
function string (value) {
|
function string (value) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user