Commit graph

627 commits

Author SHA1 Message Date
Itsusinn
39c4e3e02b refactor: move "rayon" feature under "std" 2024-06-05 08:15:51 -06:00
Itsusinn
1f52b5211c fix: no redundant load 2024-06-05 08:15:51 -06:00
Itsusinn
658025314c feat: concurrently load & parse fonts 2024-06-05 08:15:51 -06:00
apricotbucket28
5e82de11cf Promote Noto Color Emoji fallback 2024-06-04 17:51:21 -06:00
Jeremy Soller
b0a70c70ff
Fix horizontal scrolling to start of empty line 2024-05-30 14:36:18 -06:00
Jeremy Soller
cb9d405c20
Fix horizontal scroll to end of line 2024-05-30 14:33:35 -06:00
Jeremy Soller
570999809c
Track horizontal scroll (which must be implemented by renderers) 2024-05-30 14:26:38 -06:00
Jeremy Soller
2f5f2c63da
Fix extra newline in crlf sample 2024-04-30 12:26:28 -06:00
Jeremy Soller
10d5888d11
Ensure at least one line is in Buffer 2024-04-30 12:21:21 -06:00
Jeremy Soller
0cfd9b64ef
Add line ending abstraction (#250)
* Add line ending abstraction

* Make Buffer::set_text use LineIter

* Add ctrl+s for saving to editor
2024-04-30 12:12:25 -06:00
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
Jeremy Soller
b08676909f
Remove todos about highlight color, it is implemented 2024-03-18 08:41:42 -06:00
Mohammad AlSaleh
18c3d2acec Skip trying monospace fallbacks if default font supports all codepoints
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>
2024-03-10 15:05:07 -06:00
Mohammad AlSaleh
729dc868c2 Only try monospace fonts that support at least one requested script
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>
2024-03-10 15:05:07 -06:00
Mohammad AlSaleh
59ac0b824c Store a sorted list of monospace font ids in font system
Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
2024-03-10 15:05:07 -06:00
Mohammad AlSaleh
3e02ae1ea6 Cache codepoint support info for monospace fonts
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>
2024-03-10 15:05:07 -06:00
Nico Burns
a53a0b3a8c Convert rich-text example to winit 2024-03-03 17:22:33 -07:00
Nico Burns
9615978557 Refactor scrollbar width handling for editor example 2024-03-03 17:22:33 -07:00
Nico Burns
43d3620e44 Convert editor example to winit
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
2024-03-02 18:33:51 -07:00
Nico Burns
22e61965aa Enable vi feature for docs.rs build 2024-03-01 10:20:55 -07:00
Aapo Alasuutari
2766961af6 Handle inverted Ranges in add_span 2024-02-22 10:06:50 -07:00
Christopher Serr
8582173128 Fix no_std build
This fixes the `no_std` build and also makes sure it's tested properly
in the CI workflow.
2024-02-12 10:37:49 -07:00
Jeremy Soller
0cb6eba6e7
0.11.2: Fix glyph start and end when using shape-run-cache 2024-02-09 15:12:33 -07:00
Jeremy Soller
cb447ea8c6
0.11.1 2024-02-08 11:13:33 -07:00
Jeremy Soller
1eb3233373
Add shape-run-cache feature, that can significantly improve shaping performance 2024-02-08 11:12:41 -07:00
Jeremy Soller
990d66ed41
Ignore bitflags in cargo-deny duplicate check 2024-02-07 14:49:49 -07:00
Jeremy Soller
0a24ee0423
Remove editor-libcosmic 2024-02-07 14:45:11 -07:00
Jeremy Soller
8174877407
0.11.0 2024-02-07 14:18:19 -07:00
dtzxporter
be471833c9 Add a test case for extra line insertion. 2024-02-02 12:53:48 -07:00
dtzxporter
de587b3f50 Only commit a previous word range if we had an existing visual line.
Fixes #155, and also fixes Word::Wrap when two buffer overflowing words are next to each other.
2024-02-02 12:53:48 -07:00
Jeremy Soller
ceb6dccb40
Update test image size 2024-02-02 10:50:17 -07:00
Jeremy Soller
dd2c907f4e
Update test images 2024-02-02 10:48:57 -07:00
Jeremy Soller
003f73e679
Set default buffer wrap to WordOrGlyph 2024-02-02 10:45:24 -07:00
dtzxporter
cc75bb66b4 Adds a separate wrapping option to allow word to glyph fallback. 2024-02-02 10:40:30 -07:00
dtzxporter
b7f150615d Add a test for word wrapping fallback. 2024-02-02 10:40:30 -07:00
dtzxporter
e83f55bfeb Re-generate word tests so they don't wrap because that's not what they are testing. 2024-02-02 10:40:30 -07:00
dtzxporter
07a65cf81f Fallback to glyph wrapping when a word can't fit on a line by itself. 2024-02-02 10:40:30 -07:00
dtzxporter
d036f50b60 Fix benchmark issue. 2024-02-02 10:40:30 -07:00
Jeremy Soller
1b025ae56e
Update swash to 0.1.12 2024-02-01 12:43:08 -07:00
Jeremy Soller
4a66d19006
Update swash 2024-02-01 11:35:25 -07:00
Jeremy Soller
9bbf9e5c23
Fix no_std tests 2024-02-01 11:35:18 -07:00
Jeremy Soller
b2fb02c7ad Require modit 0.1.4 2024-01-31 14:03:19 -07:00
Jeremy Soller
db2f3b94ef Fix missing line separators in delete changes 2024-01-31 13:53:36 -07:00
Mohammad AlSaleh
0cea55630c Use weight absolute difference in monospace fallback matching
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 fix pop-os/cosmic-term#104.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
2024-01-31 06:32:37 -07:00
Mohammad AlSaleh
1a18296a67 Update to swash 0.1.9
Fixes #220.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
2024-01-30 14:06:35 -07:00
Mohammad AlSaleh
e0ae465f91 Only use relevant info from Attrs as a key in font_matches_cache
`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>
2024-01-23 23:05:52 -07:00
Mohammad AlSaleh
235ec02a20 Add a size limit to font_matches_cache and clear it when it's reached
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>
2024-01-23 23:05:52 -07:00
Mohammad AlSaleh
db1530c4ec Use supported codepoints instead of scripts in Monospace fallback
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>
2024-01-19 09:37:11 -07:00
Mohammad AlSaleh
845a66ceff Multiply by a glyph-to-default rounded factor when resizing fonts
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.

 Fixes pop-os/cosmic-term#69.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
2024-01-19 09:35:46 -07:00
Jeremy Soller
6aadfaddac
Fix subtraction overflow when comparing weights 2024-01-18 06:58:47 -07:00