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

47 lines
1.0 KiB
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-08-26 20:17:09 +00:00
pub fn new() -> Self {
unsafe {
from_glib_none(pango_sys::pango_item_new())
}
}
pub fn set_offset(&mut self, offset: i32, length: i32, num_chars: i32) {
self.0.offset = offset;
self.0.length = length;
self.0.num_chars = num_chars;
}
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)
}
2017-09-01 10:14:16 +00:00
pub fn length(&self) -> i32 {
self.0.length
}
}