Skip to main content

dear_imgui_cte_sys/
lib.rs

1//! Low-level FFI bindings for cimCTE and ImGuiColorTextEdit.
2
3#![allow(non_upper_case_globals)]
4#![allow(non_camel_case_types)]
5#![allow(non_snake_case)]
6#![allow(dead_code)]
7#![allow(unnecessary_transmutes)]
8#![allow(unsafe_op_in_unsafe_fn)]
9#![allow(clippy::all)]
10#![allow(unpredictable_function_pointer_comparisons)]
11
12pub use dear_imgui_sys::{
13    ImDrawList, ImGuiChildFlags, ImGuiContext, ImGuiKeyChord, ImGuiWindowFlags, ImTextureID, ImU32,
14    ImVec2, ImVec2_c, ImVec4, ImVec4_c, ImWchar,
15};
16
17pub type Color = ::std::os::raw::c_char;
18pub const text: Color = 0;
19pub const keyword: Color = 1;
20pub const declaration: Color = 2;
21pub const number: Color = 3;
22pub const string: Color = 4;
23pub const punctuation: Color = 5;
24pub const preprocessor: Color = 6;
25pub const identifier: Color = 7;
26pub const knownIdentifier: Color = 8;
27pub const comment: Color = 9;
28pub const background: Color = 10;
29pub const cursor: Color = 11;
30pub const selection: Color = 12;
31pub const whitespace: Color = 13;
32pub const matchingBracketBackground: Color = 14;
33pub const matchingBracketActive: Color = 15;
34pub const matchingBracketLevel1: Color = 16;
35pub const matchingBracketLevel2: Color = 17;
36pub const matchingBracketLevel3: Color = 18;
37pub const matchingBracketError: Color = 19;
38pub const lineNumber: Color = 20;
39pub const currentLineNumber: Color = 21;
40pub const currentLineHighlight: Color = 22;
41pub const currentLineHighlightBorder: Color = 23;
42pub const count: Color = 24;
43
44pub type BreakOption = ::std::os::raw::c_char;
45pub const mustBreak: BreakOption = 0;
46pub const allowBreak: BreakOption = 1;
47pub const noBreak: BreakOption = 2;
48pub const undefined: BreakOption = 3;
49
50#[repr(C)]
51#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
52pub struct Glyph {
53    pub codepoint: ImWchar,
54    pub color: Color,
55    pub breakOption: BreakOption,
56    pub columns: u8,
57    pub squiggle: u32,
58}
59
60impl Default for Glyph {
61    fn default() -> Self {
62        Self {
63            codepoint: 0,
64            color: text,
65            breakOption: undefined,
66            columns: 1,
67            squiggle: 0,
68        }
69    }
70}
71
72const GLYPH_SQUIGGLE_OFFSET: usize = {
73    let before_squiggle = ::std::mem::size_of::<ImWchar>() + 3;
74    let align = ::std::mem::align_of::<u32>();
75    (before_squiggle + align - 1) & !(align - 1)
76};
77
78const _: () = assert!(::std::mem::size_of::<Color>() == 1);
79const _: () = assert!(::std::mem::size_of::<BreakOption>() == 1);
80const _: () = assert!(::std::mem::offset_of!(Glyph, codepoint) == 0);
81const _: () = assert!(::std::mem::offset_of!(Glyph, color) == ::std::mem::size_of::<ImWchar>());
82const _: () =
83    assert!(::std::mem::offset_of!(Glyph, breakOption) == ::std::mem::size_of::<ImWchar>() + 1);
84const _: () = assert!(::std::mem::offset_of!(Glyph, squiggle) == GLYPH_SQUIGGLE_OFFSET);
85const _: () =
86    assert!(::std::mem::offset_of!(Glyph, columns) == ::std::mem::size_of::<ImWchar>() + 2);
87const _: () =
88    assert!(::std::mem::size_of::<Glyph>() == GLYPH_SQUIGGLE_OFFSET + ::std::mem::size_of::<u32>());
89
90include!(concat!(env!("OUT_DIR"), "/bindings.rs"));