summaryrefslogtreecommitdiff
path: root/src/jline/src/main/java/scala/tools/jline/console/Operation.java
blob: 59ee878d4544457290203275b63a0897a3228213 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
/*
 * Copyright (c) 2002-2007, Marc Prud'hommeaux. All rights reserved.
 *
 * This software is distributable under the BSD license. See the terms of the
 * BSD license in the documentation provided with this software.
 */

package scala.tools.jline.console;

import java.util.HashMap;
import java.util.Map;

/**
 * Map for console operation to virtual key bindings.
 *
 * @author <a href="mailto:mwp1@cornell.edu">Marc Prud'hommeaux</a>
 * @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
 * @see java.awt.event.KeyEvent
 * @since 2.0
 */
public enum Operation
{
    /**
     * Unknown operation.
     */
    UNKNOWN(-99),

    /**
     * Operation that moves to the beginning of the buffer.
     */
    MOVE_TO_BEG(-1),

    /**
     * Operation that moves to the end of the buffer.
     */
    MOVE_TO_END(-3),

    /**
     * Operation that moved to the previous character in the buffer.
     */
    PREV_CHAR(-4),

    /**
     * Operation that issues a newline.
     */
    NEWLINE(-6),

    /**
     * Operation that deletes the buffer from the current character to the end.
     */
    KILL_LINE(-7),

    /**
     * Operation that clears the screen.
     */
    CLEAR_SCREEN(-8),

    /**
     * Operation that sets the buffer to the next history item.
     */
    NEXT_HISTORY(-9),

    /**
     * Operation that sets the buffer to the previous history item.
     */
    PREV_HISTORY(-11),

    /**
     * Operation that redisplays the current buffer.
     */
    REDISPLAY(-13),

    /**
     * Operation that deletes the buffer from the cursor to the beginning.
     */
    KILL_LINE_PREV(-15),

    /**
     * Operation that deletes the previous word in the buffer.
     */
    DELETE_PREV_WORD(-16),

    /**
     * Operation that moves to the next character in the buffer.
     */
    NEXT_CHAR(-19),

    /**
     * Operation that moves to the previous character in the buffer.
     */
    REPEAT_PREV_CHAR(-20),

    /**
     * Operation that searches backwards in the command history.
     */
    SEARCH_PREV(-21),

    /**
     * Operation that repeats the character.
     */
    REPEAT_NEXT_CHAR(-24),

    /**
     * Operation that searches forward in the command history.
     */
    SEARCH_NEXT(-25),

    /**
     * Operation that moved to the previous whitespace.
     */
    PREV_SPACE_WORD(-27),

    /**
     * Operation that moved to the end of the current word.
     */
    TO_END_WORD(-29),

    /**
     * Operation that
     */
    REPEAT_SEARCH_PREV(-34),

    /**
     * Operation that
     */
    PASTE_PREV(-36),

    /**
     * Operation that
     */
    REPLACE_MODE(-37),

    /**
     * Operation that
     */
    SUBSTITUTE_LINE(-38),

    /**
     * Operation that
     */
    TO_PREV_CHAR(-39),

    /**
     * Operation that
     */
    NEXT_SPACE_WORD(-40),

    /**
     * Operation that
     */
    DELETE_PREV_CHAR(-41),

    /**
     * Operation that
     */
    ADD(-42),

    /**
     * Operation that
     */
    PREV_WORD(-43),

    /**
     * Operation that
     */
    CHANGE_META(-44),

    /**
     * Operation that
     */
    DELETE_META(-45),

    /**
     * Operation that
     */
    END_WORD(-46),

    /**
     * Operation that toggles insert/overtype
     */
    INSERT(-48),

    /**
     * Operation that
     */
    REPEAT_SEARCH_NEXT(-49),

    /**
     * Operation that
     */
    PASTE_NEXT(-50),

    /**
     * Operation that
     */
    REPLACE_CHAR(-51),

    /**
     * Operation that
     */
    SUBSTITUTE_CHAR(-52),

    /**
     * Operation that
     */
    TO_NEXT_CHAR(-53),

    /**
     * Operation that undoes the previous operation.
     */
    UNDO(-54),

    /**
     * Operation that moved to the next word.
     */
    NEXT_WORD(-55),

    /**
     * Operation that deletes the previous character.
     */
    DELETE_NEXT_CHAR(-56),

    /**
     * Operation that toggles between uppercase and lowercase.
     */
    CHANGE_CASE(-57),

    /**
     * Operation that performs completion operation on the current word.
     */
    COMPLETE(-58),

    /**
     * Operation that exits the command prompt.
     */
    EXIT(-59),

    /**
     * Operation that pastes the contents of the clipboard into the line
     */
    PASTE(-60),

    /**
     * Operation that moves the current History to the beginning.
     */
    START_OF_HISTORY(-61),

    /**
     * Operation that moves the current History to the end.
     */
    END_OF_HISTORY(-62),

    /**
     * Operation that clears whatever text is on the current line.
     */
    CLEAR_LINE(-63),

    /**
     * Cancel search
     */
    ABORT(-64),

    /**
     * Delete next word
     */
    DELETE_NEXT_WORD(-65),

    ;

    public final short code;

    Operation(final int code) {
        this.code = (short) code;
    }

    private static final Map<Short, Operation> codes;

    static {
        Map<Short, Operation> map = new HashMap<Short, Operation>();

        for (Operation op : Operation.values()) {
            map.put(op.code, op);
        }

        codes = map;
    }

    public static Operation valueOf(final int code) {
        return codes.get((short) code);
    }
}