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