| 1 | /* |
| 2 | * This file is part of lanterna (http://code.google.com/p/lanterna/). |
| 3 | * |
| 4 | * lanterna is free software: you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU Lesser General Public License as published by |
| 6 | * the Free Software Foundation, either version 3 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU Lesser General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Lesser General Public License |
| 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | * |
| 17 | * Copyright (C) 2010-2015 Martin |
| 18 | */ |
| 19 | package com.googlecode.lanterna.input; |
| 20 | |
| 21 | import java.io.IOException; |
| 22 | |
| 23 | /** |
| 24 | * Objects implementing this interface can read character streams and transform them into {@code Key} objects which can |
| 25 | * be read in a FIFO manner. |
| 26 | * |
| 27 | * @author Martin |
| 28 | */ |
| 29 | public interface InputProvider { |
| 30 | /** |
| 31 | * Returns the next {@code Key} off the input queue or null if there is no more input events available. Note, this |
| 32 | * method call is <b>not</b> blocking, it returns null immediately if there is nothing on the input stream. |
| 33 | * @return Key object which represents a keystroke coming in through the input stream |
| 34 | * @throws java.io.IOException Propagated error if the underlying stream gave errors |
| 35 | */ |
| 36 | KeyStroke pollInput() throws IOException; |
| 37 | |
| 38 | /** |
| 39 | * Returns the next {@code Key} off the input queue or blocks until one is available. <b>NOTE:</b> In previous |
| 40 | * versions of Lanterna, this method was <b>not</b> blocking. From lanterna 3, it is blocking and you can call |
| 41 | * {@code pollInput()} for the non-blocking version. |
| 42 | * @return Key object which represents a keystroke coming in through the input stream |
| 43 | * @throws java.io.IOException Propagated error if the underlying stream gave errors |
| 44 | */ |
| 45 | KeyStroke readInput() throws IOException; |
| 46 | } |