<commit_before>package com.jediterm.terminal;

import com.google.common.base.Ascii;

public class CharacterUtils {

  public static final int ESC = Ascii.ESC;
  public static final int DEL = Ascii.DEL;

  private CharacterUtils() {
  }

  private static final String[] NONPRINTING_NAMES = {"NUL", "SOH", "STX", "ETX", "EOT", "ENQ",
    "ACK", "BEL", "BS", "TAB", "LF", "VT", "FF", "CR", "S0", "S1",
    "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "CAN",
    "EM", "SUB", "ESC", "FS", "GS", "RS", "US"};

  public static byte[] VT102_RESPONSE = makeCode(ESC, '[', '?', '6', 'c');

  public static String getNonControlCharacters(int maxChars, char[] buf, int offset, int charsLength) {
    int len = maxChars > charsLength ? charsLength : maxChars;

    final int origLen = len;
    char tmp;
    while (maxChars > 0) {
      tmp = buf[offset++];
      if (0x20 <= tmp) { //stop when we reach control chars
        len--;
        continue;
      }
      offset--;
      break;
    }

    int length = origLen - len;

    return new String(buf, offset - length, length);
  }

  public enum CharacterType {
    NONPRINTING,
    PRINTING,
    NONASCII, NONE
  }

  public static CharacterType appendChar(final StringBuilder sb, final CharacterType last, final char c) {
    if (c <= 0x1F) {
      sb.append(' ');
      sb.append(NONPRINTING_NAMES[c]);
      return CharacterType.NONPRINTING;
    }
    else if (c == DEL) {<commit_msg>Revert stupid bug.<commit_after>package com.jediterm.terminal;

import com.google.common.base.Ascii;

public class CharacterUtils {

  public static final int ESC = Ascii.ESC;
  public static final int DEL = Ascii.DEL;

  private CharacterUtils() {
  }

  private static final String[] NONPRINTING_NAMES = {"NUL", "SOH", "STX", "ETX", "EOT", "ENQ",
    "ACK", "BEL", "BS", "TAB", "LF", "VT", "FF", "CR", "S0", "S1",
    "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "CAN",
    "EM", "SUB", "ESC", "FS", "GS", "RS", "US"};

  public static byte[] VT102_RESPONSE = makeCode(ESC, '[', '?', '6', 'c');

  public static String getNonControlCharacters(int maxChars, char[] buf, int offset, int charsLength) {
    int len = maxChars > charsLength ? charsLength : maxChars;

    final int origLen = len;
    char tmp;
    while (len > 0) {
      tmp = buf[offset++];
      if (0x20 <= tmp) { //stop when we reach control chars
        len--;
        continue;
      }
      offset--;
      break;
    }

    int length = origLen - len;

    return new String(buf, offset - length, length);
  }

  public enum CharacterType {
    NONPRINTING,
    PRINTING,
    NONASCII, NONE
  }

  public static CharacterType appendChar(final StringBuilder sb, final CharacterType last, final char c) {
    if (c <= 0x1F) {
      sb.append(' ');
      sb.append(NONPRINTING_NAMES[c]);
      return CharacterType.NONPRINTING;
    }
    else if (c == DEL) {
{'fraction_non_alphanumeric': 0.16065232477446217, 'fraction_numerical': 0.011103400416377515, 'mean_word_length': 2.9710743801652892, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6435775', 'n_tokens_mistral': 1063, 'n_tokens_neox': 991, 'n_words': 294}