Tabnine Logo
TerminalString.getCharacters
Code IndexAdd Tabnine to your IDE (free)

How to use
getCharacters
method
in
org.aesh.readline.terminal.formatting.TerminalString

Best Java code snippets using org.aesh.readline.terminal.formatting.TerminalString.getCharacters (Showing top 20 results out of 315)

origin: org.aesh/aesh-readline

private static boolean startsWithTerminalString(String criteria, List<TerminalString> completionList) {
  for (TerminalString completion : completionList)
    if (!completion.getCharacters().startsWith(criteria))
      return false;
  return true;
}
origin: org.aesh/aesh-readline

  @Override
  public int compareTo(TerminalString terminalString) {
    return this.characters.compareTo(terminalString.getCharacters());
  }
}
origin: org.aesh/aesh-readline

private static int[] calculateColumnSizes(List<TerminalString> displayList, int numColumns, int numRows, int termWidth) {
  int[] columnSizes = new int[numColumns];
  for (int i = 0; i < displayList.size(); i++) {
    int columnIndex = (i / numRows) % numColumns;
    int stringSize = displayList.get(i).getCharacters().length() + 2;
    if (columnSizes[columnIndex] < stringSize && stringSize <= termWidth) {
      columnSizes[columnIndex] = stringSize;
    }
  }
  return columnSizes;
}
origin: org.aesh/aesh-readline

@Override
public List<String> getFormattedCompletionCandidates() {
  List<String> fixedCandidates = new ArrayList<String>(completionCandidates.size());
  for(TerminalString c : completionCandidates) {
    if(!ignoreOffset && offset < cursor) {
      int pos = cursor - offset;
      if(c.getCharacters().length() >= pos)
        fixedCandidates.add(c.getCharacters().substring(pos));
      else
        fixedCandidates.add("");
    }
    else {
      fixedCandidates.add(c.getCharacters());
    }
  }
  return fixedCandidates;
}
origin: org.aesh/aesh-readline

/**
 * Return the biggest common startsWith string
 *
 * @param completionList list to compare
 * @return biggest common startsWith string
 */
public static String findStartsWithTerminalString(List<TerminalString> completionList) {
  StringBuilder builder = new StringBuilder();
  for (TerminalString completion : completionList)
    while (builder.length() < completion.getCharacters().length() &&
        startsWithTerminalString(completion.getCharacters().substring(0, builder.length() + 1), completionList))
      builder.append(completion.getCharacters().charAt(builder.length()));
  return builder.toString();
}
origin: org.aesh/aesh-readline

public void write(PrintStream out) {
  if(ignoreRendering) {
    out.print(characters);
  }
  else {
    out.print(ANSI.START);
    out.print(style.toString());
    out.print(';');
    this.color.write(out);
    out.print('m');
    out.print(getCharacters());
  }
}
origin: org.aesh/aesh-readline

@Override
public List<TerminalString> getFormattedCompletionCandidatesTerminalString() {
  List<TerminalString> fixedCandidates = new ArrayList<>(completionCandidates.size());
  for(TerminalString c : completionCandidates) {
    if(!ignoreOffset && offset < cursor) {
      int pos = cursor - offset;
      if(c.getCharacters().length() >= pos) {
        c.setCharacters(c.getCharacters().substring(pos));
        fixedCandidates.add(c);
      }
      else
        fixedCandidates.add(new TerminalString("", true));
    }
    else {
      fixedCandidates.add(c);
    }
  }
  return fixedCandidates;
}
origin: org.aesh/aesh-readline

public static void switchEscapedSpacesToSpacesInTerminalStringList(List<TerminalString> list) {
  for (TerminalString ts : list)
    ts.setCharacters(switchEscapedSpacesToSpacesInWord(ts.getCharacters()));
}
origin: org.aesh/aesh-readline

@Override
public String toString() {
  if(ignoreRendering)
    return characters;
  return ANSI.START + style.toString() + ';' +
      this.color.toString() +
      'm' + getCharacters() + ANSI.RESET;
}
origin: org.wildfly.core/wildfly-cli

@Override
public int complete(CommandContext ctx, String buffer, int cursor, List<String> candidates) {
  AeshCompleteOperation op = new AeshCompleteOperation(buffer, cursor);
  cliCompleter.complete(ctx, op, this);
  if (!op.getCompletionCandidates().isEmpty()) {
    for (TerminalString ts : op.getCompletionCandidates()) {
      candidates.add(ts.getCharacters());
    }
    return op.getOffset();
  }
  return -1;
}
origin: org.aesh/aesh-readline

public Prompt(TerminalString terminalString) {
  if(terminalString != null) {
    ansiString = Parser.toCodePoints(terminalString.toString());
    this.prompt = Parser.toCodePoints(terminalString.getCharacters());
  }
  else
    this.prompt = new int[]{};
}
origin: org.aesh/aesh-readline

/**
 * style, text color, background color
 */
public String toString(TerminalString prev) {
  if(ignoreRendering)
    return characters;
  if(equalsIgnoreCharacter(prev))
    return characters;
  else {
    StringBuilder builder = new StringBuilder();
    builder.append(ANSI.START)
        .append(style.getValueComparedToPrev(prev.getStyle()));
    if(!this.color.equals(prev.color)) {
      if(prev.getStyle().isInvert())
        builder.append(';').append(this.color.toString());
      else
        builder.append(';').append(this.color.toString(prev.color));
    }
    builder.append('m').append(getCharacters());
    return builder.toString();
  }
}
origin: wildfly/wildfly-core

