当前位置: 首页>>代码示例>>Java>>正文


Java TerminalBuilder类代码示例

本文整理汇总了Java中org.jline.terminal.TerminalBuilder的典型用法代码示例。如果您正苦于以下问题:Java TerminalBuilder类的具体用法?Java TerminalBuilder怎么用?Java TerminalBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TerminalBuilder类属于org.jline.terminal包,在下文中一共展示了TerminalBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
private void execute(Ssh.ExecuteParams params) {
    log.info("Execute received {}", params);
    try {
        Terminal terminal = TerminalBuilder.builder()
                                           .streams(params.getIn(), params.getOut())
                                           .build();
        String[] args = params.getCommand().split(" ");
        getContext().getCommandManager().runCommand(args[0],
                                                    new CommandContext(getContext(), terminal),
                                                    args);
        terminal.flush();
    }
    catch (IOException e) {
        log.error("Unable to execute command", e);
    }
}
 
开发者ID:jeeshell,项目名称:je2sh,代码行数:17,代码来源:SshPlugin.java

示例2: GraphflowCli

import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
/**
 * Constructs a CLI client that connects to the Graphflow server at the provided {@code
 * host:port}.
 *
 * @param grpcHost The gRPC server hostname.
 * @param grpcPort The gRPC server port.
 */
GraphflowCli(String grpcHost, int grpcPort) throws IOException {
    super(grpcHost, grpcPort);
    Logger.getLogger("org.jline").setLevel(Level.OFF);
    File historyFile = new File(HISTORY_FLE);
    LineReaderBuilder lineReaderBuilder = LineReaderBuilder.builder().terminal(
        TerminalBuilder.builder().build());
    try {
        if (!historyFile.exists()) {
            historyFile.createNewFile();
        }
        if (historyFile.canWrite()) {
            isHistoryEnabled = true;
            lineReaderBuilder = lineReaderBuilder.variable(LineReader.HISTORY_FILE,
                historyFile).history(new DefaultHistory());
        }
    } catch (IOException e) {
        // Ignore
    }
    lineReader = lineReaderBuilder.build();
}
 
开发者ID:graphflow,项目名称:graphflow,代码行数:28,代码来源:GraphflowCli.java

示例3: open

