36494
|
1 |
/*
|
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
|
23 |
* questions.
|
|
24 |
*/
|
|
25 |
|
|
26 |
package jdk.internal.jshell.tool;
|
|
27 |
|
|
28 |
import java.util.ArrayList;
|
|
29 |
import java.util.Arrays;
|
|
30 |
import java.util.Collection;
|
|
31 |
import java.util.EnumMap;
|
|
32 |
import java.util.EnumSet;
|
|
33 |
import java.util.HashMap;
|
|
34 |
import java.util.List;
|
|
35 |
import java.util.Locale;
|
|
36 |
import java.util.Map;
|
|
37 |
import java.util.Set;
|
|
38 |
import java.util.function.Function;
|
|
39 |
import java.util.regex.Matcher;
|
|
40 |
import java.util.regex.Pattern;
|
|
41 |
import java.util.stream.Collectors;
|
|
42 |
import java.util.stream.Stream;
|
|
43 |
|
|
44 |
/**
|
|
45 |
* Feedback customization support
|
|
46 |
*
|
|
47 |
* @author Robert Field
|
|
48 |
*/
|
|
49 |
class Feedback {
|
|
50 |
|
|
51 |
// Patern for substituted fields within a customized format string
|
|
52 |
private static final Pattern FIELD_PATTERN = Pattern.compile("\\{(.*?)\\}");
|
|
53 |
|
|
54 |
// Current mode
|
|
55 |
private Mode mode = new Mode("", false); // initial value placeholder during start-up
|
|
56 |
|
|
57 |
// Mapping of mode names to mode modes
|
|
58 |
private final Map<String, Mode> modeMap = new HashMap<>();
|
|
59 |
|
|
60 |
public boolean shouldDisplayCommandFluff() {
|
|
61 |
return mode.commandFluff;
|
|
62 |
}
|
|
63 |
|
|
64 |
public String getPre() {
|
|
65 |
return mode.pre;
|
|
66 |
}
|
|
67 |
|
|
68 |
public String getPost() {
|
|
69 |
return mode.post;
|
|
70 |
}
|
|
71 |
|
|
72 |
public String getErrorPre() {
|
|
73 |
return mode.errorPre;
|
|
74 |
}
|
|
75 |
|
|
76 |
public String getErrorPost() {
|
|
77 |
return mode.errorPost;
|
|
78 |
}
|
|
79 |
|
|
80 |
public String getFormat(FormatCase fc, FormatWhen fw, FormatAction fa, FormatResolve fr,
|
|
81 |
boolean hasName, boolean hasType, boolean hasResult) {
|
|
82 |
return mode.getFormat(fc, fw, fa, fr, hasName, hasType, hasResult);
|
|
83 |
}
|
|
84 |
|
|
85 |
public String getPrompt(String nextId) {
|
|
86 |
return mode.getPrompt(nextId);
|
|
87 |
}
|
|
88 |
|
|
89 |
public String getContinuationPrompt(String nextId) {
|
|
90 |
return mode.getContinuationPrompt(nextId);
|
|
91 |
}
|
|
92 |
|
|
93 |
public boolean setFeedback(JShellTool tool, ArgTokenizer at) {
|
|
94 |
return new FormatSetter(tool, at).setFeedback();
|
|
95 |
}
|
|
96 |
|
|
97 |
public boolean setField(JShellTool tool, ArgTokenizer at) {
|
|
98 |
return new FormatSetter(tool, at).setField();
|
|
99 |
}
|
|
100 |
|
|
101 |
public boolean setFormat(JShellTool tool, ArgTokenizer at) {
|
|
102 |
return new FormatSetter(tool, at).setFormat();
|
|
103 |
}
|
|
104 |
|
|
105 |
public boolean setNewMode(JShellTool tool, ArgTokenizer at) {
|
|
106 |
return new FormatSetter(tool, at).setNewMode();
|
|
107 |
}
|
|
108 |
|
|
109 |
public boolean setPrompt(JShellTool tool, ArgTokenizer at) {
|
|
110 |
return new FormatSetter(tool, at).setPrompt();
|
|
111 |
}
|
|
112 |
|
|
113 |
public void printFeedbackHelp(JShellTool tool) {
|
|
114 |
new FormatSetter(tool, null).printFeedbackHelp();
|
|
115 |
}
|
|
116 |
|
|
117 |
public void printFieldHelp(JShellTool tool) {
|
|
118 |
new FormatSetter(tool, null).printFieldHelp();
|
|
119 |
}
|
|
120 |
|
|
121 |
public void printFormatHelp(JShellTool tool) {
|
|
122 |
new FormatSetter(tool, null).printFormatHelp();
|
|
123 |
}
|
|
124 |
|
|
125 |
public void printNewModeHelp(JShellTool tool) {
|
|
126 |
new FormatSetter(tool, null).printNewModeHelp();
|
|
127 |
}
|
|
128 |
|
|
129 |
public void printPromptHelp(JShellTool tool) {
|
|
130 |
new FormatSetter(tool, null).printPromptHelp();
|
|
131 |
}
|
|
132 |
|
|
133 |
/**
|
|
134 |
* Holds all the context of a mode mode
|
|
135 |
*/
|
|
136 |
private class Mode {
|
|
137 |
|
|
138 |
// Use name of mode mode
|
|
139 |
|
|
140 |
final String name;
|
|
141 |
|
|
142 |
// Display command verification/information
|
|
143 |
final boolean commandFluff;
|
|
144 |
|
|
145 |
// event cases: class, method
|
|
146 |
final EnumMap<FormatCase, EnumMap<FormatAction, EnumMap<FormatWhen, String>>> cases;
|
|
147 |
|
|
148 |
// action names: add. modified, replaced, ...
|
|
149 |
final EnumMap<FormatAction, EnumMap<FormatWhen, String>> actions;
|
|
150 |
|
|
151 |
// resolution status description format with %s for unresolved
|
|
152 |
final EnumMap<FormatResolve, EnumMap<FormatWhen, String>> resolves;
|
|
153 |
|
|
154 |
// primary snippet vs update
|
|
155 |
final EnumMap<FormatWhen, String> whens;
|
|
156 |
|
|
157 |
// fixed map of how to get format string for a field, given a specific formatting contet
|
|
158 |
final EnumMap<FormatField, Function<Context, String>> fields;
|
|
159 |
|
|
160 |
// format wrappers for name, type, and result
|
|
161 |
String fname = "%s";
|
|
162 |
String ftype = "%s";
|
|
163 |
String fresult = "%s";
|
|
164 |
|
|
165 |
// start and end, also used by hard-coded output
|
|
166 |
String pre = "| ";
|
|
167 |
String post = "\n";
|
|
168 |
String errorPre = "| Error: ";
|
|
169 |
String errorPost = "\n";
|
|
170 |
|
|
171 |
String prompt = "\n-> ";
|
|
172 |
String continuationPrompt = ">> ";
|
|
173 |
|
|
174 |
/**
|
|
175 |
* The context of a specific mode to potentially display.
|
|
176 |
*/
|
|
177 |
class Context {
|
|
178 |
|
|
179 |
final FormatCase fc;
|
|
180 |
final FormatAction fa;
|
|
181 |
final FormatResolve fr;
|
|
182 |
final FormatWhen fw;
|
|
183 |
final boolean hasName;
|
|
184 |
final boolean hasType;
|
|
185 |
final boolean hasResult;
|
|
186 |
|
|
187 |
Context(FormatCase fc, FormatWhen fw, FormatAction fa, FormatResolve fr,
|
|
188 |
boolean hasName, boolean hasType, boolean hasResult) {
|
|
189 |
this.fc = fc;
|
|
190 |
this.fa = fa;
|
|
191 |
this.fr = fr;
|
|
192 |
this.fw = fw;
|
|
193 |
this.hasName = hasName;
|
|
194 |
this.hasType = hasType;
|
|
195 |
this.hasResult = hasResult;
|
|
196 |
}
|
|
197 |
|
|
198 |
String when() {
|
|
199 |
return whens.get(fw);
|
|
200 |
}
|
|
201 |
|
|
202 |
String action() {
|
|
203 |
return actions.get(fa).get(fw);
|
|
204 |
}
|
|
205 |
|
|
206 |
String resolve() {
|
|
207 |
return String.format(resolves.get(fr).get(fw), FormatField.RESOLVE.form);
|
|
208 |
}
|
|
209 |
|
|
210 |
String name() {
|
|
211 |
return hasName
|
|
212 |
? String.format(fname, FormatField.NAME.form)
|
|
213 |
: "";
|
|
214 |
}
|
|
215 |
|
|
216 |
String type() {
|
|
217 |
return hasType
|
|
218 |
? String.format(ftype, FormatField.TYPE.form)
|
|
219 |
: "";
|
|
220 |
}
|
|
221 |
|
|
222 |
String result() {
|
|
223 |
return hasResult
|
|
224 |
? String.format(fresult, FormatField.RESULT.form)
|
|
225 |
: "";
|
|
226 |
}
|
|
227 |
|
|
228 |
/**
|
|
229 |
* Lookup format based on case, action, and whether it update.
|
|
230 |
* Replace fields with context specific formats.
|
|
231 |
*
|
|
232 |
* @return format string
|
|
233 |
*/
|
|
234 |
String format() {
|
|
235 |
String format = cases.get(fc).get(fa).get(fw);
|
|
236 |
if (format == null) {
|
|
237 |
return "";
|
|
238 |
}
|
|
239 |
Matcher m = FIELD_PATTERN.matcher(format);
|
|
240 |
StringBuffer sb = new StringBuffer(format.length());
|
|
241 |
while (m.find()) {
|
|
242 |
String fieldName = m.group(1).toUpperCase(Locale.US);
|
|
243 |
String sub = null;
|
|
244 |
for (FormatField f : FormatField.values()) {
|
|
245 |
if (f.name().startsWith(fieldName)) {
|
|
246 |
sub = fields.get(f).apply(this);
|
|
247 |
break;
|
|
248 |
}
|
|
249 |
}
|
|
250 |
if (sub != null) {
|
|
251 |
m.appendReplacement(sb, Matcher.quoteReplacement(sub));
|
|
252 |
}
|
|
253 |
}
|
|
254 |
m.appendTail(sb);
|
|
255 |
return sb.toString();
|
|
256 |
}
|
|
257 |
}
|
|
258 |
|
|
259 |
{
|
|
260 |
// set fixed mappings of fields
|
|
261 |
fields = new EnumMap<>(FormatField.class);
|
|
262 |
fields.put(FormatField.WHEN, c -> c.when());
|
|
263 |
fields.put(FormatField.ACTION, c -> c.action());
|
|
264 |
fields.put(FormatField.RESOLVE, c -> c.resolve());
|
|
265 |
fields.put(FormatField.NAME, c -> c.name());
|
|
266 |
fields.put(FormatField.TYPE, c -> c.type());
|
|
267 |
fields.put(FormatField.RESULT, c -> c.result());
|
|
268 |
fields.put(FormatField.PRE, c -> pre);
|
|
269 |
fields.put(FormatField.POST, c -> post);
|
|
270 |
fields.put(FormatField.ERRORPRE, c -> errorPre);
|
|
271 |
fields.put(FormatField.ERRORPOST, c -> errorPost);
|
|
272 |
}
|
|
273 |
|
|
274 |
/**
|
|
275 |
* Set up an empty mode.
|
|
276 |
*
|
|
277 |
* @param name
|
|
278 |
* @param commandFluff True if should display command fluff messages
|
|
279 |
*/
|
|
280 |
Mode(String name, boolean commandFluff) {
|
|
281 |
this.name = name;
|
|
282 |
this.commandFluff = commandFluff;
|
|
283 |
cases = new EnumMap<>(FormatCase.class);
|
|
284 |
for (FormatCase fc : FormatCase.values()) {
|
|
285 |
EnumMap<FormatAction, EnumMap<FormatWhen, String>> ac = new EnumMap<>(FormatAction.class);
|
|
286 |
cases.put(fc, ac);
|
|
287 |
for (FormatAction fa : FormatAction.values()) {
|
|
288 |
EnumMap<FormatWhen, String> aw = new EnumMap<>(FormatWhen.class);
|
|
289 |
ac.put(fa, aw);
|
|
290 |
for (FormatWhen fw : FormatWhen.values()) {
|
|
291 |
aw.put(fw, "");
|
|
292 |
}
|
|
293 |
}
|
|
294 |
}
|
|
295 |
|
|
296 |
actions = new EnumMap<>(FormatAction.class);
|
|
297 |
for (FormatAction fa : FormatAction.values()) {
|
|
298 |
EnumMap<FormatWhen, String> afw = new EnumMap<>(FormatWhen.class);
|
|
299 |
actions.put(fa, afw);
|
|
300 |
for (FormatWhen fw : FormatWhen.values()) {
|
|
301 |
afw.put(fw, fa.name() + "-" + fw.name());
|
|
302 |
}
|
|
303 |
}
|
|
304 |
|
|
305 |
resolves = new EnumMap<>(FormatResolve.class);
|
|
306 |
for (FormatResolve fr : FormatResolve.values()) {
|
|
307 |
EnumMap<FormatWhen, String> arw = new EnumMap<>(FormatWhen.class);
|
|
308 |
resolves.put(fr, arw);
|
|
309 |
for (FormatWhen fw : FormatWhen.values()) {
|
|
310 |
arw.put(fw, fr.name() + "-" + fw.name() + ": %s");
|
|
311 |
}
|
|
312 |
}
|
|
313 |
|
|
314 |
whens = new EnumMap<>(FormatWhen.class);
|
|
315 |
for (FormatWhen fw : FormatWhen.values()) {
|
|
316 |
whens.put(fw, fw.name());
|
|
317 |
}
|
|
318 |
}
|
|
319 |
|
|
320 |
/**
|
|
321 |
* Set up a copied mode.
|
|
322 |
*
|
|
323 |
* @param name
|
|
324 |
* @param commandFluff True if should display command fluff messages
|
|
325 |
* @param m Mode to copy
|
|
326 |
*/
|
|
327 |
Mode(String name, boolean commandFluff, Mode m) {
|
|
328 |
this.name = name;
|
|
329 |
this.commandFluff = commandFluff;
|
|
330 |
cases = new EnumMap<>(FormatCase.class);
|
|
331 |
for (FormatCase fc : FormatCase.values()) {
|
|
332 |
EnumMap<FormatAction, EnumMap<FormatWhen, String>> ac = new EnumMap<>(FormatAction.class);
|
|
333 |
EnumMap<FormatAction, EnumMap<FormatWhen, String>> mc = m.cases.get(fc);
|
|
334 |
cases.put(fc, ac);
|
|
335 |
for (FormatAction fa : FormatAction.values()) {
|
|
336 |
EnumMap<FormatWhen, String> aw = new EnumMap<>(mc.get(fa));
|
|
337 |
ac.put(fa, aw);
|
|
338 |
}
|
|
339 |
}
|
|
340 |
|
|
341 |
actions = new EnumMap<>(FormatAction.class);
|
|
342 |
for (FormatAction fa : FormatAction.values()) {
|
|
343 |
EnumMap<FormatWhen, String> afw = new EnumMap<>(m.actions.get(fa));
|
|
344 |
actions.put(fa, afw);
|
|
345 |
}
|
|
346 |
|
|
347 |
resolves = new EnumMap<>(FormatResolve.class);
|
|
348 |
for (FormatResolve fr : FormatResolve.values()) {
|
|
349 |
EnumMap<FormatWhen, String> arw = new EnumMap<>(m.resolves.get(fr));
|
|
350 |
resolves.put(fr, arw);
|
|
351 |
}
|
|
352 |
|
|
353 |
whens = new EnumMap<>(m.whens);
|
|
354 |
|
|
355 |
this.fname = m.fname;
|
|
356 |
this.ftype = m.ftype;
|
|
357 |
this.fresult = m.fresult;
|
|
358 |
this.pre = m.pre;
|
|
359 |
this.post = m.post;
|
|
360 |
this.errorPre = m.errorPre;
|
|
361 |
this.errorPost = m.errorPost;
|
|
362 |
this.prompt = m.prompt;
|
|
363 |
this.continuationPrompt = m.continuationPrompt;
|
|
364 |
}
|
|
365 |
|
|
366 |
String getFormat(FormatCase fc, FormatWhen fw, FormatAction fa, FormatResolve fr,
|
|
367 |
boolean hasName, boolean hasType, boolean hasResult) {
|
|
368 |
Context context = new Context(fc, fw, fa, fr,
|
|
369 |
hasName, hasType, hasResult);
|
|
370 |
return context.format();
|
|
371 |
}
|
|
372 |
|
|
373 |
void setCases(String format, Collection<FormatCase> cc, Collection<FormatAction> ca, Collection<FormatWhen> cw) {
|
|
374 |
for (FormatCase fc : cc) {
|
|
375 |
EnumMap<FormatAction, EnumMap<FormatWhen, String>> ma = cases.get(fc);
|
|
376 |
for (FormatAction fa : ca) {
|
|
377 |
EnumMap<FormatWhen, String> mw = ma.get(fa);
|
|
378 |
for (FormatWhen fw : cw) {
|
|
379 |
mw.put(fw, format);
|
|
380 |
}
|
|
381 |
}
|
|
382 |
}
|
|
383 |
}
|
|
384 |
|
|
385 |
void setActions(String format, Collection<FormatAction> ca, Collection<FormatWhen> cw) {
|
|
386 |
for (FormatAction fa : ca) {
|
|
387 |
EnumMap<FormatWhen, String> mw = actions.get(fa);
|
|
388 |
for (FormatWhen fw : cw) {
|
|
389 |
mw.put(fw, format);
|
|
390 |
}
|
|
391 |
}
|
|
392 |
}
|
|
393 |
|
|
394 |
void setResolves(String format, Collection<FormatResolve> cr, Collection<FormatWhen> cw) {
|
|
395 |
for (FormatResolve fr : cr) {
|
|
396 |
EnumMap<FormatWhen, String> mw = resolves.get(fr);
|
|
397 |
for (FormatWhen fw : cw) {
|
|
398 |
mw.put(fw, format);
|
|
399 |
}
|
|
400 |
}
|
|
401 |
}
|
|
402 |
|
|
403 |
void setWhens(String format, Collection<FormatWhen> cw) {
|
|
404 |
for (FormatWhen fw : cw) {
|
|
405 |
whens.put(fw, format);
|
|
406 |
}
|
|
407 |
}
|
|
408 |
|
|
409 |
void setName(String s) {
|
|
410 |
fname = s;
|
|
411 |
}
|
|
412 |
|
|
413 |
void setType(String s) {
|
|
414 |
ftype = s;
|
|
415 |
}
|
|
416 |
|
|
417 |
void setResult(String s) {
|
|
418 |
fresult = s;
|
|
419 |
}
|
|
420 |
|
|
421 |
void setPre(String s) {
|
|
422 |
pre = s;
|
|
423 |
}
|
|
424 |
|
|
425 |
void setPost(String s) {
|
|
426 |
post = s;
|
|
427 |
}
|
|
428 |
|
|
429 |
void setErrorPre(String s) {
|
|
430 |
errorPre = s;
|
|
431 |
}
|
|
432 |
|
|
433 |
void setErrorPost(String s) {
|
|
434 |
errorPost = s;
|
|
435 |
}
|
|
436 |
|
|
437 |
String getPre() {
|
|
438 |
return pre;
|
|
439 |
}
|
|
440 |
|
|
441 |
String getPost() {
|
|
442 |
return post;
|
|
443 |
}
|
|
444 |
|
|
445 |
String getErrorPre() {
|
|
446 |
return errorPre;
|
|
447 |
}
|
|
448 |
|
|
449 |
String getErrorPost() {
|
|
450 |
return errorPost;
|
|
451 |
}
|
|
452 |
|
|
453 |
void setPrompts(String prompt, String continuationPrompt) {
|
|
454 |
this.prompt = prompt;
|
|
455 |
this.continuationPrompt = continuationPrompt;
|
|
456 |
}
|
|
457 |
|
|
458 |
String getPrompt(String nextId) {
|
|
459 |
return String.format(prompt, nextId);
|
|
460 |
}
|
|
461 |
|
|
462 |
String getContinuationPrompt(String nextId) {
|
|
463 |
return String.format(continuationPrompt, nextId);
|
|
464 |
}
|
|
465 |
}
|
|
466 |
|
|
467 |
/**
|
|
468 |
* The brace delimited substitutions
|
|
469 |
*/
|
|
470 |
public enum FormatField {
|
|
471 |
WHEN,
|
|
472 |
ACTION,
|
|
473 |
RESOLVE("%1$s"),
|
|
474 |
NAME("%2$s"),
|
|
475 |
TYPE("%3$s"),
|
|
476 |
RESULT("%4$s"),
|
|
477 |
PRE,
|
|
478 |
POST,
|
|
479 |
ERRORPRE,
|
|
480 |
ERRORPOST;
|
|
481 |
String form;
|
|
482 |
|
|
483 |
FormatField(String s) {
|
|
484 |
this.form = s;
|
|
485 |
}
|
|
486 |
|
|
487 |
FormatField() {
|
|
488 |
this.form = null;
|
|
489 |
}
|
|
490 |
}
|
|
491 |
|
|
492 |
/**
|
|
493 |
* The event cases
|
|
494 |
*/
|
|
495 |
public enum FormatCase {
|
|
496 |
IMPORT("import declaration: {action} {name}"),
|
|
497 |
CLASS("class, interface, enum, or annotation declaration: {action} {name} {resolve}"),
|
|
498 |
INTERFACE("class, interface, enum, or annotation declaration: {action} {name} {resolve}"),
|
|
499 |
ENUM("class, interface, enum, or annotation declaration: {action} {name} {resolve}"),
|
|
500 |
ANNOTATION("annotation interface declaration: {action} {name} {resolve}"),
|
|
501 |
METHOD("method declaration: {action} {name} {type}==parameter-types {resolve}"),
|
|
502 |
VARDECL("variable declaration: {action} {name} {type} {resolve}"),
|
|
503 |
VARDECLRECOVERABLE("recoverably failed variable declaration: {action} {name} {resolve}"),
|
|
504 |
VARINIT("variable declaration with init: {action} {name} {type} {resolve} {result}"),
|
|
505 |
VARRESET("variable reset on update: {action} {name}"),
|
|
506 |
EXPRESSION("expression: {action}=='Saved to scratch variable' {name} {type} {result}"),
|
|
507 |
VARVALUE("variable value expression: {action} {name} {type} {result}"),
|
|
508 |
ASSIGNMENT("assign variable: {action} {name} {type} {result}"),
|
|
509 |
STATEMENT("statement: {action}");
|
|
510 |
String doc;
|
|
511 |
|
|
512 |
private FormatCase(String doc) {
|
|
513 |
this.doc = doc;
|
|
514 |
}
|
|
515 |
}
|
|
516 |
|
|
517 |
/**
|
|
518 |
* The event actions
|
|
519 |
*/
|
|
520 |
public enum FormatAction {
|
|
521 |
ADDED("snippet has been added"),
|
|
522 |
MODIFIED("an existing snippet has been modified"),
|
|
523 |
REPLACED("an existing snippet has been replaced with a new snippet"),
|
|
524 |
OVERWROTE("an existing snippet has been overwritten"),
|
|
525 |
DROPPED("snippet has been dropped"),
|
|
526 |
REJECTED("snippet has failed and been rejected");
|
|
527 |
String doc;
|
|
528 |
|
|
529 |
private FormatAction(String doc) {
|
|
530 |
this.doc = doc;
|
|
531 |
}
|
|
532 |
}
|
|
533 |
|
|
534 |
/**
|
|
535 |
* When the event occurs: primary or update
|
|
536 |
*/
|
|
537 |
public enum FormatWhen {
|
|
538 |
PRIMARY("the entered snippet"),
|
|
539 |
UPDATE("an update to a dependent snippet");
|
|
540 |
String doc;
|
|
541 |
|
|
542 |
private FormatWhen(String doc) {
|
|
543 |
this.doc = doc;
|
|
544 |
}
|
|
545 |
}
|
|
546 |
|
|
547 |
/**
|
|
548 |
* Resolution problems with event
|
|
549 |
*/
|
|
550 |
public enum FormatResolve {
|
|
551 |
OK("resolved correctly"),
|
|
552 |
DEFINED("defined despite recoverably unresolved references"),
|
|
553 |
NOTDEFINED("not defined because of recoverably unresolved references");
|
|
554 |
String doc;
|
|
555 |
|
|
556 |
private FormatResolve(String doc) {
|
|
557 |
this.doc = doc;
|
|
558 |
}
|
|
559 |
}
|
|
560 |
|
|
561 |
// Class used to set custom eval output formats
|
|
562 |
// For both /set format and /set field -- Parse arguments, setting custom format, or printing error
|
|
563 |
private class FormatSetter {
|
|
564 |
|
|
565 |
private final ArgTokenizer at;
|
|
566 |
private final JShellTool tool;
|
|
567 |
boolean valid = true;
|
|
568 |
|
|
569 |
class Case<E1 extends Enum<E1>, E2 extends Enum<E2>, E3 extends Enum<E3>> {
|
|
570 |
|
|
571 |
Set<E1> e1;
|
|
572 |
Set<E2> e2;
|
|
573 |
Set<E3> e3;
|
|
574 |
|
|
575 |
Case(Set<E1> e1, Set<E2> e2, Set<E3> e3) {
|
|
576 |
this.e1 = e1;
|
|
577 |
this.e2 = e2;
|
|
578 |
this.e3 = e3;
|
|
579 |
}
|
|
580 |
|
|
581 |
Case(Set<E1> e1, Set<E2> e2) {
|
|
582 |
this.e1 = e1;
|
|
583 |
this.e2 = e2;
|
|
584 |
}
|
|
585 |
}
|
|
586 |
|
|
587 |
FormatSetter(JShellTool tool, ArgTokenizer at) {
|
|
588 |
this.tool = tool;
|
|
589 |
this.at = at;
|
|
590 |
}
|
|
591 |
|
|
592 |
void hard(String format, Object... args) {
|
|
593 |
tool.hard(format, args);
|
|
594 |
}
|
|
595 |
|
|
596 |
<E extends Enum<E>> void hardEnums(EnumSet<E> es, Function<E, String> e2s) {
|
|
597 |
hardPairs(es.stream(), ev -> ev.name().toLowerCase(Locale.US), e2s);
|
|
598 |
}
|
|
599 |
|
|
600 |
<T> void hardPairs(Stream<T> stream, Function<T, String> a, Function<T, String> b) {
|
|
601 |
tool.hardPairs(stream, a, b);
|
|
602 |
}
|
|
603 |
|
|
604 |
void fluff(String format, Object... args) {
|
|
605 |
tool.fluff(format, args);
|
|
606 |
}
|
|
607 |
|
|
608 |
void error(String format, Object... args) {
|
|
609 |
tool.error(format, args);
|
|
610 |
}
|
|
611 |
|
|
612 |
void errorat(String format, Object... args) {
|
|
613 |
Object[] a2 = Arrays.copyOf(args, args.length + 1);
|
|
614 |
a2[args.length] = at.whole();
|
|
615 |
tool.error(format + " -- /set %s", a2);
|
|
616 |
}
|
|
617 |
|
|
618 |
void fluffRaw(String format, Object... args) {
|
|
619 |
tool.fluffRaw(format, args);
|
|
620 |
}
|
|
621 |
|
|
622 |
// For /set prompt <mode> "<prompt>" "<continuation-prompt>"
|
|
623 |
boolean setPrompt() {
|
|
624 |
Mode m = nextMode();
|
|
625 |
String prompt = nextFormat();
|
|
626 |
String continuationPrompt = nextFormat();
|
|
627 |
if (valid) {
|
|
628 |
m.setPrompts(prompt, continuationPrompt);
|
|
629 |
} else {
|
|
630 |
fluff("See '/help /set prompt' for help");
|
|
631 |
}
|
|
632 |
return valid;
|
|
633 |
}
|
|
634 |
|
|
635 |
// For /set newmode <new-mode> [command|quiet [<old-mode>]]
|
|
636 |
boolean setNewMode() {
|
|
637 |
String umode = at.next();
|
|
638 |
if (umode == null) {
|
|
639 |
errorat("Expected new feedback mode");
|
|
640 |
valid = false;
|
|
641 |
}
|
|
642 |
if (modeMap.containsKey(umode)) {
|
|
643 |
errorat("Expected a new feedback mode name. %s is a known feedback mode", umode);
|
|
644 |
valid = false;
|
|
645 |
}
|
|
646 |
String[] fluffOpt = at.next("command", "quiet");
|
|
647 |
boolean fluff = fluffOpt == null || fluffOpt.length != 1 || "command".equals(fluffOpt[0]);
|
|
648 |
if (fluffOpt != null && fluffOpt.length != 1) {
|
|
649 |
errorat("Specify either 'command' or 'quiet'");
|
|
650 |
valid = false;
|
|
651 |
}
|
|
652 |
Mode om = null;
|
|
653 |
String omode = at.next();
|
|
654 |
if (omode != null) {
|
|
655 |
om = toMode(omode);
|
|
656 |
}
|
|
657 |
if (valid) {
|
|
658 |
Mode nm = (om != null)
|
|
659 |
? new Mode(umode, fluff, om)
|
|
660 |
: new Mode(umode, fluff);
|
|
661 |
modeMap.put(umode, nm);
|
|
662 |
fluff("Created new feedback mode: %s", nm.name);
|
|
663 |
} else {
|
|
664 |
fluff("See '/help /set newmode' for help");
|
|
665 |
}
|
|
666 |
return valid;
|
|
667 |
}
|
|
668 |
|
|
669 |
// For /set feedback <mode>
|
|
670 |
boolean setFeedback() {
|
|
671 |
Mode m = nextMode();
|
|
672 |
if (valid && m != null) {
|
|
673 |
mode = m;
|
|
674 |
fluff("Feedback mode: %s", mode.name);
|
|
675 |
} else {
|
|
676 |
fluff("See '/help /set feedback' for help");
|
|
677 |
}
|
|
678 |
return valid;
|
|
679 |
}
|
|
680 |
|
|
681 |
// For /set format <mode> "<format>" <selector>...
|
|
682 |
boolean setFormat() {
|
|
683 |
Mode m = nextMode();
|
|
684 |
String format = nextFormat();
|
|
685 |
if (valid) {
|
|
686 |
List<Case<FormatCase, FormatAction, FormatWhen>> specs = new ArrayList<>();
|
|
687 |
String s;
|
|
688 |
while ((s = at.next()) != null) {
|
|
689 |
String[] d = s.split("-");
|
|
690 |
specs.add(new Case<>(
|
|
691 |
parseFormatCase(d, 0),
|
|
692 |
parseFormatAction(d, 1),
|
|
693 |
parseFormatWhen(d, 2)
|
|
694 |
));
|
|
695 |
}
|
|
696 |
if (valid && specs.isEmpty()) {
|
|
697 |
errorat("At least one selector required");
|
|
698 |
valid = false;
|
|
699 |
}
|
|
700 |
if (valid) {
|
|
701 |
// set the format in the specified cases
|
|
702 |
specs.stream()
|
|
703 |
.forEach(c -> m.setCases(format, c.e1, c.e2, c.e3));
|
|
704 |
}
|
|
705 |
}
|
|
706 |
if (!valid) {
|
|
707 |
fluff("See '/help /set format' for help");
|
|
708 |
}
|
|
709 |
return valid;
|
|
710 |
}
|
|
711 |
|
|
712 |
// For /set field mode <field> "<format>" <selector>...
|
|
713 |
boolean setField() {
|
|
714 |
Mode m = nextMode();
|
|
715 |
String fieldName = at.next();
|
|
716 |
FormatField field = parseFormatSelector(fieldName, EnumSet.allOf(FormatField.class), "field");
|
|
717 |
String format = nextFormat();
|
|
718 |
if (valid) {
|
|
719 |
switch (field) {
|
|
720 |
case ACTION: {
|
|
721 |
List<Case<FormatAction, FormatWhen, FormatWhen>> specs = new ArrayList<>();
|
|
722 |
String s;
|
|
723 |
while ((s = at.next()) != null) {
|
|
724 |
String[] d = s.split("-");
|
|
725 |
specs.add(new Case<>(
|
|
726 |
parseFormatAction(d, 0),
|
|
727 |
parseFormatWhen(d, 1)
|
|
728 |
));
|
|
729 |
}
|
|
730 |
if (valid && specs.isEmpty()) {
|
|
731 |
errorat("At least one selector required");
|
|
732 |
valid = false;
|
|
733 |
}
|
|
734 |
if (valid) {
|
|
735 |
// set the format of the specified actions
|
|
736 |
specs.stream()
|
|
737 |
.forEach(c -> m.setActions(format, c.e1, c.e2));
|
|
738 |
}
|
|
739 |
break;
|
|
740 |
}
|
|
741 |
case RESOLVE: {
|
|
742 |
List<Case<FormatResolve, FormatWhen, FormatWhen>> specs = new ArrayList<>();
|
|
743 |
String s;
|
|
744 |
while ((s = at.next()) != null) {
|
|
745 |
String[] d = s.split("-");
|
|
746 |
specs.add(new Case<>(
|
|
747 |
parseFormatResolve(d, 0),
|
|
748 |
parseFormatWhen(d, 1)
|
|
749 |
));
|
|
750 |
}
|
|
751 |
if (valid && specs.isEmpty()) {
|
|
752 |
errorat("At least one selector required");
|
|
753 |
valid = false;
|
|
754 |
}
|
|
755 |
if (valid) {
|
|
756 |
// set the format of the specified resolves
|
|
757 |
specs.stream()
|
|
758 |
.forEach(c -> m.setResolves(format, c.e1, c.e2));
|
|
759 |
}
|
|
760 |
break;
|
|
761 |
}
|
|
762 |
case WHEN: {
|
|
763 |
List<Case<FormatWhen, FormatWhen, FormatWhen>> specs = new ArrayList<>();
|
|
764 |
String s;
|
|
765 |
while ((s = at.next()) != null) {
|
|
766 |
String[] d = s.split("-");
|
|
767 |
specs.add(new Case<>(
|
|
768 |
parseFormatWhen(d, 1),
|
|
769 |
null
|
|
770 |
));
|
|
771 |
}
|
|
772 |
if (valid && specs.isEmpty()) {
|
|
773 |
errorat("At least one selector required");
|
|
774 |
valid = false;
|
|
775 |
}
|
|
776 |
if (valid) {
|
|
777 |
// set the format of the specified whens
|
|
778 |
specs.stream()
|
|
779 |
.forEach(c -> m.setWhens(format, c.e1));
|
|
780 |
}
|
|
781 |
break;
|
|
782 |
}
|
|
783 |
case NAME: {
|
|
784 |
m.setName(format);
|
|
785 |
break;
|
|
786 |
}
|
|
787 |
case TYPE: {
|
|
788 |
m.setType(format);
|
|
789 |
break;
|
|
790 |
}
|
|
791 |
case RESULT: {
|
|
792 |
m.setResult(format);
|
|
793 |
break;
|
|
794 |
}
|
|
795 |
case PRE: {
|
|
796 |
m.setPre(format);
|
|
797 |
break;
|
|
798 |
}
|
|
799 |
case POST: {
|
|
800 |
m.setPost(format);
|
|
801 |
break;
|
|
802 |
}
|
|
803 |
case ERRORPRE: {
|
|
804 |
m.setErrorPre(format);
|
|
805 |
break;
|
|
806 |
}
|
|
807 |
case ERRORPOST: {
|
|
808 |
m.setErrorPost(format);
|
|
809 |
break;
|
|
810 |
}
|
|
811 |
}
|
|
812 |
}
|
|
813 |
if (!valid) {
|
|
814 |
fluff("See '/help /set field' for help");
|
|
815 |
}
|
|
816 |
return valid;
|
|
817 |
}
|
|
818 |
|
|
819 |
Mode nextMode() {
|
|
820 |
String umode = at.next();
|
|
821 |
return toMode(umode);
|
|
822 |
}
|
|
823 |
|
|
824 |
Mode toMode(String umode) {
|
|
825 |
if (umode == null) {
|
|
826 |
errorat("Expected a feedback mode");
|
|
827 |
valid = false;
|
|
828 |
return null;
|
|
829 |
}
|
|
830 |
Mode m = modeMap.get(umode);
|
|
831 |
if (m != null) {
|
|
832 |
return m;
|
|
833 |
}
|
|
834 |
// Failing an exact match, go searching
|
|
835 |
Mode[] matches = modeMap.entrySet().stream()
|
|
836 |
.filter(e -> e.getKey().startsWith(umode))
|
|
837 |
.map(e -> e.getValue())
|
|
838 |
.toArray(size -> new Mode[size]);
|
|
839 |
if (matches.length == 1) {
|
|
840 |
return matches[0];
|
|
841 |
} else {
|
|
842 |
valid = false;
|
|
843 |
if (matches.length == 0) {
|
|
844 |
errorat("Does not match any current feedback mode: %s", umode);
|
|
845 |
} else {
|
|
846 |
errorat("Matchs more then one current feedback mode: %s", umode);
|
|
847 |
}
|
|
848 |
fluff("The feedback mode should be one of the following:");
|
|
849 |
modeMap.keySet().stream()
|
|
850 |
.forEach(mk -> fluff(" %s", mk));
|
|
851 |
fluff("You may also use just enough letters to make it unique.");
|
|
852 |
return null;
|
|
853 |
}
|
|
854 |
}
|
|
855 |
|
|
856 |
// Test if the format string is correctly
|
|
857 |
final String nextFormat() {
|
|
858 |
String format = at.next();
|
|
859 |
if (format == null) {
|
|
860 |
errorat("Expected format missing");
|
|
861 |
valid = false;
|
|
862 |
return null;
|
|
863 |
}
|
|
864 |
if (!at.isQuoted()) {
|
|
865 |
errorat("Format '%s' must be quoted", format);
|
|
866 |
valid = false;
|
|
867 |
return null;
|
|
868 |
}
|
|
869 |
return format;
|
|
870 |
}
|
|
871 |
|
|
872 |
final Set<FormatCase> parseFormatCase(String[] s, int i) {
|
|
873 |
return parseFormatSelectorStar(s, i, FormatCase.class, EnumSet.allOf(FormatCase.class), "case");
|
|
874 |
}
|
|
875 |
|
|
876 |
final Set<FormatAction> parseFormatAction(String[] s, int i) {
|
|
877 |
return parseFormatSelectorStar(s, i, FormatAction.class,
|
|
878 |
EnumSet.of(FormatAction.ADDED, FormatAction.MODIFIED, FormatAction.REPLACED), "action");
|
|
879 |
}
|
|
880 |
|
|
881 |
final Set<FormatResolve> parseFormatResolve(String[] s, int i) {
|
|
882 |
return parseFormatSelectorStar(s, i, FormatResolve.class,
|
|
883 |
EnumSet.of(FormatResolve.DEFINED, FormatResolve.NOTDEFINED), "resolve");
|
|
884 |
}
|
|
885 |
|
|
886 |
final Set<FormatWhen> parseFormatWhen(String[] s, int i) {
|
|
887 |
return parseFormatSelectorStar(s, i, FormatWhen.class, EnumSet.of(FormatWhen.PRIMARY), "when");
|
|
888 |
}
|
|
889 |
|
|
890 |
/**
|
|
891 |
* In a selector x-y-z , parse x, y, or z -- whether they are missing,
|
|
892 |
* or a comma separated list of identifiers and stars.
|
|
893 |
*
|
|
894 |
* @param <E> The enum this selector should belong to
|
|
895 |
* @param sa The array of selector strings
|
|
896 |
* @param i The index of which selector string to use
|
|
897 |
* @param klass The class of the enum that should be used
|
|
898 |
* @param defaults The set of enum values to use if the selector is
|
|
899 |
* missing
|
|
900 |
* @return The set of enum values specified by this selector
|
|
901 |
*/
|
|
902 |
final <E extends Enum<E>> Set<E> parseFormatSelectorStar(String[] sa, int i, Class<E> klass, EnumSet<E> defaults, String label) {
|
|
903 |
String s = sa.length > i
|
|
904 |
? sa[i]
|
|
905 |
: null;
|
|
906 |
if (s == null || s.isEmpty()) {
|
|
907 |
return defaults;
|
|
908 |
}
|
|
909 |
Set<E> set = EnumSet.noneOf(klass);
|
|
910 |
EnumSet<E> values = EnumSet.allOf(klass);
|
|
911 |
for (String as : s.split(",")) {
|
|
912 |
if (as.equals("*")) {
|
|
913 |
set.addAll(values);
|
|
914 |
} else if (!as.isEmpty()) {
|
|
915 |
set.add(parseFormatSelector(as, values, label));
|
|
916 |
}
|
|
917 |
}
|
|
918 |
return set;
|
|
919 |
}
|
|
920 |
|
|
921 |
/**
|
|
922 |
* In a x-y-a,b selector, parse an x, y, a, or b -- that is an
|
|
923 |
* identifier
|
|
924 |
*
|
|
925 |
* @param <E> The enum this selector should belong to
|
|
926 |
* @param s The string to parse: x, y, or z
|
|
927 |
* @param values The allowed of this enum
|
|
928 |
* @return The enum value
|
|
929 |
*/
|
|
930 |
final <E extends Enum<E>> E parseFormatSelector(String s, EnumSet<E> values, String label) {
|
|
931 |
if (s == null) {
|
|
932 |
valid = false;
|
|
933 |
return null;
|
|
934 |
}
|
|
935 |
String u = s.toUpperCase(Locale.US);
|
|
936 |
for (E c : values) {
|
|
937 |
if (c.name().startsWith(u)) {
|
|
938 |
return c;
|
|
939 |
}
|
|
940 |
}
|
|
941 |
|
|
942 |
errorat("Not a valid %s: %s, must be one of: %s", label, s,
|
|
943 |
values.stream().map(v -> v.name().toLowerCase(Locale.US)).collect(Collectors.joining(" ")));
|
|
944 |
valid = false;
|
|
945 |
return values.iterator().next();
|
|
946 |
}
|
|
947 |
|
|
948 |
final void printFormatHelp() {
|
|
949 |
hard("Set the format for reporting a snippet event.");
|
|
950 |
hard("");
|
|
951 |
hard("/set format <mode> \"<format>\" <selector>...");
|
|
952 |
hard("");
|
|
953 |
hard("Where <mode> is the name of a previously defined feedback mode -- see '/help /set newmode'.");
|
|
954 |
hard("Where <format> is a quoted string which will have these field substitutions:");
|
|
955 |
hard(" {action} == The action, e.g.: Added, Modified, Assigned, ...");
|
|
956 |
hard(" {name} == The name, e.g.: the variable name, ...");
|
|
957 |
hard(" {type} == The type name");
|
|
958 |
hard(" {resolve} == Unresolved info, e.g.: ', however, it cannot be invoked until'");
|
|
959 |
hard(" {result} == The result value");
|
|
960 |
hard(" {when} == The entered snippet or a resultant update");
|
|
961 |
hard(" {pre} == The feedback prefix");
|
|
962 |
hard(" {post} == The feedback postfix");
|
|
963 |
hard(" {errorpre} == The error prefix");
|
|
964 |
hard(" {errorpost} == The error postfix");
|
|
965 |
hard("Use '/set field' to set the format of these substitutions.");
|
|
966 |
hard("Where <selector> is the context in which the format is applied.");
|
|
967 |
hard("The structure of selector is: <case>[-<action>[-<when>]]");
|
|
968 |
hard("Where each field component may be missing (indicating defaults),");
|
|
969 |
hard("star (indicating all), or a comma separated list of field values.");
|
|
970 |
hard("For case, the field values are:");
|
|
971 |
hardEnums(EnumSet.allOf(FormatCase.class), ev -> ev.doc);
|
|
972 |
hard("For action, the field values are:");
|
|
973 |
hardEnums(EnumSet.allOf(FormatAction.class), ev -> ev.doc);
|
|
974 |
hard("For when, the field values are:");
|
|
975 |
hardEnums(EnumSet.allOf(FormatWhen.class), ev -> ev.doc);
|
|
976 |
hard("");
|
|
977 |
hard("Example:");
|
|
978 |
hard(" /set format example '{pre}{action} variable {name}, reset to null{post}' varreset-*-update");
|
|
979 |
}
|
|
980 |
|
|
981 |
final void printFieldHelp() {
|
|
982 |
hard("Set the format of a field substitution as used in '/set format'.");
|
|
983 |
hard("");
|
|
984 |
hard("/set field <mode> <field> \"<format>\" <selector>...");
|
|
985 |
hard("");
|
|
986 |
hard("Where <mode> is the name of a previously defined feedback mode -- see '/set newmode'.");
|
|
987 |
hard("Where <field> is context-specific format to set, each with its own selector structure:");
|
|
988 |
hard(" action == The action. The selector: <action>-<when>.");
|
|
989 |
hard(" name == The name. '%%s' is the name. No selectors.");
|
|
990 |
hard(" type == The type name. '%%s' is the type. No selectors.");
|
|
991 |
hard(" resolve == Unresolved info. '%%s' is the unresolved list. The selector: <resolve>-<when>.");
|
|
992 |
hard(" result == The result value. '%%s' is the result value. No selectors.");
|
|
993 |
hard(" when == The entered snippet or a resultant update. The selector: <when>");
|
|
994 |
hard(" pre == The feedback prefix. No selectors.");
|
|
995 |
hard(" post == The feedback postfix. No selectors.");
|
|
996 |
hard(" errorpre == The error prefix. No selectors.");
|
|
997 |
hard(" errorpost == The error postfix. No selectors.");
|
|
998 |
hard("Where <format> is a quoted string -- see the description specific to the field (above).");
|
|
999 |
hard("Where <selector> is the context in which the format is applied (see above).");
|
|
1000 |
hard("For action, the field values are:");
|
|
1001 |
hardEnums(EnumSet.allOf(FormatAction.class), ev -> ev.doc);
|
|
1002 |
hard("For when, the field values are:");
|
|
1003 |
hardEnums(EnumSet.allOf(FormatWhen.class), ev -> ev.doc);
|
|
1004 |
hard("For resolve, the field values are:");
|
|
1005 |
hardEnums(EnumSet.allOf(FormatResolve.class), ev -> ev.doc);
|
|
1006 |
hard("");
|
|
1007 |
hard("Example:");
|
|
1008 |
hard(" /set field example resolve ' which cannot be invoked until%%s is declared' defined-update");
|
|
1009 |
}
|
|
1010 |
|
|
1011 |
final void printFeedbackHelp() {
|
|
1012 |
hard("Set the feedback mode describing displayed feedback for entered snippets and commands.");
|
|
1013 |
hard("");
|
|
1014 |
hard("/set feedback <mode>");
|
|
1015 |
hard("");
|
|
1016 |
hard("Where <mode> is the name of a previously defined feedback mode.");
|
|
1017 |
hard("Currently defined feedback modes:");
|
|
1018 |
modeMap.keySet().stream()
|
|
1019 |
.forEach(m -> hard(" %s", m));
|
|
1020 |
hard("User-defined modes can be added, see '/help /set newmode'");
|
|
1021 |
}
|
|
1022 |
|
|
1023 |
final void printNewModeHelp() {
|
|
1024 |
hard("Create a user-defined feedback mode, optionally copying from an existing mode.");
|
|
1025 |
hard("");
|
|
1026 |
hard("/set newmode <new-mode> [command|quiet [<old-mode>]]");
|
|
1027 |
hard("");
|
|
1028 |
hard("Where <new-mode> is the name of a mode you wish to create.");
|
|
1029 |
hard("Where <old-mode> is the name of a previously defined feedback mode.");
|
|
1030 |
hard("If <old-mode> is present, its settings are copied to the new mode.");
|
|
1031 |
hard("'command' vs 'quiet' determines if informative/verifying command feedback is displayed.");
|
|
1032 |
hard("");
|
|
1033 |
hard("Once the new mode is created, use '/set format', '/set field', and '/set prompt' to configure it.");
|
|
1034 |
hard("Use '/set feedback' to use the new mode.");
|
|
1035 |
}
|
|
1036 |
|
|
1037 |
final void printPromptHelp() {
|
|
1038 |
hard("Set the prompts. Both the normal prompt and the continuation-prompt must be set.");
|
|
1039 |
hard("");
|
|
1040 |
hard("/set prompt <mode> \"<prompt>\" \"<continuation-propmt>\"");
|
|
1041 |
hard("");
|
|
1042 |
hard("Where <mode> is the name of a previously defined feedback mode.");
|
|
1043 |
hard("Where <prompt> and <continuation-propmt> are quoted strings printed as input promptds;");
|
|
1044 |
hard("Both may optionally contain '%%s' which will be substituted with the next snippet id --");
|
|
1045 |
hard("note that what is entered may not be assigned that id, for example it may be an error or command.");
|
|
1046 |
hard("The continuation-prompt is used on the second and subsequent lines of a multi-line snippet.");
|
|
1047 |
}
|
|
1048 |
}
|
|
1049 |
}
|