New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pager: fix printing non-visible characters \001
& \002
#2207
base: master
Are you sure you want to change the base?
Conversation
This would only work for people using I believe a better option would be to manually opt-out of using the escapes through a configuration. |
I've created PR #2209 on top of this one, that makes header escapes optional, that should help people who aren't using terminals and pagers that support those escapes. |
When |
Ah, sorry. I think we're talking about separate issues caused by the same thing. In both following cases, I'm using When Pry uses the pager, because it's filling more than 1 page, I get this result: When it doesn't (i.e., the output doesn't fill a whole page, so it doesn't use the pager), I get this: Essentially, it's the same issue, but from different perspectives. Granted, it's not the best option when using a combination of terminal and pager where only one of them needs the escape codes to work consistently, but in #2209 I was trying to give people a workaround for when their terminal and/or pager doesn't work well with the escape codes.
|
Are your screenshots from the current release or this PR? Sorry, it's not clear. |
Those were taken from the current release ( If I use this PR, I only get those smiley faces instead of |
I was looking more into I've managed to test this with echo -e "\001\e[31m\002foo\001\e[0m\002" | less -R -r echo -e "\001\e[31m\002foo\001\e[0m\002" | less -r -R Reading the most recent |
I believe I understand the problem a bit better now. The issue is that the I think there are 3 options here, from thoughest to simplest:
I've attempted option 2, and although it didn't display I assume option 1 would be overkill, since we're adding the controls everywhere and then every time we write to the output we have to strip them. I went with option 3 because if this, since it was a simple case of adding the escapes in a single method ( I believe PR #2209 can be used in favour of this one, and this PR can be closed. |
Fixes #2185 (Non-Visible Characters Printed with Page) The `--raw-control-chars` option (aka `-r`) does the following: ``` Causes "raw" control characters to be displayed. The default is to display control characters using the caret notation; for example, a control-A (octal 001) is displayed as "^A". Warning: when the -r option is used, less cannot keep track of the actual appearance of the screen (since this depends on how the screen responds to each type of control character). Thus, various dis- play problems may result, such as long lines being split in the wrong place. ``` The `--RAW-CONTROL-CHARS` option was always used with the pager, I just expanded it from `-R`, so that it looks more descriptive. For reference, it does the following: ``` Like -r, but only ANSI "color" escape sequences are output in "raw" form. Unlike -r, the screen appearance is maintained cor- rectly in most cases. ANSI "color" escape sequences are sequences of the form: ESC [ ... m where the "..." is zero or more color specification characters For the purpose of keeping track of screen appearance, ANSI color escape sequences are assumed to not move the cursor. You can make less think that characters other than "m" can end ANSI color escape sequences by setting the environment variable LESSANSIENDCHARS to the list of characters which can end a color escape sequence. And you can make less think that characters other than the standard ones may appear between the ESC and the m by setting the environment variable LESSANSIMIDCHARS to the list of characters which can appear. ```
288a40a
to
120afab
Compare
I was digging into this tonight and it seems that either less needs to be called with In the meantime I'm using this bash script to work around this issue. Maybe others will find it useful.
|
@smook1980 it's been a long while since I've looked into this, but if I recall correctly, I don't recall in detail when it happens, but reading my past comments, I think it's when strings are printed to the prompt when not using Readline nor a pager, which happens when doing something like |
This fixes pager output from my |
Fixes #2185 (Non-Visible Characters Printed with Page)
The
--raw-control-chars
option (aka-r
) does the following:The
--RAW-CONTROL-CHARS
option was always used with the pager, I just expandedit from
-R
, so that it looks more descriptive. For reference, it does thefollowing: