Commit graph

183 commits

Author SHA1 Message Date
Caleb Yates
252078cfe4 fix: avoids panic 2024-12-21 19:15:58 -07:00
koe
069d3404bf build fixes 2024-09-03 15:59:15 -06:00
koe
9dc024616b move ShapeBuffer to FontSystem 2024-09-03 15:59:15 -06:00
koe
0935f549ee add alignment option to Buffer::set_rich_text 2024-09-01 15:26:38 -06:00
koe
f89e64aa76 cleanup 2024-09-01 15:00:17 -06:00
koe
b68f4ad5c6 Optimize Buffer::set_rich_text for when the buffer is reconstructed 2024-09-01 15:00:17 -06:00
Christian Westrom
7c25fcb7ae add the convenient API for setting tab width 2024-09-01 07:12:04 -06:00
Jeremy Soller
0e2d050a8d
Fix LayoutRunIter returning lines beyond Buffer height 2024-07-09 11:21:03 -06:00
Jeremy Soller
69d5aec7fc
Fix infinite loop if scroll is on invalid line 2024-06-12 09:42:27 -06:00
Jeremy Soller
93a7df859a Allow for undefined buffer width and/or height, fixes #70 2024-06-12 09:14:56 -06:00
Jeremy Soller
b288de13ae Allow layout to be calculated without specifying width 2024-06-12 08:00:33 -06:00
Jeremy Soller
320b034f5b Performance improvement in set_tab_width 2024-06-10 10:21:25 -06:00
Jeremy Soller
3c94352f3f Support expanding tabs 2024-06-10 08:12:42 -06:00
Jeremy Soller
56812a8348 Make vertical scroll by pixels instead of layout lines 2024-06-10 08:05:27 -06:00
Jeremy Soller
21e88ebc45
Move line height calculation to LayoutLine 2024-06-07 10:52:26 -06:00
Jeremy Soller
c7100dc989 Format 2024-06-06 19:38:40 -06:00
Jeremy Soller
497003e67e Fall back to buffer line height only if no glyphs found 2024-06-06 19:38:40 -06:00
Jeremy Soller
37688747e1 Use line height from attrs 2024-06-06 19:38:40 -06:00
Jeremy Soller
8638ec29bb Add metrics to attributes 2024-06-06 19:38:40 -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
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
Jeremy Soller
003f73e679
Set default buffer wrap to WordOrGlyph 2024-02-02 10:45:24 -07:00
Jeremy Soller
a11f68f13d Format 2024-01-17 13:31:03 -07:00
Mohammad AlSaleh
329941c4a6 Try harder to succeed at fall-backing to a Monospace font
A combination of some ideas:

 * Try all Monospace fonts before giving up.
 * Relax exact weight restriction on font matching when trying Monospace
   fall-back. Try smaller weights if needed.
 * Make the fall-back try order weight-offset aware, AND script-aware.
 * And finally, add the option to adjust the font size of glyphs using
   fall-back Monospace fonts, so the width of them matches the default
   font width.

   For my use-case, the current fall-back attempt always fails with
   Arabic script. And none of the Arabic-supporting Monospace fonts in
   my system also support medium weight. So, if my default font is set
   to medium weight, script-aware fall-back alone will still not work.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
2024-01-17 13:31:03 -07:00
Jeremy Soller
46d60a3723 Implement Clone for Buffer and use Arc::make_mut 2024-01-17 13:31:03 -07:00
Jeremy Soller
ae030e9885 Move color and x_opt out of Cursor 2024-01-17 13:31:03 -07:00
Jeremy Soller
d0b4b4635e Refactor of scroll and shaping
- 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
2024-01-17 13:31:03 -07:00
Jeremy Soller
80d120dfa5 Ensure that all shaping and layout uses scratch buffer 2024-01-17 13:31:03 -07:00
Jeremy Soller
5d1aa67804 Improve reliability of layout_cursor 2024-01-17 13:31:03 -07:00
Jeremy Soller
018a2e9d2a Move cursor motions to new Motion enum, move handling to Buffer 2024-01-17 13:31:03 -07:00
Jeremy Soller
afc5b525f1
Buffer: fix max scroll going one line beyond end 2023-11-30 14:51:22 -07:00
Jeremy Soller
19ae07bd3b
Fix some clippy lints 2023-11-15 09:21:13 -07:00
Jeremy Soller
241c4ca357
Buffer::set_rich_text: Only add attrs if they don't match the defaults 2023-11-02 10:24:28 -06:00
Jeremy Soller
d53932bd7c Add function to set metrics and size simultaneously 2023-10-31 20:40:46 -06:00
Jeremy Soller
ad10e7373b
Require default Attrs to be specified in set_rich_text 2023-10-27 13:08:27 -06:00
Jeremy Soller
1eab951e27
Merge pull request #149 from tigregalis/set-rich-text
Add `Buffer::set_rich_text` method
2023-09-11 10:58:39 -06:00
John Nunley
64e469718b Use a scratch buffer to reduce allocations
This commit adds a new ShapeBuffer type, which contains some buffers tha
are commonly re-created during the shaping process. New APIs are added
that take this structure, and old APIs are turned into wrappers around
the new API.

The goal is to reduce the number of per-layout allocations that happen
in a typical layout call.
2023-08-16 14:09:54 -07:00
John Nunley
440d24ffa0
Add more Debug implementations
I generally like to implement Debug on these kind of types.
2023-07-07 21:44:21 -07:00
tigregalis
fb8bb60972 update comments 2023-06-30 20:40:12 +08:00
tigregalis
7db01ebf3a use core::mem::{replace, take} not std:: 2023-06-30 20:31:29 +08:00
tigregalis
48f6aefb80 remove unnecessary into_iter in doctests 2023-06-27 21:59:58 +08:00
tigregalis
4a05c9c1cf add BorrowedWithFontSystem<_>::set_rich_text 2023-06-27 21:53:27 +08:00
tigregalis
f092bdde73 add Buffer::set_rich_text method 2023-06-27 21:53:05 +08:00
Héctor Ramón Jiménez
eb09cf0259
Introduce PhysicalGlyph for offsetting and scaling 2023-06-20 06:07:24 +02:00
Jeremy Soller
e8b10fd675
Base selection on the top of the line 2023-06-16 07:03:43 -06:00
Jeremy Soller
10bf182c5d
Fix line wrap and scroll 2023-06-16 06:51:11 -06:00
Héctor Ramón Jiménez
431163dc35
Consider the centering_offset for visibility in LayoutRunIter 2023-06-16 02:25:45 +02:00