@Override
public int complete(CommandContext ctx, String buffer, int cursor, List<String> candidates) {
  AeshCompleteOperation op = new AeshCompleteOperation(buffer, cursor);
  cliCompleter.complete(ctx, op, this);
  if (!op.getCompletionCandidates().isEmpty()) {
    for (TerminalString ts : op.getCompletionCandidates()) {
      candidates.add(ts.getCharacters());
    }
    return op.getOffset();
  }
  return -1;
}
origin: org.wildfly.core/wildfly-cli

@Override
public int complete(CommandContext ctx, String buffer, int cursor, List<String> candidates) {
  AeshCompleteOperation co = new AeshCompleteOperation(aeshCommands.getAeshContext(), buffer, cursor);
  complete(co);
  for (TerminalString ts : co.getCompletionCandidates()) {
    candidates.add(ts.getCharacters());
  }
  if (co.getCompletionCandidates().isEmpty()) {
    return -1;
  }
  Collections.sort(candidates);
  return co.getOffset();
}
origin: wildfly/wildfly-core

@Override
public int complete(CommandContext ctx, String buffer, int cursor, List<String> candidates) {
  AeshCompleteOperation co = new AeshCompleteOperation(aeshCommands.getAeshContext(), buffer, cursor);
  complete(co);
  for (TerminalString ts : co.getCompletionCandidates()) {
    candidates.add(ts.getCharacters());
  }
  if (co.getCompletionCandidates().isEmpty()) {
    return -1;
  }
  Collections.sort(candidates);
  return co.getOffset();
}
origin: aeshell/aesh

  private void completeDataWithValues(CompleterInvocation completerData) {
    if(completerData.getCompleterValues().size() == 1 &&
        completerData.getCompleterValues().get(0).containSpaces()) {
      String tmpData = Parser.switchSpacesToEscapedSpacesInWord(
          completerData.getCompleterValues().get(0).getCharacters());
      completerData.clearCompleterValues();
      completerData.addCompleterValue(tmpData);
      completerData.setAppendSpace(true);
    }
  }
}
origin: wildfly/wildfly-core

  private void completeLegacyCommands(CommandContext ctx, DefaultCallbackHandler parsedCmd, AeshCompleteOperation co) {
    legacyCommandCompleter.complete(ctx, parsedCmd, co);
    // DMR Operations and command handler completion doesn't work well with whitespace separator, so must not be appended.
    // whitespace only appended at the end of a command name.
    String buffer = ctx.getArgumentsString() == null ? co.getBuffer() : ctx.getArgumentsString() + co.getBuffer();
    if (co.getCompletionCandidates().size() == 1
        && co.getCompletionCandidates().get(0).getCharacters().startsWith(buffer)) {
      co.doAppendSeparator(true);
    } else if (!co.getCompletionCandidates().isEmpty()) {
      co.doAppendSeparator(false);
    }
  }
}
origin: org.wildfly.core/wildfly-cli

  private void completeLegacyCommands(CommandContext ctx, DefaultCallbackHandler parsedCmd, AeshCompleteOperation co) {
    legacyCommandCompleter.complete(ctx, parsedCmd, co);
    // DMR Operations and command handler completion doesn't work well with whitespace separator, so must not be appended.
    // whitespace only appended at the end of a command name.
    String buffer = ctx.getArgumentsString() == null ? co.getBuffer() : ctx.getArgumentsString() + co.getBuffer();
    if (co.getCompletionCandidates().size() == 1
        && co.getCompletionCandidates().get(0).getCharacters().startsWith(buffer)) {
      co.doAppendSeparator(true);
    } else if (!co.getCompletionCandidates().isEmpty()) {
      co.doAppendSeparator(false);
    }
  }
}
origin: aeshell/aesh

  @Test
  public void testRemoveEscapedSpacesFromCompletionCandidates() {
    AeshCompleteOperation co = new AeshCompleteOperation(aeshContext, "ls foob", 6);
    co.addCompletionCandidate("foo\\ bar");
    co.addCompletionCandidate("foo\\ bars");
    co.setOffset(3);

    co.removeEscapedSpacesFromCompletionCandidates();

    assertEquals("foo bar", co.getCompletionCandidates().get(0).getCharacters());
    assertEquals("foo bars", co.getCompletionCandidates().get(1).getCharacters());
  }
}
origin: org.aesh/aesh-readline

/**
 * Display the completion string in the terminal.
 * If !completion.startsWith(buffer.getLine()) the completion will be added to the line,
 * else it will replace whats at the buffer line.
 *
 * @param completion partial completion
 * @param appendSpace if its an actual complete
 */
private void displayCompletion(TerminalString completion, Buffer buffer, InputProcessor inputProcessor,
                boolean appendSpace, char separator) {
  if(completion.getCharacters().startsWith(buffer.asString())) {
    ActionMapper.mapToAction("backward-kill-word").accept(inputProcessor);
    inputProcessor.buffer().writeString(completion.toString());
  }
  else {
    inputProcessor.buffer().writeString(completion.toString());
  }
  if(appendSpace) {
    inputProcessor.buffer().writeChar(separator);
  }
}
org.aesh.readline.terminal.formattingTerminalStringgetCharacters

Popular methods of TerminalString

  • <init>
  • toString
    style, text color, background color
  • containSpaces
  • equalsIgnoreCharacter
  • getANSILength
  • getStyle
  • isFormatted
  • setCharacters
  • switchSpacesToEscapedSpaces

Popular in Java

  • Updating database using SQL prepared statement
  • findViewById (Activity)
  • compareTo (BigDecimal)
  • getSystemService (Context)
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Top plugins for WebStorm
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