1 /*
2 * Copyright (c) 2002-2012, the original author or authors.
3 *
4 * This software is distributable under the BSD license. See the terms of the
5 * BSD license in the documentation provided with this software.
6 *
7 * http://www.opensource.org/licenses/bsd-license.php
8 */
9 package jline;
10
11 import java.io.IOException;
12 import java.io.InputStream;
13 import java.io.OutputStream;
14
15 /**
16 * Representation of the input terminal for a platform.
17 *
18 * @author <a href="mailto:mwp1@cornell.edu">Marc Prud'hommeaux</a>
19 * @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
20 * @since 2.0
21 */
22 public interface Terminal
23 {
24 void init() throws Exception;
25
26 void restore() throws Exception;
27
28 void reset() throws Exception;
29
30 boolean isSupported();
31
32 int getWidth();
33
34 int getHeight();
35
36 boolean isAnsiSupported();
37
38 /**
39 * When ANSI is not natively handled, the output will have to be wrapped.
40 */
41 OutputStream wrapOutIfNeeded(OutputStream out);
42
43 /**
44 * When using native support, return the InputStream to use for reading characters
45 * else return the input stream passed as a parameter.
46 *
47 * @since 2.6
48 */
49 InputStream wrapInIfNeeded(InputStream in) throws IOException;
50
51 /**
52 * For terminals that don't wrap when character is written in last column,
53 * only when the next character is written.
54 * These are the ones that have 'am' and 'xn' termcap attributes (xterm and
55 * rxvt flavors falls under that category)
56 */
57 boolean hasWeirdWrap();
58
59 boolean isEchoEnabled();
60
61 void setEchoEnabled(boolean enabled);
62
63 String getOutputEncoding();
64
65 }