* 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
Instead of blindly pushing default font to the start of the monospace
fallbacks map. Actually collect codepoint support info for it, and if
it supports all codepoints, skip collecting that info from other
monospace fonts. If it doesn't, push it to the start of the map as
before.
This actually provides a big performance boost, while the sophisticated
monospace fallback process is still done whenever needed.
Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
When font fallback involves monospace fonts, and if word has known
scripts, limit the fonts tried for fallback to ones that support at
least one requested script.
Codepoint support info is still collected for these fonts to guide
the fallback order selection process.
A map of per-script monospace font-ids is pre-populated in font system
to acquire lists of wanted font ids efficiently.
Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
For the simplest case of " " words, a quick binary search in
`supported` vec will suffice, instead of using `slice::contains()`
for all monospace fonts, where some of them may support thousands of
codepoints.
Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
Swap color channels
Remove unused code in rich-text-winit example
Port editor example to winit
WIP
Implement scroll logic + add shape_as_needed
Handle text input using named keys
request redraw on click
cargo fmt
Implement dragging
Refactor winit event handlers to avoid duplication
Re-enable text size keyboard shortcuts
Remove unused imports
Fix updating scale factor
Fix unused variable warnings
Remove logging
Remove commented code
Delete rich-text-winit example
Rename editor-winit example to editor
When matching on weights smaller than normal, "equal or smaller"
weight restriction may cause monospace fallback to fail, depending
on font support at such weights for the text to be shaped.
So remove that restriction, and calculate weight differences instead
of offsets.
In case of no exact weight match, and with all other factors being
equal, smaller weights will be picked before bigger ones. So, this
should generally not cause any behavioral changes when matching on
normal weight or bigger.
Should fixpop-os/cosmic-term#104.
Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
`Attrs` contains info like color and metadata which are not relevant
to font matching.
So, add a new struct `FontMatchAttrs` which only contains the relevant
info, and use it as a key in `FontSystem`'s `font_matches_cache`.
Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
In `FontSystem`, `font_matches_cache` is an ever growing cache.
It can also be a fast growing one in stress tests like running this
in `cosmic-term`:
mpv -speed 3 -vo tct <some_video>
So this commit adds a size limit to that cache, and clears the cache
when that limit is reached, which shouldn't be a common occurrence in
normal usage.
Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
This should/could improve fallback order.
This could also probably be utilized for non-Monospace fallback too.
But I didn't want to touch that code to avoid accidentally breaking
anything.
Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
When matching to a default monospace width, big fonts like those
containing symbols and emojis got too small from font resizing.
Adding a glyph-to-default rounded factor to the calculation should fix
that issue without losing monospatiality.
Fixespop-os/cosmic-term#69.
Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>