org.fusesource.jansi.Ansi.eraseLine()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(170)

本文整理了Java中org.fusesource.jansi.Ansi.eraseLine()方法的一些代码示例,展示了Ansi.eraseLine()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ansi.eraseLine()方法的具体详情如下:
包路径:org.fusesource.jansi.Ansi
类名称:Ansi
方法名:eraseLine

Ansi.eraseLine介绍

暂无

代码示例

代码示例来源:origin: micronaut-projects/micronaut-core

private void erasePrompt(PrintStream printStream) {
  printStream.print(ansi()
    .eraseLine(Ansi.Erase.BACKWARD).cursorLeft(PROMPT.length()));
}

代码示例来源:origin: prestodb/presto

public void reprintLine(String line)
{
  if (isRealTerminal()) {
    out.print(ansi().eraseLine(Erase.ALL).a(line).a('\n').toString());
  }
  else {
    out.print('\r' + line);
  }
  out.flush();
  lines++;
}

代码示例来源:origin: apache/hive

/**
 * NOTE: Use this method only if isUnixTerminal is true.
 * Erases the current line and prints the given multiline. Make sure the specified line is not
 * terminated by linebreak.
 *
 * @param line - line to print
 */
private void reprintMultiLine(String line) {
 int numLines = line.split("\r\n|\r|\n").length;
 out.print(ansi().eraseLine(Ansi.Erase.ALL).a(line).a('\n').toString());
 out.flush();
 lines += numLines;
}

代码示例来源:origin: apache/drill

private void reprintMultiLine(String line) {
  int numLines = line.split("\r\n|\r|\n").length;
  out.print(ansi().eraseLine(Ansi.Erase.ALL).a(line).a('\n').toString());
  out.flush();
  lines += numLines;
 }
}

代码示例来源:origin: apache/hive

public static void reprintLine(PrintStream out, String line) {
 out.print(ansi().eraseLine(Ansi.Erase.ALL).a(line).a('\n').toString());
 out.flush();
}

代码示例来源:origin: micronaut-projects/micronaut-core

private Ansi erasePreviousLine(String categoryName) {
  int cursorMove = this.cursorMove;
  if (userInputActive) {
    cursorMove++;
  }
  if (cursorMove > 0) {
    int moveLeftLength = categoryName.length() + lastMessage.length();
    if (userInputActive) {
      moveLeftLength += PROMPT.length();
    }
    return ansi()
      .cursorUp(cursorMove)
      .cursorLeft(moveLeftLength)
      .eraseLine(FORWARD);
  }
  return ansi();
}

代码示例来源:origin: apache/hive

/**
 * NOTE: Use this method only if isUnixTerminal is true.
 * Erases the current line and prints the given line with the specified color.
 *
 * @param line  - line to print
 * @param color - color for the line
 */
private void reprintLineWithColorAsBold(String line, Ansi.Color color) {
 out.print(ansi().eraseLine(Ansi.Erase.ALL).fg(color).bold().a(line).a('\n').boldOff().reset()
  .toString());
 out.flush();
 lines++;
}

代码示例来源:origin: apache/drill

private void reprintLineWithColorAsBold(String line, Ansi.Color color) {
 out.print(ansi().eraseLine(Ansi.Erase.ALL).fg(color).bold().a(line).a('\n').boldOff().reset()
   .toString());
 out.flush();
 lines++;
}

代码示例来源:origin: fabric8io/docker-maven-plugin

private void updateAnsiProgress(String imageId, String status, String progressMessage) {
  Map<String,Integer> imgLineMap = imageLines.get();
  Integer line = imgLineMap.get(imageId);
  int diff = 0;
  if (line == null) {
    line = imgLineMap.size();
    imgLineMap.put(imageId, line);
  } else {
    diff = imgLineMap.size() - line;
  }
  if (diff > 0) {
    print(ansi().cursorUp(diff).eraseLine(Ansi.Erase.ALL).toString());
  }
  // Status with progress bars: (max length = 11, hence pad to 11)
  // Extracting
  // Downloading
  String progress = progressMessage != null ? progressMessage : "";
  String msg =
    ansi()
      .fg(COLOR_PROGRESS_ID).a(imageId).reset().a(": ")
      .fg(COLOR_PROGRESS_STATUS).a(StringUtils.rightPad(status,11) + " ")
      .fg(COLOR_PROGRESS_BAR).a(progress).toString();
  println(msg);
  if (diff > 0) {
    // move cursor back down to bottom
    print(ansi().cursorDown(diff - 1).toString());
  }
}

