Now with formatting available

This commit is contained in:
Greg Hellings
2025-02-25 14:55:39 -06:00
parent be7d2873e6
commit 0c7843b386
6 changed files with 26 additions and 11 deletions
+1
View File
@@ -15,6 +15,7 @@ pub mod ffi {
type Module;
fn get_name(self: &Module) -> String;
fn render_text(self: Pin<&mut Module>) -> String;
fn set_key_text(self: Pin<&mut Module>, key_text: &String) -> ();
fn strip_text(self: Pin<&mut Module>) -> String;
}
+10 -4
View File
@@ -7,13 +7,19 @@ namespace sword_rs {
return rust::String(this->module->getName());
}
rust::String Module::render_text() {
return std::string(
(const char*) this->module->renderText()
);
}
void Module::set_key_text(const rust::String& keyText) {
this->module->setKeyText(std::string(keyText).c_str());
}
rust::String Module::strip_text() {
return std::string(
(const char*) this->module->stripText()
);
}
void Module::set_key_text(const rust::String& keyText) {
this->module->setKeyText(std::string(keyText).c_str());
}
}
+3 -1
View File
@@ -15,8 +15,10 @@ namespace sword_rs {
rust::String get_name() const;
rust::String strip_text();
rust::String render_text();
void set_key_text(const rust::String& keyText);
rust::String strip_text();
};
}
+3 -3
View File
@@ -1,8 +1,8 @@
use rand::Rng;
use sword_rs::mgr::Mgr;
use sword_rs::mgr::{Format, Mgr};
fn main() {
let mut mgr = Mgr::new();
let mut mgr = Mgr::new_with_format(Format::HTMLHref);
for mod_name in mgr.get_modules() {
let mut module = mgr.get_module(&mod_name);
println!("Module: {}", module.get_name());
@@ -12,7 +12,7 @@ fn main() {
println!(
"Text John 3:{} is \"{}\"",
random_number,
module.strip_text()
module.render_text()
);
}
}
+6 -2
View File
@@ -14,11 +14,15 @@ impl Module {
self.module.get_name()
}
pub fn strip_text(&mut self) -> String {
self.module.pin_mut().strip_text()
pub fn render_text(&mut self) -> String {
self.module.pin_mut().render_text()
}
pub fn set_key_text(&mut self, key_text: &String) {
self.module.pin_mut().set_key_text(key_text);
}
pub fn strip_text(&mut self) -> String {
self.module.pin_mut().strip_text()
}
}