style(modulo): fix formatting
This commit is contained in:
parent
e227fae326
commit
308d1848be
|
@ -192,7 +192,7 @@ fn build_native() {
|
|||
"--without-liblzma",
|
||||
"--with-libjpeg=builtin",
|
||||
"--with-libpng=builtin",
|
||||
"--enable-universal-binary=arm64,x86_64"
|
||||
"--enable-universal-binary=arm64,x86_64",
|
||||
])
|
||||
.spawn()
|
||||
.expect("failed to execute configure")
|
||||
|
|
|
@ -21,4 +21,4 @@ pub mod config;
|
|||
pub mod generator;
|
||||
pub mod parser;
|
||||
|
||||
pub use crate::sys::form::show;
|
||||
pub use crate::sys::form::show;
|
||||
|
|
|
@ -22,7 +22,7 @@ extern crate lazy_static;
|
|||
|
||||
pub mod form;
|
||||
pub mod search;
|
||||
mod sys;
|
||||
pub mod troubleshooting;
|
||||
pub mod welcome;
|
||||
pub mod wizard;
|
||||
mod sys;
|
|
@ -97,19 +97,21 @@ fn command_filter(
|
|||
let (valid_ids, trimmed_query) = if query.starts_with('>') {
|
||||
(
|
||||
items
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, item)| item.is_builtin)
|
||||
.map(|(i, _)| i).collect::<HashSet<usize>>(),
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, item)| item.is_builtin)
|
||||
.map(|(i, _)| i)
|
||||
.collect::<HashSet<usize>>(),
|
||||
query.trim_start_matches('>'),
|
||||
)
|
||||
} else {
|
||||
(
|
||||
items
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, item)| !item.is_builtin)
|
||||
.map(|(i, _)| i).collect::<HashSet<usize>>(),
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, item)| !item.is_builtin)
|
||||
.map(|(i, _)| i)
|
||||
.collect::<HashSet<usize>>(),
|
||||
query,
|
||||
)
|
||||
};
|
||||
|
|
|
@ -21,4 +21,4 @@ pub mod algorithm;
|
|||
pub mod config;
|
||||
pub mod generator;
|
||||
|
||||
pub use crate::sys::search::show;
|
||||
pub use crate::sys::search::show;
|
||||
|
|
|
@ -156,7 +156,9 @@ mod interop {
|
|||
|
||||
impl From<types::Field> for OwnedField {
|
||||
fn from(field: types::Field) -> Self {
|
||||
let id = field.id.map(|id| CString::new(id).expect("unable to create cstring for field id"));
|
||||
let id = field
|
||||
.id
|
||||
.map(|id| CString::new(id).expect("unable to create cstring for field id"));
|
||||
|
||||
let field_type = match field.field_type {
|
||||
types::FieldType::Row(_) => FieldType_ROW,
|
||||
|
@ -353,8 +355,7 @@ pub fn show(form: types::Form) -> HashMap<String, String> {
|
|||
let mut value_map: HashMap<String, String> = HashMap::new();
|
||||
|
||||
extern "C" fn callback(values: *const ValuePair, size: c_int, map: *mut c_void) {
|
||||
let values: &[ValuePair] =
|
||||
unsafe { std::slice::from_raw_parts(values, size as usize) };
|
||||
let values: &[ValuePair] = unsafe { std::slice::from_raw_parts(values, size as usize) };
|
||||
let map = map as *mut HashMap<String, String>;
|
||||
let map = unsafe { &mut (*map) };
|
||||
for pair in values.iter() {
|
||||
|
|
|
@ -136,12 +136,12 @@ pub struct WizardMetadata {
|
|||
pub accessibility_image_2_path: *const c_char,
|
||||
pub detected_os: c_int,
|
||||
|
||||
pub is_legacy_version_running: extern fn() -> c_int,
|
||||
pub backup_and_migrate: extern fn() -> c_int,
|
||||
pub add_to_path: extern fn() -> c_int,
|
||||
pub enable_accessibility: extern fn() -> c_int,
|
||||
pub is_accessibility_enabled: extern fn() -> c_int,
|
||||
pub on_completed: extern fn(),
|
||||
pub is_legacy_version_running: extern "C" fn() -> c_int,
|
||||
pub backup_and_migrate: extern "C" fn() -> c_int,
|
||||
pub add_to_path: extern "C" fn() -> c_int,
|
||||
pub enable_accessibility: extern "C" fn() -> c_int,
|
||||
pub is_accessibility_enabled: extern "C" fn() -> c_int,
|
||||
pub on_completed: extern "C" fn(),
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -152,7 +152,7 @@ pub struct WelcomeMetadata {
|
|||
|
||||
pub already_running: c_int,
|
||||
|
||||
pub dont_show_again_changed: extern fn(c_int),
|
||||
pub dont_show_again_changed: extern "C" fn(c_int),
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -164,8 +164,8 @@ pub struct TroubleshootingMetadata {
|
|||
pub error_sets: *const ErrorSetMetadata,
|
||||
pub error_sets_count: c_int,
|
||||
|
||||
pub dont_show_again_changed: extern fn(c_int),
|
||||
pub open_file: extern fn(*const c_char),
|
||||
pub dont_show_again_changed: extern "C" fn(c_int),
|
||||
pub open_file: extern "C" fn(*const c_char),
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -216,6 +216,6 @@ extern "C" {
|
|||
// WELCOME
|
||||
pub(crate) fn interop_show_welcome(metadata: *const WelcomeMetadata);
|
||||
|
||||
// TROUBLESHOOTING
|
||||
// TROUBLESHOOTING
|
||||
pub(crate) fn interop_show_troubleshooting(metadata: *const TroubleshootingMetadata);
|
||||
}
|
||||
|
|
|
@ -20,12 +20,12 @@
|
|||
pub mod form;
|
||||
pub mod search;
|
||||
pub mod troubleshooting;
|
||||
pub mod wizard;
|
||||
pub mod welcome;
|
||||
pub mod wizard;
|
||||
|
||||
#[allow(non_upper_case_globals)]
|
||||
#[allow(dead_code)]
|
||||
#[allow(non_snake_case)]
|
||||
pub mod interop;
|
||||
|
||||
mod util;
|
||||
mod util;
|
||||
|
|
|
@ -40,8 +40,8 @@ pub mod types {
|
|||
|
||||
#[allow(dead_code)]
|
||||
mod interop {
|
||||
use super::types;
|
||||
use super::super::interop::*;
|
||||
use super::types;
|
||||
use std::ffi::{c_void, CString};
|
||||
|
||||
pub(crate) struct OwnedSearch {
|
||||
|
@ -102,7 +102,14 @@ mod interop {
|
|||
hintText: hint_ptr,
|
||||
});
|
||||
|
||||
Self { title, icon_path, hint, items, interop_items, _interop }
|
||||
Self {
|
||||
title,
|
||||
icon_path,
|
||||
hint,
|
||||
items,
|
||||
interop_items,
|
||||
_interop,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ use std::path::PathBuf;
|
|||
use std::sync::Mutex;
|
||||
|
||||
use crate::sys::interop::{ErrorSetMetadata, TroubleshootingMetadata};
|
||||
use crate::sys::troubleshooting::interop::{OwnedErrorSet};
|
||||
use crate::sys::troubleshooting::interop::OwnedErrorSet;
|
||||
use crate::sys::util::convert_to_cstring_or_null;
|
||||
use crate::troubleshooting::{TroubleshootingHandlers, TroubleshootingOptions};
|
||||
use anyhow::Result;
|
||||
|
@ -39,10 +39,7 @@ mod interop {
|
|||
use super::interop::{ErrorMetadata, ErrorSetMetadata};
|
||||
|
||||
use super::super::interop::*;
|
||||
use std::{
|
||||
ffi::{CString},
|
||||
os::raw::c_int,
|
||||
};
|
||||
use std::{ffi::CString, os::raw::c_int};
|
||||
|
||||
pub(crate) struct OwnedErrorSet {
|
||||
file_path: Option<CString>,
|
||||
|
@ -68,8 +65,10 @@ mod interop {
|
|||
|
||||
impl From<&ErrorSet> for OwnedErrorSet {
|
||||
fn from(error_set: &ErrorSet) -> Self {
|
||||
let file_path = error_set.file.as_ref().map(|file_path| CString::new(file_path.to_string_lossy().to_string())
|
||||
.expect("unable to convert file_path to CString"));
|
||||
let file_path = error_set.file.as_ref().map(|file_path| {
|
||||
CString::new(file_path.to_string_lossy().to_string())
|
||||
.expect("unable to convert file_path to CString")
|
||||
});
|
||||
|
||||
let errors: Vec<OwnedErrorMetadata> =
|
||||
error_set.errors.iter().map(|item| item.into()).collect();
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use std::os::raw::{c_char};
|
||||
use std::ffi::CString;
|
||||
use std::os::raw::c_char;
|
||||
|
||||
pub fn convert_to_cstring_or_null(str: Option<String>) -> (Option<CString>, *const c_char) {
|
||||
let c_string =
|
||||
|
@ -28,4 +28,4 @@ pub fn convert_to_cstring_or_null(str: Option<String>) -> (Option<CString>, *con
|
|||
.map_or(std::ptr::null(), |path| path.as_ptr());
|
||||
|
||||
(c_string, c_ptr)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,11 +17,14 @@
|
|||
* along with modulo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use std::os::raw::{c_int};
|
||||
use std::{ sync::Mutex};
|
||||
use std::os::raw::c_int;
|
||||
use std::sync::Mutex;
|
||||
|
||||
use crate::sys::util::convert_to_cstring_or_null;
|
||||
use crate::{sys::interop::{WelcomeMetadata}, welcome::{WelcomeHandlers, WelcomeOptions}};
|
||||
use crate::{
|
||||
sys::interop::WelcomeMetadata,
|
||||
welcome::{WelcomeHandlers, WelcomeOptions},
|
||||
};
|
||||
|
||||
lazy_static! {
|
||||
static ref HANDLERS: Mutex<Option<WelcomeHandlers>> = Mutex::new(None);
|
||||
|
@ -43,7 +46,7 @@ pub fn show(options: WelcomeOptions) {
|
|||
(*handler_ref)(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
let mut lock = HANDLERS.lock().expect("unable to acquire handlers lock");
|
||||
*lock = Some(options.handlers)
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* along with modulo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use std::os::raw::{c_int};
|
||||
use std::os::raw::c_int;
|
||||
use std::{ffi::CString, sync::Mutex};
|
||||
|
||||
use crate::sys::interop::{
|
||||
|
|
Loading…
Reference in New Issue
Block a user