|
|
|
@ -381,8 +381,8 @@ impl App {
|
|
|
|
|
self.msg_out.push_back(MsgOut::Enque(task));
|
|
|
|
|
self
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn handle_batch_external_msgs(mut self, msgs: Vec<ExternalMsg>) -> Result<Self> {
|
|
|
|
|
|
|
|
|
|
pub fn handle_batch_external_msgs(self, msgs: Vec<ExternalMsg>) -> Result<Self> {
|
|
|
|
|
for task in msgs
|
|
|
|
|
.into_iter()
|
|
|
|
|
.map(|msg| Task::new(MsgIn::External(msg), None))
|
|
|
|
@ -1112,6 +1112,13 @@ impl App {
|
|
|
|
|
self.config.general.read_only,
|
|
|
|
|
self.config.general.global_key_bindings.to_owned(),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Hooks
|
|
|
|
|
if !self.hooks.on_mode_switch.is_empty() {
|
|
|
|
|
let msgs = self.hooks.on_mode_switch.clone();
|
|
|
|
|
self = self.handle_batch_external_msgs(msgs)?
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ok(self)
|
|
|
|
|
} else {
|
|
|
|
|
self.log_error(format!("Mode not found: {}", mode))
|
|
|
|
@ -1130,6 +1137,13 @@ impl App {
|
|
|
|
|
self.config.general.read_only,
|
|
|
|
|
self.config.general.global_key_bindings.to_owned(),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Hooks
|
|
|
|
|
if !self.hooks.on_mode_switch.is_empty() {
|
|
|
|
|
let msgs = self.hooks.on_mode_switch.clone();
|
|
|
|
|
self = self.handle_batch_external_msgs(msgs)?
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ok(self)
|
|
|
|
|
} else {
|
|
|
|
|
self.log_error(format!("Builtin mode not found: {}", mode))
|
|
|
|
@ -1148,6 +1162,13 @@ impl App {
|
|
|
|
|
self.config.general.read_only,
|
|
|
|
|
self.config.general.global_key_bindings.to_owned(),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Hooks
|
|
|
|
|
if !self.hooks.on_mode_switch.is_empty() {
|
|
|
|
|
let msgs = self.hooks.on_mode_switch.clone();
|
|
|
|
|
self = self.handle_batch_external_msgs(msgs)?
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ok(self)
|
|
|
|
|
} else {
|
|
|
|
|
self.log_error(format!("Custom mode not found: {}", mode))
|
|
|
|
@ -1157,6 +1178,13 @@ impl App {
|
|
|
|
|
fn switch_layout(mut self, layout: &str) -> Result<Self> {
|
|
|
|
|
if let Some(l) = self.config.layouts.get(layout) {
|
|
|
|
|
self.layout = l.to_owned();
|
|
|
|
|
|
|
|
|
|
// Hooks
|
|
|
|
|
if !self.hooks.on_layout_switch.is_empty() {
|
|
|
|
|
let msgs = self.hooks.on_layout_switch.clone();
|
|
|
|
|
self = self.handle_batch_external_msgs(msgs)?
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ok(self)
|
|
|
|
|
} else {
|
|
|
|
|
self.log_error(format!("Layout not found: {}", layout))
|
|
|
|
@ -1166,6 +1194,13 @@ impl App {
|
|
|
|
|
fn switch_layout_builtin(mut self, layout: &str) -> Result<Self> {
|
|
|
|
|
if let Some(l) = self.config.layouts.builtin.get(layout) {
|
|
|
|
|
self.layout = l.to_owned();
|
|
|
|
|
|
|
|
|
|
// Hooks
|
|
|
|
|
if !self.hooks.on_layout_switch.is_empty() {
|
|
|
|
|
let msgs = self.hooks.on_layout_switch.clone();
|
|
|
|
|
self = self.handle_batch_external_msgs(msgs)?
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ok(self)
|
|
|
|
|
} else {
|
|
|
|
|
self.log_error(format!("Builtin layout not found: {}", layout))
|
|
|
|
@ -1175,6 +1210,13 @@ impl App {
|
|
|
|
|
fn switch_layout_custom(mut self, layout: &str) -> Result<Self> {
|
|
|
|
|
if let Some(l) = self.config.layouts.get_custom(layout) {
|
|
|
|
|
self.layout = l.to_owned();
|
|
|
|
|
|
|
|
|
|
// Hooks
|
|
|
|
|
if !self.hooks.on_layout_switch.is_empty() {
|
|
|
|
|
let msgs = self.hooks.on_layout_switch.clone();
|
|
|
|
|
self = self.handle_batch_external_msgs(msgs)?
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ok(self)
|
|
|
|
|
} else {
|
|
|
|
|
self.log_error(format!("Custom layout not found: {}", layout))
|
|
|
|
|