@Override public void complete(LineReader lineReader, ParsedLine parsedLine, List<Candidate> candidates) { String buffer = parsedLine.word().trim(); if (Strings.isNullOrEmpty(buffer)) { candidates.addAll(_commandStrs.stream().map(Candidate::new).collect(Collectors.toList())); } else { for (String match : _commandStrs.tailSet(buffer)) { if (!match.startsWith(buffer)) { break; } candidates.add(new Candidate(match)); } } // if the match was unique and the complete command was specified, print the command usage if (candidates.size() == 1 && candidates.get(0).displ().equals(buffer)) { candidates.clear(); candidates.add( new Candidate( " " + Command.getUsageMap().get(Command.getNameMap().get(buffer)).getFirst())); } } }
int len = wcwidth.apply(cand.displ()); if (cand.descr() != null) { len += MARGIN_BETWEEN_DISPLAY_AND_DESC;
Candidate cand = candidates.get(idx); boolean hasRightItem = j < columns - 1 && index.applyAsInt(i, j + 1) < candidates.size(); AttributedString left = AttributedString.fromAnsi(cand.displ()); AttributedString right = AttributedString.fromAnsi(cand.descr()); int lw = left.columnLength();