Tabnine Logo
WindowsAnsiOutputStream
Code IndexAdd Tabnine to your IDE (free)

How to use
WindowsAnsiOutputStream
in
org.fusesource.jansi

Best Java code snippets using org.fusesource.jansi.WindowsAnsiOutputStream (Showing top 20 results out of 315)

origin: jline/jline

/**
 * Returns an ansi output stream handler. We return whatever was
 * passed if we determine we cannot handle ansi based on Kernel32 calls.
 * 
 * @return an @{link AltWindowAnsiOutputStream} instance or the passed 
 * stream.
 */
private static OutputStream wrapOutputStream(final OutputStream stream) {
  if (Configuration.isWindows()) {
    // On windows we know the console does not interpret ANSI codes..
    try {
      return new WindowsAnsiOutputStream(stream);
    } catch (Throwable ignore) {
      // this happens when JNA is not in the path.. or
      // this happens when the stdout is being redirected to a file.
    }
    // Use the ANSIOutputStream to strip out the ANSI escape sequences.
    return new AnsiOutputStream(stream);
  }
  return stream;
}
origin: org.fusesource.jansi/jansi

@Override
protected void processSetBackgroundColor(int color, boolean bright) throws IOException {
  info.attributes = (short) ((info.attributes & ~0x0070) | ANSI_BACKGROUND_COLOR_MAP[color]);
  if (bright) {
    info.attributes |= BACKGROUND_INTENSITY;
  }
  applyAttribute();
}
origin: org.fusesource.jansi/jansi

@Override
protected void processCursorUp(int count) throws IOException {
  getConsoleInfo();
  info.cursorPosition.y = (short) Math.max(info.window.top, info.cursorPosition.y - count);
  applyCursorPosition();
}
origin: org.fusesource.jansi/jansi

public WindowsAnsiOutputStream(OutputStream os) throws IOException { // expected diff with WindowsAnsiPrintStream.java
  super(os); // expected diff with WindowsAnsiPrintStream.java
  getConsoleInfo();
  originalColors = info.attributes;
}
origin: org.fusesource.jansi/jansi

private void getConsoleInfo() throws IOException {
  out.flush(); // expected diff with WindowsAnsiPrintStream.java
  if (GetConsoleScreenBufferInfo(console, info) == 0) {
    throw new IOException("Could not get the screen info: " + WindowsSupport.getLastErrorMessage());
  }
  if (negative) {
    info.attributes = invertAttributeColors(info.attributes);
  }
}
origin: org.fusesource.jansi/jansi

@Override
protected void processRestoreCursorPosition() throws IOException {
  // restore only if there was a save operation first
  if (savedX != -1 && savedY != -1) {
    out.flush(); // expected diff with WindowsAnsiPrintStream.java
    info.cursorPosition.x = savedX;
    info.cursorPosition.y = savedY;
    applyCursorPosition();
  }
}
origin: org.fusesource.jansi/jansi

@Override
protected void processSaveCursorPosition() throws IOException {
  getConsoleInfo();
  savedX = info.cursorPosition.x;
  savedY = info.cursorPosition.y;
}
origin: org.fusesource.jansi/jansi

private void applyAttribute() throws IOException {
  out.flush(); // expected diff with WindowsAnsiPrintStream.java
  short attributes = info.attributes;
  if (negative) {
    attributes = invertAttributeColors(attributes);
  }
  if (SetConsoleTextAttribute(console, attributes) == 0) {
    throw new IOException(WindowsSupport.getLastErrorMessage());
  }
}
origin: locationtech/geogig

public boolean checkAnsiSupported(OutputStream out, String osName) throws Throwable {
  if (out != System.out) {
    return false;
  }
  if (osName.startsWith("windows") && osName.endsWith("10")) {
    new WindowsAnsiOutputStream(out);
  } else if (osName.startsWith("windows") && !osName.endsWith("10")) {
    return false;
  }
  if (System.console() == null) {
    return false;
  }
  return true;
}
origin: org.fusesource.jansi/jansi

@Override
protected void processCursorLeft(int count) throws IOException {
  getConsoleInfo();
  info.cursorPosition.x = (short) Math.max(0, info.cursorPosition.x - count);
  applyCursorPosition();
}
origin: org.fusesource.jansi/jansi

@Override
protected void processAttributeRest() throws IOException {
  info.attributes = (short) ((info.attributes & ~0x00FF) | originalColors);
  this.negative = false;
  applyAttribute();
}
origin: org.fusesource.jansi/jansi

@Override
protected void processDeleteLine(int optionInt) throws IOException {
  getConsoleInfo();
  SMALL_RECT scroll = info.window.copy();
  scroll.top = info.cursorPosition.y;
  COORD org = new COORD();
  org.x = 0;
  org.y = (short)(info.cursorPosition.y - optionInt);
  CHAR_INFO info = new CHAR_INFO();
  info.attributes = originalColors;
  info.unicodeChar = ' ';
  if (ScrollConsoleScreenBuffer(console, scroll, scroll, org, info) == 0) {
    throw new IOException(WindowsSupport.getLastErrorMessage());
  }
}
origin: org.locationtech.geogig/geogig-cli-core

