當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。