代码示例来源:origin: jamesagnew/hapi-fhir

long fileSize = FileUtils.sizeOf(localFile);
if (fileSize > nextLog) {
  System.err.print("\r" + ansi().eraseLine());
  System.err.print(FileUtils.byteCountToDisplaySize(fileSize));
  if (maxLength > 0) {

代码示例来源:origin: SpigotMC/BungeeCord

public void print(String s)
{
  for ( ChatColor color : colors )
  {
    s = s.replaceAll( "(?i)" + color.toString(), replacements.get( color ) );
  }
  try
  {
    console.print( Ansi.ansi().eraseLine( Erase.ALL ).toString() + ConsoleReader.RESET_LINE + s + Ansi.ansi().reset().toString() );
    console.drawLine();
    console.flush();
  } catch ( IOException ex )
  {
  }
}

代码示例来源:origin: org.gradle/gradle-logging

@Override
public AnsiContext eraseForward() {
  delegate.eraseLine(Ansi.Erase.FORWARD);
  return this;
}

代码示例来源:origin: org.apache.hive/hive-common

/**
 * NOTE: Use this method only if isUnixTerminal is true.
 * Erases the current line and prints the given multiline. Make sure the specified line is not
 * terminated by linebreak.
 *
 * @param line - line to print
 */
private void reprintMultiLine(String line) {
 int numLines = line.split("\r\n|\r|\n").length;
 out.print(ansi().eraseLine(Ansi.Erase.ALL).a(line).a('\n').toString());
 out.flush();
 lines += numLines;
}

代码示例来源:origin: org.jledit/core

@Override
public String delete() {
  console.out().print(ansi().eraseLine(Erase.FORWARD));
  String r = delegate.delete();
  if (r.equals(NEW_LINE) || r.equals(CARRIEGE_RETURN)) {
    redrawRestOfScreen();
  } else {
    redrawRestOfLine();
  }
  return r;
}

代码示例来源:origin: com.facebook.presto/presto-cli

public void reprintLine(String line)
{
  if (isRealTerminal()) {
    out.print(ansi().eraseLine(Erase.ALL).a(line).a('\n').toString());
  }
  else {
    out.print('\r' + line);
  }
  out.flush();
  lines++;
}

代码示例来源:origin: com.facebook.presto.hive/hive-apache

/**
 * NOTE: Use this method only if isUnixTerminal is true.
 * Erases the current line and prints the given line.
 * @param line - line to print
 */
public void reprintLine(String line) {
 out.print(ansi().eraseLine(Ansi.Erase.ALL).a(line).a('\n').toString());
 out.flush();
 lines++;
}

代码示例来源:origin: io.prestosql/presto-cli

public void reprintLine(String line)
{
  if (isRealTerminal()) {
    out.print(ansi().eraseLine(Erase.ALL).a(line).a('\n').toString());
  }
  else {
    out.print('\r' + line);
  }
  out.flush();
  lines++;
}

代码示例来源:origin: awegmann/consoleui

/**
 * Renders the confirmation message on the screen.
 */
private void render() {
 System.out.println("");
 System.out.println(ansi().eraseLine().cursorUp(2));
 System.out.print(renderMessagePrompt(this.confirmChoice.getMessage()) +
     itemRenderer.renderConfirmChoiceOptions(this.confirmChoice) + " " + ansi().reset().a(calcResultValue() + " ").eraseLine());
 System.out.flush();
 renderHeight = 1;
}

代码示例来源:origin: org.jboss.forge/forge-shell

@Override
public void clearLine()
{
 print(new Ansi().eraseLine(Ansi.Erase.ALL).toString());
}

代码示例来源:origin: org.apache.hive/hive-common

/**
 * NOTE: Use this method only if isUnixTerminal is true.
 * Erases the current line and prints the given line with the specified color.
 *
 * @param line  - line to print
 * @param color - color for the line
 */
private void reprintLineWithColorAsBold(String line, Ansi.Color color) {
 out.print(ansi().eraseLine(Ansi.Erase.ALL).fg(color).bold().a(line).a('\n').boldOff().reset()
  .toString());
 out.flush();
 lines++;
}

相关文章