import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
@Override
public void open() {
    parser = createParser();

    try {
        terminal = (terminalBuilder != null ? terminalBuilder : TerminalBuilder.builder()).build();
    } catch (IOException e) {
        throw SpongeUtils.wrapException(e);
    }

    LineReaderBuilder lineReaderBuilder = LineReaderBuilder.builder().appName(VersionInfo.PRODUCT).terminal(terminal).parser(parser);

    if (completer != null) {
        lineReaderBuilder.completer(completer);
    }

    reader = lineReaderBuilder.build();
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:19,代码来源:JLineInteractiveModeConsole.java

示例4: lineReader

import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
private static LineReader lineReader(Parser parser) {
    try {
        return LineReaderBuilder.builder().terminal(TerminalBuilder.terminal()).parser(parser).build();
    } catch (IOException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}
 
开发者ID:fbiville,项目名称:hands-on-neo4j-devoxx-fr-2017,代码行数:8,代码来源:Neo4jRepl.java

示例5: Shell

import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
public Shell() throws IOException {
    commandPrefix = ":";
    prompt = "> ";
    Terminal terminal = TerminalBuilder.builder()
        .build();
    reader = LineReaderBuilder.builder()
        .terminal(terminal)
        .build();
    logger.trace("create interpreter");
    interpreter = new NaiveInterpreter();
    // need to have a global ast builder, otherwise the symbol table is lost
    logger.trace("create ast builder");
    astBuilder = new ReikaAstBuilder(false);
}
 
开发者ID:xephonhq,项目名称:tsdb-proxy-java,代码行数:15,代码来源:Shell.java

示例6: provideTerminal

import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
@Provides
@Singleton
static Terminal provideTerminal() {
  try {
    return TerminalBuilder.terminal();
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:10,代码来源:TerminalModule.java

示例7: processInputs

import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
public void processInputs(InputStream is, OutputStream os, String terminalType) {
    try (Terminal terminal = TerminalBuilder.builder().system(false).type(terminalType).streams(is, os).build()) {
        LineReader reader = LineReaderBuilder.builder().terminal(terminal).completer(completer).build();
        createDefaultSessionContext(reader, terminal);
        ConsoleIO.writeOutput(SUPPORTED_COMMANDS_MESSAGE);
        processUserInput(reader);
    } catch (IOException ex) {
        log.error("Error building terminal instance", ex);
    }
}
 
开发者ID:anand1st,项目名称:sshd-shell-spring-boot,代码行数:11,代码来源:TerminalProcessor.java

示例8: newTerminal

import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
/**
 * Creates a new terminal.
 *
 * @return new terminal
 */
static Terminal newTerminal() {
    try {
        return TerminalBuilder.builder()
                              .dumb(true)
                              .build();
    } catch (IOException e) {
        throw illegalStateWithCauseOf(e);
    }
}
 
开发者ID:SpineEventEngine,项目名称:todo-list,代码行数:15,代码来源:Terminals.java

示例9: main

import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
public static void main(String[] args) {
	try (Terminal term = TerminalBuilder.builder().type("unix").name("Java FileSystem").build()) {
		System.out.println("Welcome to the Java Cloud FileSystem Provider CLI");
		new Cli(term).run();
		System.out.println("Goodbye!");
	} catch (IOException e) {
		throw new RuntimeException("Cannot build terminal", e);
	}
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:10,代码来源:Cli.java

示例10: JLineTerminal

import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
public JLineTerminal(OutputFormat outputFormat, KsqlRestClient restClient) {
  super(outputFormat, restClient);

  try {
    terminal = TerminalBuilder.builder().system(true).build();
  } catch (IOException e) {
    throw new RuntimeException("JLineTerminal failed to start!", e);
  }
  // Ignore ^C when not reading a line
  terminal.handle(org.jline.terminal.Terminal.Signal.INT, org.jline.terminal.Terminal.SignalHandler.SIG_IGN);
}
 
开发者ID:confluentinc,项目名称:ksql,代码行数:12,代码来源:JLineTerminal.java

示例11: InternalJlineManager

import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
private InternalJlineManager() throws Exception
{
    Logger.getLogger( "org.jline" ).setLevel( Level.ALL );
    terminal = TerminalBuilder.builder().dumb( true ).build();
    lineReader = LineReaderBuilder.builder()
            .terminal( terminal ).appName( "Kvantum" ).build();
}
 
开发者ID:Sauilitired,项目名称:Kvantum,代码行数:8,代码来源:InternalJlineManager.java

示例12: setTerminalBuilder

import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
public void setTerminalBuilder(TerminalBuilder terminalBuilder) {
    this.terminalBuilder = terminalBuilder;
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:4,代码来源:JLineInteractiveModeConsole.java

示例13: getTerminalBuilder

import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
public TerminalBuilder getTerminalBuilder() {
    return terminalBuilder;
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:4,代码来源:JLineInteractiveModeConsole.java

示例14: testInteractive

import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
@Test
public void testInteractive() throws Exception {
    PipedInputStream in = new PipedInputStream();

    try (PipedOutputStream pipedOutputStream = new PipedOutputStream(in)) {
        outIn = pipedOutputStream;
        ByteArrayOutputStream out = new ByteArrayOutputStream();

        engine = StandaloneEngine.builder().commandLineArgs("-k", "examples/standalone/interactive.py", "-i")
                .interactiveModeConsoleSupplier(() -> {
                    JLineInteractiveModeConsole console = new JLineInteractiveModeConsole();
                    console.setTerminalBuilder(TerminalBuilder.builder().streams(in, out));

                    return console;
                }).build();

        SpongeUtils.executeConcurrentlyOnce(engine, () -> {
            engine.startup();
            engine.getInteractiveMode().loop();
        });

        await().atMost(10, TimeUnit.SECONDS)
                .until(() -> engine != null && engine.isRunning() && engine.getInteractiveMode().isRunning());

        // Print the message.
        write("print 'Starting interactive mode tests.'");

        // Send the alarm.
        write("EPS.event(\"alarm\").send()");
        await().atMost(10, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable(Number.class, "alarms").intValue() >= 1);

        // Create trigger and send event.
        writeMulti("class T(Trigger):\\");
        writeMulti("    def onConfigure(self):\\");
        writeMulti("        self.event = \"notification\"\\");
        writeMulti("    def onRun(self, event):\\");
        writeMulti("        EPS.getVariable(\"notifications\").incrementAndGet()\\");
        writeMulti("        print \"Received the notification!\"");
        write("");
        write("EPS.enable(T)");
        write("EPS.event(\"notification\").send()");
        await().atMost(10, TimeUnit.SECONDS)
                .until(() -> engine.getOperations().getVariable(Number.class, "notifications").intValue() >= 1);

        assertFalse(engine.isError());
    } finally {
        if (engine != null) {
            engine.shutdown();
        }
    }
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:52,代码来源:InteractiveModeStandaloneTest.java

示例15: Debugger

import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
public Debugger() throws IOException {
    this.ticksStats = new TicksStats();
    this.traceBuffer = new TraceBuffer(64);
    this.log = new ArrayList<>();
    this.levels = new EnumMap<>(Component.class);
    for (Component c : Component.values()) {
        levels.put(c, Level.Info);
    }
    levels.put(Component.Memory, Level.Warning);
    state = State.Running;
    this.terminal = TerminalBuilder.terminal();
    this.views = new ArrayList<>();
    this.views.add(new Overview(this));
    this.views.add(new CPUView(this));
    breakpoints = new Breakpoints(this);
    this.views.add(breakpoints);
    this.views.add(new VIPView(this));
    this.views.add(new VSUView(this));
    this.views.add(new MemoryView(this));
    this.views.add(new OthersView(this));
    this.views.add(new Logs(log, terminal, levels));
    this.size = new Size();
    size.copy(terminal.getSize());
    if (size.getRows() == 0) {
        throw new RuntimeException("0-row term");
    }
    if (size.getColumns() == 0) {
        Integer columns = terminal.getNumericCapability(InfoCmp.Capability.columns);
        if (columns != null) {
            size.setColumns(columns);
        }
    }
    this.display = new Display(terminal, true);
    originalAttributes = terminal.enterRawMode();
    prevWinchHandler = terminal.handle(Terminal.Signal.WINCH, this::resize);
    terminal.puts(InfoCmp.Capability.enter_ca_mode);
    terminal.puts(InfoCmp.Capability.keypad_xmit);
    display.clear();
    display.reset();
    display.resize(size.getRows(), size.getColumns());
    bindingReader = new BindingReader(terminal.reader());
    keyMap = initKeyMap();
    inputThread = new InputThread();
    inputThread.start();
}
 
开发者ID:gilles-duboscq,项目名称:jvb,代码行数:46,代码来源:Debugger.java


注:本文中的org.jline.terminal.TerminalBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。