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


Java ConsoleReader.setExpandEvents方法代码示例

本文整理汇总了Java中jline.console.ConsoleReader.setExpandEvents方法的典型用法代码示例。如果您正苦于以下问题:Java ConsoleReader.setExpandEvents方法的具体用法?Java ConsoleReader.setExpandEvents怎么用?Java ConsoleReader.setExpandEvents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jline.console.ConsoleReader的用法示例。


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

示例1: initConsole

import jline.console.ConsoleReader; //导入方法依赖的package包/类
public static ConsoleReader initConsole() throws IOException, InvalidColourException{
	
	Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
	    public void run() {
	    	System.out.print("\033[0m"); // On exit turn off all formatting
	    }
	}));
	
	ConsoleReader console= new ConsoleReader(); 

	try {
		// Autcomplete commands with length > x 
		for(CommandHelp x : CommandList.commandHelpList()){
			if(x.getName().length() > 2){
				console.addCompleter(new StringsCompleter(x.getName()));
			}
		}
	} catch (InvalidCommandLineException e) {
		e.printStackTrace();
	}
	console.setExpandEvents(false);
	return console;
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:24,代码来源:Main.java

示例2: promptForText

import jline.console.ConsoleReader; //导入方法依赖的package包/类
/**
 * @param prompt
 *         to display to the user
 * @param mask
 *         single character to display instead of what the user is typing, use null if text is not secret
 * @return the text which was entered
 * @throws Exception
 *         in case of errors
 */
@Nonnull
private String promptForText(@Nonnull String prompt, @Nullable Character mask) throws Exception {
    String line;
    ConsoleReader consoleReader = new ConsoleReader(in, out);
    // Disable expansion of bangs: !
    consoleReader.setExpandEvents(false);
    // Ensure Reader does not handle user input for ctrl+C behaviour
    consoleReader.setHandleUserInterrupt(false);
    line = consoleReader.readLine(prompt + ": ", mask);
    consoleReader.close();

    if (line == null) {
        throw new CommandException("No text could be read, exiting...");
    }

    return line;
}
 
开发者ID:neo4j,项目名称:cypher-shell,代码行数:27,代码来源:Main.java

示例3: main

import jline.console.ConsoleReader; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
    Log.setOutput( new PrintStream( ByteStreams.nullOutputStream() ) );
    AnsiConsole.systemInstall();
    consoleReader = new ConsoleReader();
    consoleReader.setExpandEvents( false );

    logger = new BungeeLogger();
    System.setErr( new PrintStream( new LoggingOutputStream( logger, Level.SEVERE ), true ) );
    System.setOut( new PrintStream( new LoggingOutputStream( logger, Level.INFO ), true ) );

    instance = new ChunkrServer();

    while ( isRunning )
    {
        String line = consoleReader.readLine( ">" );
        if ( line != null )
        {
            if ( !getInstance().getPluginManager().dispatchCommand( line ) )
            {
                logger.info( "Command not found" );
            }
        }
    }
}
 
开发者ID:Chnkr,项目名称:ChunkrConnect,代码行数:26,代码来源:ChunkrServer.java

示例4: MooLogger

import jline.console.ConsoleReader; //导入方法依赖的package包/类
public MooLogger(String name, Formatter formatter) {
    super(name, null);
    super.setLevel(Level.ALL);

    // list jline console
    try {
        reader = new ConsoleReader();
        reader.setExpandEvents(false);
    }
    catch(IOException e) {
        System.err.println("Could not initialise console reader!");
        e.printStackTrace();
    }

    // checks the folder of logs
    try {
        this.consoleHandler = new ColoredWriter(reader);
        consoleHandler.setLevel(Level.ALL);
        consoleHandler.setFormatter(formatter);
        addHandler(consoleHandler);
    }
    catch(Exception ex) {
        System.err.println("Could not register logger!");
        ex.printStackTrace();
    }

    dispatcher.start();
}
 
开发者ID:Superioz,项目名称:MooProject,代码行数:29,代码来源:MooLogger.java

示例5: Hydroangeas

