Skip to content
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

Implement a zero-width styled segment #1039

Open
krader1961 opened this issue May 20, 2020 · 2 comments
Open

Implement a zero-width styled segment #1039

krader1961 opened this issue May 20, 2020 · 2 comments
Labels
Milestone

Comments

@krader1961
Copy link
Contributor

@krader1961 krader1961 commented May 20, 2020

There was a question on Gitter/IM earlier today about how to include sequences in the prompt that don't affect the visible width of the prompt and are present solely for their side-effects. Such as changing the terminal title or marking the end of the prompt in a manner recognized by the terminal. An example of the latter is the FTCS_COMMAND_START sequence recognized by iTerm2.

Zsh does provide for this use case via its %{...%} bracketed sequences. The Elvish equivalent would be a special styled segment that indicates the segment promises not to change the location of the cursor.

My suggestion is to add a zero-width style transformer; e.g., styled $obj zero-width. That transformer cannot be combined with any other transformer because constructs like styled $obj green zero-width are nonsensical. @xiaq, however, expressed a preference for a discrete command (zero-width?) to make the lack of composability with normal styled objects clearer.

@zzamboni
Copy link
Contributor

@zzamboni zzamboni commented Jul 11, 2020

After all the discussion and clarification in multiple issues (thanks @krader1961 and @xiaq!) I realize this would be the most useful feature at the moment for iTerm2 integration as implemented by iterm2.elv.

In fact, given that iTerm2 now allows variable-length prompts by re-emitting the "prompt end" escape code (https://gitlab.com/gnachman/iterm2/-/issues/8996), I'm afraid the next release of iTerm2 will break the current implementation of iterm2.elv without the zero-width segments :(

So this feature has a big vote from me 😄

@krader1961
Copy link
Contributor Author

@krader1961 krader1961 commented Aug 11, 2020

@xiaq, Do you have a strong opinion as to whether this should be implemented via a new edit:zero-width command or a zero-width transformer to thebuiltin:styled command? I prefer the latter since the point is to make it clear that the result is simply a styled segment that has no visible output; other than as a result of side-effects due to magic escape sequences. If this is implemented in terms of a new zero-width command (whatever it is named) that introduces a new data type that has to be handled by styled, echo, etc. If that command just produces a styled object with a "zero width" attribute why use a new command to produce it? If it produces a new, distinct, object then everywhere that consumes a sytyled-object has to also handle the new type.

I do not think introducing a distinct "zero-width" type, to indicate lack of composability with the styled-segment type, is worth the cost. There are undoubtedly many, existing, cases where combining attributes in a styled-segment do not make sense. A zero-width segment is just one such example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.