@ Override public String readLine ( ) throws IOException { StringBuilder lineBuilder = new StringBuilder ( ) ; EditorOperation operation ; while ( true ) { operation = readOperation ( ) ; switch ( operation . getType ( ) ) { case BACKSAPCE : case DELETE : if ( lineBuilder . length ( ) > 0 ) { lineBuilder . delete ( lineBuilder . length ( ) - 1 , lineBuilder . length ( ) ) ; console . out ( ) . print ( Ansi . ansi ( ) . cursorLeft ( 1 ) ) ; console . out ( ) . print ( " " ) ; console . out ( ) . print ( Ansi . ansi ( ) . cursorLeft ( 1 ) ) ; } break ; case NEWLINE : return lineBuilder . toString ( ) ; case TYPE : console . out ( ) . print ( operation . getInput ( ) ) ; lineBuilder . append ( operation . getInput ( ) ) ; break ; } flush ( ) ; } }
Reads a line from the user input .