1use console::AnsiCodeIterator;
3/// Expand tabs like an ANSI-enabled expand(1).
4pub fn expand_tabs(line: &str, width: usize, cursor: &mut usize) -> String {
5 let mut buffer = String::with_capacity(line.len() * 2);
7 for chunk in AnsiCodeIterator::new(line) {
9 (text, true) => buffer.push_str(text),
10 (mut text, false) => {
11 while let Some(index) = text.find('\t') {
15 buffer.push_str(&text[0..index]);
19 let spaces = width - (*cursor % width);
21 buffer.push_str(&*" ".repeat(spaces));
24 text = &text[index + 1..text.len()];
27 *cursor += text.len();
28 buffer.push_str(text);
36pub fn replace_nonprintable(input: &str, tab_width: usize) -> String {
37 let mut output = String::new();
39 let tab_width = if tab_width == 0 { 4 } else { tab_width };
41 for chr in input.chars() {
44 ' ' => output.push('•'),
51 output.push_str(&"─".repeat(tab_width - 2));
56 '\x0A' => output.push('␊'),
58 '\x0D' => output.push('␍'),
60 '\x00' => output.push('␀'),
62 '\x07' => output.push('␇'),
64 '\x08' => output.push('␈'),
66 '\x1B' => output.push('␛'),
68 _ => output.push(chr),
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list