draggable window
[fanfix.git] / src / jexer / TCommand.java
... / ...
CommitLineData
1/**
2 * Jexer - Java Text User Interface
3 *
4 * License: LGPLv3 or later
5 *
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.
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
27 *
28 * @author Kevin Lamonte [kevin.lamonte@gmail.com]
29 * @version 1
30 */
31package jexer;
32
33/**
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.
37 */
38public class TCommand {
39
40 /**
41 * Immediately abort the application (e.g. remote side closed
42 * connection).
43 */
44 public static final int ABORT = 1;
45
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;
120
121 /**
122 * Type of command, one of EXIT, CASCADE, etc.
123 */
124 private int type;
125
126 /**
127 * Protected constructor. Subclasses can be used to define new commands.
128 *
129 * @param type the Type of command, one of EXIT, CASCADE, etc.
130 */
131 protected TCommand(final int type) {
132 this.type = type;
133 }
134
135 /**
136 * Make human-readable description of this TCommand.
137 *
138 * @return displayable String
139 */
140 @Override
141 public final String toString() {
142 return String.format("%s", type);
143 }
144
145 /**
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
150 */
151 @Override
152 public final boolean equals(final Object rhs) {
153 if (!(rhs instanceof TCommand)) {
154 return false;
155 }
156
157 TCommand that = (TCommand) rhs;
158 return (type == that.type);
159 }
160
161 public static final TCommand cmAbort = new TCommand(ABORT);
162 public static final TCommand cmExit = new TCommand(EXIT);
163 public static final TCommand cmQuit = new TCommand(EXIT);
164 public static final TCommand cmOpen = new TCommand(OPEN);
165 public static final TCommand cmShell = new TCommand(SHELL);
166 public static final TCommand cmCut = new TCommand(CUT);
167 public static final TCommand cmCopy = new TCommand(COPY);
168 public static final TCommand cmPaste = new TCommand(PASTE);
169 public static final TCommand cmClear = new TCommand(CLEAR);
170 public static final TCommand cmTile = new TCommand(TILE);
171 public static final TCommand cmCascade = new TCommand(CASCADE);
172 public static final TCommand cmCloseAll = new TCommand(CLOSE_ALL);
173 public static final TCommand cmWindowMove = new TCommand(WINDOW_MOVE);
174 public static final TCommand cmWindowZoom = new TCommand(WINDOW_ZOOM);
175 public static final TCommand cmWindowNext = new TCommand(WINDOW_NEXT);
176 public static final TCommand cmWindowPrevious = new TCommand(WINDOW_PREVIOUS);
177 public static final TCommand cmWindowClose = new TCommand(WINDOW_CLOSE);
178
179}