xim_parser/
attrs.rs

1use crate::{Attr, AttrType, AttributeName};
2
3macro_rules! define_attrs {
4    ($(($name:ident, $attr_name:expr, $ty:expr),)+) => {
5        pub const fn get_name(id: u16) -> Option<AttributeName> {
6            $(
7                if id == $attr_name as _ {
8                    return Some($attr_name);
9                }
10            )+
11
12            None
13        }
14
15        pub const fn get_id(name: AttributeName) -> u16 {
16            name as u16
17        }
18
19        $(
20            pub const $name: Attr = Attr {
21                id: $attr_name as _,
22                name: $attr_name,
23                ty: $ty,
24            };
25        )+
26    };
27}
28
29define_attrs! {
30    (QUERY_INPUT_STYLE, AttributeName::QueryInputStyle, AttrType::Style),
31    (INPUT_STYLE, AttributeName::InputStyle, AttrType::Long),
32    (CLIENTWIN, AttributeName::ClientWindow, AttrType::Window),
33    (FOCUSWIN, AttributeName::FocusWindow, AttrType::Window),
34    (FILTER_EVENTS, AttributeName::FilterEvents, AttrType::Long),
35    (PREEDIT_ATTRIBUTES, AttributeName::PreeditAttributes, AttrType::NestedList),
36    (STATUS_ATTRIBUTES, AttributeName::StatusAttributes, AttrType::NestedList),
37    (FONT_SET, AttributeName::FontSet, AttrType::XFontSet),
38    (AREA, AttributeName::Area, AttrType::XRectangle),
39    (AREA_NEEDED, AttributeName::AreaNeeded, AttrType::XRectangle),
40    (COLOR_MAP, AttributeName::ColorMap, AttrType::Long),
41    (STD_COLOR_MAP, AttributeName::StdColorMap, AttrType::Long),
42    (FOREGROUND, AttributeName::Foreground, AttrType::Long),
43    (BACKGROUND, AttributeName::Background, AttrType::Long),
44    (BACKGROUND_PIXMAP, AttributeName::BackgroundPixmap, AttrType::Long),
45    (SPOT_LOCATION, AttributeName::SpotLocation, AttrType::XPoint),
46    (LINE_SPACE, AttributeName::LineSpace, AttrType::Long),
47    (SEPARATOR_OF_NESTED_LIST, AttributeName::SeparatorofNestedList, AttrType::Separator),
48}