java.lang.Object
- All Implemented Interfaces:
KeyEventListener
public final class Console extends Window implements KeyEventListener
Console utilities
-
Field Summary
Fields Modifier and Type Field Description static CursorPositioncursorstatic RawConsoleInputinstatic RawConsoleOutputoutprotected static java.util.Deque<Window>windowsOpenFields inherited from class it.polimi.ingsw.view.cli.console.graphics.components.Window
background, cli, enableInputOnReturn, returnToFields inherited from class it.polimi.ingsw.view.cli.console.graphics.components.WindowItem
activeItems, id, parent, passiveItems -
Method Summary
Modifier and Type Method Description static voidaddWindow(Window window)Adds, if absent, a new Window to the console windows liststatic voidclose()Closes the program, bringing the terminal back to canonical modestatic voidcloseWindow(Window window)Closes the given window, re-enabling the underlying onestatic WindowcurrentWindow()Provides the last window openedstatic Consoleinit(CLI cli)Initializes the Consolestatic booleanisOpen(Window window)Determines if a Window is still showing on the consolestatic intnumberOfWindowsOpen()Provides the number of windows openstatic voidplaceCursor(int row, int col)Places the cursor at the given coordinatesstatic voidshowCursor()Makes the cursor blinkMethods inherited from class it.polimi.ingsw.view.cli.console.graphics.components.Window
addToBackground, getCli, getReturnTo, showMethods inherited from class it.polimi.ingsw.view.cli.console.graphics.components.WindowItem
addActiveItem, addPassiveItem, currentActiveItem, drawShadows, getID, getParent, hideShadows, maxStringLength, nextActiveItem, previousActiveItem, removeMethods inherited from class it.polimi.ingsw.view.cli.console.graphics.components.Rectangle
drawBackground, drawBorders, findCenter, getBackgroundColor, getColor, getHeight, getInitCoord, getTextColor, getWidth, hideBorders, loadPropertiesFileMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface it.polimi.ingsw.view.cli.console.KeyEventListener
onArrowDown, onArrowLeft, onArrowRight, onArrowUp, onBackspace, onCarriageReturn, onPrintableKey, onTab
-
Field Details
-
Method Details
-
init
Initializes the Console- Parameters:
cli- the view invoking the console
-
isOpen
Determines if a Window is still showing on the console- Parameters:
window- the window to check- Returns:
- true if the window is still showing, false otherwise
-
currentWindow
Provides the last window opened- Returns:
- the last window opened, null if none has been shown
-
numberOfWindowsOpen
public static int numberOfWindowsOpen()Provides the number of windows open- Returns:
- the number of open windows
-
addWindow
Adds, if absent, a new Window to the console windows list- Parameters:
window- the window to add
-
closeWindow
Closes the given window, re-enabling the underlying one- Parameters:
window- the window to close
-
close
public static void close()Closes the program, bringing the terminal back to canonical mode -
placeCursor
public static void placeCursor(int row, int col)Places the cursor at the given coordinates- Parameters:
row- the target rowcol- the target col
-
showCursor
public static void showCursor()Makes the cursor blink
-