-
-
Notifications
You must be signed in to change notification settings - Fork 40
Improve escape sequence compatibility #656
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
Conversation
noborus
commented
Nov 14, 2024
- Enhanced handling of invalid values in escape sequences to better match terminal and `less`` behavior.
- Updated related functions to ensure compatibility.
- Improved error handling and reporting for invalid escape sequences.
- Enhanced handling of invalid values in escape sequences to better match terminal and `less`` behavior. - Updated related functions to ensure compatibility. - Improved error handling and reporting for invalid escape sequences.
@@ -90,6 +96,9 @@ func (es *escapeSequence) convert(st *parseState) bool { | |||
case mainc >= '0' && mainc <= 'f': | |||
es.parameter.WriteRune(mainc) | |||
return true | |||
case mainc < 0x40: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a magical number here, you should either explain why it's 0x40, or add a constant with a meaningful name
0x40 is @ right? 0x41 is A
What is this if statement about?
Checking that anything before @ is handled in a common way? But then @ is not caught?
I'm still unsure about what the code does
num, err := strconv.Atoi(str) | ||
if err != nil { | ||
for _, char := range str { | ||
if char >= 0x40 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same test with 0x40
} | ||
|
||
// csColor parses 8-bit color and 24-bit color. | ||
func csColor(fields []string) (int, string) { | ||
if len(fields) < 2 { | ||
return 0, "" | ||
} | ||
if fields[1] == "" { | ||
return 1, "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use constant for 0-5 and give them meaningful names
s.Bold = true | ||
case "2", "02": | ||
case 2: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use constants for all these numbers, and give them names
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [noborus/ov](https://github.com/noborus/ov) | minor | `v0.37.0` -> `v0.38.0` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>noborus/ov (noborus/ov)</summary> ### [`v0.38.0`](https://github.com/noborus/ov/releases/tag/v0.38.0) [Compare Source](noborus/ov@v0.37.0...v0.38.0) #### What's Changed - Improve escape sequence compatibility by [@​noborus](https://github.com/noborus) in noborus/ov#656 - Add support for colon-separated values by [@​noborus](https://github.com/noborus) in noborus/ov#657 - Change the range to csiParamStart/csiParamEnd by [@​noborus](https://github.com/noborus) in noborus/ov#659 - Add stdin specification by [@​noborus](https://github.com/noborus) in noborus/ov#661 - Reimplemented osc hyperlink by [@​noborus](https://github.com/noborus) in noborus/ov#664 - Fixed incompatibility in handling invalid osc by [@​noborus](https://github.com/noborus) in noborus/ov#665 - Upgrade tcell to v2.8.0 and add support for Underline style and color by [@​noborus](https://github.com/noborus) in noborus/ov#680 - Add EOF notification feature by [@​noborus](https://github.com/noborus) in noborus/ov#683 - Add function to wait for EOF by [@​noborus](https://github.com/noborus) in noborus/ov#673 - Fix the first position of Follow and Followall by [@​noborus](https://github.com/noborus) in noborus/ov#671 - Fix DocumentLen() out-of-range checks by [@​noborus](https://github.com/noborus) in noborus/ov#675 **Full Changelog**: noborus/ov@v0.37.0...v0.38.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xMzcuMiIsInVwZGF0ZWRJblZlciI6IjM5LjEzNy4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->