import jline.console.ConsoleReader; //导入方法依赖的package包/类
public Hydroangeas(OptionSet options) throws IOException
{
    instance = this;
    uuid = UUID.randomUUID();

    AnsiConsole.systemInstall();
    consoleReader = new ConsoleReader();
    consoleReader.setExpandEvents(false);

    logger = new HydroLogger(this);

    logger.info("Hydroangeas version 1.0.0");
    logger.info("----------------------------------------");

    this.scheduler = Executors.newScheduledThreadPool(16);
    this.options = options;
    loadConfig();
    this.databaseConnector = new DatabaseConnector(this);

    this.redisSubscriber = new RedisSubscriber(this);
    this.linuxBridge = new LinuxBridge();
    this.enable();
    Runtime.getRuntime().addShutdownHook(new Thread(() ->
    {
        this.log(Level.INFO, "Shutdown asked!");
        this.shutdown();
        this.log(Level.INFO, "Bye!");
    }));

    isRunning = true;
}
 
开发者ID:SamaGames,项目名称:Hydroangeas,代码行数:32,代码来源:Hydroangeas.java

示例6: BungeeCord

import jline.console.ConsoleReader; //导入方法依赖的package包/类
@SuppressFBWarnings("DM_DEFAULT_ENCODING")
public BungeeCord() throws IOException
{
    // Java uses ! to indicate a resource inside of a jar/zip/other container. Running Bungee from within a directory that has a ! will cause this to muck up.
    Preconditions.checkState( new File( "." ).getAbsolutePath().indexOf( '!' ) == -1, "Cannot use BungeeCord in directory with ! in path." );

    try
    {
        baseBundle = ResourceBundle.getBundle( "messages" );
    } catch ( MissingResourceException ex )
    {
        baseBundle = ResourceBundle.getBundle( "messages", Locale.ENGLISH );
    }
    File file = new File( "messages.properties" );
    if ( file.isFile() )
    {
        try ( FileReader rd = new FileReader( file ) )
        {
            customBundle = new PropertyResourceBundle( rd );
        }
    }

    // This is a workaround for quite possibly the weirdest bug I have ever encountered in my life!
    // When jansi attempts to extract its natives, by default it tries to extract a specific version,
    // using the loading class's implementation version. Normally this works completely fine,
    // however when on Windows certain characters such as - and : can trigger special behaviour.
    // Furthermore this behaviour only occurs in specific combinations due to the parsing done by jansi.
    // For example test-test works fine, but test-test-test does not! In order to avoid this all together but
    // still keep our versions the same as they were, we set the override property to the essentially garbage version
    // BungeeCord. This version is only used when extracting the libraries to their temp folder.
    System.setProperty( "library.jansi.version", "BungeeCord" );

    AnsiConsole.systemInstall();
    consoleReader = new ConsoleReader();
    consoleReader.setExpandEvents( false );
    consoleReader.addCompleter( new ConsoleCommandCompleter( this ) );

    logger = new BungeeLogger( this );
    System.setErr( new PrintStream( new LoggingOutputStream( logger, Level.SEVERE ), true ) );
    System.setOut( new PrintStream( new LoggingOutputStream( logger, Level.INFO ), true ) );

    if ( !Boolean.getBoolean( "net.md_5.bungee.native.disable" ) )
    {
        if ( EncryptionUtil.nativeFactory.load() )
        {
            logger.info( "Using OpenSSL based native cipher." );
        } else
        {
            logger.info( "Using standard Java JCE cipher. To enable the OpenSSL based native cipher, please make sure you are using 64 bit Ubuntu or Debian with libssl installed." );
        }
        if ( CompressFactory.zlib.load() )
        {
            logger.info( "Using native code compressor" );
        } else
        {
            logger.info( "Using standard Java compressor. To enable zero copy compression, run on 64 bit Linux" );
        }
    }
}
 
开发者ID:WaterfallMC,项目名称:Waterfall-Old,代码行数:60,代码来源:BungeeCord.java

示例7: init

import jline.console.ConsoleReader; //导入方法依赖的package包/类
public void init() {
    System.setProperty("library.jansi.version", "JaPS");

    AnsiConsole.systemInstall();

    try {
        consoleReader = new ConsoleReader();
        consoleReader.setExpandEvents(false);
    } catch (IOException e) {
        e.printStackTrace();
    }

    // Setup logging system
    logger = new JaPSLogger(consoleReader);
    System.setErr(new PrintStream(new LoggingOutputStream(logger, Level.SEVERE), true));
    System.setOut(new PrintStream(new LoggingOutputStream(logger, Level.INFO), true));

    // Register command
    commandManager = new CommandManager();
    commandManager.addCommand(new HelpCommand("help", new String[]{"h"}, "Show this output"));
    commandManager.addCommand(new SubCommand("sub", new String[]{"s", "subscribe"}, "Subscribe a channel and view it's prepareCacheSync passing"));
    commandManager.addCommand(new UnsubCommand("unsub", new String[]{}, "Unsubscribe previous subscribed channels"));
    commandManager.addCommand(new EndCommand("end", new String[]{"stop"}, "Shutdown the server"));
    commandManager.addCommand(new SetCommand("set", new String[]{"add"}, "Sets a key and value"));
    commandManager.addCommand(new GetCommand("get", new String[]{}, "Gets a value from a key"));
    commandManager.addCommand(new DeleteCommand("delete", new String[]{"remove", "del", "rm"}, "Gets a value from a key"));
    commandManager.addCommand(new SnapshotCommand("snapshot", new String[]{}, "Takes a memory snapshot"));

    // Autocomplete commands
    consoleReader.addCompleter(new StringsCompleter(commandManager.getCommands().stream().map(Command::getName).collect(Collectors.toList())));

    // Autocomplete files
    consoleReader.addCompleter(new FileNameCompleter());

    logger.info("Initialized");
}
 
开发者ID:JackWhite20,项目名称:JaPS,代码行数:37,代码来源:JaPS.java

示例8: CliRun

import jline.console.ConsoleReader; //导入方法依赖的package包/类
CliRun( CommandRunner commandRunner,
        CliProperties cliProperties )
        throws IOException {
    this.commandRunner = commandRunner;
    this.cliProperties = cliProperties;
    this.input = new InterruptableInputStream( System.in );

    // JLine must run with a blocking InputStream
    System.setProperty( "jline.esc.timeout", "0" );
    consoleReader = new ConsoleReader( input, System.out );
    started = new AtomicBoolean( false );
    consoleReader.setPrompt( getPrompt() );
    consoleReader.setExpandEvents( false );
}
 
开发者ID:renatoathaydes,项目名称:osgiaas,代码行数:15,代码来源:CliRun.java

示例9: setupConsoleReader

import jline.console.ConsoleReader; //导入方法依赖的package包/类
private ConsoleReader setupConsoleReader(@Nonnull Logger logger,
                                         @Nonnull InputStream inputStream) throws IOException {
    ConsoleReader reader = new ConsoleReader(inputStream, logger.getOutputStream());
    // Disable expansion of bangs: !
    reader.setExpandEvents(false);
    // Ensure Reader does not handle user input for ctrl+C behaviour
    reader.setHandleUserInterrupt(false);
    return reader;
}
 
开发者ID:neo4j,项目名称:cypher-shell,代码行数:10,代码来源:InteractiveShellRunner.java

示例10: readConconsole

import jline.console.ConsoleReader; //导入方法依赖的package包/类
private int readConconsole()
    throws IOException
{
    ConsoleReader reader = new ConsoleReader();
    reader.setBellEnabled(false);
    //这样就可以支持'!='这样的输入了。
    reader.setExpandEvents(false);
    reader.setCopyPasteDetection(true);
    
    String line;
    int ret = 0;
    StringBuilder prefix = new StringBuilder();
    printHelp();
    
    String tip = DEFAULT_CLI_TIP;
    
    while ((line = reader.readLine(tip)) != null)
    {
        tip = WAITING_INPUT_TIP;
        if (!prefix.toString().equals(""))
        {
            prefix.append("\n");
        }
        
        if (line.trim().startsWith("--"))
        {
            continue;
        }
        
        if (line.trim().endsWith(";") && !line.trim().endsWith("\\;"))
        {
            line = prefix.toString() + line;
            ret = processLine(line);
            prefix.delete(0, prefix.length());
            tip = DEFAULT_CLI_TIP;
        }
        else
        {
            prefix.append(line);
            continue;
        }
    }
    return ret;
}
 
开发者ID:HuaweiBigData,项目名称:StreamCQL,代码行数:45,代码来源:CQLClient.java


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