本文整理了Java中org.jline.utils.AttributedString.()
方法的一些代码示例,展示了AttributedString.()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AttributedString.()
方法的具体详情如下:
包路径:org.jline.utils.AttributedString
类名称:AttributedString
方法名:
AttributedString.介绍
暂无
代码示例
代码示例来源:origin: confluentinc/ksql
@Override
public StatusClosable setStatusMessage(final String message) {
updateStatusBar(new AttributedString(message, AttributedStyle.INVERSE));
return () -> updateStatusBar(DEFAULT_STATUS_MSG);
}
代码示例来源:origin: apache/flink
private void callSource(SqlCommandCall cmdCall) {
final String pathString = cmdCall.operands[0];
// load file
final String stmt;
try {
final Path path = Paths.get(pathString);
byte[] encoded = Files.readAllBytes(path);
stmt = new String(encoded, Charset.defaultCharset());
} catch (IOException e) {
printExecutionException(e);
return;
}
// limit the output a bit
if (stmt.length() > SOURCE_MAX_SIZE) {
printExecutionError(CliStrings.MESSAGE_MAX_SIZE_EXCEEDED);
return;
}
terminal.writer().println(CliStrings.messageInfo(CliStrings.MESSAGE_WILL_EXECUTE).toAnsi());
terminal.writer().println(new AttributedString(stmt).toString());
terminal.flush();
// try to run it
final Optional call = parseCommand(stmt);
call.ifPresent(this::callCommand);
}
代码示例来源:origin: apache/flink
lines.add(new AttributedString(CliStrings.DEFAULT_MARGIN + inputTitle));
代码示例来源:origin: apache/flink
/**
* Submits a SQL update statement and prints status information and/or errors on the terminal.
*
* @param statement SQL update statement
* @return flag to indicate if the submission was successful or not
*/
public boolean submitUpdate(String statement) {
terminal.writer().println(CliStrings.messageInfo(CliStrings.MESSAGE_WILL_EXECUTE).toAnsi());
terminal.writer().println(new AttributedString(statement).toString());
terminal.flush();
final Optional parsedStatement = parseCommand(statement);
// only support INSERT INTO
return parsedStatement.map(cmdCall -> {
switch (cmdCall.command) {
case INSERT_INTO:
return callInsertInto(cmdCall);
default:
printError(CliStrings.MESSAGE_UNSUPPORTED_SQL);
return false;
}
}).orElse(false);
}
代码示例来源:origin: confluentinc/ksql
@Test
public void shouldSetStatusMessage() {
// When:
terminal.setStatusMessage("test message");
// Then:
verify(statusBar)
.update(ImmutableList.of(new AttributedString("test message", AttributedStyle.INVERSE)));
}
代码示例来源:origin: confluentinc/ksql
@Test
public void shouldResetStatusMessage() {
// Given:
final StatusClosable closable = terminal.setStatusMessage("test message");
clearInvocations(statusBar);
// When:
closable.close();
// Then:
verify(statusBar)
.update(ImmutableList.of(new AttributedString("", AttributedStyle.DEFAULT)));
}
}
代码示例来源:origin: org.jline/jline
@Override
public AttributedString subSequence(int start, int end) {
return new AttributedString(this, start, end);
}
代码示例来源:origin: org.jline/jline
@Override
public AttributedString subSequence(int start, int end) {
return new AttributedString(
Arrays.copyOfRange(buffer, start, end),
Arrays.copyOfRange(style, start, end),
0,
end - start);
}
代码示例来源:origin: org.jline/jline
/**
* Encode string with style applying value.
*
* @param style the style
* @param value the value
* @return the result string
*/
public AttributedString style(final String style, final String value) {
requireNonNull(value);
AttributedStyle astyle = resolver.resolve(style);
return new AttributedString(value, astyle);
}
代码示例来源:origin: spring-cloud/spring-cloud-gcp
@Override
public AttributedString getPrompt() {
return new AttributedString("enter a command or type 'help' for info :> ",
AttributedStyle.DEFAULT.foreground(AttributedStyle.YELLOW));
}
}
代码示例来源:origin: org.springframework.shell/spring-shell-core
@Bean
@ConditionalOnMissingBean(PromptProvider.class)
public PromptProvider promptProvider() {
return () -> new AttributedString("shell:>", AttributedStyle.DEFAULT.foreground(AttributedStyle.YELLOW));
}
代码示例来源:origin: spring-cloud/spring-cloud-skipper
@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));
}
}
代码示例来源:origin: org.apache.karaf.shell/org.apache.karaf.shell.core
static String applyStyle(String text, Map colors, String... types) {
String t = null;
for (String type : types) {
if (colors.get(type) != null) {
t = type;
break;
}
}
return new AttributedString(text, new StyleResolver(colors::get).resolve("." + t))
.toAnsi();
}
代码示例来源:origin: apache/karaf
static String applyStyle(String text, Map colors, String... types) {
String t = null;
for (String type : types) {
if (colors.get(type) != null) {
t = type;
break;
}
}
return new AttributedString(text, new StyleResolver(colors::get).resolve("." + t))
.toAnsi();
}
代码示例来源:origin: apache/felix
static String applyStyle(String text, Map colors, String... types) {
String t = null;
for (String type : types) {
if (colors.get(type) != null) {
t = type;
break;
}
}
return new AttributedString(text, new StyleResolver(colors::get).resolve("." + t))
.toAnsi();
}
代码示例来源:origin: org.jline/jline
private AttributedString getHighlightedBuffer(String buffer) {
if (maskingCallback != null) {
buffer = maskingCallback.display(buffer);
}
if (highlighter != null && !isSet(Option.DISABLE_HIGHLIGHTER)) {
return highlighter.highlight(this, buffer);
}
return new AttributedString(buffer);
}
代码示例来源:origin: com.github.fonimus/spring-boot-ssh-shell-starter
/**
* Primary prompt provider
*
* @param properties ssh shell properties
* @return prompt provider
*/
@Bean
@Primary
public PromptProvider sshPromptProvider(SshShellProperties properties) {
return () -> new AttributedString(properties.getPrompt().getText(),
AttributedStyle.DEFAULT.foreground(properties.getPrompt().getColor().toJlineAttributedStyle()));
}
代码示例来源:origin: com.github.fonimus/ssh-shell-starter
@Bean
@Primary
public PromptProvider sshPromptProvider(SshShellProperties properties) {
return () -> new AttributedString(properties.getPrompt().getText(),
AttributedStyle.DEFAULT.foreground(properties.getPrompt().getColor().getValue()));
}
代码示例来源:origin: com.aspectran/aspectran-shell-jline
@Override
public void write(String string) {
if (style != null) {
AttributedString as = new AttributedString(string, style);
writeRawText(as.toAnsi(terminal));
} else {
writeRawText(toAnsi(string));
}
}
代码示例来源:origin: org.jline/jline
protected void cleanup() {
if (isSet(Option.ERASE_LINE_ON_FINISH)) {
Buffer oldBuffer = buf.copy();
AttributedString oldPrompt = prompt;
buf.clear();
prompt = new AttributedString("");
doCleanup(false);
prompt = oldPrompt;
buf.copyFrom(oldBuffer);
} else {
doCleanup(true);
}
}