本文整理汇总了Java中org.jline.utils.AttributedStyle类的典型用法代码示例。如果您正苦于以下问题:Java AttributedStyle类的具体用法?Java AttributedStyle怎么用?Java AttributedStyle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AttributedStyle类属于org.jline.utils包,在下文中一共展示了AttributedStyle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: accept
import org.jline.utils.AttributedStyle; //导入依赖的package包/类
@Override
public void accept(TraineeSession session, String statement) {
Collection<CypherError> errors = statementValidator.validate(statement);
if (!errors.isEmpty()) {
logger.error("An error occurred with your query. See details below:");
errors.forEach(err -> logger.error(err.toString()));
return;
}
ExerciseValidation validation = validate(session, statement);
if (!validation.isSuccessful()) {
logger.error(validation.getReport());
return;
}
if (session.isCompleted()) {
logger.log("Congrats, you're done!!!", AttributedStyle.BOLD.background(AttributedStyle.GREEN));
return;
}
logger.log(validation.getReport());
logger.log("Now moving on to next exercise! See instructions below...");
session.getCurrentExercise().accept(logger);
}
示例2: appendLines
import org.jline.utils.AttributedStyle; //导入依赖的package包/类
@Override
public void appendLines(List<AttributedString> lines, int width, int height) {
AttributedStringBuilder actionsLine = new AttributedStringBuilder();
switch (debugger.getState()) {
case Running:
actionsLine.append(" └");
actionsLine.append("P", AttributedStyle.DEFAULT.underline());
actionsLine.append("ause┘");
break;
case Paused:
actionsLine.append(" └");
actionsLine.append("C", AttributedStyle.DEFAULT.underline());
actionsLine.append("ontinue┘ └");
actionsLine.append("S", AttributedStyle.DEFAULT.underline());
actionsLine.append("tep┘");
break;
}
lines.add(actionsLine.toAttributedString());
disassemblyBox.pc = debugger.getPc();
horizontalBoxes.appendLines(lines, width, height - 1);
}
示例3: getPrompt
import org.jline.utils.AttributedStyle; //导入依赖的package包/类
@Override
public AttributedString getPrompt() {
if (skipperClient != null) {
return new AttributedString("skipper:>", AttributedStyle.DEFAULT.foreground(AttributedStyle.YELLOW));
}
else {
return new AttributedString("server-unknown:>", AttributedStyle.DEFAULT.foreground(AttributedStyle.RED));
}
}
示例4: log
import org.jline.utils.AttributedStyle; //导入依赖的package包/类
public void log(String string, AttributedStyle style, Object... args) {
if (args.length == 0) {
log(System.out, style, string);
return;
}
log(System.out, style, String.format(string, args));
}
示例5: error
import org.jline.utils.AttributedStyle; //导入依赖的package包/类
public void error(String string, Object... args) {
AttributedStyle style = AttributedStyle.BOLD.foreground(AttributedStyle.RED);
if (args.length == 0) {
log(System.err, style, string);
return;
}
log(System.err, style, String.format(string, args));
}
示例6: accept
import org.jline.utils.AttributedStyle; //导入依赖的package包/类
@Override
public void accept(TraineeSession session, String s) {
logger.log(
" .-\"\"\"\"\"\"-.\n" +
" .' '.\n" +
" / O O \\\n" +
" : ` :\n" +
" | |\n" +
" : .------. :\n" +
" \\ ' ' /\n" +
" '. .'\n" +
" '-......-'\n"
+ "Sad to see you go", AttributedStyle.DEFAULT.blink().italic().foreground(MAGENTA));
System.exit(0);
}
示例7: levelColor
import org.jline.utils.AttributedStyle; //导入依赖的package包/类
private static int levelColor(Level level) {
switch (level) {
case Error:
return AttributedStyle.RED;
case Warning:
return AttributedStyle.MAGENTA;
default:
return AttributedStyle.WHITE;
}
}
示例8: line
import org.jline.utils.AttributedStyle; //导入依赖的package包/类
private void line(int width, List<Column> columns, int[] widths, int row, AttributedStringBuilder asb) {
int currentWidth = 0;
int startLen = asb.length();
if (isActive() && row == selectedRow) {
asb.style(AttributedStyle.INVERSE);
}
for (int i = 0; i < widths.length; i++) {
Column column = columns.get(i);
column.cell(asb, row, widths[i]);
currentWidth += widths[i];
if (asb.length() - startLen > currentWidth) {
if (widths[i] > 0) {
asb.setLength(startLen + currentWidth - 1);
asb.append('…');
} else {
asb.setLength(startLen + currentWidth);
}
} else if (asb.length() - startLen < currentWidth) {
int cellStart = startLen + currentWidth - widths[i];
int extraSpace = currentWidth - (asb.length() - startLen);
AttributedString content = asb.subSequence(cellStart, asb.length());
asb.setLength(cellStart);
View.repeat(asb, extraSpace, ' ');
asb.append(content);
}
if (i < widths.length - 1) {
asb.append('│');
currentWidth++;
}
if (currentWidth > width) {
asb.setLength(startLen + width);
break;
}
}
asb.style(AttributedStyle.INVERSE_OFF);
}
示例9: appendLines
import org.jline.utils.AttributedStyle; //导入依赖的package包/类
@Override
public void appendLines(List<AttributedString> lines, int width, int height) {
int startLines = lines.size();
if (state == State.Goto) {
AttributedStringBuilder addrPromptLine = new AttributedStringBuilder();
addrPromptLine.append('│');
addrPromptLine.append(addressField.getAddressPrompt());
AttributedStyle style = AttributedStyle.DEFAULT;
if (!addressField.isCurrentInputValid()) {
style = style.foreground(AttributedStyle.RED);
}
addrPromptLine.append(addressField.getCurrentInput(), style);
View.padToLength(addrPromptLine, width - 1);
addrPromptLine.append('│');
lines.add(addrPromptLine.toAttributedString());
AttributedStringBuilder addrPromptBottomLine = new AttributedStringBuilder();
addrPromptBottomLine.append('└');
View.horizontalLine(addrPromptBottomLine, width - 2);
addrPromptBottomLine.append('┘');
lines.add(addrPromptBottomLine.toAttributedString());
AttributedStringBuilder actionsLine = new AttributedStringBuilder();
actionsLine.append(" └Abort(");
actionsLine.append("q", AttributedStyle.DEFAULT.underline());
actionsLine.append(")┘ └Go(");
actionsLine.append("⏎", addressField.isCurrentInputValid() ? AttributedStyle.DEFAULT.underline() : AttributedStyle.DEFAULT);
actionsLine.append(")┘");
lines.add(actionsLine.toAttributedString());
} else {
AttributedStringBuilder gotoLine = new AttributedStringBuilder();
gotoLine.append(" └");
gotoLine.append("G", AttributedStyle.DEFAULT.underline());
gotoLine.append("oto┘");
lines.add(gotoLine.toAttributedString());
}
int remainingHeight = height - (lines.size() - startLines);
verticalBoxes.appendLines(lines, width, remainingHeight);
}
示例10: prompt
import org.jline.utils.AttributedStyle; //导入依赖的package包/类
protected String prompt() {
return new AttributedStringBuilder()
.style(AttributedStyle.BOLD.foreground(AttributedStyle.YELLOW))
.append("configure ")
.append(name())
.append("> ")
.toAnsi();
}
示例11: createDefaultSessionContext
import org.jline.utils.AttributedStyle; //导入依赖的package包/类
private void createDefaultSessionContext(LineReader reader, Terminal terminal) {
SshSessionContext.put(ConsoleIO.LINE_READER, reader);
SshSessionContext.put(ConsoleIO.TEXT_STYLE, getStyle(properties.getText().getColor()));
SshSessionContext.put(ConsoleIO.HIGHLIGHT_COLOR,
AttributedStyle.DEFAULT.background(properties.getText().getHighlightColor().value));
SshSessionContext.put(ConsoleIO.TERMINAL, terminal);
}
示例12: accept
import org.jline.utils.AttributedStyle; //导入依赖的package包/类
@Override
public void accept(TraineeSession session, String ignored) {
commands.forEach(command -> {
logger.log(command.help(), AttributedStyle.DEFAULT.background(WHITE).foreground(BLACK));
});
}
示例13: start
import org.jline.utils.AttributedStyle; //导入依赖的package包/类
public void start() {
logger.log("\n" +
" \n" +
" ╓╖╓\n" +
" ╓▓▓▓▓▓M▌ ╟╜▀▓▌╗╥ █\n" +
" ▓▓▓▓▓¼▓▓▓╗╬╢╬▓▓▓▌╗, ,, ,; ,;;\n" +
" ╓▓▓╩╬▌╬▓▓▓▓╟▓▓▓▓▓▓▓▓▓▌ █▄▀╙└╙▀█▄ ▄▀▀└└\"▀█ ▄█▀┘└└▀▀▄ █▀ █\n" +
" ▓▓▌w╬▓▓▓▓▓╡▓▓▓▓▓▓▓▓▓▓▓M █▌ █ █▀ █ █▀ \"█ █▀ █\n" +
" ▐▓▓▓,╟▓▓▓▓▓▓╟▓▓▓▓▓▓▓▓▓▓ █= █ █▀▀▀▀▀▀▀▀▀ █ █⌐ █▀ ╓ █\n" +
" ▐▓▓▓▄,▓▓▓▓▓▓▓╬╬▓▓▓▓▓▓▌⌐ █= █ ╙█ ╙█ ▄▀ █▀ █= █\n" +
" ╟▓▓▓Ü ╟▓▌╬▓▓▓▓╬▌╝╬╬▓▌ ▀⌐ █ `▀Wæ▄æA▀ ▀▀æ▄æΦ▀└ ╝█≡≡≡≡≡≡█= █\n" +
" ╚▓▓▌▌╬▓▓▓▓▌▀▓╜½╖▓▓M █= █\n" +
" `╚▓▓▓▓▓▓▓▓▓╟@╬▓▀ ▀⌐╘≡▀└\n" +
" ▓▓▓▓▓▓▓▓▓╜╙`\n" +
" ╚▓▓▓▓▓▀\n" +
"\n", AttributedStyle.BOLD.foreground(GREEN));
AttributedStyle warningStyle = AttributedStyle.BOLD.blink().foreground(YELLOW);
logger.log("");
logger.log("Initializing session now...", AttributedStyle.DEFAULT.italic());
session.init(this.getClass().getResourceAsStream("/exercises/dump.cypher"));
logger.log("... done!", AttributedStyle.DEFAULT.italic());
logger.log("");
logger.log("Welcome to Devoxx France 2017 Hands on Neo4j!");
logger.log("Available commands can be displayed with ':commands'");
logger.log("");
logger.log("Please make sure your Cypher statements end with a semicolon.", warningStyle);
logger.log("Every exercise is independent, no changes are persisted against your database.", warningStyle);
logger.log("Make sure to undo the insertions in the browser before using this REPL!", warningStyle);
logger.log("");
logger.log("Ask for help when needed and have fun!", AttributedStyle.BOLD.foreground(AttributedStyle.CYAN));
while (true) {
try {
String statement = lineReader.readLine("(:Devoxx)-[:`<3`]-(:Cypher)> ");
commandRegistry
.findFirst(statement)
.orElse(defaultCypherCommand)
.accept(session, statement);
} catch (UserInterruptException ignored) {
} catch (EndOfFileException e) {
logger.log("Goodbye!");
return;
}
}
}
示例14: accept
import org.jline.utils.AttributedStyle; //导入依赖的package包/类
public void accept(ConsoleLogger logger) {
logger.log("");
logger.log(this.getCurrentPosition(), AttributedStyle.BOLD.italic().foreground(GREEN));
logger.log("");
logger.log(this.getInstructions(), AttributedStyle.BOLD.italic().foreground(BLUE));
}
示例15: execute
import org.jline.utils.AttributedStyle; //导入依赖的package包/类
@Override
public void execute(@NotNull CommandContext context) {
context.print("List of available commands. ");
AttributedStringBuilder headerBuilder =
new AttributedStringBuilder()
.append("To find more about a specific command run ")
.style(AttributedStyle.BOLD.foreground(AttributedStyle.RED))
.append("<command> -h");
context.println(headerBuilder.toAnsi(context.getTerminal()));
Map<String, Class<? extends Command>> commandMap =
context.getPluginContext().getCommandManager().getCommands();
AnsiContentParser ansiContentParser = new AnsiContentParser();
JTable table = JTable.of()
.width(60)
.contentParser(ansiContentParser)
.theme(JTheme.NO_LINE);
Map<String, String> helpMap = new TreeMap<>();
int maxCommandLength = 1;
for (Class<? extends Command> command : commandMap.values()) {
String cmds = getCommandNames(command).stream()
.map(s -> Ansi.ansi().fgRed().bold().a(s).reset()
.toString())
.collect(Collectors.joining(", "));
helpMap.put(cmds, getDescription(command));
maxCommandLength = Math.max(maxCommandLength, ansiContentParser.getLength(cmds));
}
for (Map.Entry<String, String> entry : helpMap.entrySet()) {
table.row()
.col().width(maxCommandLength + 6)
.padding(new JPadding(5, 0, 0, 0, ' '))
.content(Ansi.ansi().fgRed().bold().a(entry.getKey()).reset())
.done()
.col().content(entry.getValue());
}
table.render().forEach(context::println);
}