Rename EXECUTE mode to COMMAND

vim uses COMMAND, and we want to be consistent with vim when possible.
memfd
Manos Pitsidianakis 2020-07-25 13:08:36 +03:00
parent b20bdea8f0
commit c2550f60b6
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
11 changed files with 48 additions and 50 deletions

12
meli.1
View File

@ -127,8 +127,7 @@ for the location of the mailcap files and
.Xr mailcap 5 .Xr mailcap 5
for their syntax. for their syntax.
You can save individual attachments with the You can save individual attachments with the
.Em EXECUTE .Em COMMAND
command
.Cm save-attachment Ar INDEX Ar path-to-file .Cm save-attachment Ar INDEX Ar path-to-file
where where
.Ar INDEX .Ar INDEX
@ -325,8 +324,7 @@ On complete failure to save your draft or sent message it will be saved in your
directory instead and you will be notified of its location. directory instead and you will be notified of its location.
.Ss Drafts .Ss Drafts
To save your draft without sending it, issue To save your draft without sending it, issue
.Em EXECUTE .Em COMMAND
command
.Cm close .Cm close
and select 'save as draft'. and select 'save as draft'.
.sp .sp
@ -359,9 +357,9 @@ for the complete account configuration values.
.Bl -tag -compact -width 8n .Bl -tag -compact -width 8n
.It NORMAL .It NORMAL
is the default mode is the default mode
.It EXECUTE .It COMMAND
commands are issued in commands are issued in
.Em EXECUTE .Em COMMAND
mode, by default started with Space and exited with mode, by default started with Space and exited with
.Cm Esc .Cm Esc
key. key.
@ -372,7 +370,7 @@ captures all input as text input, and is exited with
.Cm Esc .Cm Esc
key. key.
.El .El
.Ss EXECUTE Mode .Ss COMMAND Mode
.Ss Mail listing commands .Ss Mail listing commands
.Bl -tag -width 36n .Bl -tag -width 36n
.It Cm set Ar plain | threaded | compact | conversations .It Cm set Ar plain | threaded | compact | conversations

View File

