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

38 lines
809 B
Rust
Raw Normal View History

use std::ptr;
use std::mem;
use pango_sys;
use glib_ffi;
2017-08-25 15:32:30 +00:00
use gobject_ffi;
use glib::translate::*;
2017-08-20 18:09:57 +00:00
use super::analysis;
glib_wrapper! {
pub struct Item(Boxed<pango_sys::PangoItem>);
match fn {
copy => |ptr| pango_sys::pango_item_copy(ptr as *mut pango_sys::PangoItem),
free => |ptr| pango_sys::pango_item_free(ptr),
2017-08-25 15:32:30 +00:00
get_type => || pango_sys::pango_item_get_type(),
}
}
impl Item {
2017-09-07 15:01:04 +00:00
#[cfg(test)]
2017-08-26 20:17:09 +00:00
pub fn new() -> Self {
unsafe {
2017-12-03 16:45:38 +00:00
from_glib_full(pango_sys::pango_item_new())
2017-08-26 20:17:09 +00:00
}
}
2017-08-20 18:09:57 +00:00
pub fn analysis(&self) -> analysis::Analysis {
analysis::Analysis::from(&self.0.analysis)
}
2017-08-25 15:32:30 +00:00
pub fn offset(&self) -> (usize, usize, usize) {
(self.0.offset as usize, self.0.length as usize, self.0.num_chars as usize)
}
}