1 /* |
|
2 * Copyright (c) 2002-2016, 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 jdk.internal.jline; |
|
10 |
|
11 import jdk.internal.jline.internal.Log; |
|
12 |
|
13 /** |
|
14 * Terminal that is used for OSv. This is seperate to unix terminal |
|
15 * implementation because exec cannot be used as currently used by UnixTerminal. |
|
16 * |
|
17 * This implimentation is derrived from the implementation at |
|
18 * https://github.com/cloudius-systems/mgmt/blob/master/crash/src/main/java/com/cloudius/cli/OSvTerminal.java |
|
19 * authored by Or Cohen. |
|
20 * |
|
21 * @author <a href-"mailto:orc@fewbytes.com">Or Cohen</a> |
|
22 * @author <a href="mailto:arun.neelicattu@gmail.com">Arun Neelicattu</a> |
|
23 * @since 2.13 |
|
24 */ |
|
25 public class OSvTerminal |
|
26 extends TerminalSupport |
|
27 { |
|
28 |
|
29 public Class<?> sttyClass = null; |
|
30 public Object stty = null; |
|
31 |
|
32 @SuppressWarnings("deprecation") |
|
33 public OSvTerminal() { |
|
34 super(true); |
|
35 |
|
36 setAnsiSupported(true); |
|
37 |
|
38 try { |
|
39 if (stty == null) { |
|
40 sttyClass = Class.forName("com.cloudius.util.Stty"); |
|
41 stty = sttyClass.newInstance(); |
|
42 } |
|
43 } catch (Exception e) { |
|
44 Log.warn("Failed to load com.cloudius.util.Stty", e); |
|
45 } |
|
46 } |
|
47 |
|
48 @Override |
|
49 public void init() throws Exception { |
|
50 super.init(); |
|
51 |
|
52 if (stty != null) { |
|
53 sttyClass.getMethod("jlineMode").invoke(stty); |
|
54 } |
|
55 } |
|
56 |
|
57 @Override |
|
58 public void restore() throws Exception { |
|
59 if (stty != null) { |
|
60 sttyClass.getMethod("reset").invoke(stty); |
|
61 } |
|
62 super.restore(); |
|
63 |
|
64 // Newline in end of restore like in jline.UnixTerminal |
|
65 System.out.println(); |
|
66 } |
|
67 |
|
68 } |
|