public boolean checkAnsiSupported(OutputStream out, String osName) throws Throwable {
  if (out != System.out) {
    return false;
  }
  if (osName.startsWith("windows") && osName.endsWith("10")) {
    new WindowsAnsiOutputStream(out);
  } else if (osName.startsWith("windows") && !osName.endsWith("10")) {
    return false;
  }
  if (System.console() == null) {
    return false;
  }
  return true;
}
origin: org.fusesource.jansi/jansi

@Override
protected void processCursorDown(int count) throws IOException {
  getConsoleInfo();
  info.cursorPosition.y = (short) Math.min(Math.max(0, info.size.y - 1), info.cursorPosition.y + count);
  applyCursorPosition();
}
origin: org.fusesource.jansi/jansi

@Override
protected void processSetForegroundColor(int color, boolean bright) throws IOException {
  info.attributes = (short) ((info.attributes & ~0x0007) | ANSI_FOREGROUND_COLOR_MAP[color]);
  if (bright) {
    info.attributes |= FOREGROUND_INTENSITY;
  }
  applyAttribute();
}
origin: org.fusesource.jansi/jansi

@Override
protected void processInsertLine(int optionInt) throws IOException {
  getConsoleInfo();
  SMALL_RECT scroll = info.window.copy();
  scroll.top = info.cursorPosition.y;
  COORD org = new COORD();
  org.x = 0;
  org.y = (short)(info.cursorPosition.y + optionInt);
  CHAR_INFO info = new CHAR_INFO();
  info.attributes = originalColors;
  info.unicodeChar = ' ';
  if (ScrollConsoleScreenBuffer(console, scroll, scroll, org, info) == 0) {
    throw new IOException(WindowsSupport.getLastErrorMessage());
  }
}
origin: org.locationtech.geogig/geogig-cli

public boolean checkAnsiSupported(OutputStream out, String osName) throws Throwable {
  if (out != System.out) {
    return false;
  }
  if (osName.startsWith("windows") && osName.endsWith("10")) {
    new WindowsAnsiOutputStream(out);
  } else if (osName.startsWith("windows") && !osName.endsWith("10")) {
    return false;
  }
  if (System.console() == null) {
    return false;
  }
  return true;
}
origin: org.fusesource.jansi/jansi

@Override
protected void processCursorRight(int count) throws IOException {
  getConsoleInfo();
  info.cursorPosition.x = (short) Math.min(info.window.width(), info.cursorPosition.x + count);
  applyCursorPosition();
}
origin: org.fusesource.jansi/jansi

@Override
protected void processDefaultTextColor() throws IOException {
  info.attributes = (short) ((info.attributes & ~0x000F) | (originalColors & 0xF));
  info.attributes = (short) (info.attributes & ~FOREGROUND_INTENSITY);
  applyAttribute();
}
origin: org.fusesource.jansi/jansi

@Override
protected void processEraseLine(int eraseOption) throws IOException {
  getConsoleInfo();
  int[] written = new int[1];
  switch (eraseOption) {
    case ERASE_LINE:
      COORD leftColCurrRow = info.cursorPosition.copy();
      leftColCurrRow.x = 0;
      FillConsoleOutputAttribute(console, originalColors, info.size.x, leftColCurrRow, written);
      FillConsoleOutputCharacterW(console, ' ', info.size.x, leftColCurrRow, written);
      break;
    case ERASE_LINE_TO_BEGINING:
      COORD leftColCurrRow2 = info.cursorPosition.copy();
      leftColCurrRow2.x = 0;
      FillConsoleOutputAttribute(console, originalColors, info.cursorPosition.x, leftColCurrRow2, written);
      FillConsoleOutputCharacterW(console, ' ', info.cursorPosition.x, leftColCurrRow2, written);
      break;
    case ERASE_LINE_TO_END:
      int lengthToLastCol = info.size.x - info.cursorPosition.x;
      FillConsoleOutputAttribute(console, originalColors, lengthToLastCol, info.cursorPosition.copy(), written);
      FillConsoleOutputCharacterW(console, ' ', lengthToLastCol, info.cursorPosition.copy(), written);
      break;
    default:
      break;
  }
}
org.fusesource.jansiWindowsAnsiOutputStream

Javadoc

A Windows ANSI escape processor, that uses JNA to access native platform API's to change the console attributes.

Most used methods

  • <init>
  • applyAttribute
  • applyCursorPosition
  • getConsoleInfo
  • invertAttributeColors

Popular in Java

  • Reactive rest calls using spring rest template
  • findViewById (Activity)
  • setScale (BigDecimal)
  • getContentResolver (Context)
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • Path (java.nio.file)
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now