key: Share state between multiple keys

This commit is contained in:
Dorota Czaplejewicz
2019-08-08 15:24:03 +00:00
parent cc3f2315a7
commit 1cfec4de50
11 changed files with 220 additions and 255 deletions

View File

@ -94,6 +94,14 @@ pub mod c {
}
});
let key = unsafe { &mut *key };
if key.symbols.len() > 0 {
eprintln!("Key {:?} already has a symbol defined", text);
return;
}
let icon = into_cstring(icon)
.unwrap_or_else(|e| {
eprintln!("Icon name unreadable: {}", e);
@ -155,7 +163,6 @@ pub mod c {
_ => panic!("unsupported element type {:?}", element),
};
let key = unsafe { &mut *key };
key.symbols.push(symbol);
}
@ -213,7 +220,7 @@ pub mod c {
};
format!("[ {} ], [ {} ]", first, second)
},
_ => panic!("Unsupported number of symbols"),
_ => panic!("Unsupported number of symbols: {}", symbol_names.len()),
};
CString::new(format!(" key <{}> {{ {} }};\n", key_name, inner))