aboutsummaryrefslogtreecommitdiffstats
path: root/src/ffi.rs
blob: e498361e3b7df85b705a0b1a38ee87f52d76f495 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use libc;

use types;

extern "C" {
    pub fn vt100_screen_new(
        rows: libc::c_int,
        cols: libc::c_int
    ) -> *mut types::ScreenImpl;
    pub fn vt100_screen_delete(screen: *mut types::ScreenImpl);

    pub fn vt100_screen_process_string(
        screen: *mut types::ScreenImpl,
        buf: *const libc::c_char,
        len: libc::size_t,
    ) -> libc::c_int;
    pub fn vt100_screen_get_string_plaintext(
        screen: *mut types::ScreenImpl,
        start: *const types::Loc,
        end: *const types::Loc,
        outp: *mut *mut libc::c_char,
        outlen: *mut libc::size_t,
    );

    pub fn vt100_screen_set_window_size(
        screen: *mut types::ScreenImpl,
        rows: libc::c_int,
        cols: libc::c_int,
    );
    pub fn vt100_screen_set_scrollback_length(
        screen: *mut types::ScreenImpl,
        rows: libc::c_int,
    );

    pub fn vt100_screen_cell_at(
        screen: *mut types::ScreenImpl,
        row: libc::c_int,
        col: libc::c_int,
    ) -> *mut types::CellImpl;

    pub fn vt100_wrapper_rows(screen: *mut types::ScreenImpl) -> libc::c_int;
    pub fn vt100_wrapper_cols(screen: *mut types::ScreenImpl) -> libc::c_int;
}

#[cfg(test)]
mod tests {
    #[test]
    fn ffi() {
        let ptr = unsafe { super::vt100_screen_new(24, 80) };
        assert!(!ptr.is_null());
        unsafe { super::vt100_screen_delete(ptr) };
    }
}