clean readme
[fanfix.git] / src / jexer / TCommand.java
CommitLineData
daa4106c 1/*
df8de03f
KL
2 * Jexer - Java Text User Interface
3 *
df8de03f
KL
4 * License: LGPLv3 or later
5 *
7b5261bc
KL
6 * This module is licensed under the GNU Lesser General Public License
7 * Version 3. Please see the file "COPYING" in this directory for more
8 * information about the GNU Lesser General Public License Version 3.
df8de03f
KL
9 *
10 * Copyright (C) 2015 Kevin Lamonte
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public License
14 * as published by the Free Software Foundation; either version 3 of
15 * the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this program; if not, see
24 * http://www.gnu.org/licenses/, or write to the Free Software
25 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
26 * 02110-1301 USA
7b5261bc
KL
27 *
28 * @author Kevin Lamonte [kevin.lamonte@gmail.com]
29 * @version 1
df8de03f
KL
30 */
31package jexer;
32
33/**
7b5261bc
KL
34 * This class encapsulates a user command event. User commands can be
35 * generated by menu actions, keyboard accelerators, and other UI elements.
36 * Commands can operate on both the application and individual widgets.
df8de03f
KL
37 */
38public class TCommand {
39
7b5261bc 40 /**
d4a29741
KL
41 * Immediately abort the application (e.g. remote side closed
42 * connection).
43 */
44 public static final int ABORT = 1;
df8de03f 45
d4a29741
KL
46 /**
47 * File open dialog.
48 */
49 public static final int OPEN = 2;
50
51 /**
52 * Exit application.
53 */
54 public static final int EXIT = 3;
55
56 /**
57 * Spawn OS shell window.
58 */
59 public static final int SHELL = 4;
60
61 /**
62 * Cut selected text and copy to the clipboard.
63 */
64 public static final int CUT = 5;
65
66 /**
67 * Copy selected text to clipboard.
68 */
69 public static final int COPY = 6;
70
71 /**
72 * Paste from clipboard.
73 */
74 public static final int PASTE = 7;
75
76 /**
77 * Clear selected text without copying it to the clipboard.
78 */
79 public static final int CLEAR = 8;
80
81 /**
82 * Tile windows.
83 */
84 public static final int TILE = 9;
85
86 /**
87 * Cascade windows.
88 */
89 public static final int CASCADE = 10;
90
91 /**
92 * Close all windows.
93 */
94 public static final int CLOSE_ALL = 11;
95
96 /**
97 * Move (move/resize) window.
98 */
99 public static final int WINDOW_MOVE = 12;
100
101 /**
102 * Zoom (maximize/restore) window.
103 */
104 public static final int WINDOW_ZOOM = 13;
105
106 /**
107 * Next window (like Alt-TAB).
108 */
109 public static final int WINDOW_NEXT = 14;
110
111 /**
112 * Previous window (like Shift-Alt-TAB).
113 */
114 public static final int WINDOW_PREVIOUS = 15;
115
116 /**
117 * Close window.
118 */
119 public static final int WINDOW_CLOSE = 16;
df8de03f
KL
120
121 /**
122 * Type of command, one of EXIT, CASCADE, etc.
123 */
d4a29741 124 private int type;
df8de03f
KL
125
126 /**
d4a29741 127 * Protected constructor. Subclasses can be used to define new commands.
df8de03f
KL
128 *
129 * @param type the Type of command, one of EXIT, CASCADE, etc.
130 */
d4a29741 131 protected TCommand(final int type) {
7b5261bc 132 this.type = type;
df8de03f
KL
133 }
134
135 /**
7b5261bc
KL
136 * Make human-readable description of this TCommand.
137 *
138 * @return displayable String
df8de03f
KL
139 */
140 @Override
7b5261bc
KL
141 public final String toString() {
142 return String.format("%s", type);
df8de03f
KL
143 }
144
4328bb42 145 /**
7b5261bc
KL
146 * Comparison check. All fields must match to return true.
147 *
148 * @param rhs another TCommand instance
149 * @return true if all fields are equal
4328bb42
KL
150 */
151 @Override
7b5261bc
KL
152 public final boolean equals(final Object rhs) {
153 if (!(rhs instanceof TCommand)) {
154 return false;
155 }
4328bb42 156
7b5261bc
KL
157 TCommand that = (TCommand) rhs;
158 return (type == that.type);
4328bb42
KL
159 }
160
e826b451
KL
161 /**
162 * Hashcode uses all fields in equals().
163 *
164 * @return the hash
165 */
166 @Override
167 public int hashCode() {
168 return type;
169 }
170
d4a29741
KL
171 public static final TCommand cmAbort = new TCommand(ABORT);
172 public static final TCommand cmExit = new TCommand(EXIT);
173 public static final TCommand cmQuit = new TCommand(EXIT);
174 public static final TCommand cmOpen = new TCommand(OPEN);
175 public static final TCommand cmShell = new TCommand(SHELL);
176 public static final TCommand cmCut = new TCommand(CUT);
177 public static final TCommand cmCopy = new TCommand(COPY);
178 public static final TCommand cmPaste = new TCommand(PASTE);
179 public static final TCommand cmClear = new TCommand(CLEAR);
180 public static final TCommand cmTile = new TCommand(TILE);
181 public static final TCommand cmCascade = new TCommand(CASCADE);
182 public static final TCommand cmCloseAll = new TCommand(CLOSE_ALL);
183 public static final TCommand cmWindowMove = new TCommand(WINDOW_MOVE);
184 public static final TCommand cmWindowZoom = new TCommand(WINDOW_ZOOM);
185 public static final TCommand cmWindowNext = new TCommand(WINDOW_NEXT);
186 public static final TCommand cmWindowPrevious = new TCommand(WINDOW_PREVIOUS);
187 public static final TCommand cmWindowClose = new TCommand(WINDOW_CLOSE);
df8de03f
KL
188
189}