-
-
Notifications
You must be signed in to change notification settings - Fork 532
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
Introducing StringSlice for Segment.Text #671
Comments
@xoofx Sounds like an excellent idea. We're aware of the problem but deliberately haven't been optimizing stuff (yet) in favor of getting things to work. If you want to send a draft PR for this, it would be greatly appreciated. |
Great. What should I do about the type? Use |
I have no problem adding a dependency on Again, really appreciate you raising this issue (and, of course, doing a PR). |
Hey, Also, after digging more into the details, I'm a bit too frustrated by the So I'm gonna close this issue, my apologize for the false hope! |
Hello Spectre.Console friends!
I'm starting to evaluate how I can use Spectre.Console for editing/rendering syntax highlighted languages and I have a suggestion to improve its support.
While a
Segment
has aText
property defined as astring
, it forces to split the original text string by its styled strings and to maintain externally a map of the split strings with the original string. e.g:var x = 5;
would generatevar
,x
,=
,5
,;
and we would have to keep the character position of each splits from the original string.Instead of using a
string
forSegment.Text
we could use a string slice (e.g a string + offset + length) which could allow to use the same original string but offer a view on it to the segment.Most of the code using it would not change much, as the contact of this type would mostly replicate the contract of a string.
There is the type
StringSegment
but it would bring a new dependencies. Also I discovered that it doesn't provide a char iterator (and some other methods, e.g likeTrim
)So the question is: can we use
StringSegment
(we can provide extension methods/enumerator on it likely) or should we introduce a new type?Maintaining the map to the original string outside of
Spectre.Console
.I can make a draft PR if you are interested in this feature? 🙂
The text was updated successfully, but these errors were encountered: