java.lang.Object
it.polimi.ingsw.view.cli.console.RawConsoleOutput
public class RawConsoleOutput
extends java.lang.Object
Raw console printing utilities
-
Constructor Summary
Constructors Constructor Description RawConsoleOutput() -
Method Summary
Modifier and Type Method Description protected voiddel()Clears the last character printedvoiddrawMatrix(java.lang.String[][] matrix)Shows a matrix on the consolevoiddrawMatrix(java.lang.String[][] matrix, CursorPosition initCoord)Shows a matrix on the console; requires the terminal to be in non-canonical modeprotected voidecho(char c)Echoes back on the console the pressed keyvoidprint(java.lang.String str)Prints a string starting from the current cursor position
The cursor is moved at the end of the printed stringvoidprintAt(CursorPosition position, java.lang.String string)Prints a string starting from a certain position
The cursor is moved at the end of the printed stringvoidprintln(java.lang.String str)Prints a string starting from the current cursor position, then terminates the line
The cursor is moved at the beginning of the first free row from the starting pointvoidprintlnAt(CursorPosition position, java.lang.String string)Prints a string starting from a certain position, then terminates the line
The cursor is moved one row below the initial cursor positionstatic java.util.List<java.lang.String>splitMessage(java.lang.String message, int maxLength)Splits a long message on multiple lines, separating the words at blank spaces OR whenever a '\n' is found
-
Constructor Details
-
RawConsoleOutput
public RawConsoleOutput()
-
-
Method Details
-
splitMessage
public static java.util.List<java.lang.String> splitMessage(java.lang.String message, int maxLength)Splits a long message on multiple lines, separating the words at blank spaces OR whenever a '\n' is found- Parameters:
message- the message to be splitmaxLength- the maximum length for a line- Returns:
- the original message, split in lines
-
print
public void print(java.lang.String str)Prints a string starting from the current cursor position
The cursor is moved at the end of the printed string- Parameters:
str- the string to print
-
printAt
Prints a string starting from a certain position
The cursor is moved at the end of the printed string- Parameters:
position- the starting positionstring- the string to print
-
println
public void println(java.lang.String str)Prints a string starting from the current cursor position, then terminates the line
The cursor is moved at the beginning of the first free row from the starting point- Parameters:
str- the string to print
-
printlnAt
Prints a string starting from a certain position, then terminates the line
The cursor is moved one row below the initial cursor position- Parameters:
position- the starting positionstring- the string to print
-
drawMatrix
Shows a matrix on the console; requires the terminal to be in non-canonical mode- Parameters:
matrix- the matrix to showinitCoord- the matrix initial position
-
drawMatrix
public void drawMatrix(java.lang.String[][] matrix)Shows a matrix on the console- Parameters:
matrix- the matrix to show
-
echo
protected void echo(char c)Echoes back on the console the pressed key- Parameters:
c- the pressed key
-
del
protected void del()Clears the last character printed
-