Prompts the user for a set of inputs specified in `fields` with given title. The fields parameter is a list which can contain the following types: This API is flexible and works both in the UI via a pop-up dialog and on the command-line. ```no_run # use binaryninja::interaction::FormInputBuilder; # use binaryninja::interaction::FormResponses; let responses = FormInputBuilder::new() .text_field("
(&mut self, title: &str)
| 491 | /// println!("{} {} likes {}", &first_name, &last_name, food); |
| 492 | /// ``` |
| 493 | pub fn get_form_input(&mut self, title: &str) -> Vec<FormResponses> { |
| 494 | if unsafe { |
| 495 | BNGetFormInput( |
| 496 | self.fields.as_mut_ptr(), |
| 497 | self.fields.len(), |
| 498 | title.into_bytes_with_nul().as_ptr() as *const _, |
| 499 | ) |
| 500 | } { |
| 501 | let result = self |
| 502 | .fields |
| 503 | .iter() |
| 504 | .map(|form_field| match form_field.type_ { |
| 505 | BNFormInputFieldType::LabelFormField |
| 506 | | BNFormInputFieldType::SeparatorFormField => FormResponses::None, |
| 507 | |
| 508 | BNFormInputFieldType::TextLineFormField |
| 509 | | BNFormInputFieldType::MultilineTextFormField |
| 510 | | BNFormInputFieldType::OpenFileNameFormField |
| 511 | | BNFormInputFieldType::SaveFileNameFormField |
| 512 | | BNFormInputFieldType::DirectoryNameFormField => { |
| 513 | FormResponses::String(unsafe { |
| 514 | CStr::from_ptr(form_field.stringResult) |
| 515 | .to_str() |
| 516 | .unwrap() |
| 517 | .to_owned() |
| 518 | }) |
| 519 | } |
| 520 | |
| 521 | BNFormInputFieldType::IntegerFormField => { |
| 522 | FormResponses::Integer(form_field.intResult) |
| 523 | } |
| 524 | BNFormInputFieldType::AddressFormField => { |
| 525 | FormResponses::Address(form_field.addressResult) |
| 526 | } |
| 527 | BNFormInputFieldType::ChoiceFormField => { |
| 528 | FormResponses::Index(form_field.indexResult) |
| 529 | } |
| 530 | }) |
| 531 | .collect(); |
| 532 | unsafe { BNFreeFormInputResults(self.fields.as_mut_ptr(), self.fields.len()) }; |
| 533 | result |
| 534 | } else { |
| 535 | vec![] |
| 536 | } |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | impl Default for FormInputBuilder { |