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 CursorPosition
cursor
static RawConsoleInput
in
static RawConsoleOutput
out
protected static java.util.Deque<Window>
windowsOpen
Fields inherited from class it.polimi.ingsw.view.cli.console.graphics.components.Window
background, cli, enableInputOnReturn, returnTo
Fields inherited from class it.polimi.ingsw.view.cli.console.graphics.components.WindowItem
activeItems, id, parent, passiveItems
-
Method Summary
Modifier and Type Method Description static void
addWindow(Window window)
Adds, if absent, a new Window to the console windows liststatic void
close()
Closes the program, bringing the terminal back to canonical modestatic void
closeWindow(Window window)
Closes the given window, re-enabling the underlying onestatic Window
currentWindow()
Provides the last window openedstatic Console
init(CLI cli)
Initializes the Consolestatic boolean
isOpen(Window window)
Determines if a Window is still showing on the consolestatic int
numberOfWindowsOpen()
Provides the number of windows openstatic void
placeCursor(int row, int col)
Places the cursor at the given coordinatesstatic void
showCursor()
Makes the cursor blinkMethods inherited from class it.polimi.ingsw.view.cli.console.graphics.components.Window
addToBackground, getCli, getReturnTo, show
Methods inherited from class it.polimi.ingsw.view.cli.console.graphics.components.WindowItem
addActiveItem, addPassiveItem, currentActiveItem, drawShadows, getID, getParent, hideShadows, maxStringLength, nextActiveItem, previousActiveItem, remove
Methods inherited from class it.polimi.ingsw.view.cli.console.graphics.components.Rectangle
drawBackground, drawBorders, findCenter, getBackgroundColor, getColor, getHeight, getInitCoord, getTextColor, getWidth, hideBorders, loadPropertiesFile
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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
-