本文整理汇总了Java中org.jline.utils.AttributedStringBuilder类的典型用法代码示例。如果您正苦于以下问题:Java AttributedStringBuilder类的具体用法?Java AttributedStringBuilder怎么用?Java AttributedStringBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AttributedStringBuilder类属于org.jline.utils包,在下文中一共展示了AttributedStringBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: appendLines
import org.jline.utils.AttributedStringBuilder; //导入依赖的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);
}
开发者ID:gilles-duboscq,项目名称:jvb,代码行数:22,代码来源:CPUView.java
示例2: appendLines
import org.jline.utils.AttributedStringBuilder; //导入依赖的package包/类
public void appendLines(List<AttributedString> lines, int width, int height) {
int nonFixedHeight = getNonFixedHeight(height, boxes);
Iterator<Box> iterator = boxes.iterator();
int currentBoxStart = -1;
Box currentBox = null;
for (int line = 0; line < height; line++) {
AttributedStringBuilder asb = new AttributedStringBuilder();
if (currentBox == null) {
if (iterator.hasNext()) {
currentBox = iterator.next();
currentBoxStart = line + 1;
HorizontalBoxes.top(width, Collections.singletonList(currentBox), new int[]{max(0, width - 2)}, asb);
}
} else {
int boxHeight = currentBox.fixedHeight() ? currentBox.minHeight() : nonFixedHeight;
if (line == currentBoxStart + boxHeight) {
HorizontalBoxes.bottom(new int[]{max(0, width - 2)}, width, asb);
currentBox = null;
} else {
boxLine(asb, currentBox, line - currentBoxStart, boxHeight, width);
}
}
lines.add(asb.toAttributedString());
}
}
开发者ID:gilles-duboscq,项目名称:jvb,代码行数:26,代码来源:VerticalBoxes.java
示例3: separator
import org.jline.utils.AttributedStringBuilder; //导入依赖的package包/类
static void separator(int[] widths, int width, AttributedStringBuilder asb) {
int currentWidth = 0;
int startLen = asb.length();
for (int i = 0; i < widths.length; i++) {
View.repeat(asb, widths[i], '─');
currentWidth += widths[i];
if (i < widths.length - 1) {
asb.append('┼');
currentWidth++;
}
if (currentWidth > width) {
asb.setLength(startLen + width);
break;
}
}
}
开发者ID:gilles-duboscq,项目名称:jvb,代码行数:17,代码来源:Table.java
示例4: horizontalBoxes
import org.jline.utils.AttributedStringBuilder; //导入依赖的package包/类
public static void horizontalBoxes(List<AttributedString> lines, int width, int height, List<Box> boxes) {
int[] widths = getWidths(width, boxes);
AttributedStringBuilder top = new AttributedStringBuilder();
top(width, boxes, widths, top);
lines.add(top.toAttributedString());
for (int i = 0; i < height - 2; i++) {
AttributedStringBuilder line = new AttributedStringBuilder();
line(width, max(0, height - 2), boxes, widths, i, line);
lines.add(line.toAttributedString());
}
AttributedStringBuilder bottom = new AttributedStringBuilder();
bottom(widths, width, bottom);
lines.add(bottom.toAttributedString());
}
开发者ID:gilles-duboscq,项目名称:jvb,代码行数:17,代码来源:HorizontalBoxes.java
示例5: appendWord
import org.jline.utils.AttributedStringBuilder; //导入依赖的package包/类
private void appendWord(AttributedStringBuilder asb, int address, Bus bus) {
try {
asb.append(formattedWord(bus.getWord(address)));
} catch (BusError e) {
if (e.getReason() == BusError.Reason.Error) {
throw new RuntimeException(e);
}
asb.append(" ");
appendByte(asb, address, bus);
asb.append(" ");
appendByte(asb, address + 1, bus);
asb.append(" ");
appendByte(asb, address + 2, bus);
asb.append(" ");
appendByte(asb, address + 3, bus);
asb.append(" ");
}
}
开发者ID:gilles-duboscq,项目名称:jvb,代码行数:19,代码来源:MemoryView.java
示例6: appendByte
import org.jline.utils.AttributedStringBuilder; //导入依赖的package包/类
private void appendByte(AttributedStringBuilder asb, int address, Bus bus) {
try {
asb.append(String.format("%02x", bus.getByte(address)));
} catch (BusError e) {
String errorValue;
switch (e.getReason()) {
case Unmapped:
errorValue = "UU";
break;
case Unimplemented:
errorValue = "II";
break;
case Permission:
errorValue = "XX";
break;
case Error:
default:
throw new RuntimeException(e);
}
asb.append(errorValue);
}
}
开发者ID:gilles-duboscq,项目名称:jvb,代码行数:23,代码来源:MemoryView.java
示例7: parse
import org.jline.utils.AttributedStringBuilder; //导入依赖的package包/类
public static String parse(String input, Terminal terminal) {
if (input == null || !input.contains("{{") || !input.contains("}}")) {
return input;
}
final AttributedStringBuilder asb = new AttributedStringBuilder(input.length());
AnsiStyleHandler handler = new AnsiStyleHandler() {
@Override
public void character(char c) {
asb.append(c);
}
@Override
public void attribute(String... attrs) {
asb.style(makeStyle(asb.style(), attrs));
}
};
handler.handle(input);
return asb.toAnsi(terminal);
}
开发者ID:aspectran,项目名称:aspectran,代码行数:23,代码来源:JLineAnsiStyler.java
示例8: cell
import org.jline.utils.AttributedStringBuilder; //导入依赖的package包/类
@Override
protected void cell(AttributedStringBuilder asb, VSUChannel channel) {
if (channel instanceof VSUPCMSweepModChannel) {
asb.append("S/M");
} else if (channel instanceof VSUPCMChannel) {
asb.append("PCM");
} else if (channel instanceof VSUNoiseChannel) {
asb.append("Noiz");
}
}
开发者ID:gilles-duboscq,项目名称:jvb,代码行数:11,代码来源:VSUView.java
示例9: cell
import org.jline.utils.AttributedStringBuilder; //导入依赖的package包/类
@Override
public void cell(AttributedStringBuilder asb, int row, int width) {
List<? extends Breakpoint> breakpoints = type.get(Breakpoints.this);
if (row >= breakpoints.size()) {
return;
}
cell(asb, breakpoints.get(row));
}
开发者ID:gilles-duboscq,项目名称:jvb,代码行数:9,代码来源:Breakpoints.java
示例10: leftPadInt
import org.jline.utils.AttributedStringBuilder; //导入依赖的package包/类
static void leftPadInt(AttributedStringBuilder asb, int length, long value) {
String s = Long.toString(value);
if (s.length() < length) {
View.repeat(asb, length - s.length(), ' ');
}
asb.append(s);
}
开发者ID:gilles-duboscq,项目名称:jvb,代码行数:8,代码来源:View.java
示例11: leftPadHex
import org.jline.utils.AttributedStringBuilder; //导入依赖的package包/类
static void leftPadHex(AttributedStringBuilder asb, int length, long value) {
String s = Long.toHexString(value);
if (s.length() < length) {
View.repeat(asb, length - s.length(), ' ');
}
asb.append(s);
}
开发者ID:gilles-duboscq,项目名称:jvb,代码行数:8,代码来源:View.java
示例12: boxLine
import org.jline.utils.AttributedStringBuilder; //导入依赖的package包/类
private void boxLine(AttributedStringBuilder asb, Box box, int line, int height, int width) {
int startLen = asb.length();
if (width > 0) {
asb.append('║');
}
box.line(asb, line, max(0, width - 2), height);
if (asb.length() - startLen > width - 1) {
asb.setLength(startLen + width - 1);
} else {
View.repeat(asb, width - 1 - (asb.length() - startLen), ' ');
}
if (width > 1) {
asb.append('║');
}
}
开发者ID:gilles-duboscq,项目名称:jvb,代码行数:16,代码来源:VerticalBoxes.java
示例13: line
import org.jline.utils.AttributedStringBuilder; //导入依赖的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);
}
开发者ID:gilles-duboscq,项目名称:jvb,代码行数:37,代码来源:Table.java
示例14: header
import org.jline.utils.AttributedStringBuilder; //导入依赖的package包/类
private static void header(int width, List<Column> columns, int[] widths, AttributedStringBuilder asb) {
int currentWidth = 0;
int startLen = asb.length();
for (int i = 0; i < widths.length; i++) {
Column column = columns.get(i);
asb.append(column.name());
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 {
View.repeat(asb, currentWidth - (asb.length() - startLen), ' ');
}
if (i < widths.length - 1) {
asb.append('│');
currentWidth++;
}
if (currentWidth > width) {
asb.setLength(startLen + width);
break;
}
}
}
开发者ID:gilles-duboscq,项目名称:jvb,代码行数:28,代码来源:Table.java
示例15: bottom
import org.jline.utils.AttributedStringBuilder; //导入依赖的package包/类
static void bottom(int[] widths, int width, AttributedStringBuilder asb) {
int currentWidth = 0;
int startLen = asb.length();
for (int w : widths) {
asb.append('╚');
View.repeat(asb, w, '═');
asb.append('╝');
currentWidth += w + 2;
if (currentWidth > width) {
asb.setLength(startLen + width);
break;
}
}
}
开发者ID:gilles-duboscq,项目名称:jvb,代码行数:15,代码来源:HorizontalBoxes.java
示例16: top
import org.jline.utils.AttributedStringBuilder; //导入依赖的package包/类
static void top(int width, List<Box> boxes, int[] widths, AttributedStringBuilder asb) {
int currentWidth = 0;
int startLen = asb.length();
for (int i = 0; i < widths.length; i++) {
Box box = boxes.get(i);
asb.append('╔');
currentWidth++;
if (widths[i] > 1) {
asb.append('═');
}
asb.append(box.name());
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 {
View.repeat(asb, currentWidth - (asb.length() - startLen), '═');
}
asb.append('╗');
currentWidth++;
if (currentWidth > width) {
asb.setLength(startLen + width);
break;
}
}
}
开发者ID:gilles-duboscq,项目名称:jvb,代码行数:32,代码来源:HorizontalBoxes.java
示例17: cell
import org.jline.utils.AttributedStringBuilder; //导入依赖的package包/类
@Override
public void cell(AttributedStringBuilder asb, int row, int width) {
T[] objects = getObjects();
if (row < objects.length) {
cell(asb, objects[row]);
}
}
开发者ID:gilles-duboscq,项目名称:jvb,代码行数:8,代码来源:SimpleColumn.java
示例18: appendLines
import org.jline.utils.AttributedStringBuilder; //导入依赖的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);
}
开发者ID:gilles-duboscq,项目名称:jvb,代码行数:40,代码来源:MemoryView.java
示例19: prompt
import org.jline.utils.AttributedStringBuilder; //导入依赖的package包/类
protected String prompt() {
return new AttributedStringBuilder()
.style(AttributedStyle.BOLD.foreground(AttributedStyle.YELLOW))
.append("configure ")
.append(name())
.append("> ")
.toAnsi();
}
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:9,代码来源:AbstractTalonConfigCommand.java
示例20: execute
import org.jline.utils.AttributedStringBuilder; //导入依赖的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);
}
开发者ID:jeeshell,项目名称:je2sh,代码行数:47,代码来源:Help.java
注:本文中的org.jline.utils.AttributedStringBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论