Skip to content

Commit

Permalink
Split Widgets class to org.jline.widget package
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed Jun 1, 2020
1 parent b3428b4 commit 4c24ce1
Show file tree
Hide file tree
Showing 15 changed files with 1,551 additions and 1,512 deletions.
70 changes: 70 additions & 0 deletions console/src/main/java/org/jline/console/CmdLine.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2002-2020, the original author or authors.
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
*
* https://opensource.org/licenses/BSD-3-Clause
*/
package org.jline.console;

import java.util.ArrayList;
import java.util.List;

public class CmdLine {
public enum DescriptionType {
/**
* Cursor is at the end of line. The args[0] is completed, the line does not have unclosed opening parenthesis
* and does not end to the closing parenthesis.
*/
COMMAND,
/**
* The part of the line from beginning till cursor has unclosed opening parenthesis.
*/
METHOD,
/**
* The part of the line from beginning till cursor ends to the closing parenthesis.
*/
SYNTAX};
private String line;
private String head;
private String tail;
private List<String> args;
private DescriptionType descType;

/**
* CmdLine class constructor.
* @param line Command line
* @param head Command line till cursor, method parameters and opening parenthesis before the cursor are removed.
* @param tail Command line after cursor, method parameters and closing parenthesis after the cursor are removed.
* @param args Parsed command line arguments.
* @param descType Request COMMAND, METHOD or SYNTAX description
*/
public CmdLine(String line, String head, String tail, List<String> args, DescriptionType descType) {
this.line = line;
this.head = head;
this.tail = tail;
this.args = new ArrayList<>(args);
this.descType = descType;
}

public String getLine() {
return line;
}

public String getHead() {
return head;
}

public String getTail() {
return tail;
}

public List<String> getArgs() {
return args;
}

public DescriptionType getDescriptionType() {
return descType;
}
}
4 changes: 2 additions & 2 deletions console/src/main/java/org/jline/console/SystemRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.Map;

import org.jline.builtins.ConsoleOptionGetter;
import org.jline.console.Widgets;
import org.jline.console.CmdLine;
import org.jline.reader.Completer;
import org.jline.terminal.Terminal;

Expand Down Expand Up @@ -62,7 +62,7 @@ public interface SystemRegistry extends CommandRegistry, ConsoleOptionGetter {
* @return command description for JLine TailTipWidgets to be displayed
* in the terminal status bar.
*/
CmdDesc commandDescription(Widgets.CmdLine line);
CmdDesc commandDescription(CmdLine line);

/**
* Execute a command, script or evaluate scriptEngine statement
Expand Down
Loading

0 comments on commit 4c24ce1

Please sign in to comment.