No description
Find a file
Joshua Megnauth ff5501d9a3
Fix: Undo and redo correctly updates editor modified status (#244)
* 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
2024-03-25 08:55:44 -06:00
.github/workflows Rendering tests: use git lfs in github actions so the tests will succeed 2023-09-27 11:57:18 +03:00
benches Fix benchmark issue. 2024-02-02 10:40:30 -07:00
examples Convert rich-text example to winit 2024-03-03 17:22:33 -07:00
fonts Add image render tests 2023-09-27 11:57:18 +03:00
sample Added BiDi example to demonstrate reordering works 2022-12-02 08:30:16 -07:00
screenshots Add screenshots 2022-11-09 07:22:20 -07:00
src Fix: Undo and redo correctly updates editor modified status (#244) 2024-03-25 08:55:44 -06:00
tests Fix: Undo and redo correctly updates editor modified status (#244) 2024-03-25 08:55:44 -06:00
.gitattributes Add image render tests 2023-09-27 11:57:18 +03:00
.gitignore Add image render tests 2023-09-27 11:57:18 +03:00
Cargo.toml Enable vi feature for docs.rs build 2024-03-01 10:20:55 -07:00
CHANGELOG.md 0.11.2: Fix glyph start and end when using shape-run-cache 2024-02-09 15:12:33 -07:00
ci.sh Fix no_std build 2024-02-12 10:37:49 -07:00
deny.toml Ignore bitflags in cargo-deny duplicate check 2024-02-07 14:49:49 -07:00
editor-orbclient.sh Relicense MIT OR Apache 2.0 2022-10-24 12:58:15 -06:00
editor-test.sh Do not use mono feature for editor test 2022-10-25 10:18:11 -06:00
LICENSE-APACHE Relicense MIT OR Apache 2.0 2022-10-24 12:58:15 -06:00
LICENSE-MIT Relicense MIT OR Apache 2.0 2022-10-24 12:58:15 -06:00
multiview.sh multiview example 2024-01-17 13:31:03 -07:00
README.md Add screenshots 2022-11-09 07:22:20 -07:00
redoxer.sh Fix redoxer script 2023-11-15 12:43:14 -07:00
rich-text.sh Use Color in more places 2022-10-27 09:07:47 -06:00
terminal.sh Improvements to syntax editor, integrate with libcosmic editor 2022-11-09 10:44:51 -07:00
test.sh Vi-style editor and other editor improvements (#40) 2022-11-15 12:26:59 -07:00

COSMIC Text

crates.io docs.rs license Rust workflow

Pure Rust multi-line text handling.

COSMIC Text provides advanced text shaping, layout, and rendering wrapped up into a simple abstraction. Shaping is provided by rustybuzz, and supports a wide variety of advanced shaping operations. Rendering is provided by swash, which supports ligatures and color emoji. Layout is implemented custom, in safe Rust, and supports bidirectional text. Font fallback is also a custom implementation, reusing some of the static fallback lists in browsers such as Chromium and Firefox. Linux, macOS, and Windows are supported with the full feature set. Other platforms may need to implement font fallback capabilities.

Screenshots

Arabic translation of Universal Declaration of Human Rights Arabic screenshot

Hindi translation of Universal Declaration of Human Rights Hindi screenshot

Simplified Chinese translation of Universal Declaration of Human Rights Simplified Chinses screenshot

Roadmap

The following features must be supported before this is "ready":

  • Font loading (using fontdb)
    • Preset fonts
    • System fonts
  • Text styles (bold, italic, etc.)
    • Per-buffer
    • Per-span
  • Font shaping (using rustybuzz)
    • Cache results
    • RTL
    • Bidirectional rendering
  • Font fallback
    • Choose font based on locale to work around "unification"
    • Per-line granularity
    • Per-character granularity
  • Font layout
    • Click detection
    • Simple wrapping
    • Wrapping with indentation
    • No wrapping
    • Ellipsize
  • Font rendering (using swash)
    • Cache results
    • Font hinting
    • Ligatures
    • Color emoji
  • Text editing
    • Performance improvements
    • Text selection
    • Can automatically recreate https://unicode.org/udhr/ without errors (see below)
    • Bidirectional selection
    • Copy/paste
  • no_std support (with default-features = false)
    • no_std font loading
    • no_std shaping
    • no_std layout
    • no_std rendering

The UDHR (Universal Declaration of Human Rights) test involves taking the entire set of UDHR translations (almost 500 languages), concatenating them as one file (which ends up being 8 megabytes!), then via the editor-test example, automatically simulating the entry of that file into cosmic-text per-character, with the use of backspace and delete tested per character and per line. Then, the final contents of the buffer is compared to the original file. All of the 106746 lines are correct.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.