jline / jline3

JLine is a Java library for handling console input.
Other
1.49k stars 218 forks source link

Highlighting in history output #325

Closed snuyanzin closed 6 years ago

snuyanzin commented 6 years ago

Could you please tell if there is a way to use the same highlighters for history output (to highlight each history record individually) as for LineReader ?

snuyanzin commented 6 years ago

such code snippet inside org.jline.builtins.Commands#history helps

 Highlighter highlighter = reader.getHighlighter();
        for (History.Entry entry : history) {
            ...
            sb.append(highlighter.highlight(reader, entry.line()));
            ...
        }

Please let me know if there is anything I could miss

gnodet commented 6 years ago

Yes, that should be fine. The LineReader also uses a MaskingCallback, but the history should be filtered already, so there's no need to handle that when displaying.

gnodet commented 6 years ago

Feel free to provide a Pull Request to make the history command nicer :-)