Skip to content

Commit

Permalink
upgrade to jline 2.10, jansi 1.10 and jna 3.5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
graemerocher committed May 13, 2013
1 parent 28fab23 commit 83197dd
Show file tree
Hide file tree
Showing 13 changed files with 131 additions and 163 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ ext {
gradleGroovyVersion = groovyVersion
gradleGroovyVersion = "1.8.2"
ivyVersion = "2.3.0"
jansiVersion = "1.2.1"
jlineVersion = "1.0"
jnaVersion = "3.2.3"
jansiVersion = "1.10"
jlineVersion = "2.10"
jnaVersion = "3.5.2"
slf4jVersion = "1.7.4"

spockVersion = '0.7-groovy-2.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*/
package grails.build.interactive.completors

import jline.FileNameCompletor
import jline.console.completer.FileNameCompleter


/**
* JLine Completor that does file path matching like FileNameCompletor,
Expand All @@ -25,7 +26,7 @@ import jline.FileNameCompletor
* @author Peter Ledbrook
* @since 2.0
*/
class EscapingFileNameCompletor extends FileNameCompletor {
class EscapingFileNameCompletor extends FileNameCompleter {
/**
* <p>Gets FileNameCompletor to create a list of candidates and then
* inserts '\' before any whitespace characters in each of the candidates.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@
*/
package grails.build.interactive.completors

import jline.ArgumentCompletor
import jline.SimpleCompletor

import jline.console.completer.ArgumentCompleter
import org.codehaus.groovy.grails.cli.interactive.InteractiveMode

/**
* @author Graeme Rocher
* @since 2.0
*/
class Open extends ArgumentCompletor {
class Open extends ArgumentCompleter {

Open() {
super([ new SimpleCompletor("open"), new SimpleOrFileNameCompletor(InteractiveMode.FIXED_OPEN_OPTIONS) ])
super([ new StringsCompleter("open"), new SimpleOrFileNameCompletor(InteractiveMode.FIXED_OPEN_OPTIONS) ])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package grails.build.interactive.completors

import jline.Completor
import jline.console.completer.Completer

import java.util.regex.Pattern

Expand All @@ -26,7 +26,7 @@ import java.util.regex.Pattern
* @author Peter Ledbrook
* @since 2.0
*/
class RegexCompletor implements Completor {
class RegexCompletor implements Completer {
Pattern pattern

RegexCompletor(String pattern) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
*/
package grails.build.interactive.completors

import jline.Completor
import jline.SimpleCompletor
import jline.console.completer.Completer
import jline.console.completer.StringsCompleter


/**
* JLine Completor that mixes a fixed set of options with file path matches.
Expand All @@ -25,7 +26,7 @@ import jline.SimpleCompletor
* @author Peter Ledbrook
* @since 2.0
*/
class SimpleOrFileNameCompletor implements Completor {
class SimpleOrFileNameCompletor implements Completer {
private simpleCompletor
private fileNameCompletor

Expand All @@ -34,7 +35,7 @@ class SimpleOrFileNameCompletor implements Completor {
}

SimpleOrFileNameCompletor(String[] fixedOptions) {
simpleCompletor = new SimpleCompletor(fixedOptions)
simpleCompletor = new StringsCompleter(fixedOptions)
fileNameCompletor = new EscapingFileNameCompletor()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/* Copyright 2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package grails.build.interactive.completors;

import jline.console.completer.Completer;

import java.util.*;

import static jline.internal.Preconditions.checkNotNull;

/**
* @author Graeme Rocher
*/
public class StringsCompleter
implements Completer
{
private SortedSet<String> strings = new TreeSet<String>();

public StringsCompleter() {
// empty
}

public StringsCompleter(final Collection<String> strings) {
checkNotNull(strings);
getStrings().addAll(strings);
}

public StringsCompleter(final String... strings) {
this(Arrays.asList(strings));
}

public SortedSet<String> getStrings() {
return strings;
}


public void setStrings(SortedSet<String> strings) {
this.strings = strings;
}

public int complete(final String buffer, final int cursor, final List<CharSequence> candidates) {
// buffer could be null
checkNotNull(candidates);

if (buffer == null) {
candidates.addAll(getStrings());
}
else {
for (String match : getStrings().tailSet(buffer)) {
if (!match.startsWith(buffer)) {
break;
}

candidates.add(match);
}
}

if (candidates.size() == 1) {
candidates.set(0, candidates.get(0) + " ");
}

return candidates.isEmpty() ? -1 : 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@
import java.util.List;
import java.util.Stack;

import jline.ConsoleReader;
import jline.History;
import jline.Terminal;

import jline.TerminalFactory;
import jline.console.ConsoleReader;
import jline.console.history.FileHistory;
import jline.console.history.History;
import org.apache.tools.ant.BuildException;
import org.codehaus.groovy.grails.cli.ScriptExitException;
import org.codehaus.groovy.grails.cli.interactive.CandidateListCompletionHandler;
Expand Down Expand Up @@ -178,7 +180,9 @@ private boolean readPropOrTrue(String prop) {
}

protected ConsoleReader createConsoleReader() throws IOException {
return new ConsoleReader(System.in, new OutputStreamWriter(out));
ConsoleReader consoleReader = new ConsoleReader(System.in, out);
consoleReader.setExpandEvents(false);
return consoleReader;
}

/**
Expand All @@ -187,18 +191,7 @@ protected ConsoleReader createConsoleReader() throws IOException {
* is controlled by the jline.terminal system property.
*/
protected Terminal createTerminal() {
if (isWindows()) {
try {
return PatchedJLineWindowsTerminal.setupTerminal(reader);
}
catch (Exception ex) {
error(ex);
}
}
else {
terminal = Terminal.setupTerminal();
}
return terminal;
return terminal = TerminalFactory.create();
}

/**
Expand All @@ -207,7 +200,7 @@ protected Terminal createTerminal() {
*/
protected History prepareHistory() throws IOException {
File file = new File(System.getProperty("user.home"), HISTORYFILE);
return file.canWrite() ? new History(file) : null;
return file.canWrite() ? new FileHistory(file) : null;
}

/**
Expand Down Expand Up @@ -517,7 +510,7 @@ private void logSimpleError(String msg) {
}

public boolean isAnsiEnabled() {
return Ansi.isEnabled() && (terminal != null && terminal.isANSISupported()) && ansiEnabled;
return Ansi.isEnabled() && (terminal != null && terminal.isAnsiSupported()) && ansiEnabled;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import java.io.IOException;
import java.io.OutputStream;

import jline.ConsoleReader;
import jline.Terminal;
import jline.UnsupportedTerminal;
import jline.console.ConsoleReader;

/**
* This class is meant to keep changes made in support of Eclipse separate from
Expand Down

This file was deleted.

Loading

0 comments on commit 83197dd

Please sign in to comment.