* feat: add Ellipsize enum
* chore: API changes needed for ellipsize
Decided not to change "layout()" function for now to avoid breaking the
interface. For now.
* chore: shape ellipsis
* feat: Ellipsize::Start
Since it can only have 1 line, it's easier to implement.
* DROPME: temporarily change rich-text for testing
* test(ellipsize): Testing Ellipsize::Start
Long text in small buffer should produce ellipsis glyphs
* fix: do not need font_system anymore
We moved ellipsis shaping elsewhere so no need to pass font_system to
layout function (which also was recreating a new one in the tests every
time making them take forever).
* feat: Ellipsize::End
* improv(ellipsize): use a single ellipsis shape
* improv: Ellipsie::End && Wrap::None
There is no need to layout the whole line if it's not going to fit.
* fix: mixed bidi text when Ellipsize::End && Wrap::None
* chore: clean up and simplify when line.RTL==span.RTL
* fix(ellipsize): last word is not (word_count -1) if iter().rev()
* refactor(layout): extract the layout algorithm to make it more readable
* improv(ellipsize): Ellipsize::Start && Wrap::None
we iterate in reverse and only layout what's going to be visible
* Revert: delete the previous approach of post processing ellipsis
* doc: explain the interaction between Ellipsize and Wrap
* chore: lower the scope
* feat: Ellipsize the last line of a paragraph
For now only the number of lines is supported
* fix: clear ellipsized field on visual lines
This was causing ellipsis to show on random lines
* chore: remove old tests
will add better tests soon
* chore: clean up changes from previous attempt
* fix: consider the ellipsis width when doing alignment
* feat(ellipsize): add `Height` limit to `Ellipsize`
* fix: ellipsize the start of the last line correctly
* fix: ellipsize at the start of mixed bidi lines
* feat: Ellipsize::Middle
* fix: consider ellipsize::middle when calculating alignment correction
* refactor: improve readability
* refactor: deduplicate "fit_glyphs"
* refactor: combine backward and forward layout into one (wip)
* fix: Backward works in the unified layout_spans
* chore: clean up
* fix: Ellipsize::Middle
* fix: handle large words in bidi boundaries
* chore: clean up and some refactoring
* fix: ellipsis is now the same level as the surrounding text
* fix: try to fit more when ellipsizing::middle
* improv: ellipsis now have the same level as the neighbors
This makes ellipsized RTL text inside a LTR line more readable.
before:
Hello سلام...خوبی؟
Hello خولی؟...سلام
* fix: some extra words were being rendered in Ellipsize::Middle
This was causing the last word (if it's not the same level as the rest)
to be rendered outside the buffer.
* test: a few test cases for ellipsize
* fix: assign the correct byte range to ellipsis
this should fix the panic when selecting or clicking on or near the
ellipsis in the editor.
The unicode-linebreak crate treats the pipe character '|' as a break opportunity (BA/AL class). This causes ShapeSpan::build to split text like '|>' into separate ShapeWords. When these words are shaped independently, the font shaping engine cannot form ligatures that cross the word boundary.
This patch manually checks for the '|>' sequence during segmentation and skips the break opportunity, ensuring they remain in the same shaping run.
Added a unit test 'ligature_segmentation' to verify that '|>' remains a single word.
* Set an index for the last saved change
I added an index that represents the last saved change.
Editors are considered to be unsaved or modified if the current change
is different from the save index. In other words, if the last saved
change is `5`, undoing or redoing past that change should indicate that
the editor has been modified.
This is needed to fix two bugs in COSMIC Edit:
* https://github.com/pop-os/cosmic-edit/issues/116
* https://github.com/pop-os/cosmic-edit/issues/128
* Unit test that confirms pivot logic works
I'll most likely simplify the API as end users don't have a way to
cleanly use `Pivot::Exact` without access to the internal command
buffer.
* Simplify save point API
* Implement more save point unit tests
A unit test for an edge case currently fails but normal usage works.
* Fix edge case for empty command index and pivot
* More save point unit tests for common use cases
- Scroll is identified by line index and layout index, instead of just
layout index
- Shaping has the option to prune, where caches outside of the scroll
view are cleared
- Syntax editor no longer requires layout of all lines, only of lines
inside scroll
- BufferLine has a metadata field that can be used by other abstractions
to know when text was changed
Add tests that will match rendered words/paragraphs against reference
images.
Use env var `GENERATE_IMAGES` to write the initial reference images to
the repository.
Try to ensure that using "the width computed during an unconstrained
layout" as the width constraint during a relayout produces the same
layout. This is useful for certain UI layout algorithms.
See https://github.com/pop-os/cosmic-text/issues/134
* Instead of computing the LayoutLine width from the positioned and
aligned glyphs, we pass through width computed during line wrapping
(unless justified alignment is used, in this case we use the old
approach because the use case for measuring the width isn't really
applicable to justified text since that will just expand to the
provided width). For the produced width to later give the same
wrapping results when passed in as the `line_width` it needs to use
the same exact float arithmatic that was used to compute the width
that is compared against `line_width` when making line wrapping
choices. Passing this width through as the LayoutLine width is the
most covenient option without making more major changse to the API.
Nevertheless, I am imagining that if we get a dedicated measurement
method (i.e. that doesn't do the final positioning and alignment of
glyphs and which caches `Vec<VisualLine>`), then this width can just
be exposed there instead of preservering it in LayoutLine.
* Incidentally, this fixes
https://github.com/pop-os/cosmic-text/issues/169.
* Switch substraction from `fit_x` to checking whether potential
addition to the current line width would exceed the `line_width`. This
avoids the float error being dependent on the provided `line_width`
value.
* When eliminating trailing space from the line width, we avoid
backtracking with subtraction (which would not give the same exact
value due to float error) and instead save the previous width and use
that.
* If the previous word did not exceed the line_width, we now include a
single blank word even if it would cross the width limit since its
width won't be counted. This is necessary to get the same wrapping
behavior when re-using the measured width (which doesn't count a
single trailing blank word). Note, this whitespace logic may be
reworked anyway if <https://github.com/pop-os/cosmic-text/issues/155>
is addressed.
* Change tests to use `opt-level=1` to keep test runtime down.
* Add `fonts` folder for fonts used in tests.
* Fix an issue where a non-breaking whitespace was assumed to be the
start of a section of spaces which included characters that weren't
even whitespace.
* Add some TODOs about incongruencies between `is_whitespace`,
justification, and line breaks.