mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-25 18:03:37 +08:00
2087a3ca63
Because we are, ultimately, interested in how many cells a string occupies, we *have* to handle carriage return (`\r`) and line feed (`\n`). A carriage return sets the current tally to 0, and only the longest tally is kept. The idea here is that the last position is the same as the last position of the longest string. So: abcdef\r123 ends up looking like 123def which is the same width as abcdef, 6. A line feed meanwhile means we flush the current tally and start a new one. Every line is printed separately, even if it's given as one. That's because, well, counting the width over multiple lines doesn't *help*. As a sidenote: This is necessarily imperfect, because, while we may know the width of the terminal ($COLUMNS), we don't know the current cursor position. So we can only give the width, and the user can then figure something out on their own. But for the common case of figuring out how wide the prompt is, this should do. |
||
---|---|---|
.. | ||
checks | ||
pexpects | ||
test_functions | ||
.gitignore | ||
history_sample_bash | ||
history_sample_corrupt1 | ||
history_sample_fish_1_x | ||
history_sample_fish_2_0 | ||
interactive.config | ||
interactive.fish | ||
test_util.fish | ||
test.fish |