neovim-gtk/src/sys/pango/mod.rs

58 lines
1.3 KiB
Rust
Raw Normal View History

2017-08-26 20:17:09 +00:00
mod item;
2017-08-20 18:09:57 +00:00
mod analysis;
2017-09-11 15:00:51 +00:00
mod attr_iterator;
2018-05-06 12:22:38 +00:00
pub mod attribute;
2017-08-26 20:17:09 +00:00
pub use self::item::Item;
pub use self::analysis::Analysis;
2017-09-11 15:00:51 +00:00
pub use self::attr_iterator::{AttrIterator, AttrIteratorFactory};
2017-08-26 20:17:09 +00:00
use std::ptr;
use pango;
use pango_sys;
use glib::translate::*;
pub fn pango_itemize(
context: &pango::Context,
2017-09-01 10:14:16 +00:00
text: &str,
2017-09-11 15:00:51 +00:00
start_index: usize,
length: usize,
attrs: &pango::AttrList,
cached_iter: Option<&mut AttrIterator>,
2017-08-26 20:17:09 +00:00
) -> Vec<Item> {
unsafe {
2018-03-18 21:15:58 +00:00
FromGlibPtrContainer::from_glib_full(pango_sys::pango_itemize(
context.to_glib_none().0,
2017-08-24 14:41:20 +00:00
text.as_ptr() as *const i8,
2017-09-11 15:00:51 +00:00
start_index as i32,
length as i32,
attrs.to_glib_none().0,
cached_iter
.map(|iter| iter.to_glib_none_mut().0)
.unwrap_or(ptr::null_mut()),
))
}
}
pub fn pango_shape(
2017-09-01 10:14:16 +00:00
text: &str,
2017-08-25 15:32:30 +00:00
offset: usize,
length: usize,
2017-08-26 20:17:09 +00:00
analysis: &Analysis,
glyphs: &mut pango::GlyphString,
) {
2017-08-25 15:32:30 +00:00
debug_assert!(offset + length <= text.len());
unsafe {
pango_sys::pango_shape(
2017-08-25 15:32:30 +00:00
(text.as_ptr() as *const i8).offset(offset as isize),
length as i32,
2017-08-20 18:09:57 +00:00
analysis.to_glib_ptr(),
glyphs.to_glib_none_mut().0,
);
}
}