Vi-style editor and other editor improvements (#40)

* WIP VI wrapper for editor

* WIP: block cursor

* Create Edit trait, run CI on all feature options

* Add prints describing build steps to ci.sh

* Custom rendering for Vi editor

* Clippy fixes

* More clippy fixes

* Show clippy results in CI

* Fix for Redox

* Fix clippy lint

* Add vi feature to enable vi-style editor

* Add escape to libcosmic text box
This commit is contained in:
Jeremy Soller 2022-11-15 12:26:59 -07:00 committed by GitHub
parent 271ca5cf7a
commit ee54e7626b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 982 additions and 616 deletions

View file

@ -1,12 +1,54 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
pub(crate) mod fallback;
use core::ops::Deref;
pub(crate) use self::font::*;
mod font;
pub(crate) mod fallback;
pub use self::matches::*;
mod matches;
pub use self::system::*;
mod system;
pub struct Font<'a> {
pub info: &'a fontdb::FaceInfo,
pub data: &'a [u8],
pub rustybuzz: rustybuzz::Face<'a>,
#[cfg(feature = "swash")]
pub swash: (u32, swash::CacheKey),
}
impl<'a> Font<'a> {
pub fn new(info: &'a fontdb::FaceInfo) -> Option<Self> {
let data = match &info.source {
fontdb::Source::Binary(data) => data.deref().as_ref(),
#[cfg(feature = "std")]
fontdb::Source::File(path) => {
log::warn!("Unsupported fontdb Source::File('{}')", path.display());
return None;
}
#[cfg(feature = "std")]
fontdb::Source::SharedFile(_path, data) => data.deref().as_ref(),
};
Some(Self {
info,
data,
rustybuzz: rustybuzz::Face::from_slice(data, info.index)?,
#[cfg(feature = "swash")]
swash: {
let swash = swash::FontRef::from_index(data, info.index as usize)?;
(swash.offset, swash.key)
},
})
}
#[cfg(feature = "swash")]
pub fn as_swash(&self) -> swash::FontRef {
swash::FontRef {
data: self.data,
offset: self.swash.0,
key: self.swash.1,
}
}
}