2 * This file is part of lanterna (http://code.google.com/p/lanterna/).
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.
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.
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/>.
17 * Copyright (C) 2010-2015 Martin
19 package com
.googlecode
.lanterna
.terminal
.swing
;
21 import com
.googlecode
.lanterna
.TextColor
;
24 * Object that encapsulates the configuration parameters for the terminal 'device' that a SwingTerminal is emulating.
25 * This includes properties such as the shape of the cursor, the color of the cursor, how large scrollback is available
26 * and if the cursor should blink or not.
29 public class TerminalEmulatorDeviceConfiguration
{
32 * This is a static reference to the default terminal device configuration. Use this one if you are unsure.
34 public static TerminalEmulatorDeviceConfiguration
getDefault() {
35 return new TerminalEmulatorDeviceConfiguration();
38 private final int lineBufferScrollbackSize
;
39 private final int blinkLengthInMilliSeconds
;
40 private final CursorStyle cursorStyle
;
41 private final TextColor cursorColor
;
42 private final boolean cursorBlinking
;
45 * Creates a new terminal device configuration object with all the defaults set
47 @SuppressWarnings("WeakerAccess")
48 public TerminalEmulatorDeviceConfiguration() {
49 this(2000, 500, CursorStyle
.REVERSED
, new TextColor
.RGB(255, 255, 255), false);
53 * Creates a new terminal device configuration object with all configurable values specified.
54 * @param lineBufferScrollbackSize How many lines of scrollback buffer should the terminal save?
55 * @param blinkLengthInMilliSeconds How many milliseconds does a 'blink' last
56 * @param cursorStyle Style of the terminal text cursor
57 * @param cursorColor Color of the terminal text cursor
58 * @param cursorBlinking Should the terminal text cursor blink?
60 @SuppressWarnings("WeakerAccess")
61 public TerminalEmulatorDeviceConfiguration(int lineBufferScrollbackSize
, int blinkLengthInMilliSeconds
, CursorStyle cursorStyle
, TextColor cursorColor
, boolean cursorBlinking
) {
62 this.lineBufferScrollbackSize
= lineBufferScrollbackSize
;
63 this.blinkLengthInMilliSeconds
= blinkLengthInMilliSeconds
;
64 this.cursorStyle
= cursorStyle
;
65 this.cursorColor
= cursorColor
;
66 this.cursorBlinking
= cursorBlinking
;
70 * Returns the length of a 'blink', which is the interval time a character with the blink SGR enabled with be drawn
71 * with foreground color and background color set to the same.
72 * @return Milliseconds of a blink interval
74 public int getBlinkLengthInMilliSeconds() {
75 return blinkLengthInMilliSeconds
;
79 * How many lines of history should be saved so the user can scroll back to them?
80 * @return Number of lines in the scrollback buffer
82 public int getLineBufferScrollbackSize() {
83 return lineBufferScrollbackSize
;
87 * Style the text cursor should take
88 * @return Text cursor style
89 * @see TerminalEmulatorDeviceConfiguration.CursorStyle
91 public CursorStyle
getCursorStyle() {
96 * What color to draw the text cursor color in
97 * @return Color of the text cursor
99 public TextColor
getCursorColor() {
104 * Should the text cursor be blinking
105 * @return {@code true} if the text cursor should be blinking
107 @SuppressWarnings("BooleanMethodIsAlwaysInverted")
108 public boolean isCursorBlinking() {
109 return cursorBlinking
;
113 * Returns a copy of this device configuration but with a different size of the scrollback buffer
114 * @param lineBufferScrollbackSize Size of the scrollback buffer (in number of lines) the copy should have
115 * @return Copy of this device configuration with a specified size for the scrollback buffer
117 public TerminalEmulatorDeviceConfiguration
withLineBufferScrollbackSize(int lineBufferScrollbackSize
) {
118 if(this.lineBufferScrollbackSize
== lineBufferScrollbackSize
) {
122 return new TerminalEmulatorDeviceConfiguration(
123 lineBufferScrollbackSize
,
124 blinkLengthInMilliSeconds
,
132 * Different cursor styles supported by SwingTerminal
134 public enum CursorStyle
{
136 * The cursor is drawn by inverting the front- and background colors of the cursor position
140 * The cursor is drawn by using the cursor color as the background color for the character at the cursor position
144 * The cursor is rendered as a thick horizontal line at the bottom of the character
148 * The cursor is rendered as a left-side aligned vertical line