Hi,

I'm trying to get vim to communicate efficiently and with low latency with java code. The current setup / idea is to have a TCP socket server written in java receive messages from vim and query vim in some instances. Below is what I've accomplished thus far. Any advice would be much appreciated. Eventual goal: have vim and gvim produce speech and Braille output via the cross platform phonemic java speech API (http://phonemic.sf.net). Phonemic in turn interface with the various accessibility technologies on win32, linux and osx.

I would like to receive notifications of as many vim events as possible such as cursor movement, key presses, line changes etc, and the lower the latency the better, hence my investigations into getting vim to output directly from inside the main editor loop.

NETBEANS PROTOCOL:
I've made some experiments with the netbeans protocol interfacing vim provides when started with the -nb flag or the :nbstart command inside a running instance.

On win32 at least the -nb command line option with the format -nb=connectionfile doesn't seem to work -- doesn't seem to read the connectionfile which contains host, port and auth details. Anyone else could test this please (see simple Java socket server attached).

The :nbstart command from inside a running vim instance was more successful and started sending events through to the java TCP socket server in the netbeans vim interfacing protocol version 2.5 as described in :he netbeans (vim docs). Main problem here is that the events are far to few -- need notifications of cursor movement, text change, error and other vim messages and possibly more events.

Looking at the netbeans.c file in the source I got new respect for C programmers! Especially when they make code cross platform. Bottom line; it's above my head to extend the netbeans protocol or implement something similar that's more verbose in the C code on the vim side.

Another option would be to have vim script that instruct vim what to send via netbeans protocl, and have the script functions fire on selected vim events? Would this work and would it be low enough latency and low enough extra overhead for vim?


As always, any and all ideas warmly welcome.

Attached java TCP socket server runs on port 8080 and simply System.out.println everything sent to it.

Regards,
K




--
Kerneels Roos
Cell: +27 (0)79 696 6038
Skype: cornelis.roos

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
/*
 * NBLogger
 *
 * Simple server for logging all incoming data to stdout.
 *
 * Author: Kerneels Roos ([email protected])
 */
//package nblogger;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;

import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;

public class NBLogger {

  /** the channel we can get messages from */
  private BufferedReader in;

  /** the channel we can write messages to */
  private PrintWriter out;

  private int port;

  private ServerSocket socket;
  private Socket clientSocket;

  private boolean serverRunning;

  public NBLogger () {
    port = 8080;
  }


  public void run () {
    try {
      // start server
      System.out.println("Starting Server..");
      socket = new ServerSocket(port);
      System.out.println("Server Started..");

      // accept client
      System.out.println("Waiting for connection...");
      clientSocket = socket.accept();
      in = new BufferedReader(new InputStreamReader(clientSocket
          .getInputStream()));
      System.out.println("Connected.");

      serverRunning = true;
      System.out.println("SERVER RUNNING:");

      // handle Events
      String line;

      try {
        while ((line = in.readLine()) != null) {
          System.out.println("RCVD:");
          System.out.println(line);
        }
      } catch (SocketException se) {
        close();
        System.out.println("Socket Exception");
      }
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }

  public static void main (String [] args) {
    NBLogger nbl = new NBLogger();
    nbl.run();
    //exit();
  }

  public boolean close() throws IOException {
    if (clientSocket != null){
      clientSocket.close();
    }
    if (socket != null){
      socket.close();
    }
    serverRunning = false;
    return true;
  }

}

Raspunde prin e-mail lui