-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #19 Not working with Scala 2.12 processes
- Loading branch information
1 parent
4fcba1e
commit 703c590
Showing
16 changed files
with
149 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
sbt.version=0.13.12 | ||
sbt.version=1.2.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// Run sbt eclipse to create Eclipse project file | ||
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0") | ||
// Run "sbt eclipse" to create Eclipse project file | ||
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package scalive.client; | ||
|
||
import scala.tools.jline_embedded.console.ConsoleReader; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.io.OutputStream; | ||
import java.net.Socket; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.List; | ||
|
||
/** | ||
* Input: cursor buffer | ||
* | ||
* Output: cursor candidate1 candidate2 candidate3... | ||
*/ | ||
class ClientCompleter { | ||
static void setup(Socket socket, ConsoleReader reader) throws Exception { | ||
final InputStream in = socket.getInputStream(); | ||
final OutputStream out = socket.getOutputStream(); | ||
|
||
final BufferedReader b = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8)); | ||
|
||
reader.addCompleter((String buffer, int cursor, List<CharSequence> candidates) -> { | ||
try { | ||
String request = String.format("%d %s\n", cursor, buffer); | ||
out.write(request.getBytes(StandardCharsets.UTF_8)); | ||
out.flush(); | ||
|
||
String response = b.readLine(); | ||
|
||
// socket closed; the client should exit | ||
if (response == null) return -1; | ||
|
||
String[] args = response.split(" "); | ||
|
||
int c = Integer.parseInt(args[0]); | ||
|
||
for (int i = 1; i < args.length; i++) { | ||
String candidate = args[i]; | ||
candidates.add(candidate); | ||
} | ||
|
||
return c; | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
}); | ||
} | ||
} |
Oops, something went wrong.