Rename EXECUTE mode to COMMAND

vim uses COMMAND, and we want to be consistent with vim when possible.
master
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
for their syntax.
You can save individual attachments with the
.Em EXECUTE
command
.Em COMMAND
.Cm save-attachment Ar INDEX Ar path-to-file
where
.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.
.Ss Drafts
To save your draft without sending it, issue
.Em EXECUTE
command
.Em COMMAND
.Cm close
and select 'save as draft'.
.sp
@ -359,9 +357,9 @@ for the complete account configuration values.
.Bl -tag -compact -width 8n
.It NORMAL
is the default mode
.It EXECUTE
.It COMMAND
commands are issued in
.Em EXECUTE
.Em COMMAND
mode, by default started with Space and exited with
.Cm Esc
key.
@ -372,7 +370,7 @@ captures all input as text input, and is exited with
.Cm Esc
key.
.El
.Ss EXECUTE Mode
.Ss COMMAND Mode
.Ss Mail listing commands
.Bl -tag -width 36n
.It Cm set Ar plain | threaded | compact | conversations

View File

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

View File

@ -19,7 +19,7 @@
* 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 melib::nom::{

View File

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

View File

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

View File

@ -666,7 +666,7 @@ impl StatusBar {
auto_complete: AutoComplete::new(Vec::new()),
progress_spinner: ProgressSpinner::new(3),
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) {
@ -714,7 +714,7 @@ impl StatusBar {
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"));
let (_, y) = write_string_to_grid(
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;
}
self.dirty = false;
@ -781,8 +781,8 @@ impl Component for StatusBar {
);
match self.mode {
UIMode::Normal => {}
UIMode::Execute => {
self.draw_execute_bar(
UIMode::Command => {
self.draw_command_bar(
grid,
(
set_y(upper_left, get_y(bottom_right) - height + 1),
@ -810,7 +810,7 @@ impl Component for StatusBar {
})
.collect();
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| {
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()) {
Some(e.into())
} else {
@ -1031,13 +1031,13 @@ impl Component for StatusBar {
&& self.cmd_history.last().map(String::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.ex_buffer.clear();
self.ex_buffer_cmd_history_pos.take();
}
UIMode::Execute => {
UIMode::Command => {
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() {
let mut utext = UText::new(suggestion);
let len = utext.as_str().len();
@ -1055,33 +1055,33 @@ impl Component for StatusBar {
self.ex_buffer = Field::Text(utext, None);
}
}
UIEvent::ExInput(Key::Char(c)) => {
UIEvent::CmdInput(Key::Char(c)) => {
self.dirty = true;
self.ex_buffer
.process_event(&mut UIEvent::InsertInput(Key::Char(*c)), context);
return true;
}
UIEvent::ExInput(Key::Paste(s)) => {
UIEvent::CmdInput(Key::Paste(s)) => {
self.dirty = true;
self.ex_buffer
.process_event(&mut UIEvent::InsertInput(Key::Paste(s.clone())), context);
return true;
}
UIEvent::ExInput(Key::Ctrl('u')) => {
UIEvent::CmdInput(Key::Ctrl('u')) => {
self.dirty = true;
self.ex_buffer.clear();
self.ex_buffer_cmd_history_pos.take();
return true;
}
UIEvent::ExInput(Key::Up) => {
UIEvent::CmdInput(Key::Up) => {
self.auto_complete.dec_cursor();
self.dirty = true;
}
UIEvent::ExInput(Key::Down) => {
UIEvent::CmdInput(Key::Down) => {
self.auto_complete.inc_cursor();
self.dirty = true;
}
UIEvent::ExInput(Key::Left) => {
UIEvent::CmdInput(Key::Left) => {
if let Field::Text(ref mut utext, _) = self.ex_buffer {
utext.cursor_dec();
} else {
@ -1091,7 +1091,7 @@ impl Component for StatusBar {
}
self.dirty = true;
}
UIEvent::ExInput(Key::Right) => {
UIEvent::CmdInput(Key::Right) => {
if let Field::Text(ref mut utext, _) = self.ex_buffer {
utext.cursor_inc();
} else {
@ -1101,7 +1101,7 @@ impl Component for StatusBar {
}
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 = Some(std::cmp::min(pos, self.cmd_history.len().saturating_sub(1)));
if pos != self.ex_buffer_cmd_history_pos {
@ -1120,7 +1120,7 @@ impl Component for StatusBar {
return true;
}
UIEvent::ExInput(Key::Ctrl('n')) => {
UIEvent::CmdInput(Key::Ctrl('n')) => {
if Some(0) == self.ex_buffer_cmd_history_pos {
self.ex_buffer_cmd_history_pos = None;
self.ex_buffer.clear();
@ -1142,13 +1142,13 @@ impl Component for StatusBar {
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.ex_buffer
.process_event(&mut UIEvent::InsertInput(k.clone()), context);
return true;
}
UIEvent::ExInput(Key::Esc) => {
UIEvent::CmdInput(Key::Esc) => {
self.ex_buffer.clear();
context
.replies
@ -1430,7 +1430,7 @@ impl Component for Tabbed {
}
let mut max_length = 6;
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<_>>();
shortcuts.sort_by_key(|(k, _)| *k);
@ -1481,7 +1481,7 @@ impl Component for Tabbed {
None,
);
write_string_to_grid(
"use EXECUTE command \"search\" to find shortcuts",
"use COMMAND \"search\" to find shortcuts",
&mut self.help_content,
Color::Default,
Color::Default,
@ -1809,10 +1809,10 @@ impl Component for Tabbed {
{
context
.replies
.push_back(UIEvent::ExInput(Key::Paste("search ".to_string())));
.push_back(UIEvent::CmdInput(Key::Paste("search ".to_string())));
context
.replies
.push_back(UIEvent::ChangeMode(UIMode::Execute));
.push_back(UIEvent::ChangeMode(UIMode::Command));
return true;
}
UIEvent::Input(ref key) if self.show_shortcuts => {

View File

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

View File

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

View File

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