@ -62,8 +62,8 @@ pub mod terminal;
use crate::terminal::*; use crate::terminal::*;
#[macro_use] #[macro_use]
pub mod execute; pub mod command;
use crate::execute::*; use crate::command::*;
pub mod state; pub mod state;
use crate::state::*; use crate::state::*;
@ -398,8 +398,8 @@ fn run_app(opt: Opt) -> Result<()> {
} }
}, },
Key::Char(' ') => { Key::Char(' ') => {
state.mode = UIMode::Execute; state.mode = UIMode::Command;
state.rcv_event(UIEvent::ChangeMode(UIMode::Execute)); state.rcv_event(UIEvent::ChangeMode(UIMode::Command));
state.redraw(); state.redraw();
} }
key => { key => {
@ -421,7 +421,7 @@ fn run_app(opt: Opt) -> Result<()> {
}, },
} }
} }
UIMode::Execute => { UIMode::Command => {
match k { match k {
Key::Char('\n') => { Key::Char('\n') => {
state.mode = UIMode::Normal; state.mode = UIMode::Normal;
@ -429,7 +429,7 @@ fn run_app(opt: Opt) -> Result<()> {
state.redraw(); state.redraw();
}, },
k => { k => {
state.rcv_event(UIEvent::ExInput(k)); state.rcv_event(UIEvent::CmdInput(k));
state.redraw(); state.redraw();
}, },
} }

View File

@ -19,7 +19,7 @@
* along with meli. If not, see <http://www.gnu.org/licenses/>. * along with meli. If not, see <http://www.gnu.org/licenses/>.
*/ */
/*! A parser module for user commands passed through the Execute mode. /*! A parser module for user commands passed through Command mode.
*/ */
use crate::melib::parser::BytesExt; use crate::melib::parser::BytesExt;
use melib::nom::{ use melib::nom::{

View File

@ -872,10 +872,10 @@ impl Component for Listing {
{ {
context context
.replies .replies
.push_back(UIEvent::ExInput(Key::Paste("search ".to_string()))); .push_back(UIEvent::CmdInput(Key::Paste("search ".to_string())));
context context
.replies .replies
.push_back(UIEvent::ChangeMode(UIMode::Execute)); .push_back(UIEvent::ChangeMode(UIMode::Command));
return true; return true;
} }
UIEvent::Input(ref key) UIEvent::Input(ref key)

View File

@ -415,7 +415,7 @@ impl Component for SVGScreenshotFilter {
if let UIEvent::Input(Key::F(6)) = event { if let UIEvent::Input(Key::F(6)) = event {
self.save_screenshot = true; self.save_screenshot = true;
true true
} else if let UIEvent::ExInput(Key::F(6)) = event { } else if let UIEvent::CmdInput(Key::F(6)) = event {
self.save_screenshot = true; self.save_screenshot = true;
true true
} else if let UIEvent::EmbedInput((Key::F(6), _)) = event { } else if let UIEvent::EmbedInput((Key::F(6), _)) = event {

View File

@ -666,7 +666,7 @@ impl StatusBar {
auto_complete: AutoComplete::new(Vec::new()), auto_complete: AutoComplete::new(Vec::new()),
progress_spinner: ProgressSpinner::new(3), progress_spinner: ProgressSpinner::new(3),
in_progress_jobs: HashSet::default(), in_progress_jobs: HashSet::default(),
cmd_history: crate::execute::history::old_cmd_history(), cmd_history: crate::command::history::old_cmd_history(),
} }
} }
fn draw_status_bar(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) { fn draw_status_bar(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
@ -714,7 +714,7 @@ impl StatusBar {
context.dirty_areas.push_back(area); context.dirty_areas.push_back(area);
} }
fn draw_execute_bar(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) { fn draw_command_bar(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
clear_area(grid, area, crate::conf::value(context, "theme_default")); clear_area(grid, area, crate::conf::value(context, "theme_default"));
let (_, y) = write_string_to_grid( let (_, y) = write_string_to_grid(
self.ex_buffer.as_str(), self.ex_buffer.as_str(),
@ -770,7 +770,7 @@ impl Component for StatusBar {
); );
} }
if self.mode != UIMode::Execute && !self.is_dirty() { if self.mode != UIMode::Command && !self.is_dirty() {
return; return;
} }
self.dirty = false; self.dirty = false;
@ -781,8 +781,8 @@ impl Component for StatusBar {
); );
match self.mode { match self.mode {
UIMode::Normal => {} UIMode::Normal => {}
UIMode::Execute => { UIMode::Command => {
self.draw_execute_bar( self.draw_command_bar(
grid, grid,
( (
set_y(upper_left, get_y(bottom_right) - height + 1), set_y(upper_left, get_y(bottom_right) - height + 1),
@ -810,7 +810,7 @@ impl Component for StatusBar {
}) })
.collect(); .collect();
let command_completion_suggestions = let command_completion_suggestions =
crate::execute::command_completion_suggestions(self.ex_buffer.as_str()); crate::command::command_completion_suggestions(self.ex_buffer.as_str());
suggestions.extend(command_completion_suggestions.iter().filter_map(|e| { suggestions.extend(command_completion_suggestions.iter().filter_map(|e| {
if !unique_suggestions.contains(e.as_str()) { if !unique_suggestions.contains(e.as_str()) {
@ -821,7 +821,7 @@ impl Component for StatusBar {
} }
})); }));
/* /*
suggestions.extend(crate::execute::COMMAND_COMPLETION.iter().filter_map(|e| { suggestions.extend(crate::command::COMMAND_COMPLETION.iter().filter_map(|e| {
if e.0.starts_with(self.ex_buffer.as_str()) { if e.0.starts_with(self.ex_buffer.as_str()) {
Some(e.into()) Some(e.into())
} else { } else {
@ -1031,13 +1031,13 @@ impl Component for StatusBar {
&& self.cmd_history.last().map(String::as_str) && self.cmd_history.last().map(String::as_str)
!= Some(self.ex_buffer.as_str()) != Some(self.ex_buffer.as_str())
{ {
crate::execute::history::log_cmd(self.ex_buffer.as_str().to_string()); crate::command::history::log_cmd(self.ex_buffer.as_str().to_string());
self.cmd_history.push(self.ex_buffer.as_str().to_string()); self.cmd_history.push(self.ex_buffer.as_str().to_string());
} }
self.ex_buffer.clear(); self.ex_buffer.clear();
self.ex_buffer_cmd_history_pos.take(); self.ex_buffer_cmd_history_pos.take();
} }
UIMode::Execute => { UIMode::Command => {
self.height = 2; self.height = 2;
} }
_ => { _ => {
@ -1045,7 +1045,7 @@ impl Component for StatusBar {
} }
}; };
} }
UIEvent::ExInput(Key::Char('\t')) => { UIEvent::CmdInput(Key::Char('\t')) => {
if let Some(suggestion) = self.auto_complete.get_suggestion() { if let Some(suggestion) = self.auto_complete.get_suggestion() {
let mut utext = UText::new(suggestion); let mut utext = UText::new(suggestion);
let len = utext.as_str().len(); let len = utext.as_str().len();
@ -1055,33 +1055,33 @@ impl Component for StatusBar {
self.ex_buffer = Field::Text(utext, None); self.ex_buffer = Field::Text(utext, None);
} }
} }
UIEvent::ExInput(Key::Char(c)) => { UIEvent::CmdInput(Key::Char(c)) => {
self.dirty = true; self.dirty = true;
self.ex_buffer self.ex_buffer
.process_event(&mut UIEvent::InsertInput(Key::Char(*c)), context); .process_event(&mut UIEvent::InsertInput(Key::Char(*c)), context);
return true; return true;
} }
UIEvent::ExInput(Key::Paste(s)) => { UIEvent::CmdInput(Key::Paste(s)) => {
self.dirty = true; self.dirty = true;
self.ex_buffer self.ex_buffer
.process_event(&mut UIEvent::InsertInput(Key::Paste(s.clone())), context); .process_event(&mut UIEvent::InsertInput(Key::Paste(s.clone())), context);
return true; return true;
} }
UIEvent::ExInput(Key::Ctrl('u')) => { UIEvent::CmdInput(Key::Ctrl('u')) => {
self.dirty = true; self.dirty = true;
self.ex_buffer.clear(); self.ex_buffer.clear();
self.ex_buffer_cmd_history_pos.take(); self.ex_buffer_cmd_history_pos.take();
return true; return true;
} }
UIEvent::ExInput(Key::Up) => { UIEvent::CmdInput(Key::Up) => {
self.auto_complete.dec_cursor(); self.auto_complete.dec_cursor();
self.dirty = true; self.dirty = true;
} }
UIEvent::ExInput(Key::Down) => { UIEvent::CmdInput(Key::Down) => {
self.auto_complete.inc_cursor(); self.auto_complete.inc_cursor();
self.dirty = true; self.dirty = true;
} }
UIEvent::ExInput(Key::Left) => { UIEvent::CmdInput(Key::Left) => {
if let Field::Text(ref mut utext, _) = self.ex_buffer { if let Field::Text(ref mut utext, _) = self.ex_buffer {
utext.cursor_dec(); utext.cursor_dec();
} else { } else {
@ -1091,7 +1091,7 @@ impl Component for StatusBar {
} }
self.dirty = true; self.dirty = true;
} }
UIEvent::ExInput(Key::Right) => { UIEvent::CmdInput(Key::Right) => {
if let Field::Text(ref mut utext, _) = self.ex_buffer { if let Field::Text(ref mut utext, _) = self.ex_buffer {
utext.cursor_inc(); utext.cursor_inc();
} else { } else {
@ -1101,7 +1101,7 @@ impl Component for StatusBar {
} }
self.dirty = true; self.dirty = true;
} }
UIEvent::ExInput(Key::Ctrl('p')) => { UIEvent::CmdInput(Key::Ctrl('p')) => {
let pos = self.ex_buffer_cmd_history_pos.map(|p| p + 1).unwrap_or(0); let pos = self.ex_buffer_cmd_history_pos.map(|p| p + 1).unwrap_or(0);
let pos = Some(std::cmp::min(pos, self.cmd_history.len().saturating_sub(1))); let pos = Some(std::cmp::min(pos, self.cmd_history.len().saturating_sub(1)));
if pos != self.ex_buffer_cmd_history_pos { if pos != self.ex_buffer_cmd_history_pos {
@ -1120,7 +1120,7 @@ impl Component for StatusBar {
return true; return true;
} }
UIEvent::ExInput(Key::Ctrl('n')) => { UIEvent::CmdInput(Key::Ctrl('n')) => {
if Some(0) == self.ex_buffer_cmd_history_pos { if Some(0) == self.ex_buffer_cmd_history_pos {
self.ex_buffer_cmd_history_pos = None; self.ex_buffer_cmd_history_pos = None;
self.ex_buffer.clear(); self.ex_buffer.clear();
@ -1142,13 +1142,13 @@ impl Component for StatusBar {
return true; return true;
} }
UIEvent::ExInput(k @ Key::Backspace) | UIEvent::ExInput(k @ Key::Ctrl(_)) => { UIEvent::CmdInput(k @ Key::Backspace) | UIEvent::CmdInput(k @ Key::Ctrl(_)) => {
self.dirty = true; self.dirty = true;
self.ex_buffer self.ex_buffer
.process_event(&mut UIEvent::InsertInput(k.clone()), context); .process_event(&mut UIEvent::InsertInput(k.clone()), context);
return true; return true;
} }
UIEvent::ExInput(Key::Esc) => { UIEvent::CmdInput(Key::Esc) => {
self.ex_buffer.clear(); self.ex_buffer.clear();
context context
.replies .replies
@ -1430,7 +1430,7 @@ impl Component for Tabbed {
} }
let mut max_length = 6; let mut max_length = 6;
let mut max_width = let mut max_width =
"Press ? to close, use EXECUTE command \"search\" to find shortcuts".len() + 3; "Press ? to close, use COMMAND \"search\" to find shortcuts".len() + 3;
let mut shortcuts = children_maps.iter().collect::<Vec<_>>(); let mut shortcuts = children_maps.iter().collect::<Vec<_>>();
shortcuts.sort_by_key(|(k, _)| *k); shortcuts.sort_by_key(|(k, _)| *k);
@ -1481,7 +1481,7 @@ impl Component for Tabbed {
None, None,
); );
write_string_to_grid( write_string_to_grid(
"use EXECUTE command \"search\" to find shortcuts", "use COMMAND \"search\" to find shortcuts",
&mut self.help_content, &mut self.help_content,
Color::Default, Color::Default,
Color::Default, Color::Default,
@ -1809,10 +1809,10 @@ impl Component for Tabbed {
{ {
context context
.replies .replies
.push_back(UIEvent::ExInput(Key::Paste("search ".to_string()))); .push_back(UIEvent::CmdInput(Key::Paste("search ".to_string())));
context context
.replies .replies
.push_back(UIEvent::ChangeMode(UIMode::Execute)); .push_back(UIEvent::ChangeMode(UIMode::Command));
return true; return true;
} }
UIEvent::Input(ref key) if self.show_shortcuts => { UIEvent::Input(ref key) if self.show_shortcuts => {

View File

@ -1390,9 +1390,9 @@ impl Account {
pub fn mailbox_operation( pub fn mailbox_operation(
&mut self, &mut self,
op: crate::execute::actions::MailboxOperation, op: crate::command::actions::MailboxOperation,
) -> Result<String> { ) -> Result<String> {
use crate::execute::actions::MailboxOperation; use crate::command::actions::MailboxOperation;
if self.settings.account.read_only() { if self.settings.account.read_only() {
return Err(MeliError::new("Account is read-only.")); return Err(MeliError::new("Account is read-only."));
} }

View File

@ -50,8 +50,8 @@ pub mod terminal;
use crate::terminal::*; use crate::terminal::*;
#[macro_use] #[macro_use]
pub mod execute; pub mod command;
use crate::execute::*; use crate::command::*;
pub mod state; pub mod state;
use crate::state::*; use crate::state::*;

View File

@ -35,7 +35,7 @@ extern crate serde;
mod helpers; mod helpers;
pub use self::helpers::*; pub use self::helpers::*;
use super::execute::Action; use super::command::Action;
use super::jobs::JobId; use super::jobs::JobId;
use super::terminal::*; use super::terminal::*;
use crate::components::{Component, ComponentId}; use crate::components::{Component, ComponentId};
@ -101,7 +101,7 @@ pub enum NotificationType {
#[derive(Debug)] #[derive(Debug)]
pub enum UIEvent { pub enum UIEvent {
Input(Key), Input(Key),
ExInput(Key), CmdInput(Key),
InsertInput(Key), InsertInput(Key),
EmbedInput((Key, Vec<u8>)), EmbedInput((Key, Vec<u8>)),
//Quit? //Quit?
@ -144,7 +144,7 @@ pub enum UIMode {
Insert, Insert,
/// Forward input to an embed pseudoterminal. /// Forward input to an embed pseudoterminal.
Embed, Embed,
Execute, Command,
Fork, Fork,
} }
@ -156,7 +156,7 @@ impl fmt::Display for UIMode {
match *self { match *self {
UIMode::Normal => "NORMAL", UIMode::Normal => "NORMAL",
UIMode::Insert => "INSERT", UIMode::Insert => "INSERT",
UIMode::Execute => "EX", UIMode::Command => "COMMAND",
UIMode::Fork => "FORK", UIMode::Fork => "FORK",
UIMode::Embed => "EMBED", UIMode::Embed => "EMBED",
} }