de.lessvoid.nifty.controls
Class ConsoleCommands

java.lang.Object
  extended by de.lessvoid.nifty.controls.ConsoleCommands
All Implemented Interfaces:
KeyInputHandler

public class ConsoleCommands
extends Object
implements KeyInputHandler

This adds all the nifty command line features to the console control: - command line completion (for all registered commands) - command history - command processing which detects commands and directly calls your registered commands (via the ConsoleCommand interface)

Author:
void

Nested Class Summary
static interface ConsoleCommands.ConsoleCommand
          You can implement this interface for individual commands and Nifty will call them when the registered command has been detected.
 
Constructor Summary
ConsoleCommands(Nifty nifty, Console console)
          Create and attach this to the given console.
 
Method Summary
 void enableCommandCompletion(boolean enabled)
          When the command completion is enabled pressing TAB will check for all known commands.
 List<String> getRegisteredCommands()
          Get all commands that are registered.
 boolean keyEvent(NiftyInputEvent inputEvent)
           
 void registerCommand(String commandText, ConsoleCommands.ConsoleCommand command)
          Register a command for the command completion feature.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConsoleCommands

public ConsoleCommands(Nifty nifty,
                       Console console)
Create and attach this to the given console.

Parameters:
console -
Method Detail

enableCommandCompletion

public void enableCommandCompletion(boolean enabled)
When the command completion is enabled pressing TAB will check for all known commands. Use registerCommand() to register commands for this feature to work. Please note that in this case you can't TAB away from the textfield.

Parameters:
enabled - true when command completion should be enabled and false if not

registerCommand

public void registerCommand(String commandText,
                            ConsoleCommands.ConsoleCommand command)
Register a command for the command completion feature.

Parameters:
command - the command to make known

getRegisteredCommands

public List<String> getRegisteredCommands()
Get all commands that are registered.

Returns:
list of all commands that have been registered

keyEvent

public boolean keyEvent(NiftyInputEvent inputEvent)
Specified by:
keyEvent in interface KeyInputHandler


Copyright © 2011. All Rights Reserved.